diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index b758408..90da7a6 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -80,12 +80,13 @@ public abstract class BSPhysObject : PhysicsActor | |||
80 | Name = name; // PhysicsActor also has the name of the object. Someday consolidate. | 80 | Name = name; // PhysicsActor also has the name of the object. Someday consolidate. |
81 | TypeName = typeName; | 81 | TypeName = typeName; |
82 | 82 | ||
83 | // The collection of things that push me around | 83 | // Oddity if object is destroyed and recreated very quickly it could still have the old body. |
84 | PhysicalActors = new BSActorCollection(PhysScene); | 84 | if (!PhysBody.HasPhysicalBody) |
85 | PhysBody = new BulletBody(localID); | ||
85 | 86 | ||
86 | // We don't have any physical representation yet. | 87 | // Clean out anything that might be in the physical actor list. |
87 | PhysBody = new BulletBody(localID); | 88 | // Again, a workaround for destroying and recreating an object very quickly. |
88 | PhysShape = new BSShapeNull(); | 89 | PhysicalActors.Dispose(); |
89 | 90 | ||
90 | UserSetCenterOfMassDisplacement = null; | 91 | UserSetCenterOfMassDisplacement = null; |
91 | 92 | ||
@@ -100,9 +101,6 @@ public abstract class BSPhysObject : PhysicsActor | |||
100 | // Default material type. Also sets Friction, Restitution and Density. | 101 | // Default material type. Also sets Friction, Restitution and Density. |
101 | SetMaterial((int)MaterialAttributes.Material.Wood); | 102 | SetMaterial((int)MaterialAttributes.Material.Wood); |
102 | 103 | ||
103 | CollisionCollection = new CollisionEventUpdate(); | ||
104 | CollisionsLastReported = CollisionCollection; | ||
105 | CollisionsLastTick = new CollisionEventUpdate(); | ||
106 | CollisionsLastTickStep = -1; | 104 | CollisionsLastTickStep = -1; |
107 | 105 | ||
108 | SubscribedEventsMs = 0; | 106 | SubscribedEventsMs = 0; |
@@ -158,9 +156,9 @@ public abstract class BSPhysObject : PhysicsActor | |||
158 | public OMV.Vector3 Inertia { get; set; } | 156 | public OMV.Vector3 Inertia { get; set; } |
159 | 157 | ||
160 | // Reference to the physical body (btCollisionObject) of this object | 158 | // Reference to the physical body (btCollisionObject) of this object |
161 | public BulletBody PhysBody; | 159 | public BulletBody PhysBody = new BulletBody(0); |
162 | // Reference to the physical shape (btCollisionShape) of this object | 160 | // Reference to the physical shape (btCollisionShape) of this object |
163 | public BSShape PhysShape; | 161 | public BSShape PhysShape = new BSShapeNull(); |
164 | 162 | ||
165 | // The physical representation of the prim might require an asset fetch. | 163 | // The physical representation of the prim might require an asset fetch. |
166 | // The asset state is first 'Unknown' then 'Waiting' then either 'Failed' or 'Fetched'. | 164 | // The asset state is first 'Unknown' then 'Waiting' then either 'Failed' or 'Fetched'. |
@@ -445,12 +443,12 @@ public abstract class BSPhysObject : PhysicsActor | |||
445 | } | 443 | } |
446 | 444 | ||
447 | // The collisions that have been collected for the next collision reporting (throttled by subscription) | 445 | // The collisions that have been collected for the next collision reporting (throttled by subscription) |
448 | protected CollisionEventUpdate CollisionCollection; | 446 | protected CollisionEventUpdate CollisionCollection = new CollisionEventUpdate(); |
449 | // This is the collision collection last reported to the Simulator. | 447 | // This is the collision collection last reported to the Simulator. |
450 | public CollisionEventUpdate CollisionsLastReported; | 448 | public CollisionEventUpdate CollisionsLastReported = new CollisionEventUpdate(); |
451 | // Remember the collisions recorded in the last tick for fancy collision checking | 449 | // Remember the collisions recorded in the last tick for fancy collision checking |
452 | // (like a BSCharacter walking up stairs). | 450 | // (like a BSCharacter walking up stairs). |
453 | public CollisionEventUpdate CollisionsLastTick; | 451 | public CollisionEventUpdate CollisionsLastTick = new CollisionEventUpdate(); |
454 | private long CollisionsLastTickStep = -1; | 452 | private long CollisionsLastTickStep = -1; |
455 | 453 | ||
456 | // The simulation step is telling this object about a collision. | 454 | // The simulation step is telling this object about a collision. |
@@ -495,7 +493,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
495 | { | 493 | { |
496 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); | 494 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); |
497 | } | 495 | } |
498 | DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}", | 496 | DetailLog("{0},{1}.Collision.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}", |
499 | LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving); | 497 | LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving); |
500 | 498 | ||
501 | ret = true; | 499 | ret = true; |
@@ -596,7 +594,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
596 | 594 | ||
597 | #region Per Simulation Step actions | 595 | #region Per Simulation Step actions |
598 | 596 | ||
599 | public BSActorCollection PhysicalActors; | 597 | public BSActorCollection PhysicalActors = new BSActorCollection(); |
600 | 598 | ||
601 | // When an update to the physical properties happens, this event is fired to let | 599 | // When an update to the physical properties happens, this event is fired to let |
602 | // different actors to modify the update before it is passed around | 600 | // different actors to modify the update before it is passed around |