diff options
author | UbitUmarov | 2016-09-02 10:37:18 +0100 |
---|---|---|
committer | UbitUmarov | 2016-09-02 10:37:18 +0100 |
commit | ea686058c9e550a1637118535d3491cb5f2022c9 (patch) | |
tree | 9039de2234ae671275f3f0174537fd353fe264d7 /OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet | |
parent | Xengine only do GC.Collect if logins disabled (diff) | |
download | opensim-SC_OLD-ea686058c9e550a1637118535d3491cb5f2022c9.zip opensim-SC_OLD-ea686058c9e550a1637118535d3491cb5f2022c9.tar.gz opensim-SC_OLD-ea686058c9e550a1637118535d3491cb5f2022c9.tar.bz2 opensim-SC_OLD-ea686058c9e550a1637118535d3491cb5f2022c9.tar.xz |
ConvexDecomposition fix some incorrect convexhull mesh generation for ubOde
Diffstat (limited to 'OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet')
-rw-r--r-- | OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs index b0bbfb9..22691e6 100644 --- a/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs +++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs | |||
@@ -1074,14 +1074,27 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet | |||
1074 | public static int maxdirfiltered(List<float3> p, int count, float3 dir, byte[] allow) | 1074 | public static int maxdirfiltered(List<float3> p, int count, float3 dir, byte[] allow) |
1075 | { | 1075 | { |
1076 | //Debug.Assert(count != 0); | 1076 | //Debug.Assert(count != 0); |
1077 | int m = 0; | 1077 | int m = -1; |
1078 | float currDotm = float3.dot(p[0], dir); | 1078 | float currDotm = 0; |
1079 | float currDoti; | 1079 | float currDoti; |
1080 | 1080 | ||
1081 | while (allow[m] == 0) | 1081 | for (int i = 0; i < count; i++) |
1082 | m++; | 1082 | { |
1083 | if (allow[i] != 0) | ||
1084 | { | ||
1085 | currDotm = float3.dot(p[i], dir); | ||
1086 | m = i; | ||
1087 | break; | ||
1088 | } | ||
1089 | } | ||
1090 | |||
1091 | if(m == -1) | ||
1092 | { | ||
1093 | Debug.Assert(false); | ||
1094 | return m; | ||
1095 | } | ||
1083 | 1096 | ||
1084 | for (int i = 1; i < count; i++) | 1097 | for (int i = m; i < count; i++) |
1085 | { | 1098 | { |
1086 | if (allow[i] != 0) | 1099 | if (allow[i] != 0) |
1087 | { | 1100 | { |
@@ -1093,7 +1106,8 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet | |||
1093 | } | 1106 | } |
1094 | } | 1107 | } |
1095 | } | 1108 | } |
1096 | //Debug.Assert(m != -1); | 1109 | |
1110 | // Debug.Assert(m != -1); | ||
1097 | return m; | 1111 | return m; |
1098 | } | 1112 | } |
1099 | 1113 | ||
@@ -1112,8 +1126,8 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet | |||
1112 | { | 1126 | { |
1113 | int mb; | 1127 | int mb; |
1114 | { | 1128 | { |
1115 | float s = (float)Math.Sin((3.14159264f / 180.0f) * (x)); | 1129 | float s = (float)Math.Sin(0.01745329f * x); |
1116 | float c = (float)Math.Cos((3.14159264f / 180.0f) * (x)); | 1130 | float c = (float)Math.Cos(0.01745329f * x); |
1117 | mb = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow); | 1131 | mb = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow); |
1118 | } | 1132 | } |
1119 | if (ma == m && mb == m) | 1133 | if (ma == m && mb == m) |
@@ -1126,8 +1140,8 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet | |||
1126 | int mc = ma; | 1140 | int mc = ma; |
1127 | for (float xx = x - 40.0f; xx <= x; xx += 5.0f) | 1141 | for (float xx = x - 40.0f; xx <= x; xx += 5.0f) |
1128 | { | 1142 | { |
1129 | float s = (float)Math.Sin((3.14159264f / 180.0f) * (xx)); | 1143 | float s = (float)Math.Sin(0.01745329f * xx); |
1130 | float c = (float)Math.Cos((3.14159264f / 180.0f) * (xx)); | 1144 | float c = (float)Math.Cos(0.01745329f * xx); |
1131 | int md = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow); | 1145 | int md = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow); |
1132 | if (mc == m && md == m) | 1146 | if (mc == m && md == m) |
1133 | { | 1147 | { |
@@ -1176,7 +1190,7 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet | |||
1176 | Debug.Assert(!(p0 == p1 || p0 == p2 || p0 == p3 || p1 == p2 || p1 == p3 || p2 == p3)); | 1190 | Debug.Assert(!(p0 == p1 || p0 == p2 || p0 == p3 || p1 == p2 || p1 == p3 || p2 == p3)); |
1177 | if (float3.dot(verts[p3] - verts[p0], float3.cross(verts[p1] - verts[p0], verts[p2] - verts[p0])) < 0) | 1191 | if (float3.dot(verts[p3] - verts[p0], float3.cross(verts[p1] - verts[p0], verts[p2] - verts[p0])) < 0) |
1178 | { | 1192 | { |
1179 | Swap(ref p2, ref p3); | 1193 | return new int4(p0, p1, p3, p2); |
1180 | } | 1194 | } |
1181 | return new int4(p0, p1, p2, p3); | 1195 | return new int4(p0, p1, p2, p3); |
1182 | } | 1196 | } |
@@ -1207,12 +1221,12 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet | |||
1207 | int j; | 1221 | int j; |
1208 | float3 bmin = new float3(verts[0]); | 1222 | float3 bmin = new float3(verts[0]); |
1209 | float3 bmax = new float3(verts[0]); | 1223 | float3 bmax = new float3(verts[0]); |
1210 | List<int> isextreme = new List<int>(verts.Count); | 1224 | byte[] isextreme = new byte[verts.Count]; |
1211 | byte[] allow = new byte[verts.Count]; | 1225 | byte[] allow = new byte[verts.Count]; |
1212 | for (j = 0; j < verts.Count; j++) | 1226 | for (j = 0; j < verts.Count; j++) |
1213 | { | 1227 | { |
1214 | allow[j] = 1; | 1228 | allow[j] = 1; |
1215 | isextreme.Add(0); | 1229 | isextreme[j] = 0; |
1216 | bmin = float3.VectorMin(bmin, verts[j]); | 1230 | bmin = float3.VectorMin(bmin, verts[j]); |
1217 | bmax = float3.VectorMax(bmax, verts[j]); | 1231 | bmax = float3.VectorMax(bmax, verts[j]); |
1218 | } | 1232 | } |