Normand Briere
2019-07-30 475f8cbdbd96fdbf8f5b216ffebb31a51f25c2f9
BoundaryRep.java
....@@ -1997,7 +1997,9 @@
19971997 if (v.vertexlinks == null)
19981998 continue;
19991999
2000
- if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0)
2000
+ // Warning: a bit faster but dangerous
2001
+ if (v.weights != null && v.weights[j] == 0)
2002
+ // < 0.001 * v.totalweight)
20012003 {
20022004 //testweight += v.weights[j-1];
20032005 continue;
....@@ -3857,6 +3859,28 @@
38573859 Trim(true/*wastrim*/,true,crease,wasstrip,false);
38583860 }
38593861
3862
+ void GenerateNormalsMesh()
3863
+ {
3864
+ if (stripified)
3865
+ {
3866
+ Unstripify();
3867
+ }
3868
+
3869
+ if (trimmed)
3870
+ {
3871
+ normals = null;
3872
+ }
3873
+ else
3874
+ {
3875
+ for (int i=VertexCount(); --i>=0;)
3876
+ {
3877
+ Vertex v = GetVertex(i);
3878
+
3879
+ v.norm = null;
3880
+ }
3881
+ }
3882
+ }
3883
+
38603884 void GenNormalsJME()
38613885 {
38623886 assert(false);
....@@ -3979,7 +4003,7 @@
39794003 NormalGenerator ng;
39804004
39814005 if (crease)
3982
- ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4);
4006
+ ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4);
39834007 else
39844008 ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4);
39854009
....@@ -4013,8 +4037,9 @@
40134037 triangles[i] = i;
40144038 }
40154039
4016
- Untrim();
4017
- MergeNormals();
4040
+// Untrim();
4041
+ if (!trimmed)
4042
+ MergeNormals();
40184043 }
40194044 }
40204045
....@@ -4076,8 +4101,9 @@
40764101 triangles[0] = 3;
40774102 }
40784103
4079
- Untrim();
4080
- MergeNormals();
4104
+ //Untrim();
4105
+ if (!trimmed)
4106
+ MergeNormals();
40814107 }
40824108
40834109 /*
....@@ -4131,6 +4157,8 @@
41314157
41324158 void MergeNormals()
41334159 {
4160
+ assert(!trimmed);
4161
+
41344162 boolean smooth = Grafreed.smoothmode;
41354163 boolean link = Grafreed.linkUV;
41364164 Grafreed.smoothmode = true;
....@@ -4942,9 +4970,18 @@
49424970 v./*pos.*/y = positions[i3 + 1];
49434971 v./*pos.*/z = positions[i3 + 2];
49444972
4945
- v.norm.x = normals[i3];
4946
- v.norm.y = normals[i3 + 1];
4947
- v.norm.z = normals[i3 + 2];
4973
+ if (normals == null)
4974
+ {
4975
+ v.norm.x = 0;
4976
+ v.norm.y = 0;
4977
+ v.norm.z = 0;
4978
+ }
4979
+ else
4980
+ {
4981
+ v.norm.x = normals[i3];
4982
+ v.norm.y = normals[i3 + 1];
4983
+ v.norm.z = normals[i3 + 2];
4984
+ }
49484985
49494986 v.s = uvmap[i2];
49504987 v.t = uvmap[i2 + 1];