aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs33
1 files changed, 17 insertions, 16 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 }