aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitMeshing
diff options
context:
space:
mode:
authorUbitUmarov2012-10-04 04:55:53 +0100
committerUbitUmarov2012-10-04 04:55:53 +0100
commit51e1830f86cd0253879f4f60470a3b5fa2b3db7c (patch)
tree834792c6c8315694219f03590037e9f70dd3e1e4 /OpenSim/Region/Physics/UbitMeshing
parent missing changed file (diff)
downloadopensim-SC_OLD-51e1830f86cd0253879f4f60470a3b5fa2b3db7c.zip
opensim-SC_OLD-51e1830f86cd0253879f4f60470a3b5fa2b3db7c.tar.gz
opensim-SC_OLD-51e1830f86cd0253879f4f60470a3b5fa2b3db7c.tar.bz2
opensim-SC_OLD-51e1830f86cd0253879f4f60470a3b5fa2b3db7c.tar.xz
more changes. Most code not in use
Diffstat (limited to 'OpenSim/Region/Physics/UbitMeshing')
-rw-r--r--OpenSim/Region/Physics/UbitMeshing/Mesh.cs78
1 files changed, 65 insertions, 13 deletions
diff --git a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs
index 98c0f0b..47e0cf4 100644
--- a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs
+++ b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs
@@ -48,8 +48,14 @@ namespace OpenSim.Region.Physics.Meshing
48 int m_indexCount = 0; 48 int m_indexCount = 0;
49 public float[] m_normals; 49 public float[] m_normals;
50 Vector3 m_centroid; 50 Vector3 m_centroid;
51 int m_centroidDiv; 51 float m_obbXmin;
52 float m_obbXmax;
53 float m_obbYmin;
54 float m_obbYmax;
55 float m_obbZmin;
56 float m_obbZmax;
52 57
58 int m_centroidDiv;
53 59
54 private class vertexcomp : IEqualityComparer<Vertex> 60 private class vertexcomp : IEqualityComparer<Vertex>
55 { 61 {
@@ -77,6 +83,14 @@ namespace OpenSim.Region.Physics.Meshing
77 m_triangles = new List<Triangle>(); 83 m_triangles = new List<Triangle>();
78 m_centroid = Vector3.Zero; 84 m_centroid = Vector3.Zero;
79 m_centroidDiv = 0; 85 m_centroidDiv = 0;
86 m_obbXmin = float.MaxValue;
87 m_obbXmax = float.MinValue;
88 m_obbYmin = float.MaxValue;
89 m_obbYmax = float.MinValue;
90 m_obbZmin = float.MaxValue;
91 m_obbZmax = float.MinValue;
92
93
80 } 94 }
81 95
82 public int RefCount { get; set; } 96 public int RefCount { get; set; }
@@ -102,6 +116,35 @@ namespace OpenSim.Region.Physics.Meshing
102 return result; 116 return result;
103 } 117 }
104 118
119 public void addVertexLStats(Vertex v)
120 {
121 float x = v.X;
122 float y = v.Y;
123 float z = v.Z;
124
125 m_centroid.X += x;
126 m_centroid.Y += y;
127 m_centroid.Z += z;
128 m_centroidDiv++;
129
130 if (x > m_obbXmax)
131 m_obbXmax = x;
132 else if (x < m_obbXmin)
133 m_obbXmin = x;
134
135 if (y > m_obbYmax)
136 m_obbYmax = y;
137 else if (y < m_obbYmin)
138 m_obbYmin = y;
139
140 if (z > m_obbZmax)
141 m_obbZmax = z;
142 else if (z < m_obbZmin)
143 m_obbZmin = z;
144
145 }
146
147
105 public void Add(Triangle triangle) 148 public void Add(Triangle triangle)
106 { 149 {
107 if (m_pinnedIndex.IsAllocated || m_pinnedVertexes.IsAllocated || m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero) 150 if (m_pinnedIndex.IsAllocated || m_pinnedVertexes.IsAllocated || m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero)
@@ -127,26 +170,17 @@ namespace OpenSim.Region.Physics.Meshing
127 if (!m_vertices.ContainsKey(triangle.v1)) 170 if (!m_vertices.ContainsKey(triangle.v1))
128 { 171 {
129 m_vertices[triangle.v1] = m_vertices.Count; 172 m_vertices[triangle.v1] = m_vertices.Count;
130 m_centroid.X += triangle.v1.X; 173 addVertexLStats(triangle.v1);
131 m_centroid.Y += triangle.v1.Y;
132 m_centroid.Z += triangle.v1.Z;
133 m_centroidDiv++;
134 } 174 }
135 if (!m_vertices.ContainsKey(triangle.v2)) 175 if (!m_vertices.ContainsKey(triangle.v2))
136 { 176 {
137 m_vertices[triangle.v2] = m_vertices.Count; 177 m_vertices[triangle.v2] = m_vertices.Count;
138 m_centroid.X += triangle.v2.X; 178 addVertexLStats(triangle.v2);
139 m_centroid.Y += triangle.v2.Y;
140 m_centroid.Z += triangle.v2.Z;
141 m_centroidDiv++;
142 } 179 }
143 if (!m_vertices.ContainsKey(triangle.v3)) 180 if (!m_vertices.ContainsKey(triangle.v3))
144 { 181 {
145 m_vertices[triangle.v3] = m_vertices.Count; 182 m_vertices[triangle.v3] = m_vertices.Count;
146 m_centroid.X += triangle.v3.X; 183 addVertexLStats(triangle.v3);
147 m_centroid.Y += triangle.v3.Y;
148 m_centroid.Z += triangle.v3.Z;
149 m_centroidDiv++;
150 } 184 }
151 m_triangles.Add(triangle); 185 m_triangles.Add(triangle);
152 } 186 }
@@ -159,6 +193,24 @@ namespace OpenSim.Region.Physics.Meshing
159 return Vector3.Zero; 193 return Vector3.Zero;
160 } 194 }
161 195
196 public Vector3 GetOBB()
197 {
198 float x, y, z;
199 if (m_centroidDiv > 0)
200 {
201 x = (m_obbXmax - m_obbXmin) * 0.5f;
202 y = (m_obbYmax - m_obbYmin) * 0.5f;
203 z = (m_obbZmax - m_obbZmin) * 0.5f;
204 }
205 else // ??
206 {
207 x = 0.5f;
208 y = 0.5f;
209 z = 0.5f;
210 }
211 return new Vector3(x, y, z);
212 }
213
162 public void CalcNormals() 214 public void CalcNormals()
163 { 215 {
164 int iTriangles = m_triangles.Count; 216 int iTriangles = m_triangles.Count;