.. | .. |
---|
1997 | 1997 | if (v.vertexlinks == null) |
---|
1998 | 1998 | continue; |
---|
1999 | 1999 | |
---|
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) |
---|
2001 | 2003 | { |
---|
2002 | 2004 | //testweight += v.weights[j-1]; |
---|
2003 | 2005 | continue; |
---|
.. | .. |
---|
3857 | 3859 | Trim(true/*wastrim*/,true,crease,wasstrip,false); |
---|
3858 | 3860 | } |
---|
3859 | 3861 | |
---|
| 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 | + |
---|
3860 | 3884 | void GenNormalsJME() |
---|
3861 | 3885 | { |
---|
3862 | 3886 | assert(false); |
---|
.. | .. |
---|
3979 | 4003 | NormalGenerator ng; |
---|
3980 | 4004 | |
---|
3981 | 4005 | 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); |
---|
3983 | 4007 | else |
---|
3984 | 4008 | ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4); |
---|
3985 | 4009 | |
---|
.. | .. |
---|
4013 | 4037 | triangles[i] = i; |
---|
4014 | 4038 | } |
---|
4015 | 4039 | |
---|
4016 | | - Untrim(); |
---|
4017 | | - MergeNormals(); |
---|
| 4040 | +// Untrim(); |
---|
| 4041 | + if (!trimmed) |
---|
| 4042 | + MergeNormals(); |
---|
4018 | 4043 | } |
---|
4019 | 4044 | } |
---|
4020 | 4045 | |
---|
.. | .. |
---|
4076 | 4101 | triangles[0] = 3; |
---|
4077 | 4102 | } |
---|
4078 | 4103 | |
---|
4079 | | - Untrim(); |
---|
4080 | | - MergeNormals(); |
---|
| 4104 | + //Untrim(); |
---|
| 4105 | + if (!trimmed) |
---|
| 4106 | + MergeNormals(); |
---|
4081 | 4107 | } |
---|
4082 | 4108 | |
---|
4083 | 4109 | /* |
---|
.. | .. |
---|
4131 | 4157 | |
---|
4132 | 4158 | void MergeNormals() |
---|
4133 | 4159 | { |
---|
| 4160 | + assert(!trimmed); |
---|
| 4161 | + |
---|
4134 | 4162 | boolean smooth = Grafreed.smoothmode; |
---|
4135 | 4163 | boolean link = Grafreed.linkUV; |
---|
4136 | 4164 | Grafreed.smoothmode = true; |
---|
.. | .. |
---|
4942 | 4970 | v./*pos.*/y = positions[i3 + 1]; |
---|
4943 | 4971 | v./*pos.*/z = positions[i3 + 2]; |
---|
4944 | 4972 | |
---|
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 | + } |
---|
4948 | 4985 | |
---|
4949 | 4986 | v.s = uvmap[i2]; |
---|
4950 | 4987 | v.t = uvmap[i2 + 1]; |
---|