Normand Briere
2019-07-30 7a77e39423398b7ad8bf7e80cf45fac6817000c2
BoundaryRep.java
....@@ -1997,7 +1997,10 @@
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]
2002
+ // == 0)
2003
+ < 0.001 * v.totalweight)
20012004 {
20022005 //testweight += v.weights[j-1];
20032006 continue;
....@@ -3857,6 +3860,28 @@
38573860 Trim(true/*wastrim*/,true,crease,wasstrip,false);
38583861 }
38593862
3863
+ void GenerateNormalsMesh()
3864
+ {
3865
+ if (stripified)
3866
+ {
3867
+ Unstripify();
3868
+ }
3869
+
3870
+ if (trimmed)
3871
+ {
3872
+ normals = null;
3873
+ }
3874
+ else
3875
+ {
3876
+ for (int i=VertexCount(); --i>=0;)
3877
+ {
3878
+ Vertex v = GetVertex(i);
3879
+
3880
+ v.norm = null;
3881
+ }
3882
+ }
3883
+ }
3884
+
38603885 void GenNormalsJME()
38613886 {
38623887 assert(false);
....@@ -3979,7 +4004,7 @@
39794004 NormalGenerator ng;
39804005
39814006 if (crease)
3982
- ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4);
4007
+ ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4);
39834008 else
39844009 ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4);
39854010
....@@ -4013,8 +4038,9 @@
40134038 triangles[i] = i;
40144039 }
40154040
4016
- Untrim();
4017
- MergeNormals();
4041
+// Untrim();
4042
+ if (!trimmed)
4043
+ MergeNormals();
40184044 }
40194045 }
40204046
....@@ -4076,8 +4102,9 @@
40764102 triangles[0] = 3;
40774103 }
40784104
4079
- Untrim();
4080
- MergeNormals();
4105
+ //Untrim();
4106
+ if (!trimmed)
4107
+ MergeNormals();
40814108 }
40824109
40834110 /*
....@@ -4131,6 +4158,8 @@
41314158
41324159 void MergeNormals()
41334160 {
4161
+ assert(!trimmed);
4162
+
41344163 boolean smooth = Grafreed.smoothmode;
41354164 boolean link = Grafreed.linkUV;
41364165 Grafreed.smoothmode = true;
....@@ -4942,9 +4971,18 @@
49424971 v./*pos.*/y = positions[i3 + 1];
49434972 v./*pos.*/z = positions[i3 + 2];
49444973
4945
- v.norm.x = normals[i3];
4946
- v.norm.y = normals[i3 + 1];
4947
- v.norm.z = normals[i3 + 2];
4974
+ if (normals == null)
4975
+ {
4976
+ v.norm.x = 0;
4977
+ v.norm.y = 0;
4978
+ v.norm.z = 0;
4979
+ }
4980
+ else
4981
+ {
4982
+ v.norm.x = normals[i3];
4983
+ v.norm.y = normals[i3 + 1];
4984
+ v.norm.z = normals[i3 + 2];
4985
+ }
49484986
49494987 v.s = uvmap[i2];
49504988 v.t = uvmap[i2 + 1];