From 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 25 Aug 2019 20:58:10 -0400
Subject: [PATCH] Proto version slider.

---
 Object3D.java |  118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/Object3D.java b/Object3D.java
index 3c575b0..9d52cb0 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -40,6 +40,19 @@
     
     ScriptNode scriptnode;
 
+    int VersionCount()
+    {
+        int count = 0;
+        
+        for (int i = versionlist.length; --i >= 0;)
+        {
+            if (versionlist[i] != null)
+                count++;
+        }
+        
+        return count;
+    }
+    
         void InitOthers()
         {
                 if (projectedVertices == null || projectedVertices.length <= 2)
@@ -568,11 +581,11 @@
         }
     }
     
-    int memorysize;
+    transient int memorysize; // needs to be transient, dunno why
     
     int MemorySize()
     {
-        if (true) // memorysize == 0)
+        if (memorysize == 0)
         {
             try
             {
@@ -3264,6 +3277,93 @@
     blockloop = false;
 }
             
+    public void ResetTransform(int mask)
+    {
+        Object3D obj = this;
+        
+        if (mask == -1)
+        {
+            if (obj instanceof Camera) // jan 2014
+            {
+                LA.matIdentity(obj.toParent);
+                LA.matIdentity(obj.fromParent);
+            }
+            else
+            {
+                obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
+                obj.fromParent = null; // LA.matIdentity(obj.fromParent);
+            }
+            return;
+        }
+        
+        if ((mask&2) != 0) // Scale/rotation
+        {
+            obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
+            obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
+            obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
+            obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
+            obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
+            obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
+        }
+        if ((mask&1) != 0) // Translation
+        {
+            if (obj.toParent != null)
+            {
+                obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
+                obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
+            }
+        }
+    }
+    
+    public void TextureRatioTransform(int axis)
+    {
+        cTexture tex = GetTextures();
+
+        com.sun.opengl.util.texture.TextureData texturedata = null;
+
+        try
+        {
+            texturedata = Globals.theRenderer.GetTextureData(tex, false, texres);
+        }
+        catch (Exception e)
+        {
+            System.err.println("FAIL TextureRatio: " + this);
+        }
+        
+        LA.matIdentity(Object3D.mat);
+        Object3D.mat[axis][axis] = (double)texturedata.getWidth() / texturedata.getHeight();
+
+        if (toParent == null)
+        {
+            toParent = LA.newMatrix();
+            fromParent = LA.newMatrix();
+        }
+
+        ResetTransform(2);
+        
+        LA.matConcat(Object3D.mat, fromParent, fromParent);
+        LA.matInvert(fromParent, toParent);
+    }
+
+    void TextureRatio(int axis)
+    {
+        if (blockloop)
+            return;
+
+        blockloop = true;
+        
+        TextureRatioTransform(axis);
+        
+        for (int i=Size(); --i>=0;)
+        {
+            Object3D v = get(i);
+
+            v.TextureRatio(axis);
+        }
+
+        blockloop = false;
+    }
+
     void TransformChildren()
     {
         if (toParent != null)
@@ -5969,6 +6069,11 @@
         return parent.IsLive();
     }
     
+    boolean IsDynamic()
+    {
+        return live && bRep != null;
+    }
+    
     void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
     {
         Invariants(); // june 2013
@@ -6029,7 +6134,8 @@
         if (support != null)
             support = support;
         
-        boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
+        boolean usecalllists = !IsDynamic() &&
+                                    IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
         //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
         
         //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
@@ -8075,10 +8181,10 @@
         } //  + super.toString();
     //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
         
-        if (!Globals.ADVANCED)
-            return objname;
+//        if (!Globals.ADVANCED)
+//            return objname;
         
-        return objname + " " + System.identityHashCode(this);
+        return objname + " " + System.identityHashCode(this); // + GetUUID()
     }
 
     public int hashCode()

--
Gitblit v1.6.2