From cf7cfa1c792eebba606a48aa648893f6e4873263 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 22 Jul 2019 23:03:04 -0400
Subject: [PATCH] Embed JPEG.

---
 BoundaryRep.java |   51 +++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/BoundaryRep.java b/BoundaryRep.java
index 3583aa0..797e9f7 100644
--- a/BoundaryRep.java
+++ b/BoundaryRep.java
@@ -3857,6 +3857,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()
     {
         assert(false);
@@ -3979,7 +4001,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);
             
@@ -4013,8 +4035,9 @@
                     triangles[i] = i;
                 }
                 
-                Untrim();
-                MergeNormals();
+//                Untrim();
+                if (!trimmed)
+                    MergeNormals();
             }
         }
 
@@ -4076,8 +4099,9 @@
                 triangles[0] = 3;
             }
             
-            Untrim();
-            MergeNormals();
+            //Untrim();
+            if (!trimmed)
+                MergeNormals();
         }
 
     /*
@@ -4131,6 +4155,8 @@
     
     void MergeNormals()
     {
+        assert(!trimmed);
+        
         boolean smooth = Grafreed.smoothmode;
         boolean link = Grafreed.linkUV;
         Grafreed.smoothmode = true;
@@ -4942,9 +4968,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