mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 02:49:19 +02:00
perf(instancing): cache instance rotation and group lod bands linearly
This commit is contained in:
@@ -664,6 +664,23 @@ void TAnimModel::RaPrepare()
|
||||
}
|
||||
}
|
||||
|
||||
glm::mat4 const &TAnimModel::rotation_scale() {
|
||||
|
||||
if( ( false == m_rotationscalevalid ) || ( vAngle != m_rotationscaleangles ) || ( m_scale != m_rotationscalescale ) ) {
|
||||
// same order as the per-instance render path
|
||||
glm::mat4 transform( 1.0f );
|
||||
if( vAngle.y != 0.0f ) { transform = glm::rotate( transform, glm::radians( vAngle.y ), glm::vec3( 0.f, 1.f, 0.f ) ); }
|
||||
if( vAngle.x != 0.0f ) { transform = glm::rotate( transform, glm::radians( vAngle.x ), glm::vec3( 1.f, 0.f, 0.f ) ); }
|
||||
if( vAngle.z != 0.0f ) { transform = glm::rotate( transform, glm::radians( vAngle.z ), glm::vec3( 0.f, 0.f, 1.f ) ); }
|
||||
if( m_scale != glm::vec3( 1.0f ) ) { transform = glm::scale( transform, m_scale ); }
|
||||
m_rotationscale = transform;
|
||||
m_rotationscaleangles = vAngle;
|
||||
m_rotationscalescale = m_scale;
|
||||
m_rotationscalevalid = true;
|
||||
}
|
||||
return m_rotationscale;
|
||||
}
|
||||
|
||||
int TAnimModel::Flags()
|
||||
{ // informacja dla TGround, czy ma być w Render, RenderAlpha, czy RenderMixed
|
||||
int i = pModel ? pModel->Flags() : 0; // pobranie flag całego modelu
|
||||
|
||||
@@ -172,6 +172,8 @@ public:
|
||||
public:
|
||||
// methods
|
||||
void RaPrepare(); // ustawienie animacji egzemplarza na wzorcu
|
||||
// rotation and scale of the instance as a matrix: rotate y * rotate x * rotate z * scale
|
||||
glm::mat4 const &rotation_scale();
|
||||
void RaAnimate( unsigned int const Framestamp ); // przeliczenie animacji egzemplarza
|
||||
|
||||
// radius() subclass details, calculates node's bounding radius
|
||||
@@ -190,6 +192,12 @@ public:
|
||||
TModel3d *pModel { nullptr };
|
||||
glm::vec3 vAngle; // bazowe obroty egzemplarza względem osi
|
||||
glm::vec3 m_scale { 1.0f, 1.0f, 1.0f }; // per-axis scale (see Scale() accessors above)
|
||||
// rotation and scale part of the instance transform, cached for the instanced render path.
|
||||
// rebuilt by rotation_scale() whenever the angles or the scale differ from the ones it was built from
|
||||
glm::mat4 m_rotationscale { 1.0f };
|
||||
glm::vec3 m_rotationscaleangles { 0.0f, 0.0f, 0.0f };
|
||||
glm::vec3 m_rotationscalescale { 1.0f, 1.0f, 1.0f };
|
||||
bool m_rotationscalevalid { false };
|
||||
material_data m_materialdata;
|
||||
|
||||
std::string asText; // tekst dla wyświetlacza znakowego
|
||||
|
||||
Reference in New Issue
Block a user