diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index fb802e4..093d2a4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -111,8 +111,8 @@ public class BSTerrainManager | |||
111 | BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, TERRAIN_COLLISION_MARGIN), | 111 | BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, TERRAIN_COLLISION_MARGIN), |
112 | ShapeData.PhysicsShapeType.SHAPE_GROUNDPLANE); | 112 | ShapeData.PhysicsShapeType.SHAPE_GROUNDPLANE); |
113 | m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID, | 113 | m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID, |
114 | BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.Ptr, Vector3.Zero, Quaternion.Identity)); | 114 | BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, Vector3.Zero, Quaternion.Identity)); |
115 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.Ptr, m_groundPlane.Ptr); | 115 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr); |
116 | 116 | ||
117 | Vector3 minTerrainCoords = new Vector3(0f, 0f, HEIGHT_INITIALIZATION - HEIGHT_EQUAL_FUDGE); | 117 | Vector3 minTerrainCoords = new Vector3(0f, 0f, HEIGHT_INITIALIZATION - HEIGHT_EQUAL_FUDGE); |
118 | Vector3 maxTerrainCoords = new Vector3(DefaultRegionSize.X, DefaultRegionSize.Y, HEIGHT_INITIALIZATION); | 118 | Vector3 maxTerrainCoords = new Vector3(DefaultRegionSize.X, DefaultRegionSize.Y, HEIGHT_INITIALIZATION); |
@@ -128,13 +128,13 @@ public class BSTerrainManager | |||
128 | // Release all the terrain structures we might have allocated | 128 | // Release all the terrain structures we might have allocated |
129 | public void ReleaseGroundPlaneAndTerrain() | 129 | public void ReleaseGroundPlaneAndTerrain() |
130 | { | 130 | { |
131 | if (m_groundPlane.Ptr != IntPtr.Zero) | 131 | if (m_groundPlane.ptr != IntPtr.Zero) |
132 | { | 132 | { |
133 | if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.Ptr, m_groundPlane.Ptr)) | 133 | if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr)) |
134 | { | 134 | { |
135 | BulletSimAPI.DestroyObject2(PhysicsScene.World.Ptr, m_groundPlane.Ptr); | 135 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_groundPlane.ptr); |
136 | } | 136 | } |
137 | m_groundPlane.Ptr = IntPtr.Zero; | 137 | m_groundPlane.ptr = IntPtr.Zero; |
138 | } | 138 | } |
139 | 139 | ||
140 | ReleaseTerrain(); | 140 | ReleaseTerrain(); |
@@ -145,9 +145,9 @@ public class BSTerrainManager | |||
145 | { | 145 | { |
146 | foreach (KeyValuePair<Vector2, BulletHeightMapInfo> kvp in m_heightMaps) | 146 | foreach (KeyValuePair<Vector2, BulletHeightMapInfo> kvp in m_heightMaps) |
147 | { | 147 | { |
148 | if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.Ptr, kvp.Value.terrainBody.Ptr)) | 148 | if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, kvp.Value.terrainBody.ptr)) |
149 | { | 149 | { |
150 | BulletSimAPI.DestroyObject2(PhysicsScene.World.Ptr, kvp.Value.terrainBody.Ptr); | 150 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, kvp.Value.terrainBody.ptr); |
151 | BulletSimAPI.ReleaseHeightMapInfo2(kvp.Value.Ptr); | 151 | BulletSimAPI.ReleaseHeightMapInfo2(kvp.Value.Ptr); |
152 | } | 152 | } |
153 | } | 153 | } |
@@ -248,17 +248,17 @@ public class BSTerrainManager | |||
248 | return; | 248 | return; |
249 | } | 249 | } |
250 | 250 | ||
251 | if (mapInfo.terrainBody.Ptr != IntPtr.Zero) | 251 | if (mapInfo.terrainBody.ptr != IntPtr.Zero) |
252 | { | 252 | { |
253 | // Updating an existing terrain. | 253 | // Updating an existing terrain. |
254 | DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,taint,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}", | 254 | DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,taint,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}", |
255 | BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY); | 255 | BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY); |
256 | 256 | ||
257 | // Remove from the dynamics world because we're going to mangle this object | 257 | // Remove from the dynamics world because we're going to mangle this object |
258 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.Ptr, mapInfo.terrainBody.Ptr); | 258 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); |
259 | 259 | ||
260 | // Get rid of the old terrain | 260 | // Get rid of the old terrain |
261 | BulletSimAPI.DestroyObject2(PhysicsScene.World.Ptr, mapInfo.terrainBody.Ptr); | 261 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); |
262 | BulletSimAPI.ReleaseHeightMapInfo2(mapInfo.Ptr); | 262 | BulletSimAPI.ReleaseHeightMapInfo2(mapInfo.Ptr); |
263 | mapInfo.Ptr = IntPtr.Zero; | 263 | mapInfo.Ptr = IntPtr.Zero; |
264 | 264 | ||
@@ -289,7 +289,7 @@ public class BSTerrainManager | |||
289 | BSScene.DetailLogZero, mapInfo.minCoords.X, mapInfo.minCoords.Y, minZ, maxZ); | 289 | BSScene.DetailLogZero, mapInfo.minCoords.X, mapInfo.minCoords.Y, minZ, maxZ); |
290 | 290 | ||
291 | mapInfo.ID = id; | 291 | mapInfo.ID = id; |
292 | mapInfo.Ptr = BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.Ptr, mapInfo.ID, | 292 | mapInfo.Ptr = BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, mapInfo.ID, |
293 | mapInfo.minCoords, mapInfo.maxCoords, mapInfo.heightMap, TERRAIN_COLLISION_MARGIN); | 293 | mapInfo.minCoords, mapInfo.maxCoords, mapInfo.heightMap, TERRAIN_COLLISION_MARGIN); |
294 | 294 | ||
295 | // The terrain object initial position is at the center of the object | 295 | // The terrain object initial position is at the center of the object |
@@ -303,7 +303,7 @@ public class BSTerrainManager | |||
303 | ShapeData.PhysicsShapeType.SHAPE_TERRAIN); | 303 | ShapeData.PhysicsShapeType.SHAPE_TERRAIN); |
304 | 304 | ||
305 | mapInfo.terrainBody = new BulletBody(mapInfo.ID, | 305 | mapInfo.terrainBody = new BulletBody(mapInfo.ID, |
306 | BulletSimAPI.CreateBodyWithDefaultMotionState2(mapInfo.terrainShape.Ptr, | 306 | BulletSimAPI.CreateBodyWithDefaultMotionState2(mapInfo.terrainShape.ptr, |
307 | centerPos, Quaternion.Identity)); | 307 | centerPos, Quaternion.Identity)); |
308 | } | 308 | } |
309 | 309 | ||
@@ -311,22 +311,22 @@ public class BSTerrainManager | |||
311 | m_heightMaps[terrainRegionBase] = mapInfo; | 311 | m_heightMaps[terrainRegionBase] = mapInfo; |
312 | 312 | ||
313 | // Set current terrain attributes | 313 | // Set current terrain attributes |
314 | BulletSimAPI.SetFriction2(mapInfo.terrainBody.Ptr, PhysicsScene.Params.terrainFriction); | 314 | BulletSimAPI.SetFriction2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainFriction); |
315 | BulletSimAPI.SetHitFraction2(mapInfo.terrainBody.Ptr, PhysicsScene.Params.terrainHitFraction); | 315 | BulletSimAPI.SetHitFraction2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainHitFraction); |
316 | BulletSimAPI.SetRestitution2(mapInfo.terrainBody.Ptr, PhysicsScene.Params.terrainRestitution); | 316 | BulletSimAPI.SetRestitution2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainRestitution); |
317 | BulletSimAPI.SetCollisionFlags2(mapInfo.terrainBody.Ptr, CollisionFlags.CF_STATIC_OBJECT); | 317 | BulletSimAPI.SetCollisionFlags2(mapInfo.terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); |
318 | 318 | ||
319 | BulletSimAPI.SetMassProps2(mapInfo.terrainBody.Ptr, 0f, Vector3.Zero); | 319 | BulletSimAPI.SetMassProps2(mapInfo.terrainBody.ptr, 0f, Vector3.Zero); |
320 | BulletSimAPI.UpdateInertiaTensor2(mapInfo.terrainBody.Ptr); | 320 | BulletSimAPI.UpdateInertiaTensor2(mapInfo.terrainBody.ptr); |
321 | 321 | ||
322 | // Return the new terrain to the world of physical objects | 322 | // Return the new terrain to the world of physical objects |
323 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.Ptr, mapInfo.terrainBody.Ptr); | 323 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); |
324 | 324 | ||
325 | // redo its bounding box now that it is in the world | 325 | // redo its bounding box now that it is in the world |
326 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.Ptr, mapInfo.terrainBody.Ptr); | 326 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); |
327 | 327 | ||
328 | // Make sure the new shape is processed. | 328 | // Make sure the new shape is processed. |
329 | BulletSimAPI.Activate2(mapInfo.terrainBody.Ptr, true); | 329 | BulletSimAPI.Activate2(mapInfo.terrainBody.ptr, true); |
330 | 330 | ||
331 | m_terrainModified = true; | 331 | m_terrainModified = true; |
332 | }; | 332 | }; |
@@ -361,7 +361,7 @@ public class BSTerrainManager | |||
361 | DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,taint,baseX={1},baseY={2}", BSScene.DetailLogZero, minCoords.X, minCoords.Y); | 361 | DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,taint,baseX={1},baseY={2}", BSScene.DetailLogZero, minCoords.X, minCoords.Y); |
362 | // Create a new mapInfo that will be filled with the new info | 362 | // Create a new mapInfo that will be filled with the new info |
363 | mapInfo = new BulletHeightMapInfo(id, heightMapX, | 363 | mapInfo = new BulletHeightMapInfo(id, heightMapX, |
364 | BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.Ptr, newTerrainID, | 364 | BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, newTerrainID, |
365 | minCoordsX, maxCoordsX, heightMapX, TERRAIN_COLLISION_MARGIN)); | 365 | minCoordsX, maxCoordsX, heightMapX, TERRAIN_COLLISION_MARGIN)); |
366 | // Put the unfilled heightmap info into the collection of same | 366 | // Put the unfilled heightmap info into the collection of same |
367 | m_heightMaps.Add(terrainRegionBase, mapInfo); | 367 | m_heightMaps.Add(terrainRegionBase, mapInfo); |