Skip to content

Commit

Permalink
initial fix: enable unpacking GLTF models multiple levels
Browse files Browse the repository at this point in the history
This is a quick initial fix; Not ready for merge yet

This fixes one major issue with the feature. Previously, you couldn't break apart a GLTF model more than once, as it would just create duplicates of the thing you were trying to break apart

I don't know if the feature works for all cases of GLTF transform hierarchies
  • Loading branch information
eeropomell committed Nov 26, 2024
1 parent e479c83 commit 547affb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Assets/Scripts/Widgets/ModelWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,18 @@ public void SyncHierarchyToSubtree(string previousSubtree = null)
string subpathToTraverse;
if (!string.IsNullOrEmpty(previousSubtree))
{
subpathToTraverse = m_Subtree.Substring(previousSubtree.Length);

// example case:
// previousSubtree = CarBody/Floor
// m_Subtree = CarBody/Floor/Wheel1
// subpathToTraverse should be Floor/Wheel1

// Floor
string lastLevel = previousSubtree.Split("/")[^1];

int startIndex = previousSubtree.Length - (lastLevel.Length + "/".Length);

subpathToTraverse = m_Subtree.Substring(startIndex);
}
else
{
Expand Down

0 comments on commit 547affb

Please sign in to comment.