*/}}
Bladeren bron

Instancer and properties ui fix

YimingWu 1 jaar geleden
bovenliggende
commit
c4fcdf12bf
4 gewijzigde bestanden met toevoegingen van 70 en 66 verwijderingen
  1. 1 0
      la_tns.h
  2. 6 0
      la_tns_kernel.c
  3. 61 65
      resources/la_templates.c
  4. 2 1
      resources/la_widgets_viewers.c

+ 1 - 0
la_tns.h

@@ -490,6 +490,7 @@ STRUCTURE(tnsEvaluateData){
     int FillOutline;
     int FillSelectionID;
     int OverrideID;
+    laListHandle ParentStack;
     tnsEvaluatedInstance* Commands; int NextCommand, MaxCommand;
     tnsEvaluatedInstance* Outlines; int NextOutline, MaxOutline;
     tnsEvaluatedInstance* Overlays; int NextOverlay, MaxOverlay;

+ 6 - 0
la_tns_kernel.c

@@ -3775,10 +3775,14 @@ void tnsEvaluateInstancerObject(tnsInstancer* o, tnsEvaluateData* ed){
     if(o->Instance){
         tnsObject* inst=o->Instance;
         if(ed->SceneEvaluateMode){ inst=tnsEnsurePlayDuplicate(inst); }
+        for(laListItemPointer* lip=ed->ParentStack.pFirst;lip;lip=lip->pNext){
+            if(lip->p == inst || lip->p==o->Instance){ goto eval_inst_cleanup; }
+        }
         tnsPushEvaluateMatrixWith(ed,o->Base.GlobalTransform);
         tnsEvaluateObjectTree(inst, ed, ed->SceneEvaluateMode);
         tnsPopEvaluateMatrix(ed);
     }
+eval_inst_cleanup:
     ed->OverrideID=origid; ed->FillOutline=origoutline;
 }
 
@@ -4047,6 +4051,7 @@ void tnsEvaluateObjectTree(tnsObject* from, tnsEvaluateData* UseED, int Evaluate
         if(!UseED){ tnsEnsureEvaluatedScene(ed,from); }
         CP=ed->Scene->CurrentParent; CC=ed->Scene->CurrentChild;
     }
+    lstPushPointer(&ed->ParentStack,from);
 
     tnsEvaluateThisObject(from, ed);
     
@@ -4057,6 +4062,7 @@ void tnsEvaluateObjectTree(tnsObject* from, tnsEvaluateData* UseED, int Evaluate
         if(ed->SceneEvaluateMode){ ed->Scene->CurrentChild=ed->Scene->CurrentChild?ed->Scene->CurrentChild->Item.pNext:0; }
     }
 
+    lstPopPointer(&ed->ParentStack);
     if(ed->SceneEvaluateMode){ ed->Scene->CurrentParent=CP; ed->Scene->CurrentChild=CC; }
     if(!UseED){ ed->Done=1;
         //if(ed->Scene){ tnsPrintEvaluatedNode(ed->Scene->Root,0);}

+ 61 - 65
resources/la_templates.c

@@ -1783,15 +1783,6 @@ void tnsui_LightObjectProperties(laUiList *uil, laPropPack *This, laPropPack *UN
     laColumn* c=laFirstColumn(uil);
     laShowLabel(uil,c,"Light Object",0,0)->Flags|=LA_TEXT_ALIGN_CENTER|LA_UI_FLAGS_DISABLED; 
 }
-void tnsui_MeshObjectProperties(laUiList *uil, laPropPack *This, laPropPack *UNUSED_Extra, laColumn *UNUSED_Colums, int context){
-    laColumn* c=laFirstColumn(uil);
-    laShowLabel(uil,c,"Mesh Object",0,0)->Flags|=LA_TEXT_ALIGN_CENTER|LA_UI_FLAGS_DISABLED; 
-}
-void tnsui_InstancerObjectProperties(laUiList *uil, laPropPack *This, laPropPack *UNUSED_Extra, laColumn *UNUSED_Colums, int context){
-    laColumn* c=laFirstColumn(uil), *cl,*cr;
-    laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,5); cr=laRightColumn(c,0);
-    laShowLabel(uil,cl,"Instance",0,0); laShowItemFull(uil,cr,This,"instance",LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0);
-}
 void tnsui_Material(laUiList *uil, laPropPack *This, laPropPack *UNUSED_Extra, laColumn *UNUSED_Colums, int context){
     laColumn* c=laFirstColumn(uil),*cl,*cr; laUiItem* b,*b1,*b2;
     laSplitColumn(uil,c,0.4); cl=laLeftColumn(c,8); cr=laRightColumn(c,0);
@@ -1844,45 +1835,51 @@ void tnsui_MaterialSlot(laUiList *uil, laPropPack *This, laPropPack *UNUSED_Extr
         laShowItem(uil,c,This,"name")->Flags|=LA_UI_FLAGS_DISABLED;
     }laEndCondition(uil,b1);
 }
+void tnsui_MeshObjectProperties(laUiList *uil, laPropPack *This, laPropPack *UNUSED_Extra, laColumn *UNUSED_Colums, int context){
+    laColumn* c=laFirstColumn(uil); laUiItem* g,*tg; laUiList* gu,*tu; laColumn* gc,*gcl,*gcr,*tc; laUiItem* b1,*b2,*b3,*b4,*b5;
+    laShowLabel(uil,c,"Mesh Object",0,0)->Flags|=LA_TEXT_ALIGN_CENTER|LA_UI_FLAGS_DISABLED; 
+    g=laMakeGroup(uil,c,"Materials",0); gu=g->Page; gc=laFirstColumn(gu); laSplitColumn(gu,gc,0.7);
+    gcl=laLeftColumn(gc,0); gcr=laRightColumn(gc,1);
+    tg=laMakeEmptyGroup(gu,gcl,"Slots",0); tu=tg->Page; tc=laFirstColumn(tu); tu->HeightCoeff=4;
+    laShowItemFull(tu,tc,This,"materials",0,0,tnsui_MaterialSlot,0)->Flags|=LA_UI_FLAGS_NO_DECAL;
+    laShowItem(gu,gcr,This,"add_material_slot");
+    b2=laOnConditionThat(gu,gc,laPropExpression(This,"current_material"));{
+        laUiItem* mat=laShowInvisibleItem(gu,gc,This,"current_material");
+        laShowItem(gu,gcr,&mat->PP,"remove");
+        b3=laBeginRow(gu,gc,0,0); laUiItem* sel;
+        laShowItem(gu,gc,This,"add_material")->Flags|=LA_UI_FLAGS_ICON;
+        b4=laOnConditionThat(gu,gc,laPropExpression(&mat->PP,"material"));{
+            sel=laShowItemFull(gu,gc,&mat->PP,"material",LA_WIDGET_COLLECTION_SELECTOR,0,tnsui_MaterialListItem,0);
+            sel->Flags|=LA_UI_COLLECTION_SIMPLE_SELECTOR;
+            laShowItem(gu,gc,&mat->PP,"material.name")->Expand=1;
+            laShowItem(gu,gc,&sel->PP,"clear_selection")->Flags|=LA_UI_FLAGS_ICON;
+        }laElse(gu,b4);{
+            sel=laShowItemFull(gu,gc,&mat->PP,"material",LA_WIDGET_COLLECTION_SELECTOR,0,tnsui_MaterialListItem,0);
+            sel->Flags|=LA_UI_COLLECTION_SIMPLE_SELECTOR; sel->Expand=1;
+        }laEndCondition(gu,b4);
+        laEndRow(gu,b3);
+        b4=laOnConditionThat(gu,gc,laEqual(laPropExpression(This,"mode"),laIntExpression(TNS_MESH_EDIT_MODE)));{
+            b5=laBeginRow(gu,gc,0,0);
+            laShowLabel(gu,gc,"Edit:",0,0);
+            laShowItemFull(gu,gc,This,"assign_material_slot",0,"text=Assign",0,0);
+            laEndRow(gu,b5);
+        }laEndCondition(gu,b4);
+        laShowSeparator(gu,gc);
+        b4=laOnConditionThat(gu,gc,laPropExpression(&mat->PP,"material"));{
+            laShowItemFull(gu,gc,&mat->PP,"material",LA_WIDGET_COLLECTION_SINGLE,0,tnsui_Material,1)->Flags|=LA_UI_FLAGS_NO_DECAL;
+        }laEndCondition(gu,b4);
+    }laElse(gu,b2);{
+        laShowLabel(gu,gc,"No active material slot.",0,0);
+    }laEndCondition(gu,b2);
+}
+void tnsui_InstancerObjectProperties(laUiList *uil, laPropPack *This, laPropPack *UNUSED_Extra, laColumn *UNUSED_Colums, int context){
+    laColumn* c=laFirstColumn(uil), *cl,*cr;
+    laSplitColumn(uil,c,0.5); cl=laLeftColumn(c,5); cr=laRightColumn(c,0);
+    laShowLabel(uil,cl,"Instance",0,0); laShowItemFull(uil,cr,This,"instance",LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0);
+}
 void tnsui_BaseObjectProperties(laUiList *uil, laPropPack *This, laPropPack *UNUSED_Extra, laColumn *UNUSED_Colums, int context){
     laColumn* c=laFirstColumn(uil); laUiItem* g,*tg; laUiList* gu,*tu; laColumn* gc,*gcl,*gcr,*tc; laUiItem* b1,*b2,*b3,*b4,*b5;
-
-    b1=laOnConditionThat(uil,c,laEqual(laPropExpression(This,"__self.type"),laIntExpression(TNS_OBJECT_MESH)));{
-        g=laMakeGroup(uil,c,"Materials",0); gu=g->Page; gc=laFirstColumn(gu); laSplitColumn(gu,gc,0.7);
-        gcl=laLeftColumn(gc,0); gcr=laRightColumn(gc,1);
-        tg=laMakeEmptyGroup(gu,gcl,"Slots",0); tu=tg->Page; tc=laFirstColumn(tu); tu->HeightCoeff=4;
-        laShowItemFull(tu,tc,This,"as_mesh.materials",0,0,tnsui_MaterialSlot,0)->Flags|=LA_UI_FLAGS_NO_DECAL;
-        laShowItem(gu,gcr,This,"as_mesh.add_material_slot");
-        b2=laOnConditionThat(gu,gc,laPropExpression(This,"as_mesh.current_material"));{
-            laUiItem* mat=laShowInvisibleItem(gu,gc,This,"as_mesh.current_material");
-            laShowItem(gu,gcr,&mat->PP,"remove");
-            b3=laBeginRow(gu,gc,0,0); laUiItem* sel;
-            laShowItem(gu,gc,This,"as_mesh.add_material")->Flags|=LA_UI_FLAGS_ICON;
-            b4=laOnConditionThat(gu,gc,laPropExpression(&mat->PP,"material"));{
-                sel=laShowItemFull(gu,gc,&mat->PP,"material",LA_WIDGET_COLLECTION_SELECTOR,0,tnsui_MaterialListItem,0);
-                sel->Flags|=LA_UI_COLLECTION_SIMPLE_SELECTOR;
-                laShowItem(gu,gc,&mat->PP,"material.name")->Expand=1;
-                laShowItem(gu,gc,&sel->PP,"clear_selection")->Flags|=LA_UI_FLAGS_ICON;
-            }laElse(gu,b4);{
-                sel=laShowItemFull(gu,gc,&mat->PP,"material",LA_WIDGET_COLLECTION_SELECTOR,0,tnsui_MaterialListItem,0);
-                sel->Flags|=LA_UI_COLLECTION_SIMPLE_SELECTOR; sel->Expand=1;
-            }laEndCondition(gu,b4);
-            laEndRow(gu,b3);
-            b4=laOnConditionThat(gu,gc,laEqual(laPropExpression(This,"as_mesh.mode"),laIntExpression(TNS_MESH_EDIT_MODE)));{
-                b5=laBeginRow(gu,gc,0,0);
-                laShowLabel(gu,gc,"Edit:",0,0);
-                laShowItemFull(gu,gc,This,"as_mesh.assign_material_slot",0,"text=Assign",0,0);
-                laEndRow(gu,b5);
-            }laEndCondition(gu,b4);
-            laShowSeparator(gu,gc);
-            b4=laOnConditionThat(gu,gc,laPropExpression(&mat->PP,"material"));{
-                laShowItemFull(gu,gc,&mat->PP,"material",LA_WIDGET_COLLECTION_SINGLE,0,tnsui_Material,1)->Flags|=LA_UI_FLAGS_NO_DECAL;
-            }laEndCondition(gu,b4);
-        }laElse(gu,b2);{
-            laShowLabel(gu,gc,"No active material slot.",0,0);
-        }laEndCondition(gu,b2);
-    }laEndCondition(uil,b1);
-
+    laShowLabel(uil,c,"Generic",0,0)->Flags|=LA_TEXT_ALIGN_CENTER|LA_UI_FLAGS_DISABLED; 
     g=laMakeGroup(uil,c,"Object",0); gu=g->Page; gc=laFirstColumn(gu);
     b1=laOnConditionToggle(gu,gc,0,0,0,0,0);{ strSafeSet(&b1->ExtraInstructions,"text=Transformations");
         //b1->State=LA_UI_ACTIVE;
@@ -1903,39 +1900,38 @@ void tnsuidetached_ObjectProperties(laPanel* p){
     la_MakeDetachedProp(p, "tns.world.root_objects", "root_object");
 }
 void tnsui_ObjectProperties(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn *UNUSED, int context){
-    laColumn* c=laFirstColumn(uil),*cl, *cr;
-    laSplitColumn(uil,c,0.2); cl=laLeftColumn(c,1); cr=laRightColumn(c,0);
+    laColumn* c=laFirstColumn(uil);
 
-    laShowItemFull(uil,cl,Extra,"detached",0,0,0,0)->Flags|=LA_UI_FLAGS_HIGHLIGHT|LA_UI_FLAGS_ICON;
+    laUiItem* b=laBeginRow(uil,c,0,0);
+    laShowItemFull(uil,c,Extra,"detached",0,0,0,0)->Flags|=LA_UI_FLAGS_HIGHLIGHT|LA_UI_FLAGS_ICON;
 
 #define ADD_PAGE1(base,path) \
-    laUiItem* b=laBeginRow(uil,cr,0,0);\
-    laUiItem* rb=laShowItemFull(uil,cr,base,path,LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0);\
+    laUiItem* rb=laShowItemFull(uil,c,base,path,LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0);\
         rb->Flags|=LA_UI_COLLECTION_SIMPLE_SELECTOR;\
-    laUiItem* b2=laOnConditionThat(uil,cr,laPropExpression(&rb->PP,""));{\
-        laShowItem(uil,cr,&rb->PP,"name")->Flags|=LA_UI_FLAGS_NO_DECAL;\
-        laUiItem* b3=laOnConditionThat(uil,cr,laPropExpression(&rb->PP,"active"));{\
-            laShowLabel(uil,cr,"⯈",0,0); laShowItem(uil,cr,&rb->PP,"active.name")->Flags|=LA_UI_FLAGS_NO_DECAL;\
+    laUiItem* b2=laOnConditionThat(uil,c,laPropExpression(&rb->PP,""));{\
+        laShowItem(uil,c,&rb->PP,"name")->Flags|=LA_UI_FLAGS_NO_DECAL;\
+        laUiItem* b3=laOnConditionThat(uil,c,laPropExpression(&rb->PP,"active"));{\
+            laShowLabel(uil,c,"⯈",0,0); laShowItem(uil,c,&rb->PP,"active.name")->Flags|=LA_UI_FLAGS_NO_DECAL;\
         }laEndCondition(uil,b3);\
     }laEndCondition(uil,b2);\
-    laEndRow(uil,b);\
-    laUiItem* g; laUiList* gu; laColumn* gc;\
-    g=laMakeEmptyGroup(uil,c,"Object",0); gu=g->Page; gc=laFirstColumn(gu); g->Flags|=LA_UI_FLAGS_NO_DECAL;
+    laEndRow(uil,b);
 
 #define ADD_PAGE2 \
-    laUiItem* b3=laOnConditionThat(gu,gc,laPropExpression(&actui->PP,""));{\
-        tnsui_BaseObjectProperties(gu,&actui->PP,0,0,0);\
-    }laElse(gu,b3);{\
-        laShowLabel(gu,gc,"No active object.",0,0)->Flags|=LA_TEXT_ALIGN_CENTER|LA_UI_FLAGS_DISABLED;;\
-    }laEndCondition(gu,b3);
+    laUiItem* b3=laOnConditionThat(uil,c,laPropExpression(&actui->PP,""));{\
+        tnsui_BaseObjectProperties(uil,&actui->PP,0,0,0);\
+    }laElse(uil,b3);{\
+        laShowLabel(uil,c,"No active object.",0,0)->Flags|=LA_TEXT_ALIGN_CENTER|LA_UI_FLAGS_DISABLED;;\
+    }laEndCondition(uil,b3);
 
     laUiItem* b0=laOnConditionThat(uil,c,laPropExpression(Extra,"detached"));{
         ADD_PAGE1(Extra,"root_object")
-        laUiItem* actui=laShowInvisibleItem(gu,gc,&rb->PP,"active");
+        laUiItem* actui=laShowItemFull(uil,c,&rb->PP,"active",LA_WIDGET_COLLECTION_SINGLE,0,0,0);
+            actui->Flags|=LA_UI_FLAGS_NO_DECAL;
         ADD_PAGE2
     }laElse(uil,b0);{
         ADD_PAGE1(0,"tns.world.active_root")
-        laUiItem* actui=laShowInvisibleItem(gu,gc,0,"tns.world.active_root.active");
+        laUiItem* actui=laShowItemFull(uil,c,0,"tns.world.active_root.active",LA_WIDGET_COLLECTION_SINGLE,0,0,0);
+            actui->Flags|=LA_UI_FLAGS_NO_DECAL;
         ADD_PAGE2
     }laEndCondition(uil,b0);
 

+ 2 - 1
resources/la_widgets_viewers.c

@@ -563,7 +563,8 @@ void laDefault3DViewOverlay(laUiItem *ui){
                         laShowLabel(gu, gc, "DLoc:", 0, 0);laShowItem(gu, gc, &ui->PP, "active.dlocation")->Flags|=LA_UI_FLAGS_TRANSPOSE;
                         laShowSeparator(gu,gc);
                         laShowLabel(gu, gc, "DRot:", 0, 0);laShowItem(gu, gc, &ui->PP, "active.drotation")->Flags|=LA_UI_FLAGS_TRANSPOSE;
-                        laShowItem(gu, gc, &ui->PP, "active.dscale");
+                        laShowSeparator(gu,gc);
+                        laShowLabel(gu, gc, "DSca:", 0, 0);laShowItem(gu, gc, &ui->PP, "active.dscale")->Flags|=LA_UI_FLAGS_TRANSPOSE;
                     }laElse(gu,b);{
                         laShowLabel(gu, gc, "Loc:", 0, 0);laShowItem(gu, gc, &ui->PP, "active.location")->Flags|=LA_UI_FLAGS_TRANSPOSE;
                         laShowSeparator(gu,gc);