Skip to content

Commit 0812c68

Browse files
committed
Fixed polyimport not taking entity parent transforms into account on import
1 parent f167b22 commit 0812c68

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Tools/Contents/polyimport/Source/polyimport.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ unsigned int addBone(aiBone *bone) {
5555
return bones.size()-1;
5656
}
5757

58+
aiMatrix4x4 getFullTransform(const struct aiNode *nd) {
59+
if(nd->mParent) {
60+
return getFullTransform(nd->mParent) * nd->mTransformation;
61+
} else {
62+
return nd->mTransformation;
63+
}
64+
}
65+
5866
void addToMesh(String prefix, Polycode::Mesh *tmesh, const struct aiScene *sc, const struct aiNode* nd, bool swapZY, bool addSubmeshes, bool listOnly, ObjectEntry *parentSceneObject, String overrideMaterial, ObjectEntry *materialsParent, String assetPrefixPath, String baseFileName) {
5967
int i, nIgnoredPolygons = 0;
6068
unsigned int n = 0, t;
@@ -194,7 +202,10 @@ void addToMesh(String prefix, Polycode::Mesh *tmesh, const struct aiScene *sc, c
194202
aiVector3D p;
195203
aiVector3D s;
196204
aiQuaternion r;
197-
nd->mTransformation.Decompose(s, r, p);
205+
206+
aiMatrix4x4 fullTransform = getFullTransform(nd);
207+
208+
fullTransform.Decompose(s, r, p);
198209

199210
meshEntry->addChild("sX", s.x);
200211

0 commit comments

Comments
 (0)