Skip to content

Commit

Permalink
gltf import: Don't reparent existing Object3Ds
Browse files Browse the repository at this point in the history
This makes it possible to set up a custom heirachy before importing a
model, and not have it changed.
  • Loading branch information
ZNixian committed Jul 15, 2022
1 parent ad1e7c7 commit f4cce9e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion PD2ModelParser/Importers/GltfImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ void ImportNode(GLTF.Node node, DM.Object3D parent)
.Where(i => i != null)
.FirstOrDefault(i => i.HashName.Hash == hashname.Hash);

bool shouldSetParent = true;

if (obj == null)
{
/*var extras = node.TryUseExtrasAsDictionary(false);
Expand Down Expand Up @@ -136,11 +138,14 @@ void ImportNode(GLTF.Node node, DM.Object3D parent)
{
throw new Exception("Can't overwrite lights yet.");
}

// Don't re-parent nodes that already exist in the tree
shouldSetParent = false;
}

objectsByNode.Add(node, obj);

if(parent != null)
if(parent != null && shouldSetParent)
{
obj.SetParent(parent);
}
Expand Down

0 comments on commit f4cce9e

Please sign in to comment.