aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitMeshing/Mesh.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitMeshing/Mesh.cs')
-rw-r--r--OpenSim/Region/Physics/UbitMeshing/Mesh.cs57
1 files changed, 34 insertions, 23 deletions
diff --git a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs
index c715642..98c0f0b 100644
--- a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs
+++ b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs
@@ -37,6 +37,7 @@ namespace OpenSim.Region.Physics.Meshing
37{ 37{
38 public class Mesh : IMesh 38 public class Mesh : IMesh
39 { 39 {
40
40 private Dictionary<Vertex, int> m_vertices; 41 private Dictionary<Vertex, int> m_vertices;
41 private List<Triangle> m_triangles; 42 private List<Triangle> m_triangles;
42 GCHandle m_pinnedVertexes; 43 GCHandle m_pinnedVertexes;
@@ -46,8 +47,9 @@ namespace OpenSim.Region.Physics.Meshing
46 IntPtr m_indicesPtr = IntPtr.Zero; 47 IntPtr m_indicesPtr = IntPtr.Zero;
47 int m_indexCount = 0; 48 int m_indexCount = 0;
48 public float[] m_normals; 49 public float[] m_normals;
49 Vector3 _centroid; 50 Vector3 m_centroid;
50 int _centroidDiv; 51 int m_centroidDiv;
52
51 53
52 private class vertexcomp : IEqualityComparer<Vertex> 54 private class vertexcomp : IEqualityComparer<Vertex>
53 { 55 {
@@ -65,7 +67,6 @@ namespace OpenSim.Region.Physics.Meshing
65 int c = v.Z.GetHashCode(); 67 int c = v.Z.GetHashCode();
66 return (a << 16) ^ (b << 8) ^ c; 68 return (a << 16) ^ (b << 8) ^ c;
67 } 69 }
68
69 } 70 }
70 71
71 public Mesh() 72 public Mesh()
@@ -74,8 +75,18 @@ namespace OpenSim.Region.Physics.Meshing
74 75
75 m_vertices = new Dictionary<Vertex, int>(vcomp); 76 m_vertices = new Dictionary<Vertex, int>(vcomp);
76 m_triangles = new List<Triangle>(); 77 m_triangles = new List<Triangle>();
77 _centroid = Vector3.Zero; 78 m_centroid = Vector3.Zero;
78 _centroidDiv = 0; 79 m_centroidDiv = 0;
80 }
81
82 public int RefCount { get; set; }
83
84 public AMeshKey Key { get; set; }
85
86 public void Scale(Vector3 scale)
87 {
88
89
79 } 90 }
80 91
81 public Mesh Clone() 92 public Mesh Clone()
@@ -86,8 +97,8 @@ namespace OpenSim.Region.Physics.Meshing
86 { 97 {
87 result.Add(new Triangle(t.v1.Clone(), t.v2.Clone(), t.v3.Clone())); 98 result.Add(new Triangle(t.v1.Clone(), t.v2.Clone(), t.v3.Clone()));
88 } 99 }
89 result._centroid = _centroid; 100 result.m_centroid = m_centroid;
90 result._centroidDiv = _centroidDiv; 101 result.m_centroidDiv = m_centroidDiv;
91 return result; 102 return result;
92 } 103 }
93 104
@@ -109,41 +120,41 @@ namespace OpenSim.Region.Physics.Meshing
109 120
110 if (m_vertices.Count == 0) 121 if (m_vertices.Count == 0)
111 { 122 {
112 _centroidDiv = 0; 123 m_centroidDiv = 0;
113 _centroid = Vector3.Zero; 124 m_centroid = Vector3.Zero;
114 } 125 }
115 126
116 if (!m_vertices.ContainsKey(triangle.v1)) 127 if (!m_vertices.ContainsKey(triangle.v1))
117 { 128 {
118 m_vertices[triangle.v1] = m_vertices.Count; 129 m_vertices[triangle.v1] = m_vertices.Count;
119 _centroid.X += triangle.v1.X; 130 m_centroid.X += triangle.v1.X;
120 _centroid.Y += triangle.v1.Y; 131 m_centroid.Y += triangle.v1.Y;
121 _centroid.Z += triangle.v1.Z; 132 m_centroid.Z += triangle.v1.Z;
122 _centroidDiv++; 133 m_centroidDiv++;
123 } 134 }
124 if (!m_vertices.ContainsKey(triangle.v2)) 135 if (!m_vertices.ContainsKey(triangle.v2))
125 { 136 {
126 m_vertices[triangle.v2] = m_vertices.Count; 137 m_vertices[triangle.v2] = m_vertices.Count;
127 _centroid.X += triangle.v2.X; 138 m_centroid.X += triangle.v2.X;
128 _centroid.Y += triangle.v2.Y; 139 m_centroid.Y += triangle.v2.Y;
129 _centroid.Z += triangle.v2.Z; 140 m_centroid.Z += triangle.v2.Z;
130 _centroidDiv++; 141 m_centroidDiv++;
131 } 142 }
132 if (!m_vertices.ContainsKey(triangle.v3)) 143 if (!m_vertices.ContainsKey(triangle.v3))
133 { 144 {
134 m_vertices[triangle.v3] = m_vertices.Count; 145 m_vertices[triangle.v3] = m_vertices.Count;
135 _centroid.X += triangle.v3.X; 146 m_centroid.X += triangle.v3.X;
136 _centroid.Y += triangle.v3.Y; 147 m_centroid.Y += triangle.v3.Y;
137 _centroid.Z += triangle.v3.Z; 148 m_centroid.Z += triangle.v3.Z;
138 _centroidDiv++; 149 m_centroidDiv++;
139 } 150 }
140 m_triangles.Add(triangle); 151 m_triangles.Add(triangle);
141 } 152 }
142 153
143 public Vector3 GetCentroid() 154 public Vector3 GetCentroid()
144 { 155 {
145 if (_centroidDiv > 0) 156 if (m_centroidDiv > 0)
146 return new Vector3(_centroid.X / _centroidDiv, _centroid.Y / _centroidDiv, _centroid.Z / _centroidDiv); 157 return new Vector3(m_centroid.X / m_centroidDiv, m_centroid.Y / m_centroidDiv, m_centroid.Z / m_centroidDiv);
147 else 158 else
148 return Vector3.Zero; 159 return Vector3.Zero;
149 } 160 }