diff options
author | UbitUmarov | 2012-08-06 09:06:46 +0100 |
---|---|---|
committer | UbitUmarov | 2012-08-06 09:06:46 +0100 |
commit | 36a1248b317cd80717fef6bc7c8fab318172a075 (patch) | |
tree | c81fc363cfc52d9b3faec5ccb0693f2173650bc0 /OpenSim/Region/Physics/UbitMeshing/Mesh.cs | |
parent | bug fix: keep sculpt bitmaps border pixels during resolution scaling. (diff) | |
download | opensim-SC-36a1248b317cd80717fef6bc7c8fab318172a075.zip opensim-SC-36a1248b317cd80717fef6bc7c8fab318172a075.tar.gz opensim-SC-36a1248b317cd80717fef6bc7c8fab318172a075.tar.bz2 opensim-SC-36a1248b317cd80717fef6bc7c8fab318172a075.tar.xz |
** DANGER someone should stress test more ** release unused physics meshs, including unmanaged memory allocations (allocated by managed code)
Diffstat (limited to 'OpenSim/Region/Physics/UbitMeshing/Mesh.cs')
-rw-r--r-- | OpenSim/Region/Physics/UbitMeshing/Mesh.cs | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs index c715642..0727802 100644 --- a/OpenSim/Region/Physics/UbitMeshing/Mesh.cs +++ b/OpenSim/Region/Physics/UbitMeshing/Mesh.cs | |||
@@ -46,8 +46,8 @@ namespace OpenSim.Region.Physics.Meshing | |||
46 | IntPtr m_indicesPtr = IntPtr.Zero; | 46 | IntPtr m_indicesPtr = IntPtr.Zero; |
47 | int m_indexCount = 0; | 47 | int m_indexCount = 0; |
48 | public float[] m_normals; | 48 | public float[] m_normals; |
49 | Vector3 _centroid; | 49 | Vector3 m_centroid; |
50 | int _centroidDiv; | 50 | int m_centroidDiv; |
51 | 51 | ||
52 | private class vertexcomp : IEqualityComparer<Vertex> | 52 | private class vertexcomp : IEqualityComparer<Vertex> |
53 | { | 53 | { |
@@ -65,7 +65,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
65 | int c = v.Z.GetHashCode(); | 65 | int c = v.Z.GetHashCode(); |
66 | return (a << 16) ^ (b << 8) ^ c; | 66 | return (a << 16) ^ (b << 8) ^ c; |
67 | } | 67 | } |
68 | |||
69 | } | 68 | } |
70 | 69 | ||
71 | public Mesh() | 70 | public Mesh() |
@@ -74,8 +73,18 @@ namespace OpenSim.Region.Physics.Meshing | |||
74 | 73 | ||
75 | m_vertices = new Dictionary<Vertex, int>(vcomp); | 74 | m_vertices = new Dictionary<Vertex, int>(vcomp); |
76 | m_triangles = new List<Triangle>(); | 75 | m_triangles = new List<Triangle>(); |
77 | _centroid = Vector3.Zero; | 76 | m_centroid = Vector3.Zero; |
78 | _centroidDiv = 0; | 77 | m_centroidDiv = 0; |
78 | } | ||
79 | |||
80 | public int RefCount { get; set; } | ||
81 | |||
82 | public ulong Key { get; set; } | ||
83 | |||
84 | public void Scale(Vector3 scale) | ||
85 | { | ||
86 | |||
87 | |||
79 | } | 88 | } |
80 | 89 | ||
81 | public Mesh Clone() | 90 | public Mesh Clone() |
@@ -86,8 +95,8 @@ namespace OpenSim.Region.Physics.Meshing | |||
86 | { | 95 | { |
87 | result.Add(new Triangle(t.v1.Clone(), t.v2.Clone(), t.v3.Clone())); | 96 | result.Add(new Triangle(t.v1.Clone(), t.v2.Clone(), t.v3.Clone())); |
88 | } | 97 | } |
89 | result._centroid = _centroid; | 98 | result.m_centroid = m_centroid; |
90 | result._centroidDiv = _centroidDiv; | 99 | result.m_centroidDiv = m_centroidDiv; |
91 | return result; | 100 | return result; |
92 | } | 101 | } |
93 | 102 | ||
@@ -109,41 +118,41 @@ namespace OpenSim.Region.Physics.Meshing | |||
109 | 118 | ||
110 | if (m_vertices.Count == 0) | 119 | if (m_vertices.Count == 0) |
111 | { | 120 | { |
112 | _centroidDiv = 0; | 121 | m_centroidDiv = 0; |
113 | _centroid = Vector3.Zero; | 122 | m_centroid = Vector3.Zero; |
114 | } | 123 | } |
115 | 124 | ||
116 | if (!m_vertices.ContainsKey(triangle.v1)) | 125 | if (!m_vertices.ContainsKey(triangle.v1)) |
117 | { | 126 | { |
118 | m_vertices[triangle.v1] = m_vertices.Count; | 127 | m_vertices[triangle.v1] = m_vertices.Count; |
119 | _centroid.X += triangle.v1.X; | 128 | m_centroid.X += triangle.v1.X; |
120 | _centroid.Y += triangle.v1.Y; | 129 | m_centroid.Y += triangle.v1.Y; |
121 | _centroid.Z += triangle.v1.Z; | 130 | m_centroid.Z += triangle.v1.Z; |
122 | _centroidDiv++; | 131 | m_centroidDiv++; |
123 | } | 132 | } |
124 | if (!m_vertices.ContainsKey(triangle.v2)) | 133 | if (!m_vertices.ContainsKey(triangle.v2)) |
125 | { | 134 | { |
126 | m_vertices[triangle.v2] = m_vertices.Count; | 135 | m_vertices[triangle.v2] = m_vertices.Count; |
127 | _centroid.X += triangle.v2.X; | 136 | m_centroid.X += triangle.v2.X; |
128 | _centroid.Y += triangle.v2.Y; | 137 | m_centroid.Y += triangle.v2.Y; |
129 | _centroid.Z += triangle.v2.Z; | 138 | m_centroid.Z += triangle.v2.Z; |
130 | _centroidDiv++; | 139 | m_centroidDiv++; |
131 | } | 140 | } |
132 | if (!m_vertices.ContainsKey(triangle.v3)) | 141 | if (!m_vertices.ContainsKey(triangle.v3)) |
133 | { | 142 | { |
134 | m_vertices[triangle.v3] = m_vertices.Count; | 143 | m_vertices[triangle.v3] = m_vertices.Count; |
135 | _centroid.X += triangle.v3.X; | 144 | m_centroid.X += triangle.v3.X; |
136 | _centroid.Y += triangle.v3.Y; | 145 | m_centroid.Y += triangle.v3.Y; |
137 | _centroid.Z += triangle.v3.Z; | 146 | m_centroid.Z += triangle.v3.Z; |
138 | _centroidDiv++; | 147 | m_centroidDiv++; |
139 | } | 148 | } |
140 | m_triangles.Add(triangle); | 149 | m_triangles.Add(triangle); |
141 | } | 150 | } |
142 | 151 | ||
143 | public Vector3 GetCentroid() | 152 | public Vector3 GetCentroid() |
144 | { | 153 | { |
145 | if (_centroidDiv > 0) | 154 | if (m_centroidDiv > 0) |
146 | return new Vector3(_centroid.X / _centroidDiv, _centroid.Y / _centroidDiv, _centroid.Z / _centroidDiv); | 155 | return new Vector3(m_centroid.X / m_centroidDiv, m_centroid.Y / m_centroidDiv, m_centroid.Z / m_centroidDiv); |
147 | else | 156 | else |
148 | return Vector3.Zero; | 157 | return Vector3.Zero; |
149 | } | 158 | } |