diff options
author | Robert Adams | 2012-08-15 11:36:50 -0700 |
---|---|---|
committer | Robert Adams | 2012-08-15 12:08:21 -0700 |
commit | dd10cf01e70f757f70f18d442974688a45a2d433 (patch) | |
tree | ca1cd801fa143adbdc87106d04d3b78a3f57ddb2 /OpenSim/Region/Physics | |
parent | BulletSim: add locking to constraintCollection and rename some of the public ... (diff) | |
download | opensim-SC_OLD-dd10cf01e70f757f70f18d442974688a45a2d433.zip opensim-SC_OLD-dd10cf01e70f757f70f18d442974688a45a2d433.tar.gz opensim-SC_OLD-dd10cf01e70f757f70f18d442974688a45a2d433.tar.bz2 opensim-SC_OLD-dd10cf01e70f757f70f18d442974688a45a2d433.tar.xz |
BulletSim: add hinge constraint.
Update BulletSimAPI with new constraint related function calls.
Reorganize locking in BS6DofConstraint.
Update BS6DofConstraint to do constraint reset correctly.
Add new 'midpoint' construction of 6Dof constraint.
Diffstat (limited to 'OpenSim/Region/Physics')
3 files changed, 126 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs index 72df6b9..683bc51 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs | |||
@@ -37,7 +37,8 @@ public class BS6DofConstraint : BSConstraint | |||
37 | // Create a btGeneric6DofConstraint | 37 | // Create a btGeneric6DofConstraint |
38 | public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, | 38 | public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, |
39 | Vector3 frame1, Quaternion frame1rot, | 39 | Vector3 frame1, Quaternion frame1rot, |
40 | Vector3 frame2, Quaternion frame2rot ) | 40 | Vector3 frame2, Quaternion frame2rot, |
41 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | ||
41 | { | 42 | { |
42 | m_world = world; | 43 | m_world = world; |
43 | m_body1 = obj1; | 44 | m_body1 = obj1; |
@@ -46,16 +47,45 @@ public class BS6DofConstraint : BSConstraint | |||
46 | BulletSimAPI.Create6DofConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, | 47 | BulletSimAPI.Create6DofConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, |
47 | frame1, frame1rot, | 48 | frame1, frame1rot, |
48 | frame2, frame2rot, | 49 | frame2, frame2rot, |
49 | true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/)); | 50 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); |
50 | m_enabled = true; | 51 | m_enabled = true; |
51 | } | 52 | } |
52 | 53 | ||
54 | public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, | ||
55 | Vector3 joinPoint, | ||
56 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | ||
57 | { | ||
58 | m_world = world; | ||
59 | m_body1 = obj1; | ||
60 | m_body2 = obj2; | ||
61 | m_constraint = new BulletConstraint( | ||
62 | BulletSimAPI.Create6DofConstraintToPoint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, | ||
63 | joinPoint, | ||
64 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
65 | m_enabled = true; | ||
66 | } | ||
67 | |||
68 | public bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot) | ||
69 | { | ||
70 | bool ret = false; | ||
71 | if (m_enabled) | ||
72 | { | ||
73 | BulletSimAPI.SetFrames2(m_constraint.Ptr, frameA, frameArot, frameB, frameBrot); | ||
74 | ret = true; | ||
75 | } | ||
76 | return ret; | ||
77 | } | ||
78 | |||
53 | public bool SetCFMAndERP(float cfm, float erp) | 79 | public bool SetCFMAndERP(float cfm, float erp) |
54 | { | 80 | { |
55 | bool ret = true; | 81 | bool ret = false; |
56 | BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | 82 | if (m_enabled) |
57 | BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); | 83 | { |
58 | BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | 84 | BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); |
85 | BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); | ||
86 | BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | ||
87 | ret = true; | ||
88 | } | ||
59 | return ret; | 89 | return ret; |
60 | } | 90 | } |
61 | 91 | ||
@@ -76,5 +106,13 @@ public class BS6DofConstraint : BSConstraint | |||
76 | ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce); | 106 | ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce); |
77 | return ret; | 107 | return ret; |
78 | } | 108 | } |
109 | |||
110 | public bool SetBreakingImpulseThreshold(float threshold) | ||
111 | { | ||
112 | bool ret = false; | ||
113 | if (m_enabled) | ||
114 | ret = BulletSimAPI.SetBreakingImpulseThreshold2(m_constraint.Ptr, threshold); | ||
115 | return ret; | ||
116 | } | ||
79 | } | 117 | } |
80 | } | 118 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSHingeConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSHingeConstraint.cs new file mode 100755 index 0000000..d68048b --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSHingeConstraint.cs | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyrightD | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
33 | { | ||
34 | |||
35 | class BSHingeConstraint : BSConstraint | ||
36 | { | ||
37 | public BSHingeConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, | ||
38 | Vector3 pivotInA, Vector3 pivotInB, | ||
39 | Vector3 axisInA, Vector3 axisInB, | ||
40 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | ||
41 | { | ||
42 | m_world = world; | ||
43 | m_body1 = obj1; | ||
44 | m_body2 = obj2; | ||
45 | m_constraint = new BulletConstraint( | ||
46 | BulletSimAPI.CreateHingeConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, | ||
47 | pivotInA, pivotInB, | ||
48 | axisInA, axisInB, | ||
49 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
50 | m_enabled = true; | ||
51 | } | ||
52 | |||
53 | } | ||
54 | |||
55 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 6800b96..504bd3c 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | |||
@@ -416,6 +416,27 @@ public static extern IntPtr Create6DofConstraint2(IntPtr world, IntPtr obj1, Int | |||
416 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | 416 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); |
417 | 417 | ||
418 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 418 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
419 | public static extern IntPtr Create6DofConstraintToPoint2(IntPtr world, IntPtr obj1, IntPtr obj2, | ||
420 | Vector3 joinPoint, | ||
421 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | ||
422 | |||
423 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
424 | public static extern IntPtr CreateHingeConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2, | ||
425 | Vector3 pivotinA, Vector3 pivotinB, | ||
426 | Vector3 axisInA, Vector3 axisInB, | ||
427 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | ||
428 | |||
429 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
430 | public static extern void SetConstraintEnable2(IntPtr constrain, float numericTrueFalse); | ||
431 | |||
432 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
433 | public static extern void SetConstraintNumSolverIterations2(IntPtr constrain, float iterations); | ||
434 | |||
435 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
436 | public static extern bool SetFrames2(IntPtr constrain, | ||
437 | Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot); | ||
438 | |||
439 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
419 | public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi); | 440 | public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi); |
420 | 441 | ||
421 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 442 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -428,6 +449,9 @@ public static extern bool UseFrameOffset2(IntPtr constrain, float enable); | |||
428 | public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enable, float targetVel, float maxMotorForce); | 449 | public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enable, float targetVel, float maxMotorForce); |
429 | 450 | ||
430 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 451 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
452 | public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold); | ||
453 | |||
454 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
431 | public static extern bool CalculateTransforms2(IntPtr constrain); | 455 | public static extern bool CalculateTransforms2(IntPtr constrain); |
432 | 456 | ||
433 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 457 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -518,6 +542,9 @@ public static extern bool SetGravity2(IntPtr obj, Vector3 val); | |||
518 | public static extern IntPtr ClearForces2(IntPtr obj); | 542 | public static extern IntPtr ClearForces2(IntPtr obj); |
519 | 543 | ||
520 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 544 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
545 | public static extern IntPtr ClearAllForces2(IntPtr obj); | ||
546 | |||
547 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
521 | public static extern bool SetMargin2(IntPtr obj, float val); | 548 | public static extern bool SetMargin2(IntPtr obj, float val); |
522 | 549 | ||
523 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 550 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |