Normand Briere
2019-09-18 f9325048496d7cdbcad233f8a6b84c88e79adcc2
BoundaryRep.java
....@@ -7,7 +7,8 @@
77
88 class BoundaryRep implements java.io.Serializable
99 {
10
- static final long serialVersionUID = -4852664309425035321L;
10
+ static final long serialVersionUID = // VERY old 2008 -5762968998168738314L;
11
+ -4852664309425035321L;
1112
1213 transient int displaylist = 0;
1314
....@@ -530,7 +531,7 @@
530531 static Vertex vertextemp = new Vertex(true);
531532 static Vertex vertextemp2 = new Vertex(true);
532533
533
- static double SEUIL = 0.05f; // 0.1 for rag doll; 0.07;
534
+ static double SEUIL = 0.025f; // 0.1 for rag doll; 0.07;
534535
535536 // Compute weight of point w/r to this
536537 float ComputeWeight(Vertex v, double[][] toRoot, int k)
....@@ -686,6 +687,7 @@
686687
687688 void RecomputeBasis(BoundaryRep other, double[][] toRoot, Vertex v)
688689 {
690
+ CameraPane.CreateSelectedPoint();
689691 CameraPane.selectedpoint.
690692 getAverage(cStatic.point1, true);
691693
....@@ -1003,6 +1005,7 @@
10031005
10041006 v.closestsupport = -1;
10051007
1008
+ CameraPane.CreateSelectedPoint();
10061009 CameraPane.selectedpoint.
10071010 getAverage(cStatic.point1, true);
10081011
....@@ -1261,6 +1264,7 @@
12611264 for (int wi = v0.weights.length; --wi>=0;)
12621265 v[wi] = 0;
12631266
1267
+ CameraPane.CreateSelectedPoint();
12641268 CameraPane.selectedpoint.
12651269 getAverage(cStatic.point1, true);
12661270
....@@ -1398,6 +1402,7 @@
13981402 v0.x = v0.y = v0.z = 0;
13991403 v0.norm.x = v0.norm.y = v0.norm.z = 0;
14001404
1405
+ CameraPane.CreateSelectedPoint();
14011406 CameraPane.selectedpoint.
14021407 getAverage(cStatic.point1, true);
14031408
....@@ -1997,7 +2002,10 @@
19972002 if (v.vertexlinks == null)
19982003 continue;
19992004
2000
- if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0)
2005
+ // Warning: faster but dangerous
2006
+ if (v.weights != null && v.weights[j]
2007
+ == 0)
2008
+ //< 0.001 * v.totalweight)
20012009 {
20022010 //testweight += v.weights[j-1];
20032011 continue;
....@@ -3767,7 +3775,7 @@
37673775
37683776 //tempRep.Unstripify();
37693777
3770
- tempRep.GenerateNormals2(crease);
3778
+ tempRep.GenerateNormals(crease);
37713779
37723780 boolean keepnormal = Vertex.normalmode;
37733781 boolean epsequal = Grafreed.epsequal;
....@@ -3830,6 +3838,9 @@
38303838 if (n == null)
38313839 continue;
38323840
3841
+ if (v.norm == null)
3842
+ v.norm = new cVector();
3843
+
38333844 LA.vecCopy(n, v.norm);
38343845
38353846 this.SetVertex(v, i);
....@@ -3855,6 +3866,28 @@
38553866 }
38563867
38573868 Trim(true/*wastrim*/,true,crease,wasstrip,false);
3869
+ }
3870
+
3871
+ void GenerateNormalsMesh()
3872
+ {
3873
+ if (stripified)
3874
+ {
3875
+ Unstripify();
3876
+ }
3877
+
3878
+ if (trimmed)
3879
+ {
3880
+ normals = null;
3881
+ }
3882
+ else
3883
+ {
3884
+ for (int i=VertexCount(); --i>=0;)
3885
+ {
3886
+ Vertex v = GetVertex(i);
3887
+
3888
+ v.norm = null;
3889
+ }
3890
+ }
38583891 }
38593892
38603893 void GenNormalsJME()
....@@ -3979,7 +4012,7 @@
39794012 NormalGenerator ng;
39804013
39814014 if (crease)
3982
- ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4);
4015
+ ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4);
39834016 else
39844017 ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4);
39854018
....@@ -3997,8 +4030,6 @@
39974030 //System.out.println("NEW = " + positions.length);
39984031 uvmap = new float[ta.getVertexCount() * 2];
39994032
4000
- colors = new float[ta.getVertexCount()]; // * 3];
4001
-
40024033 ta.getCoordinates(0, positions);
40034034 ta.getNormals(0, normals);
40044035 // ta.getColors(0, colors);
....@@ -4006,6 +4037,14 @@
40064037
40074038 System.out.println("UV = " + uvmap[2] + ", " + uvmap[3] + ";");
40084039
4040
+ colors = null;
4041
+// colors = new float[ta.getVertexCount()]; // * 3];
4042
+//
4043
+// for (int i=colors.length; --i>=0;)
4044
+// {
4045
+// colors[i] = 1;
4046
+// }
4047
+
40094048 triangles = new int[ta.getVertexCount()];
40104049
40114050 for (int i = 0; i < triangles.length; i++)
....@@ -4013,8 +4052,9 @@
40134052 triangles[i] = i;
40144053 }
40154054
4016
- Untrim();
4017
- MergeNormals();
4055
+// Untrim();
4056
+ if (!trimmed)
4057
+ MergeNormals();
40184058 }
40194059 }
40204060
....@@ -4042,17 +4082,18 @@
40424082 positions = new float[3 * ga.getVertexCount()];
40434083 normals = new float[3 * ga.getVertexCount()];
40444084 uvmap = new float[2 * ga.getVertexCount()];
4045
- colors = new float[1 * ga.getVertexCount()];
40464085
40474086 tsa.getCoordinates(0, positions);
40484087 tsa.getNormals(0, normals);
40494088 tsa.getTextureCoordinates(0, 0, uvmap);
40504089 // tsa.getColors(0, colors);
4051
-
4052
- for (int i=colors.length; --i>=0;)
4053
- {
4054
- colors[i] = 1;
4055
- }
4090
+
4091
+ colors = null;
4092
+// colors = new float[1 * ga.getVertexCount()];
4093
+// for (int i=colors.length; --i>=0;)
4094
+// {
4095
+// colors[i] = 1;
4096
+// }
40564097
40574098 int stripcount = tsa.getNumStrips();
40584099 triangles = new int[stripcount];
....@@ -4061,6 +4102,7 @@
40614102 stripified = true;
40624103 } catch (ClassCastException e)
40634104 {
4105
+ // ??? aug 2019
40644106 TriangleArray ta = (TriangleArray) ga;
40654107
40664108 positions = new float[3 * ga.getVertexCount()];
....@@ -4076,8 +4118,9 @@
40764118 triangles[0] = 3;
40774119 }
40784120
4079
- Untrim();
4080
- MergeNormals();
4121
+ //Untrim();
4122
+ if (!trimmed)
4123
+ MergeNormals();
40814124 }
40824125
40834126 /*
....@@ -4131,6 +4174,8 @@
41314174
41324175 void MergeNormals()
41334176 {
4177
+ assert(!trimmed);
4178
+
41344179 boolean smooth = Grafreed.smoothmode;
41354180 boolean link = Grafreed.linkUV;
41364181 Grafreed.smoothmode = true;
....@@ -4942,9 +4987,18 @@
49424987 v./*pos.*/y = positions[i3 + 1];
49434988 v./*pos.*/z = positions[i3 + 2];
49444989
4945
- v.norm.x = normals[i3];
4946
- v.norm.y = normals[i3 + 1];
4947
- v.norm.z = normals[i3 + 2];
4990
+ if (normals == null)
4991
+ {
4992
+ v.norm.x = 0;
4993
+ v.norm.y = 0;
4994
+ v.norm.z = 0;
4995
+ }
4996
+ else
4997
+ {
4998
+ v.norm.x = normals[i3];
4999
+ v.norm.y = normals[i3 + 1];
5000
+ v.norm.z = normals[i3 + 2];
5001
+ }
49485002
49495003 v.s = uvmap[i2];
49505004 v.t = uvmap[i2 + 1];