diff options
author | Robert Adams | 2012-10-26 16:09:08 -0700 |
---|---|---|
committer | Robert Adams | 2012-11-03 21:13:27 -0700 |
commit | 7af28724acf12245977fc44576c36ec0de320a8a (patch) | |
tree | cc441f1cc22bfd5bafdc4ac46b255c2a1fbf61d2 /OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs | |
parent | BulletSim: many small changes for vehicles simulation. (diff) | |
download | opensim-SC_OLD-7af28724acf12245977fc44576c36ec0de320a8a.zip opensim-SC_OLD-7af28724acf12245977fc44576c36ec0de320a8a.tar.gz opensim-SC_OLD-7af28724acf12245977fc44576c36ec0de320a8a.tar.bz2 opensim-SC_OLD-7af28724acf12245977fc44576c36ec0de320a8a.tar.xz |
BulletSim: rename constraint classes so they show up together alphabetically.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs | 154 |
1 files changed, 0 insertions, 154 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs deleted file mode 100755 index ecb3ec8..0000000 --- a/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs +++ /dev/null | |||
@@ -1,154 +0,0 @@ | |||
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 | public sealed class BS6DofConstraint : BSConstraint | ||
36 | { | ||
37 | private static string LogHeader = "[BULLETSIM 6DOF CONSTRAINT]"; | ||
38 | |||
39 | public override ConstraintType Type { get { return ConstraintType.D6_CONSTRAINT_TYPE; } } | ||
40 | |||
41 | // Create a btGeneric6DofConstraint | ||
42 | public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, | ||
43 | Vector3 frame1, Quaternion frame1rot, | ||
44 | Vector3 frame2, Quaternion frame2rot, | ||
45 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | ||
46 | { | ||
47 | m_world = world; | ||
48 | m_body1 = obj1; | ||
49 | m_body2 = obj2; | ||
50 | m_constraint = new BulletConstraint( | ||
51 | BulletSimAPI.Create6DofConstraint2(m_world.ptr, m_body1.ptr, m_body2.ptr, | ||
52 | frame1, frame1rot, | ||
53 | frame2, frame2rot, | ||
54 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
55 | m_enabled = true; | ||
56 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | ||
57 | BSScene.DetailLogZero, world.worldID, | ||
58 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | ||
59 | } | ||
60 | |||
61 | public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, | ||
62 | Vector3 joinPoint, | ||
63 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | ||
64 | { | ||
65 | m_world = world; | ||
66 | m_body1 = obj1; | ||
67 | m_body2 = obj2; | ||
68 | if (obj1.ptr == IntPtr.Zero || obj2.ptr == IntPtr.Zero) | ||
69 | { | ||
70 | world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | ||
71 | BSScene.DetailLogZero, world.worldID, | ||
72 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | ||
73 | world.physicsScene.Logger.ErrorFormat("{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | ||
74 | "[BULLETSIM 6DOF CONSTRAINT]", world.worldID, | ||
75 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | ||
76 | m_enabled = false; | ||
77 | } | ||
78 | else | ||
79 | { | ||
80 | m_constraint = new BulletConstraint( | ||
81 | BulletSimAPI.Create6DofConstraintToPoint2(m_world.ptr, m_body1.ptr, m_body2.ptr, | ||
82 | joinPoint, | ||
83 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
84 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}", | ||
85 | BSScene.DetailLogZero, world.worldID, m_constraint.ptr.ToString("X"), | ||
86 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | ||
87 | if (m_constraint.ptr == IntPtr.Zero) | ||
88 | { | ||
89 | world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}", | ||
90 | LogHeader, obj1.ID, obj2.ID); | ||
91 | m_enabled = false; | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | m_enabled = true; | ||
96 | } | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot) | ||
101 | { | ||
102 | bool ret = false; | ||
103 | if (m_enabled) | ||
104 | { | ||
105 | BulletSimAPI.SetFrames2(m_constraint.ptr, frameA, frameArot, frameB, frameBrot); | ||
106 | ret = true; | ||
107 | } | ||
108 | return ret; | ||
109 | } | ||
110 | |||
111 | public bool SetCFMAndERP(float cfm, float erp) | ||
112 | { | ||
113 | bool ret = false; | ||
114 | if (m_enabled) | ||
115 | { | ||
116 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | ||
117 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); | ||
118 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | ||
119 | ret = true; | ||
120 | } | ||
121 | return ret; | ||
122 | } | ||
123 | |||
124 | public bool UseFrameOffset(bool useOffset) | ||
125 | { | ||
126 | bool ret = false; | ||
127 | float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | ||
128 | if (m_enabled) | ||
129 | ret = BulletSimAPI.UseFrameOffset2(m_constraint.ptr, onOff); | ||
130 | return ret; | ||
131 | } | ||
132 | |||
133 | public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce) | ||
134 | { | ||
135 | bool ret = false; | ||
136 | float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | ||
137 | if (m_enabled) | ||
138 | { | ||
139 | ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.ptr, onOff, targetVelocity, maxMotorForce); | ||
140 | m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}", | ||
141 | BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce); | ||
142 | } | ||
143 | return ret; | ||
144 | } | ||
145 | |||
146 | public bool SetBreakingImpulseThreshold(float threshold) | ||
147 | { | ||
148 | bool ret = false; | ||
149 | if (m_enabled) | ||
150 | ret = BulletSimAPI.SetBreakingImpulseThreshold2(m_constraint.ptr, threshold); | ||
151 | return ret; | ||
152 | } | ||
153 | } | ||
154 | } | ||