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