From f56a2b67be6fb37de3d54e67dbe94b99a7ac830b Mon Sep 17 00:00:00 2001 From: milek7 Date: Sun, 9 Dec 2018 23:12:18 +0100 Subject: [PATCH] add hack for proper submodel offset calculation after t3d init, fixes cabin sound positioning --- Model3d.cpp | 19 +++++++++---------- Model3d.h | 2 ++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Model3d.cpp b/Model3d.cpp index 2977fa30..d8786796 100644 --- a/Model3d.cpp +++ b/Model3d.cpp @@ -779,6 +779,8 @@ int TSubModel::FlagsCheck() // samo pomijanie glBindTexture() nie poprawi wydajności // ale można sprawdzić, czy można w ogóle pominąć kod do tekstur (sprawdzanie // replaceskin) + m_rotation_init_done = true; + int i = 0; if (Child) { // Child jest renderowany po danym submodelu @@ -1237,16 +1239,10 @@ TSubModel::offset( float const Geometrytestoffsetthreshold ) const { } } - if( true == TestFlag( iFlags, 0x0200 ) ) { - // flip coordinates for t3d file which wasn't yet initialized - if( ( false == simulation::is_ready ) - || ( false == Vertices.empty() ) ) { - // NOTE, HACK: results require flipping if the model wasn't yet initialized, so we're using crude method to detect possible cases - // TODO: sort out this mess, either unify offset lookups to take place before (or after) initialization, - // or provide way to determine on submodel level whether the initialization took place - offset = { -offset.x, offset.z, offset.y }; - } - } + if (!m_rotation_init_done) + // NOTE, HACK: results require flipping if the model wasn't yet initialized, + // TODO: sort out this mess, maybe try unify offset lookups to take place before (or after) initialization, + offset = { -offset.x, offset.z, offset.y }; return offset; } @@ -1494,6 +1490,9 @@ void TSubModel::deserialize(std::istream &s) fCosFalloffAngle = sn_utils::ld_float32(s); fCosHotspotAngle = sn_utils::ld_float32(s); fCosViewAngle = sn_utils::ld_float32(s); + + // necessary rotations were already done during t3d->e3d conversion + m_rotation_init_done = true; } void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic) diff --git a/Model3d.h b/Model3d.h index 884dca3f..6a1536c3 100644 --- a/Model3d.h +++ b/Model3d.h @@ -119,6 +119,8 @@ private: float fCosHotspotAngle { 0.3f }; // cosinus kąta stożka pod którym widać aureolę i zwiększone natężenie światła float fCosViewAngle { 0.0f }; // cos kata pod jakim sie teraz patrzy + bool m_rotation_init_done = false; + TSubModel *Next { nullptr }; TSubModel *Child { nullptr }; public: // temporary access, clean this up during refactoring