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.cs35
1 files changed, 22 insertions, 13 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 623ac8f..a041ba8 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -105,7 +105,7 @@ public class BSCharacter : BSPhysObject
105 shapeData.Position = _position; 105 shapeData.Position = _position;
106 shapeData.Rotation = _orientation; 106 shapeData.Rotation = _orientation;
107 shapeData.Velocity = _velocity; 107 shapeData.Velocity = _velocity;
108 shapeData.Size = Scale; 108 shapeData.Size = Scale; // capsule is a native shape but scale is not just <1,1,1>
109 shapeData.Scale = Scale; 109 shapeData.Scale = Scale;
110 shapeData.Mass = _mass; 110 shapeData.Mass = _mass;
111 shapeData.Buoyancy = _buoyancy; 111 shapeData.Buoyancy = _buoyancy;
@@ -144,7 +144,9 @@ public class BSCharacter : BSPhysObject
144 ForcePosition = _position; 144 ForcePosition = _position;
145 // Set the velocity and compute the proper friction 145 // Set the velocity and compute the proper friction
146 ForceVelocity = _velocity; 146 ForceVelocity = _velocity;
147
147 BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.avatarRestitution); 148 BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.avatarRestitution);
149 BulletSimAPI.SetMargin2(BSShape.ptr, PhysicsScene.Params.collisionMargin);
148 BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale); 150 BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale);
149 BulletSimAPI.SetContactProcessingThreshold2(BSBody.ptr, PhysicsScene.Params.contactProcessingThreshold); 151 BulletSimAPI.SetContactProcessingThreshold2(BSBody.ptr, PhysicsScene.Params.contactProcessingThreshold);
150 if (PhysicsScene.Params.ccdMotionThreshold > 0f) 152 if (PhysicsScene.Params.ccdMotionThreshold > 0f)
@@ -156,16 +158,20 @@ public class BSCharacter : BSPhysObject
156 OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw); 158 OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw);
157 BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); 159 BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia);
158 160
161 // Make so capsule does not fall over
162 BulletSimAPI.SetAngularFactorV2(BSBody.ptr, OMV.Vector3.Zero);
163
159 BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT); 164 BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT);
160 165
161 BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr); 166 BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr);
162 167
163 BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG); 168 // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG);
169 BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.DISABLE_DEACTIVATION);
164 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, BSBody.ptr); 170 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, BSBody.ptr);
165 171
166 // Do this after the object has been added to the world 172 // Do this after the object has been added to the world
167 BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr, 173 BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr,
168 (uint)CollisionFilterGroups.AvatarFilter, 174 (uint)CollisionFilterGroups.AvatarFilter,
169 (uint)CollisionFilterGroups.AvatarMask); 175 (uint)CollisionFilterGroups.AvatarMask);
170 } 176 }
171 177
@@ -175,11 +181,13 @@ public class BSCharacter : BSPhysObject
175 } 181 }
176 // No one calls this method so I don't know what it could possibly mean 182 // No one calls this method so I don't know what it could possibly mean
177 public override bool Stopped { get { return false; } } 183 public override bool Stopped { get { return false; } }
184
178 public override OMV.Vector3 Size { 185 public override OMV.Vector3 Size {
179 get 186 get
180 { 187 {
181 // Avatar capsule size is kept in the scale parameter. 188 // Avatar capsule size is kept in the scale parameter.
182 return _size; 189 // return _size;
190 return new OMV.Vector3(Scale.X * 2f, Scale.Y * 2f, Scale.Z);
183 } 191 }
184 192
185 set { 193 set {
@@ -199,7 +207,9 @@ public class BSCharacter : BSPhysObject
199 207
200 } 208 }
201 } 209 }
210
202 public override OMV.Vector3 Scale { get; set; } 211 public override OMV.Vector3 Scale { get; set; }
212
203 public override PrimitiveBaseShape Shape 213 public override PrimitiveBaseShape Shape
204 { 214 {
205 set { BaseShape = value; } 215 set { BaseShape = value; }
@@ -264,12 +274,12 @@ public class BSCharacter : BSPhysObject
264 274
265 275
266 // Check that the current position is sane and, if not, modify the position to make it so. 276 // Check that the current position is sane and, if not, modify the position to make it so.
267 // Check for being below terrain and being out of bounds. 277 // Check for being below terrain or on water.
268 // Returns 'true' of the position was made sane by some action. 278 // Returns 'true' of the position was made sane by some action.
269 private bool PositionSanityCheck() 279 private bool PositionSanityCheck()
270 { 280 {
271 bool ret = false; 281 bool ret = false;
272 282
273 // If below the ground, move the avatar up 283 // If below the ground, move the avatar up
274 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); 284 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position);
275 if (Position.Z < terrainHeight) 285 if (Position.Z < terrainHeight)
@@ -335,7 +345,7 @@ public class BSCharacter : BSPhysObject
335 } 345 }
336 346
337 // Avatars don't do vehicles 347 // Avatars don't do vehicles
338 public override int VehicleType { get { return 0; } set { return; } } 348 public override int VehicleType { get { return (int)Vehicle.TYPE_NONE; } set { return; } }
339 public override void VehicleFloatParam(int param, float value) { } 349 public override void VehicleFloatParam(int param, float value) { }
340 public override void VehicleVectorParam(int param, OMV.Vector3 value) {} 350 public override void VehicleVectorParam(int param, OMV.Vector3 value) {}
341 public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { } 351 public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { }
@@ -413,7 +423,7 @@ public class BSCharacter : BSPhysObject
413 }); 423 });
414 } 424 }
415 } 425 }
416 // Go directly to Bullet to get/set the value. 426 // Go directly to Bullet to get/set the value.
417 public override OMV.Quaternion ForceOrientation 427 public override OMV.Quaternion ForceOrientation
418 { 428 {
419 get 429 get
@@ -478,7 +488,7 @@ public class BSCharacter : BSPhysObject
478 set { _collidingObj = value; } 488 set { _collidingObj = value; }
479 } 489 }
480 public override bool FloatOnWater { 490 public override bool FloatOnWater {
481 set { 491 set {
482 _floatOnWater = value; 492 _floatOnWater = value;
483 PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate() 493 PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate()
484 { 494 {
@@ -588,9 +598,8 @@ public class BSCharacter : BSPhysObject
588 newScale.X = PhysicsScene.Params.avatarCapsuleRadius; 598 newScale.X = PhysicsScene.Params.avatarCapsuleRadius;
589 newScale.Y = PhysicsScene.Params.avatarCapsuleRadius; 599 newScale.Y = PhysicsScene.Params.avatarCapsuleRadius;
590 600
591 // From the total height, remote the capsule half spheres that are at each end 601 // From the total height, remove the capsule half spheres that are at each end
592 newScale.Z = (size.Z * 2f) - Math.Min(newScale.X, newScale.Y); 602 newScale.Z = size.Z- (newScale.X + newScale.Y);
593 // newScale.Z = (size.Z * 2f);
594 Scale = newScale; 603 Scale = newScale;
595 } 604 }
596 605
@@ -636,7 +645,7 @@ public class BSCharacter : BSPhysObject
636 BulletSimAPI.SetLinearVelocity2(BSBody.ptr, avVel); 645 BulletSimAPI.SetLinearVelocity2(BSBody.ptr, avVel);
637 } 646 }
638 647
639 // Tell the linkset about this 648 // Tell the linkset about value changes
640 Linkset.UpdateProperties(this); 649 Linkset.UpdateProperties(this);
641 650
642 // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. 651 // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop.