From f9325048496d7cdbcad233f8a6b84c88e79adcc2 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Tue, 17 Sep 2019 20:11:47 -0400
Subject: [PATCH] Rename link2master to link2support.

---
 BoundaryRep.java |   94 +++++++++++++++++++++++++++++++++++++----------
 1 files changed, 74 insertions(+), 20 deletions(-)

diff --git a/BoundaryRep.java b/BoundaryRep.java
index 3583aa0..6fecd44 100644
--- a/BoundaryRep.java
+++ b/BoundaryRep.java
@@ -7,7 +7,8 @@
 
 class BoundaryRep implements java.io.Serializable
 {
-    static final long serialVersionUID = -4852664309425035321L;
+    static final long serialVersionUID = // VERY old 2008 -5762968998168738314L;
+                                        -4852664309425035321L;
 
     transient int displaylist = 0;
     
@@ -530,7 +531,7 @@
     static Vertex vertextemp = new Vertex(true);
     static Vertex vertextemp2 = new Vertex(true);
     
-    static double SEUIL = 0.05f; // 0.1 for rag doll; 0.07;
+    static double SEUIL = 0.025f; // 0.1 for rag doll; 0.07;
         
     // Compute weight of point w/r to this
     float ComputeWeight(Vertex v, double[][] toRoot, int k)
@@ -686,6 +687,7 @@
     
     void RecomputeBasis(BoundaryRep other, double[][] toRoot, Vertex v)
     {
+        CameraPane.CreateSelectedPoint();
         CameraPane.selectedpoint.
             getAverage(cStatic.point1, true);
 
@@ -1003,6 +1005,7 @@
             
             v.closestsupport = -1;
             
+        CameraPane.CreateSelectedPoint();
         CameraPane.selectedpoint.
             getAverage(cStatic.point1, true);
 
@@ -1261,6 +1264,7 @@
         for (int wi = v0.weights.length; --wi>=0;)
             v[wi] = 0;
             
+        CameraPane.CreateSelectedPoint();
         CameraPane.selectedpoint.
             getAverage(cStatic.point1, true);
 
@@ -1398,6 +1402,7 @@
         v0.x = v0.y = v0.z = 0;
         v0.norm.x = v0.norm.y = v0.norm.z = 0;
             
+        CameraPane.CreateSelectedPoint();
         CameraPane.selectedpoint.
             getAverage(cStatic.point1, true);
 
@@ -1997,7 +2002,10 @@
                 if (v.vertexlinks == null)
                     continue;
                 
-                if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0)
+                // Warning: faster but dangerous
+                if (v.weights != null && v.weights[j]
+                         == 0)
+                        //< 0.001 * v.totalweight)
                 {
                     //testweight += v.weights[j-1];
                     continue;
@@ -3767,7 +3775,7 @@
         
         //tempRep.Unstripify();
         
-        tempRep.GenerateNormals2(crease);
+        tempRep.GenerateNormals(crease);
         
         boolean keepnormal = Vertex.normalmode;
         boolean epsequal = Grafreed.epsequal;
@@ -3830,6 +3838,9 @@
             if (n == null)
                 continue;
             
+            if (v.norm == null)
+                v.norm = new cVector();
+            
             LA.vecCopy(n, v.norm);
             
             this.SetVertex(v, i);
@@ -3855,6 +3866,28 @@
         }
         
         Trim(true/*wastrim*/,true,crease,wasstrip,false);
+    }
+    
+    void GenerateNormalsMesh()
+    {
+        if (stripified)
+        {
+            Unstripify();
+        }
+        
+        if (trimmed)
+        {
+            normals = null;
+        }
+        else
+        {
+            for (int i=VertexCount(); --i>=0;)
+            {
+                Vertex v = GetVertex(i);
+
+                v.norm = null;
+            }
+        }
     }
     
     void GenNormalsJME()
@@ -3979,7 +4012,7 @@
             NormalGenerator ng;
             
             if (crease)
-                ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4);
+                ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4);
             else
                 ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4);
             
@@ -3997,8 +4030,6 @@
                 //System.out.println("NEW = " + positions.length);
                 uvmap = new float[ta.getVertexCount() * 2];
                 
-                colors = new float[ta.getVertexCount()]; // * 3];
-
                 ta.getCoordinates(0, positions);
                 ta.getNormals(0, normals);
 //                ta.getColors(0, colors);
@@ -4006,6 +4037,14 @@
 
                 System.out.println("UV = " + uvmap[2] + ", " + uvmap[3] + ";");
 
+                colors = null;
+//                colors = new float[ta.getVertexCount()]; // * 3];
+//
+//                for (int i=colors.length; --i>=0;)
+//                {
+//                        colors[i] = 1;
+//                }
+                
                 triangles = new int[ta.getVertexCount()];
 
                 for (int i = 0; i < triangles.length; i++)
@@ -4013,8 +4052,9 @@
                     triangles[i] = i;
                 }
                 
-                Untrim();
-                MergeNormals();
+//                Untrim();
+                if (!trimmed)
+                    MergeNormals();
             }
         }
 
@@ -4042,17 +4082,18 @@
                 positions = new float[3 * ga.getVertexCount()];
                 normals = new float[3 * ga.getVertexCount()];
                 uvmap = new float[2 * ga.getVertexCount()];
-                colors = new float[1 * ga.getVertexCount()];
 
                 tsa.getCoordinates(0, positions);
                 tsa.getNormals(0, normals);
                 tsa.getTextureCoordinates(0, 0, uvmap);
            //     tsa.getColors(0, colors);
-                
-                for (int i=colors.length; --i>=0;)
-                {
-                        colors[i] = 1;
-                }
+
+                colors = null;
+//                colors = new float[1 * ga.getVertexCount()];
+//                for (int i=colors.length; --i>=0;)
+//                {
+//                        colors[i] = 1;
+//                }
 
                 int stripcount = tsa.getNumStrips();
                 triangles = new int[stripcount];
@@ -4061,6 +4102,7 @@
                 stripified = true;
             } catch (ClassCastException e)
             {
+                // ??? aug 2019
                 TriangleArray ta = (TriangleArray) ga;
 
                 positions = new float[3 * ga.getVertexCount()];
@@ -4076,8 +4118,9 @@
                 triangles[0] = 3;
             }
             
-            Untrim();
-            MergeNormals();
+            //Untrim();
+            if (!trimmed)
+                MergeNormals();
         }
 
     /*
@@ -4131,6 +4174,8 @@
     
     void MergeNormals()
     {
+        assert(!trimmed);
+        
         boolean smooth = Grafreed.smoothmode;
         boolean link = Grafreed.linkUV;
         Grafreed.smoothmode = true;
@@ -4942,9 +4987,18 @@
             v./*pos.*/y = positions[i3 + 1];
             v./*pos.*/z = positions[i3 + 2];
 
-            v.norm.x = normals[i3];
-            v.norm.y = normals[i3 + 1];
-            v.norm.z = normals[i3 + 2];
+            if (normals == null)
+            {
+                v.norm.x = 0;
+                v.norm.y = 0;
+                v.norm.z = 0;
+            }
+            else
+            {
+                v.norm.x = normals[i3];
+                v.norm.y = normals[i3 + 1];
+                v.norm.z = normals[i3 + 2];
+            }
 
             v.s = uvmap[i2];
             v.t = uvmap[i2 + 1];

--
Gitblit v1.6.2