From 4629090fafbef256abd0686a85ee12042d658868 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Wed, 12 Jun 2019 22:37:48 -0400
Subject: [PATCH] Mocap big data

---
 Object3D.java |  218 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 167 insertions(+), 51 deletions(-)

diff --git a/Object3D.java b/Object3D.java
index 2c2cf4d..d7a346f 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -24,6 +24,11 @@
     
     private UUID uuid = UUID.randomUUID();
     
+    // TEMPORARY for mocap undo
+    mocap.reader.BVHReader.BVHResult bvh;
+    Object3D skeleton;
+    //
+    
     ScriptNode scriptnode;
 
         void InitOthers()
@@ -104,64 +109,136 @@
     
 //    transient boolean reduced; // for morph reduction
     
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
+    transient com.bulletphysics.linearmath.Transform cache; // for fast merge
+    transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
 
-transient Object3D transientsupport; // for cloning
-transient boolean transientlink2master;
+    transient Object3D transientsupport; // for cloning
+    transient boolean transientlink2master;
 
-void SaveSupports()
-{
-    if (blockloop)
-        return;
-
-    transientsupport = support;
-    transientlink2master = link2master;
-    
-    support = null;
-    link2master = false;
-    
-    if (bRep != null)
+    void SaveSupports()
     {
-        bRep.SaveSupports();
-    }
-    
-    for (int i = 0; i < Size(); i++)
-    {
-        Object3D child = (Object3D) get(i);
-        if (child == null)
-            continue;
-        blockloop = true;
-        child.SaveSupports();
-        blockloop = false;
-    }
-}
+        if (blockloop)
+            return;
 
-void RestoreSupports()
-{
-    if (blockloop)
-        return;
+        transientsupport = support;
+        transientlink2master = link2master;
 
-    support = transientsupport;
-    link2master = transientlink2master;
-    transientsupport = null;
-    transientlink2master = false;
-    
-    if (bRep != null)
-    {
-        bRep.RestoreSupports();
+        support = null;
+        link2master = false;
+
+        if (bRep != null)
+        {
+            bRep.SaveSupports();
+        }
+
+        for (int i = 0; i < Size(); i++)
+        {
+            Object3D child = (Object3D) get(i);
+            if (child == null)
+                continue;
+            blockloop = true;
+            child.SaveSupports();
+            blockloop = false;
+        }
     }
-    
-    for (int i = 0; i < Size(); i++)
+
+    void RestoreSupports()
     {
-        Object3D child = (Object3D) get(i);
-        if (child == null)
-            continue;
-        blockloop = true;
-        child.RestoreSupports();
-        blockloop = false;
+        if (blockloop)
+            return;
+
+        support = transientsupport;
+        link2master = transientlink2master;
+        transientsupport = null;
+        transientlink2master = false;
+
+        if (bRep != null)
+        {
+            bRep.RestoreSupports();
+        }
+
+        for (int i = 0; i < Size(); i++)
+        {
+            Object3D child = (Object3D) get(i);
+            if (child == null)
+                continue;
+            blockloop = true;
+            child.RestoreSupports();
+            blockloop = false;
+        }
     }
-}
+
+    void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
+    {
+        if (hashtable.containsKey(GetUUID()))
+        {
+            Object3D o = hashtable.get(GetUUID());
+
+            assert(this.bRep == o.bRep);
+            if (this.bRep != null)
+                assert(this.bRep.support == o.transientrep);
+
+            return;
+        }
+
+        Object3D o = new Object3D();
+
+        hashtable.put(GetUUID(), o);
+
+        for (int i=0; i<Size(); i++)
+        {
+            get(i).ExtractBigData(hashtable);
+        }
+        
+        ExtractBigData(o);
+    }
+
+    void ExtractBigData(Object3D o)
+    {
+        o.bRep = this.bRep;
+        if (this.bRep != null)
+        {
+            o.transientrep = this.bRep.support;
+            o.bRep.support = null;
+        }
+        
+        //    o.support = this.support;
+        //    o.fileparent = this.fileparent;
+        //    if (this.bRep != null)
+        //        o.bRep = this.bRep.support;
+        
+        this.bRep = null;
+    //    if (this.bRep != null)
+    //        this.bRep.support = null;
+    //    this.support = null;
+    //    this.fileparent = null;
+    }
+
+    void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
+    {
+        if (!hashtable.containsKey(GetUUID()))
+            return;
+
+        Object3D o = hashtable.get(GetUUID());
+
+        RestoreBigData(o);
+
+        hashtable.remove(GetUUID());
+
+        for (int i=0; i<Size(); i++)
+        {
+            get(i).RestoreBigData(hashtable);
+        }
+    }
+
+    void RestoreBigData(Object3D o)
+    {
+        this.bRep = o.bRep;
+        if (this.bRep != null)
+            this.bRep.support = o.transientrep;
+    //    this.support = o.support;
+    //    this.fileparent = o.fileparent;
+    }
 
 // MOCAP SUPPORT
     double tx,ty,tz,rx,ry,rz;
@@ -2632,6 +2709,18 @@
         //Touch();
     }
 
+    void GenNormalsMeshS()
+    {
+        selection.GenNormalsMesh();
+//        for (int i=0; i<selection.size(); i++)
+//        {
+//            Object3D selectee = (Object3D) selection.elementAt(i);
+//            selectee.GenNormals(crease);
+//        }
+
+        //Touch();
+    }
+
     void ClearColorsS()
     {
         selection.ClearColors();
@@ -2763,6 +2852,24 @@
             if (child == null)
                 continue;
             child.GenNormals(crease);
+//            Children().release(i);
+        }
+        blockloop = false;
+    }
+
+    void GenNormalsMesh()
+    {
+        if (blockloop)
+            return;
+        
+        blockloop = true;
+        GenNormalsMesh0();
+        for (int i = 0; i < Children().Size(); i++)
+        {
+            Object3D child = (Object3D) Children().get(i); // reserve(i);
+            if (child == null)
+                continue;
+            child.GenNormalsMesh();
 //            Children().release(i);
         }
         blockloop = false;
@@ -2931,6 +3038,15 @@
         if (bRep != null)
         {
             bRep.GenerateNormals(crease);
+            Touch();
+        }
+    }
+
+    void GenNormalsMesh0()
+    {
+        if (bRep != null)
+        {
+            bRep.GenerateNormalsMesh();
             Touch();
         }
     }
@@ -7567,7 +7683,7 @@
 	/*transient*/ cVector2[] projectedVertices = new cVector2[0];
         
     Object3D /*Composite*/ parent;
-    Object3D /*Composite*/ fileparent;
+    Object3D /*Composite*/ fileparent; // In the case of FileObject
     
     double[][] toParent; // dynamic matrix
     double[][] fromParent;

--
Gitblit v1.6.2