From e36047725ce3217618d4e5807ac7c8769b9e3598 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 17 Jun 2019 19:45:55 -0400
Subject: [PATCH] Split pigment bump.

---
 Object3D.java |  112 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 96 insertions(+), 16 deletions(-)

diff --git a/Object3D.java b/Object3D.java
index d7a346f..d6e0e59 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -174,7 +174,7 @@
         {
             Object3D o = hashtable.get(GetUUID());
 
-            assert(this.bRep == o.bRep);
+            Grafreed.Assert(this.bRep == o.bRep);
             if (this.bRep != null)
                 assert(this.bRep.support == o.transientrep);
 
@@ -563,12 +563,14 @@
             toParent = LA.newMatrix();
             fromParent = LA.newMatrix();
         }
+        
         if (toParentMarked == null)
         {
             if (maxcount != 1)
             {
                 new Exception().printStackTrace();
             }
+            
             toParentMarked = LA.newMatrix();
             fromParentMarked = LA.newMatrix();
         }
@@ -4349,6 +4351,55 @@
         }
     }
     
+    void RepairSOV()
+    {
+        if (blockloop)
+            return;
+
+        String texname = this.GetPigmentTexture();
+        
+        if (texname.startsWith("sov"))
+        {
+            String[] s = texname.split("/");
+
+            String[] sname = s[1].split("Color.pn");
+            
+            texname = sname[0];
+            
+            if (sname.length > 1)
+            {
+                texname += "Color.jpg";
+            }
+            
+            this.SetPigmentTexture("sov/" + texname);
+        }
+                
+        texname = this.GetBumpTexture();
+        
+        if (texname.startsWith("sov"))
+        {
+            String[] s = texname.split("/");
+
+            String[] sname = s[1].split("Bump.pn");
+            
+            texname = sname[0];
+            
+            if (sname.length > 1)
+            {
+                texname += "Bump.jpg";
+            }
+            
+            this.SetBumpTexture("sov/" + texname);
+        }
+                
+        for (int i=0; i<Size(); i++)
+        {               
+                blockloop = true;
+            get(i).RepairSOV();
+                blockloop = false;
+        }
+    }
+    
     void RepairTexture()
     {
         if (this instanceof FileObject || blockloop)
@@ -5572,12 +5623,23 @@
     boolean NeedSupport()
     {
         return
-                CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
+                CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
                  // PROBLEM with CROWD!!
                     && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
     }
     
     static boolean DEBUG_SELECTION = false;
+    
+    boolean IsLive()
+    {
+        if (live)
+            return true;
+        
+        if (parent == null)
+            return false;
+        
+        return parent.IsLive();
+    }
     
     void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
     {
@@ -5640,7 +5702,7 @@
             support = support;
         
         //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
-        boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
+        boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
         
         if (!usecalllists && bRep != null && bRep.displaylist > 0)
         {
@@ -5660,10 +5722,12 @@
         boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
         
         if (!selectmode && //display.DrawMode() != display.SELECTION &&
-                (touched || (bRep != null && bRep.displaylist <= 0)))
+                //(touched || (bRep != null && bRep.displaylist <= 0)))
+                (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
         {
             Globals.lighttouched = true;
         } // all panes...
+        
         //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
         if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
                 (touched || (bRep != null && bRep.displaylist <= 0)))
@@ -5831,16 +5895,27 @@
         tex = GetTextures();
     }
 
-    boolean failed = false;
+    boolean failedPigment = false;
+    boolean failedBump = false;
     
     try
     {
-        display.BindTextures(tex, texres);
+        display.BindPigmentTexture(tex, texres);
     }
     catch (Exception e)
     {
         System.err.println("FAILED: " + this);
-        failed = true;
+        failedPigment = true;
+    }
+           
+    try
+    {
+        display.BindBumpTexture(tex, texres);
+    }
+    catch (Exception e)
+    {
+        //System.err.println("FAILED: " + this);
+        failedBump = true;
     }
            
             if (!compiled)
@@ -5863,8 +5938,11 @@
                 }
             }
 
-    if (!failed)
-        display.ReleaseTextures(tex);
+    if (!failedBump)
+        display.ReleaseBumpTexture(tex);
+
+    if (!failedPigment)
+        display.ReleasePigmentTexture(tex);
 
     display.PopMaterial(this, selected);
         }
@@ -7089,7 +7167,7 @@
             spot.translate(32, 32);
             spotw = spot.x + spot.width;
             spoth = spot.y + spot.height;
-            info.g.setColor(Color.blue);
+            info.g.setColor(Color.cyan);
             info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
 //            if (CameraPane.Xmin > spot.x)
 //            {
@@ -7107,11 +7185,12 @@
 //            {
 //                CameraPane.Ymax = spoth;
 //            }
-            // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
-            //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
+            // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
+            //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
             spot.translate(0, -32);
-            info.g.setColor(Color.green);
+            info.g.setColor(Color.yellow);
             info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
+            info.g.setColor(Color.green);
 //            if (CameraPane.Xmin > spot.x)
 //            {
 //                CameraPane.Xmin = spot.x;
@@ -7429,19 +7508,20 @@
                 switch (info.pane.RenderCamera().viewCode)
                 {
                     case 3: // '\001'
-                        if (modified)
+                        if (modified || opposite)
                         {
                             //LA.matScale(toParent, 1, hScale, vScale);
                             LA.matScale(toParent, totalScale, 1, 1);
                         } // vScale, 1);
                         else
                         {
+                            // EXCEPTION!
                             LA.matScale(toParent, totalScale, totalScale, totalScale);
                         } // vScale, 1);
                         break;
 
                     case 2: // '\002'
-                        if (modified)
+                        if (modified || opposite)
                         {
                             //LA.matScale(toParent, hScale, 1, vScale);
                             LA.matScale(toParent, 1, totalScale, 1);
@@ -7452,7 +7532,7 @@
                         break;
 
                     case 1: // '\003'
-                        if (modified)
+                        if (modified || opposite)
                         {
                             //LA.matScale(toParent, hScale, vScale, 1);
                             LA.matScale(toParent, 1, 1, totalScale);

--
Gitblit v1.6.2