16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 18:39:18 +02:00

cache gauge sound position

This commit is contained in:
milek7
2017-09-30 00:30:45 +02:00
parent cc61b8c00c
commit 7723e69ed3
2 changed files with 9 additions and 8 deletions

View File

@@ -50,6 +50,10 @@ void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale,
} }
else // a banan może być z optymalizacją? else // a banan może być z optymalizacją?
NewSubModel->WillBeAnimated(); // wyłączenie ignowania jedynkowego transformu NewSubModel->WillBeAnimated(); // wyłączenie ignowania jedynkowego transformu
float4x4 mat;
SubModel->ParentMatrix(&mat);
model_pos = *mat.TranslationGet();
} }
}; };
@@ -318,7 +322,6 @@ void TGauge::UpdateValue()
}; };
// todo: ugly approach to getting train translation // todo: ugly approach to getting train translation
// maybe cache gauge position
extern TWorld World; extern TWorld World;
@@ -331,14 +334,10 @@ void TGauge::play( sound *Sound )
if (SubModel && World.train()) if (SubModel && World.train())
{ {
float4x4 mat; if (glm::length(model_pos) > 1.0f)
SubModel->ParentMatrix(&mat);
glm::vec3 pos = *mat.TranslationGet();
if (glm::length(pos) > 1.0f)
{ {
pos = glm::vec3(glm::vec4(pos, 1.0f) * glm::inverse((glm::mat4)World.train()->Dynamic()->mMatrix)); auto pos = glm::vec3(glm::vec4(model_pos, 1.0f) * glm::inverse((glm::mat4)World.train()->Dynamic()->mMatrix));
pos = pos + (glm::vec3)World.train()->Dynamic()->GetPosition(); pos += (glm::vec3)World.train()->Dynamic()->GetPosition();
Sound->set_mode(sound::anchored).dist(1.5f).position(pos); Sound->set_mode(sound::anchored).dist(1.5f).position(pos);
} }

View File

@@ -50,6 +50,8 @@ class TGauge {
void void
play( sound* Sound ); play( sound* Sound );
glm::vec3 model_pos;
public: public:
TGauge() = default; TGauge() = default;
inline inline