aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorMelanie2013-02-04 19:21:39 +0000
committerMelanie2013-02-04 19:21:39 +0000
commit7482ad1c22e44e03c1a36f1d67d862084c20dae6 (patch)
tree9450dd7cbe79e1d34b6d0519d994b1fd16a253ed /OpenSim/Region/Physics
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-7482ad1c22e44e03c1a36f1d67d862084c20dae6.zip
opensim-SC-7482ad1c22e44e03c1a36f1d67d862084c20dae6.tar.gz
opensim-SC-7482ad1c22e44e03c1a36f1d67d862084c20dae6.tar.bz2
opensim-SC-7482ad1c22e44e03c1a36f1d67d862084c20dae6.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs8
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs30
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs81
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs12
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs20
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs125
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt35
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs4
8 files changed, 166 insertions, 149 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 3884a5d..192bcb5 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -126,9 +126,9 @@ public sealed class BSCharacter : BSPhysObject
126 DetailLog("{0},BSCharacter.Destroy", LocalID); 126 DetailLog("{0},BSCharacter.Destroy", LocalID);
127 PhysicsScene.TaintedObject("BSCharacter.destroy", delegate() 127 PhysicsScene.TaintedObject("BSCharacter.destroy", delegate()
128 { 128 {
129 PhysicsScene.Shapes.DereferenceBody(PhysBody, true /* inTaintTime */, null /* bodyCallback */); 129 PhysicsScene.Shapes.DereferenceBody(PhysBody, null /* bodyCallback */);
130 PhysBody.Clear(); 130 PhysBody.Clear();
131 PhysicsScene.Shapes.DereferenceShape(PhysShape, true /* inTaintTime */, null /* bodyCallback */); 131 PhysicsScene.Shapes.DereferenceShape(PhysShape, null /* bodyCallback */);
132 PhysShape.Clear(); 132 PhysShape.Clear();
133 }); 133 });
134 } 134 }
@@ -557,11 +557,12 @@ public sealed class BSCharacter : BSPhysObject
557 { 557 {
558 get 558 get
559 { 559 {
560 return _velocityMotor.TargetValue; 560 return m_targetVelocity;
561 } 561 }
562 set 562 set
563 { 563 {
564 DetailLog("{0},BSCharacter.setTargetVelocity,call,vel={1}", LocalID, value); 564 DetailLog("{0},BSCharacter.setTargetVelocity,call,vel={1}", LocalID, value);
565 m_targetVelocity = value;
565 OMV.Vector3 targetVel = value; 566 OMV.Vector3 targetVel = value;
566 if (_setAlwaysRun) 567 if (_setAlwaysRun)
567 targetVel *= BSParam.AvatarAlwaysRunFactor; 568 targetVel *= BSParam.AvatarAlwaysRunFactor;
@@ -591,7 +592,6 @@ public sealed class BSCharacter : BSPhysObject
591 _velocityMotor.Reset(); 592 _velocityMotor.Reset();
592 _velocityMotor.SetCurrent(_velocity); 593 _velocityMotor.SetCurrent(_velocity);
593 _velocityMotor.SetTarget(_velocity); 594 _velocityMotor.SetTarget(_velocity);
594 // Even though the motor is initialized, it's not used and the velocity goes straight into the avatar.
595 _velocityMotor.Enabled = false; 595 _velocityMotor.Enabled = false;
596 596
597 DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, _velocity); 597 DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, _velocity);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 05ab180..8ecf2ff 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -581,9 +581,18 @@ namespace OpenSim.Region.Physics.BulletSPlugin
581 } 581 }
582 #endregion // Vehicle parameter setting 582 #endregion // Vehicle parameter setting
583 583
584 public void Refresh()
585 {
586 // If asking for a refresh, reset the physical parameters before the next simulation step.
587 PhysicsScene.PostTaintObject("BSDynamics.Refresh", Prim.LocalID, delegate()
588 {
589 SetPhysicalParameters();
590 });
591 }
592
584 // Some of the properties of this prim may have changed. 593 // Some of the properties of this prim may have changed.
585 // Do any updating needed for a vehicle 594 // Do any updating needed for a vehicle
586 public void Refresh() 595 private void SetPhysicalParameters()
587 { 596 {
588 if (IsActive) 597 if (IsActive)
589 { 598 {
@@ -614,7 +623,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
614 // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same. 623 // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same.
615 PhysicsScene.PE.SetGravity(Prim.PhysBody, Vector3.Zero); 624 PhysicsScene.PE.SetGravity(Prim.PhysBody, Vector3.Zero);
616 625
617 VDetailLog("{0},BSDynamics.Refresh,mass={1},inert={2},grav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}", 626 VDetailLog("{0},BSDynamics.SetPhysicalParameters,mass={1},inert={2},vehGrav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}",
618 Prim.LocalID, m_vehicleMass, Prim.Inertia, m_VehicleGravity, 627 Prim.LocalID, m_vehicleMass, Prim.Inertia, m_VehicleGravity,
619 BSParam.VehicleAngularDamping, BSParam.VehicleFriction, BSParam.VehicleRestitution, 628 BSParam.VehicleAngularDamping, BSParam.VehicleFriction, BSParam.VehicleRestitution,
620 BSParam.VehicleLinearFactor, BSParam.VehicleAngularFactor 629 BSParam.VehicleLinearFactor, BSParam.VehicleAngularFactor
@@ -622,26 +631,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin
622 } 631 }
623 else 632 else
624 { 633 {
625 PhysicsScene.PE.RemoveFromCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); 634 if (Prim.PhysBody.HasPhysicalBody)
635 PhysicsScene.PE.RemoveFromCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS);
626 } 636 }
627 } 637 }
628 638
629 public bool RemoveBodyDependencies(BSPhysObject prim) 639 public bool RemoveBodyDependencies(BSPhysObject prim)
630 { 640 {
631 // If active, we need to add our properties back when the body is rebuilt.
632 return IsActive;
633 }
634
635 public void RestoreBodyDependencies(BSPhysObject prim)
636 {
637 if (Prim.LocalID != prim.LocalID)
638 {
639 // The call should be on us by our prim. Error if not.
640 PhysicsScene.Logger.ErrorFormat("{0} RestoreBodyDependencies: called by not my prim. passedLocalID={1}, vehiclePrimLocalID={2}",
641 LogHeader, prim.LocalID, Prim.LocalID);
642 return;
643 }
644 Refresh(); 641 Refresh();
642 return IsActive;
645 } 643 }
646 644
647 #region Known vehicle value functions 645 #region Known vehicle value functions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 54dc458..0c4db40 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -219,43 +219,65 @@ public sealed class BSLinksetCompound : BSLinkset
219 { 219 {
220 // Gather the child info. It might not be there if the linkset is in transition. 220 // Gather the child info. It might not be there if the linkset is in transition.
221 BSLinksetCompoundInfo lsi = updated.LinksetInfo as BSLinksetCompoundInfo; 221 BSLinksetCompoundInfo lsi = updated.LinksetInfo as BSLinksetCompoundInfo;
222 if (LinksetRoot.PhysShape.HasPhysicalShape && lsi != null) 222 if (lsi != null)
223 { 223 {
224 if (PhysicsScene.PE.IsCompound(LinksetRoot.PhysShape)) 224 // Since the child moved or rotationed, it needs a new relative position within the linkset
225 BSLinksetCompoundInfo newLsi = new BSLinksetCompoundInfo(lsi.Index, LinksetRoot, updated, LinksetRoot.PositionDisplacement);
226 updated.LinksetInfo = newLsi;
227
228 // Find the physical instance of the child
229 if (LinksetRoot.PhysShape.HasPhysicalShape && PhysicsScene.PE.IsCompound(LinksetRoot.PhysShape))
225 { 230 {
226 BulletShape linksetChildShape = PhysicsScene.PE.GetChildShapeFromCompoundShapeIndex(LinksetRoot.PhysShape, lsi.Index); 231 // It is possible that the linkset is still under construction and the child is not yet
227 if (linksetChildShape.HasPhysicalShape) 232 // inserted into the compound shape. A rebuild of the linkset in a pre-step action will
233 // build the whole thing with the new position or rotation.
234 // The index must be checked because Bullet references the child array but does no validity
235 // checking of the child index passed.
236 int numLinksetChildren = PhysicsScene.PE.GetNumberOfCompoundChildren(LinksetRoot.PhysShape);
237 if (lsi.Index < numLinksetChildren)
228 { 238 {
229 // Compute the offset from the center-of-gravity 239 BulletShape linksetChildShape = PhysicsScene.PE.GetChildShapeFromCompoundShapeIndex(LinksetRoot.PhysShape, lsi.Index);
230 BSLinksetCompoundInfo newLsi = new BSLinksetCompoundInfo(lsi.Index, LinksetRoot, updated, LinksetRoot.PositionDisplacement); 240 if (linksetChildShape.HasPhysicalShape)
231 PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, lsi.Index, 241 {
232 newLsi.OffsetFromCenterOfMass, 242 // Found the child shape within the compound shape
233 newLsi.OffsetRot, 243 PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, lsi.Index,
234 true /* shouldRecalculateLocalAabb */); 244 newLsi.OffsetFromCenterOfMass,
235 DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1},newLsi={2}", 245 newLsi.OffsetRot,
236 updated.LocalID, whichUpdated, newLsi); 246 true /* shouldRecalculateLocalAabb */);
237 updated.LinksetInfo = newLsi; 247 updatedChild = true;
238 updatedChild = true; 248 DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1},newLsi={2}",
249 updated.LocalID, whichUpdated, newLsi);
250 }
251 else // DEBUG DEBUG
252 { // DEBUG DEBUG
253 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noChildShape,shape={1}",
254 updated.LocalID, linksetChildShape);
255 } // DEBUG DEBUG
239 } 256 }
240 else // DEBUG DEBUG 257 else // DEBUG DEBUG
241 { // DEBUG DEBUG 258 { // DEBUG DEBUG
242 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noChildShape,shape={1}", 259 // the child is not yet in the compound shape. This is non-fatal.
243 updated.LocalID, linksetChildShape); 260 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,childNotInCompoundShape,numChildren={1},index={2}",
261 updated.LocalID, numLinksetChildren, lsi.Index);
244 } // DEBUG DEBUG 262 } // DEBUG DEBUG
245 } 263 }
246 else // DEBUG DEBUG 264 else // DEBUG DEBUG
247 { // DEBUG DEBUG 265 { // DEBUG DEBUG
248 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,notCompound", updated.LocalID); 266 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noBodyOrNotCompound", updated.LocalID);
249 } // DEBUG DEBUG 267 } // DEBUG DEBUG
250 } 268 }
251 else // DEBUG DEBUG 269 else // DEBUG DEBUG
252 { // DEBUG DEBUG 270 { // DEBUG DEBUG
253 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,rootPhysShape={1},lsi={2}", 271 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noLinkSetInfo,rootPhysShape={1}",
254 updated.LocalID, LinksetRoot.PhysShape, lsi == null ? "NULL" : lsi.ToString()); 272 updated.LocalID, LinksetRoot.PhysShape);
255 } // DEBUG DEBUG 273 } // DEBUG DEBUG
274
256 if (!updatedChild) 275 if (!updatedChild)
257 { 276 {
258 // If couldn't do the individual child, the linkset needs a rebuild to incorporate the new child info. 277 // If couldn't do the individual child, the linkset needs a rebuild to incorporate the new child info.
278 // Note: there are several ways through this code that will not update the child if
279 // the linkset is being rebuilt. In this case, scheduling a rebuild is a NOOP since
280 // there will already be a rebuild scheduled.
259 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}", 281 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}",
260 updated.LocalID, whichUpdated); 282 updated.LocalID, whichUpdated);
261 updated.LinksetInfo = null; // setting to 'null' causes relative position to be recomputed. 283 updated.LinksetInfo = null; // setting to 'null' causes relative position to be recomputed.
@@ -274,13 +296,14 @@ public sealed class BSLinksetCompound : BSLinkset
274 bool ret = false; 296 bool ret = false;
275 297
276 DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}", 298 DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}",
277 child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, IsRoot(child)); 299 child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody, IsRoot(child));
278 300
279 if (!IsRoot(child)) 301 if (!IsRoot(child))
280 { 302 {
281 // Because it is a convenient time, recompute child world position and rotation based on 303 // Because it is a convenient time, recompute child world position and rotation based on
282 // its position in the linkset. 304 // its position in the linkset.
283 RecomputeChildWorldPosition(child, true); 305 RecomputeChildWorldPosition(child, true /* inTaintTime */);
306 child.LinksetInfo = null;
284 } 307 }
285 308
286 // Cannot schedule a refresh/rebuild here because this routine is called when 309 // Cannot schedule a refresh/rebuild here because this routine is called when
@@ -295,6 +318,14 @@ public sealed class BSLinksetCompound : BSLinkset
295 // prim. The child prim's location must be recomputed based on the location of the root shape. 318 // prim. The child prim's location must be recomputed based on the location of the root shape.
296 private void RecomputeChildWorldPosition(BSPhysObject child, bool inTaintTime) 319 private void RecomputeChildWorldPosition(BSPhysObject child, bool inTaintTime)
297 { 320 {
321 // For the moment (20130201), disable this computation (converting the child physical addr back to
322 // a region address) until we have a good handle on center-of-mass offsets and what the physics
323 // engine moving a child actually means.
324 // The simulator keeps track of where children should be as the linkset moves. Setting
325 // the pos/rot here does not effect that knowledge as there is no good way for the
326 // physics engine to send the simulator an update for a child.
327
328 /*
298 BSLinksetCompoundInfo lci = child.LinksetInfo as BSLinksetCompoundInfo; 329 BSLinksetCompoundInfo lci = child.LinksetInfo as BSLinksetCompoundInfo;
299 if (lci != null) 330 if (lci != null)
300 { 331 {
@@ -323,6 +354,7 @@ public sealed class BSLinksetCompound : BSLinkset
323 // LogHeader, child.LocalID); 354 // LogHeader, child.LocalID);
324 DetailLog("{0},BSLinksetCompound.recomputeChildWorldPosition,noRelativePositonInfo", child.LocalID); 355 DetailLog("{0},BSLinksetCompound.recomputeChildWorldPosition,noRelativePositonInfo", child.LocalID);
325 } 356 }
357 */
326 } 358 }
327 359
328 // ================================================================ 360 // ================================================================
@@ -356,6 +388,7 @@ public sealed class BSLinksetCompound : BSLinkset
356 388
357 // Cause the child's body to be rebuilt and thus restored to normal operation 389 // Cause the child's body to be rebuilt and thus restored to normal operation
358 RecomputeChildWorldPosition(child, false); 390 RecomputeChildWorldPosition(child, false);
391 child.LinksetInfo = null;
359 child.ForceBodyShapeRebuild(false); 392 child.ForceBodyShapeRebuild(false);
360 393
361 if (!HasAnyChildren) 394 if (!HasAnyChildren)
@@ -377,16 +410,16 @@ public sealed class BSLinksetCompound : BSLinkset
377 // Constraint linksets are rebuilt every time. 410 // Constraint linksets are rebuilt every time.
378 // Note that this works for rebuilding just the root after a linkset is taken apart. 411 // Note that this works for rebuilding just the root after a linkset is taken apart.
379 // Called at taint time!! 412 // Called at taint time!!
380 private bool disableCOM = true; // disable until we get this debugged 413 private bool disableCOM = true; // DEBUG DEBUG: disable until we get this debugged
381 private void RecomputeLinksetCompound() 414 private void RecomputeLinksetCompound()
382 { 415 {
383 try 416 try
384 { 417 {
385 // Suppress rebuilding while rebuilding 418 // Suppress rebuilding while rebuilding. (We know rebuilding is on only one thread.)
386 Rebuilding = true; 419 Rebuilding = true;
387 420
388 // Cause the root shape to be rebuilt as a compound object with just the root in it 421 // Cause the root shape to be rebuilt as a compound object with just the root in it
389 LinksetRoot.ForceBodyShapeRebuild(true); 422 LinksetRoot.ForceBodyShapeRebuild(true /* inTaintTime */);
390 423
391 // The center of mass for the linkset is the geometric center of the group. 424 // The center of mass for the linkset is the geometric center of the group.
392 // Compute a displacement for each component so it is relative to the center-of-mass. 425 // Compute a displacement for each component so it is relative to the center-of-mass.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index a113530..823402b 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -190,18 +190,6 @@ public abstract class BSPhysObject : PhysicsActor
190 public abstract OMV.Quaternion RawOrientation { get; set; } 190 public abstract OMV.Quaternion RawOrientation { get; set; }
191 public abstract OMV.Quaternion ForceOrientation { get; set; } 191 public abstract OMV.Quaternion ForceOrientation { get; set; }
192 192
193 // The system is telling us the velocity it wants to move at.
194 // Velocity in world coordinates.
195 // protected OMV.Vector3 m_targetVelocity; // use the definition in PhysicsActor
196 public override OMV.Vector3 TargetVelocity
197 {
198 get { return m_targetVelocity; }
199 set
200 {
201 m_targetVelocity = value;
202 Velocity = value;
203 }
204 }
205 public virtual float TargetSpeed 193 public virtual float TargetSpeed
206 { 194 {
207 get 195 get
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index b5dd131..54bf063 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -146,9 +146,9 @@ public sealed class BSPrim : BSPhysObject
146 { 146 {
147 DetailLog("{0},BSPrim.Destroy,taint,", LocalID); 147 DetailLog("{0},BSPrim.Destroy,taint,", LocalID);
148 // If there are physical body and shape, release my use of same. 148 // If there are physical body and shape, release my use of same.
149 PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null); 149 PhysicsScene.Shapes.DereferenceBody(PhysBody, null);
150 PhysBody.Clear(); 150 PhysBody.Clear();
151 PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null); 151 PhysicsScene.Shapes.DereferenceShape(PhysShape, null);
152 PhysShape.Clear(); 152 PhysShape.Clear();
153 }); 153 });
154 } 154 }
@@ -181,11 +181,19 @@ public sealed class BSPrim : BSPhysObject
181 181
182 public override bool ForceBodyShapeRebuild(bool inTaintTime) 182 public override bool ForceBodyShapeRebuild(bool inTaintTime)
183 { 183 {
184 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ForceBodyShapeRebuild", delegate() 184 if (inTaintTime)
185 { 185 {
186 _mass = CalculateMass(); // changing the shape changes the mass 186 _mass = CalculateMass(); // changing the shape changes the mass
187 CreateGeomAndObject(true); 187 CreateGeomAndObject(true);
188 }); 188 }
189 else
190 {
191 PhysicsScene.TaintedObject("BSPrim.ForceBodyShapeRebuild", delegate()
192 {
193 _mass = CalculateMass(); // changing the shape changes the mass
194 CreateGeomAndObject(true);
195 });
196 }
189 return true; 197 return true;
190 } 198 }
191 public override bool Grabbed { 199 public override bool Grabbed {
@@ -1597,9 +1605,9 @@ public sealed class BSPrim : BSPhysObject
1597 public void CreateGeomAndObject(bool forceRebuild) 1605 public void CreateGeomAndObject(bool forceRebuild)
1598 { 1606 {
1599 // Create the correct physical representation for this type of object. 1607 // Create the correct physical representation for this type of object.
1600 // Updates PhysBody and PhysShape with the new information. 1608 // Updates base.PhysBody and base.PhysShape with the new information.
1601 // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. 1609 // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary.
1602 PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, null, delegate(BulletBody dBody) 1610 PhysicsScene.Shapes.GetBodyAndShape(false /*forceRebuild */, PhysicsScene.World, this, null, delegate(BulletBody dBody)
1603 { 1611 {
1604 // Called if the current prim body is about to be destroyed. 1612 // Called if the current prim body is about to be destroyed.
1605 // Remove all the physical dependencies on the old body. 1613 // Remove all the physical dependencies on the old body.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index 473ef10..37bccbc 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -116,8 +116,7 @@ public sealed class BSShapeCollection : IDisposable
116 // rebuild the body around it. 116 // rebuild the body around it.
117 // Updates prim.BSBody with information/pointers to requested body 117 // Updates prim.BSBody with information/pointers to requested body
118 // Returns 'true' if BSBody was changed. 118 // Returns 'true' if BSBody was changed.
119 bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, 119 bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, bodyCallback);
120 prim.PhysShape, bodyCallback);
121 ret = newGeom || newBody; 120 ret = newGeom || newBody;
122 } 121 }
123 DetailLog("{0},BSShapeCollection.GetBodyAndShape,taintExit,force={1},ret={2},body={3},shape={4}", 122 DetailLog("{0},BSShapeCollection.GetBodyAndShape,taintExit,force={1},ret={2},body={3},shape={4}",
@@ -134,48 +133,44 @@ public sealed class BSShapeCollection : IDisposable
134 // Track another user of a body. 133 // Track another user of a body.
135 // We presume the caller has allocated the body. 134 // We presume the caller has allocated the body.
136 // Bodies only have one user so the body is just put into the world if not already there. 135 // Bodies only have one user so the body is just put into the world if not already there.
137 public void ReferenceBody(BulletBody body, bool inTaintTime) 136 private void ReferenceBody(BulletBody body)
138 { 137 {
139 lock (m_collectionActivityLock) 138 lock (m_collectionActivityLock)
140 { 139 {
141 if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body); 140 if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body);
142 PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.ReferenceBody", delegate() 141 if (!PhysicsScene.PE.IsInWorld(PhysicsScene.World, body))
143 { 142 {
144 if (!PhysicsScene.PE.IsInWorld(PhysicsScene.World, body)) 143 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body);
145 { 144 if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body);
146 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body); 145 }
147 if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body);
148 }
149 });
150 } 146 }
151 } 147 }
152 148
153 // Release the usage of a body. 149 // Release the usage of a body.
154 // Called when releasing use of a BSBody. BSShape is handled separately. 150 // Called when releasing use of a BSBody. BSShape is handled separately.
155 public void DereferenceBody(BulletBody body, bool inTaintTime, BodyDestructionCallback bodyCallback ) 151 // Called in taint time.
152 public void DereferenceBody(BulletBody body, BodyDestructionCallback bodyCallback )
156 { 153 {
157 if (!body.HasPhysicalBody) 154 if (!body.HasPhysicalBody)
158 return; 155 return;
159 156
157 PhysicsScene.AssertInTaintTime("BSShapeCollection.DereferenceBody");
158
160 lock (m_collectionActivityLock) 159 lock (m_collectionActivityLock)
161 { 160 {
162 PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.DereferenceBody", delegate() 161 if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody,body={1}", body.ID, body);
163 { 162 // If the caller needs to know the old body is going away, pass the event up.
164 if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody,body={1},inTaintTime={2}", 163 if (bodyCallback != null) bodyCallback(body);
165 body.ID, body, inTaintTime);
166 // If the caller needs to know the old body is going away, pass the event up.
167 if (bodyCallback != null) bodyCallback(body);
168 164
169 if (PhysicsScene.PE.IsInWorld(PhysicsScene.World, body)) 165 if (PhysicsScene.PE.IsInWorld(PhysicsScene.World, body))
170 { 166 {
171 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body); 167 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
172 if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body); 168 if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body);
173 } 169 }
174 170
175 // Zero any reference to the shape so it is not freed when the body is deleted. 171 // Zero any reference to the shape so it is not freed when the body is deleted.
176 PhysicsScene.PE.SetCollisionShape(PhysicsScene.World, body, null); 172 PhysicsScene.PE.SetCollisionShape(PhysicsScene.World, body, null);
177 PhysicsScene.PE.DestroyObject(PhysicsScene.World, body); 173 PhysicsScene.PE.DestroyObject(PhysicsScene.World, body);
178 });
179 } 174 }
180 } 175 }
181 176
@@ -246,44 +241,43 @@ public sealed class BSShapeCollection : IDisposable
246 } 241 }
247 242
248 // Release the usage of a shape. 243 // Release the usage of a shape.
249 public void DereferenceShape(BulletShape shape, bool inTaintTime, ShapeDestructionCallback shapeCallback) 244 public void DereferenceShape(BulletShape shape, ShapeDestructionCallback shapeCallback)
250 { 245 {
251 if (!shape.HasPhysicalShape) 246 if (!shape.HasPhysicalShape)
252 return; 247 return;
253 248
254 PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.DereferenceShape", delegate() 249 PhysicsScene.AssertInTaintTime("BSShapeCollection.DereferenceShape");
250
251 if (shape.HasPhysicalShape)
255 { 252 {
256 if (shape.HasPhysicalShape) 253 if (shape.isNativeShape)
257 { 254 {
258 if (shape.isNativeShape) 255 // Native shapes are not tracked and are released immediately
259 { 256 if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1}",
260 // Native shapes are not tracked and are released immediately 257 BSScene.DetailLogZero, shape.AddrString);
261 if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1},taintTime={2}", 258 if (shapeCallback != null) shapeCallback(shape);
262 BSScene.DetailLogZero, shape.AddrString, inTaintTime); 259 PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape);
263 if (shapeCallback != null) shapeCallback(shape); 260 }
264 PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape); 261 else
265 } 262 {
266 else 263 switch (shape.type)
267 { 264 {
268 switch (shape.type) 265 case BSPhysicsShapeType.SHAPE_HULL:
269 { 266 DereferenceHull(shape, shapeCallback);
270 case BSPhysicsShapeType.SHAPE_HULL: 267 break;
271 DereferenceHull(shape, shapeCallback); 268 case BSPhysicsShapeType.SHAPE_MESH:
272 break; 269 DereferenceMesh(shape, shapeCallback);
273 case BSPhysicsShapeType.SHAPE_MESH: 270 break;
274 DereferenceMesh(shape, shapeCallback); 271 case BSPhysicsShapeType.SHAPE_COMPOUND:
275 break; 272 DereferenceCompound(shape, shapeCallback);
276 case BSPhysicsShapeType.SHAPE_COMPOUND: 273 break;
277 DereferenceCompound(shape, shapeCallback); 274 case BSPhysicsShapeType.SHAPE_UNKNOWN:
278 break; 275 break;
279 case BSPhysicsShapeType.SHAPE_UNKNOWN: 276 default:
280 break; 277 break;
281 default:
282 break;
283 }
284 } 278 }
285 } 279 }
286 }); 280 }
287 } 281 }
288 282
289 // Count down the reference count for a mesh shape 283 // Count down the reference count for a mesh shape
@@ -394,7 +388,7 @@ public sealed class BSShapeCollection : IDisposable
394 388
395 if (shapeInfo.type != BSPhysicsShapeType.SHAPE_UNKNOWN) 389 if (shapeInfo.type != BSPhysicsShapeType.SHAPE_UNKNOWN)
396 { 390 {
397 DereferenceShape(shapeInfo, true, null); 391 DereferenceShape(shapeInfo, null);
398 } 392 }
399 else 393 else
400 { 394 {
@@ -544,7 +538,7 @@ public sealed class BSShapeCollection : IDisposable
544 ShapeDestructionCallback shapeCallback) 538 ShapeDestructionCallback shapeCallback)
545 { 539 {
546 // release any previous shape 540 // release any previous shape
547 DereferenceShape(prim.PhysShape, true, shapeCallback); 541 DereferenceShape(prim.PhysShape, shapeCallback);
548 542
549 BulletShape newShape = BuildPhysicalNativeShape(prim, shapeType, shapeKey); 543 BulletShape newShape = BuildPhysicalNativeShape(prim, shapeType, shapeKey);
550 544
@@ -612,7 +606,7 @@ public sealed class BSShapeCollection : IDisposable
612 prim.LocalID, prim.PhysShape.shapeKey.ToString("X"), newMeshKey.ToString("X")); 606 prim.LocalID, prim.PhysShape.shapeKey.ToString("X"), newMeshKey.ToString("X"));
613 607
614 // Since we're recreating new, get rid of the reference to the previous shape 608 // Since we're recreating new, get rid of the reference to the previous shape
615 DereferenceShape(prim.PhysShape, true, shapeCallback); 609 DereferenceShape(prim.PhysShape, shapeCallback);
616 610
617 newShape = CreatePhysicalMesh(prim.PhysObjectName, newMeshKey, prim.BaseShape, prim.Size, lod); 611 newShape = CreatePhysicalMesh(prim.PhysObjectName, newMeshKey, prim.BaseShape, prim.Size, lod);
618 // Take evasive action if the mesh was not constructed. 612 // Take evasive action if the mesh was not constructed.
@@ -683,7 +677,7 @@ public sealed class BSShapeCollection : IDisposable
683 prim.LocalID, prim.PhysShape.shapeKey.ToString("X"), newHullKey.ToString("X")); 677 prim.LocalID, prim.PhysShape.shapeKey.ToString("X"), newHullKey.ToString("X"));
684 678
685 // Remove usage of the previous shape. 679 // Remove usage of the previous shape.
686 DereferenceShape(prim.PhysShape, true, shapeCallback); 680 DereferenceShape(prim.PhysShape, shapeCallback);
687 681
688 newShape = CreatePhysicalHull(prim.PhysObjectName, newHullKey, prim.BaseShape, prim.Size, lod); 682 newShape = CreatePhysicalHull(prim.PhysObjectName, newHullKey, prim.BaseShape, prim.Size, lod);
689 newShape = VerifyMeshCreated(newShape, prim); 683 newShape = VerifyMeshCreated(newShape, prim);
@@ -818,7 +812,6 @@ public sealed class BSShapeCollection : IDisposable
818 // Don't need to do this as the shape is freed when the new root shape is created below. 812 // Don't need to do this as the shape is freed when the new root shape is created below.
819 // DereferenceShape(prim.PhysShape, true, shapeCallback); 813 // DereferenceShape(prim.PhysShape, true, shapeCallback);
820 814
821
822 BulletShape cShape = PhysicsScene.PE.CreateCompoundShape(PhysicsScene.World, false); 815 BulletShape cShape = PhysicsScene.PE.CreateCompoundShape(PhysicsScene.World, false);
823 816
824 // Create the shape for the root prim and add it to the compound shape. Cannot be a native shape. 817 // Create the shape for the root prim and add it to the compound shape. Cannot be a native shape.
@@ -933,8 +926,7 @@ public sealed class BSShapeCollection : IDisposable
933 // Updates prim.BSBody with the information about the new body if one is created. 926 // Updates prim.BSBody with the information about the new body if one is created.
934 // Returns 'true' if an object was actually created. 927 // Returns 'true' if an object was actually created.
935 // Called at taint-time. 928 // Called at taint-time.
936 private bool CreateBody(bool forceRebuild, BSPhysObject prim, BulletWorld sim, BulletShape shape, 929 private bool CreateBody(bool forceRebuild, BSPhysObject prim, BulletWorld sim, BodyDestructionCallback bodyCallback)
937 BodyDestructionCallback bodyCallback)
938 { 930 {
939 bool ret = false; 931 bool ret = false;
940 932
@@ -951,27 +943,28 @@ public sealed class BSShapeCollection : IDisposable
951 { 943 {
952 // If the collisionObject is not the correct type for solidness, rebuild what's there 944 // If the collisionObject is not the correct type for solidness, rebuild what's there
953 mustRebuild = true; 945 mustRebuild = true;
946 if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,forceRebuildBecauseChangingBodyType,bodyType={1}", prim.LocalID, bodyType);
954 } 947 }
955 } 948 }
956 949
957 if (mustRebuild || forceRebuild) 950 if (mustRebuild || forceRebuild)
958 { 951 {
959 // Free any old body 952 // Free any old body
960 DereferenceBody(prim.PhysBody, true, bodyCallback); 953 DereferenceBody(prim.PhysBody, bodyCallback);
961 954
962 BulletBody aBody; 955 BulletBody aBody;
963 if (prim.IsSolid) 956 if (prim.IsSolid)
964 { 957 {
965 aBody = PhysicsScene.PE.CreateBodyFromShape(sim, shape, prim.LocalID, prim.RawPosition, prim.RawOrientation); 958 aBody = PhysicsScene.PE.CreateBodyFromShape(sim, prim.PhysShape, prim.LocalID, prim.RawPosition, prim.RawOrientation);
966 if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,mesh,body={1}", prim.LocalID, aBody); 959 if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,mesh,body={1}", prim.LocalID, aBody);
967 } 960 }
968 else 961 else
969 { 962 {
970 aBody = PhysicsScene.PE.CreateGhostFromShape(sim, shape, prim.LocalID, prim.RawPosition, prim.RawOrientation); 963 aBody = PhysicsScene.PE.CreateGhostFromShape(sim, prim.PhysShape, prim.LocalID, prim.RawPosition, prim.RawOrientation);
971 if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,ghost,body={1}", prim.LocalID, aBody); 964 if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,ghost,body={1}", prim.LocalID, aBody);
972 } 965 }
973 966
974 ReferenceBody(aBody, true); 967 ReferenceBody(aBody);
975 968
976 prim.PhysBody = aBody; 969 prim.PhysBody = aBody;
977 970
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
index a95e169..a3b3556 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
@@ -6,6 +6,7 @@ One sided meshes? Should terrain be built into a closed shape?
6 Ref: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4869 6 Ref: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4869
7Deleting a linkset while standing on the root will leave the physical shape of the root behind. 7Deleting a linkset while standing on the root will leave the physical shape of the root behind.
8 Not sure if it is because standing on it. Done with large prim linksets. 8 Not sure if it is because standing on it. Done with large prim linksets.
9Terrain detail: double terrain mesh detail
9Vehicle angular vertical attraction 10Vehicle angular vertical attraction
10vehicle angular banking 11vehicle angular banking
11Center-of-gravity 12Center-of-gravity
@@ -34,34 +35,20 @@ Vehicle script tuning/debugging
34 Weapon shooter script 35 Weapon shooter script
35Add material densities to the material types 36Add material densities to the material types
36 37
37CRASHES
38=================================================
39Crazyness during 20130115 office hours was PositionAdjustUnderground for both char and prim
40 m1:logs/20130115.0934/physics-BulletSim-20130115083613.log
41 Creation of Neb's terrain made the terrain "disappear". Everything started to fall
42 and then get restored to be above terrain.
4320121129.1411: editting/moving phys object across region boundries causes crash
44 getPos-> btRigidBody::upcast -> getBodyType -> BOOM
4520121128.1600: mesh object not rezzing (no physics mesh).
46 Causes many errors. Doesn't stop after first error with box shape.
47 Eventually crashes when deleting the object.
4820121206.1434: rez Sam-pan into OSGrid BulletSim11 region
49 Immediate simulator crash. Mono does not output any stacktrace and
50 log just stops after reporting taint-time linking of the linkset.
51
52VEHICLES TODO LIST: 38VEHICLES TODO LIST:
53================================================= 39=================================================
54Border crossing with linked vehicle causes crash 40Border crossing with linked vehicle causes crash
41 20121129.1411: editting/moving phys object across region boundries causes crash
42 getPos-> btRigidBody::upcast -> getBodyType -> BOOM
55Vehicles (Move smoothly) 43Vehicles (Move smoothly)
56Some vehicles should not be able to turn if no speed or off ground. 44Some vehicles should not be able to turn if no speed or off ground.
45What to do if vehicle and prim buoyancy differ?
57Cannot edit/move a vehicle being ridden: it jumps back to the origional position. 46Cannot edit/move a vehicle being ridden: it jumps back to the origional position.
58Neb car jiggling left and right 47Neb car jiggling left and right
59 Happens on terrain and any other mesh object. Flat cubes are much smoother. 48 Happens on terrain and any other mesh object. Flat cubes are much smoother.
60 This has been reduced but not eliminated. 49 This has been reduced but not eliminated.
61Implement referenceFrame for all the motion routines. 50Implement referenceFrame for all the motion routines.
62For limitMotorUp, use raycast down to find if vehicle is in the air. 51For limitMotorUp, use raycast down to find if vehicle is in the air.
63Angular motion around Z moves the vehicle in world Z and not vehicle Z in ODE.
64 Verify that angular motion specified around Z moves in the vehicle coordinates.
65Verify llGetVel() is returning a smooth and good value for vehicle movement. 52Verify llGetVel() is returning a smooth and good value for vehicle movement.
66llGetVel() should return the root's velocity if requested in a child prim. 53llGetVel() should return the root's velocity if requested in a child prim.
67Implement function efficiency for lineaar and angular motion. 54Implement function efficiency for lineaar and angular motion.
@@ -73,10 +60,15 @@ Remove vehicle angular velocity zeroing in BSPrim.UpdateProperties().
73Incorporate inter-relationship of angular corrections. For instance, angularDeflection 60Incorporate inter-relationship of angular corrections. For instance, angularDeflection
74 and angularMotorUp will compute same X or Y correction. When added together 61 and angularMotorUp will compute same X or Y correction. When added together
75 creates over-correction and over-shoot and wabbling. 62 creates over-correction and over-shoot and wabbling.
63Vehicle attributes are not restored when a vehicle is rezzed on region creation
64 Create vehicle, setup vehicle properties, restart region, vehicle is not reinitialized.
76 65
77GENERAL TODO LIST: 66GENERAL TODO LIST:
78================================================= 67=================================================
79Avatar standing on a moving object should start to move with the object. 68Collisions are inconsistant: arrows are supposed to hit and report collision. Often don't.
69 If arrow show at prim, collision reported about 1/3 of time. If collision reported,
70 both arrow and prim report it. The arrow bounces off the prim 9 out of 10 times.
71 Shooting 5m sphere "arrows" at 60m/s.
80llMoveToTarget objects are not effected by gravity until target is removed. 72llMoveToTarget objects are not effected by gravity until target is removed.
81Compute CCD parameters based on body size 73Compute CCD parameters based on body size
82Can solver iterations be changed per body/shape? Can be for constraints but what 74Can solver iterations be changed per body/shape? Can be for constraints but what
@@ -135,6 +127,7 @@ Physical and phantom will drop through the terrain
135 127
136LINKSETS 128LINKSETS
137====================================================== 129======================================================
130Child prims do not report collisions
138Editing a child of a linkset causes the child to go phantom 131Editing a child of a linkset causes the child to go phantom
139 Move a child prim once when it is physical and can never move it again without it going phantom 132 Move a child prim once when it is physical and can never move it again without it going phantom
140Offset the center of the linkset to be the geometric center of all the prims 133Offset the center of the linkset to be the geometric center of all the prims
@@ -330,4 +323,8 @@ Boats float low in the water (DONE)
330Boats floating at proper level (DONE) 323Boats floating at proper level (DONE)
331When is force introduced by SetForce removed? The prestep action could go forever. (DONE) 324When is force introduced by SetForce removed? The prestep action could go forever. (DONE)
332 (Resolution: setForce registers a prestep action which keeps applying the force) 325 (Resolution: setForce registers a prestep action which keeps applying the force)
333Child movement in linkset (don't rebuild linkset) (DONE 20130122)) \ No newline at end of file 326Child movement in linkset (don't rebuild linkset) (DONE 20130122))
327Avatar standing on a moving object should start to move with the object. (DONE 20130125)
328Angular motion around Z moves the vehicle in world Z and not vehicle Z in ODE.
329 Verify that angular motion specified around Z moves in the vehicle coordinates.
330 DONE 20130120: BulletSim properly applies force in vehicle relative coordinates. \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index fe418d3..20a70b4 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Physics.Manager
47 public delegate void JointDeactivated(PhysicsJoint joint); 47 public delegate void JointDeactivated(PhysicsJoint joint);
48 public delegate void JointErrorMessage(PhysicsJoint joint, string message); // this refers to an "error message due to a problem", not "amount of joint constraint violation" 48 public delegate void JointErrorMessage(PhysicsJoint joint, string message); // this refers to an "error message due to a problem", not "amount of joint constraint violation"
49 49
50 public enum RayFilterFlags:ushort 50 public enum RayFilterFlags : ushort
51 { 51 {
52 // the flags 52 // the flags
53 water = 0x01, 53 water = 0x01,
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Physics.Manager
64 ClosestHit = 0x8000, 64 ClosestHit = 0x8000,
65 65
66 // some combinations 66 // some combinations
67 LSLPhanton = phantom | volumedtc, 67 LSLPhantom = phantom | volumedtc,
68 PrimsNonPhantom = nonphysical | physical, 68 PrimsNonPhantom = nonphysical | physical,
69 PrimsNonPhantomAgents = nonphysical | physical | agent, 69 PrimsNonPhantomAgents = nonphysical | physical | agent,
70 70