mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 18:56:49 +01:00
refactor(vehicle): AnimModel.h, Sweep.h and Camera.h no longer include DynObj.h
The scenery models (AnimModel.h), the sweeps (Sweep.h) and the camera
(Camera.h, which Globals.h includes) pulled in the whole vehicle header, for
one structure (material_data) and a pointer type.
- model/materialdata.h/.cpp: material_data and TextureTest(), moved from
DynObj.h/.cpp as they were
- Camera.h names TDynamicObject through utilities/Classes.h
- Classes.h includes interfaces/ITexture.h for null_handle, the value of the
handles it defines; AnimModel.h includes utilities/Names.h for basic_table
itself. Both came through DynObj.h before.
- the files that use the vehicles include vehicle/DynObj.h themselves
164 of the 730 objects of the build depend on DynObj.h now, 304 before.
No change in behaviour: 1142/1142 tests, golden traces exact against staging
62f7a29b.
This commit is contained in:
@@ -213,6 +213,7 @@ set(SOURCES
|
||||
"input/drivermouseinput.cpp"
|
||||
"utilities/translation.cpp"
|
||||
"model/material.cpp"
|
||||
"model/materialdata.cpp"
|
||||
"stdafx.cpp"
|
||||
"input/messaging.cpp"
|
||||
"scene/scene.cpp"
|
||||
|
||||
@@ -21,6 +21,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "scene/scenenodegroups.h"
|
||||
#include "application/editoruilayer.h"
|
||||
#include "physics/mover.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#ifndef _WIN32
|
||||
#include <spawn.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -22,6 +22,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/Logs.h"
|
||||
#include "utilities/utilities.h"
|
||||
#include "physics/mover.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
|
||||
auto const EU07_CONTROLLER_MOUSESLIDERSIZE{ 0.6 };
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/Timer.h"
|
||||
#include "utilities/Logs.h"
|
||||
#include "rendering/renderer.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
|
||||
std::list<std::weak_ptr<TAnimContainer>> TAnimModel::acAnimList;
|
||||
|
||||
|
||||
+2
-1
@@ -17,7 +17,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/Classes.h"
|
||||
#include "utilities/Float3d.h"
|
||||
#include "model/Model3d.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#include "model/materialdata.h"
|
||||
#include "utilities/Names.h"
|
||||
#include "scene/scenenode.h"
|
||||
|
||||
const int iMaxNumLights = 8;
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "model/materialdata.h"
|
||||
|
||||
#include "model/Texture.h"
|
||||
#include "rendering/renderer.h"
|
||||
#include "utilities/parser.h"
|
||||
#include "utilities/utilities.h"
|
||||
#include "utilities/Globals.h"
|
||||
|
||||
// Ra 2015-01: sprawdzenie dostępności tekstury o podanej nazwie
|
||||
std::string
|
||||
TextureTest( std::string const &Name ) {
|
||||
|
||||
auto const lookup {
|
||||
FileExists(
|
||||
{ Global.asCurrentTexturePath + Name, Name, paths::textures + Name },
|
||||
{ ".mat", ".dds", ".tga", ".ktx", ".png", ".bmp", ".jpg", ".tex" } ) };
|
||||
|
||||
return lookup.first + lookup.second;
|
||||
}
|
||||
|
||||
// assigns specified texture or a group of textures to replacable texture slots
|
||||
void
|
||||
material_data::assign( std::string const &Replacableskin ) {
|
||||
|
||||
// a template puts its parameter after a folder ("tabl/(p6)"): a texture made by a script given there keeps its scheme
|
||||
if( auto const scheme { Replacableskin.find( "/make:" ) };
|
||||
scheme != std::string::npos
|
||||
&& false == contains( Replacableskin, '|' ) ) {
|
||||
assign( Replacableskin.substr( scheme + 1 ) );
|
||||
return;
|
||||
}
|
||||
// check for the pipe method first
|
||||
if( contains( Replacableskin, '|' ) ) {
|
||||
cParser nameparser( Replacableskin );
|
||||
nameparser.getTokens( 4, false, "|" );
|
||||
int skinindex = 0;
|
||||
std::string texturename; nameparser >> texturename;
|
||||
while( texturename != "" && skinindex < 4 ) {
|
||||
replacable_skins[ skinindex + 1 ] = GfxRenderer->Fetch_Material( texturename );
|
||||
++skinindex;
|
||||
texturename = ""; nameparser >> texturename;
|
||||
}
|
||||
multi_textures = skinindex;
|
||||
}
|
||||
else {
|
||||
// otherwise try the basic approach
|
||||
int skinindex = 0;
|
||||
do {
|
||||
// test quietly for file existence so we don't generate tons of false errors in the log
|
||||
// NOTE: this means actual missing files won't get reported which is hardly ideal, but still somewhat better
|
||||
auto const material { TextureTest( ToLower( Replacableskin + "," + std::to_string( skinindex + 1 ) ) ) };
|
||||
if( true == material.empty() ) { break; }
|
||||
|
||||
replacable_skins[ skinindex + 1 ] = GfxRenderer->Fetch_Material( material );
|
||||
++skinindex;
|
||||
} while( skinindex < 4 );
|
||||
multi_textures = skinindex;
|
||||
if( multi_textures == 0 ) {
|
||||
// zestaw nie zadziałał, próbujemy normanie
|
||||
replacable_skins[ 1 ] = GfxRenderer->Fetch_Material( Replacableskin );
|
||||
}
|
||||
}
|
||||
if( replacable_skins[ 1 ] == null_handle ) {
|
||||
// last ditch attempt, check for single replacable skin texture
|
||||
replacable_skins[ 1 ] = GfxRenderer->Fetch_Material( Replacableskin );
|
||||
}
|
||||
|
||||
// BUGS! it's not entierly designed whether opacity is property of material or submodel,
|
||||
// and code does confusing things with this in various places
|
||||
textures_alpha = GfxRenderer->Material(replacable_skins[1])->is_translucent() ? 0x31310031 : // tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||
0x30300030; // wszystkie tekstury nieprzezroczyste - nie renderować w cyklu przezroczystych
|
||||
if( GfxRenderer->Material( replacable_skins[ 2 ] )->is_translucent() ) {
|
||||
// tekstura -2 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||
textures_alpha |= 0x02020002;
|
||||
}
|
||||
if( GfxRenderer->Material( replacable_skins[ 3 ] )->is_translucent() ) {
|
||||
// tekstura -3 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||
textures_alpha |= 0x04040004;
|
||||
}
|
||||
if( GfxRenderer->Material( replacable_skins[ 4 ] )->is_translucent() ) {
|
||||
// tekstura -4 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||
textures_alpha |= 0x08080008;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
// the replaceable skins of a model: the textures a vehicle or a scenery model puts in place of the replaceable ones
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "interfaces/IMaterial.h"
|
||||
#include "utilities/Classes.h"
|
||||
|
||||
struct material_data {
|
||||
|
||||
int textures_alpha{ 0x30300030 }; // maska przezroczystości tekstur. default: tekstury wymienne nie mają przezroczystości
|
||||
material_handle replacable_skins[ 5 ] = { null_handle, null_handle, null_handle, null_handle, null_handle }; // McZapkie:zmienialne nadwozie
|
||||
int multi_textures{ 0 }; //<0 tekstury wskazane wpisem, >0 tekstury z przecinkami, =0 jedna
|
||||
|
||||
// assigns specified texture or a group of textures to replacable texture slots
|
||||
void assign( std::string const &Replacableskin );
|
||||
};
|
||||
|
||||
// the file of the texture or the material of the given name, looked up as the models do; empty when there is none
|
||||
std::string TextureTest( std::string const &Name );
|
||||
@@ -19,6 +19,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "model/Model3d.h"
|
||||
#include "utilities/Globals.h"
|
||||
#include "utilities/utilities.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "rendering/screenshot.h"
|
||||
#include "rendering/editoroverlay.h"
|
||||
#include "physics/mover.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#include <imgui/imgui_impl_opengl3.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -17,6 +17,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/Logs.h"
|
||||
#include "vehicle/smoke.h"
|
||||
#include "physics/mover.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
|
||||
|
||||
void
|
||||
|
||||
@@ -24,6 +24,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/Logs.h"
|
||||
#include "utilities/color.h"
|
||||
#include "utilities/utilities.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
|
||||
@@ -25,6 +25,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "widgets/map_objects.h"
|
||||
#include "vehicle/aiwire.h"
|
||||
#include "physics/mover.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "input/command.h"
|
||||
#include "utilities/Timer.h"
|
||||
#include "vehicle/Camera.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
|
||||
// the view matrix of the camera (TCamera::SetMatrix): the pitch (Angle.x) and the yaw (Angle.y) give the line of sight,
|
||||
// the roll (Angle.z) turns the view about that line, wherever the camera looks. The roll comes from the sway of the cab
|
||||
|
||||
@@ -9,6 +9,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifndef ClassesH
|
||||
#define ClassesH
|
||||
|
||||
#include "interfaces/ITexture.h" // null_handle, for the handles below
|
||||
//---------------------------------------------------------------------------
|
||||
// Ra: zestaw klas do robienia wskaźników, aby uporządkować nagłówki
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include "input/command.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#include "utilities/Classes.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -78,18 +78,6 @@ GetSubmodelFromName( TModel3d * const Model, std::string const Name ) {
|
||||
return Model ? Model->GetFromName(Name) : nullptr;
|
||||
}
|
||||
|
||||
// Ra 2015-01: sprawdzenie dostępności tekstury o podanej nazwie
|
||||
std::string
|
||||
TextureTest( std::string const &Name ) {
|
||||
|
||||
auto const lookup {
|
||||
FileExists(
|
||||
{ Global.asCurrentTexturePath + Name, Name, paths::textures + Name },
|
||||
{ ".mat", ".dds", ".tga", ".ktx", ".png", ".bmp", ".jpg", ".tex" } ) };
|
||||
|
||||
return lookup.first + lookup.second;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void TAnimPant::common_pantograph_settings()
|
||||
{ // wspólne ustawienia, liczone po przypisaniu wymiarów ramion
|
||||
@@ -258,72 +246,6 @@ void TAnim::Parovoz(){
|
||||
*/
|
||||
|
||||
|
||||
// assigns specified texture or a group of textures to replacable texture slots
|
||||
void
|
||||
material_data::assign( std::string const &Replacableskin ) {
|
||||
|
||||
// a template puts its parameter after a folder ("tabl/(p6)"): a texture made by a script given there keeps its scheme
|
||||
if( auto const scheme { Replacableskin.find( "/make:" ) };
|
||||
scheme != std::string::npos
|
||||
&& false == contains( Replacableskin, '|' ) ) {
|
||||
assign( Replacableskin.substr( scheme + 1 ) );
|
||||
return;
|
||||
}
|
||||
// check for the pipe method first
|
||||
if( contains( Replacableskin, '|' ) ) {
|
||||
cParser nameparser( Replacableskin );
|
||||
nameparser.getTokens( 4, false, "|" );
|
||||
int skinindex = 0;
|
||||
std::string texturename; nameparser >> texturename;
|
||||
while( texturename != "" && skinindex < 4 ) {
|
||||
replacable_skins[ skinindex + 1 ] = GfxRenderer->Fetch_Material( texturename );
|
||||
++skinindex;
|
||||
texturename = ""; nameparser >> texturename;
|
||||
}
|
||||
multi_textures = skinindex;
|
||||
}
|
||||
else {
|
||||
// otherwise try the basic approach
|
||||
int skinindex = 0;
|
||||
do {
|
||||
// test quietly for file existence so we don't generate tons of false errors in the log
|
||||
// NOTE: this means actual missing files won't get reported which is hardly ideal, but still somewhat better
|
||||
auto const material { TextureTest( ToLower( Replacableskin + "," + std::to_string( skinindex + 1 ) ) ) };
|
||||
if( true == material.empty() ) { break; }
|
||||
|
||||
replacable_skins[ skinindex + 1 ] = GfxRenderer->Fetch_Material( material );
|
||||
++skinindex;
|
||||
} while( skinindex < 4 );
|
||||
multi_textures = skinindex;
|
||||
if( multi_textures == 0 ) {
|
||||
// zestaw nie zadziałał, próbujemy normanie
|
||||
replacable_skins[ 1 ] = GfxRenderer->Fetch_Material( Replacableskin );
|
||||
}
|
||||
}
|
||||
if( replacable_skins[ 1 ] == null_handle ) {
|
||||
// last ditch attempt, check for single replacable skin texture
|
||||
replacable_skins[ 1 ] = GfxRenderer->Fetch_Material( Replacableskin );
|
||||
}
|
||||
|
||||
// BUGS! it's not entierly designed whether opacity is property of material or submodel,
|
||||
// and code does confusing things with this in various places
|
||||
textures_alpha = GfxRenderer->Material(replacable_skins[1])->is_translucent() ? 0x31310031 : // tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||
0x30300030; // wszystkie tekstury nieprzezroczyste - nie renderować w cyklu przezroczystych
|
||||
if( GfxRenderer->Material( replacable_skins[ 2 ] )->is_translucent() ) {
|
||||
// tekstura -2 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||
textures_alpha |= 0x02020002;
|
||||
}
|
||||
if( GfxRenderer->Material( replacable_skins[ 3 ] )->is_translucent() ) {
|
||||
// tekstura -3 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||
textures_alpha |= 0x04040004;
|
||||
}
|
||||
if( GfxRenderer->Material( replacable_skins[ 4 ] )->is_translucent() ) {
|
||||
// tekstura -4 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||
textures_alpha |= 0x08080008;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
// a luadestinationsign: or wasmdestinationsign: block, its script in the vehicle folder when it has no path of its own
|
||||
|
||||
+1
-10
@@ -14,6 +14,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "utilities/Classes.h"
|
||||
#include "interfaces/IMaterial.h"
|
||||
#include "model/materialdata.h"
|
||||
#include "physics/vehicletypes.h"
|
||||
#include "physics/derailment.h"
|
||||
#include "vehicle/derailmotion.h"
|
||||
@@ -189,16 +190,6 @@ enum class announcement_t : int {
|
||||
};
|
||||
|
||||
// parameters for the material object, as currently used by various simulator models
|
||||
struct material_data {
|
||||
|
||||
int textures_alpha{ 0x30300030 }; // maska przezroczystości tekstur. default: tekstury wymienne nie mają przezroczystości
|
||||
material_handle replacable_skins[ 5 ] = { null_handle, null_handle, null_handle, null_handle, null_handle }; // McZapkie:zmienialne nadwozie
|
||||
int multi_textures{ 0 }; //<0 tekstury wskazane wpisem, >0 tekstury z przecinkami, =0 jedna
|
||||
|
||||
// assigns specified texture or a group of textures to replacable texture slots
|
||||
void assign( std::string const &Replacableskin );
|
||||
};
|
||||
|
||||
class TDynamicObject { // klasa pojazdu
|
||||
|
||||
friend opengl46_renderer;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "vehicle/Driver.h"
|
||||
#include "model/AnimModel.h"
|
||||
#include "application/application.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
|
||||
ui::map_panel::map_panel() : ui_panel(STR_C("Map"), false)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "simulation/simulation.h"
|
||||
#include "utilities/utilities.h"
|
||||
#include "physics/mover.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "scene/scenenode.h"
|
||||
#include "world/Road.h"
|
||||
#include "world/Segment.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#include "model/materialdata.h"
|
||||
|
||||
namespace scene
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user