diff options
Diffstat (limited to 'OpenSim/Region/Physics/UbitMeshing/Mesh.cs')
-rw-r--r-- | OpenSim/Region/Physics/UbitMeshing/Mesh.cs | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs index fa06926..0418893 100644 --- a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs +++ b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs | |||
@@ -205,34 +205,21 @@ namespace OpenSim.Region.Physics.Meshing | |||
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | private float fRound(float f) | ||
209 | { | ||
210 | int i; | ||
211 | if (f == 0f) | ||
212 | return f; | ||
213 | else if (f > 0f) | ||
214 | i = (int)(1e5f * f + 0.5f); | ||
215 | else | ||
216 | i = (int)(1e5f * f - 0.5f); | ||
217 | |||
218 | return ((float)i * 1e-5f); | ||
219 | } | ||
220 | |||
221 | public void Add(Triangle triangle) | 208 | public void Add(Triangle triangle) |
222 | { | 209 | { |
223 | if (m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero) | 210 | if (m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero) |
224 | throw new NotSupportedException("Attempt to Add to a pinned Mesh"); | 211 | throw new NotSupportedException("Attempt to Add to a pinned Mesh"); |
225 | 212 | ||
226 | // round down | 213 | |
227 | triangle.v1.X = fRound(triangle.v1.X); | 214 | triangle.v1.X = (float)Math.Round(triangle.v1.X, 6); |
228 | triangle.v1.Y = fRound(triangle.v1.Y); | 215 | triangle.v1.Y = (float)Math.Round(triangle.v1.Y, 6); |
229 | triangle.v1.Z = fRound(triangle.v1.Z); | 216 | triangle.v1.Z = (float)Math.Round(triangle.v1.Z, 6); |
230 | triangle.v2.X = fRound(triangle.v2.X); | 217 | triangle.v2.X = (float)Math.Round(triangle.v2.X, 6); |
231 | triangle.v2.Y = fRound(triangle.v2.Y); | 218 | triangle.v2.Y = (float)Math.Round(triangle.v2.Y, 6); |
232 | triangle.v2.Z = fRound(triangle.v2.Z); | 219 | triangle.v2.Z = (float)Math.Round(triangle.v2.Z, 6); |
233 | triangle.v3.X = fRound(triangle.v3.X); | 220 | triangle.v3.X = (float)Math.Round(triangle.v3.X, 6); |
234 | triangle.v3.Y = fRound(triangle.v3.Y); | 221 | triangle.v3.Y = (float)Math.Round(triangle.v3.Y, 6); |
235 | triangle.v3.Z = fRound(triangle.v3.Z); | 222 | triangle.v3.Z = (float)Math.Round(triangle.v3.Z, 6); |
236 | 223 | ||
237 | if ((triangle.v1.X == triangle.v2.X && triangle.v1.Y == triangle.v2.Y && triangle.v1.Z == triangle.v2.Z) | 224 | if ((triangle.v1.X == triangle.v2.X && triangle.v1.Y == triangle.v2.Y && triangle.v1.Z == triangle.v2.Z) |
238 | || (triangle.v1.X == triangle.v3.X && triangle.v1.Y == triangle.v3.Y && triangle.v1.Z == triangle.v3.Z) | 225 | || (triangle.v1.X == triangle.v3.X && triangle.v1.Y == triangle.v3.Y && triangle.v1.Z == triangle.v3.Z) |