diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4bc266b..5d12338 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -134,8 +134,8 @@ public class BSPrim : BSPhysObject | |||
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 | PhysicsScene.Shapes.DereferenceBody(PhysBody, null); |
136 | PhysBody.Clear(); | 136 | PhysBody.Clear(); |
137 | PhysicsScene.Shapes.DereferenceShape(PhysShape, null); | 137 | PhysShape.Dereference(PhysicsScene); |
138 | PhysShape.Clear(); | 138 | PhysShape = new BSShapeNull(); |
139 | }); | 139 | }); |
140 | } | 140 | } |
141 | 141 | ||
@@ -161,25 +161,13 @@ public class BSPrim : BSPhysObject | |||
161 | ForceBodyShapeRebuild(false); | 161 | ForceBodyShapeRebuild(false); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | // 'unknown' says to choose the best type | ||
165 | public override BSPhysicsShapeType PreferredPhysicalShape | ||
166 | { get { return BSPhysicsShapeType.SHAPE_UNKNOWN; } } | ||
167 | |||
168 | public override bool ForceBodyShapeRebuild(bool inTaintTime) | 164 | public override bool ForceBodyShapeRebuild(bool inTaintTime) |
169 | { | 165 | { |
170 | if (inTaintTime) | 166 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ForceBodyShapeRebuild", delegate() |
171 | { | 167 | { |
172 | _mass = CalculateMass(); // changing the shape changes the mass | 168 | _mass = CalculateMass(); // changing the shape changes the mass |
173 | CreateGeomAndObject(true); | 169 | CreateGeomAndObject(true); |
174 | } | 170 | }); |
175 | else | ||
176 | { | ||
177 | PhysicsScene.TaintedObject("BSPrim.ForceBodyShapeRebuild", delegate() | ||
178 | { | ||
179 | _mass = CalculateMass(); // changing the shape changes the mass | ||
180 | CreateGeomAndObject(true); | ||
181 | }); | ||
182 | } | ||
183 | return true; | 171 | return true; |
184 | } | 172 | } |
185 | public override bool Grabbed { | 173 | public override bool Grabbed { |
@@ -462,7 +450,7 @@ public class BSPrim : BSPhysObject | |||
462 | Gravity = ComputeGravity(Buoyancy); | 450 | Gravity = ComputeGravity(Buoyancy); |
463 | PhysicsScene.PE.SetGravity(PhysBody, Gravity); | 451 | PhysicsScene.PE.SetGravity(PhysBody, Gravity); |
464 | 452 | ||
465 | Inertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape, physMass); | 453 | Inertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass); |
466 | PhysicsScene.PE.SetMassProps(PhysBody, physMass, Inertia); | 454 | PhysicsScene.PE.SetMassProps(PhysBody, physMass, Inertia); |
467 | PhysicsScene.PE.UpdateInertiaTensor(PhysBody); | 455 | PhysicsScene.PE.UpdateInertiaTensor(PhysBody); |
468 | 456 | ||
@@ -805,7 +793,8 @@ public class BSPrim : BSPhysObject | |||
805 | PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody); | 793 | PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody); |
806 | 794 | ||
807 | 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}", |
808 | LocalID, IsStatic, IsSolid, Mass, SubscribedEvents(), CurrentCollisionFlags, PhysBody.collisionType, PhysBody, PhysShape); | 796 | LocalID, IsStatic, IsSolid, Mass, SubscribedEvents(), |
797 | CurrentCollisionFlags, PhysBody.collisionType, PhysBody, PhysShape); | ||
809 | } | 798 | } |
810 | 799 | ||
811 | // "Making dynamic" means changing to and from static. | 800 | // "Making dynamic" means changing to and from static. |
@@ -1463,12 +1452,13 @@ public class BSPrim : BSPhysObject | |||
1463 | // Create the correct physical representation for this type of object. | 1452 | // Create the correct physical representation for this type of object. |
1464 | // Updates base.PhysBody and base.PhysShape with the new information. | 1453 | // Updates base.PhysBody and base.PhysShape with the new information. |
1465 | // Ignore 'forceRebuild'. 'GetBodyAndShape' makes the right choices and changes of necessary. | 1454 | // Ignore 'forceRebuild'. 'GetBodyAndShape' makes the right choices and changes of necessary. |
1466 | PhysicsScene.Shapes.GetBodyAndShape(false /*forceRebuild */, PhysicsScene.World, this, null, delegate(BulletBody dBody) | 1455 | PhysicsScene.Shapes.GetBodyAndShape(false /*forceRebuild */, PhysicsScene.World, this, delegate(BulletBody pBody, BulletShape pShape) |
1467 | { | 1456 | { |
1468 | // Called if the current prim body is about to be destroyed. | 1457 | // Called if the current prim body is about to be destroyed. |
1469 | // Remove all the physical dependencies on the old body. | 1458 | // Remove all the physical dependencies on the old body. |
1470 | // (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...) | 1459 | // (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...) |
1471 | RemoveBodyDependencies(); | 1460 | // Note: this virtual function is overloaded by BSPrimLinkable to remove linkset constraints. |
1461 | RemoveDependencies(); | ||
1472 | }); | 1462 | }); |
1473 | 1463 | ||
1474 | // Make sure the properties are set on the new object | 1464 | // Make sure the properties are set on the new object |
@@ -1477,9 +1467,9 @@ public class BSPrim : BSPhysObject | |||
1477 | } | 1467 | } |
1478 | 1468 | ||
1479 | // Called at taint-time | 1469 | // Called at taint-time |
1480 | protected virtual void RemoveBodyDependencies() | 1470 | protected virtual void RemoveDependencies() |
1481 | { | 1471 | { |
1482 | PhysicalActors.RemoveBodyDependencies(); | 1472 | PhysicalActors.RemoveDependencies(); |
1483 | } | 1473 | } |
1484 | 1474 | ||
1485 | // The physics engine says that properties have updated. Update same and inform | 1475 | // The physics engine says that properties have updated. Update same and inform |