From aa00308b10228cd2c5a04a41fc5b3da8009cd0fd Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 2 Dec 2012 03:58:40 +0000 Subject: *TEST* reduce all mesh vertices resolution to 1e-5. This reduces number of unique vertices only originated by math errors in PrimMesher --- OpenSim/Region/Physics/UbitMeshing/Mesh.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs index 1e9b8bc..0476b28 100644 --- a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs +++ b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs @@ -205,12 +205,28 @@ namespace OpenSim.Region.Physics.Meshing } + private float fRound(float f) + { + int i = (int)(1e5f * f +0.5f); + return ((float)i * 1e-5f); + } public void Add(Triangle triangle) { if (m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero) throw new NotSupportedException("Attempt to Add to a pinned Mesh"); + // round down + triangle.v1.X = fRound(triangle.v1.X); + triangle.v1.Y = fRound(triangle.v1.Y); + triangle.v1.Z = fRound(triangle.v1.Z); + triangle.v2.X = fRound(triangle.v2.X); + triangle.v2.Y = fRound(triangle.v2.Y); + triangle.v2.Z = fRound(triangle.v2.Z); + triangle.v3.X = fRound(triangle.v3.X); + triangle.v3.Y = fRound(triangle.v3.Y); + triangle.v3.Z = fRound(triangle.v3.Z); + if ((triangle.v1.X == triangle.v2.X && triangle.v1.Y == triangle.v2.Y && triangle.v1.Z == triangle.v2.Z) || (triangle.v1.X == triangle.v3.X && triangle.v1.Y == triangle.v3.Y && triangle.v1.Z == triangle.v3.Z) || (triangle.v2.X == triangle.v3.X && triangle.v2.Y == triangle.v3.Y && triangle.v2.Z == triangle.v3.Z) -- cgit v1.1