*/}}
Selaa lähdekoodia

Single node handling, data optimizations

YimingWu 1 vuosi sitten
vanhempi
commit
55f6e40a51
5 muutettua tiedostoa jossa 22 lisäystä ja 8 poistoa
  1. 3 1
      la_data.c
  2. 12 6
      la_tns_kernel.c
  3. 3 0
      la_tns_mesh.c
  4. 1 0
      resources/la_modelling.c
  5. 3 1
      resources/la_operators.c

+ 3 - 1
la_data.c

@@ -2741,6 +2741,8 @@ void *la_FindSharedResouce(char *id){
 }
 
 void la_AppendHyperRecord(laUDF *udf, void *HyperUserMem, laPropContainer* pc, u64bit Seek){
+    // this happens when theres a type{base{} ... } like tnsobject, should not be problematic...?
+    if(lstHasPointer(&udf->HyperRecords, HyperUserMem)) return;
     laUDFHyperRecordItem *hri = lstAppendPointerSized(&udf->HyperRecords, HyperUserMem, sizeof(laUDFHyperRecordItem));
     hri->Seek = Seek;
     hri->pc = pc;
@@ -4135,7 +4137,7 @@ int la_GenerateListDifferences(laDBInst* dbi, laDBSubProp* dbp, laPropPack* pp,
     laPropIterator pi={0};
     void* inst; int any=0;
     laListHandle New={0}, NewAdded={0}, NewDeleted={0}, NewMoved={0};
-    
+
     inst = laGetInstance(p, pp->LastPs->UseInstance, &pi);
     pp->EndInstance = inst;
     while (inst){

+ 12 - 6
la_tns_kernel.c

@@ -3429,7 +3429,7 @@ tnsObject *tnsCreateRootObject(char *name){
     strSafeSet(&o->Name, name);
     lstAppendItem(&w->RootObjects, o);
 
-    w->ActiveRoot = o; // XXX: same here
+    memAssignRef(w,&w->ActiveRoot,o);
 
     o->Drivers=memAcquire(sizeof(laRackPageCollection));
 
@@ -3440,13 +3440,19 @@ void tnsDestroyRootObject(tnsObject *root){
     tnsObject *o, *NextO;
     memAssignRef(w,&w->ActiveRoot,root->Item.pPrev ? root->Item.pPrev : root->Item.pNext ? root->Item.pNext : 0);
 
+    root->Evaluated.Done=root->EvaluatedPlay.Done=0;
     tnsFreeEvaluatedArray(&root->Evaluated);
-    tnsClearPlayDuplicate(o);
-    if(o->EvaluatedPlay.Commands) tnsFreeEvaluatedArray(&o->EvaluatedPlay);
-    tnsFreeEvaluatedScene(&o->EvaluatedPlay);
+    tnsClearPlayDuplicate(root);
+    if(root->EvaluatedPlay.Commands) tnsFreeEvaluatedArray(&root->EvaluatedPlay);
+    tnsFreeEvaluatedScene(&root->EvaluatedPlay);
 
-    //XXX: destroy rack page; and then release memory;
-    root->Drivers=0; memLeave(root->Drivers); 
+    //destroy rack page; and then release memory;
+    laRackPage*rp;
+    while(rp=lstPopItem(&root->Drivers->Pages)){
+        laNodeRack* rr; while(rr=lstPopItem(&rp->Racks)){ laDestroyRack(rr); }
+        memLeave(rp);
+    }
+    memLeave(root->Drivers); // root->Drivers=0; never reset address for single, see la_GiveDiffCommand()
 
     lstRemoveItem(&w->RootObjects, root);
     while (lstPopPointerLeave(&root->ChildObjects));

+ 3 - 0
la_tns_mesh.c

@@ -241,6 +241,7 @@ int* tnsGetEdgeBatch(tnsMeshObject* mo){
 void tnsInvalidateMeshBatch(tnsMeshObject* mo){
     if(mo->Base.Type!=TNS_OBJECT_MESH) return;
     if(mo->Batch) tnsDeleteBatch(mo->Batch); mo->Batch=0;
+    if(mo->Base.PlayDuplicate){ tnsMeshObject*pmo=mo->Base.PlayDuplicate; pmo->Batch=0; }
 }
 void tnsRegenerateMeshBatch(tnsMeshObject* mo){
     if(!mo) return;
@@ -278,6 +279,8 @@ void tnsRegenerateMeshBatch(tnsMeshObject* mo){
         //for(int i=0;i<mo->totme*2;i++){ printf("%d ",eelems[i]); } printf("\n");
     }
     if(idcolors) free(idcolors); if(editcolors) free(editcolors); if(eelems) free(eelems);
+
+    if(mo->Base.PlayDuplicate){ tnsMeshObject*pmo=mo->Base.PlayDuplicate; pmo->Batch=mo->Batch; }
 }
 void tnsEnsureMeshBatch(tnsMeshObject* mo){
     if(mo->Base.Type!=TNS_OBJECT_MESH) return;

+ 1 - 0
resources/la_modelling.c

@@ -1632,6 +1632,7 @@ int OPINV_RemoveRootObject(laOperator *a, laEvent *e){
     if(a->This && a->This->EndInstance){ tnsDestroyRootObject(a->This->EndInstance); }
     else{ tnsDestroyRootObject(T->World->ActiveRoot); }
     laNotifyUsers("tns.world.root_objects"); laNotifyUsers("tns.world.active_root");
+    laRecordDifferences(0,"tns.world"); laPushDifferences("Removed root object",0);
     return LA_FINISHED;
 }
 

+ 3 - 1
resources/la_operators.c

@@ -554,6 +554,8 @@ int OPMOD_UDFRead(laOperator *a, laEvent *e){
             laManagedUDF* m;
             upe->UDF = laOpenUDF(a->ConfirmData->StrData, 1, 0, &m);
             if (upe->UDF){
+                laFreeNewerDifferences();
+                laFreeOlderDifferences(1);
                 laExtractUDF(upe->UDF, m, upe->Append?LA_UDF_MODE_APPEND:LA_UDF_MODE_OVERWRITE, 0);
                 laCloseUDF(upe->UDF);
                 laRecordEverythingAndPush();
@@ -1275,7 +1277,7 @@ int laui_BlockMenu(laOperator *WindowAct, laWindow* w, laLayout *l, laBlock *b,
 
     laShowSeparator(uil,c);
 
-    if(forp->PanelTemplate->Header){
+    if(forp->PanelTemplate && forp->PanelTemplate->Header){
         laShowLabel(uil, c, "Panel properties:", 0, 0);
         forp->PanelTemplate->Header(uil, &forp->PP, &forp->PropLinkPP, c, 0);
     }else{