aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
diff options
context:
space:
mode:
authorRobert Adams2013-01-31 15:52:50 -0800
committerRobert Adams2013-01-31 15:56:10 -0800
commit75a05c16c5c0ec0712f7f564b60530e0a3fd1c82 (patch)
treefc6700bc9c7b6e04ea0e6615b57b04ffc1fcb2cd /OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
parentBulletSim: make sure vehicle physical properties are set when going (diff)
downloadopensim-SC_OLD-75a05c16c5c0ec0712f7f564b60530e0a3fd1c82.zip
opensim-SC_OLD-75a05c16c5c0ec0712f7f564b60530e0a3fd1c82.tar.gz
opensim-SC_OLD-75a05c16c5c0ec0712f7f564b60530e0a3fd1c82.tar.bz2
opensim-SC_OLD-75a05c16c5c0ec0712f7f564b60530e0a3fd1c82.tar.xz
BulletSim: fix crash caused when linksets were rebuilt. A problem added
when individual child pos/rot changes were implementated a week or so ago. Remove some passing of inTaintTime flag when it was never false.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs48
1 files changed, 34 insertions, 14 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 92f6ee2..6c6ca09 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -219,28 +219,45 @@ 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
223 // The linksetInfo will need to be rebuilt either here or when the linkset is rebuilt
222 if (LinksetRoot.PhysShape.HasPhysicalShape && lsi != null) 224 if (LinksetRoot.PhysShape.HasPhysicalShape && lsi != null)
223 { 225 {
224 if (PhysicsScene.PE.IsCompound(LinksetRoot.PhysShape)) 226 if (PhysicsScene.PE.IsCompound(LinksetRoot.PhysShape))
225 { 227 {
226 BulletShape linksetChildShape = PhysicsScene.PE.GetChildShapeFromCompoundShapeIndex(LinksetRoot.PhysShape, lsi.Index); 228 int numLinksetChildren = PhysicsScene.PE.GetNumberOfCompoundChildren(LinksetRoot.PhysShape);
227 if (linksetChildShape.HasPhysicalShape) 229 if (lsi.Index < numLinksetChildren)
228 { 230 {
229 // Compute the offset from the center-of-gravity 231 // It is possible that the linkset is still under construction and the child is not yet
230 BSLinksetCompoundInfo newLsi = new BSLinksetCompoundInfo(lsi.Index, LinksetRoot, updated, LinksetRoot.PositionDisplacement); 232 // inserted into the compound shape. A rebuild of the linkset in a pre-step action will
231 PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, lsi.Index, 233 // build the whole thing with the new position or rotation.
232 newLsi.OffsetFromCenterOfMass, 234 // This must be checked for because Bullet references the child array but does no validity
233 newLsi.OffsetRot, 235 // checking of the child index passed.
234 true /* shouldRecalculateLocalAabb */); 236 BulletShape linksetChildShape = PhysicsScene.PE.GetChildShapeFromCompoundShapeIndex(LinksetRoot.PhysShape, lsi.Index);
235 DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1},newLsi={2}", 237 if (linksetChildShape.HasPhysicalShape)
236 updated.LocalID, whichUpdated, newLsi); 238 {
237 updated.LinksetInfo = newLsi; 239 // Compute the offset from the center-of-gravity
238 updatedChild = true; 240 BSLinksetCompoundInfo newLsi = new BSLinksetCompoundInfo(lsi.Index, LinksetRoot, updated, LinksetRoot.PositionDisplacement);
241 PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, lsi.Index,
242 newLsi.OffsetFromCenterOfMass,
243 newLsi.OffsetRot,
244 true /* shouldRecalculateLocalAabb */);
245 updated.LinksetInfo = newLsi;
246 updatedChild = true;
247 DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1},newLsi={2}",
248 updated.LocalID, whichUpdated, newLsi);
249 }
250 else // DEBUG DEBUG
251 { // DEBUG DEBUG
252 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noChildShape,shape={1}",
253 updated.LocalID, linksetChildShape);
254 } // DEBUG DEBUG
239 } 255 }
240 else // DEBUG DEBUG 256 else // DEBUG DEBUG
241 { // DEBUG DEBUG 257 { // DEBUG DEBUG
242 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noChildShape,shape={1}", 258 // the child is not yet in the compound shape. This is non-fatal.
243 updated.LocalID, linksetChildShape); 259 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,childNotInCompoundShape,numChildren={1},index={2}",
260 updated.LocalID, numLinksetChildren, lsi.Index);
244 } // DEBUG DEBUG 261 } // DEBUG DEBUG
245 } 262 }
246 else // DEBUG DEBUG 263 else // DEBUG DEBUG
@@ -256,6 +273,9 @@ public sealed class BSLinksetCompound : BSLinkset
256 if (!updatedChild) 273 if (!updatedChild)
257 { 274 {
258 // If couldn't do the individual child, the linkset needs a rebuild to incorporate the new child info. 275 // If couldn't do the individual child, the linkset needs a rebuild to incorporate the new child info.
276 // Note that there are several ways through this code that will not update the child that can
277 // occur if the linkset is being rebuilt. In this case, scheduling a rebuild is a NOOP since
278 // there will already be a rebuild scheduled.
259 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}", 279 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}",
260 updated.LocalID, whichUpdated); 280 updated.LocalID, whichUpdated);
261 updated.LinksetInfo = null; // setting to 'null' causes relative position to be recomputed. 281 updated.LinksetInfo = null; // setting to 'null' causes relative position to be recomputed.