aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
authorRobert Adams2012-08-09 15:01:05 -0700
committerRobert Adams2012-08-09 15:01:05 -0700
commit38e79b80a87d213748d55d66e8b72021999d3945 (patch)
treef8da528b7cc0038e6df145c1ad70874c142a85e3 /OpenSim/Region/Physics/BulletSPlugin
parentBulletSim: add avatar code to keep avatars from ending up trapped under the t... (diff)
downloadopensim-SC_OLD-38e79b80a87d213748d55d66e8b72021999d3945.zip
opensim-SC_OLD-38e79b80a87d213748d55d66e8b72021999d3945.tar.gz
opensim-SC_OLD-38e79b80a87d213748d55d66e8b72021999d3945.tar.bz2
opensim-SC_OLD-38e79b80a87d213748d55d66e8b72021999d3945.tar.xz
BulletSim: separate out the constraints by type. The linksets use
6dof constraint but eventually others will be exposed so future features can use all the Bullet capabilities. Force children to generate a position update when unlinked.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs80
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs60
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs10
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs38
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs15
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs37
6 files changed, 146 insertions, 94 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs
new file mode 100755
index 0000000..72df6b9
--- /dev/null
+++ b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs
@@ -0,0 +1,80 @@
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 class BS6DofConstraint : BSConstraint
36{
37 // Create a btGeneric6DofConstraint
38 public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2,
39 Vector3 frame1, Quaternion frame1rot,
40 Vector3 frame2, Quaternion frame2rot )
41 {
42 m_world = world;
43 m_body1 = obj1;
44 m_body2 = obj2;
45 m_constraint = new BulletConstraint(
46 BulletSimAPI.Create6DofConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr,
47 frame1, frame1rot,
48 frame2, frame2rot,
49 true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/));
50 m_enabled = true;
51 }
52
53 public bool SetCFMAndERP(float cfm, float erp)
54 {
55 bool ret = true;
56 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
57 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL);
58 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
59 return ret;
60 }
61
62 public bool UseFrameOffset(bool useOffset)
63 {
64 bool ret = false;
65 float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
66 if (m_enabled)
67 ret = BulletSimAPI.UseFrameOffset2(m_constraint.Ptr, onOff);
68 return ret;
69 }
70
71 public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce)
72 {
73 bool ret = false;
74 float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
75 if (m_enabled)
76 ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce);
77 return ret;
78 }
79}
80}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
index ea3093a..a17efea 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
@@ -32,30 +32,19 @@ using OpenMetaverse;
32namespace OpenSim.Region.Physics.BulletSPlugin 32namespace OpenSim.Region.Physics.BulletSPlugin
33{ 33{
34 34
35public class BSConstraint : IDisposable 35public abstract class BSConstraint : IDisposable
36{ 36{
37 private BulletSim m_world; 37 protected BulletSim m_world;
38 private BulletBody m_body1; 38 protected BulletBody m_body1;
39 private BulletBody m_body2; 39 protected BulletBody m_body2;
40 private BulletConstraint m_constraint; 40 protected BulletConstraint m_constraint;
41 private bool m_enabled = false; 41 protected bool m_enabled = false;
42 42
43 public BSConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, 43 public BSConstraint()
44 Vector3 frame1, Quaternion frame1rot,
45 Vector3 frame2, Quaternion frame2rot
46 )
47 { 44 {
48 m_world = world;
49 m_body1 = obj1;
50 m_body2 = obj2;
51 m_constraint = new BulletConstraint(BulletSimAPI.CreateConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr,
52 frame1, frame1rot,
53 frame2, frame2rot,
54 true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/));
55 m_enabled = true;
56 } 45 }
57 46
58 public void Dispose() 47 public virtual void Dispose()
59 { 48 {
60 if (m_enabled) 49 if (m_enabled)
61 { 50 {
@@ -68,7 +57,7 @@ public class BSConstraint : IDisposable
68 public BulletBody Body1 { get { return m_body1; } } 57 public BulletBody Body1 { get { return m_body1; } }
69 public BulletBody Body2 { get { return m_body2; } } 58 public BulletBody Body2 { get { return m_body2; } }
70 59
71 public bool SetLinearLimits(Vector3 low, Vector3 high) 60 public virtual bool SetLinearLimits(Vector3 low, Vector3 high)
72 { 61 {
73 bool ret = false; 62 bool ret = false;
74 if (m_enabled) 63 if (m_enabled)
@@ -76,7 +65,7 @@ public class BSConstraint : IDisposable
76 return ret; 65 return ret;
77 } 66 }
78 67
79 public bool SetAngularLimits(Vector3 low, Vector3 high) 68 public virtual bool SetAngularLimits(Vector3 low, Vector3 high)
80 { 69 {
81 bool ret = false; 70 bool ret = false;
82 if (m_enabled) 71 if (m_enabled)
@@ -84,34 +73,7 @@ public class BSConstraint : IDisposable
84 return ret; 73 return ret;
85 } 74 }
86 75
87 public bool SetCFMAndERP(float cfm, float erp) 76 public virtual bool CalculateTransforms()
88 {
89 bool ret = true;
90 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
91 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL);
92 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
93 return ret;
94 }
95
96 public bool UseFrameOffset(bool useOffset)
97 {
98 bool ret = false;
99 float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
100 if (m_enabled)
101 ret = BulletSimAPI.UseFrameOffset2(m_constraint.Ptr, onOff);
102 return ret;
103 }
104
105 public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce)
106 {
107 bool ret = false;
108 float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
109 if (m_enabled)
110 ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce);
111 return ret;
112 }
113
114 public bool CalculateTransforms()
115 { 77 {
116 bool ret = false; 78 bool ret = false;
117 if (m_enabled) 79 if (m_enabled)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs
index c88e645..397045a 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs
@@ -63,16 +63,6 @@ public class BSConstraintCollection : IDisposable
63 m_constraints.Clear(); 63 m_constraints.Clear();
64 } 64 }
65 65
66 public BSConstraint CreateConstraint(BulletSim world, BulletBody obj1, BulletBody obj2,
67 Vector3 frame1, Quaternion frame1rot,
68 Vector3 frame2, Quaternion frame2rot)
69 {
70 BSConstraint constrain = new BSConstraint(world, obj1, obj2, frame1, frame1rot, frame2, frame2rot);
71
72 this.AddConstraint(constrain);
73 return constrain;
74 }
75
76 public bool AddConstraint(BSConstraint cons) 66 public bool AddConstraint(BSConstraint cons)
77 { 67 {
78 // There is only one constraint between any bodies. Remove any old just to make sure. 68 // There is only one constraint between any bodies. Remove any old just to make sure.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index d19c4b8..e265d6d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -101,7 +101,7 @@ public class BSLinkset
101 { 101 {
102 // Note that we don't do a foreach because the remove routine 102 // Note that we don't do a foreach because the remove routine
103 // takes it out of the list. 103 // takes it out of the list.
104 RemoveChildFromLinkset(m_children[0]); 104 RemoveChildFromOtherLinkset(m_children[0]);
105 } 105 }
106 m_children.Clear(); // just to make sure 106 m_children.Clear(); // just to make sure
107 } 107 }
@@ -124,6 +124,7 @@ public class BSLinkset
124 124
125 lock (m_linksetActivityLock) 125 lock (m_linksetActivityLock)
126 { 126 {
127 // The body pointer is refetched in case anything has moved.
127 System.IntPtr aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, m_linksetRoot.LocalID); 128 System.IntPtr aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, m_linksetRoot.LocalID);
128 if (aPtr == System.IntPtr.Zero) 129 if (aPtr == System.IntPtr.Zero)
129 { 130 {
@@ -155,7 +156,7 @@ public class BSLinkset
155 } 156 }
156 foreach (BSPrim bsp in toRemove) 157 foreach (BSPrim bsp in toRemove)
157 { 158 {
158 RemoveChildFromLinkset(bsp); 159 RemoveChildFromOtherLinkset(bsp);
159 } 160 }
160 } 161 }
161 } 162 }
@@ -208,7 +209,8 @@ public class BSLinkset
208 com += bp.Position * bp.MassRaw; 209 com += bp.Position * bp.MassRaw;
209 totalMass += bp.MassRaw; 210 totalMass += bp.MassRaw;
210 } 211 }
211 com /= totalMass; 212 if (totalMass != 0f)
213 com /= totalMass;
212 214
213 return com; 215 return com;
214 } 216 }
@@ -221,7 +223,7 @@ public class BSLinkset
221 { 223 {
222 com += bp.Position * bp.MassRaw; 224 com += bp.Position * bp.MassRaw;
223 } 225 }
224 com /= m_children.Count + 1; 226 com /= (m_children.Count + 1);
225 227
226 return com; 228 return com;
227 } 229 }
@@ -237,13 +239,24 @@ public class BSLinkset
237 m_scene.TaintedObject(delegate() 239 m_scene.TaintedObject(delegate()
238 { 240 {
239 DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID); 241 DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID);
240 DetailLog("{0},AddChildToLinkset,child={1}", m_linksetRoot.LocalID, pchild.LocalID); 242 DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID);
241 PhysicallyLinkAChildToRoot(pchild); // build the physical binding between me and the child 243 PhysicallyLinkAChildToRoot(pchild); // build the physical binding between me and the child
242 }); 244 });
243 } 245 }
244 return; 246 return;
245 } 247 }
246 248
249 // Forcefully removing a child from a linkset.
250 // This is not being called by the child so we have to make sure the child doesn't think
251 // it's still connected to the linkset.
252 // Normal OpenSimulator operation will never do this because other SceneObjectPart information
253 // has to be updated also (like pointer to prim's parent).
254 public void RemoveChildFromOtherLinkset(BSPrim pchild)
255 {
256 pchild.Linkset = new BSLinkset(m_scene, pchild);
257 RemoveChildFromLinkset(pchild);
258 }
259
247 // I am the root of a linkset and one of my children is being removed. 260 // I am the root of a linkset and one of my children is being removed.
248 // Safe to call even if the child is not really in my linkset. 261 // Safe to call even if the child is not really in my linkset.
249 public void RemoveChildFromLinkset(BSPrim pchild) 262 public void RemoveChildFromLinkset(BSPrim pchild)
@@ -255,7 +268,7 @@ public class BSLinkset
255 m_scene.TaintedObject(delegate() 268 m_scene.TaintedObject(delegate()
256 { 269 {
257 DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); 270 DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID);
258 DetailLog("{0},RemoveChildFromLinkset,child={1}", m_linksetRoot.LocalID, pchild.LocalID); 271 DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID);
259 272
260 if (m_children.Count == 0) 273 if (m_children.Count == 0)
261 { 274 {
@@ -294,13 +307,14 @@ public class BSLinkset
294 // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 307 // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818
295 // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); 308 // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID);
296 DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); 309 DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID);
297 BSConstraint constrain = m_scene.Constraints.CreateConstraint( 310 BS6DofConstraint constrain = new BS6DofConstraint(
298 m_scene.World, m_linksetRoot.Body, childPrim.Body, 311 m_scene.World, m_linksetRoot.Body, childPrim.Body,
299 childRelativePosition, 312 childRelativePosition,
300 childRelativeRotation, 313 childRelativeRotation,
301 OMV.Vector3.Zero, 314 OMV.Vector3.Zero,
302 -childRelativeRotation 315 -childRelativeRotation
303 ); 316 );
317 m_scene.Constraints.AddConstraint(constrain);
304 318
305 // zero linear and angular limits makes the objects unable to move in relation to each other 319 // zero linear and angular limits makes the objects unable to move in relation to each other
306 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 320 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
@@ -319,11 +333,13 @@ public class BSLinkset
319 // Called at taint time! 333 // Called at taint time!
320 private void PhysicallyUnlinkAChildFromRoot(BSPrim childPrim) 334 private void PhysicallyUnlinkAChildFromRoot(BSPrim childPrim)
321 { 335 {
322 DebugLog("{0}: PhysicallyUnlinkAChildFromRoot: RemoveConstraint between root prim {1} and child prim {2}", 336 // DebugLog("{0}: PhysicallyUnlinkAChildFromRoot: RemoveConstraint between root prim {1} and child prim {2}",
323 LogHeader, m_linksetRoot.LocalID, childPrim.LocalID); 337 // LogHeader, m_linksetRoot.LocalID, childPrim.LocalID);
324 DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); 338 DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID);
325 // BulletSimAPI.RemoveConstraint(_scene.WorldID, LocalID, childPrim.LocalID); 339
326 m_scene.Constraints.RemoveAndDestroyConstraint(m_linksetRoot.Body, childPrim.Body); 340 m_scene.Constraints.RemoveAndDestroyConstraint(m_linksetRoot.Body, childPrim.Body);
341 // Make the child refresh its location
342 BulletSimAPI.PushUpdate2(childPrim.Body.Ptr);
327 } 343 }
328 344
329 // Remove linkage between myself and any possible children I might have 345 // Remove linkage between myself and any possible children I might have
@@ -332,8 +348,8 @@ public class BSLinkset
332 { 348 {
333 // DebugLog("{0}: PhysicallyUnlinkAllChildren:", LogHeader); 349 // DebugLog("{0}: PhysicallyUnlinkAllChildren:", LogHeader);
334 DetailLog("{0},PhysicallyUnlinkAllChildren,taint", m_linksetRoot.LocalID); 350 DetailLog("{0},PhysicallyUnlinkAllChildren,taint", m_linksetRoot.LocalID);
351
335 m_scene.Constraints.RemoveAndDestroyConstraint(m_linksetRoot.Body); 352 m_scene.Constraints.RemoveAndDestroyConstraint(m_linksetRoot.Body);
336 // BulletSimAPI.RemoveConstraintByID(_scene.WorldID, LocalID);
337 } 353 }
338 354
339 // Invoke the detailed logger and output something if it's enabled. 355 // Invoke the detailed logger and output something if it's enabled.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 98b69b1..e0f6ed2 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -224,10 +224,12 @@ public sealed class BSPrim : PhysicsActor
224 // link me to the specified parent 224 // link me to the specified parent
225 public override void link(PhysicsActor obj) { 225 public override void link(PhysicsActor obj) {
226 BSPrim parent = obj as BSPrim; 226 BSPrim parent = obj as BSPrim;
227 DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, obj.LocalID); 227 if (parent != null)
228 DetailLog("{0},link,parent={1}", LocalID, obj.LocalID); 228 {
229 229 DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID);
230 _linkset = _linkset.AddMeToLinkset(this, parent); 230 DetailLog("{0},link,parent={1}", LocalID, parent.LocalID);
231 _linkset = _linkset.AddMeToLinkset(this, parent);
232 }
231 return; 233 return;
232 } 234 }
233 235
@@ -478,7 +480,6 @@ public sealed class BSPrim : PhysicsActor
478 480
479 // Make gravity work if the object is physical and not selected 481 // Make gravity work if the object is physical and not selected
480 // No locking here because only called when it is safe 482 // No locking here because only called when it is safe
481 // Only called at taint time so it is save to call into Bullet.
482 private void SetObjectDynamic() 483 private void SetObjectDynamic()
483 { 484 {
484 // RA: remove this for the moment. 485 // RA: remove this for the moment.
@@ -982,7 +983,7 @@ public sealed class BSPrim : PhysicsActor
982 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); 983 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size);
983 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE)) 984 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE))
984 { 985 {
985 DetailLog("{0},CreateGeom,sphere", LocalID); 986 DetailLog("{0},CreateGeom,sphere (force={1}", LocalID, forceRebuild);
986 _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; 987 _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE;
987 // Bullet native objects are scaled by the Bullet engine so pass the size in 988 // Bullet native objects are scaled by the Bullet engine so pass the size in
988 _scale = _size; 989 _scale = _size;
@@ -996,7 +997,7 @@ public sealed class BSPrim : PhysicsActor
996 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size); 997 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size);
997 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX)) 998 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX))
998 { 999 {
999 DetailLog("{0},CreateGeom,box", LocalID); 1000 DetailLog("{0},CreateGeom,box (force={1})", LocalID, forceRebuild);
1000 _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; 1001 _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX;
1001 _scale = _size; 1002 _scale = _size;
1002 // TODO: do we need to check for and destroy a mesh or hull that might have been left from before? 1003 // TODO: do we need to check for and destroy a mesh or hull that might have been left from before?
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 86fc9d2..c016402 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -363,7 +363,7 @@ public static extern IntPtr GetSimHandle2(uint worldID);
363public static extern IntPtr GetBodyHandleWorldID2(uint worldID, uint id); 363public static extern IntPtr GetBodyHandleWorldID2(uint worldID, uint id);
364 364
365[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 365[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
366public static extern IntPtr GetBodyHandle2(IntPtr sim, uint id); 366public static extern IntPtr GetBodyHandle2(IntPtr world, uint id);
367 367
368// =============================================================================== 368// ===============================================================================
369[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 369[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@@ -372,40 +372,43 @@ public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms,
372 int maxUpdates, IntPtr updateArray); 372 int maxUpdates, IntPtr updateArray);
373 373
374[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 374[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
375public static extern bool UpdateParameter2(IntPtr sim, uint localID, String parm, float value); 375public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value);
376 376
377[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 377[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
378public static extern void SetHeightmap2(IntPtr sim, float[] heightmap); 378public static extern void SetHeightmap2(IntPtr world, float[] heightmap);
379 379
380[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 380[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
381public static extern void Shutdown2(IntPtr sim); 381public static extern void Shutdown2(IntPtr sim);
382 382
383[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 383[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
384public static extern int PhysicsStep2(IntPtr sim, float timeStep, int maxSubSteps, float fixedTimeStep, 384public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep,
385 out int updatedEntityCount, 385 out int updatedEntityCount,
386 out IntPtr updatedEntitiesPtr, 386 out IntPtr updatedEntitiesPtr,
387 out int collidersCount, 387 out int collidersCount,
388 out IntPtr collidersPtr); 388 out IntPtr collidersPtr);
389 389
390[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
391public static extern bool PushUpdate2(IntPtr obj);
392
390/* 393/*
391[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 394[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
392public static extern IntPtr CreateMesh2(IntPtr sim, int indicesCount, int* indices, int verticesCount, float* vertices ); 395public static extern IntPtr CreateMesh2(IntPtr world, int indicesCount, int* indices, int verticesCount, float* vertices );
393 396
394[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 397[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
395public static extern bool BuildHull2(IntPtr sim, IntPtr mesh); 398public static extern bool BuildHull2(IntPtr world, IntPtr mesh);
396 399
397[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 400[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
398public static extern bool ReleaseHull2(IntPtr sim, IntPtr mesh); 401public static extern bool ReleaseHull2(IntPtr world, IntPtr mesh);
399 402
400[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 403[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
401public static extern bool DestroyMesh2(IntPtr sim, IntPtr mesh); 404public static extern bool DestroyMesh2(IntPtr world, IntPtr mesh);
402 405
403[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 406[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
404public static extern IntPtr CreateObject2(IntPtr sim, ShapeData shapeData); 407public static extern IntPtr CreateObject2(IntPtr world, ShapeData shapeData);
405*/ 408*/
406 409
407[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 410[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
408public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2, 411public static extern IntPtr Create6DofConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2,
409 Vector3 frame1loc, Quaternion frame1rot, 412 Vector3 frame1loc, Quaternion frame1rot,
410 Vector3 frame2loc, Quaternion frame2rot, 413 Vector3 frame2loc, Quaternion frame2rot,
411 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); 414 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
@@ -429,7 +432,13 @@ public static extern bool CalculateTransforms2(IntPtr constrain);
429public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis); 432public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
430 433
431[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 434[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
432public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain); 435public static extern bool DestroyConstraint2(IntPtr world, IntPtr constrain);
436
437[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
438public static extern Vector3 AddObjectToWorld2(IntPtr world, IntPtr obj);
439
440[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
441public static extern Vector3 RemoveObjectFromWorld2(IntPtr world, IntPtr obj);
433 442
434[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 443[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
435public static extern Vector3 GetPosition2(IntPtr obj); 444public static extern Vector3 GetPosition2(IntPtr obj);
@@ -510,12 +519,6 @@ public static extern bool SetMargin2(IntPtr obj, float val);
510public static extern bool UpdateSingleAabb2(IntPtr world, IntPtr obj); 519public static extern bool UpdateSingleAabb2(IntPtr world, IntPtr obj);
511 520
512[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 521[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
513public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj);
514
515[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
516public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj);
517
518[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
519public static extern bool DestroyObject2(IntPtr world, uint id); 522public static extern bool DestroyObject2(IntPtr world, uint id);
520 523
521[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 524[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]