mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 06:19:18 +02:00
Merge remote-tracking branch 'tmj/master' into sim
This commit is contained in:
@@ -7534,16 +7534,18 @@ void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// jeśli nic nie robi
|
// jeśli nic nie robi
|
||||||
|
OrderNext( Prepare_engine );
|
||||||
if( pVehicle->MoverParameters->iLights[ ( mvOccupied->CabActive < 0 ?
|
if( pVehicle->MoverParameters->iLights[ ( mvOccupied->CabActive < 0 ?
|
||||||
end::rear :
|
end::rear :
|
||||||
end::front ) ]
|
end::front ) ]
|
||||||
& ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) // któreś ze świateł zapalone?
|
& ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) // któreś ze świateł zapalone?
|
||||||
{ // od wersji 357 oczekujemy podania komend dla AI przez scenerię
|
{ // od wersji 357 oczekujemy podania komend dla AI przez scenerię
|
||||||
OrderNext( Prepare_engine );
|
/*
|
||||||
if( pVehicle->MoverParameters->iLights[ mvOccupied->CabActive < 0 ? end::rear : end::front ] & light::headlight_upper ) // górne światło zapalone
|
if( pVehicle->MoverParameters->iLights[ mvOccupied->CabActive < 0 ? end::rear : end::front ] & light::headlight_upper ) // górne światło zapalone
|
||||||
OrderNext( Obey_train ); // jazda pociągowa
|
OrderNext( Obey_train ); // jazda pociągowa
|
||||||
else
|
else
|
||||||
OrderNext( Shunt ); // jazda manewrowa
|
OrderNext( Shunt ); // jazda manewrowa
|
||||||
|
*/
|
||||||
if( mvOccupied->Vel >= 1.0 ) // jeśli jedzie (dla 0.1 ma stać)
|
if( mvOccupied->Vel >= 1.0 ) // jeśli jedzie (dla 0.1 ma stać)
|
||||||
iDrivigFlags &= ~moveStopHere; // to ma nie czekać na sygnał, tylko jechać
|
iDrivigFlags &= ~moveStopHere; // to ma nie czekać na sygnał, tylko jechać
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3159,7 +3159,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
&& ( MoverParameters->Doors.instances[ side::left ].open_permit
|
&& ( MoverParameters->Doors.instances[ side::left ].open_permit
|
||||||
|| MoverParameters->Doors.instances[ side::right ].open_permit ) ) };
|
|| MoverParameters->Doors.instances[ side::right ].open_permit ) ) };
|
||||||
|
|
||||||
if ((MoverParameters->Vel < 0.5) && (MoverParameters->BrakePress > 0.2 || doorisopen))
|
if ((MoverParameters->Vel < 0.5) && (eimic < 0 || doorisopen || MoverParameters->Hamulec->GetEDBCP()))
|
||||||
{
|
{
|
||||||
MoverParameters->ShuntMode = true;
|
MoverParameters->ShuntMode = true;
|
||||||
}
|
}
|
||||||
@@ -3184,8 +3184,8 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
{
|
{
|
||||||
Fzad = std::min(LBR * FmaxED, FfulED);
|
Fzad = std::min(LBR * FmaxED, FfulED);
|
||||||
}
|
}
|
||||||
if (((MoverParameters->ShuntMode) && (Frj < 0.0015 * masa)) ||
|
if (((MoverParameters->ShuntMode) && (eimic <= 0)) /*||
|
||||||
(MoverParameters->V * MoverParameters->DirAbsolute < -0.2))
|
(MoverParameters->V * MoverParameters->DirAbsolute < -0.2)*/)
|
||||||
{
|
{
|
||||||
auto const sbd { ( ( MoverParameters->SpringBrake.IsActive && MoverParameters->ReleaseParkingBySpringBrake ) ? 0.0 : MoverParameters->StopBrakeDecc ) };
|
auto const sbd { ( ( MoverParameters->SpringBrake.IsActive && MoverParameters->ReleaseParkingBySpringBrake ) ? 0.0 : MoverParameters->StopBrakeDecc ) };
|
||||||
Fzad = std::max( Fzad, sbd * masa );
|
Fzad = std::max( Fzad, sbd * masa );
|
||||||
|
|||||||
@@ -7059,7 +7059,8 @@ void TMoverParameters::CheckEIMIC(double dt)
|
|||||||
( ( true == Mains ) || ( Power == 0.0 ) )
|
( ( true == Mains ) || ( Power == 0.0 ) )
|
||||||
&& ( ( Doors.instances[ side::left ].open_permit == false )
|
&& ( ( Doors.instances[ side::left ].open_permit == false )
|
||||||
&& ( Doors.instances[ side::right ].open_permit == false ) )
|
&& ( Doors.instances[ side::right ].open_permit == false ) )
|
||||||
&& ( !SpringBrake.IsActive ) };
|
&& ( !SpringBrake.IsActive )
|
||||||
|
&& ( !LockPipe ) };
|
||||||
eimic = clamp(eimic, -1.0, eimicpowerenabled ? 1.0 : 0.0);
|
eimic = clamp(eimic, -1.0, eimicpowerenabled ? 1.0 : 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
Model3d.cpp
27
Model3d.cpp
@@ -446,8 +446,9 @@ std::pair<int, int> TSubModel::Load( cParser &parser, bool dynamic )
|
|||||||
0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta
|
0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta
|
||||||
}
|
}
|
||||||
// and same thing with selfillum
|
// and same thing with selfillum
|
||||||
if (!std::isnan(mat.selfillum))
|
if( mat.selfillum ) {
|
||||||
fLight = mat.selfillum;
|
fLight = mat.selfillum.value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_material > 0)
|
if (m_material > 0)
|
||||||
@@ -455,18 +456,18 @@ std::pair<int, int> TSubModel::Load( cParser &parser, bool dynamic )
|
|||||||
const opengl_material &mat = GfxRenderer->Material(m_material);
|
const opengl_material &mat = GfxRenderer->Material(m_material);
|
||||||
|
|
||||||
// if material have opacity set, replace submodel opacity with it
|
// if material have opacity set, replace submodel opacity with it
|
||||||
if (!std::isnan(mat.opacity))
|
if (mat.opacity)
|
||||||
{
|
{
|
||||||
iFlags &= ~0x30;
|
iFlags &= ~0x30;
|
||||||
if (mat.opacity == 0.0f)
|
if (*mat.opacity == 0.0f)
|
||||||
iFlags |= 0x20; // translucent
|
iFlags |= 0x20; // translucent
|
||||||
else
|
else
|
||||||
iFlags |= 0x10; // opaque
|
iFlags |= 0x10; // opaque
|
||||||
}
|
}
|
||||||
|
|
||||||
// and same thing with selfillum
|
// and same thing with selfillum
|
||||||
if (!std::isnan(mat.selfillum))
|
if (mat.selfillum)
|
||||||
fLight = mat.selfillum;
|
fLight = *mat.selfillum;
|
||||||
}
|
}
|
||||||
|
|
||||||
// visibility range
|
// visibility range
|
||||||
@@ -2059,11 +2060,12 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
|
|||||||
if (!(iFlags & 0x30) && m_material != null_handle)
|
if (!(iFlags & 0x30) && m_material != null_handle)
|
||||||
{
|
{
|
||||||
const opengl_material &mat = GfxRenderer->Material(m_material);
|
const opengl_material &mat = GfxRenderer->Material(m_material);
|
||||||
float opacity = mat.opacity;
|
float opacity;
|
||||||
|
if (mat.opacity)
|
||||||
|
opacity = *mat.opacity;
|
||||||
// if material don't have opacity set, try to guess it
|
// if material don't have opacity set, try to guess it
|
||||||
if (std::isnan(opacity))
|
else
|
||||||
opacity = mat.get_or_guess_opacity();
|
opacity = mat.get_or_guess_opacity();
|
||||||
|
|
||||||
// set phase flag based on material opacity
|
// set phase flag based on material opacity
|
||||||
if (opacity == 0.0f)
|
if (opacity == 0.0f)
|
||||||
@@ -2077,8 +2079,9 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
|
|||||||
opengl_material const &mat = GfxRenderer->Material(m_material);
|
opengl_material const &mat = GfxRenderer->Material(m_material);
|
||||||
|
|
||||||
// replace submodel selfillum with material one
|
// replace submodel selfillum with material one
|
||||||
if (!std::isnan(mat.selfillum))
|
if( mat.selfillum ) {
|
||||||
fLight = mat.selfillum;
|
fLight = mat.selfillum.value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ basic_vertex::deserialize_packed( std::istream &s, bool const Tangent ) {
|
|||||||
// based on
|
// based on
|
||||||
// Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”.
|
// Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”.
|
||||||
// Terathon Software, 2001. http://terathon.com/code/tangent.html
|
// Terathon Software, 2001. http://terathon.com/code/tangent.html
|
||||||
void calculate_tangents(vertex_array &vertices, const index_array &indices, int type)
|
void calculate_tangents(vertex_array &vertices, index_array const &indices, int const type)
|
||||||
{
|
{
|
||||||
size_t vertex_count = vertices.size();
|
size_t vertex_count = vertices.size();
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ void calculate_indices( index_array &Indices, vertex_array &Vertices, float tole
|
|||||||
|
|
||||||
Indices.resize( Vertices.size() );
|
Indices.resize( Vertices.size() );
|
||||||
std::iota( std::begin( Indices ), std::end( Indices ), 0 );
|
std::iota( std::begin( Indices ), std::end( Indices ), 0 );
|
||||||
// gather instances of used verices, replace the original vertex bank with it after you're done
|
// gather instances of used vertices, replace the original vertex bank with it after you're done
|
||||||
vertex_array indexedvertices;
|
vertex_array indexedvertices;
|
||||||
indexedvertices.reserve( std::max<size_t>( 100, Vertices.size() / 3 ) ); // optimistic guesstimate, but should reduce re-allocation somewhat
|
indexedvertices.reserve( std::max<size_t>( 100, Vertices.size() / 3 ) ); // optimistic guesstimate, but should reduce re-allocation somewhat
|
||||||
auto const matchtolerance { 1e-5f * tolerancescale };
|
auto const matchtolerance { 1e-5f * tolerancescale };
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ using basic_index = std::uint32_t;
|
|||||||
using vertex_array = std::vector<basic_vertex>;
|
using vertex_array = std::vector<basic_vertex>;
|
||||||
using index_array = std::vector<basic_index>;
|
using index_array = std::vector<basic_index>;
|
||||||
|
|
||||||
void calculate_tangents(vertex_array &vertices, const index_array &indices, int type);
|
void calculate_tangents( vertex_array &vertices, index_array const &indices, int const type );
|
||||||
void calculate_indices(index_array &Indices, vertex_array &Vertices, float tolerancescale = 1.0f);
|
void calculate_indices( index_array &Indices, vertex_array &Vertices, float tolerancescale = 1.0f );
|
||||||
|
|
||||||
// generic geometry bank class, allows storage, update and drawing of geometry chunks
|
// generic geometry bank class, allows storage, update and drawing of geometry chunks
|
||||||
|
|
||||||
|
|||||||
@@ -426,9 +426,9 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c
|
|||||||
|
|
||||||
float opengl_material::get_or_guess_opacity() const {
|
float opengl_material::get_or_guess_opacity() const {
|
||||||
|
|
||||||
if (!std::isnan(opacity))
|
if( opacity ) {
|
||||||
return opacity;
|
return opacity.value();
|
||||||
|
}
|
||||||
if (textures[0] != null_handle)
|
if (textures[0] != null_handle)
|
||||||
{
|
{
|
||||||
auto const &tex = GfxRenderer->Texture(textures[0]);
|
auto const &tex = GfxRenderer->Texture(textures[0]);
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ struct opengl_material {
|
|||||||
std::vector<gl::shader::param_entry> params_state;
|
std::vector<gl::shader::param_entry> params_state;
|
||||||
|
|
||||||
std::shared_ptr<gl::program> shader;
|
std::shared_ptr<gl::program> shader;
|
||||||
float opacity = std::numeric_limits<float>::quiet_NaN();
|
std::optional<float> opacity;
|
||||||
float selfillum = std::numeric_limits<float>::quiet_NaN();
|
std::optional<float> selfillum;
|
||||||
float glossiness { 10.f };
|
float glossiness { 10.f };
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|||||||
@@ -1874,7 +1874,7 @@ gfx::geometry_handle opengl33_renderer::Insert( gfx::index_array &Indices, gfx::
|
|||||||
// creates a new geometry chunk of specified type from supplied data, in specified bank. returns: handle to the chunk or NULL
|
// creates a new geometry chunk of specified type from supplied data, in specified bank. returns: handle to the chunk or NULL
|
||||||
gfx::geometry_handle opengl33_renderer::Insert(gfx::vertex_array &Vertices, gfx::geometrybank_handle const &Geometry, int const Type)
|
gfx::geometry_handle opengl33_renderer::Insert(gfx::vertex_array &Vertices, gfx::geometrybank_handle const &Geometry, int const Type)
|
||||||
{
|
{
|
||||||
gfx::calculate_tangents(Vertices, gfx::index_array(), Type);
|
gfx::calculate_tangents(Vertices, gfx::index_array(), Type);
|
||||||
|
|
||||||
return m_geometry.create_chunk(Vertices, Geometry, Type);
|
return m_geometry.create_chunk(Vertices, Geometry, Type);
|
||||||
}
|
}
|
||||||
@@ -1882,7 +1882,7 @@ gfx::geometry_handle opengl33_renderer::Insert(gfx::vertex_array &Vertices, gfx:
|
|||||||
// replaces data of specified chunk with the supplied vertex data, starting from specified offset
|
// replaces data of specified chunk with the supplied vertex data, starting from specified offset
|
||||||
bool opengl33_renderer::Replace(gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, int const Type, std::size_t const Offset)
|
bool opengl33_renderer::Replace(gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, int const Type, std::size_t const Offset)
|
||||||
{
|
{
|
||||||
gfx::calculate_tangents(Vertices, gfx::index_array(), Type);
|
gfx::calculate_tangents(Vertices, gfx::index_array(), Type);
|
||||||
|
|
||||||
return m_geometry.replace(Vertices, Geometry, Offset);
|
return m_geometry.replace(Vertices, Geometry, Offset);
|
||||||
}
|
}
|
||||||
@@ -1890,7 +1890,7 @@ bool opengl33_renderer::Replace(gfx::vertex_array &Vertices, gfx::geometry_handl
|
|||||||
// adds supplied vertex data at the end of specified chunk
|
// adds supplied vertex data at the end of specified chunk
|
||||||
bool opengl33_renderer::Append(gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, int const Type)
|
bool opengl33_renderer::Append(gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, int const Type)
|
||||||
{
|
{
|
||||||
gfx::calculate_tangents(Vertices, gfx::index_array(), Type);
|
gfx::calculate_tangents(Vertices, gfx::index_array(), Type);
|
||||||
|
|
||||||
return m_geometry.append(Vertices, Geometry);
|
return m_geometry.append(Vertices, Geometry);
|
||||||
}
|
}
|
||||||
@@ -2019,11 +2019,11 @@ void opengl33_renderer::Bind_Material( material_handle const Material, TSubModel
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if( !std::isnan( material.opacity ) ) {
|
if( material.opacity ) {
|
||||||
model_ubs.opacity = (
|
model_ubs.opacity = (
|
||||||
m_blendingenabled ?
|
m_blendingenabled ?
|
||||||
-material.opacity :
|
-material.opacity.value() :
|
||||||
material.opacity );
|
material.opacity.value() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
model_ubs.opacity = (
|
model_ubs.opacity = (
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ glm::vec4 sn_utils::d_vec4( std::istream& s )
|
|||||||
uint8_t sn_utils::d_uint8( std::istream& s ) {
|
uint8_t sn_utils::d_uint8( std::istream& s ) {
|
||||||
|
|
||||||
uint8_t buf;
|
uint8_t buf;
|
||||||
s.read((char*)&buf, 1);
|
s.read((char*)&buf, 1);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user