Normand Briere
2019-09-02 21ac57b36a9e3b909853c7d64ac29b7ad72490a3
BoundaryRep.java
....@@ -686,6 +686,7 @@
686686
687687 void RecomputeBasis(BoundaryRep other, double[][] toRoot, Vertex v)
688688 {
689
+ CameraPane.CreateSelectedPoint();
689690 CameraPane.selectedpoint.
690691 getAverage(cStatic.point1, true);
691692
....@@ -1003,6 +1004,7 @@
10031004
10041005 v.closestsupport = -1;
10051006
1007
+ CameraPane.CreateSelectedPoint();
10061008 CameraPane.selectedpoint.
10071009 getAverage(cStatic.point1, true);
10081010
....@@ -1261,6 +1263,7 @@
12611263 for (int wi = v0.weights.length; --wi>=0;)
12621264 v[wi] = 0;
12631265
1266
+ CameraPane.CreateSelectedPoint();
12641267 CameraPane.selectedpoint.
12651268 getAverage(cStatic.point1, true);
12661269
....@@ -1398,6 +1401,7 @@
13981401 v0.x = v0.y = v0.z = 0;
13991402 v0.norm.x = v0.norm.y = v0.norm.z = 0;
14001403
1404
+ CameraPane.CreateSelectedPoint();
14011405 CameraPane.selectedpoint.
14021406 getAverage(cStatic.point1, true);
14031407
....@@ -1997,7 +2001,10 @@
19972001 if (v.vertexlinks == null)
19982002 continue;
19992003
2000
- if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0)
2004
+ // Warning: faster but dangerous
2005
+ if (v.weights != null && v.weights[j]
2006
+ // == 0)
2007
+ < 0.0001 * v.totalweight)
20012008 {
20022009 //testweight += v.weights[j-1];
20032010 continue;
....@@ -3857,6 +3864,28 @@
38573864 Trim(true/*wastrim*/,true,crease,wasstrip,false);
38583865 }
38593866
3867
+ void GenerateNormalsMesh()
3868
+ {
3869
+ if (stripified)
3870
+ {
3871
+ Unstripify();
3872
+ }
3873
+
3874
+ if (trimmed)
3875
+ {
3876
+ normals = null;
3877
+ }
3878
+ else
3879
+ {
3880
+ for (int i=VertexCount(); --i>=0;)
3881
+ {
3882
+ Vertex v = GetVertex(i);
3883
+
3884
+ v.norm = null;
3885
+ }
3886
+ }
3887
+ }
3888
+
38603889 void GenNormalsJME()
38613890 {
38623891 assert(false);
....@@ -3979,7 +4008,7 @@
39794008 NormalGenerator ng;
39804009
39814010 if (crease)
3982
- ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4);
4011
+ ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4);
39834012 else
39844013 ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4);
39854014
....@@ -3997,8 +4026,6 @@
39974026 //System.out.println("NEW = " + positions.length);
39984027 uvmap = new float[ta.getVertexCount() * 2];
39994028
4000
- colors = new float[ta.getVertexCount()]; // * 3];
4001
-
40024029 ta.getCoordinates(0, positions);
40034030 ta.getNormals(0, normals);
40044031 // ta.getColors(0, colors);
....@@ -4006,6 +4033,14 @@
40064033
40074034 System.out.println("UV = " + uvmap[2] + ", " + uvmap[3] + ";");
40084035
4036
+ colors = null;
4037
+// colors = new float[ta.getVertexCount()]; // * 3];
4038
+//
4039
+// for (int i=colors.length; --i>=0;)
4040
+// {
4041
+// colors[i] = 1;
4042
+// }
4043
+
40094044 triangles = new int[ta.getVertexCount()];
40104045
40114046 for (int i = 0; i < triangles.length; i++)
....@@ -4013,8 +4048,9 @@
40134048 triangles[i] = i;
40144049 }
40154050
4016
- Untrim();
4017
- MergeNormals();
4051
+// Untrim();
4052
+ if (!trimmed)
4053
+ MergeNormals();
40184054 }
40194055 }
40204056
....@@ -4042,17 +4078,18 @@
40424078 positions = new float[3 * ga.getVertexCount()];
40434079 normals = new float[3 * ga.getVertexCount()];
40444080 uvmap = new float[2 * ga.getVertexCount()];
4045
- colors = new float[1 * ga.getVertexCount()];
40464081
40474082 tsa.getCoordinates(0, positions);
40484083 tsa.getNormals(0, normals);
40494084 tsa.getTextureCoordinates(0, 0, uvmap);
40504085 // tsa.getColors(0, colors);
4051
-
4052
- for (int i=colors.length; --i>=0;)
4053
- {
4054
- colors[i] = 1;
4055
- }
4086
+
4087
+ colors = null;
4088
+// colors = new float[1 * ga.getVertexCount()];
4089
+// for (int i=colors.length; --i>=0;)
4090
+// {
4091
+// colors[i] = 1;
4092
+// }
40564093
40574094 int stripcount = tsa.getNumStrips();
40584095 triangles = new int[stripcount];
....@@ -4061,6 +4098,7 @@
40614098 stripified = true;
40624099 } catch (ClassCastException e)
40634100 {
4101
+ // ??? aug 2019
40644102 TriangleArray ta = (TriangleArray) ga;
40654103
40664104 positions = new float[3 * ga.getVertexCount()];
....@@ -4076,8 +4114,9 @@
40764114 triangles[0] = 3;
40774115 }
40784116
4079
- Untrim();
4080
- MergeNormals();
4117
+ //Untrim();
4118
+ if (!trimmed)
4119
+ MergeNormals();
40814120 }
40824121
40834122 /*
....@@ -4131,6 +4170,8 @@
41314170
41324171 void MergeNormals()
41334172 {
4173
+ assert(!trimmed);
4174
+
41344175 boolean smooth = Grafreed.smoothmode;
41354176 boolean link = Grafreed.linkUV;
41364177 Grafreed.smoothmode = true;
....@@ -4942,9 +4983,18 @@
49424983 v./*pos.*/y = positions[i3 + 1];
49434984 v./*pos.*/z = positions[i3 + 2];
49444985
4945
- v.norm.x = normals[i3];
4946
- v.norm.y = normals[i3 + 1];
4947
- v.norm.z = normals[i3 + 2];
4986
+ if (normals == null)
4987
+ {
4988
+ v.norm.x = 0;
4989
+ v.norm.y = 0;
4990
+ v.norm.z = 0;
4991
+ }
4992
+ else
4993
+ {
4994
+ v.norm.x = normals[i3];
4995
+ v.norm.y = normals[i3 + 1];
4996
+ v.norm.z = normals[i3 + 2];
4997
+ }
49484998
49494999 v.s = uvmap[i2];
49505000 v.t = uvmap[i2 + 1];