aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
authorMelanie2012-11-19 22:53:03 +0000
committerMelanie2012-11-19 22:53:03 +0000
commit9f2d232c71d76a7e652f7dbae05051e62ab558d7 (patch)
tree84f6d25a5f17d88984b23fe8e1c72a95f9a3b00e /OpenSim/Region/Physics/BulletSPlugin
parentMerge branch 'avination' into careminster (diff)
parentBulletSim: Use base class constructors for initialization of BSShape and othe... (diff)
downloadopensim-SC-9f2d232c71d76a7e652f7dbae05051e62ab558d7.zip
opensim-SC-9f2d232c71d76a7e652f7dbae05051e62ab558d7.tar.gz
opensim-SC-9f2d232c71d76a7e652f7dbae05051e62ab558d7.tar.bz2
opensim-SC-9f2d232c71d76a7e652f7dbae05051e62ab558d7.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs8
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs5
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs2
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapes.cs421
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs134
6 files changed, 220 insertions, 352 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index f33c124..3c48dcc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -78,8 +78,8 @@ public sealed class BSCharacter : BSPhysObject
78 private float _PIDHoverTao; 78 private float _PIDHoverTao;
79 79
80 public BSCharacter(uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, bool isFlying) 80 public BSCharacter(uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, bool isFlying)
81 : base(parent_scene, localID, avName, "BSCharacter")
81 { 82 {
82 base.BaseInitialize(parent_scene, localID, avName, "BSCharacter");
83 _physicsActorType = (int)ActorTypes.Agent; 83 _physicsActorType = (int)ActorTypes.Agent;
84 _position = pos; 84 _position = pos;
85 _size = size; 85 _size = size;
@@ -131,6 +131,10 @@ public sealed class BSCharacter : BSPhysObject
131 // Set the velocity and compute the proper friction 131 // Set the velocity and compute the proper friction
132 ForceVelocity = _velocity; 132 ForceVelocity = _velocity;
133 133
134 // This will enable or disable the flying buoyancy of the avatar.
135 // Needs to be reset especially when an avatar is recreated after crossing a region boundry.
136 Flying = _flying;
137
134 BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.avatarRestitution); 138 BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.avatarRestitution);
135 BulletSimAPI.SetMargin2(PhysShape.ptr, PhysicsScene.Params.collisionMargin); 139 BulletSimAPI.SetMargin2(PhysShape.ptr, PhysicsScene.Params.collisionMargin);
136 BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); 140 BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
@@ -615,7 +619,7 @@ public sealed class BSCharacter : BSPhysObject
615 newScale.Y = PhysicsScene.Params.avatarCapsuleRadius; 619 newScale.Y = PhysicsScene.Params.avatarCapsuleRadius;
616 620
617 // From the total height, remove the capsule half spheres that are at each end 621 // From the total height, remove the capsule half spheres that are at each end
618 newScale.Z = size.Z- (newScale.X + newScale.Y); 622 newScale.Z = size.Z - (newScale.X + newScale.Y);
619 Scale = newScale; 623 Scale = newScale;
620 } 624 }
621 625
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index e803072..991e5b1 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -47,7 +47,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
47 */ 47 */
48public abstract class BSPhysObject : PhysicsActor 48public abstract class BSPhysObject : PhysicsActor
49{ 49{
50 protected void BaseInitialize(BSScene parentScene, uint localID, string name, string typeName) 50 protected BSPhysObject()
51 {
52 }
53 protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName)
51 { 54 {
52 PhysicsScene = parentScene; 55 PhysicsScene = parentScene;
53 LocalID = localID; 56 LocalID = localID;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 14eb505..500c84a 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -88,9 +88,9 @@ public sealed class BSPrim : BSPhysObject
88 88
89 public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, 89 public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
90 OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) 90 OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
91 : base(parent_scene, localID, primName, "BSPrim")
91 { 92 {
92 // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID); 93 // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
93 base.BaseInitialize(parent_scene, localID, primName, "BSPrim");
94 _physicsActorType = (int)ActorTypes.Prim; 94 _physicsActorType = (int)ActorTypes.Prim;
95 _position = pos; 95 _position = pos;
96 _size = size; 96 _size = size;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 1cc607a..2fee95e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -683,7 +683,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
683 #region Taints 683 #region Taints
684 684
685 // Calls to the PhysicsActors can't directly call into the physics engine 685 // Calls to the PhysicsActors can't directly call into the physics engine
686 // because it might be busy. We delay changes to a known time. 686 // because it might be busy. We delay changes to a known time.
687 // We rely on C#'s closure to save and restore the context for the delegate. 687 // We rely on C#'s closure to save and restore the context for the delegate.
688 public void TaintedObject(String ident, TaintCallback callback) 688 public void TaintedObject(String ident, TaintCallback callback)
689 { 689 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
index 5e2c4a8..d59a486 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs
@@ -1,213 +1,208 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyrightD 9 * * Redistributions in binary form must reproduce the above copyrightD
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq; 30using System.Linq;
31using System.Text; 31using System.Text;
32 32
33namespace OpenSim.Region.Physics.BulletSPlugin 33namespace OpenSim.Region.Physics.BulletSPlugin
34{ 34{
35public abstract class BSShape 35public abstract class BSShape
36{ 36{
37 public IntPtr ptr { get; set; } 37 public IntPtr ptr { get; set; }
38 public ShapeData.PhysicsShapeType type { get; set; } 38 public ShapeData.PhysicsShapeType type { get; set; }
39 public System.UInt64 key { get; set; } 39 public System.UInt64 key { get; set; }
40 public int referenceCount { get; set; } 40 public int referenceCount { get; set; }
41 public DateTime lastReferenced { get; set; } 41 public DateTime lastReferenced { get; set; }
42 42
43 protected void Initialize() 43 public BSShape()
44 { 44 {
45 ptr = IntPtr.Zero; 45 ptr = IntPtr.Zero;
46 type = ShapeData.PhysicsShapeType.SHAPE_UNKNOWN; 46 type = ShapeData.PhysicsShapeType.SHAPE_UNKNOWN;
47 key = 0; 47 key = 0;
48 referenceCount = 0; 48 referenceCount = 0;
49 lastReferenced = DateTime.Now; 49 lastReferenced = DateTime.Now;
50 } 50 }
51 51
52 // Get a reference to a physical shape. Create if it doesn't exist 52 // Get a reference to a physical shape. Create if it doesn't exist
53 public static BSShape GetShapeReference(BSScene physicsScene, bool forceRebuild, BSPhysObject prim) 53 public static BSShape GetShapeReference(BSScene physicsScene, bool forceRebuild, BSPhysObject prim)
54 { 54 {
55 BSShape ret = null; 55 BSShape ret = null;
56 56
57 if (prim.PreferredPhysicalShape == ShapeData.PhysicsShapeType.SHAPE_AVATAR) 57 if (prim.PreferredPhysicalShape == ShapeData.PhysicsShapeType.SHAPE_AVATAR)
58 { 58 {
59 // an avatar capsule is close to a native shape (it is not shared) 59 // an avatar capsule is close to a native shape (it is not shared)
60 ret = BSShapeNative.GetReference(physicsScene, prim, ShapeData.PhysicsShapeType.SHAPE_AVATAR, 60 ret = BSShapeNative.GetReference(physicsScene, prim, ShapeData.PhysicsShapeType.SHAPE_AVATAR,
61 ShapeData.FixedShapeKey.KEY_CAPSULE); 61 ShapeData.FixedShapeKey.KEY_CAPSULE);
62 physicsScene.DetailLog("{0},BSShape.GetShapeReference,avatarCapsule,shape={1}", prim.LocalID, ret); 62 physicsScene.DetailLog("{0},BSShape.GetShapeReference,avatarCapsule,shape={1}", prim.LocalID, ret);
63 } 63 }
64 64
65 // Compound shapes are handled special as they are rebuilt from scratch. 65 // Compound shapes are handled special as they are rebuilt from scratch.
66 // This isn't too great a hardship since most of the child shapes will already been created. 66 // This isn't too great a hardship since most of the child shapes will already been created.
67 if (ret == null && prim.PreferredPhysicalShape == ShapeData.PhysicsShapeType.SHAPE_COMPOUND) 67 if (ret == null && prim.PreferredPhysicalShape == ShapeData.PhysicsShapeType.SHAPE_COMPOUND)
68 { 68 {
69 // Getting a reference to a compound shape gets you the compound shape with the root prim shape added 69 // Getting a reference to a compound shape gets you the compound shape with the root prim shape added
70 ret = BSShapeCompound.GetReference(prim); 70 ret = BSShapeCompound.GetReference(prim);
71 physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, ret); 71 physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, ret);
72 } 72 }
73 73
74 if (ret == null) 74 if (ret == null)
75 ret = GetShapeReferenceNonSpecial(physicsScene, forceRebuild, prim); 75 ret = GetShapeReferenceNonSpecial(physicsScene, forceRebuild, prim);
76 76
77 return ret; 77 return ret;
78 } 78 }
79 public static BSShape GetShapeReferenceNonSpecial(BSScene physicsScene, bool forceRebuild, BSPhysObject prim) 79 public static BSShape GetShapeReferenceNonSpecial(BSScene physicsScene, bool forceRebuild, BSPhysObject prim)
80 { 80 {
81 return null; 81 return null;
82 } 82 }
83 public static BSShape GetShapeReferenceNonNative(BSScene physicsScene, bool forceRebuild, BSPhysObject prim) 83 public static BSShape GetShapeReferenceNonNative(BSScene physicsScene, bool forceRebuild, BSPhysObject prim)
84 { 84 {
85 return null; 85 return null;
86 } 86 }
87 87
88 // Release the use of a physical shape. 88 // Release the use of a physical shape.
89 public abstract void Dereference(BSScene physicsScene); 89 public abstract void Dereference(BSScene physicsScene);
90 90
91 // All shapes have a static call to get a reference to the physical shape 91 // All shapes have a static call to get a reference to the physical shape
92 // protected abstract static BSShape GetReference(); 92 // protected abstract static BSShape GetReference();
93 93
94 public override string ToString() 94 public override string ToString()
95 { 95 {
96 StringBuilder buff = new StringBuilder(); 96 StringBuilder buff = new StringBuilder();
97 buff.Append("<p="); 97 buff.Append("<p=");
98 buff.Append(ptr.ToString("X")); 98 buff.Append(ptr.ToString("X"));
99 buff.Append(",s="); 99 buff.Append(",s=");
100 buff.Append(type.ToString()); 100 buff.Append(type.ToString());
101 buff.Append(",k="); 101 buff.Append(",k=");
102 buff.Append(key.ToString("X")); 102 buff.Append(key.ToString("X"));
103 buff.Append(",c="); 103 buff.Append(",c=");
104 buff.Append(referenceCount.ToString()); 104 buff.Append(referenceCount.ToString());
105 buff.Append(">"); 105 buff.Append(">");
106 return buff.ToString(); 106 return buff.ToString();
107 } 107 }
108} 108}
109 109
110public class BSShapeNull : BSShape 110public class BSShapeNull : BSShape
111{ 111{
112 public BSShapeNull() 112 public BSShapeNull() : base()
113 { 113 {
114 base.Initialize(); 114 }
115 } 115 public static BSShape GetReference() { return new BSShapeNull(); }
116 public static BSShape GetReference() { return new BSShapeNull(); } 116 public override void Dereference(BSScene physicsScene) { /* The magic of garbage collection will make this go away */ }
117 public override void Dereference(BSScene physicsScene) { /* The magic of garbage collection will make this go away */ } 117}
118} 118
119 119public class BSShapeNative : BSShape
120public class BSShapeNative : BSShape 120{
121{ 121 private static string LogHeader = "[BULLETSIM SHAPE NATIVE]";
122 private static string LogHeader = "[BULLETSIM SHAPE NATIVE]"; 122 public BSShapeNative() : base()
123 public BSShapeNative() 123 {
124 { 124 }
125 base.Initialize(); 125 public static BSShape GetReference(BSScene physicsScene, BSPhysObject prim,
126 } 126 ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey)
127 public static BSShape GetReference(BSScene physicsScene, BSPhysObject prim, 127 {
128 ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey) 128 // Native shapes are not shared and are always built anew.
129 { 129 return new BSShapeNative(physicsScene, prim, shapeType, shapeKey);
130 // Native shapes are not shared and are always built anew. 130 }
131 return new BSShapeNative(physicsScene, prim, shapeType, shapeKey); 131
132 } 132 private BSShapeNative(BSScene physicsScene, BSPhysObject prim,
133 133 ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey)
134 private BSShapeNative(BSScene physicsScene, BSPhysObject prim, 134 {
135 ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey) 135 ShapeData nativeShapeData = new ShapeData();
136 { 136 nativeShapeData.Type = shapeType;
137 ShapeData nativeShapeData = new ShapeData(); 137 nativeShapeData.ID = prim.LocalID;
138 nativeShapeData.Type = shapeType; 138 nativeShapeData.Scale = prim.Scale;
139 nativeShapeData.ID = prim.LocalID; 139 nativeShapeData.Size = prim.Scale;
140 nativeShapeData.Scale = prim.Scale; 140 nativeShapeData.MeshKey = (ulong)shapeKey;
141 nativeShapeData.Size = prim.Scale; 141 nativeShapeData.HullKey = (ulong)shapeKey;
142 nativeShapeData.MeshKey = (ulong)shapeKey; 142
143 nativeShapeData.HullKey = (ulong)shapeKey; 143
144 144 if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR)
145 145 {
146 if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR) 146 ptr = BulletSimAPI.BuildCapsuleShape2(physicsScene.World.ptr, 1f, 1f, prim.Scale);
147 { 147 physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale);
148 ptr = BulletSimAPI.BuildCapsuleShape2(physicsScene.World.ptr, 1f, 1f, prim.Scale); 148 }
149 physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); 149 else
150 } 150 {
151 else 151 ptr = BulletSimAPI.BuildNativeShape2(physicsScene.World.ptr, nativeShapeData);
152 { 152 }
153 ptr = BulletSimAPI.BuildNativeShape2(physicsScene.World.ptr, nativeShapeData); 153 if (ptr == IntPtr.Zero)
154 } 154 {
155 if (ptr == IntPtr.Zero) 155 physicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}",
156 { 156 LogHeader, prim.LocalID, shapeType);
157 physicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}", 157 }
158 LogHeader, prim.LocalID, shapeType); 158 type = shapeType;
159 } 159 key = (UInt64)shapeKey;
160 type = shapeType; 160 }
161 key = (UInt64)shapeKey; 161 // Make this reference to the physical shape go away since native shapes are not shared.
162 } 162 public override void Dereference(BSScene physicsScene)
163 // Make this reference to the physical shape go away since native shapes are not shared. 163 {
164 public override void Dereference(BSScene physicsScene) 164 // Native shapes are not tracked and are released immediately
165 { 165 physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this);
166 // Native shapes are not tracked and are released immediately 166 BulletSimAPI.DeleteCollisionShape2(physicsScene.World.ptr, ptr);
167 physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this); 167 ptr = IntPtr.Zero;
168 BulletSimAPI.DeleteCollisionShape2(physicsScene.World.ptr, ptr); 168 // Garbage collection will free up this instance.
169 ptr = IntPtr.Zero; 169 }
170 // Garbage collection will free up this instance. 170}
171 } 171
172} 172public class BSShapeMesh : BSShape
173 173{
174public class BSShapeMesh : BSShape 174 private static string LogHeader = "[BULLETSIM SHAPE MESH]";
175{ 175 private static Dictionary<System.UInt64, BSShapeMesh> Meshes = new Dictionary<System.UInt64, BSShapeMesh>();
176 private static string LogHeader = "[BULLETSIM SHAPE MESH]"; 176
177 private static Dictionary<System.UInt64, BSShapeMesh> Meshes = new Dictionary<System.UInt64, BSShapeMesh>(); 177 public BSShapeMesh() : base()
178 178 {
179 public BSShapeMesh() 179 }
180 { 180 public static BSShape GetReference() { return new BSShapeNull(); }
181 base.Initialize(); 181 public override void Dereference(BSScene physicsScene) { }
182 } 182}
183 public static BSShape GetReference() { return new BSShapeNull(); } 183
184 public override void Dereference(BSScene physicsScene) { } 184public class BSShapeHull : BSShape
185} 185{
186 186 private static string LogHeader = "[BULLETSIM SHAPE HULL]";
187public class BSShapeHull : BSShape 187 private static Dictionary<System.UInt64, BSShapeHull> Hulls = new Dictionary<System.UInt64, BSShapeHull>();
188{ 188
189 private static string LogHeader = "[BULLETSIM SHAPE HULL]"; 189 public BSShapeHull() : base()
190 private static Dictionary<System.UInt64, BSShapeHull> Hulls = new Dictionary<System.UInt64, BSShapeHull>(); 190 {
191 191 }
192 public BSShapeHull() 192 public static BSShape GetReference() { return new BSShapeNull(); }
193 { 193 public override void Dereference(BSScene physicsScene) { }
194 base.Initialize(); 194}
195 } 195
196 public static BSShape GetReference() { return new BSShapeNull(); } 196public class BSShapeCompound : BSShape
197 public override void Dereference(BSScene physicsScene) { } 197{
198} 198 private static string LogHeader = "[BULLETSIM SHAPE COMPOUND]";
199 199 public BSShapeCompound() : base()
200public class BSShapeCompound : BSShape 200 {
201{ 201 }
202 private static string LogHeader = "[BULLETSIM SHAPE COMPOUND]"; 202 public static BSShape GetReference(BSPhysObject prim)
203 public BSShapeCompound() 203 {
204 { 204 return new BSShapeNull();
205 base.Initialize(); 205 }
206 } 206 public override void Dereference(BSScene physicsScene) { }
207 public static BSShape GetReference(BSPhysObject prim) 207}
208 { 208}
209 return new BSShapeNull();
210 }
211 public override void Dereference(BSScene physicsScene) { }
212}
213}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 07149d8..28fae13 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -429,140 +429,6 @@ static class BulletSimAPI {
429[UnmanagedFunctionPointer(CallingConvention.Cdecl)] 429[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
430public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); 430public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
431 431
432[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
433[return: MarshalAs(UnmanagedType.LPStr)]
434public static extern string GetVersion();
435
436/* Remove the linkage to the old api methods
437[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
438public static extern uint Initialize(Vector3 maxPosition, IntPtr parms,
439 int maxCollisions, IntPtr collisionArray,
440 int maxUpdates, IntPtr updateArray,
441 DebugLogCallback logRoutine);
442
443[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
444public static extern void CreateInitialGroundPlaneAndTerrain(uint worldID);
445
446[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
447public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
448
449[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
450public static extern void Shutdown(uint worldID);
451
452[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
453public static extern bool UpdateParameter(uint worldID, uint localID,
454 [MarshalAs(UnmanagedType.LPStr)]string paramCode, float value);
455
456// ===============================================================================
457[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
458public static extern int PhysicsStep(uint worldID, float timeStep, int maxSubSteps, float fixedTimeStep,
459 out int updatedEntityCount,
460 out IntPtr updatedEntitiesPtr,
461 out int collidersCount,
462 out IntPtr collidersPtr);
463
464[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
465public static extern bool CreateHull(uint worldID, System.UInt64 meshKey,
466 int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls
467 );
468
469[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
470public static extern bool CreateMesh(uint worldID, System.UInt64 meshKey,
471 int indexCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices,
472 int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices
473 );
474
475[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
476public static extern bool DestroyHull(uint worldID, System.UInt64 meshKey);
477
478[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
479public static extern bool DestroyMesh(uint worldID, System.UInt64 meshKey);
480
481[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
482public static extern bool CreateObject(uint worldID, ShapeData shapeData);
483
484[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
485public static extern Vector3 GetObjectPosition(uint WorldID, uint id);
486
487[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
488public static extern Quaternion GetObjectOrientation(uint WorldID, uint id);
489
490[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
491public static extern bool SetObjectTranslation(uint worldID, uint id, Vector3 position, Quaternion rotation);
492
493[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
494public static extern bool SetObjectVelocity(uint worldID, uint id, Vector3 velocity);
495
496[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
497public static extern bool SetObjectAngularVelocity(uint worldID, uint id, Vector3 angularVelocity);
498
499// Set the current force acting on the object
500[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
501public static extern bool SetObjectForce(uint worldID, uint id, Vector3 force);
502
503[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
504public static extern bool SetObjectScaleMass(uint worldID, uint id, Vector3 scale, float mass, bool isDynamic);
505
506[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
507public static extern bool SetObjectCollidable(uint worldID, uint id, bool phantom);
508
509[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
510public static extern bool SetObjectDynamic(uint worldID, uint id, bool isDynamic, float mass);
511
512[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
513public static extern bool SetObjectGhost(uint worldID, uint id, bool ghostly);
514
515[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
516public static extern bool SetObjectProperties(uint worldID, uint id, bool isStatic, bool isSolid, bool genCollisions, float mass);
517
518[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
519public static extern bool SetObjectBuoyancy(uint worldID, uint id, float buoyancy);
520
521[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
522public static extern bool HasObject(uint worldID, uint id);
523
524[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
525public static extern bool DestroyObject(uint worldID, uint id);
526
527// ===============================================================================
528[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
529public static extern SweepHit ConvexSweepTest(uint worldID, uint id, Vector3 to, float extraMargin);
530
531[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
532public static extern RaycastHit RayTest(uint worldID, uint id, Vector3 from, Vector3 to);
533
534[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
535public static extern Vector3 RecoverFromPenetration(uint worldID, uint id);
536
537// ===============================================================================
538[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
539public static extern void DumpBulletStatistics();
540*/
541// Log a debug message
542[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
543public static extern void SetDebugLogCallback(DebugLogCallback callback);
544
545// ===============================================================================
546// ===============================================================================
547// ===============================================================================
548// A new version of the API that enables moving all the logic out of the C++ code and into
549// the C# code. This will make modifications easier for the next person.
550// This interface passes the actual pointers to the objects in the unmanaged
551// address space. All the management (calls for creation/destruction/lookup)
552// is done in the C# code.
553// The names have a "2" tacked on. This will be removed as the C# code gets rebuilt
554// and the old code is removed.
555
556// Functions use while converting from API1 to API2. Can be removed when totally converted.
557[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
558public static extern IntPtr GetSimHandle2(uint worldID);
559
560[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
561public static extern IntPtr GetBodyHandleWorldID2(uint worldID, uint id);
562
563[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
564public static extern IntPtr GetBodyHandle2(IntPtr world, uint id);
565
566// =============================================================================== 432// ===============================================================================
567// Initialization and simulation 433// Initialization and simulation
568[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 434[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]