Normand Briere
2019-07-24 ebd16116fc612bf14e2469ba27dd7ee54918eabb
BoundaryRep.java
....@@ -1997,7 +1997,8 @@
19971997 if (v.vertexlinks == null)
19981998 continue;
19991999
2000
- if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0)
2000
+ // Warning: faster but dangerous
2001
+ if (v.weights != null && v.weights[j] == 0) // < 0.001 * v.totalweight)
20012002 {
20022003 //testweight += v.weights[j-1];
20032004 continue;
....@@ -3857,6 +3858,28 @@
38573858 Trim(true/*wastrim*/,true,crease,wasstrip,false);
38583859 }
38593860
3861
+ void GenerateNormalsMesh()
3862
+ {
3863
+ if (stripified)
3864
+ {
3865
+ Unstripify();
3866
+ }
3867
+
3868
+ if (trimmed)
3869
+ {
3870
+ normals = null;
3871
+ }
3872
+ else
3873
+ {
3874
+ for (int i=VertexCount(); --i>=0;)
3875
+ {
3876
+ Vertex v = GetVertex(i);
3877
+
3878
+ v.norm = null;
3879
+ }
3880
+ }
3881
+ }
3882
+
38603883 void GenNormalsJME()
38613884 {
38623885 assert(false);
....@@ -3979,7 +4002,7 @@
39794002 NormalGenerator ng;
39804003
39814004 if (crease)
3982
- ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4);
4005
+ ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4);
39834006 else
39844007 ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4);
39854008
....@@ -4013,8 +4036,9 @@
40134036 triangles[i] = i;
40144037 }
40154038
4016
- Untrim();
4017
- MergeNormals();
4039
+// Untrim();
4040
+ if (!trimmed)
4041
+ MergeNormals();
40184042 }
40194043 }
40204044
....@@ -4076,8 +4100,9 @@
40764100 triangles[0] = 3;
40774101 }
40784102
4079
- Untrim();
4080
- MergeNormals();
4103
+ //Untrim();
4104
+ if (!trimmed)
4105
+ MergeNormals();
40814106 }
40824107
40834108 /*
....@@ -4131,6 +4156,8 @@
41314156
41324157 void MergeNormals()
41334158 {
4159
+ assert(!trimmed);
4160
+
41344161 boolean smooth = Grafreed.smoothmode;
41354162 boolean link = Grafreed.linkUV;
41364163 Grafreed.smoothmode = true;
....@@ -4942,9 +4969,18 @@
49424969 v./*pos.*/y = positions[i3 + 1];
49434970 v./*pos.*/z = positions[i3 + 2];
49444971
4945
- v.norm.x = normals[i3];
4946
- v.norm.y = normals[i3 + 1];
4947
- v.norm.z = normals[i3 + 2];
4972
+ if (normals == null)
4973
+ {
4974
+ v.norm.x = 0;
4975
+ v.norm.y = 0;
4976
+ v.norm.z = 0;
4977
+ }
4978
+ else
4979
+ {
4980
+ v.norm.x = normals[i3];
4981
+ v.norm.y = normals[i3 + 1];
4982
+ v.norm.z = normals[i3 + 2];
4983
+ }
49484984
49494985 v.s = uvmap[i2];
49504986 v.t = uvmap[i2 + 1];