aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs33
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs4
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs30
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs8
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs1
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs2
6 files changed, 43 insertions, 35 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index e7bff6e..fc4526b 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -141,10 +141,6 @@ public class BSCharacter : BSPhysObject
141 BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, BSBody.ptr); 141 BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, BSBody.ptr);
142 142
143 ZeroMotion(); 143 ZeroMotion();
144
145 OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw);
146 BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia);
147
148 ForcePosition = _position; 144 ForcePosition = _position;
149 // Set the velocity and compute the proper friction 145 // Set the velocity and compute the proper friction
150 ForceVelocity = _velocity; 146 ForceVelocity = _velocity;
@@ -157,6 +153,9 @@ public class BSCharacter : BSPhysObject
157 BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); 153 BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius);
158 } 154 }
159 155
156 OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw);
157 BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia);
158
160 BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT); 159 BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT);
161 160
162 BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr); 161 BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr);
@@ -583,14 +582,16 @@ public class BSCharacter : BSPhysObject
583 582
584 private void ComputeAvatarScale(OMV.Vector3 size) 583 private void ComputeAvatarScale(OMV.Vector3 size)
585 { 584 {
585 // The 'size' given by the simulator is the mid-point of the avatar
586 // and X and Y are unspecified.
587
586 OMV.Vector3 newScale = OMV.Vector3.Zero; 588 OMV.Vector3 newScale = OMV.Vector3.Zero;
587 // Scale wants the diameter so mult radius by two 589 newScale.X = PhysicsScene.Params.avatarCapsuleRadius;
588 newScale.X = PhysicsScene.Params.avatarCapsuleRadius * 2f; 590 newScale.Y = PhysicsScene.Params.avatarCapsuleRadius;
589 newScale.Y = PhysicsScene.Params.avatarCapsuleRadius * 2f;
590 591
591 // From the total height, add the capsule half spheres that are at each end 592 // From the total height, remote the capsule half spheres that are at each end
592 // newScale.Z = (size.Z) - Math.Min(newScale.X, newScale.Y); 593 newScale.Z = (size.Z * 2f) - Math.Min(newScale.X, newScale.Y);
593 newScale.Z = (size.Z * 2f); 594 // newScale.Z = (size.Z * 2f);
594 Scale = newScale; 595 Scale = newScale;
595 } 596 }
596 597
@@ -599,14 +600,14 @@ public class BSCharacter : BSPhysObject
599 { 600 {
600 _avatarVolume = (float)( 601 _avatarVolume = (float)(
601 Math.PI 602 Math.PI
602 * (Scale.X / 2f) 603 * Scale.X
603 * (Scale.Y / 2f) // the area of capsule cylinder 604 * Scale.Y // the area of capsule cylinder
604 * Scale.Z // times height of capsule cylinder 605 * Scale.Z // times height of capsule cylinder
605 + 1.33333333f 606 + 1.33333333f
606 * Math.PI 607 * Math.PI
607 * (Scale.X / 2f) 608 * Scale.X
608 * (Math.Min(Scale.X, Scale.Y) / 2f) 609 * Math.Min(Scale.X, Scale.Y)
609 * (Scale.Y / 2f) // plus the volume of the capsule end caps 610 * Scale.Y // plus the volume of the capsule end caps
610 ); 611 );
611 _mass = _avatarDensity * _avatarVolume; 612 _mass = _avatarDensity * _avatarVolume;
612 } 613 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index b8ef338..202052d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -156,9 +156,11 @@ public abstract class BSPhysObject : PhysicsActor
156 public virtual bool SendCollisions() 156 public virtual bool SendCollisions()
157 { 157 {
158 bool ret = true; 158 bool ret = true;
159 // If the 'no collision' call, force it to happen right now so quick collision_end
160 bool force = CollisionCollection.Count == 0;
159 161
160 // throttle the collisions to the number of milliseconds specified in the subscription 162 // throttle the collisions to the number of milliseconds specified in the subscription
161 if (PhysicsScene.SimulationNowTime >= NextCollisionOkTime) 163 if (force || (PhysicsScene.SimulationNowTime >= NextCollisionOkTime))
162 { 164 {
163 NextCollisionOkTime = PhysicsScene.SimulationNowTime + SubscribedEventsMs; 165 NextCollisionOkTime = PhysicsScene.SimulationNowTime + SubscribedEventsMs;
164 166
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index ab2835c..6621d39 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -532,26 +532,26 @@ public class BSScene : PhysicsScene, IPhysicsParameters
532 } 532 }
533 } 533 }
534 534
535 // This is a kludge to get avatar movement updates.
536 // The simulator expects collisions for avatars even if there are have been no collisions. This updates
537 // avatar animations and stuff.
538 // If you fix avatar animation updates, remove this overhead and let normal collision processing happen.
539 foreach (BSPhysObject bsp in m_avatars)
540 bsp.SendCollisions();
541
542 // The above SendCollision's batch up the collisions on the objects. 535 // The above SendCollision's batch up the collisions on the objects.
543 // Now push the collisions into the simulator. 536 // Now push the collisions into the simulator.
544 if (ObjectsWithCollisions.Count > 0) 537 if (ObjectsWithCollisions.Count > 0)
545 { 538 {
546 foreach (BSPhysObject bsp in ObjectsWithCollisions) 539 foreach (BSPhysObject bsp in ObjectsWithCollisions)
547 if (!m_avatars.Contains(bsp)) // don't call avatars twice 540 if (!bsp.SendCollisions())
548 if (!bsp.SendCollisions()) 541 {
549 { 542 // If the object is done colliding, see that it's removed from the colliding list
550 // If the object is done colliding, see that it's removed from the colliding list 543 ObjectsWithNoMoreCollisions.Add(bsp);
551 ObjectsWithNoMoreCollisions.Add(bsp); 544 }
552 }
553 } 545 }
554 546
547 // This is a kludge to get avatar movement updates.
548 // The simulator expects collisions for avatars even if there are have been no collisions.
549 // The event updates avatar animations and stuff.
550 // If you fix avatar animation updates, remove this overhead and let normal collision processing happen.
551 foreach (BSPhysObject bsp in m_avatars)
552 if (!ObjectsWithCollisions.Contains(bsp)) // don't call avatars twice
553 bsp.SendCollisions();
554
555 // Objects that are done colliding are removed from the ObjectsWithCollisions list. 555 // Objects that are done colliding are removed from the ObjectsWithCollisions list.
556 // Not done above because it is inside an iteration of ObjectWithCollisions. 556 // Not done above because it is inside an iteration of ObjectWithCollisions.
557 if (ObjectsWithNoMoreCollisions.Count > 0) 557 if (ObjectsWithNoMoreCollisions.Count > 0)
@@ -575,6 +575,10 @@ public class BSScene : PhysicsScene, IPhysicsParameters
575 } 575 }
576 } 576 }
577 577
578 // This causes the unmanaged code to output ALL the values found in ALL the objects in the world.
579 // Only enable this in a limited test world with few objects.
580 // BulletSimAPI.DumpAllInfo2(World.ptr); // DEBUG DEBUG DEBUG
581
578 // The physics engine returns the number of milliseconds it simulated this call. 582 // The physics engine returns the number of milliseconds it simulated this call.
579 // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. 583 // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS.
580 // We multiply by 55 to give a recognizable running rate (55 or less). 584 // We multiply by 55 to give a recognizable running rate (55 or less).
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index 3d15eaa..861ffe7 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -417,10 +417,9 @@ public class BSShapeCollection : IDisposable
417 417
418 if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR) 418 if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR)
419 { 419 {
420 // The radius is scaled by 1/2 because we scale by the diameter.
421 newShape = new BulletShape( 420 newShape = new BulletShape(
422 BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 0.5f, 1.0f, shapeData.Scale), 421 BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1.0f, 1.0f, shapeData.Scale),
423 shapeType); 422 shapeType);
424 newShape.shapeKey = (System.UInt64)shapeKey; 423 newShape.shapeKey = (System.UInt64)shapeKey;
425 newShape.isNativeShape = true; 424 newShape.isNativeShape = true;
426 } 425 }
@@ -432,7 +431,8 @@ public class BSShapeCollection : IDisposable
432 } 431 }
433 432
434 // Don't need to do a 'ReferenceShape()' here because native shapes are not shared. 433 // Don't need to do a 'ReferenceShape()' here because native shapes are not shared.
435 // DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1}", shapeData.ID, newShape); 434 DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1},scale={2}",
435 shapeData.ID, newShape, shapeData.Scale);
436 436
437 prim.BSShape = newShape; 437 prim.BSShape = newShape;
438 return true; 438 return true;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
index 9743d94..4106534 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
@@ -114,6 +114,7 @@ public class BSTerrainManager
114 BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID, 114 BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID,
115 Vector3.Zero, Quaternion.Identity)); 115 Vector3.Zero, Quaternion.Identity));
116 BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr); 116 BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr);
117 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_groundPlane.ptr);
117 // Ground plane does not move 118 // Ground plane does not move
118 BulletSimAPI.ForceActivationState2(m_groundPlane.ptr, ActivationState.DISABLE_SIMULATION); 119 BulletSimAPI.ForceActivationState2(m_groundPlane.ptr, ActivationState.DISABLE_SIMULATION);
119 // Everything collides with the ground plane. 120 // Everything collides with the ground plane.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 24d8db6..5ffd591 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -390,7 +390,7 @@ public enum CollisionFilterGroups : uint
390 VolumeDetectMask = ~BSensorTrigger, 390 VolumeDetectMask = ~BSensorTrigger,
391 TerrainFilter = BTerrainFilter, 391 TerrainFilter = BTerrainFilter,
392 TerrainMask = BAllFilter & ~BStaticFilter, 392 TerrainMask = BAllFilter & ~BStaticFilter,
393 GroundPlaneFilter = BAllFilter, 393 GroundPlaneFilter = BGroundPlaneFilter,
394 GroundPlaneMask = BAllFilter 394 GroundPlaneMask = BAllFilter
395 395
396}; 396};