diff options
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | 133 |
1 files changed, 73 insertions, 60 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index d48462e..70aa429 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -57,14 +57,14 @@ public class BSTerrainManager | |||
57 | public const float TERRAIN_COLLISION_MARGIN = 0.0f; | 57 | public const float TERRAIN_COLLISION_MARGIN = 0.0f; |
58 | 58 | ||
59 | // Until the whole simulator is changed to pass us the region size, we rely on constants. | 59 | // Until the whole simulator is changed to pass us the region size, we rely on constants. |
60 | public Vector3 DefaultRegionSize = new Vector3(Constants.RegionSize, Constants.RegionSize, 0f); | 60 | public Vector3 DefaultRegionSize = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); |
61 | 61 | ||
62 | // The scene that I am part of | 62 | // The scene that I am part of |
63 | private BSScene m_physicsScene; | 63 | private BSScene PhysicsScene { get; set; } |
64 | 64 | ||
65 | // The ground plane created to keep thing from falling to infinity. | 65 | // The ground plane created to keep thing from falling to infinity. |
66 | private BulletBody m_groundPlane; | 66 | private BulletBody m_groundPlane; |
67 | 67 | ||
68 | // If doing mega-regions, if we're region zero we will be managing multiple | 68 | // If doing mega-regions, if we're region zero we will be managing multiple |
69 | // region terrains since region zero does the physics for the whole mega-region. | 69 | // region terrains since region zero does the physics for the whole mega-region. |
70 | private Dictionary<Vector2, BulletHeightMapInfo> m_heightMaps; | 70 | private Dictionary<Vector2, BulletHeightMapInfo> m_heightMaps; |
@@ -84,18 +84,18 @@ public class BSTerrainManager | |||
84 | // If the parent region (region 0), this is the extent of the combined regions | 84 | // If the parent region (region 0), this is the extent of the combined regions |
85 | // relative to the origin of region zero | 85 | // relative to the origin of region zero |
86 | private Vector3 m_worldMax; | 86 | private Vector3 m_worldMax; |
87 | private PhysicsScene m_parentScene; | 87 | private PhysicsScene MegaRegionParentPhysicsScene { get; set; } |
88 | 88 | ||
89 | public BSTerrainManager(BSScene physicsScene) | 89 | public BSTerrainManager(BSScene physicsScene) |
90 | { | 90 | { |
91 | m_physicsScene = physicsScene; | 91 | PhysicsScene = physicsScene; |
92 | m_heightMaps = new Dictionary<Vector2,BulletHeightMapInfo>(); | 92 | m_heightMaps = new Dictionary<Vector2,BulletHeightMapInfo>(); |
93 | m_terrainModified = false; | 93 | m_terrainModified = false; |
94 | 94 | ||
95 | // Assume one region of default size | 95 | // Assume one region of default size |
96 | m_worldOffset = Vector3.Zero; | 96 | m_worldOffset = Vector3.Zero; |
97 | m_worldMax = new Vector3(DefaultRegionSize.X, DefaultRegionSize.Y, 4096f); | 97 | m_worldMax = new Vector3(DefaultRegionSize); |
98 | m_parentScene = null; | 98 | MegaRegionParentPhysicsScene = null; |
99 | } | 99 | } |
100 | 100 | ||
101 | // Create the initial instance of terrain and the underlying ground plane. | 101 | // Create the initial instance of terrain and the underlying ground plane. |
@@ -107,10 +107,16 @@ public class BSTerrainManager | |||
107 | public void CreateInitialGroundPlaneAndTerrain() | 107 | public void CreateInitialGroundPlaneAndTerrain() |
108 | { | 108 | { |
109 | // The ground plane is here to catch things that are trying to drop to negative infinity | 109 | // The ground plane is here to catch things that are trying to drop to negative infinity |
110 | BulletShape groundPlaneShape = new BulletShape(BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, TERRAIN_COLLISION_MARGIN)); | 110 | BulletShape groundPlaneShape = new BulletShape( |
111 | m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID, | 111 | BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, TERRAIN_COLLISION_MARGIN), |
112 | BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.Ptr, Vector3.Zero, Quaternion.Identity)); | 112 | ShapeData.PhysicsShapeType.SHAPE_GROUNDPLANE); |
113 | BulletSimAPI.AddObjectToWorld2(m_physicsScene.World.Ptr, m_groundPlane.Ptr); | 113 | m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID, |
114 | BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID, | ||
115 | Vector3.Zero, Quaternion.Identity)); | ||
116 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr); | ||
117 | // Everything collides with the ground plane. | ||
118 | BulletSimAPI.SetCollisionFilterMask2(m_groundPlane.ptr, | ||
119 | (uint)CollisionFilterGroups.GroundPlaneFilter, (uint)CollisionFilterGroups.GroundPlaneMask); | ||
114 | 120 | ||
115 | Vector3 minTerrainCoords = new Vector3(0f, 0f, HEIGHT_INITIALIZATION - HEIGHT_EQUAL_FUDGE); | 121 | Vector3 minTerrainCoords = new Vector3(0f, 0f, HEIGHT_INITIALIZATION - HEIGHT_EQUAL_FUDGE); |
116 | Vector3 maxTerrainCoords = new Vector3(DefaultRegionSize.X, DefaultRegionSize.Y, HEIGHT_INITIALIZATION); | 122 | Vector3 maxTerrainCoords = new Vector3(DefaultRegionSize.X, DefaultRegionSize.Y, HEIGHT_INITIALIZATION); |
@@ -126,13 +132,13 @@ public class BSTerrainManager | |||
126 | // Release all the terrain structures we might have allocated | 132 | // Release all the terrain structures we might have allocated |
127 | public void ReleaseGroundPlaneAndTerrain() | 133 | public void ReleaseGroundPlaneAndTerrain() |
128 | { | 134 | { |
129 | if (m_groundPlane.Ptr != IntPtr.Zero) | 135 | if (m_groundPlane.ptr != IntPtr.Zero) |
130 | { | 136 | { |
131 | if (BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, m_groundPlane.Ptr)) | 137 | if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr)) |
132 | { | 138 | { |
133 | BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, m_groundPlane.Ptr); | 139 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_groundPlane.ptr); |
134 | } | 140 | } |
135 | m_groundPlane.Ptr = IntPtr.Zero; | 141 | m_groundPlane.ptr = IntPtr.Zero; |
136 | } | 142 | } |
137 | 143 | ||
138 | ReleaseTerrain(); | 144 | ReleaseTerrain(); |
@@ -143,9 +149,9 @@ public class BSTerrainManager | |||
143 | { | 149 | { |
144 | foreach (KeyValuePair<Vector2, BulletHeightMapInfo> kvp in m_heightMaps) | 150 | foreach (KeyValuePair<Vector2, BulletHeightMapInfo> kvp in m_heightMaps) |
145 | { | 151 | { |
146 | if (BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, kvp.Value.terrainBody.Ptr)) | 152 | if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, kvp.Value.terrainBody.ptr)) |
147 | { | 153 | { |
148 | BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, kvp.Value.terrainBody.Ptr); | 154 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, kvp.Value.terrainBody.ptr); |
149 | BulletSimAPI.ReleaseHeightMapInfo2(kvp.Value.Ptr); | 155 | BulletSimAPI.ReleaseHeightMapInfo2(kvp.Value.Ptr); |
150 | } | 156 | } |
151 | } | 157 | } |
@@ -155,19 +161,19 @@ public class BSTerrainManager | |||
155 | // The simulator wants to set a new heightmap for the terrain. | 161 | // The simulator wants to set a new heightmap for the terrain. |
156 | public void SetTerrain(float[] heightMap) { | 162 | public void SetTerrain(float[] heightMap) { |
157 | float[] localHeightMap = heightMap; | 163 | float[] localHeightMap = heightMap; |
158 | m_physicsScene.TaintedObject("TerrainManager.SetTerrain", delegate() | 164 | PhysicsScene.TaintedObject("TerrainManager.SetTerrain", delegate() |
159 | { | 165 | { |
160 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) | 166 | if (m_worldOffset != Vector3.Zero && MegaRegionParentPhysicsScene != null) |
161 | { | 167 | { |
162 | // If a child of a mega-region, we shouldn't have any terrain allocated for us | 168 | // If a child of a mega-region, we shouldn't have any terrain allocated for us |
163 | ReleaseGroundPlaneAndTerrain(); | 169 | ReleaseGroundPlaneAndTerrain(); |
164 | // If doing the mega-prim stuff and we are the child of the zero region, | 170 | // If doing the mega-prim stuff and we are the child of the zero region, |
165 | // the terrain is added to our parent | 171 | // the terrain is added to our parent |
166 | if (m_parentScene is BSScene) | 172 | if (MegaRegionParentPhysicsScene is BSScene) |
167 | { | 173 | { |
168 | DetailLog("{0},SetTerrain.ToParent,offset={1},worldMax={2}", | 174 | DetailLog("{0},SetTerrain.ToParent,offset={1},worldMax={2}", |
169 | BSScene.DetailLogZero, m_worldOffset, m_worldMax); | 175 | BSScene.DetailLogZero, m_worldOffset, m_worldMax); |
170 | ((BSScene)m_parentScene).TerrainManager.UpdateOrCreateTerrain(BSScene.CHILDTERRAIN_ID, | 176 | ((BSScene)MegaRegionParentPhysicsScene).TerrainManager.UpdateOrCreateTerrain(BSScene.CHILDTERRAIN_ID, |
171 | localHeightMap, m_worldOffset, m_worldOffset + DefaultRegionSize, true); | 177 | localHeightMap, m_worldOffset, m_worldOffset + DefaultRegionSize, true); |
172 | } | 178 | } |
173 | } | 179 | } |
@@ -176,7 +182,8 @@ public class BSTerrainManager | |||
176 | // If not doing the mega-prim thing, just change the terrain | 182 | // If not doing the mega-prim thing, just change the terrain |
177 | DetailLog("{0},SetTerrain.Existing", BSScene.DetailLogZero); | 183 | DetailLog("{0},SetTerrain.Existing", BSScene.DetailLogZero); |
178 | 184 | ||
179 | UpdateOrCreateTerrain(BSScene.TERRAIN_ID, localHeightMap, m_worldOffset, m_worldOffset + DefaultRegionSize, true); | 185 | UpdateOrCreateTerrain(BSScene.TERRAIN_ID, localHeightMap, |
186 | m_worldOffset, m_worldOffset + DefaultRegionSize, true); | ||
180 | } | 187 | } |
181 | }); | 188 | }); |
182 | } | 189 | } |
@@ -194,10 +201,10 @@ public class BSTerrainManager | |||
194 | // The 'doNow' boolean says whether to do all the unmanaged activities right now (like when | 201 | // The 'doNow' boolean says whether to do all the unmanaged activities right now (like when |
195 | // calling this routine from initialization or taint-time routines) or whether to delay | 202 | // calling this routine from initialization or taint-time routines) or whether to delay |
196 | // all the unmanaged activities to taint-time. | 203 | // all the unmanaged activities to taint-time. |
197 | private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool doNow) | 204 | private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool atTaintTime) |
198 | { | 205 | { |
199 | DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},doNow={3}", | 206 | DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},atTaintTime={3}", |
200 | BSScene.DetailLogZero, minCoords, maxCoords, doNow); | 207 | BSScene.DetailLogZero, minCoords, maxCoords, atTaintTime); |
201 | 208 | ||
202 | float minZ = float.MaxValue; | 209 | float minZ = float.MaxValue; |
203 | float maxZ = float.MinValue; | 210 | float maxZ = float.MinValue; |
@@ -227,12 +234,12 @@ public class BSTerrainManager | |||
227 | mapInfo.maxZ = maxZ; | 234 | mapInfo.maxZ = maxZ; |
228 | mapInfo.sizeX = maxCoords.X - minCoords.X; | 235 | mapInfo.sizeX = maxCoords.X - minCoords.X; |
229 | mapInfo.sizeY = maxCoords.Y - minCoords.Y; | 236 | mapInfo.sizeY = maxCoords.Y - minCoords.Y; |
230 | DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,call,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}", | 237 | DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,call,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}", |
231 | BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY); | 238 | BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY); |
232 | 239 | ||
233 | BSScene.TaintCallback rebuildOperation = delegate() | 240 | BSScene.TaintCallback rebuildOperation = delegate() |
234 | { | 241 | { |
235 | if (m_parentScene != null) | 242 | if (MegaRegionParentPhysicsScene != null) |
236 | { | 243 | { |
237 | // It's possible that Combine() was called after this code was queued. | 244 | // It's possible that Combine() was called after this code was queued. |
238 | // If we are a child of combined regions, we don't create any terrain for us. | 245 | // If we are a child of combined regions, we don't create any terrain for us. |
@@ -245,17 +252,17 @@ public class BSTerrainManager | |||
245 | return; | 252 | return; |
246 | } | 253 | } |
247 | 254 | ||
248 | if (mapInfo.terrainBody.Ptr != IntPtr.Zero) | 255 | if (mapInfo.terrainBody.ptr != IntPtr.Zero) |
249 | { | 256 | { |
250 | // Updating an existing terrain. | 257 | // Updating an existing terrain. |
251 | DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,taint,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}", | 258 | DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,taint,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}", |
252 | BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY); | 259 | BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY); |
253 | 260 | ||
254 | // Remove from the dynamics world because we're going to mangle this object | 261 | // Remove from the dynamics world because we're going to mangle this object |
255 | BulletSimAPI.RemoveObjectFromWorld2(m_physicsScene.World.Ptr, mapInfo.terrainBody.Ptr); | 262 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); |
256 | 263 | ||
257 | // Get rid of the old terrain | 264 | // Get rid of the old terrain |
258 | BulletSimAPI.DestroyObject2(m_physicsScene.World.Ptr, mapInfo.terrainBody.Ptr); | 265 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); |
259 | BulletSimAPI.ReleaseHeightMapInfo2(mapInfo.Ptr); | 266 | BulletSimAPI.ReleaseHeightMapInfo2(mapInfo.Ptr); |
260 | mapInfo.Ptr = IntPtr.Zero; | 267 | mapInfo.Ptr = IntPtr.Zero; |
261 | 268 | ||
@@ -282,11 +289,11 @@ public class BSTerrainManager | |||
282 | // else | 289 | // else |
283 | { | 290 | { |
284 | // Creating a new terrain. | 291 | // Creating a new terrain. |
285 | DetailLog("{0},UpdateOrCreateTerrain:CreateNewTerrain,taint,baseX={1},baseY={2},minZ={3},maxZ={4}", | 292 | DetailLog("{0},UpdateOrCreateTerrain:CreateNewTerrain,taint,baseX={1},baseY={2},minZ={3},maxZ={4}", |
286 | BSScene.DetailLogZero, mapInfo.minCoords.X, mapInfo.minCoords.Y, minZ, maxZ); | 293 | BSScene.DetailLogZero, mapInfo.minCoords.X, mapInfo.minCoords.Y, minZ, maxZ); |
287 | 294 | ||
288 | mapInfo.ID = id; | 295 | mapInfo.ID = id; |
289 | mapInfo.Ptr = BulletSimAPI.CreateHeightMapInfo2(m_physicsScene.World.Ptr, mapInfo.ID, | 296 | mapInfo.Ptr = BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, mapInfo.ID, |
290 | mapInfo.minCoords, mapInfo.maxCoords, mapInfo.heightMap, TERRAIN_COLLISION_MARGIN); | 297 | mapInfo.minCoords, mapInfo.maxCoords, mapInfo.heightMap, TERRAIN_COLLISION_MARGIN); |
291 | 298 | ||
292 | // The terrain object initial position is at the center of the object | 299 | // The terrain object initial position is at the center of the object |
@@ -296,43 +303,49 @@ public class BSTerrainManager | |||
296 | centerPos.Z = minZ + ((maxZ - minZ) / 2f); | 303 | centerPos.Z = minZ + ((maxZ - minZ) / 2f); |
297 | 304 | ||
298 | // Create the terrain shape from the mapInfo | 305 | // Create the terrain shape from the mapInfo |
299 | mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr)); | 306 | mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr), |
307 | ShapeData.PhysicsShapeType.SHAPE_TERRAIN); | ||
300 | 308 | ||
301 | mapInfo.terrainBody = new BulletBody(mapInfo.ID, | 309 | mapInfo.terrainBody = new BulletBody(mapInfo.ID, |
302 | BulletSimAPI.CreateBodyWithDefaultMotionState2(mapInfo.terrainShape.Ptr, | 310 | BulletSimAPI.CreateBodyWithDefaultMotionState2(mapInfo.terrainShape.ptr, |
303 | centerPos, Quaternion.Identity)); | 311 | id, centerPos, Quaternion.Identity)); |
304 | } | 312 | } |
305 | 313 | ||
306 | // Make sure the entry is in the heightmap table | 314 | // Make sure the entry is in the heightmap table |
307 | m_heightMaps[terrainRegionBase] = mapInfo; | 315 | m_heightMaps[terrainRegionBase] = mapInfo; |
308 | 316 | ||
309 | // Set current terrain attributes | 317 | // Set current terrain attributes |
310 | BulletSimAPI.SetFriction2(mapInfo.terrainBody.Ptr, m_physicsScene.Params.terrainFriction); | 318 | BulletSimAPI.SetFriction2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainFriction); |
311 | BulletSimAPI.SetHitFraction2(mapInfo.terrainBody.Ptr, m_physicsScene.Params.terrainHitFraction); | 319 | BulletSimAPI.SetHitFraction2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainHitFraction); |
312 | BulletSimAPI.SetRestitution2(mapInfo.terrainBody.Ptr, m_physicsScene.Params.terrainRestitution); | 320 | BulletSimAPI.SetRestitution2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainRestitution); |
313 | BulletSimAPI.SetCollisionFlags2(mapInfo.terrainBody.Ptr, CollisionFlags.CF_STATIC_OBJECT); | 321 | BulletSimAPI.SetCollisionFlags2(mapInfo.terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); |
314 | 322 | ||
315 | BulletSimAPI.SetMassProps2(mapInfo.terrainBody.Ptr, 0f, Vector3.Zero); | 323 | BulletSimAPI.SetMassProps2(mapInfo.terrainBody.ptr, 0f, Vector3.Zero); |
316 | BulletSimAPI.UpdateInertiaTensor2(mapInfo.terrainBody.Ptr); | 324 | BulletSimAPI.UpdateInertiaTensor2(mapInfo.terrainBody.ptr); |
317 | 325 | ||
318 | // Return the new terrain to the world of physical objects | 326 | // Return the new terrain to the world of physical objects |
319 | BulletSimAPI.AddObjectToWorld2(m_physicsScene.World.Ptr, mapInfo.terrainBody.Ptr); | 327 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); |
320 | 328 | ||
321 | // redo its bounding box now that it is in the world | 329 | // redo its bounding box now that it is in the world |
322 | BulletSimAPI.UpdateSingleAabb2(m_physicsScene.World.Ptr, mapInfo.terrainBody.Ptr); | 330 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); |
331 | |||
332 | BulletSimAPI.SetCollisionFilterMask2(mapInfo.terrainBody.ptr, | ||
333 | (uint)CollisionFilterGroups.TerrainFilter, | ||
334 | (uint)CollisionFilterGroups.TerrainMask); | ||
323 | 335 | ||
324 | // Make sure the new shape is processed. | 336 | // Make sure the new shape is processed. |
325 | BulletSimAPI.Activate2(mapInfo.terrainBody.Ptr, true); | 337 | // BulletSimAPI.Activate2(mapInfo.terrainBody.ptr, true); |
338 | BulletSimAPI.ForceActivationState2(mapInfo.terrainBody.ptr, ActivationState.DISABLE_SIMULATION); | ||
326 | 339 | ||
327 | m_terrainModified = true; | 340 | m_terrainModified = true; |
328 | }; | 341 | }; |
329 | 342 | ||
330 | // There is the option to do the changes now (we're already in 'taint time'), or | 343 | // There is the option to do the changes now (we're already in 'taint time'), or |
331 | // to do the Bullet operations later. | 344 | // to do the Bullet operations later. |
332 | if (doNow) | 345 | if (atTaintTime) |
333 | rebuildOperation(); | 346 | rebuildOperation(); |
334 | else | 347 | else |
335 | m_physicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:UpdateExisting", rebuildOperation); | 348 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:UpdateExisting", rebuildOperation); |
336 | } | 349 | } |
337 | else | 350 | else |
338 | { | 351 | { |
@@ -348,7 +361,7 @@ public class BSTerrainManager | |||
348 | Vector3 minCoordsX = minCoords; | 361 | Vector3 minCoordsX = minCoords; |
349 | Vector3 maxCoordsX = maxCoords; | 362 | Vector3 maxCoordsX = maxCoords; |
350 | 363 | ||
351 | DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,call,id={1}, minC={2}, maxC={3}", | 364 | DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,call,id={1}, minC={2}, maxC={3}", |
352 | BSScene.DetailLogZero, newTerrainID, minCoords, minCoords); | 365 | BSScene.DetailLogZero, newTerrainID, minCoords, minCoords); |
353 | 366 | ||
354 | // Code that must happen at taint-time | 367 | // Code that must happen at taint-time |
@@ -357,7 +370,7 @@ public class BSTerrainManager | |||
357 | DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,taint,baseX={1},baseY={2}", BSScene.DetailLogZero, minCoords.X, minCoords.Y); | 370 | DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,taint,baseX={1},baseY={2}", BSScene.DetailLogZero, minCoords.X, minCoords.Y); |
358 | // Create a new mapInfo that will be filled with the new info | 371 | // Create a new mapInfo that will be filled with the new info |
359 | mapInfo = new BulletHeightMapInfo(id, heightMapX, | 372 | mapInfo = new BulletHeightMapInfo(id, heightMapX, |
360 | BulletSimAPI.CreateHeightMapInfo2(m_physicsScene.World.Ptr, newTerrainID, | 373 | BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, newTerrainID, |
361 | minCoordsX, maxCoordsX, heightMapX, TERRAIN_COLLISION_MARGIN)); | 374 | minCoordsX, maxCoordsX, heightMapX, TERRAIN_COLLISION_MARGIN)); |
362 | // Put the unfilled heightmap info into the collection of same | 375 | // Put the unfilled heightmap info into the collection of same |
363 | m_heightMaps.Add(terrainRegionBase, mapInfo); | 376 | m_heightMaps.Add(terrainRegionBase, mapInfo); |
@@ -368,10 +381,10 @@ public class BSTerrainManager | |||
368 | }; | 381 | }; |
369 | 382 | ||
370 | // If already in taint-time, just call Bullet. Otherwise queue the operations for the safe time. | 383 | // If already in taint-time, just call Bullet. Otherwise queue the operations for the safe time. |
371 | if (doNow) | 384 | if (atTaintTime) |
372 | createOperation(); | 385 | createOperation(); |
373 | else | 386 | else |
374 | m_physicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:NewTerrain", createOperation); | 387 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:NewTerrain", createOperation); |
375 | } | 388 | } |
376 | } | 389 | } |
377 | 390 | ||
@@ -419,7 +432,7 @@ public class BSTerrainManager | |||
419 | catch | 432 | catch |
420 | { | 433 | { |
421 | // Sometimes they give us wonky values of X and Y. Give a warning and return something. | 434 | // Sometimes they give us wonky values of X and Y. Give a warning and return something. |
422 | m_physicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, x={2}, y={3}", | 435 | PhysicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, x={2}, y={3}", |
423 | LogHeader, terrainBaseXY, regionX, regionY); | 436 | LogHeader, terrainBaseXY, regionX, regionY); |
424 | ret = HEIGHT_GETHEIGHT_RET; | 437 | ret = HEIGHT_GETHEIGHT_RET; |
425 | } | 438 | } |
@@ -428,8 +441,8 @@ public class BSTerrainManager | |||
428 | } | 441 | } |
429 | else | 442 | else |
430 | { | 443 | { |
431 | m_physicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: region={1}, x={2}, y={3}", | 444 | PhysicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: region={1}, x={2}, y={3}", |
432 | LogHeader, m_physicsScene.RegionName, tX, tY); | 445 | LogHeader, PhysicsScene.RegionName, tX, tY); |
433 | } | 446 | } |
434 | m_terrainModified = false; | 447 | m_terrainModified = false; |
435 | lastHeight = ret; | 448 | lastHeight = ret; |
@@ -441,7 +454,7 @@ public class BSTerrainManager | |||
441 | { | 454 | { |
442 | return true; | 455 | return true; |
443 | } | 456 | } |
444 | 457 | ||
445 | // This routine is called two ways: | 458 | // This routine is called two ways: |
446 | // One with 'offset' and 'pScene' zero and null but 'extents' giving the maximum | 459 | // One with 'offset' and 'pScene' zero and null but 'extents' giving the maximum |
447 | // extent of the combined regions. This is to inform the parent of the size | 460 | // extent of the combined regions. This is to inform the parent of the size |
@@ -453,14 +466,14 @@ public class BSTerrainManager | |||
453 | { | 466 | { |
454 | m_worldOffset = offset; | 467 | m_worldOffset = offset; |
455 | m_worldMax = extents; | 468 | m_worldMax = extents; |
456 | m_parentScene = pScene; | 469 | MegaRegionParentPhysicsScene = pScene; |
457 | if (pScene != null) | 470 | if (pScene != null) |
458 | { | 471 | { |
459 | // We are a child. | 472 | // We are a child. |
460 | // We want m_worldMax to be the highest coordinate of our piece of terrain. | 473 | // We want m_worldMax to be the highest coordinate of our piece of terrain. |
461 | m_worldMax = offset + DefaultRegionSize; | 474 | m_worldMax = offset + DefaultRegionSize; |
462 | } | 475 | } |
463 | DetailLog("{0},BSTerrainManager.Combine,offset={1},extents={2},wOffset={3},wMax={4}", | 476 | DetailLog("{0},BSTerrainManager.Combine,offset={1},extents={2},wOffset={3},wMax={4}", |
464 | BSScene.DetailLogZero, offset, extents, m_worldOffset, m_worldMax); | 477 | BSScene.DetailLogZero, offset, extents, m_worldOffset, m_worldMax); |
465 | } | 478 | } |
466 | 479 | ||
@@ -474,7 +487,7 @@ public class BSTerrainManager | |||
474 | 487 | ||
475 | private void DetailLog(string msg, params Object[] args) | 488 | private void DetailLog(string msg, params Object[] args) |
476 | { | 489 | { |
477 | m_physicsScene.PhysicsLogging.Write(msg, args); | 490 | PhysicsScene.PhysicsLogging.Write(msg, args); |
478 | } | 491 | } |
479 | } | 492 | } |
480 | } | 493 | } |