*/}}
Browse Source

Minor fixes for file read

Yiming Wu 2 years ago
parent
commit
c9fc20f2a9

+ 6 - 4
source/lagui/la_data.c

@@ -2573,7 +2573,7 @@ void la_WriteEnumProp(laUDF *udf, laPropPack *pp){
 void la_ReadRawProp(laUDF *udf, laPropPack *pp){
     la_ReadShort(udf);//mark
     int _size=0;
-    void* data=la_ReadRaw(pp,&_size);
+    void* data=la_ReadRaw(udf,&_size);
     if (pp) laSetRaw(pp, data, _size); free(data);
 }
 void la_WriteRawProp(laUDF *udf, laPropPack *pp){
@@ -2695,18 +2695,20 @@ int la_WriteProp(laUDF *udf, laPropPack *pp, int FromThis, int UseInstanceList){
             }
 
             while (inst){
-                laPropContainer* pc=p->SubProp;
-                if (((laSubProp*)p)->GetType){ pc=((laSubProp*)p)->GetType(inst); la_WriteString(udf, pc->Identifier); }
+                laPropContainer* pc=p->SubProp; int need_type=0;
+                if (((laSubProp*)p)->GetType){ pc=((laSubProp*)p)->GetType(inst); need_type=1; }
 
                 if (pc->Hyper == 2){
                     if(UseInstanceList&&inst!=udf->CurrentH2Instance->Instance){
                         inst = laGetNextInstance(p, inst, &pi); pp->EndInstance = inst; continue;}
+                    if(need_type){  la_WriteString(udf, pc->Identifier); }
                     hi = inst;
                     la_WriteShort(udf, LA_UDF_HYPER_ITEM);
                     la_AppendHyperRecord(udf, inst, p->SubProp, la_Tell(udf));
                     la_WriteHyperData(udf, inst);
                     memMarkClean(inst);
                 }else{
+                    if(need_type){  la_WriteString(udf, pc->Identifier); }
                     la_WriteShort(udf, LA_UDF_ITEM);
                 }
                 
@@ -3111,7 +3113,7 @@ int la_ExtractProp(laUDF *udf, laManagedUDF* mUDF, laPropPack *pp, void *ParentI
                         if(!pc){pc=p->SubProp;} RealSize=pc->NodeSize; 
                     }
 
-                    ItemType = (short)la_ReadShort(udf);
+                    ItemType = la_ReadShort(udf);
 
                     if (Parent) uci = la_AppendUDFContentInstance(Parent, la_Tell(udf));
 

+ 2 - 2
source/lagui/la_tns_kernel.c

@@ -3293,8 +3293,8 @@ int tnsCheckParentable(tnsObject* child, tnsObject* parent){
 void tnsParentObject(tnsObject *child, tnsObject *parent, int KeepTransform){
     if (!child || !parent || child->ParentObject==parent || parent->ParentObject==child || parent==child) return;
 
-    if (child->ParentObject) lstRemovePointer(&child->ParentObject->ChildObjects, child);
-    else lstRemovePointer(&child->InRoot->ChildObjects, child);
+    if (child->ParentObject) lstRemovePointerLeave(&child->ParentObject->ChildObjects, child);
+    else lstRemovePointerLeave(&child->InRoot->ChildObjects, child);
 
     lstAppendPointer(&parent->ChildObjects, child);
     memAssignRef(child, &child->ParentObject, parent);

+ 4 - 3
source/lagui/resources/la_modelling.c

@@ -609,8 +609,9 @@ int la_ParentableRecursive(tnsObject* root, tnsObject* parent){
     }return 1;
 }
 void la_MakeParentExecuteRecursive(tnsObject* root, tnsObject* parent, int Unparent, int KeepTransform){
-    for(laListItemPointer* lip=root->ChildObjects.pFirst;lip;lip=lip->pNext){
-        tnsObject* o=lip->p; if((!o) || (!(o->Flags&TNS_OBJECT_FLAGS_SELECTED))) continue;
+    laListItemPointer* NextLip;
+    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);
@@ -630,7 +631,7 @@ int OPINV_MakeParent(laOperator *a, laEvent *e){
     if(strSame(keep,"false")){ KeepTransform=0; }
 
     if(!Unparent){ if((!mo) || (!(mo->Flags&TNS_OBJECT_FLAGS_SELECTED))) return LA_FINISHED; 
-        if(!la_ParentableRecursive(root,mo)) laEnableMessagePanel(0,0,"It didn't work","There are loops in parenting",e->x,e->y,0,e); return LA_FINISHED;
+        if(!la_ParentableRecursive(root,mo)){ laEnableMessagePanel(0,0,"It didn't work","There are loops in parenting",e->x,e->y,0,e); return LA_FINISHED; }
     }
 
     if(keep){

+ 2 - 0
source/lagui/resources/la_properties.c

@@ -1289,6 +1289,7 @@ void la_RegisterInternalProps(){
         laPropContainerExtraFunctions(p,0,0,tnspropagate_Object,0);
         TNS_PC_OBJECT_GENERIC=p;
         laAddStringProperty(p, "name", "Object Name", "The Name Of The Object", 0, 0, 0, 0, 1, offsetof(tnsObject, Name), 0, 0, 0, 0, LA_AS_IDENTIFIER);
+        laAddIntProperty(p,"flags","Flags","Flags",0,0,0,0,0,0,0,0,offsetof(tnsObject,Flags),0,0,0,0,0,0,0,0,0,0,LA_READ_ONLY);
         ep = laAddEnumProperty(p, "show", "Show", "Show object in the viewport", 0, 0, 0, 0, 0, offsetof(tnsObject, Show), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);{
             laAddEnumItem(ep, "false", "False", "False", L'🌔');
             laAddEnumItem(ep, "true", "IsTrue", "IsTrue", L'🌑');
@@ -1318,6 +1319,7 @@ void la_RegisterInternalProps(){
             laAddEnumItem(ep, "quaternion", "Quaternion", "Quaternion Mode", 0);
         }
         laAddSubGroup(p, "active", "Active", "Active reference", "tns_object",0, 0, 0, offsetof(tnsObject, Active), 0, 0, 0, 0, 0, 0, 0, LA_UDF_REFER|LA_READ_ONLY);
+        laAddSubGroup(p, "in_root", "In Root", "Root object of this object", "tns_object",0, 0, 0, offsetof(tnsObject, InRoot), 0, 0, 0, 0, 0, 0, 0, LA_UDF_REFER);
         laAddSubGroup(p, "parent", "Parent", "Object parent", "tns_object",0, 0, 0, offsetof(tnsObject, ParentObject), 0, 0, 0, 0, 0, 0, 0, LA_UDF_REFER);
         laAddSubGroup(p, "children", "Children", "The Children Of This Object", "tns_child_object",0, 0, 0, -1, 0, 0, 0, 0, 0, 0, offsetof(tnsObject, ChildObjects), 0);
     }