Fix issue with import scale on prefab model
This commit is contained in:
@@ -1219,13 +1219,13 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
|
|||||||
// Apply the import transformation
|
// Apply the import transformation
|
||||||
if (!importTransform.IsIdentity())
|
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)
|
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
|
// Apply import transform on meshes
|
||||||
Matrix meshTransformMatrix;
|
Matrix meshTransformMatrix;
|
||||||
meshTransform.GetWorld(meshTransformMatrix);
|
meshTransform.GetWorld(meshTransformMatrix);
|
||||||
@@ -1249,6 +1249,12 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
|
|||||||
bone.OffsetMatrix = importMatrixInv * bone.OffsetMatrix;
|
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
|
// Post-process imported data
|
||||||
|
|||||||
Reference in New Issue
Block a user