mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 18:19:19 +02:00
use glm instead of Math3D in vehicle
WARNING: Model rotation is broken
This commit is contained in:
@@ -568,7 +568,7 @@ TTrain::TTrain() {
|
||||
fHaslerTimer = 0;
|
||||
DynamicSet(NULL); // ustawia wszystkie mv*
|
||||
//-----
|
||||
pMechSittingPosition = Math3D::vector3(0, 0, 0); // ABu: 180404
|
||||
pMechSittingPosition = glm::dvec3(0, 0, 0); // ABu: 180404
|
||||
fTachoTimer = 0.0; // włączenie skoków wskazań prędkościomierza
|
||||
|
||||
//
|
||||
@@ -5122,10 +5122,10 @@ void TTrain::OnCommand_redmarkerstoggle( TTrain *Train, command_data const &Comm
|
||||
|
||||
if( vehicle == nullptr ) { return; }
|
||||
|
||||
auto locationHead = vehicle->HeadPosition() - glm::dvec3(Command.location); // TODO: Maybe command_data should be dvec3?
|
||||
auto locationRear = vehicle->RearPosition() - glm::dvec3(Command.location);
|
||||
int const CouplNr {
|
||||
clamp(
|
||||
vehicle->DirectionGet()
|
||||
* ( Math3D::LengthSquared3( vehicle->HeadPosition() - Command.location ) > Math3D::LengthSquared3( vehicle->RearPosition() - Command.location ) ?
|
||||
clamp(vehicle->DirectionGet() * (glm::dot(locationHead, locationHead) > glm::dot(locationRear, locationRear) ?
|
||||
1 :
|
||||
-1 ),
|
||||
0, 1 ) }; // z [-1,1] zrobić [0,1]
|
||||
@@ -5147,11 +5147,11 @@ void TTrain::OnCommand_endsignalstoggle( TTrain *Train, command_data const &Comm
|
||||
auto *vehicle { std::get<TDynamicObject *>( simulation::Region->find_vehicle( Command.location, 10, false, true ) ) };
|
||||
|
||||
if( vehicle == nullptr ) { return; }
|
||||
|
||||
// TODO: Maybe command_data should be dvec3?
|
||||
int const CouplNr {
|
||||
clamp(
|
||||
vehicle->DirectionGet()
|
||||
* ( Math3D::LengthSquared3( vehicle->HeadPosition() - Command.location ) > Math3D::LengthSquared3( vehicle->RearPosition() - Command.location ) ?
|
||||
* ( Math3D::LengthSquared3( vehicle->HeadPosition() - glm::dvec3(Command.location) ) > Math3D::LengthSquared3( vehicle->RearPosition() - glm::dvec3(Command.location) ) ?
|
||||
1 :
|
||||
-1 ),
|
||||
0, 1 ) }; // z [-1,1] zrobić [0,1]
|
||||
@@ -9449,7 +9449,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
{
|
||||
*/
|
||||
// configure placement of sound emitters which aren't bound with any device model, and weren't placed manually
|
||||
auto const caboffset { glm::dvec3 { ( Cabine[ cabindex ].CabPos1 + Cabine[ cabindex ].CabPos2 ) * 0.5 } +glm::dvec3 { 0, 1, 0 } };
|
||||
auto const caboffset { glm::dvec3 { ( Cabine[ cabindex ].CabPos1 + Cabine[ cabindex ].CabPos2 ) * 0.5f } +glm::dvec3 { 0, 1, 0 } };
|
||||
// NOTE: since radiosound is an incomplete template not using std::optional it gets a special treatment
|
||||
if( m_radiosound.offset() == nullvector ) {
|
||||
m_radiosound.offset( btLampkaRadio.model_offset() );
|
||||
@@ -9517,15 +9517,15 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
return true;
|
||||
}
|
||||
|
||||
Math3D::vector3 TTrain::MirrorPosition(bool lewe)
|
||||
glm::dvec3 TTrain::MirrorPosition(bool lewe)
|
||||
{ // zwraca współrzędne widoku kamery z lusterka
|
||||
auto const shiftdirection { ( lewe ? -1 : 1 ) * ( iCabn == 2 ? 1 : -1 ) };
|
||||
|
||||
return DynamicObject->mMatrix
|
||||
* Math3D::vector3(
|
||||
return DynamicObject->mMatrix *
|
||||
glm::dvec4(
|
||||
mvOccupied->Dim.W * ( 0.5 * shiftdirection ) + ( 0.2 * shiftdirection ),
|
||||
1.5 + Cabine[iCabn].CabPos1.y,
|
||||
interpolate( Cabine[ iCabn ].CabPos1.z , Cabine[ iCabn ].CabPos2.z, 0.5 ) );
|
||||
interpolate( Cabine[ iCabn ].CabPos1.z , Cabine[ iCabn ].CabPos2.z, 0.5 ), 0.0 );
|
||||
};
|
||||
|
||||
void TTrain::DynamicSet(TDynamicObject *d)
|
||||
@@ -9697,23 +9697,23 @@ TTrain::MoveToVehicle(TDynamicObject *target) {
|
||||
}
|
||||
|
||||
// checks whether specified point is within boundaries of the active cab
|
||||
bool
|
||||
TTrain::point_inside( Math3D::vector3 const Point ) const {
|
||||
bool TTrain::point_inside(glm::dvec3 const Point) const
|
||||
{
|
||||
|
||||
return ( Point.x >= Cabine[ iCabn ].CabPos1.x ) && ( Point.x <= Cabine[ iCabn ].CabPos2.x )
|
||||
&& ( Point.y >= Cabine[ iCabn ].CabPos1.y + 0.5 ) && ( Point.y <= Cabine[ iCabn ].CabPos2.y + 1.8 )
|
||||
&& ( Point.z >= Cabine[ iCabn ].CabPos1.z ) && ( Point.z <= Cabine[ iCabn ].CabPos2.z );
|
||||
}
|
||||
|
||||
Math3D::vector3
|
||||
TTrain::clamp_inside( Math3D::vector3 const &Point ) const {
|
||||
glm::dvec3 TTrain::clamp_inside(glm::dvec3 const &Point) const
|
||||
{
|
||||
|
||||
if( DebugModeFlag ) { return Point; }
|
||||
|
||||
return {
|
||||
clamp( Point.x, Cabine[ iCabn ].CabPos1.x, Cabine[ iCabn ].CabPos2.x ),
|
||||
clamp( Point.y, Cabine[ iCabn ].CabPos1.y + 0.5, Cabine[ iCabn ].CabPos2.y + 1.8 ),
|
||||
clamp( Point.z, Cabine[ iCabn ].CabPos1.z, Cabine[ iCabn ].CabPos2.z ) };
|
||||
clamp( Point.x, (double)Cabine[ iCabn ].CabPos1.x, (double)Cabine[ iCabn ].CabPos2.x ),
|
||||
clamp( Point.y, (double)Cabine[ iCabn ].CabPos1.y + 0.5, (double)Cabine[ iCabn ].CabPos2.y + 1.8 ),
|
||||
clamp( Point.z, (double)Cabine[ iCabn ].CabPos1.z, (double)Cabine[ iCabn ].CabPos2.z ) };
|
||||
}
|
||||
|
||||
const TTrain::screenentry_sequence& TTrain::get_screens() {
|
||||
|
||||
Reference in New Issue
Block a user