Fix issue with import scale on prefab model

This commit is contained in:
Wojtek Figat
2023-12-07 10:25:59 +01:00
parent cb92110976
commit d847dfda61

View File

@@ -1219,13 +1219,13 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
// Apply the import transformation
if (!importTransform.IsIdentity())
{
// Transform the root node using the import transformation
auto& root = data.Skeleton.RootNode();
Transform meshTransform = root.LocalTransform.WorldToLocal(importTransform).LocalToWorld(root.LocalTransform);
root.LocalTransform = importTransform.LocalToWorld(root.LocalTransform);
if (options.Type == ModelType::SkinnedModel)
{
// Transform the root node using the import transformation
auto& root = data.Skeleton.RootNode();
Transform meshTransform = root.LocalTransform.WorldToLocal(importTransform).LocalToWorld(root.LocalTransform);
root.LocalTransform = importTransform.LocalToWorld(root.LocalTransform);
// Apply import transform on meshes
Matrix meshTransformMatrix;
meshTransform.GetWorld(meshTransformMatrix);
@@ -1249,6 +1249,12 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
bone.OffsetMatrix = importMatrixInv * bone.OffsetMatrix;
}
}
else
{
// Transform the root node using the import transformation
auto& root = data.Nodes[0];
root.LocalTransform = importTransform.LocalToWorld(root.LocalTransform);
}
}
// Post-process imported data