diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSNPlugin/BSConstraint.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSNPlugin/BSConstraint.cs | 135 |
1 files changed, 0 insertions, 135 deletions
diff --git a/OpenSim/Region/Physics/BulletSNPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSNPlugin/BSConstraint.cs deleted file mode 100644 index f1bed39..0000000 --- a/OpenSim/Region/Physics/BulletSNPlugin/BSConstraint.cs +++ /dev/null | |||
@@ -1,135 +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.BulletSNPlugin | ||
33 | { | ||
34 | |||
35 | public abstract class BSConstraint : IDisposable | ||
36 | { | ||
37 | private static string LogHeader = "[BULLETSIM CONSTRAINT]"; | ||
38 | |||
39 | protected BulletWorld m_world; | ||
40 | protected BulletBody m_body1; | ||
41 | protected BulletBody m_body2; | ||
42 | protected BulletConstraint m_constraint; | ||
43 | protected bool m_enabled = false; | ||
44 | |||
45 | public BulletBody Body1 { get { return m_body1; } } | ||
46 | public BulletBody Body2 { get { return m_body2; } } | ||
47 | public BulletConstraint Constraint { get { return m_constraint; } } | ||
48 | public abstract ConstraintType Type { get; } | ||
49 | public bool IsEnabled { get { return m_enabled; } } | ||
50 | |||
51 | public BSConstraint() | ||
52 | { | ||
53 | } | ||
54 | |||
55 | public virtual void Dispose() | ||
56 | { | ||
57 | if (m_enabled) | ||
58 | { | ||
59 | m_enabled = false; | ||
60 | if (m_constraint.HasPhysicalConstraint) | ||
61 | { | ||
62 | bool success = BulletSimAPI.DestroyConstraint2(m_world.ptr, m_constraint.ptr); | ||
63 | m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}", | ||
64 | BSScene.DetailLogZero, | ||
65 | m_body1.ID, m_body1.ptr.ToString(), | ||
66 | m_body2.ID, m_body2.ptr.ToString(), | ||
67 | success); | ||
68 | m_constraint.Clear(); | ||
69 | } | ||
70 | } | ||
71 | } | ||
72 | |||
73 | public virtual bool SetLinearLimits(Vector3 low, Vector3 high) | ||
74 | { | ||
75 | bool ret = false; | ||
76 | if (m_enabled) | ||
77 | ret = BulletSimAPI.SetLinearLimits2(m_constraint.ptr, low, high); | ||
78 | return ret; | ||
79 | } | ||
80 | |||
81 | public virtual bool SetAngularLimits(Vector3 low, Vector3 high) | ||
82 | { | ||
83 | bool ret = false; | ||
84 | if (m_enabled) | ||
85 | ret = BulletSimAPI.SetAngularLimits2(m_constraint.ptr, low, high); | ||
86 | return ret; | ||
87 | } | ||
88 | |||
89 | public virtual bool SetSolverIterations(float cnt) | ||
90 | { | ||
91 | bool ret = false; | ||
92 | if (m_enabled) | ||
93 | { | ||
94 | BulletSimAPI.SetConstraintNumSolverIterations2(m_constraint.ptr, cnt); | ||
95 | ret = true; | ||
96 | } | ||
97 | return ret; | ||
98 | } | ||
99 | |||
100 | public virtual bool CalculateTransforms() | ||
101 | { | ||
102 | bool ret = false; | ||
103 | if (m_enabled) | ||
104 | { | ||
105 | // Recompute the internal transforms | ||
106 | BulletSimAPI.CalculateTransforms2(m_constraint.ptr); | ||
107 | ret = true; | ||
108 | } | ||
109 | return ret; | ||
110 | } | ||
111 | |||
112 | // Reset this constraint making sure it has all its internal structures | ||
113 | // recomputed and is enabled and ready to go. | ||
114 | public virtual bool RecomputeConstraintVariables(float mass) | ||
115 | { | ||
116 | bool ret = false; | ||
117 | if (m_enabled) | ||
118 | { | ||
119 | ret = CalculateTransforms(); | ||
120 | if (ret) | ||
121 | { | ||
122 | // Setting an object's mass to zero (making it static like when it's selected) | ||
123 | // automatically disables the constraints. | ||
124 | // If the link is enabled, be sure to set the constraint itself to enabled. | ||
125 | BulletSimAPI.SetConstraintEnable2(m_constraint.ptr, BSParam.NumericBool(true)); | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | m_world.physicsScene.Logger.ErrorFormat("{0} CalculateTransforms failed. A={1}, B={2}", LogHeader, Body1.ID, Body2.ID); | ||
130 | } | ||
131 | } | ||
132 | return ret; | ||
133 | } | ||
134 | } | ||
135 | } | ||