From e24558ddeacfc945b9e9ba0a32b552d04e2ed4dd Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 02 Jun 2019 20:11:20 -0400
Subject: [PATCH] Selectable mode + new mesh reduction.

---
 Object3D.java |   43 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/Object3D.java b/Object3D.java
index 9c74924..56b46d5 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -300,6 +300,7 @@
         }
         
     boolean live = false;
+    boolean dontselect = false;
     boolean hide = false;
     boolean link2master = false; // performs reset support/master at each frame
     boolean marked = false; // animation node
@@ -1834,12 +1835,15 @@
             if (obj.name == null)
                 continue; // can't be a null one
             
+            // Try perfect match first.
             if (n.equals(obj.name))
             {
                 theobj = obj;
                 count++;
             }
         }
+        
+        // not needed: n = n.split(":")[0]; // Poser generates a count
         
     if (count != 1)
         for (int i=Size(); --i>=0;)
@@ -3002,8 +3006,10 @@
                     v.fromParent = LA.newMatrix();
                 }
 
-                LA.matConcat(v.toParent, toParent, v.toParent);
-                LA.matConcat(fromParent, v.fromParent, v.fromParent);
+//                LA.matConcat(v.toParent, toParent, v.toParent);
+//                LA.matConcat(fromParent, v.fromParent, v.fromParent);
+                LA.matConcat(toParent, v.toParent, v.toParent);
+                LA.matConcat(v.fromParent, fromParent, v.fromParent);
             }
 
             toParent = null; // LA.matIdentity(toParent);
@@ -3236,7 +3242,9 @@
         bRep.support = null;
         BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
 //            bRep.SplitInTwo(onlyone); // thread...
-            temprep.SplitInTwo(reduction34, onlyone);
+        
+        while(temprep.SplitInTwo(reduction34, onlyone));
+        
             bRep = temprep;
             bRep.support = sup;
             Touch();
@@ -4711,7 +4719,7 @@
 
     cTreePath SelectLeaf(int indexcount, boolean deselect)
     {
-        if (hide)
+        if (hide || dontselect)
             return null;
         
         if (count <= 0)
@@ -4737,7 +4745,7 @@
     
     cTreePath Select(int indexcount, boolean deselect)
     {
-        if (hide)
+        if (hide || dontselect)
             return null;
             
         if (count <= 0)
@@ -5407,7 +5415,7 @@
     boolean NeedSupport()
     {
         return
-                CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
+                CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
                  // PROBLEM with CROWD!!
                     && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
     }
@@ -5424,7 +5432,7 @@
         }
         
         if (display.DrawMode() == iCameraPane.SELECTION &&
-                hide)
+                (hide || dontselect))
             return;
 
         if (name != null && name.contains("sclera"))
@@ -5666,7 +5674,17 @@
         tex = GetTextures();
     }
 
-    display.BindTextures(tex, texres);
+    boolean failed = false;
+    
+    try
+    {
+        display.BindTextures(tex, texres);
+    }
+    catch (Exception e)
+    {
+        System.err.println("FAILED: " + this);
+        failed = true;
+    }
            
             if (!compiled)
             {
@@ -5688,7 +5706,8 @@
                 }
             }
 
-    display.ReleaseTextures(tex);
+    if (!failed)
+        display.ReleaseTextures(tex);
 
     display.PopMaterial(this, selected);
         }
@@ -5817,6 +5836,9 @@
     
     void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
     {
+        if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
+            return;
+        
         if (hide)
             return;
         // shadow optimisation
@@ -5942,6 +5964,9 @@
         if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
             return; // no shadow for transparent objects
         
+        if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
+            return;
+        
         if (hide)
             return;
         

--
Gitblit v1.6.2