aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs418
1 files changed, 302 insertions, 116 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]