aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
diff options
context:
space:
mode:
authorRobert Adams2012-10-12 16:03:03 -0700
committerRobert Adams2012-10-19 10:51:58 -0700
commitfd7a097849b8a405bdd62cfe6d4ee2bbf0a3961c (patch)
tree93606a507aa16538a73e10956735a66f4306fe18 /OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
parentminor: Increase attachment name field from 36 to 50 chars in "attachments sho... (diff)
downloadopensim-SC_OLD-fd7a097849b8a405bdd62cfe6d4ee2bbf0a3961c.zip
opensim-SC_OLD-fd7a097849b8a405bdd62cfe6d4ee2bbf0a3961c.tar.gz
opensim-SC_OLD-fd7a097849b8a405bdd62cfe6d4ee2bbf0a3961c.tar.bz2
opensim-SC_OLD-fd7a097849b8a405bdd62cfe6d4ee2bbf0a3961c.tar.xz
BulletSim: Update BSCharacter to use API2 interface.
Add capsule shape to BSShapeCollection(). Remember last updated values so inter frame diffs can be computed. Parameterize avatarStandingFriction and reduce to 10 from 999. The latter high value made avatars very hard to push. Set CCD parameters for prims and characters of specified.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs51
1 files changed, 36 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index d189f1d..7d0f84a 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -93,7 +93,7 @@ public class BSShapeCollection : IDisposable
93 // sure the body is of the right type. 93 // sure the body is of the right type.
94 // Return 'true' if either the body or the shape changed. 94 // Return 'true' if either the body or the shape changed.
95 // Called at taint-time!! 95 // Called at taint-time!!
96 public bool GetBodyAndShape(bool forceRebuild, BulletSim sim, BSPrim prim, 96 public bool GetBodyAndShape(bool forceRebuild, BulletSim sim, BSPhysObject prim,
97 ShapeData shapeData, PrimitiveBaseShape pbs, 97 ShapeData shapeData, PrimitiveBaseShape pbs,
98 ShapeDestructionCallback shapeCallback, BodyDestructionCallback bodyCallback) 98 ShapeDestructionCallback shapeCallback, BodyDestructionCallback bodyCallback)
99 { 99 {
@@ -351,19 +351,30 @@ public class BSShapeCollection : IDisposable
351 351
352 // Create the geometry information in Bullet for later use. 352 // Create the geometry information in Bullet for later use.
353 // The objects needs a hull if it's physical otherwise a mesh is enough. 353 // The objects needs a hull if it's physical otherwise a mesh is enough.
354 // No locking here because this is done when we know physics is not simulating. 354 // if 'forceRebuild' is true, the geometry is unconditionally rebuilt. For meshes and hulls,
355 // if 'forceRebuild' is true, the geometry is rebuilt. Otherwise a previously built version is used. 355 // shared geometries will be used. If the parameters of the existing shape are the same
356 // as this request, the shape is not rebuilt.
357 // Info in prim.BSShape is updated to the new shape.
356 // Returns 'true' if the geometry was rebuilt. 358 // Returns 'true' if the geometry was rebuilt.
357 // Called at taint-time! 359 // Called at taint-time!
358 private bool CreateGeom(bool forceRebuild, BSPrim prim, ShapeData shapeData, 360 private bool CreateGeom(bool forceRebuild, BSPhysObject prim, ShapeData shapeData,
359 PrimitiveBaseShape pbs, ShapeDestructionCallback shapeCallback) 361 PrimitiveBaseShape pbs, ShapeDestructionCallback shapeCallback)
360 { 362 {
361 bool ret = false; 363 bool ret = false;
362 bool haveShape = false; 364 bool haveShape = false;
363 bool nativeShapePossible = true; 365 bool nativeShapePossible = true;
364 366
367 if (shapeData.Type == ShapeData.PhysicsShapeType.SHAPE_AVATAR)
368 {
369 // an avatar capsule is close to a native shape (it is not shared)
370 ret = GetReferenceToNativeShape(prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_AVATAR,
371 ShapeData.FixedShapeKey.KEY_CAPSULE, shapeCallback);
372 haveShape = true;
373 }
365 // If the prim attributes are simple, this could be a simple Bullet native shape 374 // If the prim attributes are simple, this could be a simple Bullet native shape
366 if (nativeShapePossible 375 if (!haveShape
376 && pbs != null
377 && nativeShapePossible
367 && ((pbs.SculptEntry && !PhysicsScene.ShouldMeshSculptedPrim) 378 && ((pbs.SculptEntry && !PhysicsScene.ShouldMeshSculptedPrim)
368 || (pbs.ProfileBegin == 0 && pbs.ProfileEnd == 0 379 || (pbs.ProfileBegin == 0 && pbs.ProfileEnd == 0
369 && pbs.ProfileHollow == 0 380 && pbs.ProfileHollow == 0
@@ -406,7 +417,7 @@ public class BSShapeCollection : IDisposable
406 // If a simple shape is not happening, create a mesh and possibly a hull. 417 // If a simple shape is not happening, create a mesh and possibly a hull.
407 // Note that if it's a native shape, the check for physical/non-physical is not 418 // Note that if it's a native shape, the check for physical/non-physical is not
408 // made. Native shapes are best used in either case. 419 // made. Native shapes are best used in either case.
409 if (!haveShape) 420 if (!haveShape && pbs != null)
410 { 421 {
411 if (prim.IsPhysical && PhysicsScene.ShouldUseHullsForPhysicalObjects) 422 if (prim.IsPhysical && PhysicsScene.ShouldUseHullsForPhysicalObjects)
412 { 423 {
@@ -425,8 +436,9 @@ public class BSShapeCollection : IDisposable
425 return ret; 436 return ret;
426 } 437 }
427 438
428 // Creates a native shape and assignes it to prim.BSShape 439 // Creates a native shape and assignes it to prim.BSShape.
429 private bool GetReferenceToNativeShape( BSPrim prim, ShapeData shapeData, 440 // "Native" shapes are never shared. they are created here and destroyed in DereferenceShape().
441 private bool GetReferenceToNativeShape(BSPhysObject prim, ShapeData shapeData,
430 ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey, 442 ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey,
431 ShapeDestructionCallback shapeCallback) 443 ShapeDestructionCallback shapeCallback)
432 { 444 {
@@ -440,10 +452,19 @@ public class BSShapeCollection : IDisposable
440 // release any previous shape 452 // release any previous shape
441 DereferenceShape(prim.BSShape, true, shapeCallback); 453 DereferenceShape(prim.BSShape, true, shapeCallback);
442 454
443 // Native shapes are always built independently. 455 if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR)
444 newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, shapeData), shapeType); 456 {
445 newShape.shapeKey = (System.UInt64)shapeKey; 457 newShape = new BulletShape(BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, shapeData), shapeType);
446 newShape.isNativeShape = true; 458 newShape.shapeKey = (System.UInt64)shapeKey;
459 newShape.isNativeShape = true;
460 }
461 else
462 {
463 // Native shapes are always built independently.
464 newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, shapeData), shapeType);
465 newShape.shapeKey = (System.UInt64)shapeKey;
466 newShape.isNativeShape = true;
467 }
447 468
448 // Don't need to do a 'ReferenceShape()' here because native shapes are not tracked. 469 // Don't need to do a 'ReferenceShape()' here because native shapes are not tracked.
449 // DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1}", shapeData.ID, newShape); 470 // DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1}", shapeData.ID, newShape);
@@ -456,7 +477,7 @@ public class BSShapeCollection : IDisposable
456 // Dereferences previous shape in BSShape and adds a reference for this new shape. 477 // Dereferences previous shape in BSShape and adds a reference for this new shape.
457 // Returns 'true' of a mesh was actually built. Otherwise . 478 // Returns 'true' of a mesh was actually built. Otherwise .
458 // Called at taint-time! 479 // Called at taint-time!
459 private bool GetReferenceToMesh(BSPrim prim, ShapeData shapeData, PrimitiveBaseShape pbs, 480 private bool GetReferenceToMesh(BSPhysObject prim, ShapeData shapeData, PrimitiveBaseShape pbs,
460 ShapeDestructionCallback shapeCallback) 481 ShapeDestructionCallback shapeCallback)
461 { 482 {
462 BulletShape newShape = new BulletShape(IntPtr.Zero); 483 BulletShape newShape = new BulletShape(IntPtr.Zero);
@@ -526,7 +547,7 @@ public class BSShapeCollection : IDisposable
526 547
527 // See that hull shape exists in the physical world and update prim.BSShape. 548 // See that hull shape exists in the physical world and update prim.BSShape.
528 // We could be creating the hull because scale changed or whatever. 549 // We could be creating the hull because scale changed or whatever.
529 private bool GetReferenceToHull(BSPrim prim, ShapeData shapeData, PrimitiveBaseShape pbs, 550 private bool GetReferenceToHull(BSPhysObject prim, ShapeData shapeData, PrimitiveBaseShape pbs,
530 ShapeDestructionCallback shapeCallback) 551 ShapeDestructionCallback shapeCallback)
531 { 552 {
532 BulletShape newShape; 553 BulletShape newShape;
@@ -694,7 +715,7 @@ public class BSShapeCollection : IDisposable
694 // Updates prim.BSBody with the information about the new body if one is created. 715 // Updates prim.BSBody with the information about the new body if one is created.
695 // Returns 'true' if an object was actually created. 716 // Returns 'true' if an object was actually created.
696 // Called at taint-time. 717 // Called at taint-time.
697 private bool CreateBody(bool forceRebuild, BSPrim prim, BulletSim sim, BulletShape shape, 718 private bool CreateBody(bool forceRebuild, BSPhysObject prim, BulletSim sim, BulletShape shape,
698 ShapeData shapeData, BodyDestructionCallback bodyCallback) 719 ShapeData shapeData, BodyDestructionCallback bodyCallback)
699 { 720 {
700 bool ret = false; 721 bool ret = false;