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.cs86
1 files changed, 42 insertions, 44 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 3b77e49..103d8fc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -137,7 +137,7 @@ public sealed class BSCharacter : BSPhysObject
137 137
138 private void SetPhysicalProperties() 138 private void SetPhysicalProperties()
139 { 139 {
140 BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); 140 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody);
141 141
142 ZeroMotion(true); 142 ZeroMotion(true);
143 ForcePosition = _position; 143 ForcePosition = _position;
@@ -152,32 +152,32 @@ public sealed class BSCharacter : BSPhysObject
152 // Needs to be reset especially when an avatar is recreated after crossing a region boundry. 152 // Needs to be reset especially when an avatar is recreated after crossing a region boundry.
153 Flying = _flying; 153 Flying = _flying;
154 154
155 BulletSimAPI.SetRestitution2(PhysBody.ptr, BSParam.AvatarRestitution); 155 PhysicsScene.PE.SetRestitution(PhysBody, BSParam.AvatarRestitution);
156 BulletSimAPI.SetMargin2(PhysShape.ptr, PhysicsScene.Params.collisionMargin); 156 PhysicsScene.PE.SetMargin(PhysShape, PhysicsScene.Params.collisionMargin);
157 BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); 157 PhysicsScene.PE.SetLocalScaling(PhysShape, Scale);
158 BulletSimAPI.SetContactProcessingThreshold2(PhysBody.ptr, BSParam.ContactProcessingThreshold); 158 PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
159 if (BSParam.CcdMotionThreshold > 0f) 159 if (BSParam.CcdMotionThreshold > 0f)
160 { 160 {
161 BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold); 161 PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold);
162 BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius); 162 PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius);
163 } 163 }
164 164
165 UpdatePhysicalMassProperties(RawMass, false); 165 UpdatePhysicalMassProperties(RawMass, false);
166 166
167 // Make so capsule does not fall over 167 // Make so capsule does not fall over
168 BulletSimAPI.SetAngularFactorV2(PhysBody.ptr, OMV.Vector3.Zero); 168 PhysicsScene.PE.SetAngularFactorV(PhysBody, OMV.Vector3.Zero);
169 169
170 BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT); 170 PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_CHARACTER_OBJECT);
171 171
172 BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); 172 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody);
173 173
174 // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG); 174 // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG);
175 BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_DEACTIVATION); 175 PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_DEACTIVATION);
176 BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); 176 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody);
177 177
178 // Do this after the object has been added to the world 178 // Do this after the object has been added to the world
179 PhysBody.collisionType = CollisionType.Avatar; 179 PhysBody.collisionType = CollisionType.Avatar;
180 PhysBody.ApplyCollisionMask(); 180 PhysBody.ApplyCollisionMask(PhysicsScene);
181 } 181 }
182 182
183 // The avatar's movement is controlled by this motor that speeds up and slows down 183 // The avatar's movement is controlled by this motor that speeds up and slows down
@@ -210,8 +210,7 @@ public sealed class BSCharacter : BSPhysObject
210 if (!Flying && !IsColliding) 210 if (!Flying && !IsColliding)
211 { 211 {
212 stepVelocity.Z = _velocity.Z; 212 stepVelocity.Z = _velocity.Z;
213 DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", 213 // DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity);
214 LocalID, stepVelocity);
215 } 214 }
216 215
217 // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. 216 // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force.
@@ -231,8 +230,7 @@ public sealed class BSCharacter : BSPhysObject
231 AddForce(moveForce, false, true); 230 AddForce(moveForce, false, true);
232 } 231 }
233 */ 232 */
234 DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", 233 // DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce);
235 LocalID, stepVelocity, _velocity, Mass, moveForce);
236 AddForce(moveForce, false, true); 234 AddForce(moveForce, false, true);
237 }); 235 });
238 } 236 }
@@ -267,10 +265,10 @@ public sealed class BSCharacter : BSPhysObject
267 { 265 {
268 if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape) 266 if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape)
269 { 267 {
270 BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); 268 PhysicsScene.PE.SetLocalScaling(PhysShape, Scale);
271 UpdatePhysicalMassProperties(RawMass, true); 269 UpdatePhysicalMassProperties(RawMass, true);
272 // Make sure this change appears as a property update event 270 // Make sure this change appears as a property update event
273 BulletSimAPI.PushUpdate2(PhysBody.ptr); 271 PhysicsScene.PE.PushUpdate(PhysBody);
274 } 272 }
275 }); 273 });
276 274
@@ -311,7 +309,7 @@ public sealed class BSCharacter : BSPhysObject
311 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() 309 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
312 { 310 {
313 if (PhysBody.HasPhysicalBody) 311 if (PhysBody.HasPhysicalBody)
314 BulletSimAPI.ClearAllForces2(PhysBody.ptr); 312 PhysicsScene.PE.ClearAllForces(PhysBody);
315 }); 313 });
316 } 314 }
317 public override void ZeroAngularMotion(bool inTaintTime) 315 public override void ZeroAngularMotion(bool inTaintTime)
@@ -322,10 +320,10 @@ public sealed class BSCharacter : BSPhysObject
322 { 320 {
323 if (PhysBody.HasPhysicalBody) 321 if (PhysBody.HasPhysicalBody)
324 { 322 {
325 BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); 323 PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, OMV.Vector3.Zero);
326 BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); 324 PhysicsScene.PE.SetAngularVelocity(PhysBody, OMV.Vector3.Zero);
327 // The next also get rid of applied linear force but the linear velocity is untouched. 325 // The next also get rid of applied linear force but the linear velocity is untouched.
328 BulletSimAPI.ClearForces2(PhysBody.ptr); 326 PhysicsScene.PE.ClearForces(PhysBody);
329 } 327 }
330 }); 328 });
331 } 329 }
@@ -341,7 +339,7 @@ public sealed class BSCharacter : BSPhysObject
341 public override OMV.Vector3 Position { 339 public override OMV.Vector3 Position {
342 get { 340 get {
343 // Don't refetch the position because this function is called a zillion times 341 // Don't refetch the position because this function is called a zillion times
344 // _position = BulletSimAPI.GetObjectPosition2(Scene.World.ptr, LocalID); 342 // _position = PhysicsScene.PE.GetObjectPosition(Scene.World, LocalID);
345 return _position; 343 return _position;
346 } 344 }
347 set { 345 set {
@@ -352,19 +350,19 @@ public sealed class BSCharacter : BSPhysObject
352 { 350 {
353 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 351 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
354 if (PhysBody.HasPhysicalBody) 352 if (PhysBody.HasPhysicalBody)
355 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); 353 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
356 }); 354 });
357 } 355 }
358 } 356 }
359 public override OMV.Vector3 ForcePosition { 357 public override OMV.Vector3 ForcePosition {
360 get { 358 get {
361 _position = BulletSimAPI.GetPosition2(PhysBody.ptr); 359 _position = PhysicsScene.PE.GetPosition(PhysBody);
362 return _position; 360 return _position;
363 } 361 }
364 set { 362 set {
365 _position = value; 363 _position = value;
366 PositionSanityCheck(); 364 PositionSanityCheck();
367 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); 365 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
368 } 366 }
369 } 367 }
370 368
@@ -420,7 +418,7 @@ public sealed class BSCharacter : BSPhysObject
420 { 418 {
421 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); 419 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
422 if (PhysBody.HasPhysicalBody) 420 if (PhysBody.HasPhysicalBody)
423 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); 421 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
424 }); 422 });
425 ret = true; 423 ret = true;
426 } 424 }
@@ -435,8 +433,8 @@ public sealed class BSCharacter : BSPhysObject
435 } 433 }
436 public override void UpdatePhysicalMassProperties(float physMass, bool inWorld) 434 public override void UpdatePhysicalMassProperties(float physMass, bool inWorld)
437 { 435 {
438 OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); 436 OMV.Vector3 localInertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape, physMass);
439 BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, localInertia); 437 PhysicsScene.PE.SetMassProps(PhysBody, physMass, localInertia);
440 } 438 }
441 439
442 public override OMV.Vector3 Force { 440 public override OMV.Vector3 Force {
@@ -448,7 +446,7 @@ public sealed class BSCharacter : BSPhysObject
448 { 446 {
449 DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force); 447 DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
450 if (PhysBody.HasPhysicalBody) 448 if (PhysBody.HasPhysicalBody)
451 BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); 449 PhysicsScene.PE.SetObjectForce(PhysBody, _force);
452 }); 450 });
453 } 451 }
454 } 452 }
@@ -522,7 +520,7 @@ public sealed class BSCharacter : BSPhysObject
522 { 520 {
523 _currentFriction = BSParam.AvatarStandingFriction; 521 _currentFriction = BSParam.AvatarStandingFriction;
524 if (PhysBody.HasPhysicalBody) 522 if (PhysBody.HasPhysicalBody)
525 BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction); 523 PhysicsScene.PE.SetFriction(PhysBody, _currentFriction);
526 } 524 }
527 } 525 }
528 else 526 else
@@ -531,12 +529,12 @@ public sealed class BSCharacter : BSPhysObject
531 { 529 {
532 _currentFriction = BSParam.AvatarFriction; 530 _currentFriction = BSParam.AvatarFriction;
533 if (PhysBody.HasPhysicalBody) 531 if (PhysBody.HasPhysicalBody)
534 BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction); 532 PhysicsScene.PE.SetFriction(PhysBody, _currentFriction);
535 } 533 }
536 } 534 }
537 535
538 BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); 536 PhysicsScene.PE.SetLinearVelocity(PhysBody, _velocity);
539 BulletSimAPI.Activate2(PhysBody.ptr, true); 537 PhysicsScene.PE.Activate(PhysBody, true);
540 } 538 }
541 } 539 }
542 public override OMV.Vector3 Torque { 540 public override OMV.Vector3 Torque {
@@ -578,7 +576,7 @@ public sealed class BSCharacter : BSPhysObject
578 { 576 {
579 get 577 get
580 { 578 {
581 _orientation = BulletSimAPI.GetOrientation2(PhysBody.ptr); 579 _orientation = PhysicsScene.PE.GetOrientation(PhysBody);
582 return _orientation; 580 return _orientation;
583 } 581 }
584 set 582 set
@@ -586,8 +584,8 @@ public sealed class BSCharacter : BSPhysObject
586 _orientation = value; 584 _orientation = value;
587 if (PhysBody.HasPhysicalBody) 585 if (PhysBody.HasPhysicalBody)
588 { 586 {
589 // _position = BulletSimAPI.GetPosition2(BSBody.ptr); 587 // _position = PhysicsScene.PE.GetPosition(BSBody);
590 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); 588 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
591 } 589 }
592 } 590 }
593 } 591 }
@@ -638,9 +636,9 @@ public sealed class BSCharacter : BSPhysObject
638 if (PhysBody.HasPhysicalBody) 636 if (PhysBody.HasPhysicalBody)
639 { 637 {
640 if (_floatOnWater) 638 if (_floatOnWater)
641 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); 639 CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
642 else 640 else
643 CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); 641 CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER);
644 } 642 }
645 }); 643 });
646 } 644 }
@@ -678,7 +676,7 @@ public sealed class BSCharacter : BSPhysObject
678 // Buoyancy is faked by changing the gravity applied to the object 676 // Buoyancy is faked by changing the gravity applied to the object
679 float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); 677 float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
680 if (PhysBody.HasPhysicalBody) 678 if (PhysBody.HasPhysicalBody)
681 BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav)); 679 PhysicsScene.PE.SetGravity(PhysBody, new OMV.Vector3(0f, 0f, grav));
682 } 680 }
683 } 681 }
684 682
@@ -736,10 +734,10 @@ public sealed class BSCharacter : BSPhysObject
736 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() 734 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate()
737 { 735 {
738 // Bullet adds this central force to the total force for this tick 736 // Bullet adds this central force to the total force for this tick
739 DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce); 737 // DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce);
740 if (PhysBody.HasPhysicalBody) 738 if (PhysBody.HasPhysicalBody)
741 { 739 {
742 BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce); 740 PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce);
743 } 741 }
744 }); 742 });
745 } 743 }