diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 52 |
1 files changed, 26 insertions, 26 deletions
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 | } |