aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
authorRobert Adams2013-02-01 11:52:27 -0800
committerRobert Adams2013-02-01 11:52:27 -0800
commit5bb85a14d46ad280b045e945edcc9e9bc6045612 (patch)
treef3b1d963d8f78d9272b46e682798de9226ad1108 /OpenSim/Region/Physics/BulletSPlugin
parentBulletSim: fix crash caused when linksets were rebuilt. A problem added (diff)
downloadopensim-SC-5bb85a14d46ad280b045e945edcc9e9bc6045612.zip
opensim-SC-5bb85a14d46ad280b045e945edcc9e9bc6045612.tar.gz
opensim-SC-5bb85a14d46ad280b045e945edcc9e9bc6045612.tar.bz2
opensim-SC-5bb85a14d46ad280b045e945edcc9e9bc6045612.tar.xz
BulletSim: fix problem where editting a physical linkset caused the
child prim physical positions to get out of sync with the view. More reliably compute the offset of children in a physical linkset.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs51
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt1
2 files changed, 33 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 6c6ca09..0c4db40 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -219,30 +219,31 @@ 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 222 if (lsi != null)
223 // The linksetInfo will need to be rebuilt either here or when the linkset is rebuilt
224 if (LinksetRoot.PhysShape.HasPhysicalShape && lsi != null)
225 { 223 {
226 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))
227 { 230 {
231 // It is possible that the linkset is still under construction and the child is not yet
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.
228 int numLinksetChildren = PhysicsScene.PE.GetNumberOfCompoundChildren(LinksetRoot.PhysShape); 236 int numLinksetChildren = PhysicsScene.PE.GetNumberOfCompoundChildren(LinksetRoot.PhysShape);
229 if (lsi.Index < numLinksetChildren) 237 if (lsi.Index < numLinksetChildren)
230 { 238 {
231 // It is possible that the linkset is still under construction and the child is not yet
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 // This must be checked for because Bullet references the child array but does no validity
235 // checking of the child index passed.
236 BulletShape linksetChildShape = PhysicsScene.PE.GetChildShapeFromCompoundShapeIndex(LinksetRoot.PhysShape, lsi.Index); 239 BulletShape linksetChildShape = PhysicsScene.PE.GetChildShapeFromCompoundShapeIndex(LinksetRoot.PhysShape, lsi.Index);
237 if (linksetChildShape.HasPhysicalShape) 240 if (linksetChildShape.HasPhysicalShape)
238 { 241 {
239 // Compute the offset from the center-of-gravity 242 // Found the child shape within the compound shape
240 BSLinksetCompoundInfo newLsi = new BSLinksetCompoundInfo(lsi.Index, LinksetRoot, updated, LinksetRoot.PositionDisplacement);
241 PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, lsi.Index, 243 PhysicsScene.PE.UpdateChildTransform(LinksetRoot.PhysShape, lsi.Index,
242 newLsi.OffsetFromCenterOfMass, 244 newLsi.OffsetFromCenterOfMass,
243 newLsi.OffsetRot, 245 newLsi.OffsetRot,
244 true /* shouldRecalculateLocalAabb */); 246 true /* shouldRecalculateLocalAabb */);
245 updated.LinksetInfo = newLsi;
246 updatedChild = true; 247 updatedChild = true;
247 DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1},newLsi={2}", 248 DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1},newLsi={2}",
248 updated.LocalID, whichUpdated, newLsi); 249 updated.LocalID, whichUpdated, newLsi);
@@ -262,19 +263,20 @@ public sealed class BSLinksetCompound : BSLinkset
262 } 263 }
263 else // DEBUG DEBUG 264 else // DEBUG DEBUG
264 { // DEBUG DEBUG 265 { // DEBUG DEBUG
265 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,notCompound", updated.LocalID); 266 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noBodyOrNotCompound", updated.LocalID);
266 } // DEBUG DEBUG 267 } // DEBUG DEBUG
267 } 268 }
268 else // DEBUG DEBUG 269 else // DEBUG DEBUG
269 { // DEBUG DEBUG 270 { // DEBUG DEBUG
270 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,rootPhysShape={1},lsi={2}", 271 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild,noLinkSetInfo,rootPhysShape={1}",
271 updated.LocalID, LinksetRoot.PhysShape, lsi == null ? "NULL" : lsi.ToString()); 272 updated.LocalID, LinksetRoot.PhysShape);
272 } // DEBUG DEBUG 273 } // DEBUG DEBUG
274
273 if (!updatedChild) 275 if (!updatedChild)
274 { 276 {
275 // 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.
276 // Note that there are several ways through this code that will not update the child that can 278 // Note: there are several ways through this code that will not update the child if
277 // occur if the linkset is being rebuilt. In this case, scheduling a rebuild is a NOOP since 279 // the linkset is being rebuilt. In this case, scheduling a rebuild is a NOOP since
278 // there will already be a rebuild scheduled. 280 // there will already be a rebuild scheduled.
279 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}", 281 DetailLog("{0},BSLinksetCompound.UpdateProperties,couldNotUpdateChild.schedulingRebuild,whichUpdated={1}",
280 updated.LocalID, whichUpdated); 282 updated.LocalID, whichUpdated);
@@ -300,7 +302,8 @@ public sealed class BSLinksetCompound : BSLinkset
300 { 302 {
301 // 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
302 // its position in the linkset. 304 // its position in the linkset.
303 RecomputeChildWorldPosition(child, true); 305 RecomputeChildWorldPosition(child, true /* inTaintTime */);
306 child.LinksetInfo = null;
304 } 307 }
305 308
306 // 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
@@ -315,6 +318,14 @@ public sealed class BSLinksetCompound : BSLinkset
315 // 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.
316 private void RecomputeChildWorldPosition(BSPhysObject child, bool inTaintTime) 319 private void RecomputeChildWorldPosition(BSPhysObject child, bool inTaintTime)
317 { 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 /*
318 BSLinksetCompoundInfo lci = child.LinksetInfo as BSLinksetCompoundInfo; 329 BSLinksetCompoundInfo lci = child.LinksetInfo as BSLinksetCompoundInfo;
319 if (lci != null) 330 if (lci != null)
320 { 331 {
@@ -343,6 +354,7 @@ public sealed class BSLinksetCompound : BSLinkset
343 // LogHeader, child.LocalID); 354 // LogHeader, child.LocalID);
344 DetailLog("{0},BSLinksetCompound.recomputeChildWorldPosition,noRelativePositonInfo", child.LocalID); 355 DetailLog("{0},BSLinksetCompound.recomputeChildWorldPosition,noRelativePositonInfo", child.LocalID);
345 } 356 }
357 */
346 } 358 }
347 359
348 // ================================================================ 360 // ================================================================
@@ -376,6 +388,7 @@ public sealed class BSLinksetCompound : BSLinkset
376 388
377 // 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
378 RecomputeChildWorldPosition(child, false); 390 RecomputeChildWorldPosition(child, false);
391 child.LinksetInfo = null;
379 child.ForceBodyShapeRebuild(false); 392 child.ForceBodyShapeRebuild(false);
380 393
381 if (!HasAnyChildren) 394 if (!HasAnyChildren)
@@ -397,7 +410,7 @@ public sealed class BSLinksetCompound : BSLinkset
397 // Constraint linksets are rebuilt every time. 410 // Constraint linksets are rebuilt every time.
398 // 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.
399 // Called at taint time!! 412 // Called at taint time!!
400 private bool disableCOM = true; // disable until we get this debugged 413 private bool disableCOM = true; // DEBUG DEBUG: disable until we get this debugged
401 private void RecomputeLinksetCompound() 414 private void RecomputeLinksetCompound()
402 { 415 {
403 try 416 try
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
index 7dfdec1..a3b3556 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
@@ -127,6 +127,7 @@ Physical and phantom will drop through the terrain
127 127
128LINKSETS 128LINKSETS
129====================================================== 129======================================================
130Child prims do not report collisions
130Editing a child of a linkset causes the child to go phantom 131Editing a child of a linkset causes the child to go phantom
131 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
132Offset 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