aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRobert Adams2013-04-28 21:50:47 -0700
committerRobert Adams2013-04-29 07:38:55 -0700
commitad1787770ed02f71feaa002ab689467e187803bb (patch)
tree08026c7b0b160ae9b16c2876894852f8a729bbb4
parentBulletSim: first cut at new linksetCompound shape building. (diff)
downloadopensim-SC_OLD-ad1787770ed02f71feaa002ab689467e187803bb.zip
opensim-SC_OLD-ad1787770ed02f71feaa002ab689467e187803bb.tar.gz
opensim-SC_OLD-ad1787770ed02f71feaa002ab689467e187803bb.tar.bz2
opensim-SC_OLD-ad1787770ed02f71feaa002ab689467e187803bb.tar.xz
BulletSim: rename variable 'PhysicsScene' to be either 'PhysScene' or 'm_physicsScene' to match coding conventions and reduce confusion.
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs112
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs8
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs10
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs34
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs16
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs52
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs188
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs8
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs28
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs56
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs52
11 files changed, 282 insertions, 282 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index da23a262..e12fc8e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -95,18 +95,18 @@ public sealed class BSCharacter : BSPhysObject
95 // the avatar seeking to reach the motor's target speed. 95 // the avatar seeking to reach the motor's target speed.
96 // This motor runs as a prestep action for the avatar so it will keep the avatar 96 // This motor runs as a prestep action for the avatar so it will keep the avatar
97 // standing as well as moving. Destruction of the avatar will destroy the pre-step action. 97 // standing as well as moving. Destruction of the avatar will destroy the pre-step action.
98 m_moveActor = new BSActorAvatarMove(PhysicsScene, this, AvatarMoveActorName); 98 m_moveActor = new BSActorAvatarMove(PhysScene, this, AvatarMoveActorName);
99 PhysicalActors.Add(AvatarMoveActorName, m_moveActor); 99 PhysicalActors.Add(AvatarMoveActorName, m_moveActor);
100 100
101 DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}", 101 DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}",
102 LocalID, _size, Scale, Density, _avatarVolume, RawMass); 102 LocalID, _size, Scale, Density, _avatarVolume, RawMass);
103 103
104 // do actual creation in taint time 104 // do actual creation in taint time
105 PhysicsScene.TaintedObject("BSCharacter.create", delegate() 105 PhysScene.TaintedObject("BSCharacter.create", delegate()
106 { 106 {
107 DetailLog("{0},BSCharacter.create,taint", LocalID); 107 DetailLog("{0},BSCharacter.create,taint", LocalID);
108 // New body and shape into PhysBody and PhysShape 108 // New body and shape into PhysBody and PhysShape
109 PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this); 109 PhysScene.Shapes.GetBodyAndShape(true, PhysScene.World, this);
110 110
111 SetPhysicalProperties(); 111 SetPhysicalProperties();
112 }); 112 });
@@ -119,18 +119,18 @@ public sealed class BSCharacter : BSPhysObject
119 base.Destroy(); 119 base.Destroy();
120 120
121 DetailLog("{0},BSCharacter.Destroy", LocalID); 121 DetailLog("{0},BSCharacter.Destroy", LocalID);
122 PhysicsScene.TaintedObject("BSCharacter.destroy", delegate() 122 PhysScene.TaintedObject("BSCharacter.destroy", delegate()
123 { 123 {
124 PhysicsScene.Shapes.DereferenceBody(PhysBody, null /* bodyCallback */); 124 PhysScene.Shapes.DereferenceBody(PhysBody, null /* bodyCallback */);
125 PhysBody.Clear(); 125 PhysBody.Clear();
126 PhysShape.Dereference(PhysicsScene); 126 PhysShape.Dereference(PhysScene);
127 PhysShape = new BSShapeNull(); 127 PhysShape = new BSShapeNull();
128 }); 128 });
129 } 129 }
130 130
131 private void SetPhysicalProperties() 131 private void SetPhysicalProperties()
132 { 132 {
133 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); 133 PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody);
134 134
135 ZeroMotion(true); 135 ZeroMotion(true);
136 ForcePosition = _position; 136 ForcePosition = _position;
@@ -145,35 +145,35 @@ public sealed class BSCharacter : BSPhysObject
145 // Needs to be reset especially when an avatar is recreated after crossing a region boundry. 145 // Needs to be reset especially when an avatar is recreated after crossing a region boundry.
146 Flying = _flying; 146 Flying = _flying;
147 147
148 PhysicsScene.PE.SetRestitution(PhysBody, BSParam.AvatarRestitution); 148 PhysScene.PE.SetRestitution(PhysBody, BSParam.AvatarRestitution);
149 PhysicsScene.PE.SetMargin(PhysShape.physShapeInfo, PhysicsScene.Params.collisionMargin); 149 PhysScene.PE.SetMargin(PhysShape.physShapeInfo, PhysScene.Params.collisionMargin);
150 PhysicsScene.PE.SetLocalScaling(PhysShape.physShapeInfo, Scale); 150 PhysScene.PE.SetLocalScaling(PhysShape.physShapeInfo, Scale);
151 PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); 151 PhysScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
152 if (BSParam.CcdMotionThreshold > 0f) 152 if (BSParam.CcdMotionThreshold > 0f)
153 { 153 {
154 PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); 154 PhysScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
155 PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); 155 PhysScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
156 } 156 }
157 157
158 UpdatePhysicalMassProperties(RawMass, false); 158 UpdatePhysicalMassProperties(RawMass, false);
159 159
160 // Make so capsule does not fall over 160 // Make so capsule does not fall over
161 PhysicsScene.PE.SetAngularFactorV(PhysBody, OMV.Vector3.Zero); 161 PhysScene.PE.SetAngularFactorV(PhysBody, OMV.Vector3.Zero);
162 162
163 // The avatar mover sets some parameters. 163 // The avatar mover sets some parameters.
164 PhysicalActors.Refresh(); 164 PhysicalActors.Refresh();
165 165
166 PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_CHARACTER_OBJECT); 166 PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_CHARACTER_OBJECT);
167 167
168 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody); 168 PhysScene.PE.AddObjectToWorld(PhysScene.World, PhysBody);
169 169
170 // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG); 170 // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG);
171 PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_DEACTIVATION); 171 PhysScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_DEACTIVATION);
172 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody); 172 PhysScene.PE.UpdateSingleAabb(PhysScene.World, PhysBody);
173 173
174 // Do this after the object has been added to the world 174 // Do this after the object has been added to the world
175 PhysBody.collisionType = CollisionType.Avatar; 175 PhysBody.collisionType = CollisionType.Avatar;
176 PhysBody.ApplyCollisionMask(PhysicsScene); 176 PhysBody.ApplyCollisionMask(PhysScene);
177 } 177 }
178 178
179 179
@@ -203,14 +203,14 @@ public sealed class BSCharacter : BSPhysObject
203 DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}", 203 DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}",
204 LocalID, _size, Scale, Density, _avatarVolume, RawMass); 204 LocalID, _size, Scale, Density, _avatarVolume, RawMass);
205 205
206 PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() 206 PhysScene.TaintedObject("BSCharacter.setSize", delegate()
207 { 207 {
208 if (PhysBody.HasPhysicalBody && PhysShape.physShapeInfo.HasPhysicalShape) 208 if (PhysBody.HasPhysicalBody && PhysShape.physShapeInfo.HasPhysicalShape)
209 { 209 {
210 PhysicsScene.PE.SetLocalScaling(PhysShape.physShapeInfo, Scale); 210 PhysScene.PE.SetLocalScaling(PhysShape.physShapeInfo, Scale);
211 UpdatePhysicalMassProperties(RawMass, true); 211 UpdatePhysicalMassProperties(RawMass, true);
212 // Make sure this change appears as a property update event 212 // Make sure this change appears as a property update event
213 PhysicsScene.PE.PushUpdate(PhysBody); 213 PhysScene.PE.PushUpdate(PhysBody);
214 } 214 }
215 }); 215 });
216 216
@@ -247,24 +247,24 @@ public sealed class BSCharacter : BSPhysObject
247 _rotationalVelocity = OMV.Vector3.Zero; 247 _rotationalVelocity = OMV.Vector3.Zero;
248 248
249 // Zero some other properties directly into the physics engine 249 // Zero some other properties directly into the physics engine
250 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() 250 PhysScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
251 { 251 {
252 if (PhysBody.HasPhysicalBody) 252 if (PhysBody.HasPhysicalBody)
253 PhysicsScene.PE.ClearAllForces(PhysBody); 253 PhysScene.PE.ClearAllForces(PhysBody);
254 }); 254 });
255 } 255 }
256 public override void ZeroAngularMotion(bool inTaintTime) 256 public override void ZeroAngularMotion(bool inTaintTime)
257 { 257 {
258 _rotationalVelocity = OMV.Vector3.Zero; 258 _rotationalVelocity = OMV.Vector3.Zero;
259 259
260 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() 260 PhysScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
261 { 261 {
262 if (PhysBody.HasPhysicalBody) 262 if (PhysBody.HasPhysicalBody)
263 { 263 {
264 PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, OMV.Vector3.Zero); 264 PhysScene.PE.SetInterpolationAngularVelocity(PhysBody, OMV.Vector3.Zero);
265 PhysicsScene.PE.SetAngularVelocity(PhysBody, OMV.Vector3.Zero); 265 PhysScene.PE.SetAngularVelocity(PhysBody, OMV.Vector3.Zero);
266 // The next also get rid of applied linear force but the linear velocity is untouched. 266 // The next also get rid of applied linear force but the linear velocity is untouched.
267 PhysicsScene.PE.ClearForces(PhysBody); 267 PhysScene.PE.ClearForces(PhysBody);
268 } 268 }
269 }); 269 });
270 } 270 }
@@ -286,7 +286,7 @@ public sealed class BSCharacter : BSPhysObject
286 set { 286 set {
287 _position = value; 287 _position = value;
288 288
289 PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate() 289 PhysScene.TaintedObject("BSCharacter.setPosition", delegate()
290 { 290 {
291 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 291 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
292 PositionSanityCheck(); 292 PositionSanityCheck();
@@ -296,14 +296,14 @@ public sealed class BSCharacter : BSPhysObject
296 } 296 }
297 public override OMV.Vector3 ForcePosition { 297 public override OMV.Vector3 ForcePosition {
298 get { 298 get {
299 _position = PhysicsScene.PE.GetPosition(PhysBody); 299 _position = PhysScene.PE.GetPosition(PhysBody);
300 return _position; 300 return _position;
301 } 301 }
302 set { 302 set {
303 _position = value; 303 _position = value;
304 if (PhysBody.HasPhysicalBody) 304 if (PhysBody.HasPhysicalBody)
305 { 305 {
306 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); 306 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation);
307 } 307 }
308 } 308 }
309 } 309 }
@@ -317,18 +317,18 @@ public sealed class BSCharacter : BSPhysObject
317 bool ret = false; 317 bool ret = false;
318 318
319 // TODO: check for out of bounds 319 // TODO: check for out of bounds
320 if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition)) 320 if (!PhysScene.TerrainManager.IsWithinKnownTerrain(RawPosition))
321 { 321 {
322 // The character is out of the known/simulated area. 322 // The character is out of the known/simulated area.
323 // Force the avatar position to be within known. ScenePresence will use the position 323 // Force the avatar position to be within known. ScenePresence will use the position
324 // plus the velocity to decide if the avatar is moving out of the region. 324 // plus the velocity to decide if the avatar is moving out of the region.
325 RawPosition = PhysicsScene.TerrainManager.ClampPositionIntoKnownTerrain(RawPosition); 325 RawPosition = PhysScene.TerrainManager.ClampPositionIntoKnownTerrain(RawPosition);
326 DetailLog("{0},BSCharacter.PositionSanityCheck,notWithinKnownTerrain,clampedPos={1}", LocalID, RawPosition); 326 DetailLog("{0},BSCharacter.PositionSanityCheck,notWithinKnownTerrain,clampedPos={1}", LocalID, RawPosition);
327 return true; 327 return true;
328 } 328 }
329 329
330 // If below the ground, move the avatar up 330 // If below the ground, move the avatar up
331 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); 331 float terrainHeight = PhysScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition);
332 if (Position.Z < terrainHeight) 332 if (Position.Z < terrainHeight)
333 { 333 {
334 DetailLog("{0},BSCharacter.PositionSanityCheck,adjustForUnderGround,pos={1},terrain={2}", LocalID, _position, terrainHeight); 334 DetailLog("{0},BSCharacter.PositionSanityCheck,adjustForUnderGround,pos={1},terrain={2}", LocalID, _position, terrainHeight);
@@ -337,7 +337,7 @@ public sealed class BSCharacter : BSPhysObject
337 } 337 }
338 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) 338 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0)
339 { 339 {
340 float waterHeight = PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(_position); 340 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(_position);
341 if (Position.Z < waterHeight) 341 if (Position.Z < waterHeight)
342 { 342 {
343 _position.Z = waterHeight; 343 _position.Z = waterHeight;
@@ -358,7 +358,7 @@ public sealed class BSCharacter : BSPhysObject
358 { 358 {
359 // The new position value must be pushed into the physics engine but we can't 359 // The new position value must be pushed into the physics engine but we can't
360 // just assign to "Position" because of potential call loops. 360 // just assign to "Position" because of potential call loops.
361 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate() 361 PhysScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate()
362 { 362 {
363 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); 363 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
364 ForcePosition = _position; 364 ForcePosition = _position;
@@ -376,8 +376,8 @@ public sealed class BSCharacter : BSPhysObject
376 } 376 }
377 public override void UpdatePhysicalMassProperties(float physMass, bool inWorld) 377 public override void UpdatePhysicalMassProperties(float physMass, bool inWorld)
378 { 378 {
379 OMV.Vector3 localInertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass); 379 OMV.Vector3 localInertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass);
380 PhysicsScene.PE.SetMassProps(PhysBody, physMass, localInertia); 380 PhysScene.PE.SetMassProps(PhysBody, physMass, localInertia);
381 } 381 }
382 382
383 public override OMV.Vector3 Force { 383 public override OMV.Vector3 Force {
@@ -385,11 +385,11 @@ public sealed class BSCharacter : BSPhysObject
385 set { 385 set {
386 RawForce = value; 386 RawForce = value;
387 // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); 387 // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force);
388 PhysicsScene.TaintedObject("BSCharacter.SetForce", delegate() 388 PhysScene.TaintedObject("BSCharacter.SetForce", delegate()
389 { 389 {
390 DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, RawForce); 390 DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, RawForce);
391 if (PhysBody.HasPhysicalBody) 391 if (PhysBody.HasPhysicalBody)
392 PhysicsScene.PE.SetObjectForce(PhysBody, RawForce); 392 PhysScene.PE.SetObjectForce(PhysBody, RawForce);
393 }); 393 });
394 } 394 }
395 } 395 }
@@ -432,7 +432,7 @@ public sealed class BSCharacter : BSPhysObject
432 set { 432 set {
433 RawVelocity = value; 433 RawVelocity = value;
434 // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, RawVelocity); 434 // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, RawVelocity);
435 PhysicsScene.TaintedObject("BSCharacter.setVelocity", delegate() 435 PhysScene.TaintedObject("BSCharacter.setVelocity", delegate()
436 { 436 {
437 if (m_moveActor != null) 437 if (m_moveActor != null)
438 m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, true /* inTaintTime */); 438 m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, true /* inTaintTime */);
@@ -445,11 +445,11 @@ public sealed class BSCharacter : BSPhysObject
445 public override OMV.Vector3 ForceVelocity { 445 public override OMV.Vector3 ForceVelocity {
446 get { return RawVelocity; } 446 get { return RawVelocity; }
447 set { 447 set {
448 PhysicsScene.AssertInTaintTime("BSCharacter.ForceVelocity"); 448 PhysScene.AssertInTaintTime("BSCharacter.ForceVelocity");
449 449
450 RawVelocity = value; 450 RawVelocity = value;
451 PhysicsScene.PE.SetLinearVelocity(PhysBody, RawVelocity); 451 PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity);
452 PhysicsScene.PE.Activate(PhysBody, true); 452 PhysScene.PE.Activate(PhysBody, true);
453 } 453 }
454 } 454 }
455 public override OMV.Vector3 Torque { 455 public override OMV.Vector3 Torque {
@@ -479,7 +479,7 @@ public sealed class BSCharacter : BSPhysObject
479 if (_orientation != value) 479 if (_orientation != value)
480 { 480 {
481 _orientation = value; 481 _orientation = value;
482 PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate() 482 PhysScene.TaintedObject("BSCharacter.setOrientation", delegate()
483 { 483 {
484 ForceOrientation = _orientation; 484 ForceOrientation = _orientation;
485 }); 485 });
@@ -491,7 +491,7 @@ public sealed class BSCharacter : BSPhysObject
491 { 491 {
492 get 492 get
493 { 493 {
494 _orientation = PhysicsScene.PE.GetOrientation(PhysBody); 494 _orientation = PhysScene.PE.GetOrientation(PhysBody);
495 return _orientation; 495 return _orientation;
496 } 496 }
497 set 497 set
@@ -500,7 +500,7 @@ public sealed class BSCharacter : BSPhysObject
500 if (PhysBody.HasPhysicalBody) 500 if (PhysBody.HasPhysicalBody)
501 { 501 {
502 // _position = PhysicsScene.PE.GetPosition(BSBody); 502 // _position = PhysicsScene.PE.GetPosition(BSBody);
503 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); 503 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation);
504 } 504 }
505 } 505 }
506 } 506 }
@@ -549,14 +549,14 @@ public sealed class BSCharacter : BSPhysObject
549 public override bool FloatOnWater { 549 public override bool FloatOnWater {
550 set { 550 set {
551 _floatOnWater = value; 551 _floatOnWater = value;
552 PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate() 552 PhysScene.TaintedObject("BSCharacter.setFloatOnWater", delegate()
553 { 553 {
554 if (PhysBody.HasPhysicalBody) 554 if (PhysBody.HasPhysicalBody)
555 { 555 {
556 if (_floatOnWater) 556 if (_floatOnWater)
557 CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); 557 CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
558 else 558 else
559 CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); 559 CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
560 } 560 }
561 }); 561 });
562 } 562 }
@@ -577,7 +577,7 @@ public sealed class BSCharacter : BSPhysObject
577 public override float Buoyancy { 577 public override float Buoyancy {
578 get { return _buoyancy; } 578 get { return _buoyancy; }
579 set { _buoyancy = value; 579 set { _buoyancy = value;
580 PhysicsScene.TaintedObject("BSCharacter.setBuoyancy", delegate() 580 PhysScene.TaintedObject("BSCharacter.setBuoyancy", delegate()
581 { 581 {
582 DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); 582 DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
583 ForceBuoyancy = _buoyancy; 583 ForceBuoyancy = _buoyancy;
@@ -587,7 +587,7 @@ public sealed class BSCharacter : BSPhysObject
587 public override float ForceBuoyancy { 587 public override float ForceBuoyancy {
588 get { return _buoyancy; } 588 get { return _buoyancy; }
589 set { 589 set {
590 PhysicsScene.AssertInTaintTime("BSCharacter.ForceBuoyancy"); 590 PhysScene.AssertInTaintTime("BSCharacter.ForceBuoyancy");
591 591
592 _buoyancy = value; 592 _buoyancy = value;
593 DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); 593 DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
@@ -595,7 +595,7 @@ public sealed class BSCharacter : BSPhysObject
595 float grav = BSParam.Gravity * (1f - _buoyancy); 595 float grav = BSParam.Gravity * (1f - _buoyancy);
596 Gravity = new OMV.Vector3(0f, 0f, grav); 596 Gravity = new OMV.Vector3(0f, 0f, grav);
597 if (PhysBody.HasPhysicalBody) 597 if (PhysBody.HasPhysicalBody)
598 PhysicsScene.PE.SetGravity(PhysBody, Gravity); 598 PhysScene.PE.SetGravity(PhysBody, Gravity);
599 } 599 }
600 } 600 }
601 601
@@ -613,7 +613,7 @@ public sealed class BSCharacter : BSPhysObject
613 public override void AddForce(OMV.Vector3 force, bool pushforce) 613 public override void AddForce(OMV.Vector3 force, bool pushforce)
614 { 614 {
615 // Since this force is being applied in only one step, make this a force per second. 615 // Since this force is being applied in only one step, make this a force per second.
616 OMV.Vector3 addForce = force / PhysicsScene.LastTimeStep; 616 OMV.Vector3 addForce = force / PhysScene.LastTimeStep;
617 AddForce(addForce, pushforce, false); 617 AddForce(addForce, pushforce, false);
618 } 618 }
619 private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { 619 private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
@@ -622,13 +622,13 @@ public sealed class BSCharacter : BSPhysObject
622 OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); 622 OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude);
623 // DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce); 623 // DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce);
624 624
625 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() 625 PhysScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate()
626 { 626 {
627 // Bullet adds this central force to the total force for this tick 627 // Bullet adds this central force to the total force for this tick
628 // DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce); 628 // DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce);
629 if (PhysBody.HasPhysicalBody) 629 if (PhysBody.HasPhysicalBody)
630 { 630 {
631 PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce); 631 PhysScene.PE.ApplyCentralForce(PhysBody, addForce);
632 } 632 }
633 }); 633 });
634 } 634 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index e2e807e..56d2415 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -789,7 +789,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
789 if ((m_knownHas & m_knownChangedTerrainHeight) == 0 || pos != lastRememberedHeightPos) 789 if ((m_knownHas & m_knownChangedTerrainHeight) == 0 || pos != lastRememberedHeightPos)
790 { 790 {
791 lastRememberedHeightPos = pos; 791 lastRememberedHeightPos = pos;
792 m_knownTerrainHeight = ControllingPrim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos); 792 m_knownTerrainHeight = ControllingPrim.PhysScene.TerrainManager.GetTerrainHeightAtXYZ(pos);
793 m_knownHas |= m_knownChangedTerrainHeight; 793 m_knownHas |= m_knownChangedTerrainHeight;
794 } 794 }
795 return m_knownTerrainHeight; 795 return m_knownTerrainHeight;
@@ -801,7 +801,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
801 { 801 {
802 if ((m_knownHas & m_knownChangedWaterLevel) == 0) 802 if ((m_knownHas & m_knownChangedWaterLevel) == 0)
803 { 803 {
804 m_knownWaterLevel = ControllingPrim.PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(pos); 804 m_knownWaterLevel = ControllingPrim.PhysScene.TerrainManager.GetWaterLevelAtXYZ(pos);
805 m_knownHas |= m_knownChangedWaterLevel; 805 m_knownHas |= m_knownChangedWaterLevel;
806 } 806 }
807 return (float)m_knownWaterLevel; 807 return (float)m_knownWaterLevel;
@@ -1637,8 +1637,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1637 // Invoke the detailed logger and output something if it's enabled. 1637 // Invoke the detailed logger and output something if it's enabled.
1638 private void VDetailLog(string msg, params Object[] args) 1638 private void VDetailLog(string msg, params Object[] args)
1639 { 1639 {
1640 if (ControllingPrim.PhysicsScene.VehicleLoggingEnabled) 1640 if (ControllingPrim.PhysScene.VehicleLoggingEnabled)
1641 ControllingPrim.PhysicsScene.DetailLog(msg, args); 1641 ControllingPrim.PhysScene.DetailLog(msg, args);
1642 } 1642 }
1643 } 1643 }
1644} 1644}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index df1dd34..6d0d0eb 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -80,7 +80,7 @@ public abstract class BSLinkset
80 80
81 public BSPrimLinkable LinksetRoot { get; protected set; } 81 public BSPrimLinkable LinksetRoot { get; protected set; }
82 82
83 public BSScene PhysicsScene { get; private set; } 83 protected BSScene m_physicsScene { get; private set; }
84 84
85 static int m_nextLinksetID = 1; 85 static int m_nextLinksetID = 1;
86 public int LinksetID { get; private set; } 86 public int LinksetID { get; private set; }
@@ -115,7 +115,7 @@ public abstract class BSLinkset
115 // We create LOTS of linksets. 115 // We create LOTS of linksets.
116 if (m_nextLinksetID <= 0) 116 if (m_nextLinksetID <= 0)
117 m_nextLinksetID = 1; 117 m_nextLinksetID = 1;
118 PhysicsScene = scene; 118 m_physicsScene = scene;
119 LinksetRoot = parent; 119 LinksetRoot = parent;
120 m_children = new HashSet<BSPrimLinkable>(); 120 m_children = new HashSet<BSPrimLinkable>();
121 LinksetMass = parent.RawMass; 121 LinksetMass = parent.RawMass;
@@ -158,7 +158,7 @@ public abstract class BSLinkset
158 } 158 }
159 159
160 // The child is down to a linkset of just itself 160 // The child is down to a linkset of just itself
161 return BSLinkset.Factory(PhysicsScene, child); 161 return BSLinkset.Factory(m_physicsScene, child);
162 } 162 }
163 163
164 // Return 'true' if the passed object is the root object of this linkset 164 // Return 'true' if the passed object is the root object of this linkset
@@ -316,8 +316,8 @@ public abstract class BSLinkset
316 // Invoke the detailed logger and output something if it's enabled. 316 // Invoke the detailed logger and output something if it's enabled.
317 protected void DetailLog(string msg, params Object[] args) 317 protected void DetailLog(string msg, params Object[] args)
318 { 318 {
319 if (PhysicsScene.PhysicsLogging.Enabled) 319 if (m_physicsScene.PhysicsLogging.Enabled)
320 PhysicsScene.DetailLog(msg, args); 320 m_physicsScene.DetailLog(msg, args);
321 } 321 }
322 322
323} 323}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index be01808..01ada3f 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -121,7 +121,7 @@ public sealed class BSLinksetCompound : BSLinkset
121 // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. 121 // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding.
122 if (!Rebuilding && HasAnyChildren) 122 if (!Rebuilding && HasAnyChildren)
123 { 123 {
124 PhysicsScene.PostTaintObject("BSLinksetCompound.ScheduleRebuild", LinksetRoot.LocalID, delegate() 124 m_physicsScene.PostTaintObject("BSLinksetCompound.ScheduleRebuild", LinksetRoot.LocalID, delegate()
125 { 125 {
126 if (HasAnyChildren) 126 if (HasAnyChildren)
127 RecomputeLinksetCompound(); 127 RecomputeLinksetCompound();
@@ -147,10 +147,10 @@ public sealed class BSLinksetCompound : BSLinkset
147 { 147 {
148 // The origional prims are removed from the world as the shape of the root compound 148 // The origional prims are removed from the world as the shape of the root compound
149 // shape takes over. 149 // shape takes over.
150 PhysicsScene.PE.AddToCollisionFlags(child.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); 150 m_physicsScene.PE.AddToCollisionFlags(child.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
151 PhysicsScene.PE.ForceActivationState(child.PhysBody, ActivationState.DISABLE_SIMULATION); 151 m_physicsScene.PE.ForceActivationState(child.PhysBody, ActivationState.DISABLE_SIMULATION);
152 // We don't want collisions from the old linkset children. 152 // We don't want collisions from the old linkset children.
153 PhysicsScene.PE.RemoveFromCollisionFlags(child.PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 153 m_physicsScene.PE.RemoveFromCollisionFlags(child.PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
154 154
155 child.PhysBody.collisionType = CollisionType.LinksetChild; 155 child.PhysBody.collisionType = CollisionType.LinksetChild;
156 156
@@ -175,12 +175,12 @@ public sealed class BSLinksetCompound : BSLinkset
175 else 175 else
176 { 176 {
177 // The non-physical children can come back to life. 177 // The non-physical children can come back to life.
178 PhysicsScene.PE.RemoveFromCollisionFlags(child.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); 178 m_physicsScene.PE.RemoveFromCollisionFlags(child.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
179 179
180 child.PhysBody.collisionType = CollisionType.LinksetChild; 180 child.PhysBody.collisionType = CollisionType.LinksetChild;
181 181
182 // Don't force activation so setting of DISABLE_SIMULATION can stay if used. 182 // Don't force activation so setting of DISABLE_SIMULATION can stay if used.
183 PhysicsScene.PE.Activate(child.PhysBody, false); 183 m_physicsScene.PE.Activate(child.PhysBody, false);
184 ret = true; 184 ret = true;
185 } 185 }
186 return ret; 186 return ret;
@@ -196,7 +196,7 @@ public sealed class BSLinksetCompound : BSLinkset
196 // but it also means all the child positions get updated. 196 // but it also means all the child positions get updated.
197 // What would cause an unnecessary rebuild so we make sure the linkset is in a 197 // What would cause an unnecessary rebuild so we make sure the linkset is in a
198 // region before bothering to do a rebuild. 198 // region before bothering to do a rebuild.
199 if (!IsRoot(updated) && PhysicsScene.TerrainManager.IsWithinKnownTerrain(LinksetRoot.RawPosition)) 199 if (!IsRoot(updated) && m_physicsScene.TerrainManager.IsWithinKnownTerrain(LinksetRoot.RawPosition))
200 { 200 {
201 // If a child of the linkset is updating only the position or rotation, that can be done 201 // If a child of the linkset is updating only the position or rotation, that can be done
202 // without rebuilding the linkset. 202 // without rebuilding the linkset.
@@ -209,21 +209,21 @@ public sealed class BSLinksetCompound : BSLinkset
209 if ((whichUpdated & ~(UpdatedProperties.Position | UpdatedProperties.Orientation)) == 0) 209 if ((whichUpdated & ~(UpdatedProperties.Position | UpdatedProperties.Orientation)) == 0)
210 { 210 {
211 // Find the physical instance of the child 211 // Find the physical instance of the child
212 if (LinksetRoot.PhysShape.HasPhysicalShape && PhysicsScene.PE.IsCompound(LinksetRoot.PhysShape.physShapeInfo)) 212 if (LinksetRoot.PhysShape.HasPhysicalShape && m_physicsScene.PE.IsCompound(LinksetRoot.PhysShape.physShapeInfo))
213 { 213 {
214 // It is possible that the linkset is still under construction and the child is not yet 214 // It is possible that the linkset is still under construction and the child is not yet
215 // inserted into the compound shape. A rebuild of the linkset in a pre-step action will 215 // inserted into the compound shape. A rebuild of the linkset in a pre-step action will
216 // build the whole thing with the new position or rotation. 216 // build the whole thing with the new position or rotation.
217 // The index must be checked because Bullet references the child array but does no validity 217 // The index must be checked because Bullet references the child array but does no validity
218 // checking of the child index passed. 218 // checking of the child index passed.
219 int numLinksetChildren = PhysicsScene.PE.GetNumberOfCompoundChildren(LinksetRoot.PhysShape.physShapeInfo); 219 int numLinksetChildren = m_physicsScene.PE.GetNumberOfCompoundChildren(LinksetRoot.PhysShape.physShapeInfo);
220 if (updated.LinksetChildIndex < numLinksetChildren) 220 if (updated.LinksetChildIndex < numLinksetChildren)
221 { 221 {
222 BulletShape linksetChildShape = PhysicsScene.PE.GetChildShapeFromCompoundShapeIndex(LinksetRoot.PhysShape.physShapeInfo, updated.LinksetChildIndex); 222 BulletShape linksetChildShape = m_physicsScene.PE.GetChildShapeFromCompoundShapeIndex(LinksetRoot.PhysShape.physShapeInfo, updated.LinksetChildIndex);
223 if (linksetChildShape.HasPhysicalShape) 223 if (linksetChildShape.HasPhysicalShape)
224 { 224 {
225 // Found the child shape within the compound shape 225 // Found the child shape within the compound shape
226 PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape.physShapeInfo, updated.LinksetChildIndex, 226 m_physicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape.physShapeInfo, updated.LinksetChildIndex,
227 updated.RawPosition - LinksetRoot.RawPosition, 227 updated.RawPosition - LinksetRoot.RawPosition,
228 updated.RawOrientation * OMV.Quaternion.Inverse(LinksetRoot.RawOrientation), 228 updated.RawOrientation * OMV.Quaternion.Inverse(LinksetRoot.RawOrientation),
229 true /* shouldRecalculateLocalAabb */); 229 true /* shouldRecalculateLocalAabb */);
@@ -401,9 +401,9 @@ public sealed class BSLinksetCompound : BSLinkset
401 // Here we build the compound shape made up of all the children. 401 // Here we build the compound shape made up of all the children.
402 402
403 // Free up any shape we'd previously built. 403 // Free up any shape we'd previously built.
404 LinksetShape.Dereference(PhysicsScene); 404 LinksetShape.Dereference(m_physicsScene);
405 405
406 LinksetShape = BSShapeCompound.GetReference(PhysicsScene, LinksetRoot); 406 LinksetShape = BSShapeCompound.GetReference(m_physicsScene, LinksetRoot);
407 407
408 // The center of mass for the linkset is the geometric center of the group. 408 // The center of mass for the linkset is the geometric center of the group.
409 // Compute a displacement for each component so it is relative to the center-of-mass. 409 // Compute a displacement for each component so it is relative to the center-of-mass.
@@ -435,7 +435,7 @@ public sealed class BSLinksetCompound : BSLinkset
435 childShape.IncrementReference(); 435 childShape.IncrementReference();
436 OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement; 436 OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacement;
437 OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation; 437 OMV.Quaternion offsetRot = cPrim.RawOrientation * invRootOrientation;
438 PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot); 438 m_physicsScene.PE.AddChildShapeToCompoundShape(LinksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot);
439 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},rShape={2},cShape={3},offPos={4},offRot={5}", 439 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},rShape={2},cShape={3},offPos={4},offRot={5}",
440 LinksetRoot.LocalID, memberIndex, LinksetRoot.PhysShape, cPrim.PhysShape, offsetPos, offsetRot); 440 LinksetRoot.LocalID, memberIndex, LinksetRoot.PhysShape, cPrim.PhysShape, offsetPos, offsetRot);
441 441
@@ -446,14 +446,14 @@ public sealed class BSLinksetCompound : BSLinkset
446 446
447 // Sneak the built compound shape in as the shape of the root prim. 447 // Sneak the built compound shape in as the shape of the root prim.
448 // Note this doesn't touch the root prim's PhysShape so be sure the manage the difference. 448 // Note this doesn't touch the root prim's PhysShape so be sure the manage the difference.
449 PhysicsScene.PE.SetCollisionShape(PhysicsScene.World, LinksetRoot.PhysBody, LinksetShape.physShapeInfo); 449 m_physicsScene.PE.SetCollisionShape(m_physicsScene.World, LinksetRoot.PhysBody, LinksetShape.physShapeInfo);
450 450
451 // With all of the linkset packed into the root prim, it has the mass of everyone. 451 // With all of the linkset packed into the root prim, it has the mass of everyone.
452 LinksetMass = ComputeLinksetMass(); 452 LinksetMass = ComputeLinksetMass();
453 LinksetRoot.UpdatePhysicalMassProperties(LinksetMass, true); 453 LinksetRoot.UpdatePhysicalMassProperties(LinksetMass, true);
454 454
455 // Enable the physical position updator to return the position and rotation of the root shape 455 // Enable the physical position updator to return the position and rotation of the root shape
456 PhysicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE); 456 m_physicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE);
457 } 457 }
458 finally 458 finally
459 { 459 {
@@ -461,7 +461,7 @@ public sealed class BSLinksetCompound : BSLinkset
461 } 461 }
462 462
463 // See that the Aabb surrounds the new shape 463 // See that the Aabb surrounds the new shape
464 PhysicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape.physShapeInfo); 464 m_physicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape.physShapeInfo);
465 } 465 }
466} 466}
467} \ No newline at end of file 467} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
index 1811772..a06a44d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
@@ -51,7 +51,7 @@ public sealed class BSLinksetConstraints : BSLinkset
51 if (HasAnyChildren && IsRoot(requestor)) 51 if (HasAnyChildren && IsRoot(requestor))
52 { 52 {
53 // Queue to happen after all the other taint processing 53 // Queue to happen after all the other taint processing
54 PhysicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() 54 m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate()
55 { 55 {
56 if (HasAnyChildren && IsRoot(requestor)) 56 if (HasAnyChildren && IsRoot(requestor))
57 RecomputeLinksetConstraints(); 57 RecomputeLinksetConstraints();
@@ -142,7 +142,7 @@ public sealed class BSLinksetConstraints : BSLinkset
142 rootx.LocalID, rootx.PhysBody.AddrString, 142 rootx.LocalID, rootx.PhysBody.AddrString,
143 childx.LocalID, childx.PhysBody.AddrString); 143 childx.LocalID, childx.PhysBody.AddrString);
144 144
145 PhysicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate() 145 m_physicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate()
146 { 146 {
147 PhysicallyUnlinkAChildFromRoot(rootx, childx); 147 PhysicallyUnlinkAChildFromRoot(rootx, childx);
148 }); 148 });
@@ -187,7 +187,7 @@ public sealed class BSLinksetConstraints : BSLinkset
187 // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 187 // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818
188 188
189 BSConstraint6Dof constrain = new BSConstraint6Dof( 189 BSConstraint6Dof constrain = new BSConstraint6Dof(
190 PhysicsScene.World, rootPrim.PhysBody, childPrim.PhysBody, midPoint, true, true ); 190 m_physicsScene.World, rootPrim.PhysBody, childPrim.PhysBody, midPoint, true, true );
191 // PhysicsScene.World, childPrim.BSBody, rootPrim.BSBody, midPoint, true, true ); 191 // PhysicsScene.World, childPrim.BSBody, rootPrim.BSBody, midPoint, true, true );
192 192
193 /* NOTE: below is an attempt to build constraint with full frame computation, etc. 193 /* NOTE: below is an attempt to build constraint with full frame computation, etc.
@@ -216,7 +216,7 @@ public sealed class BSLinksetConstraints : BSLinkset
216 // ================================================================================== 216 // ==================================================================================
217 */ 217 */
218 218
219 PhysicsScene.Constraints.AddConstraint(constrain); 219 m_physicsScene.Constraints.AddConstraint(constrain);
220 220
221 // zero linear and angular limits makes the objects unable to move in relation to each other 221 // zero linear and angular limits makes the objects unable to move in relation to each other
222 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 222 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
@@ -248,10 +248,10 @@ public sealed class BSLinksetConstraints : BSLinkset
248 childPrim.LocalID, childPrim.PhysBody.AddrString); 248 childPrim.LocalID, childPrim.PhysBody.AddrString);
249 249
250 // Find the constraint for this link and get rid of it from the overall collection and from my list 250 // Find the constraint for this link and get rid of it from the overall collection and from my list
251 if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) 251 if (m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody))
252 { 252 {
253 // Make the child refresh its location 253 // Make the child refresh its location
254 PhysicsScene.PE.PushUpdate(childPrim.PhysBody); 254 m_physicsScene.PE.PushUpdate(childPrim.PhysBody);
255 ret = true; 255 ret = true;
256 } 256 }
257 257
@@ -265,7 +265,7 @@ public sealed class BSLinksetConstraints : BSLinkset
265 { 265 {
266 DetailLog("{0},BSLinksetConstraint.PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID); 266 DetailLog("{0},BSLinksetConstraint.PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID);
267 267
268 return PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody); 268 return m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody);
269 } 269 }
270 270
271 // Call each of the constraints that make up this linkset and recompute the 271 // Call each of the constraints that make up this linkset and recompute the
@@ -289,7 +289,7 @@ public sealed class BSLinksetConstraints : BSLinkset
289 child.UpdatePhysicalMassProperties(linksetMass, true); 289 child.UpdatePhysicalMassProperties(linksetMass, true);
290 290
291 BSConstraint constrain; 291 BSConstraint constrain;
292 if (!PhysicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) 292 if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain))
293 { 293 {
294 // If constraint doesn't exist yet, create it. 294 // If constraint doesn't exist yet, create it.
295 constrain = BuildConstraint(LinksetRoot, child); 295 constrain = BuildConstraint(LinksetRoot, child);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index b6eb619..6a3ada2 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -72,14 +72,14 @@ public abstract class BSPhysObject : PhysicsActor
72 } 72 }
73 protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName) 73 protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName)
74 { 74 {
75 PhysicsScene = parentScene; 75 PhysScene = parentScene;
76 LocalID = localID; 76 LocalID = localID;
77 PhysObjectName = name; 77 PhysObjectName = name;
78 Name = name; // PhysicsActor also has the name of the object. Someday consolidate. 78 Name = name; // PhysicsActor also has the name of the object. Someday consolidate.
79 TypeName = typeName; 79 TypeName = typeName;
80 80
81 // The collection of things that push me around 81 // The collection of things that push me around
82 PhysicalActors = new BSActorCollection(PhysicsScene); 82 PhysicalActors = new BSActorCollection(PhysScene);
83 83
84 // Initialize variables kept in base. 84 // Initialize variables kept in base.
85 GravModifier = 1.0f; 85 GravModifier = 1.0f;
@@ -112,13 +112,13 @@ public abstract class BSPhysObject : PhysicsActor
112 public virtual void Destroy() 112 public virtual void Destroy()
113 { 113 {
114 PhysicalActors.Enable(false); 114 PhysicalActors.Enable(false);
115 PhysicsScene.TaintedObject("BSPhysObject.Destroy", delegate() 115 PhysScene.TaintedObject("BSPhysObject.Destroy", delegate()
116 { 116 {
117 PhysicalActors.Dispose(); 117 PhysicalActors.Dispose();
118 }); 118 });
119 } 119 }
120 120
121 public BSScene PhysicsScene { get; protected set; } 121 public BSScene PhysScene { get; protected set; }
122 // public override uint LocalID { get; set; } // Use the LocalID definition in PhysicsActor 122 // public override uint LocalID { get; set; } // Use the LocalID definition in PhysicsActor
123 public string PhysObjectName { get; protected set; } 123 public string PhysObjectName { get; protected set; }
124 public string TypeName { get; protected set; } 124 public string TypeName { get; protected set; }
@@ -270,7 +270,7 @@ public abstract class BSPhysObject : PhysicsActor
270 public void ActivateIfPhysical(bool forceIt) 270 public void ActivateIfPhysical(bool forceIt)
271 { 271 {
272 if (IsPhysical && PhysBody.HasPhysicalBody) 272 if (IsPhysical && PhysBody.HasPhysicalBody)
273 PhysicsScene.PE.Activate(PhysBody, forceIt); 273 PhysScene.PE.Activate(PhysBody, forceIt);
274 } 274 }
275 275
276 // 'actors' act on the physical object to change or constrain its motion. These can range from 276 // 'actors' act on the physical object to change or constrain its motion. These can range from
@@ -333,29 +333,29 @@ public abstract class BSPhysObject : PhysicsActor
333 protected long CollisionAccumulation { get; set; } 333 protected long CollisionAccumulation { get; set; }
334 334
335 public override bool IsColliding { 335 public override bool IsColliding {
336 get { return (CollidingStep == PhysicsScene.SimulationStep); } 336 get { return (CollidingStep == PhysScene.SimulationStep); }
337 set { 337 set {
338 if (value) 338 if (value)
339 CollidingStep = PhysicsScene.SimulationStep; 339 CollidingStep = PhysScene.SimulationStep;
340 else 340 else
341 CollidingStep = 0; 341 CollidingStep = 0;
342 } 342 }
343 } 343 }
344 public override bool CollidingGround { 344 public override bool CollidingGround {
345 get { return (CollidingGroundStep == PhysicsScene.SimulationStep); } 345 get { return (CollidingGroundStep == PhysScene.SimulationStep); }
346 set 346 set
347 { 347 {
348 if (value) 348 if (value)
349 CollidingGroundStep = PhysicsScene.SimulationStep; 349 CollidingGroundStep = PhysScene.SimulationStep;
350 else 350 else
351 CollidingGroundStep = 0; 351 CollidingGroundStep = 0;
352 } 352 }
353 } 353 }
354 public override bool CollidingObj { 354 public override bool CollidingObj {
355 get { return (CollidingObjectStep == PhysicsScene.SimulationStep); } 355 get { return (CollidingObjectStep == PhysScene.SimulationStep); }
356 set { 356 set {
357 if (value) 357 if (value)
358 CollidingObjectStep = PhysicsScene.SimulationStep; 358 CollidingObjectStep = PhysScene.SimulationStep;
359 else 359 else
360 CollidingObjectStep = 0; 360 CollidingObjectStep = 0;
361 } 361 }
@@ -380,14 +380,14 @@ public abstract class BSPhysObject : PhysicsActor
380 bool ret = false; 380 bool ret = false;
381 381
382 // The following lines make IsColliding(), CollidingGround() and CollidingObj work 382 // The following lines make IsColliding(), CollidingGround() and CollidingObj work
383 CollidingStep = PhysicsScene.SimulationStep; 383 CollidingStep = PhysScene.SimulationStep;
384 if (collidingWith <= PhysicsScene.TerrainManager.HighestTerrainID) 384 if (collidingWith <= PhysScene.TerrainManager.HighestTerrainID)
385 { 385 {
386 CollidingGroundStep = PhysicsScene.SimulationStep; 386 CollidingGroundStep = PhysScene.SimulationStep;
387 } 387 }
388 else 388 else
389 { 389 {
390 CollidingObjectStep = PhysicsScene.SimulationStep; 390 CollidingObjectStep = PhysScene.SimulationStep;
391 } 391 }
392 392
393 CollisionAccumulation++; 393 CollisionAccumulation++;
@@ -397,10 +397,10 @@ public abstract class BSPhysObject : PhysicsActor
397 397
398 // Make a collection of the collisions that happened the last simulation tick. 398 // Make a collection of the collisions that happened the last simulation tick.
399 // This is different than the collection created for sending up to the simulator as it is cleared every tick. 399 // This is different than the collection created for sending up to the simulator as it is cleared every tick.
400 if (CollisionsLastTickStep != PhysicsScene.SimulationStep) 400 if (CollisionsLastTickStep != PhysScene.SimulationStep)
401 { 401 {
402 CollisionsLastTick = new CollisionEventUpdate(); 402 CollisionsLastTick = new CollisionEventUpdate();
403 CollisionsLastTickStep = PhysicsScene.SimulationStep; 403 CollisionsLastTickStep = PhysScene.SimulationStep;
404 } 404 }
405 CollisionsLastTick.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); 405 CollisionsLastTick.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
406 406
@@ -427,9 +427,9 @@ public abstract class BSPhysObject : PhysicsActor
427 bool force = (CollisionCollection.Count == 0 && CollisionsLastReported.Count != 0); 427 bool force = (CollisionCollection.Count == 0 && CollisionsLastReported.Count != 0);
428 428
429 // throttle the collisions to the number of milliseconds specified in the subscription 429 // throttle the collisions to the number of milliseconds specified in the subscription
430 if (force || (PhysicsScene.SimulationNowTime >= NextCollisionOkTime)) 430 if (force || (PhysScene.SimulationNowTime >= NextCollisionOkTime))
431 { 431 {
432 NextCollisionOkTime = PhysicsScene.SimulationNowTime + SubscribedEventsMs; 432 NextCollisionOkTime = PhysScene.SimulationNowTime + SubscribedEventsMs;
433 433
434 // We are called if we previously had collisions. If there are no collisions 434 // We are called if we previously had collisions. If there are no collisions
435 // this time, send up one last empty event so OpenSim can sense collision end. 435 // this time, send up one last empty event so OpenSim can sense collision end.
@@ -464,10 +464,10 @@ public abstract class BSPhysObject : PhysicsActor
464 // make sure first collision happens 464 // make sure first collision happens
465 NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs); 465 NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs);
466 466
467 PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate() 467 PhysScene.TaintedObject(TypeName+".SubscribeEvents", delegate()
468 { 468 {
469 if (PhysBody.HasPhysicalBody) 469 if (PhysBody.HasPhysicalBody)
470 CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 470 CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
471 }); 471 });
472 } 472 }
473 else 473 else
@@ -479,11 +479,11 @@ public abstract class BSPhysObject : PhysicsActor
479 public override void UnSubscribeEvents() { 479 public override void UnSubscribeEvents() {
480 // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); 480 // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName);
481 SubscribedEventsMs = 0; 481 SubscribedEventsMs = 0;
482 PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() 482 PhysScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate()
483 { 483 {
484 // Make sure there is a body there because sometimes destruction happens in an un-ideal order. 484 // Make sure there is a body there because sometimes destruction happens in an un-ideal order.
485 if (PhysBody.HasPhysicalBody) 485 if (PhysBody.HasPhysicalBody)
486 CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 486 CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
487 }); 487 });
488 } 488 }
489 // Return 'true' if the simulator wants collision events 489 // Return 'true' if the simulator wants collision events
@@ -497,7 +497,7 @@ public abstract class BSPhysObject : PhysicsActor
497 { 497 {
498 // Scale the collision count by the time since the last collision. 498 // Scale the collision count by the time since the last collision.
499 // The "+1" prevents dividing by zero. 499 // The "+1" prevents dividing by zero.
500 long timeAgo = PhysicsScene.SimulationStep - CollidingStep + 1; 500 long timeAgo = PhysScene.SimulationStep - CollidingStep + 1;
501 CollisionScore = CollisionAccumulation / timeAgo; 501 CollisionScore = CollisionAccumulation / timeAgo;
502 } 502 }
503 public override float CollisionScore { get; set; } 503 public override float CollisionScore { get; set; }
@@ -524,8 +524,8 @@ public abstract class BSPhysObject : PhysicsActor
524 // High performance detailed logging routine used by the physical objects. 524 // High performance detailed logging routine used by the physical objects.
525 protected void DetailLog(string msg, params Object[] args) 525 protected void DetailLog(string msg, params Object[] args)
526 { 526 {
527 if (PhysicsScene.PhysicsLogging.Enabled) 527 if (PhysScene.PhysicsLogging.Enabled)
528 PhysicsScene.DetailLog(msg, args); 528 PhysScene.DetailLog(msg, args);
529 } 529 }
530 530
531} 531}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 5d12338..0d45579 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -101,21 +101,21 @@ public class BSPrim : BSPhysObject
101 _isVolumeDetect = false; 101 _isVolumeDetect = false;
102 102
103 // We keep a handle to the vehicle actor so we can set vehicle parameters later. 103 // We keep a handle to the vehicle actor so we can set vehicle parameters later.
104 VehicleActor = new BSDynamics(PhysicsScene, this, VehicleActorName); 104 VehicleActor = new BSDynamics(PhysScene, this, VehicleActorName);
105 PhysicalActors.Add(VehicleActorName, VehicleActor); 105 PhysicalActors.Add(VehicleActorName, VehicleActor);
106 106
107 _mass = CalculateMass(); 107 _mass = CalculateMass();
108 108
109 // DetailLog("{0},BSPrim.constructor,call", LocalID); 109 // DetailLog("{0},BSPrim.constructor,call", LocalID);
110 // do the actual object creation at taint time 110 // do the actual object creation at taint time
111 PhysicsScene.TaintedObject("BSPrim.create", delegate() 111 PhysScene.TaintedObject("BSPrim.create", delegate()
112 { 112 {
113 // Make sure the object is being created with some sanity. 113 // Make sure the object is being created with some sanity.
114 ExtremeSanityCheck(true /* inTaintTime */); 114 ExtremeSanityCheck(true /* inTaintTime */);
115 115
116 CreateGeomAndObject(true); 116 CreateGeomAndObject(true);
117 117
118 CurrentCollisionFlags = PhysicsScene.PE.GetCollisionFlags(PhysBody); 118 CurrentCollisionFlags = PhysScene.PE.GetCollisionFlags(PhysBody);
119 }); 119 });
120 } 120 }
121 121
@@ -128,13 +128,13 @@ public class BSPrim : BSPhysObject
128 // Undo any vehicle properties 128 // Undo any vehicle properties
129 this.VehicleType = (int)Vehicle.TYPE_NONE; 129 this.VehicleType = (int)Vehicle.TYPE_NONE;
130 130
131 PhysicsScene.TaintedObject("BSPrim.Destroy", delegate() 131 PhysScene.TaintedObject("BSPrim.Destroy", delegate()
132 { 132 {
133 DetailLog("{0},BSPrim.Destroy,taint,", LocalID); 133 DetailLog("{0},BSPrim.Destroy,taint,", LocalID);
134 // If there are physical body and shape, release my use of same. 134 // If there are physical body and shape, release my use of same.
135 PhysicsScene.Shapes.DereferenceBody(PhysBody, null); 135 PhysScene.Shapes.DereferenceBody(PhysBody, null);
136 PhysBody.Clear(); 136 PhysBody.Clear();
137 PhysShape.Dereference(PhysicsScene); 137 PhysShape.Dereference(PhysScene);
138 PhysShape = new BSShapeNull(); 138 PhysShape = new BSShapeNull();
139 }); 139 });
140 } 140 }
@@ -163,7 +163,7 @@ public class BSPrim : BSPhysObject
163 } 163 }
164 public override bool ForceBodyShapeRebuild(bool inTaintTime) 164 public override bool ForceBodyShapeRebuild(bool inTaintTime)
165 { 165 {
166 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ForceBodyShapeRebuild", delegate() 166 PhysScene.TaintedObject(inTaintTime, "BSPrim.ForceBodyShapeRebuild", delegate()
167 { 167 {
168 _mass = CalculateMass(); // changing the shape changes the mass 168 _mass = CalculateMass(); // changing the shape changes the mass
169 CreateGeomAndObject(true); 169 CreateGeomAndObject(true);
@@ -180,7 +180,7 @@ public class BSPrim : BSPhysObject
180 if (value != _isSelected) 180 if (value != _isSelected)
181 { 181 {
182 _isSelected = value; 182 _isSelected = value;
183 PhysicsScene.TaintedObject("BSPrim.setSelected", delegate() 183 PhysScene.TaintedObject("BSPrim.setSelected", delegate()
184 { 184 {
185 DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected); 185 DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected);
186 SetObjectDynamic(false); 186 SetObjectDynamic(false);
@@ -226,23 +226,23 @@ public class BSPrim : BSPhysObject
226 _rotationalVelocity = OMV.Vector3.Zero; 226 _rotationalVelocity = OMV.Vector3.Zero;
227 227
228 // Zero some other properties in the physics engine 228 // Zero some other properties in the physics engine
229 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() 229 PhysScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
230 { 230 {
231 if (PhysBody.HasPhysicalBody) 231 if (PhysBody.HasPhysicalBody)
232 PhysicsScene.PE.ClearAllForces(PhysBody); 232 PhysScene.PE.ClearAllForces(PhysBody);
233 }); 233 });
234 } 234 }
235 public override void ZeroAngularMotion(bool inTaintTime) 235 public override void ZeroAngularMotion(bool inTaintTime)
236 { 236 {
237 _rotationalVelocity = OMV.Vector3.Zero; 237 _rotationalVelocity = OMV.Vector3.Zero;
238 // Zero some other properties in the physics engine 238 // Zero some other properties in the physics engine
239 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() 239 PhysScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
240 { 240 {
241 // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); 241 // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity);
242 if (PhysBody.HasPhysicalBody) 242 if (PhysBody.HasPhysicalBody)
243 { 243 {
244 PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); 244 PhysScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
245 PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); 245 PhysScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
246 } 246 }
247 }); 247 });
248 } 248 }
@@ -260,11 +260,11 @@ public class BSPrim : BSPhysObject
260 260
261 EnableActor(LockedAxis != LockedAxisFree, LockedAxisActorName, delegate() 261 EnableActor(LockedAxis != LockedAxisFree, LockedAxisActorName, delegate()
262 { 262 {
263 return new BSActorLockAxis(PhysicsScene, this, LockedAxisActorName); 263 return new BSActorLockAxis(PhysScene, this, LockedAxisActorName);
264 }); 264 });
265 265
266 // Update parameters so the new actor's Refresh() action is called at the right time. 266 // Update parameters so the new actor's Refresh() action is called at the right time.
267 PhysicsScene.TaintedObject("BSPrim.LockAngularMotion", delegate() 267 PhysScene.TaintedObject("BSPrim.LockAngularMotion", delegate()
268 { 268 {
269 UpdatePhysicalParameters(); 269 UpdatePhysicalParameters();
270 }); 270 });
@@ -294,7 +294,7 @@ public class BSPrim : BSPhysObject
294 _position = value; 294 _position = value;
295 PositionSanityCheck(false); 295 PositionSanityCheck(false);
296 296
297 PhysicsScene.TaintedObject("BSPrim.setPosition", delegate() 297 PhysScene.TaintedObject("BSPrim.setPosition", delegate()
298 { 298 {
299 DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 299 DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
300 ForcePosition = _position; 300 ForcePosition = _position;
@@ -304,14 +304,14 @@ public class BSPrim : BSPhysObject
304 304
305 public override OMV.Vector3 ForcePosition { 305 public override OMV.Vector3 ForcePosition {
306 get { 306 get {
307 _position = PhysicsScene.PE.GetPosition(PhysBody); 307 _position = PhysScene.PE.GetPosition(PhysBody);
308 return _position; 308 return _position;
309 } 309 }
310 set { 310 set {
311 _position = value; 311 _position = value;
312 if (PhysBody.HasPhysicalBody) 312 if (PhysBody.HasPhysicalBody)
313 { 313 {
314 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); 314 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation);
315 ActivateIfPhysical(false); 315 ActivateIfPhysical(false);
316 } 316 }
317 } 317 }
@@ -328,7 +328,7 @@ public class BSPrim : BSPhysObject
328 if (!IsPhysicallyActive) 328 if (!IsPhysicallyActive)
329 return ret; 329 return ret;
330 330
331 if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition)) 331 if (!PhysScene.TerrainManager.IsWithinKnownTerrain(RawPosition))
332 { 332 {
333 // The physical object is out of the known/simulated area. 333 // The physical object is out of the known/simulated area.
334 // Upper levels of code will handle the transition to other areas so, for 334 // Upper levels of code will handle the transition to other areas so, for
@@ -336,7 +336,7 @@ public class BSPrim : BSPhysObject
336 return ret; 336 return ret;
337 } 337 }
338 338
339 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); 339 float terrainHeight = PhysScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition);
340 OMV.Vector3 upForce = OMV.Vector3.Zero; 340 OMV.Vector3 upForce = OMV.Vector3.Zero;
341 float approxSize = Math.Max(Size.X, Math.Max(Size.Y, Size.Z)); 341 float approxSize = Math.Max(Size.X, Math.Max(Size.Y, Size.Z));
342 if ((RawPosition.Z + approxSize / 2f) < terrainHeight) 342 if ((RawPosition.Z + approxSize / 2f) < terrainHeight)
@@ -357,7 +357,7 @@ public class BSPrim : BSPhysObject
357 357
358 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) 358 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0)
359 { 359 {
360 float waterHeight = PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(_position); 360 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(_position);
361 // TODO: a floating motor so object will bob in the water 361 // TODO: a floating motor so object will bob in the water
362 if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f) 362 if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f)
363 { 363 {
@@ -365,7 +365,7 @@ public class BSPrim : BSPhysObject
365 upForce.Z = (waterHeight - RawPosition.Z) * 1f; 365 upForce.Z = (waterHeight - RawPosition.Z) * 1f;
366 366
367 // Apply upforce and overcome gravity. 367 // Apply upforce and overcome gravity.
368 OMV.Vector3 correctionForce = upForce - PhysicsScene.DefaultGravity; 368 OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity;
369 DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, _position, upForce, correctionForce); 369 DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, _position, upForce, correctionForce);
370 AddForce(correctionForce, false, inTaintTime); 370 AddForce(correctionForce, false, inTaintTime);
371 ret = true; 371 ret = true;
@@ -431,10 +431,10 @@ public class BSPrim : BSPhysObject
431 { 431 {
432 if (IsStatic) 432 if (IsStatic)
433 { 433 {
434 PhysicsScene.PE.SetGravity(PhysBody, PhysicsScene.DefaultGravity); 434 PhysScene.PE.SetGravity(PhysBody, PhysScene.DefaultGravity);
435 Inertia = OMV.Vector3.Zero; 435 Inertia = OMV.Vector3.Zero;
436 PhysicsScene.PE.SetMassProps(PhysBody, 0f, Inertia); 436 PhysScene.PE.SetMassProps(PhysBody, 0f, Inertia);
437 PhysicsScene.PE.UpdateInertiaTensor(PhysBody); 437 PhysScene.PE.UpdateInertiaTensor(PhysBody);
438 } 438 }
439 else 439 else
440 { 440 {
@@ -443,16 +443,16 @@ public class BSPrim : BSPhysObject
443 // Changing interesting properties doesn't change proxy and collision cache 443 // Changing interesting properties doesn't change proxy and collision cache
444 // information. The Bullet solution is to re-add the object to the world 444 // information. The Bullet solution is to re-add the object to the world
445 // after parameters are changed. 445 // after parameters are changed.
446 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); 446 PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody);
447 } 447 }
448 448
449 // The computation of mass props requires gravity to be set on the object. 449 // The computation of mass props requires gravity to be set on the object.
450 Gravity = ComputeGravity(Buoyancy); 450 Gravity = ComputeGravity(Buoyancy);
451 PhysicsScene.PE.SetGravity(PhysBody, Gravity); 451 PhysScene.PE.SetGravity(PhysBody, Gravity);
452 452
453 Inertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass); 453 Inertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass);
454 PhysicsScene.PE.SetMassProps(PhysBody, physMass, Inertia); 454 PhysScene.PE.SetMassProps(PhysBody, physMass, Inertia);
455 PhysicsScene.PE.UpdateInertiaTensor(PhysBody); 455 PhysScene.PE.UpdateInertiaTensor(PhysBody);
456 456
457 DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", 457 DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}",
458 LocalID, physMass, Inertia, Gravity, inWorld); 458 LocalID, physMass, Inertia, Gravity, inWorld);
@@ -468,7 +468,7 @@ public class BSPrim : BSPhysObject
468 // Return what gravity should be set to this very moment 468 // Return what gravity should be set to this very moment
469 public OMV.Vector3 ComputeGravity(float buoyancy) 469 public OMV.Vector3 ComputeGravity(float buoyancy)
470 { 470 {
471 OMV.Vector3 ret = PhysicsScene.DefaultGravity; 471 OMV.Vector3 ret = PhysScene.DefaultGravity;
472 472
473 if (!IsStatic) 473 if (!IsStatic)
474 { 474 {
@@ -497,7 +497,7 @@ public class BSPrim : BSPhysObject
497 RawForce = value; 497 RawForce = value;
498 EnableActor(RawForce != OMV.Vector3.Zero, SetForceActorName, delegate() 498 EnableActor(RawForce != OMV.Vector3.Zero, SetForceActorName, delegate()
499 { 499 {
500 return new BSActorSetForce(PhysicsScene, this, SetForceActorName); 500 return new BSActorSetForce(PhysScene, this, SetForceActorName);
501 }); 501 });
502 } 502 }
503 } 503 }
@@ -509,7 +509,7 @@ public class BSPrim : BSPhysObject
509 set { 509 set {
510 Vehicle type = (Vehicle)value; 510 Vehicle type = (Vehicle)value;
511 511
512 PhysicsScene.TaintedObject("setVehicleType", delegate() 512 PhysScene.TaintedObject("setVehicleType", delegate()
513 { 513 {
514 // Vehicle code changes the parameters for this vehicle type. 514 // Vehicle code changes the parameters for this vehicle type.
515 VehicleActor.ProcessTypeChange(type); 515 VehicleActor.ProcessTypeChange(type);
@@ -519,7 +519,7 @@ public class BSPrim : BSPhysObject
519 } 519 }
520 public override void VehicleFloatParam(int param, float value) 520 public override void VehicleFloatParam(int param, float value)
521 { 521 {
522 PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() 522 PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
523 { 523 {
524 VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); 524 VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value);
525 ActivateIfPhysical(false); 525 ActivateIfPhysical(false);
@@ -527,7 +527,7 @@ public class BSPrim : BSPhysObject
527 } 527 }
528 public override void VehicleVectorParam(int param, OMV.Vector3 value) 528 public override void VehicleVectorParam(int param, OMV.Vector3 value)
529 { 529 {
530 PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() 530 PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
531 { 531 {
532 VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); 532 VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value);
533 ActivateIfPhysical(false); 533 ActivateIfPhysical(false);
@@ -535,7 +535,7 @@ public class BSPrim : BSPhysObject
535 } 535 }
536 public override void VehicleRotationParam(int param, OMV.Quaternion rotation) 536 public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
537 { 537 {
538 PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() 538 PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
539 { 539 {
540 VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); 540 VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation);
541 ActivateIfPhysical(false); 541 ActivateIfPhysical(false);
@@ -543,7 +543,7 @@ public class BSPrim : BSPhysObject
543 } 543 }
544 public override void VehicleFlags(int param, bool remove) 544 public override void VehicleFlags(int param, bool remove)
545 { 545 {
546 PhysicsScene.TaintedObject("BSPrim.VehicleFlags", delegate() 546 PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate()
547 { 547 {
548 VehicleActor.ProcessVehicleFlags(param, remove); 548 VehicleActor.ProcessVehicleFlags(param, remove);
549 }); 549 });
@@ -555,7 +555,7 @@ public class BSPrim : BSPhysObject
555 if (_isVolumeDetect != newValue) 555 if (_isVolumeDetect != newValue)
556 { 556 {
557 _isVolumeDetect = newValue; 557 _isVolumeDetect = newValue;
558 PhysicsScene.TaintedObject("BSPrim.SetVolumeDetect", delegate() 558 PhysScene.TaintedObject("BSPrim.SetVolumeDetect", delegate()
559 { 559 {
560 // DetailLog("{0},setVolumeDetect,taint,volDetect={1}", LocalID, _isVolumeDetect); 560 // DetailLog("{0},setVolumeDetect,taint,volDetect={1}", LocalID, _isVolumeDetect);
561 SetObjectDynamic(true); 561 SetObjectDynamic(true);
@@ -566,7 +566,7 @@ public class BSPrim : BSPhysObject
566 public override void SetMaterial(int material) 566 public override void SetMaterial(int material)
567 { 567 {
568 base.SetMaterial(material); 568 base.SetMaterial(material);
569 PhysicsScene.TaintedObject("BSPrim.SetMaterial", delegate() 569 PhysScene.TaintedObject("BSPrim.SetMaterial", delegate()
570 { 570 {
571 UpdatePhysicalParameters(); 571 UpdatePhysicalParameters();
572 }); 572 });
@@ -579,7 +579,7 @@ public class BSPrim : BSPhysObject
579 if (base.Friction != value) 579 if (base.Friction != value)
580 { 580 {
581 base.Friction = value; 581 base.Friction = value;
582 PhysicsScene.TaintedObject("BSPrim.setFriction", delegate() 582 PhysScene.TaintedObject("BSPrim.setFriction", delegate()
583 { 583 {
584 UpdatePhysicalParameters(); 584 UpdatePhysicalParameters();
585 }); 585 });
@@ -594,7 +594,7 @@ public class BSPrim : BSPhysObject
594 if (base.Restitution != value) 594 if (base.Restitution != value)
595 { 595 {
596 base.Restitution = value; 596 base.Restitution = value;
597 PhysicsScene.TaintedObject("BSPrim.setRestitution", delegate() 597 PhysScene.TaintedObject("BSPrim.setRestitution", delegate()
598 { 598 {
599 UpdatePhysicalParameters(); 599 UpdatePhysicalParameters();
600 }); 600 });
@@ -611,7 +611,7 @@ public class BSPrim : BSPhysObject
611 if (base.Density != value) 611 if (base.Density != value)
612 { 612 {
613 base.Density = value; 613 base.Density = value;
614 PhysicsScene.TaintedObject("BSPrim.setDensity", delegate() 614 PhysScene.TaintedObject("BSPrim.setDensity", delegate()
615 { 615 {
616 UpdatePhysicalParameters(); 616 UpdatePhysicalParameters();
617 }); 617 });
@@ -626,7 +626,7 @@ public class BSPrim : BSPhysObject
626 if (base.GravModifier != value) 626 if (base.GravModifier != value)
627 { 627 {
628 base.GravModifier = value; 628 base.GravModifier = value;
629 PhysicsScene.TaintedObject("BSPrim.setGravityModifier", delegate() 629 PhysScene.TaintedObject("BSPrim.setGravityModifier", delegate()
630 { 630 {
631 UpdatePhysicalParameters(); 631 UpdatePhysicalParameters();
632 }); 632 });
@@ -637,7 +637,7 @@ public class BSPrim : BSPhysObject
637 get { return RawVelocity; } 637 get { return RawVelocity; }
638 set { 638 set {
639 RawVelocity = value; 639 RawVelocity = value;
640 PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate() 640 PhysScene.TaintedObject("BSPrim.setVelocity", delegate()
641 { 641 {
642 // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, RawVelocity); 642 // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, RawVelocity);
643 ForceVelocity = RawVelocity; 643 ForceVelocity = RawVelocity;
@@ -647,13 +647,13 @@ public class BSPrim : BSPhysObject
647 public override OMV.Vector3 ForceVelocity { 647 public override OMV.Vector3 ForceVelocity {
648 get { return RawVelocity; } 648 get { return RawVelocity; }
649 set { 649 set {
650 PhysicsScene.AssertInTaintTime("BSPrim.ForceVelocity"); 650 PhysScene.AssertInTaintTime("BSPrim.ForceVelocity");
651 651
652 RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity); 652 RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity);
653 if (PhysBody.HasPhysicalBody) 653 if (PhysBody.HasPhysicalBody)
654 { 654 {
655 DetailLog("{0},BSPrim.ForceVelocity,taint,vel={1}", LocalID, RawVelocity); 655 DetailLog("{0},BSPrim.ForceVelocity,taint,vel={1}", LocalID, RawVelocity);
656 PhysicsScene.PE.SetLinearVelocity(PhysBody, RawVelocity); 656 PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity);
657 ActivateIfPhysical(false); 657 ActivateIfPhysical(false);
658 } 658 }
659 } 659 }
@@ -664,7 +664,7 @@ public class BSPrim : BSPhysObject
664 RawTorque = value; 664 RawTorque = value;
665 EnableActor(RawTorque != OMV.Vector3.Zero, SetTorqueActorName, delegate() 665 EnableActor(RawTorque != OMV.Vector3.Zero, SetTorqueActorName, delegate()
666 { 666 {
667 return new BSActorSetTorque(PhysicsScene, this, SetTorqueActorName); 667 return new BSActorSetTorque(PhysScene, this, SetTorqueActorName);
668 }); 668 });
669 DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, RawTorque); 669 DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, RawTorque);
670 } 670 }
@@ -687,7 +687,7 @@ public class BSPrim : BSPhysObject
687 return; 687 return;
688 _orientation = value; 688 _orientation = value;
689 689
690 PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() 690 PhysScene.TaintedObject("BSPrim.setOrientation", delegate()
691 { 691 {
692 ForceOrientation = _orientation; 692 ForceOrientation = _orientation;
693 }); 693 });
@@ -698,14 +698,14 @@ public class BSPrim : BSPhysObject
698 { 698 {
699 get 699 get
700 { 700 {
701 _orientation = PhysicsScene.PE.GetOrientation(PhysBody); 701 _orientation = PhysScene.PE.GetOrientation(PhysBody);
702 return _orientation; 702 return _orientation;
703 } 703 }
704 set 704 set
705 { 705 {
706 _orientation = value; 706 _orientation = value;
707 if (PhysBody.HasPhysicalBody) 707 if (PhysBody.HasPhysicalBody)
708 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); 708 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation);
709 } 709 }
710 } 710 }
711 public override int PhysicsActorType { 711 public override int PhysicsActorType {
@@ -718,7 +718,7 @@ public class BSPrim : BSPhysObject
718 if (_isPhysical != value) 718 if (_isPhysical != value)
719 { 719 {
720 _isPhysical = value; 720 _isPhysical = value;
721 PhysicsScene.TaintedObject("BSPrim.setIsPhysical", delegate() 721 PhysScene.TaintedObject("BSPrim.setIsPhysical", delegate()
722 { 722 {
723 DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); 723 DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical);
724 SetObjectDynamic(true); 724 SetObjectDynamic(true);
@@ -773,7 +773,7 @@ public class BSPrim : BSPhysObject
773 773
774 // Mangling all the physical properties requires the object not be in the physical world. 774 // Mangling all the physical properties requires the object not be in the physical world.
775 // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). 775 // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found).
776 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); 776 PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody);
777 777
778 // Set up the object physicalness (does gravity and collisions move this object) 778 // Set up the object physicalness (does gravity and collisions move this object)
779 MakeDynamic(IsStatic); 779 MakeDynamic(IsStatic);
@@ -790,7 +790,7 @@ public class BSPrim : BSPhysObject
790 AddObjectToPhysicalWorld(); 790 AddObjectToPhysicalWorld();
791 791
792 // Rebuild its shape 792 // Rebuild its shape
793 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody); 793 PhysScene.PE.UpdateSingleAabb(PhysScene.World, PhysBody);
794 794
795 DetailLog("{0},BSPrim.UpdatePhysicalParameters,taintExit,static={1},solid={2},mass={3},collide={4},cf={5:X},cType={6},body={7},shape={8}", 795 DetailLog("{0},BSPrim.UpdatePhysicalParameters,taintExit,static={1},solid={2},mass={3},collide={4},cf={5:X},cType={6},body={7},shape={8}",
796 LocalID, IsStatic, IsSolid, Mass, SubscribedEvents(), 796 LocalID, IsStatic, IsSolid, Mass, SubscribedEvents(),
@@ -807,28 +807,28 @@ public class BSPrim : BSPhysObject
807 if (makeStatic) 807 if (makeStatic)
808 { 808 {
809 // Become a Bullet 'static' object type 809 // Become a Bullet 'static' object type
810 CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); 810 CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT);
811 // Stop all movement 811 // Stop all movement
812 ZeroMotion(true); 812 ZeroMotion(true);
813 813
814 // Set various physical properties so other object interact properly 814 // Set various physical properties so other object interact properly
815 PhysicsScene.PE.SetFriction(PhysBody, Friction); 815 PhysScene.PE.SetFriction(PhysBody, Friction);
816 PhysicsScene.PE.SetRestitution(PhysBody, Restitution); 816 PhysScene.PE.SetRestitution(PhysBody, Restitution);
817 PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); 817 PhysScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
818 818
819 // Mass is zero which disables a bunch of physics stuff in Bullet 819 // Mass is zero which disables a bunch of physics stuff in Bullet
820 UpdatePhysicalMassProperties(0f, false); 820 UpdatePhysicalMassProperties(0f, false);
821 // Set collision detection parameters 821 // Set collision detection parameters
822 if (BSParam.CcdMotionThreshold > 0f) 822 if (BSParam.CcdMotionThreshold > 0f)
823 { 823 {
824 PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); 824 PhysScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
825 PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); 825 PhysScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
826 } 826 }
827 827
828 // The activation state is 'disabled' so Bullet will not try to act on it. 828 // The activation state is 'disabled' so Bullet will not try to act on it.
829 // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_SIMULATION); 829 // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_SIMULATION);
830 // Start it out sleeping and physical actions could wake it up. 830 // Start it out sleeping and physical actions could wake it up.
831 PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ISLAND_SLEEPING); 831 PhysScene.PE.ForceActivationState(PhysBody, ActivationState.ISLAND_SLEEPING);
832 832
833 // This collides like a static object 833 // This collides like a static object
834 PhysBody.collisionType = CollisionType.Static; 834 PhysBody.collisionType = CollisionType.Static;
@@ -836,11 +836,11 @@ public class BSPrim : BSPhysObject
836 else 836 else
837 { 837 {
838 // Not a Bullet static object 838 // Not a Bullet static object
839 CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); 839 CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT);
840 840
841 // Set various physical properties so other object interact properly 841 // Set various physical properties so other object interact properly
842 PhysicsScene.PE.SetFriction(PhysBody, Friction); 842 PhysScene.PE.SetFriction(PhysBody, Friction);
843 PhysicsScene.PE.SetRestitution(PhysBody, Restitution); 843 PhysScene.PE.SetRestitution(PhysBody, Restitution);
844 // DetailLog("{0},BSPrim.MakeDynamic,frict={1},rest={2}", LocalID, Friction, Restitution); 844 // DetailLog("{0},BSPrim.MakeDynamic,frict={1},rest={2}", LocalID, Friction, Restitution);
845 845
846 // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 846 // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382
@@ -858,22 +858,22 @@ public class BSPrim : BSPhysObject
858 // Set collision detection parameters 858 // Set collision detection parameters
859 if (BSParam.CcdMotionThreshold > 0f) 859 if (BSParam.CcdMotionThreshold > 0f)
860 { 860 {
861 PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); 861 PhysScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
862 PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); 862 PhysScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
863 } 863 }
864 864
865 // Various values for simulation limits 865 // Various values for simulation limits
866 PhysicsScene.PE.SetDamping(PhysBody, BSParam.LinearDamping, BSParam.AngularDamping); 866 PhysScene.PE.SetDamping(PhysBody, BSParam.LinearDamping, BSParam.AngularDamping);
867 PhysicsScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime); 867 PhysScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime);
868 PhysicsScene.PE.SetSleepingThresholds(PhysBody, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold); 868 PhysScene.PE.SetSleepingThresholds(PhysBody, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold);
869 PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); 869 PhysScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
870 870
871 // This collides like an object. 871 // This collides like an object.
872 PhysBody.collisionType = CollisionType.Dynamic; 872 PhysBody.collisionType = CollisionType.Dynamic;
873 873
874 // Force activation of the object so Bullet will act on it. 874 // Force activation of the object so Bullet will act on it.
875 // Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects. 875 // Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects.
876 PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG); 876 PhysScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG);
877 } 877 }
878 } 878 }
879 879
@@ -883,7 +883,7 @@ public class BSPrim : BSPhysObject
883 // the functions after this one set up the state of a possibly newly created collision body. 883 // the functions after this one set up the state of a possibly newly created collision body.
884 private void MakeSolid(bool makeSolid) 884 private void MakeSolid(bool makeSolid)
885 { 885 {
886 CollisionObjectTypes bodyType = (CollisionObjectTypes)PhysicsScene.PE.GetBodyType(PhysBody); 886 CollisionObjectTypes bodyType = (CollisionObjectTypes)PhysScene.PE.GetBodyType(PhysBody);
887 if (makeSolid) 887 if (makeSolid)
888 { 888 {
889 // Verify the previous code created the correct shape for this type of thing. 889 // Verify the previous code created the correct shape for this type of thing.
@@ -891,7 +891,7 @@ public class BSPrim : BSPhysObject
891 { 891 {
892 m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType); 892 m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType);
893 } 893 }
894 CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); 894 CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
895 } 895 }
896 else 896 else
897 { 897 {
@@ -899,7 +899,7 @@ public class BSPrim : BSPhysObject
899 { 899 {
900 m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); 900 m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType);
901 } 901 }
902 CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); 902 CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE);
903 903
904 // Change collision info from a static object to a ghosty collision object 904 // Change collision info from a static object to a ghosty collision object
905 PhysBody.collisionType = CollisionType.VolumeDetect; 905 PhysBody.collisionType = CollisionType.VolumeDetect;
@@ -911,11 +911,11 @@ public class BSPrim : BSPhysObject
911 { 911 {
912 if (wantsCollisionEvents) 912 if (wantsCollisionEvents)
913 { 913 {
914 CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 914 CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
915 } 915 }
916 else 916 else
917 { 917 {
918 CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 918 CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
919 } 919 }
920 } 920 }
921 921
@@ -926,7 +926,7 @@ public class BSPrim : BSPhysObject
926 { 926 {
927 if (PhysBody.HasPhysicalBody) 927 if (PhysBody.HasPhysicalBody)
928 { 928 {
929 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody); 929 PhysScene.PE.AddObjectToWorld(PhysScene.World, PhysBody);
930 } 930 }
931 else 931 else
932 { 932 {
@@ -961,12 +961,12 @@ public class BSPrim : BSPhysObject
961 public override bool FloatOnWater { 961 public override bool FloatOnWater {
962 set { 962 set {
963 _floatOnWater = value; 963 _floatOnWater = value;
964 PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate() 964 PhysScene.TaintedObject("BSPrim.setFloatOnWater", delegate()
965 { 965 {
966 if (_floatOnWater) 966 if (_floatOnWater)
967 CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); 967 CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
968 else 968 else
969 CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); 969 CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
970 }); 970 });
971 } 971 }
972 } 972 }
@@ -978,7 +978,7 @@ public class BSPrim : BSPhysObject
978 _rotationalVelocity = value; 978 _rotationalVelocity = value;
979 Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity); 979 Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity);
980 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); 980 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
981 PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() 981 PhysScene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
982 { 982 {
983 ForceRotationalVelocity = _rotationalVelocity; 983 ForceRotationalVelocity = _rotationalVelocity;
984 }); 984 });
@@ -993,7 +993,7 @@ public class BSPrim : BSPhysObject
993 if (PhysBody.HasPhysicalBody) 993 if (PhysBody.HasPhysicalBody)
994 { 994 {
995 DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); 995 DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
996 PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); 996 PhysScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
997 // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); 997 // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
998 ActivateIfPhysical(false); 998 ActivateIfPhysical(false);
999 } 999 }
@@ -1009,7 +1009,7 @@ public class BSPrim : BSPhysObject
1009 get { return _buoyancy; } 1009 get { return _buoyancy; }
1010 set { 1010 set {
1011 _buoyancy = value; 1011 _buoyancy = value;
1012 PhysicsScene.TaintedObject("BSPrim.setBuoyancy", delegate() 1012 PhysScene.TaintedObject("BSPrim.setBuoyancy", delegate()
1013 { 1013 {
1014 ForceBuoyancy = _buoyancy; 1014 ForceBuoyancy = _buoyancy;
1015 }); 1015 });
@@ -1032,7 +1032,7 @@ public class BSPrim : BSPhysObject
1032 base.MoveToTargetActive = value; 1032 base.MoveToTargetActive = value;
1033 EnableActor(MoveToTargetActive, MoveToTargetActorName, delegate() 1033 EnableActor(MoveToTargetActive, MoveToTargetActorName, delegate()
1034 { 1034 {
1035 return new BSActorMoveToTarget(PhysicsScene, this, MoveToTargetActorName); 1035 return new BSActorMoveToTarget(PhysScene, this, MoveToTargetActorName);
1036 }); 1036 });
1037 } 1037 }
1038 } 1038 }
@@ -1044,7 +1044,7 @@ public class BSPrim : BSPhysObject
1044 base.HoverActive = value; 1044 base.HoverActive = value;
1045 EnableActor(HoverActive, HoverActorName, delegate() 1045 EnableActor(HoverActive, HoverActorName, delegate()
1046 { 1046 {
1047 return new BSActorHover(PhysicsScene, this, HoverActorName); 1047 return new BSActorHover(PhysScene, this, HoverActorName);
1048 }); 1048 });
1049 } 1049 }
1050 } 1050 }
@@ -1054,7 +1054,7 @@ public class BSPrim : BSPhysObject
1054 OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); 1054 OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude);
1055 1055
1056 // Since this force is being applied in only one step, make this a force per second. 1056 // Since this force is being applied in only one step, make this a force per second.
1057 addForce /= PhysicsScene.LastTimeStep; 1057 addForce /= PhysScene.LastTimeStep;
1058 AddForce(addForce, pushforce, false /* inTaintTime */); 1058 AddForce(addForce, pushforce, false /* inTaintTime */);
1059 } 1059 }
1060 1060
@@ -1069,13 +1069,13 @@ public class BSPrim : BSPhysObject
1069 // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); 1069 // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce);
1070 1070
1071 OMV.Vector3 addForce = force; 1071 OMV.Vector3 addForce = force;
1072 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() 1072 PhysScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate()
1073 { 1073 {
1074 // Bullet adds this central force to the total force for this tick 1074 // Bullet adds this central force to the total force for this tick
1075 DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce); 1075 DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce);
1076 if (PhysBody.HasPhysicalBody) 1076 if (PhysBody.HasPhysicalBody)
1077 { 1077 {
1078 PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce); 1078 PhysScene.PE.ApplyCentralForce(PhysBody, addForce);
1079 ActivateIfPhysical(false); 1079 ActivateIfPhysical(false);
1080 } 1080 }
1081 }); 1081 });
@@ -1097,13 +1097,13 @@ public class BSPrim : BSPhysObject
1097 OMV.Vector3 addImpulse = Util.ClampV(impulse, BSParam.MaxAddForceMagnitude); 1097 OMV.Vector3 addImpulse = Util.ClampV(impulse, BSParam.MaxAddForceMagnitude);
1098 // DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse); 1098 // DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse);
1099 1099
1100 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddImpulse", delegate() 1100 PhysScene.TaintedObject(inTaintTime, "BSPrim.AddImpulse", delegate()
1101 { 1101 {
1102 // Bullet adds this impulse immediately to the velocity 1102 // Bullet adds this impulse immediately to the velocity
1103 DetailLog("{0},BSPrim.addForceImpulse,taint,impulseforce={1}", LocalID, addImpulse); 1103 DetailLog("{0},BSPrim.addForceImpulse,taint,impulseforce={1}", LocalID, addImpulse);
1104 if (PhysBody.HasPhysicalBody) 1104 if (PhysBody.HasPhysicalBody)
1105 { 1105 {
1106 PhysicsScene.PE.ApplyCentralImpulse(PhysBody, addImpulse); 1106 PhysScene.PE.ApplyCentralImpulse(PhysBody, addImpulse);
1107 ActivateIfPhysical(false); 1107 ActivateIfPhysical(false);
1108 } 1108 }
1109 }); 1109 });
@@ -1122,12 +1122,12 @@ public class BSPrim : BSPhysObject
1122 if (force.IsFinite()) 1122 if (force.IsFinite())
1123 { 1123 {
1124 OMV.Vector3 angForce = force; 1124 OMV.Vector3 angForce = force;
1125 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddAngularForce", delegate() 1125 PhysScene.TaintedObject(inTaintTime, "BSPrim.AddAngularForce", delegate()
1126 { 1126 {
1127 if (PhysBody.HasPhysicalBody) 1127 if (PhysBody.HasPhysicalBody)
1128 { 1128 {
1129 DetailLog("{0},BSPrim.AddAngularForce,taint,angForce={1}", LocalID, angForce); 1129 DetailLog("{0},BSPrim.AddAngularForce,taint,angForce={1}", LocalID, angForce);
1130 PhysicsScene.PE.ApplyTorque(PhysBody, angForce); 1130 PhysScene.PE.ApplyTorque(PhysBody, angForce);
1131 ActivateIfPhysical(false); 1131 ActivateIfPhysical(false);
1132 } 1132 }
1133 }); 1133 });
@@ -1146,11 +1146,11 @@ public class BSPrim : BSPhysObject
1146 public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime) 1146 public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime)
1147 { 1147 {
1148 OMV.Vector3 applyImpulse = impulse; 1148 OMV.Vector3 applyImpulse = impulse;
1149 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate() 1149 PhysScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate()
1150 { 1150 {
1151 if (PhysBody.HasPhysicalBody) 1151 if (PhysBody.HasPhysicalBody)
1152 { 1152 {
1153 PhysicsScene.PE.ApplyTorqueImpulse(PhysBody, applyImpulse); 1153 PhysScene.PE.ApplyTorqueImpulse(PhysBody, applyImpulse);
1154 ActivateIfPhysical(false); 1154 ActivateIfPhysical(false);
1155 } 1155 }
1156 }); 1156 });
@@ -1452,7 +1452,7 @@ public class BSPrim : BSPhysObject
1452 // Create the correct physical representation for this type of object. 1452 // Create the correct physical representation for this type of object.
1453 // Updates base.PhysBody and base.PhysShape with the new information. 1453 // Updates base.PhysBody and base.PhysShape with the new information.
1454 // Ignore 'forceRebuild'. 'GetBodyAndShape' makes the right choices and changes of necessary. 1454 // Ignore 'forceRebuild'. 'GetBodyAndShape' makes the right choices and changes of necessary.
1455 PhysicsScene.Shapes.GetBodyAndShape(false /*forceRebuild */, PhysicsScene.World, this, delegate(BulletBody pBody, BulletShape pShape) 1455 PhysScene.Shapes.GetBodyAndShape(false /*forceRebuild */, PhysScene.World, this, delegate(BulletBody pBody, BulletShape pShape)
1456 { 1456 {
1457 // Called if the current prim body is about to be destroyed. 1457 // Called if the current prim body is about to be destroyed.
1458 // Remove all the physical dependencies on the old body. 1458 // Remove all the physical dependencies on the old body.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
index 81104ec..5236909 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
@@ -47,9 +47,9 @@ public class BSPrimLinkable : BSPrimDisplaced
47 OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) 47 OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
48 : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical) 48 : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical)
49 { 49 {
50 Linkset = BSLinkset.Factory(PhysicsScene, this); 50 Linkset = BSLinkset.Factory(PhysScene, this);
51 51
52 PhysicsScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate() 52 PhysScene.TaintedObject("BSPrimLinksetCompound.Refresh", delegate()
53 { 53 {
54 Linkset.Refresh(this); 54 Linkset.Refresh(this);
55 }); 55 });
@@ -99,7 +99,7 @@ public class BSPrimLinkable : BSPrimDisplaced
99 set 99 set
100 { 100 {
101 base.Position = value; 101 base.Position = value;
102 PhysicsScene.TaintedObject("BSPrimLinkset.setPosition", delegate() 102 PhysScene.TaintedObject("BSPrimLinkset.setPosition", delegate()
103 { 103 {
104 Linkset.UpdateProperties(UpdatedProperties.Position, this); 104 Linkset.UpdateProperties(UpdatedProperties.Position, this);
105 }); 105 });
@@ -113,7 +113,7 @@ public class BSPrimLinkable : BSPrimDisplaced
113 set 113 set
114 { 114 {
115 base.Orientation = value; 115 base.Orientation = value;
116 PhysicsScene.TaintedObject("BSPrimLinkset.setOrientation", delegate() 116 PhysScene.TaintedObject("BSPrimLinkset.setOrientation", delegate()
117 { 117 {
118 Linkset.UpdateProperties(UpdatedProperties.Orientation, this); 118 Linkset.UpdateProperties(UpdatedProperties.Orientation, this);
119 }); 119 });
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
index e4fecc3..5a19797 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
@@ -92,7 +92,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
92 private void BuildHeightmapTerrain() 92 private void BuildHeightmapTerrain()
93 { 93 {
94 // Create the terrain shape from the mapInfo 94 // Create the terrain shape from the mapInfo
95 m_mapInfo.terrainShape = PhysicsScene.PE.CreateTerrainShape( m_mapInfo.ID, 95 m_mapInfo.terrainShape = m_physicsScene.PE.CreateTerrainShape( m_mapInfo.ID,
96 new Vector3(m_mapInfo.sizeX, m_mapInfo.sizeY, 0), m_mapInfo.minZ, m_mapInfo.maxZ, 96 new Vector3(m_mapInfo.sizeX, m_mapInfo.sizeY, 0), m_mapInfo.minZ, m_mapInfo.maxZ,
97 m_mapInfo.heightMap, 1f, BSParam.TerrainCollisionMargin); 97 m_mapInfo.heightMap, 1f, BSParam.TerrainCollisionMargin);
98 98
@@ -103,26 +103,26 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
103 centerPos.Y = m_mapInfo.minCoords.Y + (m_mapInfo.sizeY / 2f); 103 centerPos.Y = m_mapInfo.minCoords.Y + (m_mapInfo.sizeY / 2f);
104 centerPos.Z = m_mapInfo.minZ + ((m_mapInfo.maxZ - m_mapInfo.minZ) / 2f); 104 centerPos.Z = m_mapInfo.minZ + ((m_mapInfo.maxZ - m_mapInfo.minZ) / 2f);
105 105
106 m_mapInfo.terrainBody = PhysicsScene.PE.CreateBodyWithDefaultMotionState(m_mapInfo.terrainShape, 106 m_mapInfo.terrainBody = m_physicsScene.PE.CreateBodyWithDefaultMotionState(m_mapInfo.terrainShape,
107 m_mapInfo.ID, centerPos, Quaternion.Identity); 107 m_mapInfo.ID, centerPos, Quaternion.Identity);
108 108
109 // Set current terrain attributes 109 // Set current terrain attributes
110 PhysicsScene.PE.SetFriction(m_mapInfo.terrainBody, BSParam.TerrainFriction); 110 m_physicsScene.PE.SetFriction(m_mapInfo.terrainBody, BSParam.TerrainFriction);
111 PhysicsScene.PE.SetHitFraction(m_mapInfo.terrainBody, BSParam.TerrainHitFraction); 111 m_physicsScene.PE.SetHitFraction(m_mapInfo.terrainBody, BSParam.TerrainHitFraction);
112 PhysicsScene.PE.SetRestitution(m_mapInfo.terrainBody, BSParam.TerrainRestitution); 112 m_physicsScene.PE.SetRestitution(m_mapInfo.terrainBody, BSParam.TerrainRestitution);
113 PhysicsScene.PE.SetCollisionFlags(m_mapInfo.terrainBody, CollisionFlags.CF_STATIC_OBJECT); 113 m_physicsScene.PE.SetCollisionFlags(m_mapInfo.terrainBody, CollisionFlags.CF_STATIC_OBJECT);
114 114
115 // Return the new terrain to the world of physical objects 115 // Return the new terrain to the world of physical objects
116 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_mapInfo.terrainBody); 116 m_physicsScene.PE.AddObjectToWorld(m_physicsScene.World, m_mapInfo.terrainBody);
117 117
118 // redo its bounding box now that it is in the world 118 // redo its bounding box now that it is in the world
119 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_mapInfo.terrainBody); 119 m_physicsScene.PE.UpdateSingleAabb(m_physicsScene.World, m_mapInfo.terrainBody);
120 120
121 m_mapInfo.terrainBody.collisionType = CollisionType.Terrain; 121 m_mapInfo.terrainBody.collisionType = CollisionType.Terrain;
122 m_mapInfo.terrainBody.ApplyCollisionMask(PhysicsScene); 122 m_mapInfo.terrainBody.ApplyCollisionMask(m_physicsScene);
123 123
124 // Make it so the terrain will not move or be considered for movement. 124 // Make it so the terrain will not move or be considered for movement.
125 PhysicsScene.PE.ForceActivationState(m_mapInfo.terrainBody, ActivationState.DISABLE_SIMULATION); 125 m_physicsScene.PE.ForceActivationState(m_mapInfo.terrainBody, ActivationState.DISABLE_SIMULATION);
126 126
127 return; 127 return;
128 } 128 }
@@ -134,9 +134,9 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
134 { 134 {
135 if (m_mapInfo.terrainBody.HasPhysicalBody) 135 if (m_mapInfo.terrainBody.HasPhysicalBody)
136 { 136 {
137 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_mapInfo.terrainBody); 137 m_physicsScene.PE.RemoveObjectFromWorld(m_physicsScene.World, m_mapInfo.terrainBody);
138 // Frees both the body and the shape. 138 // Frees both the body and the shape.
139 PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_mapInfo.terrainBody); 139 m_physicsScene.PE.DestroyObject(m_physicsScene.World, m_mapInfo.terrainBody);
140 } 140 }
141 } 141 }
142 m_mapInfo = null; 142 m_mapInfo = null;
@@ -155,7 +155,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
155 catch 155 catch
156 { 156 {
157 // Sometimes they give us wonky values of X and Y. Give a warning and return something. 157 // Sometimes they give us wonky values of X and Y. Give a warning and return something.
158 PhysicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, pos={2}", 158 m_physicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, pos={2}",
159 LogHeader, m_mapInfo.terrainRegionBase, pos); 159 LogHeader, m_mapInfo.terrainRegionBase, pos);
160 ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET; 160 ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET;
161 } 161 }
@@ -165,7 +165,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
165 // The passed position is relative to the base of the region. 165 // The passed position is relative to the base of the region.
166 public override float GetWaterLevelAtXYZ(Vector3 pos) 166 public override float GetWaterLevelAtXYZ(Vector3 pos)
167 { 167 {
168 return PhysicsScene.SimpleWaterLevel; 168 return m_physicsScene.SimpleWaterLevel;
169 } 169 }
170} 170}
171} 171}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
index 5240ad8..0d16eda 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
@@ -50,14 +50,14 @@ public abstract class BSTerrainPhys : IDisposable
50 Mesh = 1 50 Mesh = 1
51 } 51 }
52 52
53 public BSScene PhysicsScene { get; private set; } 53 protected BSScene m_physicsScene { get; private set; }
54 // Base of the region in world coordinates. Coordinates inside the region are relative to this. 54 // Base of the region in world coordinates. Coordinates inside the region are relative to this.
55 public Vector3 TerrainBase { get; private set; } 55 public Vector3 TerrainBase { get; private set; }
56 public uint ID { get; private set; } 56 public uint ID { get; private set; }
57 57
58 public BSTerrainPhys(BSScene physicsScene, Vector3 regionBase, uint id) 58 public BSTerrainPhys(BSScene physicsScene, Vector3 regionBase, uint id)
59 { 59 {
60 PhysicsScene = physicsScene; 60 m_physicsScene = physicsScene;
61 TerrainBase = regionBase; 61 TerrainBase = regionBase;
62 ID = id; 62 ID = id;
63 } 63 }
@@ -86,7 +86,7 @@ public sealed class BSTerrainManager : IDisposable
86 public Vector3 DefaultRegionSize = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); 86 public Vector3 DefaultRegionSize = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
87 87
88 // The scene that I am part of 88 // The scene that I am part of
89 private BSScene PhysicsScene { get; set; } 89 private BSScene m_physicsScene { get; set; }
90 90
91 // The ground plane created to keep thing from falling to infinity. 91 // The ground plane created to keep thing from falling to infinity.
92 private BulletBody m_groundPlane; 92 private BulletBody m_groundPlane;
@@ -113,7 +113,7 @@ public sealed class BSTerrainManager : IDisposable
113 113
114 public BSTerrainManager(BSScene physicsScene) 114 public BSTerrainManager(BSScene physicsScene)
115 { 115 {
116 PhysicsScene = physicsScene; 116 m_physicsScene = physicsScene;
117 m_terrains = new Dictionary<Vector3,BSTerrainPhys>(); 117 m_terrains = new Dictionary<Vector3,BSTerrainPhys>();
118 118
119 // Assume one region of default size 119 // Assume one region of default size
@@ -132,21 +132,21 @@ public sealed class BSTerrainManager : IDisposable
132 // safe to call Bullet in real time. We hope no one is moving prims around yet. 132 // safe to call Bullet in real time. We hope no one is moving prims around yet.
133 public void CreateInitialGroundPlaneAndTerrain() 133 public void CreateInitialGroundPlaneAndTerrain()
134 { 134 {
135 DetailLog("{0},BSTerrainManager.CreateInitialGroundPlaneAndTerrain,region={1}", BSScene.DetailLogZero, PhysicsScene.RegionName); 135 DetailLog("{0},BSTerrainManager.CreateInitialGroundPlaneAndTerrain,region={1}", BSScene.DetailLogZero, m_physicsScene.RegionName);
136 // The ground plane is here to catch things that are trying to drop to negative infinity 136 // The ground plane is here to catch things that are trying to drop to negative infinity
137 BulletShape groundPlaneShape = PhysicsScene.PE.CreateGroundPlaneShape(BSScene.GROUNDPLANE_ID, 1f, BSParam.TerrainCollisionMargin); 137 BulletShape groundPlaneShape = m_physicsScene.PE.CreateGroundPlaneShape(BSScene.GROUNDPLANE_ID, 1f, BSParam.TerrainCollisionMargin);
138 m_groundPlane = PhysicsScene.PE.CreateBodyWithDefaultMotionState(groundPlaneShape, 138 m_groundPlane = m_physicsScene.PE.CreateBodyWithDefaultMotionState(groundPlaneShape,
139 BSScene.GROUNDPLANE_ID, Vector3.Zero, Quaternion.Identity); 139 BSScene.GROUNDPLANE_ID, Vector3.Zero, Quaternion.Identity);
140 140
141 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_groundPlane); 141 m_physicsScene.PE.AddObjectToWorld(m_physicsScene.World, m_groundPlane);
142 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_groundPlane); 142 m_physicsScene.PE.UpdateSingleAabb(m_physicsScene.World, m_groundPlane);
143 // Ground plane does not move 143 // Ground plane does not move
144 PhysicsScene.PE.ForceActivationState(m_groundPlane, ActivationState.DISABLE_SIMULATION); 144 m_physicsScene.PE.ForceActivationState(m_groundPlane, ActivationState.DISABLE_SIMULATION);
145 // Everything collides with the ground plane. 145 // Everything collides with the ground plane.
146 m_groundPlane.collisionType = CollisionType.Groundplane; 146 m_groundPlane.collisionType = CollisionType.Groundplane;
147 m_groundPlane.ApplyCollisionMask(PhysicsScene); 147 m_groundPlane.ApplyCollisionMask(m_physicsScene);
148 148
149 BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize); 149 BSTerrainPhys initialTerrain = new BSTerrainHeightmap(m_physicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize);
150 lock (m_terrains) 150 lock (m_terrains)
151 { 151 {
152 // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain. 152 // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain.
@@ -157,12 +157,12 @@ public sealed class BSTerrainManager : IDisposable
157 // Release all the terrain structures we might have allocated 157 // Release all the terrain structures we might have allocated
158 public void ReleaseGroundPlaneAndTerrain() 158 public void ReleaseGroundPlaneAndTerrain()
159 { 159 {
160 DetailLog("{0},BSTerrainManager.ReleaseGroundPlaneAndTerrain,region={1}", BSScene.DetailLogZero, PhysicsScene.RegionName); 160 DetailLog("{0},BSTerrainManager.ReleaseGroundPlaneAndTerrain,region={1}", BSScene.DetailLogZero, m_physicsScene.RegionName);
161 if (m_groundPlane.HasPhysicalBody) 161 if (m_groundPlane.HasPhysicalBody)
162 { 162 {
163 if (PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_groundPlane)) 163 if (m_physicsScene.PE.RemoveObjectFromWorld(m_physicsScene.World, m_groundPlane))
164 { 164 {
165 PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_groundPlane); 165 m_physicsScene.PE.DestroyObject(m_physicsScene.World, m_groundPlane);
166 } 166 }
167 m_groundPlane.Clear(); 167 m_groundPlane.Clear();
168 } 168 }
@@ -188,7 +188,7 @@ public sealed class BSTerrainManager : IDisposable
188 float[] localHeightMap = heightMap; 188 float[] localHeightMap = heightMap;
189 // If there are multiple requests for changes to the same terrain between ticks, 189 // If there are multiple requests for changes to the same terrain between ticks,
190 // only do that last one. 190 // only do that last one.
191 PhysicsScene.PostTaintObject("TerrainManager.SetTerrain-"+ m_worldOffset.ToString(), 0, delegate() 191 m_physicsScene.PostTaintObject("TerrainManager.SetTerrain-"+ m_worldOffset.ToString(), 0, delegate()
192 { 192 {
193 if (m_worldOffset != Vector3.Zero && MegaRegionParentPhysicsScene != null) 193 if (m_worldOffset != Vector3.Zero && MegaRegionParentPhysicsScene != null)
194 { 194 {
@@ -219,7 +219,7 @@ public sealed class BSTerrainManager : IDisposable
219 private void AddMegaRegionChildTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords) 219 private void AddMegaRegionChildTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords)
220 { 220 {
221 // Since we are called by another region's thread, the action must be rescheduled onto our processing thread. 221 // Since we are called by another region's thread, the action must be rescheduled onto our processing thread.
222 PhysicsScene.PostTaintObject("TerrainManager.AddMegaRegionChild" + minCoords.ToString(), id, delegate() 222 m_physicsScene.PostTaintObject("TerrainManager.AddMegaRegionChild" + minCoords.ToString(), id, delegate()
223 { 223 {
224 UpdateTerrain(id, heightMap, minCoords, maxCoords); 224 UpdateTerrain(id, heightMap, minCoords, maxCoords);
225 }); 225 });
@@ -318,26 +318,26 @@ public sealed class BSTerrainManager : IDisposable
318 // TODO: redo terrain implementation selection to allow other base types than heightMap. 318 // TODO: redo terrain implementation selection to allow other base types than heightMap.
319 private BSTerrainPhys BuildPhysicalTerrain(Vector3 terrainRegionBase, uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords) 319 private BSTerrainPhys BuildPhysicalTerrain(Vector3 terrainRegionBase, uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords)
320 { 320 {
321 PhysicsScene.Logger.DebugFormat("{0} Terrain for {1}/{2} created with {3}", 321 m_physicsScene.Logger.DebugFormat("{0} Terrain for {1}/{2} created with {3}",
322 LogHeader, PhysicsScene.RegionName, terrainRegionBase, 322 LogHeader, m_physicsScene.RegionName, terrainRegionBase,
323 (BSTerrainPhys.TerrainImplementation)BSParam.TerrainImplementation); 323 (BSTerrainPhys.TerrainImplementation)BSParam.TerrainImplementation);
324 BSTerrainPhys newTerrainPhys = null; 324 BSTerrainPhys newTerrainPhys = null;
325 switch ((int)BSParam.TerrainImplementation) 325 switch ((int)BSParam.TerrainImplementation)
326 { 326 {
327 case (int)BSTerrainPhys.TerrainImplementation.Heightmap: 327 case (int)BSTerrainPhys.TerrainImplementation.Heightmap:
328 newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id, 328 newTerrainPhys = new BSTerrainHeightmap(m_physicsScene, terrainRegionBase, id,
329 heightMap, minCoords, maxCoords); 329 heightMap, minCoords, maxCoords);
330 break; 330 break;
331 case (int)BSTerrainPhys.TerrainImplementation.Mesh: 331 case (int)BSTerrainPhys.TerrainImplementation.Mesh:
332 newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id, 332 newTerrainPhys = new BSTerrainMesh(m_physicsScene, terrainRegionBase, id,
333 heightMap, minCoords, maxCoords); 333 heightMap, minCoords, maxCoords);
334 break; 334 break;
335 default: 335 default:
336 PhysicsScene.Logger.ErrorFormat("{0} Bad terrain implementation specified. Type={1}/{2},Region={3}/{4}", 336 m_physicsScene.Logger.ErrorFormat("{0} Bad terrain implementation specified. Type={1}/{2},Region={3}/{4}",
337 LogHeader, 337 LogHeader,
338 (int)BSParam.TerrainImplementation, 338 (int)BSParam.TerrainImplementation,
339 BSParam.TerrainImplementation, 339 BSParam.TerrainImplementation,
340 PhysicsScene.RegionName, terrainRegionBase); 340 m_physicsScene.RegionName, terrainRegionBase);
341 break; 341 break;
342 } 342 }
343 return newTerrainPhys; 343 return newTerrainPhys;
@@ -429,8 +429,8 @@ public sealed class BSTerrainManager : IDisposable
429 } 429 }
430 else 430 else
431 { 431 {
432 PhysicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: region={1}, x={2}, y={3}", 432 m_physicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: region={1}, x={2}, y={3}",
433 LogHeader, PhysicsScene.RegionName, tX, tY); 433 LogHeader, m_physicsScene.RegionName, tX, tY);
434 DetailLog("{0},BSTerrainManager.GetTerrainHeightAtXYZ,terrainNotFound,pos={1},base={2}", 434 DetailLog("{0},BSTerrainManager.GetTerrainHeightAtXYZ,terrainNotFound,pos={1},base={2}",
435 BSScene.DetailLogZero, pos, terrainBaseXYZ); 435 BSScene.DetailLogZero, pos, terrainBaseXYZ);
436 } 436 }
@@ -451,8 +451,8 @@ public sealed class BSTerrainManager : IDisposable
451 } 451 }
452 else 452 else
453 { 453 {
454 PhysicsScene.Logger.ErrorFormat("{0} GetWaterHeightAtXY: terrain not found: pos={1}, terrainBase={2}, height={3}", 454 m_physicsScene.Logger.ErrorFormat("{0} GetWaterHeightAtXY: terrain not found: pos={1}, terrainBase={2}, height={3}",
455 LogHeader, PhysicsScene.RegionName, pos, terrainBaseXYZ, ret); 455 LogHeader, m_physicsScene.RegionName, pos, terrainBaseXYZ, ret);
456 } 456 }
457 return ret; 457 return ret;
458 } 458 }
@@ -564,7 +564,7 @@ public sealed class BSTerrainManager : IDisposable
564 564
565 private void DetailLog(string msg, params Object[] args) 565 private void DetailLog(string msg, params Object[] args)
566 { 566 {
567 PhysicsScene.PhysicsLogging.Write(msg, args); 567 m_physicsScene.PhysicsLogging.Write(msg, args);
568 } 568 }
569} 569}
570} 570}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
index 2ce1513..ee2a1f2 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
@@ -80,7 +80,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
80 if (BSParam.TerrainMeshMagnification == 1) 80 if (BSParam.TerrainMeshMagnification == 1)
81 { 81 {
82 // If a magnification of one, use the old routine that is tried and true. 82 // If a magnification of one, use the old routine that is tried and true.
83 meshCreationSuccess = BSTerrainMesh.ConvertHeightmapToMesh(PhysicsScene, 83 meshCreationSuccess = BSTerrainMesh.ConvertHeightmapToMesh(m_physicsScene,
84 initialMap, m_sizeX, m_sizeY, // input size 84 initialMap, m_sizeX, m_sizeY, // input size
85 Vector3.Zero, // base for mesh 85 Vector3.Zero, // base for mesh
86 out indicesCount, out indices, out verticesCount, out vertices); 86 out indicesCount, out indices, out verticesCount, out vertices);
@@ -88,7 +88,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
88 else 88 else
89 { 89 {
90 // Other magnifications use the newer routine 90 // Other magnifications use the newer routine
91 meshCreationSuccess = BSTerrainMesh.ConvertHeightmapToMesh2(PhysicsScene, 91 meshCreationSuccess = BSTerrainMesh.ConvertHeightmapToMesh2(m_physicsScene,
92 initialMap, m_sizeX, m_sizeY, // input size 92 initialMap, m_sizeX, m_sizeY, // input size
93 BSParam.TerrainMeshMagnification, 93 BSParam.TerrainMeshMagnification,
94 physicsScene.TerrainManager.DefaultRegionSize, 94 physicsScene.TerrainManager.DefaultRegionSize,
@@ -98,21 +98,21 @@ public sealed class BSTerrainMesh : BSTerrainPhys
98 if (!meshCreationSuccess) 98 if (!meshCreationSuccess)
99 { 99 {
100 // DISASTER!! 100 // DISASTER!!
101 PhysicsScene.DetailLog("{0},BSTerrainMesh.create,failedConversionOfHeightmap,id={1}", BSScene.DetailLogZero, ID); 101 m_physicsScene.DetailLog("{0},BSTerrainMesh.create,failedConversionOfHeightmap,id={1}", BSScene.DetailLogZero, ID);
102 PhysicsScene.Logger.ErrorFormat("{0} Failed conversion of heightmap to mesh! base={1}", LogHeader, TerrainBase); 102 m_physicsScene.Logger.ErrorFormat("{0} Failed conversion of heightmap to mesh! base={1}", LogHeader, TerrainBase);
103 // Something is very messed up and a crash is in our future. 103 // Something is very messed up and a crash is in our future.
104 return; 104 return;
105 } 105 }
106 106
107 PhysicsScene.DetailLog("{0},BSTerrainMesh.create,meshed,id={1},indices={2},indSz={3},vertices={4},vertSz={5}", 107 m_physicsScene.DetailLog("{0},BSTerrainMesh.create,meshed,id={1},indices={2},indSz={3},vertices={4},vertSz={5}",
108 BSScene.DetailLogZero, ID, indicesCount, indices.Length, verticesCount, vertices.Length); 108 BSScene.DetailLogZero, ID, indicesCount, indices.Length, verticesCount, vertices.Length);
109 109
110 m_terrainShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, indicesCount, indices, verticesCount, vertices); 110 m_terrainShape = m_physicsScene.PE.CreateMeshShape(m_physicsScene.World, indicesCount, indices, verticesCount, vertices);
111 if (!m_terrainShape.HasPhysicalShape) 111 if (!m_terrainShape.HasPhysicalShape)
112 { 112 {
113 // DISASTER!! 113 // DISASTER!!
114 PhysicsScene.DetailLog("{0},BSTerrainMesh.create,failedCreationOfShape,id={1}", BSScene.DetailLogZero, ID); 114 m_physicsScene.DetailLog("{0},BSTerrainMesh.create,failedCreationOfShape,id={1}", BSScene.DetailLogZero, ID);
115 PhysicsScene.Logger.ErrorFormat("{0} Failed creation of terrain mesh! base={1}", LogHeader, TerrainBase); 115 m_physicsScene.Logger.ErrorFormat("{0} Failed creation of terrain mesh! base={1}", LogHeader, TerrainBase);
116 // Something is very messed up and a crash is in our future. 116 // Something is very messed up and a crash is in our future.
117 return; 117 return;
118 } 118 }
@@ -120,52 +120,52 @@ public sealed class BSTerrainMesh : BSTerrainPhys
120 Vector3 pos = regionBase; 120 Vector3 pos = regionBase;
121 Quaternion rot = Quaternion.Identity; 121 Quaternion rot = Quaternion.Identity;
122 122
123 m_terrainBody = PhysicsScene.PE.CreateBodyWithDefaultMotionState(m_terrainShape, ID, pos, rot); 123 m_terrainBody = m_physicsScene.PE.CreateBodyWithDefaultMotionState(m_terrainShape, ID, pos, rot);
124 if (!m_terrainBody.HasPhysicalBody) 124 if (!m_terrainBody.HasPhysicalBody)
125 { 125 {
126 // DISASTER!! 126 // DISASTER!!
127 PhysicsScene.Logger.ErrorFormat("{0} Failed creation of terrain body! base={1}", LogHeader, TerrainBase); 127 m_physicsScene.Logger.ErrorFormat("{0} Failed creation of terrain body! base={1}", LogHeader, TerrainBase);
128 // Something is very messed up and a crash is in our future. 128 // Something is very messed up and a crash is in our future.
129 return; 129 return;
130 } 130 }
131 physicsScene.PE.SetShapeCollisionMargin(m_terrainShape, BSParam.TerrainCollisionMargin); 131 physicsScene.PE.SetShapeCollisionMargin(m_terrainShape, BSParam.TerrainCollisionMargin);
132 132
133 // Set current terrain attributes 133 // Set current terrain attributes
134 PhysicsScene.PE.SetFriction(m_terrainBody, BSParam.TerrainFriction); 134 m_physicsScene.PE.SetFriction(m_terrainBody, BSParam.TerrainFriction);
135 PhysicsScene.PE.SetHitFraction(m_terrainBody, BSParam.TerrainHitFraction); 135 m_physicsScene.PE.SetHitFraction(m_terrainBody, BSParam.TerrainHitFraction);
136 PhysicsScene.PE.SetRestitution(m_terrainBody, BSParam.TerrainRestitution); 136 m_physicsScene.PE.SetRestitution(m_terrainBody, BSParam.TerrainRestitution);
137 PhysicsScene.PE.SetContactProcessingThreshold(m_terrainBody, BSParam.TerrainContactProcessingThreshold); 137 m_physicsScene.PE.SetContactProcessingThreshold(m_terrainBody, BSParam.TerrainContactProcessingThreshold);
138 PhysicsScene.PE.SetCollisionFlags(m_terrainBody, CollisionFlags.CF_STATIC_OBJECT); 138 m_physicsScene.PE.SetCollisionFlags(m_terrainBody, CollisionFlags.CF_STATIC_OBJECT);
139 139
140 // Static objects are not very massive. 140 // Static objects are not very massive.
141 PhysicsScene.PE.SetMassProps(m_terrainBody, 0f, Vector3.Zero); 141 m_physicsScene.PE.SetMassProps(m_terrainBody, 0f, Vector3.Zero);
142 142
143 // Put the new terrain to the world of physical objects 143 // Put the new terrain to the world of physical objects
144 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_terrainBody); 144 m_physicsScene.PE.AddObjectToWorld(m_physicsScene.World, m_terrainBody);
145 145
146 // Redo its bounding box now that it is in the world 146 // Redo its bounding box now that it is in the world
147 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_terrainBody); 147 m_physicsScene.PE.UpdateSingleAabb(m_physicsScene.World, m_terrainBody);
148 148
149 m_terrainBody.collisionType = CollisionType.Terrain; 149 m_terrainBody.collisionType = CollisionType.Terrain;
150 m_terrainBody.ApplyCollisionMask(PhysicsScene); 150 m_terrainBody.ApplyCollisionMask(m_physicsScene);
151 151
152 if (BSParam.UseSingleSidedMeshes) 152 if (BSParam.UseSingleSidedMeshes)
153 { 153 {
154 PhysicsScene.DetailLog("{0},BSTerrainMesh.settingCustomMaterial,id={1}", BSScene.DetailLogZero, id); 154 m_physicsScene.DetailLog("{0},BSTerrainMesh.settingCustomMaterial,id={1}", BSScene.DetailLogZero, id);
155 PhysicsScene.PE.AddToCollisionFlags(m_terrainBody, CollisionFlags.CF_CUSTOM_MATERIAL_CALLBACK); 155 m_physicsScene.PE.AddToCollisionFlags(m_terrainBody, CollisionFlags.CF_CUSTOM_MATERIAL_CALLBACK);
156 } 156 }
157 157
158 // Make it so the terrain will not move or be considered for movement. 158 // Make it so the terrain will not move or be considered for movement.
159 PhysicsScene.PE.ForceActivationState(m_terrainBody, ActivationState.DISABLE_SIMULATION); 159 m_physicsScene.PE.ForceActivationState(m_terrainBody, ActivationState.DISABLE_SIMULATION);
160 } 160 }
161 161
162 public override void Dispose() 162 public override void Dispose()
163 { 163 {
164 if (m_terrainBody.HasPhysicalBody) 164 if (m_terrainBody.HasPhysicalBody)
165 { 165 {
166 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_terrainBody); 166 m_physicsScene.PE.RemoveObjectFromWorld(m_physicsScene.World, m_terrainBody);
167 // Frees both the body and the shape. 167 // Frees both the body and the shape.
168 PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_terrainBody); 168 m_physicsScene.PE.DestroyObject(m_physicsScene.World, m_terrainBody);
169 m_terrainBody.Clear(); 169 m_terrainBody.Clear();
170 m_terrainShape.Clear(); 170 m_terrainShape.Clear();
171 } 171 }
@@ -185,7 +185,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
185 catch 185 catch
186 { 186 {
187 // Sometimes they give us wonky values of X and Y. Give a warning and return something. 187 // Sometimes they give us wonky values of X and Y. Give a warning and return something.
188 PhysicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, pos={2}", 188 m_physicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, pos={2}",
189 LogHeader, TerrainBase, pos); 189 LogHeader, TerrainBase, pos);
190 ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET; 190 ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET;
191 } 191 }
@@ -195,7 +195,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
195 // The passed position is relative to the base of the region. 195 // The passed position is relative to the base of the region.
196 public override float GetWaterLevelAtXYZ(Vector3 pos) 196 public override float GetWaterLevelAtXYZ(Vector3 pos)
197 { 197 {
198 return PhysicsScene.SimpleWaterLevel; 198 return m_physicsScene.SimpleWaterLevel;
199 } 199 }
200 200
201 // Convert the passed heightmap to mesh information suitable for CreateMeshShape2(). 201 // Convert the passed heightmap to mesh information suitable for CreateMeshShape2().