mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 16:19:19 +02:00
cache gauge sound position
This commit is contained in:
15
Gauge.cpp
15
Gauge.cpp
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user