aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2012-12-30 14:26:57 -0800
committerRobert Adams2012-12-31 19:57:23 -0800
commitc2a7af18b639646b647eb4cdff4168a2b9746ee4 (patch)
treeafe36195792b9990f7defd18bc29791f7527dcff /OpenSim/Region
parentBulletSim: remove all the debug printing of pointer formatting (.ToString(X))... (diff)
downloadopensim-SC_OLD-c2a7af18b639646b647eb4cdff4168a2b9746ee4.zip
opensim-SC_OLD-c2a7af18b639646b647eb4cdff4168a2b9746ee4.tar.gz
opensim-SC_OLD-c2a7af18b639646b647eb4cdff4168a2b9746ee4.tar.bz2
opensim-SC_OLD-c2a7af18b639646b647eb4cdff4168a2b9746ee4.tar.xz
BulletSim: nearly complete in conversion from BulletSimAPI to BSAPITemplate. Only initialization and debug fuctions left.
Diffstat (limited to 'OpenSim/Region')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs418
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs)7
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs34
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs12
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs5
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs11
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs10
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs46
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs2
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs10
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapes.cs6
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs2
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs2
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs4
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs4
15 files changed, 372 insertions, 201 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
index 9a8a2e8..6e68053 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
@@ -34,7 +34,7 @@ using OpenMetaverse;
34 34
35namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.Physics.BulletSPlugin
36{ 36{
37public sealed class BSAPIUnman : BulletSimAPITemplate 37public sealed class BSAPIUnman : BSAPITemplate
38{ 38{
39 /* 39 /*
40// Initialization and simulation 40// Initialization and simulation
@@ -55,8 +55,11 @@ public int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float
55 out int collidersCount, 55 out int collidersCount,
56 out IntPtr collidersPtr); 56 out IntPtr collidersPtr);
57 57
58public bool PushUpdate(BulletBody obj);
59 */ 58 */
59public override bool PushUpdate(BulletBody obj)
60{
61 return BSAPICPP.PushUpdate2(obj.ptr);
62}
60 63
61// ===================================================================================== 64// =====================================================================================
62// Mesh, hull, shape and body creation helper routines 65// Mesh, hull, shape and body creation helper routines
@@ -569,146 +572,332 @@ public override void SetUserPointer(BulletBody obj, IntPtr val)
569 BSAPICPP.SetUserPointer2(obj.ptr, val); 572 BSAPICPP.SetUserPointer2(obj.ptr, val);
570} 573}
571 574
572 /*
573// ===================================================================================== 575// =====================================================================================
574// btRigidBody entries 576// btRigidBody entries
575public override void ApplyGravity(BulletBody obj); 577public override void ApplyGravity(BulletBody obj)
576 578{
577public override void SetGravity(BulletBody obj, Vector3 val); 579 BSAPICPP.ApplyGravity2(obj.ptr);
580}
578 581
579public override Vector3 GetGravity(BulletBody obj); 582public override void SetGravity(BulletBody obj, Vector3 val)
583{
584 BSAPICPP.SetGravity2(obj.ptr, val);
585}
580 586
581public override void SetDamping(BulletBody obj, float lin_damping, float ang_damping); 587public override Vector3 GetGravity(BulletBody obj)
588{
589 return BSAPICPP.GetGravity2(obj.ptr);
590}
582 591
583public override void SetLinearDamping(BulletBody obj, float lin_damping); 592public override void SetDamping(BulletBody obj, float lin_damping, float ang_damping)
593{
594 BSAPICPP.SetDamping2(obj.ptr, lin_damping, ang_damping);
595}
584 596
585public override void SetAngularDamping(BulletBody obj, float ang_damping); 597public override void SetLinearDamping(BulletBody obj, float lin_damping)
598{
599 BSAPICPP.SetLinearDamping2(obj.ptr, lin_damping);
600}
586 601
587public override float GetLinearDamping(BulletBody obj); 602public override void SetAngularDamping(BulletBody obj, float ang_damping)
603{
604 BSAPICPP.SetAngularDamping2(obj.ptr, ang_damping);
605}
588 606
589public override float GetAngularDamping(BulletBody obj); 607public override float GetLinearDamping(BulletBody obj)
608{
609 return BSAPICPP.GetLinearDamping2(obj.ptr);
610}
590 611
591public override float GetLinearSleepingThreshold(BulletBody obj); 612public override float GetAngularDamping(BulletBody obj)
613{
614 return BSAPICPP.GetAngularDamping2(obj.ptr);
615}
592 616
617public override float GetLinearSleepingThreshold(BulletBody obj)
618{
619 return BSAPICPP.GetLinearSleepingThreshold2(obj.ptr);
620}
593 621
594public override void ApplyDamping(BulletBody obj, float timeStep); 622public override void ApplyDamping(BulletBody obj, float timeStep)
623{
624 BSAPICPP.ApplyDamping2(obj.ptr, timeStep);
625}
595 626
596public override void SetMassProps(BulletBody obj, float mass, Vector3 inertia); 627public override void SetMassProps(BulletBody obj, float mass, Vector3 inertia)
628{
629 BSAPICPP.SetMassProps2(obj.ptr, mass, inertia);
630}
597 631
598public override Vector3 GetLinearFactor(BulletBody obj); 632public override Vector3 GetLinearFactor(BulletBody obj)
633{
634 return BSAPICPP.GetLinearFactor2(obj.ptr);
635}
599 636
600public override void SetLinearFactor(BulletBody obj, Vector3 factor); 637public override void SetLinearFactor(BulletBody obj, Vector3 factor)
638{
639 BSAPICPP.SetLinearFactor2(obj.ptr, factor);
640}
601 641
602public override void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot); 642public override void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot)
643{
644 BSAPICPP.SetCenterOfMassByPosRot2(obj.ptr, pos, rot);
645}
603 646
604// Add a force to the object as if its mass is one. 647// Add a force to the object as if its mass is one.
605public override void ApplyCentralForce(BulletBody obj, Vector3 force); 648public override void ApplyCentralForce(BulletBody obj, Vector3 force)
649{
650 BSAPICPP.ApplyCentralForce2(obj.ptr, force);
651}
606 652
607// Set the force being applied to the object as if its mass is one. 653// Set the force being applied to the object as if its mass is one.
608public override void SetObjectForce(BulletBody obj, Vector3 force); 654public override void SetObjectForce(BulletBody obj, Vector3 force)
655{
656 BSAPICPP.SetObjectForce2(obj.ptr, force);
657}
609 658
610public override Vector3 GetTotalForce(BulletBody obj); 659public override Vector3 GetTotalForce(BulletBody obj)
660{
661 return BSAPICPP.GetTotalForce2(obj.ptr);
662}
611 663
612public override Vector3 GetTotalTorque(BulletBody obj); 664public override Vector3 GetTotalTorque(BulletBody obj)
665{
666 return BSAPICPP.GetTotalTorque2(obj.ptr);
667}
613 668
614public override Vector3 GetInvInertiaDiagLocal(BulletBody obj); 669public override Vector3 GetInvInertiaDiagLocal(BulletBody obj)
670{
671 return BSAPICPP.GetInvInertiaDiagLocal2(obj.ptr);
672}
615 673
616public override void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert); 674public override void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert)
675{
676 BSAPICPP.SetInvInertiaDiagLocal2(obj.ptr, inert);
677}
617 678
618public override void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold); 679public override void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold)
680{
681 BSAPICPP.SetSleepingThresholds2(obj.ptr, lin_threshold, ang_threshold);
682}
619 683
620public override void ApplyTorque(BulletBody obj, Vector3 torque); 684public override void ApplyTorque(BulletBody obj, Vector3 torque)
685{
686 BSAPICPP.ApplyTorque2(obj.ptr, torque);
687}
621 688
622// Apply force at the given point. Will add torque to the object. 689// Apply force at the given point. Will add torque to the object.
623public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos); 690public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos)
691{
692 BSAPICPP.ApplyForce2(obj.ptr, force, pos);
693}
624 694
625// Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass. 695// Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass.
626public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp); 696public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp)
697{
698 BSAPICPP.ApplyCentralImpulse2(obj.ptr, imp);
699}
627 700
628// Apply impulse to the object's torque. Force is scaled by object's mass. 701// Apply impulse to the object's torque. Force is scaled by object's mass.
629public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp); 702public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp)
703{
704 BSAPICPP.ApplyTorqueImpulse2(obj.ptr, imp);
705}
630 706
631// Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces. 707// Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces.
632public override void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos); 708public override void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos)
709{
710 BSAPICPP.ApplyImpulse2(obj.ptr, imp, pos);
711}
633 712
634public override void ClearForces(BulletBody obj); 713public override void ClearForces(BulletBody obj)
714{
715 BSAPICPP.ClearForces2(obj.ptr);
716}
635 717
636public override void ClearAllForces(BulletBody obj); 718public override void ClearAllForces(BulletBody obj)
719{
720 BSAPICPP.ClearAllForces2(obj.ptr);
721}
637 722
638public override void UpdateInertiaTensor(BulletBody obj); 723public override void UpdateInertiaTensor(BulletBody obj)
724{
725 BSAPICPP.UpdateInertiaTensor2(obj.ptr);
726}
639 727
640public override Vector3 GetLinearVelocity(BulletBody obj); 728public override Vector3 GetLinearVelocity(BulletBody obj)
729{
730 return BSAPICPP.GetLinearVelocity2(obj.ptr);
731}
641 732
642public override Vector3 GetAngularVelocity(BulletBody obj); 733public override Vector3 GetAngularVelocity(BulletBody obj)
734{
735 return BSAPICPP.GetAngularVelocity2(obj.ptr);
736}
643 737
644public override void SetLinearVelocity(BulletBody obj, Vector3 val); 738public override void SetLinearVelocity(BulletBody obj, Vector3 vel)
739{
740 BSAPICPP.SetLinearVelocity2(obj.ptr, vel);
741}
645 742
646public override void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity); 743public override void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity)
744{
745 BSAPICPP.SetAngularVelocity2(obj.ptr, angularVelocity);
746}
647 747
648public override Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos); 748public override Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos)
749{
750 return BSAPICPP.GetVelocityInLocalPoint2(obj.ptr, pos);
751}
649 752
650public override void Translate(BulletBody obj, Vector3 trans); 753public override void Translate(BulletBody obj, Vector3 trans)
754{
755 BSAPICPP.Translate2(obj.ptr, trans);
756}
651 757
652public override void UpdateDeactivation(BulletBody obj, float timeStep); 758public override void UpdateDeactivation(BulletBody obj, float timeStep)
759{
760 BSAPICPP.UpdateDeactivation2(obj.ptr, timeStep);
761}
653 762
654public override bool WantsSleeping(BulletBody obj); 763public override bool WantsSleeping(BulletBody obj)
764{
765 return BSAPICPP.WantsSleeping2(obj.ptr);
766}
655 767
656public override void SetAngularFactor(BulletBody obj, float factor); 768public override void SetAngularFactor(BulletBody obj, float factor)
769{
770 BSAPICPP.SetAngularFactor2(obj.ptr, factor);
771}
657 772
658public override void SetAngularFactorV(BulletBody obj, Vector3 factor); 773public override void SetAngularFactorV(BulletBody obj, Vector3 factor)
774{
775 BSAPICPP.SetAngularFactorV2(obj.ptr, factor);
776}
659 777
660public override Vector3 GetAngularFactor(BulletBody obj); 778public override Vector3 GetAngularFactor(BulletBody obj)
779{
780 return BSAPICPP.GetAngularFactor2(obj.ptr);
781}
661 782
662public override bool IsInWorld(BulletBody obj); 783public override bool IsInWorld(BulletBody obj)
784{
785 return BSAPICPP.IsInWorld2(obj.ptr);
786}
663 787
664public override void AddConstraintRef(BulletBody obj, BulletConstraint constrain); 788public override void AddConstraintRef(BulletBody obj, BulletConstraint constrain)
789{
790 BSAPICPP.AddConstraintRef2(obj.ptr, constrain.ptr);
791}
665 792
666public override void RemoveConstraintRef(BulletBody obj, BulletConstraint constrain); 793public override void RemoveConstraintRef(BulletBody obj, BulletConstraint constrain)
794{
795 BSAPICPP.RemoveConstraintRef2(obj.ptr, constrain.ptr);
796}
667 797
668public override BulletConstraint GetConstraintRef(BulletBody obj, int index); 798public override BulletConstraint GetConstraintRef(BulletBody obj, int index)
799{
800 return new BulletConstraint(BSAPICPP.GetConstraintRef2(obj.ptr, index));
801}
669 802
670public override int GetNumConstraintRefs(BulletBody obj); 803public override int GetNumConstraintRefs(BulletBody obj)
804{
805 return BSAPICPP.GetNumConstraintRefs2(obj.ptr);
806}
671 807
672public override bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask); 808public override bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask)
809{
810 return BSAPICPP.SetCollisionGroupMask2(body.ptr, filter, mask);
811}
673 812
674// ===================================================================================== 813// =====================================================================================
675// btCollisionShape entries 814// btCollisionShape entries
676 815
677public override float GetAngularMotionDisc(BulletShape shape); 816public override float GetAngularMotionDisc(BulletShape shape)
817{
818 return BSAPICPP.GetAngularMotionDisc2(shape.ptr);
819}
678 820
679public override float GetContactBreakingThreshold(BulletShape shape, float defaultFactor); 821public override float GetContactBreakingThreshold(BulletShape shape, float defaultFactor)
822{
823 return BSAPICPP.GetContactBreakingThreshold2(shape.ptr, defaultFactor);
824}
680 825
681public override bool IsPolyhedral(BulletShape shape); 826public override bool IsPolyhedral(BulletShape shape)
827{
828 return BSAPICPP.IsPolyhedral2(shape.ptr);
829}
682 830
683public override bool IsConvex2d(BulletShape shape); 831public override bool IsConvex2d(BulletShape shape)
832{
833 return BSAPICPP.IsConvex2d2(shape.ptr);
834}
684 835
685public override bool IsConvex(BulletShape shape); 836public override bool IsConvex(BulletShape shape)
837{
838 return BSAPICPP.IsConvex2(shape.ptr);
839}
686 840
687public override bool IsNonMoving(BulletShape shape); 841public override bool IsNonMoving(BulletShape shape)
842{
843 return BSAPICPP.IsNonMoving2(shape.ptr);
844}
688 845
689public override bool IsConcave(BulletShape shape); 846public override bool IsConcave(BulletShape shape)
847{
848 return BSAPICPP.IsConcave2(shape.ptr);
849}
690 850
691public override bool IsCompound(BulletShape shape); 851public override bool IsCompound(BulletShape shape)
852{
853 return BSAPICPP.IsCompound2(shape.ptr);
854}
692 855
693public override bool IsSoftBody(BulletShape shape); 856public override bool IsSoftBody(BulletShape shape)
857{
858 return BSAPICPP.IsSoftBody2(shape.ptr);
859}
694 860
695public override bool IsInfinite(BulletShape shape); 861public override bool IsInfinite(BulletShape shape)
862{
863 return BSAPICPP.IsInfinite2(shape.ptr);
864}
696 865
697public override void SetLocalScaling(BulletShape shape, Vector3 scale); 866public override void SetLocalScaling(BulletShape shape, Vector3 scale)
867{
868 BSAPICPP.SetLocalScaling2(shape.ptr, scale);
869}
698 870
699public override Vector3 GetLocalScaling(BulletShape shape); 871public override Vector3 GetLocalScaling(BulletShape shape)
872{
873 return BSAPICPP.GetLocalScaling2(shape.ptr);
874}
700 875
701public override Vector3 CalculateLocalInertia(BulletShape shape, float mass); 876public override Vector3 CalculateLocalInertia(BulletShape shape, float mass)
877{
878 return BSAPICPP.CalculateLocalInertia2(shape.ptr, mass);
879}
702 880
703public override int GetShapeType(BulletShape shape); 881public override int GetShapeType(BulletShape shape)
882{
883 return BSAPICPP.GetShapeType2(shape.ptr);
884}
704 885
705public override void SetMargin(BulletShape shape, float val); 886public override void SetMargin(BulletShape shape, float val)
887{
888 BSAPICPP.SetMargin2(shape.ptr, val);
889}
706 890
707public override float GetMargin(BulletShape shape); 891public override float GetMargin(BulletShape shape)
708 */ 892{
893 return BSAPICPP.GetMargin2(shape.ptr);
894}
709 895
710static class BSAPICPP 896static class BSAPICPP
711{ 897{
898[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
899public static extern bool PushUpdate2(IntPtr obj);
900
712// ===================================================================================== 901// =====================================================================================
713// Mesh, hull, shape and body creation helper routines 902// Mesh, hull, shape and body creation helper routines
714[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 903[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -1029,55 +1218,6 @@ public static extern IntPtr GetUserPointer2(IntPtr obj);
1029[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1218[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1030public static extern void SetUserPointer2(IntPtr obj, IntPtr val); 1219public static extern void SetUserPointer2(IntPtr obj, IntPtr val);
1031 1220
1032}
1033}
1034
1035// ===============================================================================
1036// ===============================================================================
1037// ===============================================================================
1038// ===============================================================================
1039// ===============================================================================
1040// ===============================================================================
1041// ===============================================================================
1042// ===============================================================================
1043// ===============================================================================
1044// ===============================================================================
1045// ===============================================================================
1046// ===============================================================================
1047// ===============================================================================
1048static class BulletSimAPI {
1049// ===============================================================================
1050// Link back to the managed code for outputting log messages
1051[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
1052public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
1053
1054// ===============================================================================
1055// Initialization and simulation
1056[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1057public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
1058 int maxCollisions, IntPtr collisionArray,
1059 int maxUpdates, IntPtr updateArray,
1060 DebugLogCallback logRoutine);
1061
1062[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1063public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
1064
1065[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1066public static extern void SetHeightMap2(IntPtr world, float[] heightmap);
1067
1068[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1069public static extern void Shutdown2(IntPtr sim);
1070
1071[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1072public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep,
1073 out int updatedEntityCount,
1074 out IntPtr updatedEntitiesPtr,
1075 out int collidersCount,
1076 out IntPtr collidersPtr);
1077
1078[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1079public static extern bool PushUpdate2(IntPtr obj);
1080
1081// ===================================================================================== 1221// =====================================================================================
1082// btRigidBody entries 1222// btRigidBody entries
1083[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1223[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -1291,6 +1431,52 @@ public static extern void SetMargin2(IntPtr shape, float val);
1291[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1431[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1292public static extern float GetMargin2(IntPtr shape); 1432public static extern float GetMargin2(IntPtr shape);
1293 1433
1434}
1435}
1436
1437// ===============================================================================
1438// ===============================================================================
1439// ===============================================================================
1440// ===============================================================================
1441// ===============================================================================
1442// ===============================================================================
1443// ===============================================================================
1444// ===============================================================================
1445// ===============================================================================
1446// ===============================================================================
1447// ===============================================================================
1448// ===============================================================================
1449// ===============================================================================
1450static class BulletSimAPI {
1451// ===============================================================================
1452// Link back to the managed code for outputting log messages
1453[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
1454public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
1455
1456// ===============================================================================
1457// Initialization and simulation
1458[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1459public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
1460 int maxCollisions, IntPtr collisionArray,
1461 int maxUpdates, IntPtr updateArray,
1462 DebugLogCallback logRoutine);
1463
1464[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1465public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
1466
1467[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1468public static extern void SetHeightMap2(IntPtr world, float[] heightmap);
1469
1470[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1471public static extern void Shutdown2(IntPtr sim);
1472
1473[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
1474public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep,
1475 out int updatedEntityCount,
1476 out IntPtr updatedEntitiesPtr,
1477 out int collidersCount,
1478 out IntPtr collidersPtr);
1479
1294// ===================================================================================== 1480// =====================================================================================
1295// Debugging 1481// Debugging
1296[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 1482[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
index b119f22..fbf362d 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs
@@ -290,7 +290,7 @@ public enum ConstraintParamAxis : int
290 AXIS_ALL 290 AXIS_ALL
291}; 291};
292 292
293public abstract class BulletSimAPITemplate 293public abstract class BSAPITemplate
294{ 294{
295 /* 295 /*
296// Initialization and simulation 296// Initialization and simulation
@@ -311,8 +311,8 @@ public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSte
311 out int collidersCount, 311 out int collidersCount,
312 out IntPtr collidersPtr); 312 out IntPtr collidersPtr);
313 313
314public abstract bool PushUpdate(BulletBody obj);
315 */ 314 */
315public abstract bool PushUpdate(BulletBody obj);
316 316
317// ===================================================================================== 317// =====================================================================================
318// Mesh, hull, shape and body creation helper routines 318// Mesh, hull, shape and body creation helper routines
@@ -525,7 +525,6 @@ public abstract IntPtr GetUserPointer(BulletBody obj);
525 525
526public abstract void SetUserPointer(BulletBody obj, IntPtr val); 526public abstract void SetUserPointer(BulletBody obj, IntPtr val);
527 527
528 /*
529// ===================================================================================== 528// =====================================================================================
530// btRigidBody entries 529// btRigidBody entries
531public abstract void ApplyGravity(BulletBody obj); 530public abstract void ApplyGravity(BulletBody obj);
@@ -546,7 +545,6 @@ public abstract float GetAngularDamping(BulletBody obj);
546 545
547public abstract float GetLinearSleepingThreshold(BulletBody obj); 546public abstract float GetLinearSleepingThreshold(BulletBody obj);
548 547
549
550public abstract void ApplyDamping(BulletBody obj, float timeStep); 548public abstract void ApplyDamping(BulletBody obj, float timeStep);
551 549
552public abstract void SetMassProps(BulletBody obj, float mass, Vector3 inertia); 550public abstract void SetMassProps(BulletBody obj, float mass, Vector3 inertia);
@@ -661,7 +659,6 @@ public abstract int GetShapeType(BulletShape shape);
661public abstract void SetMargin(BulletShape shape, float val); 659public abstract void SetMargin(BulletShape shape, float val);
662 660
663public abstract float GetMargin(BulletShape shape); 661public abstract float GetMargin(BulletShape shape);
664 */
665 662
666}; 663};
667} 664}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 328164b..103d8fc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -153,8 +153,8 @@ public sealed class BSCharacter : BSPhysObject
153 Flying = _flying; 153 Flying = _flying;
154 154
155 PhysicsScene.PE.SetRestitution(PhysBody, 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 PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); 158 PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
159 if (BSParam.CcdMotionThreshold > 0f) 159 if (BSParam.CcdMotionThreshold > 0f)
160 { 160 {
@@ -165,19 +165,19 @@ public sealed class BSCharacter : BSPhysObject
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 PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_CHARACTER_OBJECT); 170 PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_CHARACTER_OBJECT);
171 171
172 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody); 172 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody);
173 173
174 // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG); 174 // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG);
175 PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_DEACTIVATION); 175 PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_DEACTIVATION);
176 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody); 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
@@ -265,10 +265,10 @@ public sealed class BSCharacter : BSPhysObject
265 { 265 {
266 if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape) 266 if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape)
267 { 267 {
268 BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); 268 PhysicsScene.PE.SetLocalScaling(PhysShape, Scale);
269 UpdatePhysicalMassProperties(RawMass, true); 269 UpdatePhysicalMassProperties(RawMass, true);
270 // Make sure this change appears as a property update event 270 // Make sure this change appears as a property update event
271 BulletSimAPI.PushUpdate2(PhysBody.ptr); 271 PhysicsScene.PE.PushUpdate(PhysBody);
272 } 272 }
273 }); 273 });
274 274
@@ -309,7 +309,7 @@ public sealed class BSCharacter : BSPhysObject
309 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() 309 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
310 { 310 {
311 if (PhysBody.HasPhysicalBody) 311 if (PhysBody.HasPhysicalBody)
312 BulletSimAPI.ClearAllForces2(PhysBody.ptr); 312 PhysicsScene.PE.ClearAllForces(PhysBody);
313 }); 313 });
314 } 314 }
315 public override void ZeroAngularMotion(bool inTaintTime) 315 public override void ZeroAngularMotion(bool inTaintTime)
@@ -321,9 +321,9 @@ public sealed class BSCharacter : BSPhysObject
321 if (PhysBody.HasPhysicalBody) 321 if (PhysBody.HasPhysicalBody)
322 { 322 {
323 PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, OMV.Vector3.Zero); 323 PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, OMV.Vector3.Zero);
324 BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); 324 PhysicsScene.PE.SetAngularVelocity(PhysBody, OMV.Vector3.Zero);
325 // 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.
326 BulletSimAPI.ClearForces2(PhysBody.ptr); 326 PhysicsScene.PE.ClearForces(PhysBody);
327 } 327 }
328 }); 328 });
329 } 329 }
@@ -339,7 +339,7 @@ public sealed class BSCharacter : BSPhysObject
339 public override OMV.Vector3 Position { 339 public override OMV.Vector3 Position {
340 get { 340 get {
341 // 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
342 // _position = BulletSimAPI.GetObjectPosition2(Scene.World.ptr, LocalID); 342 // _position = PhysicsScene.PE.GetObjectPosition(Scene.World, LocalID);
343 return _position; 343 return _position;
344 } 344 }
345 set { 345 set {
@@ -433,8 +433,8 @@ public sealed class BSCharacter : BSPhysObject
433 } 433 }
434 public override void UpdatePhysicalMassProperties(float physMass, bool inWorld) 434 public override void UpdatePhysicalMassProperties(float physMass, bool inWorld)
435 { 435 {
436 OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); 436 OMV.Vector3 localInertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape, physMass);
437 BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, localInertia); 437 PhysicsScene.PE.SetMassProps(PhysBody, physMass, localInertia);
438 } 438 }
439 439
440 public override OMV.Vector3 Force { 440 public override OMV.Vector3 Force {
@@ -446,7 +446,7 @@ public sealed class BSCharacter : BSPhysObject
446 { 446 {
447 DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force); 447 DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
448 if (PhysBody.HasPhysicalBody) 448 if (PhysBody.HasPhysicalBody)
449 BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); 449 PhysicsScene.PE.SetObjectForce(PhysBody, _force);
450 }); 450 });
451 } 451 }
452 } 452 }
@@ -533,7 +533,7 @@ public sealed class BSCharacter : BSPhysObject
533 } 533 }
534 } 534 }
535 535
536 BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); 536 PhysicsScene.PE.SetLinearVelocity(PhysBody, _velocity);
537 PhysicsScene.PE.Activate(PhysBody, true); 537 PhysicsScene.PE.Activate(PhysBody, true);
538 } 538 }
539 } 539 }
@@ -676,7 +676,7 @@ public sealed class BSCharacter : BSPhysObject
676 // Buoyancy is faked by changing the gravity applied to the object 676 // Buoyancy is faked by changing the gravity applied to the object
677 float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); 677 float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
678 if (PhysBody.HasPhysicalBody) 678 if (PhysBody.HasPhysicalBody)
679 BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav)); 679 PhysicsScene.PE.SetGravity(PhysBody, new OMV.Vector3(0f, 0f, grav));
680 } 680 }
681 } 681 }
682 682
@@ -737,7 +737,7 @@ public sealed class BSCharacter : BSPhysObject
737 // DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce); 737 // DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce);
738 if (PhysBody.HasPhysicalBody) 738 if (PhysBody.HasPhysicalBody)
739 { 739 {
740 BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce); 740 PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce);
741 } 741 }
742 }); 742 });
743 } 743 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 5d70ef7..e4e3edc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -564,17 +564,17 @@ namespace OpenSim.Region.Physics.BulletSPlugin
564 // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. 564 // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle.
565 // Maybe compute linear and angular factor and damping from params. 565 // Maybe compute linear and angular factor and damping from params.
566 float angularDamping = BSParam.VehicleAngularDamping; 566 float angularDamping = BSParam.VehicleAngularDamping;
567 BulletSimAPI.SetAngularDamping2(Prim.PhysBody.ptr, angularDamping); 567 PhysicsScene.PE.SetAngularDamping(Prim.PhysBody, angularDamping);
568 568
569 // Vehicles report collision events so we know when it's on the ground 569 // Vehicles report collision events so we know when it's on the ground
570 PhysicsScene.PE.AddToCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); 570 PhysicsScene.PE.AddToCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS);
571 571
572 Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(Prim.PhysShape.ptr, m_vehicleMass); 572 Vector3 localInertia = PhysicsScene.PE.CalculateLocalInertia(Prim.PhysShape, m_vehicleMass);
573 BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia); 573 PhysicsScene.PE.SetMassProps(Prim.PhysBody, m_vehicleMass, localInertia);
574 BulletSimAPI.UpdateInertiaTensor2(Prim.PhysBody.ptr); 574 PhysicsScene.PE.UpdateInertiaTensor(Prim.PhysBody);
575 575
576 Vector3 grav = PhysicsScene.DefaultGravity * (1f - Prim.Buoyancy); 576 Vector3 grav = PhysicsScene.DefaultGravity * (1f - Prim.Buoyancy);
577 BulletSimAPI.SetGravity2(Prim.PhysBody.ptr, grav); 577 PhysicsScene.PE.SetGravity(Prim.PhysBody, grav);
578 578
579 VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4}", 579 VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4}",
580 Prim.LocalID, m_vehicleMass, friction, localInertia, angularDamping); 580 Prim.LocalID, m_vehicleMass, friction, localInertia, angularDamping);
@@ -669,7 +669,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
669 669
670 // If we set one of the values (ie, the physics engine didn't do it) we must force 670 // If we set one of the values (ie, the physics engine didn't do it) we must force
671 // an UpdateProperties event to send the changes up to the simulator. 671 // an UpdateProperties event to send the changes up to the simulator.
672 BulletSimAPI.PushUpdate2(Prim.PhysBody.ptr); 672 PhysicsScene.PE.PushUpdate(Prim.PhysBody);
673 } 673 }
674 m_knownChanged = 0; 674 m_knownChanged = 0;
675 } 675 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 143c60c..bd03d31 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -387,11 +387,6 @@ public sealed class BSLinksetCompound : BSLinkset
387 } 387 }
388 388
389 PhysicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape); 389 PhysicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape);
390
391 // DEBUG: see of inter-linkset collisions are causing problems for constraint linksets.
392 // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr,
393 // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask);
394
395 } 390 }
396} 391}
397} \ No newline at end of file 392} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
index 629bc72..d0b2a56 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs
@@ -259,7 +259,7 @@ public sealed class BSLinksetConstraints : BSLinkset
259 if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) 259 if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody))
260 { 260 {
261 // Make the child refresh its location 261 // Make the child refresh its location
262 BulletSimAPI.PushUpdate2(childPrim.PhysBody.ptr); 262 PhysicsScene.PE.PushUpdate(childPrim.PhysBody);
263 ret = true; 263 ret = true;
264 } 264 }
265 265
@@ -286,9 +286,6 @@ public sealed class BSLinksetConstraints : BSLinkset
286 float linksetMass = LinksetMass; 286 float linksetMass = LinksetMass;
287 LinksetRoot.UpdatePhysicalMassProperties(linksetMass, true); 287 LinksetRoot.UpdatePhysicalMassProperties(linksetMass, true);
288 288
289 // DEBUG: see of inter-linkset collisions are causing problems
290 // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr,
291 // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask);
292 DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", 289 DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}",
293 LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass); 290 LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass);
294 291
@@ -307,11 +304,7 @@ public sealed class BSLinksetConstraints : BSLinkset
307 } 304 }
308 constrain.RecomputeConstraintVariables(linksetMass); 305 constrain.RecomputeConstraintVariables(linksetMass);
309 306
310 // DEBUG: see of inter-linkset collisions are causing problems 307 // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG
311 // BulletSimAPI.SetCollisionFilterMask2(child.BSBody.ptr,
312 // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask);
313
314 // BulletSimAPI.DumpConstraint2(PhysicsScene.World.ptr, constrain.Constraint.ptr); // DEBUG DEBUG
315 } 308 }
316 309
317 } 310 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index c6c2946..339722e 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -280,7 +280,7 @@ public static class BSParam
280 (s,cf,p,v) => { s.UnmanagedParams[0].gravity = cf.GetFloat(p, v); }, 280 (s,cf,p,v) => { s.UnmanagedParams[0].gravity = cf.GetFloat(p, v); },
281 (s) => { return s.UnmanagedParams[0].gravity; }, 281 (s) => { return s.UnmanagedParams[0].gravity; },
282 (s,p,l,v) => { s.UpdateParameterObject((x)=>{s.UnmanagedParams[0].gravity=x;}, p, PhysParameterEntry.APPLY_TO_NONE, v); }, 282 (s,p,l,v) => { s.UpdateParameterObject((x)=>{s.UnmanagedParams[0].gravity=x;}, p, PhysParameterEntry.APPLY_TO_NONE, v); },
283 (s,o,v) => { BulletSimAPI.SetGravity2(s.World.ptr, new Vector3(0f,0f,v)); } ), 283 (s,o,v) => { s.PE.SetGravity(o.PhysBody, new Vector3(0f,0f,v)); } ),
284 284
285 285
286 new ParameterDefn("LinearDamping", "Factor to damp linear movement per second (0.0 - 1.0)", 286 new ParameterDefn("LinearDamping", "Factor to damp linear movement per second (0.0 - 1.0)",
@@ -288,13 +288,13 @@ public static class BSParam
288 (s,cf,p,v) => { LinearDamping = cf.GetFloat(p, v); }, 288 (s,cf,p,v) => { LinearDamping = cf.GetFloat(p, v); },
289 (s) => { return LinearDamping; }, 289 (s) => { return LinearDamping; },
290 (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearDamping=x;}, p, l, v); }, 290 (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearDamping=x;}, p, l, v); },
291 (s,o,v) => { BulletSimAPI.SetDamping2(o.PhysBody.ptr, v, AngularDamping); } ), 291 (s,o,v) => { s.PE.SetDamping(o.PhysBody, v, AngularDamping); } ),
292 new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)", 292 new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)",
293 0f, 293 0f,
294 (s,cf,p,v) => { AngularDamping = cf.GetFloat(p, v); }, 294 (s,cf,p,v) => { AngularDamping = cf.GetFloat(p, v); },
295 (s) => { return AngularDamping; }, 295 (s) => { return AngularDamping; },
296 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularDamping=x;}, p, l, v); }, 296 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularDamping=x;}, p, l, v); },
297 (s,o,v) => { BulletSimAPI.SetDamping2(o.PhysBody.ptr, LinearDamping, v); } ), 297 (s,o,v) => { s.PE.SetDamping(o.PhysBody, LinearDamping, v); } ),
298 new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static", 298 new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static",
299 0.2f, 299 0.2f,
300 (s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); }, 300 (s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); },
@@ -306,13 +306,13 @@ public static class BSParam
306 (s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); }, 306 (s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); },
307 (s) => { return LinearSleepingThreshold; }, 307 (s) => { return LinearSleepingThreshold; },
308 (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearSleepingThreshold=x;}, p, l, v); }, 308 (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearSleepingThreshold=x;}, p, l, v); },
309 (s,o,v) => { BulletSimAPI.SetSleepingThresholds2(o.PhysBody.ptr, v, v); } ), 309 (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
310 new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static", 310 new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static",
311 1.0f, 311 1.0f,
312 (s,cf,p,v) => { AngularSleepingThreshold = cf.GetFloat(p, v); }, 312 (s,cf,p,v) => { AngularSleepingThreshold = cf.GetFloat(p, v); },
313 (s) => { return AngularSleepingThreshold; }, 313 (s) => { return AngularSleepingThreshold; },
314 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); }, 314 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); },
315 (s,o,v) => { BulletSimAPI.SetSleepingThresholds2(o.PhysBody.ptr, v, v); } ), 315 (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
316 new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , 316 new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ,
317 0f, // set to zero to disable 317 0f, // set to zero to disable
318 (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); }, 318 (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); },
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 613606f..064ce3c 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -253,7 +253,7 @@ public sealed class BSPrim : BSPhysObject
253 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() 253 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate()
254 { 254 {
255 if (PhysBody.HasPhysicalBody) 255 if (PhysBody.HasPhysicalBody)
256 BulletSimAPI.ClearAllForces2(PhysBody.ptr); 256 PhysicsScene.PE.ClearAllForces(PhysBody);
257 }); 257 });
258 } 258 }
259 public override void ZeroAngularMotion(bool inTaintTime) 259 public override void ZeroAngularMotion(bool inTaintTime)
@@ -266,7 +266,7 @@ public sealed class BSPrim : BSPhysObject
266 if (PhysBody.HasPhysicalBody) 266 if (PhysBody.HasPhysicalBody)
267 { 267 {
268 PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); 268 PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
269 BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); 269 PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
270 } 270 }
271 }); 271 });
272 } 272 }
@@ -292,7 +292,7 @@ public sealed class BSPrim : BSPhysObject
292 */ 292 */
293 293
294 // don't do the GetObjectPosition for root elements because this function is called a zillion times. 294 // don't do the GetObjectPosition for root elements because this function is called a zillion times.
295 // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); 295 // _position = PhysicsScene.PE.GetObjectPosition2(PhysicsScene.World, BSBody);
296 return _position; 296 return _position;
297 } 297 }
298 set { 298 set {
@@ -405,10 +405,10 @@ public sealed class BSPrim : BSPhysObject
405 { 405 {
406 if (IsStatic) 406 if (IsStatic)
407 { 407 {
408 BulletSimAPI.SetGravity2(PhysBody.ptr, PhysicsScene.DefaultGravity); 408 PhysicsScene.PE.SetGravity(PhysBody, PhysicsScene.DefaultGravity);
409 Inertia = OMV.Vector3.Zero; 409 Inertia = OMV.Vector3.Zero;
410 BulletSimAPI.SetMassProps2(PhysBody.ptr, 0f, Inertia); 410 PhysicsScene.PE.SetMassProps(PhysBody, 0f, Inertia);
411 BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); 411 PhysicsScene.PE.UpdateInertiaTensor(PhysBody);
412 } 412 }
413 else 413 else
414 { 414 {
@@ -423,14 +423,14 @@ public sealed class BSPrim : BSPhysObject
423 } 423 }
424 424
425 // The computation of mass props requires gravity to be set on the object. 425 // The computation of mass props requires gravity to be set on the object.
426 BulletSimAPI.SetGravity2(PhysBody.ptr, grav); 426 PhysicsScene.PE.SetGravity(PhysBody, grav);
427 427
428 Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); 428 Inertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape, physMass);
429 BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia); 429 PhysicsScene.PE.SetMassProps(PhysBody, physMass, Inertia);
430 BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); 430 PhysicsScene.PE.UpdateInertiaTensor(PhysBody);
431 431
432 // center of mass is at the zero of the object 432 // center of mass is at the zero of the object
433 // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation); 433 // DEBUG DEBUG PhysicsScene.PE.SetCenterOfMassByPosRot(PhysBody, ForcePosition, ForceOrientation);
434 DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", LocalID, physMass, Inertia, grav, inWorld); 434 DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", LocalID, physMass, Inertia, grav, inWorld);
435 435
436 if (inWorld) 436 if (inWorld)
@@ -440,7 +440,7 @@ public sealed class BSPrim : BSPhysObject
440 440
441 // Must set gravity after it has been added to the world because, for unknown reasons, 441 // Must set gravity after it has been added to the world because, for unknown reasons,
442 // adding the object resets the object's gravity to world gravity 442 // adding the object resets the object's gravity to world gravity
443 BulletSimAPI.SetGravity2(PhysBody.ptr, grav); 443 PhysicsScene.PE.SetGravity(PhysBody, grav);
444 444
445 } 445 }
446 } 446 }
@@ -483,7 +483,7 @@ public sealed class BSPrim : BSPhysObject
483 DetailLog("{0},BSPrim.setForce,preStep,force={1}", LocalID, _force); 483 DetailLog("{0},BSPrim.setForce,preStep,force={1}", LocalID, _force);
484 if (PhysBody.HasPhysicalBody) 484 if (PhysBody.HasPhysicalBody)
485 { 485 {
486 BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, _force); 486 PhysicsScene.PE.ApplyCentralForce(PhysBody, _force);
487 ActivateIfPhysical(false); 487 ActivateIfPhysical(false);
488 } 488 }
489 } 489 }
@@ -583,7 +583,7 @@ public sealed class BSPrim : BSPhysObject
583 _velocity = value; 583 _velocity = value;
584 if (PhysBody.HasPhysicalBody) 584 if (PhysBody.HasPhysicalBody)
585 { 585 {
586 BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); 586 PhysicsScene.PE.SetLinearVelocity(PhysBody, _velocity);
587 ActivateIfPhysical(false); 587 ActivateIfPhysical(false);
588 } 588 }
589 } 589 }
@@ -809,7 +809,7 @@ public sealed class BSPrim : BSPhysObject
809 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); 809 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
810 810
811 // Center of mass is at the center of the object 811 // Center of mass is at the center of the object
812 // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody, _position, _orientation); 812 // DEBUG DEBUG PhysicsScene.PE.SetCenterOfMassByPosRot(Linkset.LinksetRoot.PhysBody, _position, _orientation);
813 813
814 // A dynamic object has mass 814 // A dynamic object has mass
815 UpdatePhysicalMassProperties(RawMass, false); 815 UpdatePhysicalMassProperties(RawMass, false);
@@ -822,9 +822,9 @@ public sealed class BSPrim : BSPhysObject
822 } 822 }
823 823
824 // Various values for simulation limits 824 // Various values for simulation limits
825 BulletSimAPI.SetDamping2(PhysBody.ptr, BSParam.LinearDamping, BSParam.AngularDamping); 825 PhysicsScene.PE.SetDamping(PhysBody, BSParam.LinearDamping, BSParam.AngularDamping);
826 PhysicsScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime); 826 PhysicsScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime);
827 BulletSimAPI.SetSleepingThresholds2(PhysBody.ptr, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold); 827 PhysicsScene.PE.SetSleepingThresholds(PhysBody, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold);
828 PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); 828 PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold);
829 829
830 // This collides like an object. 830 // This collides like an object.
@@ -901,10 +901,10 @@ public sealed class BSPrim : BSPhysObject
901 901
902 // TODO: Fix this. Total kludge because adding object to world resets its gravity to default. 902 // TODO: Fix this. Total kludge because adding object to world resets its gravity to default.
903 // Replace this when the new AddObjectToWorld function is complete. 903 // Replace this when the new AddObjectToWorld function is complete.
904 BulletSimAPI.SetGravity2(PhysBody.ptr, ComputeGravity()); 904 PhysicsScene.PE.SetGravity(PhysBody, ComputeGravity());
905 905
906 // Collision filter can be set only when the object is in the world 906 // Collision filter can be set only when the object is in the world
907 if (!PhysBody.ApplyCollisionMask()) 907 if (!PhysBody.ApplyCollisionMask(PhysicsScene))
908 { 908 {
909 m_log.ErrorFormat("{0} Failed setting object collision mask: id={1}", LogHeader, LocalID); 909 m_log.ErrorFormat("{0} Failed setting object collision mask: id={1}", LogHeader, LocalID);
910 DetailLog("{0},BSPrim.UpdatePhysicalParameters,failedSetMaskGroup,cType={1}", LocalID, PhysBody.collisionType); 910 DetailLog("{0},BSPrim.UpdatePhysicalParameters,failedSetMaskGroup,cType={1}", LocalID, PhysBody.collisionType);
@@ -969,7 +969,7 @@ public sealed class BSPrim : BSPhysObject
969 _rotationalVelocity = value; 969 _rotationalVelocity = value;
970 if (PhysBody.HasPhysicalBody) 970 if (PhysBody.HasPhysicalBody)
971 { 971 {
972 BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); 972 PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
973 ActivateIfPhysical(false); 973 ActivateIfPhysical(false);
974 } 974 }
975 } 975 }
@@ -1061,7 +1061,7 @@ public sealed class BSPrim : BSPhysObject
1061 DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce); 1061 DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce);
1062 if (PhysBody.HasPhysicalBody) 1062 if (PhysBody.HasPhysicalBody)
1063 { 1063 {
1064 BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce); 1064 PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce);
1065 ActivateIfPhysical(false); 1065 ActivateIfPhysical(false);
1066 } 1066 }
1067 }); 1067 });
@@ -1085,7 +1085,7 @@ public sealed class BSPrim : BSPhysObject
1085 { 1085 {
1086 if (PhysBody.HasPhysicalBody) 1086 if (PhysBody.HasPhysicalBody)
1087 { 1087 {
1088 BulletSimAPI.ApplyTorque2(PhysBody.ptr, angForce); 1088 PhysicsScene.PE.ApplyTorque(PhysBody, angForce);
1089 ActivateIfPhysical(false); 1089 ActivateIfPhysical(false);
1090 } 1090 }
1091 }); 1091 });
@@ -1108,7 +1108,7 @@ public sealed class BSPrim : BSPhysObject
1108 { 1108 {
1109 if (PhysBody.HasPhysicalBody) 1109 if (PhysBody.HasPhysicalBody)
1110 { 1110 {
1111 BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse); 1111 PhysicsScene.PE.ApplyTorqueImpulse(PhysBody, applyImpulse);
1112 ActivateIfPhysical(false); 1112 ActivateIfPhysical(false);
1113 } 1113 }
1114 }); 1114 });
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index bfc9df2..28c6680 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -51,7 +51,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
51 public string BulletSimVersion = "?"; 51 public string BulletSimVersion = "?";
52 52
53 // The handle to the underlying managed or unmanaged version of Bullet being used. 53 // The handle to the underlying managed or unmanaged version of Bullet being used.
54 public BulletSimAPITemplate PE; 54 public BSAPITemplate PE;
55 55
56 public Dictionary<uint, BSPhysObject> PhysObjects; 56 public Dictionary<uint, BSPhysObject> PhysObjects;
57 public BSShapeCollection Shapes; 57 public BSShapeCollection Shapes;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index d59e455..cd77581 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -141,7 +141,7 @@ public sealed class BSShapeCollection : IDisposable
141 if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body); 141 if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body);
142 PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.ReferenceBody", delegate() 142 PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.ReferenceBody", delegate()
143 { 143 {
144 if (!BulletSimAPI.IsInWorld2(body.ptr)) 144 if (!PhysicsScene.PE.IsInWorld(body))
145 { 145 {
146 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body); 146 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body);
147 if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body); 147 if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body);
@@ -166,7 +166,7 @@ public sealed class BSShapeCollection : IDisposable
166 // If the caller needs to know the old body is going away, pass the event up. 166 // If the caller needs to know the old body is going away, pass the event up.
167 if (bodyCallback != null) bodyCallback(body); 167 if (bodyCallback != null) bodyCallback(body);
168 168
169 if (BulletSimAPI.IsInWorld2(body.ptr)) 169 if (PhysicsScene.PE.IsInWorld(body))
170 { 170 {
171 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body); 171 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body);
172 if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body); 172 if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body);
@@ -332,7 +332,7 @@ public sealed class BSShapeCollection : IDisposable
332 // Called at taint-time. 332 // Called at taint-time.
333 private void DereferenceCompound(BulletShape shape, ShapeDestructionCallback shapeCallback) 333 private void DereferenceCompound(BulletShape shape, ShapeDestructionCallback shapeCallback)
334 { 334 {
335 if (!BulletSimAPI.IsCompound2(shape.ptr)) 335 if (!PhysicsScene.PE.IsCompound(shape))
336 { 336 {
337 // Failed the sanity check!! 337 // Failed the sanity check!!
338 PhysicsScene.Logger.ErrorFormat("{0} Attempt to free a compound shape that is not compound!! type={1}, ptr={2}", 338 PhysicsScene.Logger.ErrorFormat("{0} Attempt to free a compound shape that is not compound!! type={1}, ptr={2}",
@@ -376,7 +376,7 @@ public sealed class BSShapeCollection : IDisposable
376 } 376 }
377 else 377 else
378 { 378 {
379 if (BulletSimAPI.IsCompound2(cShape)) 379 if (PhysicsScene.PE.IsCompound(shapeInfo))
380 { 380 {
381 shapeInfo.type = BSPhysicsShapeType.SHAPE_COMPOUND; 381 shapeInfo.type = BSPhysicsShapeType.SHAPE_COMPOUND;
382 } 382 }
@@ -467,7 +467,7 @@ public sealed class BSShapeCollection : IDisposable
467 // Get the scale of any existing shape so we can see if the new shape is same native type and same size. 467 // Get the scale of any existing shape so we can see if the new shape is same native type and same size.
468 OMV.Vector3 scaleOfExistingShape = OMV.Vector3.Zero; 468 OMV.Vector3 scaleOfExistingShape = OMV.Vector3.Zero;
469 if (prim.PhysShape.HasPhysicalShape) 469 if (prim.PhysShape.HasPhysicalShape)
470 scaleOfExistingShape = BulletSimAPI.GetLocalScaling2(prim.PhysShape.ptr); 470 scaleOfExistingShape = PhysicsScene.PE.GetLocalScaling(prim.PhysShape);
471 471
472 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}", 472 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}",
473 prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.type); 473 prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.type);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
index 423e700..c75eb9b 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
@@ -151,12 +151,12 @@ public class BSShapeNative : BSShape
151 /* 151 /*
152 if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) 152 if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE)
153 { 153 {
154 ptr = BulletSimAPI.BuildCapsuleShape2(physicsScene.World.ptr, 1f, 1f, prim.Scale); 154 ptr = PhysicsScene.PE.BuildCapsuleShape(physicsScene.World, 1f, 1f, prim.Scale);
155 physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); 155 physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale);
156 } 156 }
157 else 157 else
158 { 158 {
159 ptr = BulletSimAPI.BuildNativeShape2(physicsScene.World.ptr, nativeShapeData); 159 ptr = PhysicsScene.PE.BuildNativeShape(physicsScene.World, nativeShapeData);
160 } 160 }
161 if (ptr == IntPtr.Zero) 161 if (ptr == IntPtr.Zero)
162 { 162 {
@@ -173,7 +173,7 @@ public class BSShapeNative : BSShape
173 /* 173 /*
174 // Native shapes are not tracked and are released immediately 174 // Native shapes are not tracked and are released immediately
175 physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this); 175 physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this);
176 BulletSimAPI.DeleteCollisionShape2(physicsScene.World.ptr, ptr); 176 PhysicsScene.PE.DeleteCollisionShape(physicsScene.World, this);
177 ptr = IntPtr.Zero; 177 ptr = IntPtr.Zero;
178 // Garbage collection will free up this instance. 178 // Garbage collection will free up this instance.
179 */ 179 */
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
index 01966c0..cc28344 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
@@ -120,7 +120,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
120 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_mapInfo.terrainBody); 120 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_mapInfo.terrainBody);
121 121
122 m_mapInfo.terrainBody.collisionType = CollisionType.Terrain; 122 m_mapInfo.terrainBody.collisionType = CollisionType.Terrain;
123 m_mapInfo.terrainBody.ApplyCollisionMask(); 123 m_mapInfo.terrainBody.ApplyCollisionMask(PhysicsScene);
124 124
125 // Make it so the terrain will not move or be considered for movement. 125 // Make it so the terrain will not move or be considered for movement.
126 PhysicsScene.PE.ForceActivationState(m_mapInfo.terrainBody, ActivationState.DISABLE_SIMULATION); 126 PhysicsScene.PE.ForceActivationState(m_mapInfo.terrainBody, ActivationState.DISABLE_SIMULATION);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
index 590c687..2e9db39 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
@@ -143,7 +143,7 @@ public sealed class BSTerrainManager : IDisposable
143 PhysicsScene.PE.ForceActivationState(m_groundPlane, ActivationState.DISABLE_SIMULATION); 143 PhysicsScene.PE.ForceActivationState(m_groundPlane, ActivationState.DISABLE_SIMULATION);
144 // Everything collides with the ground plane. 144 // Everything collides with the ground plane.
145 m_groundPlane.collisionType = CollisionType.Groundplane; 145 m_groundPlane.collisionType = CollisionType.Groundplane;
146 m_groundPlane.ApplyCollisionMask(); 146 m_groundPlane.ApplyCollisionMask(PhysicsScene);
147 147
148 // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain. 148 // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain.
149 BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize); 149 BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
index 2f55fc3..1d55ce3 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs
@@ -120,7 +120,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
120 PhysicsScene.PE.SetCollisionFlags(m_terrainBody, CollisionFlags.CF_STATIC_OBJECT); 120 PhysicsScene.PE.SetCollisionFlags(m_terrainBody, CollisionFlags.CF_STATIC_OBJECT);
121 121
122 // Static objects are not very massive. 122 // Static objects are not very massive.
123 BulletSimAPI.SetMassProps2(m_terrainBody.ptr, 0f, Vector3.Zero); 123 PhysicsScene.PE.SetMassProps(m_terrainBody, 0f, Vector3.Zero);
124 124
125 // Put the new terrain to the world of physical objects 125 // Put the new terrain to the world of physical objects
126 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_terrainBody); 126 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_terrainBody);
@@ -129,7 +129,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
129 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_terrainBody); 129 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_terrainBody);
130 130
131 m_terrainBody.collisionType = CollisionType.Terrain; 131 m_terrainBody.collisionType = CollisionType.Terrain;
132 m_terrainBody.ApplyCollisionMask(); 132 m_terrainBody.ApplyCollisionMask(PhysicsScene);
133 133
134 // Make it so the terrain will not move or be considered for movement. 134 // Make it so the terrain will not move or be considered for movement.
135 PhysicsScene.PE.ForceActivationState(m_terrainBody, ActivationState.DISABLE_SIMULATION); 135 PhysicsScene.PE.ForceActivationState(m_terrainBody, ActivationState.DISABLE_SIMULATION);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs
index c10d75e..a040928 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs
@@ -72,12 +72,12 @@ public class BulletBody
72 public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } } 72 public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } }
73 73
74 // Apply the specificed collision mask into the physical world 74 // Apply the specificed collision mask into the physical world
75 public bool ApplyCollisionMask() 75 public bool ApplyCollisionMask(BSScene physicsScene)
76 { 76 {
77 // Should assert the body has been added to the physical world. 77 // Should assert the body has been added to the physical world.
78 // (The collision masks are stored in the collision proxy cache which only exists for 78 // (The collision masks are stored in the collision proxy cache which only exists for
79 // a collision body that is in the world.) 79 // a collision body that is in the world.)
80 return BulletSimAPI.SetCollisionGroupMask2(ptr, 80 return physicsScene.PE.SetCollisionGroupMask(this,
81 BulletSimData.CollisionTypeMasks[collisionType].group, 81 BulletSimData.CollisionTypeMasks[collisionType].group,
82 BulletSimData.CollisionTypeMasks[collisionType].mask); 82 BulletSimData.CollisionTypeMasks[collisionType].mask);
83 } 83 }