*/}}
Browse Source

Unparent object fix

YimingWu 1 year ago
parent
commit
c266416361
1 changed files with 7 additions and 4 deletions
  1. 7 4
      resources/la_modelling.c

+ 7 - 4
resources/la_modelling.c

@@ -790,11 +790,14 @@ int la_ParentableRecursive(tnsObject* root, tnsObject* parent){
 }
 void la_MakeParentExecuteRecursive(tnsObject* root, tnsObject* parent, int Unparent, int KeepTransform){
     laListItemPointer* NextLip;
+    if(root->Type!=TNS_OBJECT_ROOT){ 
+        if((root->Flags&TNS_OBJECT_FLAGS_SELECTED)&&root->InRoot==parent->InRoot){
+            if(Unparent) tnsUnparentObject(root, KeepTransform);
+            elif(root!=parent) tnsParentObject(root, parent, KeepTransform);
+        }
+    }
     for(laListItemPointer* lip=root->ChildObjects.pFirst;lip;lip=NextLip){ NextLip=lip->pNext;
-        tnsObject* o=lip->p; if((!o) || (!(o->Flags&TNS_OBJECT_FLAGS_SELECTED)) || (o==parent)) continue;
-        if(Unparent) tnsUnparentObject(o, KeepTransform);
-        else tnsParentObject(o, parent, KeepTransform);
-        la_MakeParentExecuteRecursive(o,parent,Unparent,KeepTransform);
+        tnsObject* o=lip->p; if(!o) continue; la_MakeParentExecuteRecursive(o,parent,Unparent,KeepTransform);
     }
     laNotifyUsers("tns.world");
 }