diff --git a/components/nif/nif_file.cpp b/components/nif/nif_file.cpp index 52a37ba5c..80ea7a0b7 100644 --- a/components/nif/nif_file.cpp +++ b/components/nif/nif_file.cpp @@ -162,6 +162,15 @@ void NIFFile::parse() r->recName = rec; records[i] = r; r->read(this); + + // Discard tranformations for the root node, otherwise some meshes + // occasionally get wrong orientation. Only for NiNode-s for now, but + // can be expanded if needed. + // This should be rewritten when the method is cleaned up. + if (0 == i && rec == "NiNode") + { + static_cast(r)->trafo = Nif::Transformation::getIdentity(); + } } /* After the data, the nif contains an int N and then a list of N diff --git a/components/nif/nif_types.hpp b/components/nif/nif_types.hpp index 17cec19bc..ce7a0de62 100644 --- a/components/nif/nif_types.hpp +++ b/components/nif/nif_types.hpp @@ -59,6 +59,21 @@ struct Transformation Matrix rotation; float scale; Vector velocity; + + static const Transformation* getIdentity() + { + static Transformation* identity = NULL; + if (NULL == identity) + { + identity = new Transformation(); + identity->scale = 1.0f; + identity->rotation.v[0].array[0] = 1.0f; + identity->rotation.v[1].array[1] = 1.0f; + identity->rotation.v[2].array[2] = 1.0f; + } + + return identity; + } }; #pragma pack(pop)