diff options
author | Justin Clark-Casey (justincc) | 2013-01-01 23:27:10 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-01-01 23:27:10 +0000 |
commit | e8a3cc701910130e1aafb2b757737517c1cd1627 (patch) | |
tree | f1fd4ed9cf2b8e80ea43d2a8028837874f1b193c /OpenSim/Region/Physics | |
parent | Clarify that AllowLightShareFunctions setting is false, which is the default ... (diff) | |
parent | BulletSim: remove unused unmanaged memory reference functions from BSAPITempl... (diff) | |
download | opensim-SC_OLD-e8a3cc701910130e1aafb2b757737517c1cd1627.zip opensim-SC_OLD-e8a3cc701910130e1aafb2b757737517c1cd1627.tar.gz opensim-SC_OLD-e8a3cc701910130e1aafb2b757737517c1cd1627.tar.bz2 opensim-SC_OLD-e8a3cc701910130e1aafb2b757737517c1cd1627.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/Physics')
23 files changed, 1887 insertions, 886 deletions
diff --git a/OpenSim/Region/Physics/BulletSNPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSNPlugin/BSPrim.cs index 9c4ba30..aadb5b2 100644 --- a/OpenSim/Region/Physics/BulletSNPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSNPlugin/BSPrim.cs | |||
@@ -111,10 +111,6 @@ public sealed class BSPrim : BSPhysObject | |||
111 | 111 | ||
112 | _mass = CalculateMass(); | 112 | _mass = CalculateMass(); |
113 | 113 | ||
114 | // No body or shape yet | ||
115 | PhysBody = new BulletBody(LocalID); | ||
116 | PhysShape = new BulletShape(); | ||
117 | |||
118 | Linkset.Refresh(this); | 114 | Linkset.Refresh(this); |
119 | 115 | ||
120 | DetailLog("{0},BSPrim.constructor,call", LocalID); | 116 | DetailLog("{0},BSPrim.constructor,call", LocalID); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs index b361498..3975776 100644..100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs | |||
@@ -26,664 +26,954 @@ | |||
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | ||
29 | using System.Runtime.InteropServices; | 30 | using System.Runtime.InteropServices; |
30 | using System.Security; | 31 | using System.Security; |
31 | using System.Text; | 32 | using System.Text; |
33 | |||
32 | using OpenMetaverse; | 34 | using OpenMetaverse; |
33 | 35 | ||
34 | namespace OpenSim.Region.Physics.BulletSPlugin { | 36 | namespace OpenSim.Region.Physics.BulletSPlugin |
37 | { | ||
38 | public sealed class BSAPIUnman : BSAPITemplate | ||
39 | { | ||
40 | |||
41 | // We pin the memory passed between the managed and unmanaged code. | ||
42 | GCHandle m_paramsHandle; | ||
43 | private GCHandle m_collisionArrayPinnedHandle; | ||
44 | private GCHandle m_updateArrayPinnedHandle; | ||
45 | |||
46 | // Handle to the callback used by the unmanaged code to call into the managed code. | ||
47 | // Used for debug logging. | ||
48 | // Need to store the handle in a persistant variable so it won't be freed. | ||
49 | private BSAPICPP.DebugLogCallback m_DebugLogCallbackHandle; | ||
50 | |||
51 | private BSScene PhysicsScene { get; set; } | ||
52 | |||
53 | public override string BulletEngineName { get { return "BulletUnmanaged"; } } | ||
54 | public override string BulletEngineVersion { get; protected set; } | ||
35 | 55 | ||
36 | // Constraint type values as defined by Bullet | 56 | public BSAPIUnman(string paramName, BSScene physScene) |
37 | public enum ConstraintType : int | ||
38 | { | 57 | { |
39 | POINT2POINT_CONSTRAINT_TYPE = 3, | 58 | PhysicsScene = physScene; |
40 | HINGE_CONSTRAINT_TYPE, | 59 | // Do something fancy with the paramName to get the right DLL implementation |
41 | CONETWIST_CONSTRAINT_TYPE, | 60 | // like "Bullet-2.80-OpenCL-Intel" loading the version for Intel based OpenCL implementation, etc. |
42 | D6_CONSTRAINT_TYPE, | ||
43 | SLIDER_CONSTRAINT_TYPE, | ||
44 | CONTACT_CONSTRAINT_TYPE, | ||
45 | D6_SPRING_CONSTRAINT_TYPE, | ||
46 | MAX_CONSTRAINT_TYPE | ||
47 | } | 61 | } |
48 | 62 | ||
49 | // =============================================================================== | ||
50 | [StructLayout(LayoutKind.Sequential)] | ||
51 | public struct ConvexHull | ||
52 | { | ||
53 | Vector3 Offset; | ||
54 | int VertexCount; | ||
55 | Vector3[] Vertices; | ||
56 | } | ||
57 | public enum BSPhysicsShapeType | ||
58 | { | ||
59 | SHAPE_UNKNOWN = 0, | ||
60 | SHAPE_CAPSULE = 1, | ||
61 | SHAPE_BOX = 2, | ||
62 | SHAPE_CONE = 3, | ||
63 | SHAPE_CYLINDER = 4, | ||
64 | SHAPE_SPHERE = 5, | ||
65 | SHAPE_MESH = 6, | ||
66 | SHAPE_HULL = 7, | ||
67 | // following defined by BulletSim | ||
68 | SHAPE_GROUNDPLANE = 20, | ||
69 | SHAPE_TERRAIN = 21, | ||
70 | SHAPE_COMPOUND = 22, | ||
71 | SHAPE_HEIGHTMAP = 23, | ||
72 | SHAPE_AVATAR = 24, | ||
73 | }; | ||
74 | |||
75 | // The native shapes have predefined shape hash keys | ||
76 | public enum FixedShapeKey : ulong | ||
77 | { | ||
78 | KEY_NONE = 0, | ||
79 | KEY_BOX = 1, | ||
80 | KEY_SPHERE = 2, | ||
81 | KEY_CONE = 3, | ||
82 | KEY_CYLINDER = 4, | ||
83 | KEY_CAPSULE = 5, | ||
84 | KEY_AVATAR = 6, | ||
85 | } | ||
86 | |||
87 | [StructLayout(LayoutKind.Sequential)] | ||
88 | public struct ShapeData | ||
89 | { | ||
90 | public uint ID; | ||
91 | public BSPhysicsShapeType Type; | ||
92 | public Vector3 Position; | ||
93 | public Quaternion Rotation; | ||
94 | public Vector3 Velocity; | ||
95 | public Vector3 Scale; | ||
96 | public float Mass; | ||
97 | public float Buoyancy; | ||
98 | public System.UInt64 HullKey; | ||
99 | public System.UInt64 MeshKey; | ||
100 | public float Friction; | ||
101 | public float Restitution; | ||
102 | public float Collidable; // true of things bump into this | ||
103 | public float Static; // true if a static object. Otherwise gravity, etc. | ||
104 | public float Solid; // true if object cannot be passed through | ||
105 | public Vector3 Size; | ||
106 | |||
107 | // note that bools are passed as floats since bool size changes by language and architecture | ||
108 | public const float numericTrue = 1f; | ||
109 | public const float numericFalse = 0f; | ||
110 | } | ||
111 | [StructLayout(LayoutKind.Sequential)] | ||
112 | public struct SweepHit | ||
113 | { | ||
114 | public uint ID; | ||
115 | public float Fraction; | ||
116 | public Vector3 Normal; | ||
117 | public Vector3 Point; | ||
118 | } | ||
119 | [StructLayout(LayoutKind.Sequential)] | ||
120 | public struct RaycastHit | ||
121 | { | ||
122 | public uint ID; | ||
123 | public float Fraction; | ||
124 | public Vector3 Normal; | ||
125 | } | ||
126 | [StructLayout(LayoutKind.Sequential)] | ||
127 | public struct CollisionDesc | ||
128 | { | ||
129 | public uint aID; | ||
130 | public uint bID; | ||
131 | public Vector3 point; | ||
132 | public Vector3 normal; | ||
133 | } | ||
134 | [StructLayout(LayoutKind.Sequential)] | ||
135 | public struct EntityProperties | ||
136 | { | ||
137 | public uint ID; | ||
138 | public Vector3 Position; | ||
139 | public Quaternion Rotation; | ||
140 | public Vector3 Velocity; | ||
141 | public Vector3 Acceleration; | ||
142 | public Vector3 RotationalVelocity; | ||
143 | } | ||
144 | |||
145 | // Format of this structure must match the definition in the C++ code | ||
146 | // NOTE: adding the X causes compile breaks if used. These are unused symbols | ||
147 | // that can be removed from both here and the unmanaged definition of this structure. | ||
148 | [StructLayout(LayoutKind.Sequential)] | ||
149 | public struct ConfigurationParameters | ||
150 | { | ||
151 | public float defaultFriction; | ||
152 | public float defaultDensity; | ||
153 | public float defaultRestitution; | ||
154 | public float collisionMargin; | ||
155 | public float gravity; | ||
156 | |||
157 | public float XlinearDamping; | ||
158 | public float XangularDamping; | ||
159 | public float XdeactivationTime; | ||
160 | public float XlinearSleepingThreshold; | ||
161 | public float XangularSleepingThreshold; | ||
162 | public float XccdMotionThreshold; | ||
163 | public float XccdSweptSphereRadius; | ||
164 | public float XcontactProcessingThreshold; | ||
165 | |||
166 | public float XterrainImplementation; | ||
167 | public float XterrainFriction; | ||
168 | public float XterrainHitFraction; | ||
169 | public float XterrainRestitution; | ||
170 | public float XterrainCollisionMargin; | ||
171 | |||
172 | public float XavatarFriction; | ||
173 | public float XavatarStandingFriction; | ||
174 | public float XavatarDensity; | ||
175 | public float XavatarRestitution; | ||
176 | public float XavatarCapsuleWidth; | ||
177 | public float XavatarCapsuleDepth; | ||
178 | public float XavatarCapsuleHeight; | ||
179 | public float XavatarContactProcessingThreshold; | ||
180 | |||
181 | public float XvehicleAngularDamping; | ||
182 | |||
183 | public float maxPersistantManifoldPoolSize; | ||
184 | public float maxCollisionAlgorithmPoolSize; | ||
185 | public float shouldDisableContactPoolDynamicAllocation; | ||
186 | public float shouldForceUpdateAllAabbs; | ||
187 | public float shouldRandomizeSolverOrder; | ||
188 | public float shouldSplitSimulationIslands; | ||
189 | public float shouldEnableFrictionCaching; | ||
190 | public float numberOfSolverIterations; | ||
191 | |||
192 | public float XlinksetImplementation; | ||
193 | public float XlinkConstraintUseFrameOffset; | ||
194 | public float XlinkConstraintEnableTransMotor; | ||
195 | public float XlinkConstraintTransMotorMaxVel; | ||
196 | public float XlinkConstraintTransMotorMaxForce; | ||
197 | public float XlinkConstraintERP; | ||
198 | public float XlinkConstraintCFM; | ||
199 | public float XlinkConstraintSolverIterations; | ||
200 | |||
201 | public float physicsLoggingFrames; | ||
202 | |||
203 | public const float numericTrue = 1f; | ||
204 | public const float numericFalse = 0f; | ||
205 | } | ||
206 | |||
207 | |||
208 | // The states a bullet collision object can have | ||
209 | public enum ActivationState : uint | ||
210 | { | ||
211 | ACTIVE_TAG = 1, | ||
212 | ISLAND_SLEEPING, | ||
213 | WANTS_DEACTIVATION, | ||
214 | DISABLE_DEACTIVATION, | ||
215 | DISABLE_SIMULATION, | ||
216 | } | ||
217 | |||
218 | public enum CollisionObjectTypes : int | ||
219 | { | ||
220 | CO_COLLISION_OBJECT = 1 << 0, | ||
221 | CO_RIGID_BODY = 1 << 1, | ||
222 | CO_GHOST_OBJECT = 1 << 2, | ||
223 | CO_SOFT_BODY = 1 << 3, | ||
224 | CO_HF_FLUID = 1 << 4, | ||
225 | CO_USER_TYPE = 1 << 5, | ||
226 | } | ||
227 | |||
228 | // Values used by Bullet and BulletSim to control object properties. | ||
229 | // Bullet's "CollisionFlags" has more to do with operations on the | ||
230 | // object (if collisions happen, if gravity effects it, ...). | ||
231 | public enum CollisionFlags : uint | ||
232 | { | ||
233 | CF_STATIC_OBJECT = 1 << 0, | ||
234 | CF_KINEMATIC_OBJECT = 1 << 1, | ||
235 | CF_NO_CONTACT_RESPONSE = 1 << 2, | ||
236 | CF_CUSTOM_MATERIAL_CALLBACK = 1 << 3, | ||
237 | CF_CHARACTER_OBJECT = 1 << 4, | ||
238 | CF_DISABLE_VISUALIZE_OBJECT = 1 << 5, | ||
239 | CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6, | ||
240 | // Following used by BulletSim to control collisions and updates | ||
241 | BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, | ||
242 | BS_FLOATS_ON_WATER = 1 << 11, | ||
243 | BS_VEHICLE_COLLISIONS = 1 << 12, | ||
244 | BS_NONE = 0, | ||
245 | BS_ALL = 0xFFFFFFFF | ||
246 | }; | ||
247 | |||
248 | // Values f collisions groups and masks | ||
249 | public enum CollisionFilterGroups : uint | ||
250 | { | ||
251 | // Don't use the bit definitions!! Define the use in a | ||
252 | // filter/mask definition below. This way collision interactions | ||
253 | // are more easily found and debugged. | ||
254 | BNoneGroup = 0, | ||
255 | BDefaultGroup = 1 << 0, // 0001 | ||
256 | BStaticGroup = 1 << 1, // 0002 | ||
257 | BKinematicGroup = 1 << 2, // 0004 | ||
258 | BDebrisGroup = 1 << 3, // 0008 | ||
259 | BSensorTrigger = 1 << 4, // 0010 | ||
260 | BCharacterGroup = 1 << 5, // 0020 | ||
261 | BAllGroup = 0x000FFFFF, | ||
262 | // Filter groups defined by BulletSim | ||
263 | BGroundPlaneGroup = 1 << 10, // 0400 | ||
264 | BTerrainGroup = 1 << 11, // 0800 | ||
265 | BRaycastGroup = 1 << 12, // 1000 | ||
266 | BSolidGroup = 1 << 13, // 2000 | ||
267 | // BLinksetGroup = xx // a linkset proper is either static or dynamic | ||
268 | BLinksetChildGroup = 1 << 14, // 4000 | ||
269 | }; | ||
270 | |||
271 | // CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0 | ||
272 | // ERP controls amount of correction per tick. Usable range=0.1..0.8. Default=0.2. | ||
273 | public enum ConstraintParams : int | ||
274 | { | ||
275 | BT_CONSTRAINT_ERP = 1, // this one is not used in Bullet as of 20120730 | ||
276 | BT_CONSTRAINT_STOP_ERP, | ||
277 | BT_CONSTRAINT_CFM, | ||
278 | BT_CONSTRAINT_STOP_CFM, | ||
279 | }; | ||
280 | public enum ConstraintParamAxis : int | ||
281 | { | ||
282 | AXIS_LINEAR_X = 0, | ||
283 | AXIS_LINEAR_Y, | ||
284 | AXIS_LINEAR_Z, | ||
285 | AXIS_ANGULAR_X, | ||
286 | AXIS_ANGULAR_Y, | ||
287 | AXIS_ANGULAR_Z, | ||
288 | AXIS_LINEAR_ALL = 20, // these last three added by BulletSim so we don't have to do zillions of calls | ||
289 | AXIS_ANGULAR_ALL, | ||
290 | AXIS_ALL | ||
291 | }; | ||
292 | |||
293 | public abstract class BulletSimAPITemplate | ||
294 | { | ||
295 | // Initialization and simulation | 63 | // Initialization and simulation |
296 | public abstract BulletWorld Initialize2(Vector3 maxPosition, IntPtr parms, | 64 | public override BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms, |
297 | int maxCollisions, IntPtr collisionArray, | 65 | int maxCollisions, ref CollisionDesc[] collisionArray, |
298 | int maxUpdates, IntPtr updateArray | 66 | int maxUpdates, ref EntityProperties[] updateArray |
299 | ); | 67 | ) |
68 | { | ||
69 | // Pin down the memory that will be used to pass object collisions and updates back from unmanaged code | ||
70 | m_paramsHandle = GCHandle.Alloc(parms, GCHandleType.Pinned); | ||
71 | m_collisionArrayPinnedHandle = GCHandle.Alloc(collisionArray, GCHandleType.Pinned); | ||
72 | m_updateArrayPinnedHandle = GCHandle.Alloc(updateArray, GCHandleType.Pinned); | ||
73 | |||
74 | // If Debug logging level, enable logging from the unmanaged code | ||
75 | m_DebugLogCallbackHandle = null; | ||
76 | if (BSScene.m_log.IsDebugEnabled || PhysicsScene.PhysicsLogging.Enabled) | ||
77 | { | ||
78 | BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader); | ||
79 | if (PhysicsScene.PhysicsLogging.Enabled) | ||
80 | // The handle is saved in a variable to make sure it doesn't get freed after this call | ||
81 | m_DebugLogCallbackHandle = new BSAPICPP.DebugLogCallback(BulletLoggerPhysLog); | ||
82 | else | ||
83 | m_DebugLogCallbackHandle = new BSAPICPP.DebugLogCallback(BulletLogger); | ||
84 | } | ||
85 | |||
86 | // Get the version of the DLL | ||
87 | // TODO: this doesn't work yet. Something wrong with marshaling the returned string. | ||
88 | // BulletEngineVersion = BulletSimAPI.GetVersion2(); | ||
89 | BulletEngineVersion = ""; | ||
90 | |||
91 | // Call the unmanaged code with the buffers and other information | ||
92 | return new BulletWorld(0, PhysicsScene, BSAPICPP.Initialize2(maxPosition, m_paramsHandle.AddrOfPinnedObject(), | ||
93 | maxCollisions, m_collisionArrayPinnedHandle.AddrOfPinnedObject(), | ||
94 | maxUpdates, m_updateArrayPinnedHandle.AddrOfPinnedObject(), | ||
95 | m_DebugLogCallbackHandle)); | ||
300 | 96 | ||
301 | public abstract bool UpdateParameter2(BulletWorld world, uint localID, String parm, float value); | 97 | } |
302 | 98 | ||
303 | public abstract void SetHeightMap2(BulletWorld world, float[] heightmap); | 99 | // Called directly from unmanaged code so don't do much |
100 | private void BulletLogger(string msg) | ||
101 | { | ||
102 | BSScene.m_log.Debug("[BULLETS UNMANAGED]:" + msg); | ||
103 | } | ||
304 | 104 | ||
305 | public abstract void Shutdown2(BulletWorld sim); | 105 | // Called directly from unmanaged code so don't do much |
106 | private void BulletLoggerPhysLog(string msg) | ||
107 | { | ||
108 | PhysicsScene.DetailLog("[BULLETS UNMANAGED]:" + msg); | ||
109 | } | ||
306 | 110 | ||
307 | public abstract int PhysicsStep2(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, | 111 | public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, |
308 | out int updatedEntityCount, | 112 | out int updatedEntityCount, out int collidersCount) |
309 | out IntPtr updatedEntitiesPtr, | 113 | { |
310 | out int collidersCount, | 114 | return BSAPICPP.PhysicsStep2(world.ptr, timeStep, maxSubSteps, fixedTimeStep, out updatedEntityCount, out collidersCount); |
311 | out IntPtr collidersPtr); | 115 | } |
312 | 116 | ||
313 | public abstract bool PushUpdate2(BulletBody obj); | 117 | public override void Shutdown(BulletWorld sim) |
118 | { | ||
119 | BSAPICPP.Shutdown2(sim.ptr); | ||
120 | } | ||
314 | 121 | ||
315 | // ===================================================================================== | 122 | public override bool PushUpdate(BulletBody obj) |
316 | // Mesh, hull, shape and body creation helper routines | 123 | { |
317 | public abstract BulletShape CreateMeshShape2(BulletWorld world, | 124 | return BSAPICPP.PushUpdate2(obj.ptr); |
318 | int indicesCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices, | 125 | } |
319 | int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices ); | ||
320 | 126 | ||
321 | public abstract BulletShape CreateHullShape2(BulletWorld world, | 127 | public override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value) |
322 | int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls); | 128 | { |
129 | return BSAPICPP.UpdateParameter2(world.ptr, localID, parm, value); | ||
130 | } | ||
323 | 131 | ||
324 | public abstract BulletShape BuildHullShapeFromMesh2(BulletWorld world, BulletShape meshShape); | 132 | // ===================================================================================== |
133 | // Mesh, hull, shape and body creation helper routines | ||
134 | public override BulletShape CreateMeshShape(BulletWorld world, | ||
135 | int indicesCount, int[] indices, | ||
136 | int verticesCount, float[] vertices) | ||
137 | { | ||
138 | return new BulletShape( | ||
139 | BSAPICPP.CreateMeshShape2(world.ptr, indicesCount, indices, verticesCount, vertices), | ||
140 | BSPhysicsShapeType.SHAPE_MESH); | ||
141 | } | ||
325 | 142 | ||
326 | public abstract BulletShape BuildNativeShape2(BulletWorld world, ShapeData shapeData); | 143 | public override BulletShape CreateHullShape(BulletWorld world, int hullCount, float[] hulls) |
144 | { | ||
145 | return new BulletShape( | ||
146 | BSAPICPP.CreateHullShape2(world.ptr, hullCount, hulls), | ||
147 | BSPhysicsShapeType.SHAPE_HULL); | ||
148 | } | ||
327 | 149 | ||
328 | public abstract bool IsNativeShape2(BulletShape shape); | 150 | public override BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape) |
151 | { | ||
152 | return new BulletShape( | ||
153 | BSAPICPP.BuildHullShapeFromMesh2(world.ptr, meshShape.ptr), | ||
154 | BSPhysicsShapeType.SHAPE_HULL); | ||
155 | } | ||
329 | 156 | ||
330 | public abstract void SetShapeCollisionMargin(BulletShape shape, float margin); | 157 | public override BulletShape BuildNativeShape( BulletWorld world, ShapeData shapeData) |
158 | { | ||
159 | return new BulletShape( | ||
160 | BSAPICPP.BuildNativeShape2(world.ptr, shapeData), | ||
161 | shapeData.Type); | ||
162 | } | ||
331 | 163 | ||
332 | public abstract BulletShape BuildCapsuleShape2(BulletWorld world, float radius, float height, Vector3 scale); | 164 | public override bool IsNativeShape(BulletShape shape) |
165 | { | ||
166 | if (shape.HasPhysicalShape) | ||
167 | return BSAPICPP.IsNativeShape2(shape.ptr); | ||
168 | return false; | ||
169 | } | ||
333 | 170 | ||
334 | public abstract BulletShape CreateCompoundShape2(BulletWorld sim, bool enableDynamicAabbTree); | 171 | public override void SetShapeCollisionMargin(BulletShape shape, float margin) |
172 | { | ||
173 | if (shape.HasPhysicalShape) | ||
174 | BSAPICPP.SetShapeCollisionMargin2(shape.ptr, margin); | ||
175 | } | ||
335 | 176 | ||
336 | public abstract int GetNumberOfCompoundChildren2(BulletShape cShape); | 177 | public override BulletShape BuildCapsuleShape(BulletWorld world, float radius, float height, Vector3 scale) |
178 | { | ||
179 | return new BulletShape( | ||
180 | BSAPICPP.BuildCapsuleShape2(world.ptr, radius, height, scale), | ||
181 | BSPhysicsShapeType.SHAPE_CAPSULE); | ||
182 | } | ||
337 | 183 | ||
338 | public abstract void AddChildShapeToCompoundShape2(BulletShape cShape, BulletShape addShape, Vector3 pos, Quaternion rot); | 184 | public override BulletShape CreateCompoundShape(BulletWorld sim, bool enableDynamicAabbTree) |
185 | { | ||
186 | return new BulletShape( | ||
187 | BSAPICPP.CreateCompoundShape2(sim.ptr, enableDynamicAabbTree), | ||
188 | BSPhysicsShapeType.SHAPE_COMPOUND); | ||
339 | 189 | ||
340 | public abstract BulletShape GetChildShapeFromCompoundShapeIndex2(BulletShape cShape, int indx); | 190 | } |
341 | 191 | ||
342 | public abstract BulletShape RemoveChildShapeFromCompoundShapeIndex2(BulletShape cShape, int indx); | 192 | public override int GetNumberOfCompoundChildren(BulletShape shape) |
193 | { | ||
194 | if (shape.HasPhysicalShape) | ||
195 | return BSAPICPP.GetNumberOfCompoundChildren2(shape.ptr); | ||
196 | return 0; | ||
197 | } | ||
343 | 198 | ||
344 | public abstract void RemoveChildShapeFromCompoundShape2(BulletShape cShape, BulletShape removeShape); | 199 | public override void AddChildShapeToCompoundShape(BulletShape cShape, BulletShape addShape, Vector3 pos, Quaternion rot) |
200 | { | ||
201 | BSAPICPP.AddChildShapeToCompoundShape2(cShape.ptr, addShape.ptr, pos, rot); | ||
202 | } | ||
345 | 203 | ||
346 | public abstract void RecalculateCompoundShapeLocalAabb2(BulletShape cShape); | 204 | public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx) |
205 | { | ||
206 | return new BulletShape(BSAPICPP.GetChildShapeFromCompoundShapeIndex2(cShape.ptr, indx)); | ||
207 | } | ||
347 | 208 | ||
348 | public abstract BulletShape DuplicateCollisionShape2(BulletWorld sim, BulletShape srcShape, uint id); | 209 | public override BulletShape RemoveChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx) |
210 | { | ||
211 | return new BulletShape(BSAPICPP.RemoveChildShapeFromCompoundShapeIndex2(cShape.ptr, indx)); | ||
212 | } | ||
349 | 213 | ||
350 | public abstract BulletBody CreateBodyFromShapeAndInfo2(BulletWorld sim, BulletShape shape, uint id, IntPtr constructionInfo); | 214 | public override void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape) |
215 | { | ||
216 | BSAPICPP.RemoveChildShapeFromCompoundShape2(cShape.ptr, removeShape.ptr); | ||
217 | } | ||
351 | 218 | ||
352 | public abstract bool DeleteCollisionShape2(BulletWorld world, BulletShape shape); | 219 | public override void RecalculateCompoundShapeLocalAabb(BulletShape cShape) |
220 | { | ||
221 | BSAPICPP.RecalculateCompoundShapeLocalAabb2(cShape.ptr); | ||
222 | } | ||
353 | 223 | ||
354 | public abstract int GetBodyType2(BulletBody obj); | 224 | public override BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id) |
225 | { | ||
226 | return new BulletShape(BSAPICPP.DuplicateCollisionShape2(sim.ptr, srcShape.ptr, id), srcShape.type); | ||
227 | } | ||
355 | 228 | ||
356 | public abstract BulletBody CreateBodyFromShape2(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot); | 229 | public override bool DeleteCollisionShape(BulletWorld world, BulletShape shape) |
230 | { | ||
231 | return BSAPICPP.DeleteCollisionShape2(world.ptr, shape.ptr); | ||
232 | } | ||
357 | 233 | ||
358 | public abstract BulletBody CreateBodyWithDefaultMotionState2(BulletShape shape, uint id, Vector3 pos, Quaternion rot); | 234 | public override int GetBodyType(BulletBody obj) |
235 | { | ||
236 | return BSAPICPP.GetBodyType2(obj.ptr); | ||
237 | } | ||
359 | 238 | ||
360 | public abstract BulletBody CreateGhostFromShape2(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot); | 239 | public override BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot) |
240 | { | ||
241 | return new BulletBody(id, BSAPICPP.CreateBodyFromShape2(sim.ptr, shape.ptr, id, pos, rot)); | ||
242 | } | ||
361 | 243 | ||
362 | public abstract IntPtr AllocateBodyInfo2(BulletBody obj); | 244 | public override BulletBody CreateBodyWithDefaultMotionState(BulletShape shape, uint id, Vector3 pos, Quaternion rot) |
245 | { | ||
246 | return new BulletBody(id, BSAPICPP.CreateBodyWithDefaultMotionState2(shape.ptr, id, pos, rot)); | ||
247 | } | ||
363 | 248 | ||
364 | public abstract void ReleaseBodyInfo2(IntPtr obj); | 249 | public override BulletBody CreateGhostFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot) |
250 | { | ||
251 | return new BulletBody(id, BSAPICPP.CreateGhostFromShape2(sim.ptr, shape.ptr, id, pos, rot)); | ||
252 | } | ||
365 | 253 | ||
366 | public abstract void DestroyObject2(BulletWorld sim, BulletBody obj); | 254 | public override void DestroyObject(BulletWorld sim, BulletBody obj) |
255 | { | ||
256 | BSAPICPP.DestroyObject2(sim.ptr, obj.ptr); | ||
257 | } | ||
367 | 258 | ||
368 | // ===================================================================================== | 259 | // ===================================================================================== |
369 | // Terrain creation and helper routines | 260 | // Terrain creation and helper routines |
370 | public abstract IntPtr CreateHeightMapInfo2(BulletWorld sim, uint id, Vector3 minCoords, Vector3 maxCoords, | 261 | public override BulletShape CreateGroundPlaneShape(uint id, float height, float collisionMargin) |
371 | [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin); | 262 | { |
372 | 263 | return new BulletShape(BSAPICPP.CreateGroundPlaneShape2(id, height, collisionMargin), BSPhysicsShapeType.SHAPE_GROUNDPLANE); | |
373 | public abstract IntPtr FillHeightMapInfo2(BulletWorld sim, IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords, | 264 | } |
374 | [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin); | ||
375 | |||
376 | public abstract bool ReleaseHeightMapInfo2(IntPtr heightMapInfo); | ||
377 | |||
378 | public abstract BulletBody CreateGroundPlaneShape2(uint id, float height, float collisionMargin); | ||
379 | 265 | ||
380 | public abstract BulletBody CreateTerrainShape2(IntPtr mapInfo); | 266 | public override BulletShape CreateTerrainShape(uint id, Vector3 size, float minHeight, float maxHeight, float[] heightMap, |
267 | float scaleFactor, float collisionMargin) | ||
268 | { | ||
269 | return new BulletShape(BSAPICPP.CreateTerrainShape2(id, size, minHeight, maxHeight, heightMap, scaleFactor, collisionMargin), | ||
270 | BSPhysicsShapeType.SHAPE_TERRAIN); | ||
271 | } | ||
381 | 272 | ||
382 | // ===================================================================================== | 273 | // ===================================================================================== |
383 | // Constraint creation and helper routines | 274 | // Constraint creation and helper routines |
384 | public abstract BulletConstraint Create6DofConstraint2(BulletWorld world, BulletBody obj1, BulletBody obj2, | 275 | public override BulletConstraint Create6DofConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, |
385 | Vector3 frame1loc, Quaternion frame1rot, | 276 | Vector3 frame1loc, Quaternion frame1rot, |
386 | Vector3 frame2loc, Quaternion frame2rot, | 277 | Vector3 frame2loc, Quaternion frame2rot, |
387 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | 278 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
279 | { | ||
280 | return new BulletConstraint(BSAPICPP.Create6DofConstraint2(world.ptr, obj1.ptr, obj2.ptr, frame1loc, frame1rot, | ||
281 | frame2loc, frame2rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
282 | } | ||
388 | 283 | ||
389 | public abstract BulletConstraint Create6DofConstraintToPoint2(BulletWorld world, BulletBody obj1, BulletBody obj2, | 284 | public override BulletConstraint Create6DofConstraintToPoint(BulletWorld world, BulletBody obj1, BulletBody obj2, |
390 | Vector3 joinPoint, | 285 | Vector3 joinPoint, |
391 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | 286 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
287 | { | ||
288 | return new BulletConstraint(BSAPICPP.Create6DofConstraintToPoint2(world.ptr, obj1.ptr, obj2.ptr, | ||
289 | joinPoint, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
290 | } | ||
392 | 291 | ||
393 | public abstract BulletConstraint CreateHingeConstraint2(BulletWorld world, BulletBody obj1, BulletBody obj2, | 292 | public override BulletConstraint CreateHingeConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, |
394 | Vector3 pivotinA, Vector3 pivotinB, | 293 | Vector3 pivotinA, Vector3 pivotinB, |
395 | Vector3 axisInA, Vector3 axisInB, | 294 | Vector3 axisInA, Vector3 axisInB, |
396 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | 295 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
296 | { | ||
297 | return new BulletConstraint(BSAPICPP.CreateHingeConstraint2(world.ptr, obj1.ptr, obj2.ptr, | ||
298 | pivotinA, pivotinB, axisInA, axisInB, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
299 | } | ||
397 | 300 | ||
398 | public abstract void SetConstraintEnable2(BulletConstraint constrain, float numericTrueFalse); | 301 | public override void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse) |
302 | { | ||
303 | BSAPICPP.SetConstraintEnable2(constrain.ptr, numericTrueFalse); | ||
304 | } | ||
399 | 305 | ||
400 | public abstract void SetConstraintNumSolverIterations2(BulletConstraint constrain, float iterations); | 306 | public override void SetConstraintNumSolverIterations(BulletConstraint constrain, float iterations) |
307 | { | ||
308 | BSAPICPP.SetConstraintNumSolverIterations2(constrain.ptr, iterations); | ||
309 | } | ||
401 | 310 | ||
402 | public abstract bool SetFrames2(BulletConstraint constrain, | 311 | public override bool SetFrames(BulletConstraint constrain, |
403 | Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot); | 312 | Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot) |
313 | { | ||
314 | return BSAPICPP.SetFrames2(constrain.ptr, frameA, frameArot, frameB, frameBrot); | ||
315 | } | ||
404 | 316 | ||
405 | public abstract bool SetLinearLimits2(BulletConstraint constrain, Vector3 low, Vector3 hi); | 317 | public override bool SetLinearLimits(BulletConstraint constrain, Vector3 low, Vector3 hi) |
318 | { | ||
319 | return BSAPICPP.SetLinearLimits2(constrain.ptr, low, hi); | ||
320 | } | ||
406 | 321 | ||
407 | public abstract bool SetAngularLimits2(BulletConstraint constrain, Vector3 low, Vector3 hi); | 322 | public override bool SetAngularLimits(BulletConstraint constrain, Vector3 low, Vector3 hi) |
323 | { | ||
324 | return BSAPICPP.SetAngularLimits2(constrain.ptr, low, hi); | ||
325 | } | ||
408 | 326 | ||
409 | public abstract bool UseFrameOffset2(BulletConstraint constrain, float enable); | 327 | public override bool UseFrameOffset(BulletConstraint constrain, float enable) |
328 | { | ||
329 | return BSAPICPP.UseFrameOffset2(constrain.ptr, enable); | ||
330 | } | ||
410 | 331 | ||
411 | public abstract bool TranslationalLimitMotor2(BulletConstraint constrain, float enable, float targetVel, float maxMotorForce); | 332 | public override bool TranslationalLimitMotor(BulletConstraint constrain, float enable, float targetVel, float maxMotorForce) |
333 | { | ||
334 | return BSAPICPP.TranslationalLimitMotor2(constrain.ptr, enable, targetVel, maxMotorForce); | ||
335 | } | ||
412 | 336 | ||
413 | public abstract bool SetBreakingImpulseThreshold2(BulletConstraint constrain, float threshold); | 337 | public override bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold) |
338 | { | ||
339 | return BSAPICPP.SetBreakingImpulseThreshold2(constrain.ptr, threshold); | ||
340 | } | ||
414 | 341 | ||
415 | public abstract bool CalculateTransforms2(BulletConstraint constrain); | 342 | public override bool CalculateTransforms(BulletConstraint constrain) |
343 | { | ||
344 | return BSAPICPP.CalculateTransforms2(constrain.ptr); | ||
345 | } | ||
416 | 346 | ||
417 | public abstract bool SetConstraintParam2(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis); | 347 | public override bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis) |
348 | { | ||
349 | return BSAPICPP.SetConstraintParam2(constrain.ptr, paramIndex, value, axis); | ||
350 | } | ||
418 | 351 | ||
419 | public abstract bool DestroyConstraint2(BulletWorld world, BulletConstraint constrain); | 352 | public override bool DestroyConstraint(BulletWorld world, BulletConstraint constrain) |
353 | { | ||
354 | return BSAPICPP.DestroyConstraint2(world.ptr, constrain.ptr); | ||
355 | } | ||
420 | 356 | ||
421 | // ===================================================================================== | 357 | // ===================================================================================== |
422 | // btCollisionWorld entries | 358 | // btCollisionWorld entries |
423 | public abstract void UpdateSingleAabb2(BulletWorld world, BulletBody obj); | 359 | public override void UpdateSingleAabb(BulletWorld world, BulletBody obj) |
360 | { | ||
361 | BSAPICPP.UpdateSingleAabb2(world.ptr, obj.ptr); | ||
362 | } | ||
424 | 363 | ||
425 | public abstract void UpdateAabbs2(BulletWorld world); | 364 | public override void UpdateAabbs(BulletWorld world) |
365 | { | ||
366 | BSAPICPP.UpdateAabbs2(world.ptr); | ||
367 | } | ||
426 | 368 | ||
427 | public abstract bool GetForceUpdateAllAabbs2(BulletWorld world); | 369 | public override bool GetForceUpdateAllAabbs(BulletWorld world) |
370 | { | ||
371 | return BSAPICPP.GetForceUpdateAllAabbs2(world.ptr); | ||
372 | } | ||
428 | 373 | ||
429 | public abstract void SetForceUpdateAllAabbs2(BulletWorld world, bool force); | 374 | public override void SetForceUpdateAllAabbs(BulletWorld world, bool force) |
375 | { | ||
376 | BSAPICPP.SetForceUpdateAllAabbs2(world.ptr, force); | ||
377 | } | ||
430 | 378 | ||
431 | // ===================================================================================== | 379 | // ===================================================================================== |
432 | // btDynamicsWorld entries | 380 | // btDynamicsWorld entries |
433 | public abstract bool AddObjectToWorld2(BulletWorld world, BulletBody obj); | 381 | public override bool AddObjectToWorld(BulletWorld world, BulletBody obj) |
382 | { | ||
383 | return BSAPICPP.AddObjectToWorld2(world.ptr, obj.ptr); | ||
384 | } | ||
434 | 385 | ||
435 | public abstract bool RemoveObjectFromWorld2(BulletWorld world, BulletBody obj); | 386 | public override bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj) |
387 | { | ||
388 | return BSAPICPP.RemoveObjectFromWorld2(world.ptr, obj.ptr); | ||
389 | } | ||
436 | 390 | ||
437 | public abstract bool AddConstraintToWorld2(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects); | 391 | public override bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects) |
392 | { | ||
393 | return BSAPICPP.AddConstraintToWorld2(world.ptr, constrain.ptr, disableCollisionsBetweenLinkedObjects); | ||
394 | } | ||
438 | 395 | ||
439 | public abstract bool RemoveConstraintFromWorld2(BulletWorld world, BulletConstraint constrain); | 396 | public override bool RemoveConstraintFromWorld(BulletWorld world, BulletConstraint constrain) |
397 | { | ||
398 | return BSAPICPP.RemoveConstraintFromWorld2(world.ptr, constrain.ptr); | ||
399 | } | ||
440 | // ===================================================================================== | 400 | // ===================================================================================== |
441 | // btCollisionObject entries | 401 | // btCollisionObject entries |
442 | public abstract Vector3 GetAnisotripicFriction2(BulletConstraint constrain); | 402 | public override Vector3 GetAnisotripicFriction(BulletConstraint constrain) |
443 | 403 | { | |
444 | public abstract Vector3 SetAnisotripicFriction2(BulletConstraint constrain, Vector3 frict); | 404 | return BSAPICPP.GetAnisotripicFriction2(constrain.ptr); |
445 | 405 | } | |
446 | public abstract bool HasAnisotripicFriction2(BulletConstraint constrain); | ||
447 | |||
448 | public abstract void SetContactProcessingThreshold2(BulletBody obj, float val); | ||
449 | |||
450 | public abstract float GetContactProcessingThreshold2(BulletBody obj); | ||
451 | 406 | ||
452 | public abstract bool IsStaticObject2(BulletBody obj); | 407 | public override Vector3 SetAnisotripicFriction(BulletConstraint constrain, Vector3 frict) |
408 | { | ||
409 | return BSAPICPP.SetAnisotripicFriction2(constrain.ptr, frict); | ||
410 | } | ||
453 | 411 | ||
454 | public abstract bool IsKinematicObject2(BulletBody obj); | 412 | public override bool HasAnisotripicFriction(BulletConstraint constrain) |
413 | { | ||
414 | return BSAPICPP.HasAnisotripicFriction2(constrain.ptr); | ||
415 | } | ||
455 | 416 | ||
456 | public abstract bool IsStaticOrKinematicObject2(BulletBody obj); | 417 | public override void SetContactProcessingThreshold(BulletBody obj, float val) |
418 | { | ||
419 | BSAPICPP.SetContactProcessingThreshold2(obj.ptr, val); | ||
420 | } | ||
457 | 421 | ||
458 | public abstract bool HasContactResponse2(BulletBody obj); | 422 | public override float GetContactProcessingThreshold(BulletBody obj) |
423 | { | ||
424 | return BSAPICPP.GetContactProcessingThreshold2(obj.ptr); | ||
425 | } | ||
459 | 426 | ||
460 | public abstract void SetCollisionShape2(BulletWorld sim, BulletBody obj, BulletBody shape); | 427 | public override bool IsStaticObject(BulletBody obj) |
428 | { | ||
429 | return BSAPICPP.IsStaticObject2(obj.ptr); | ||
430 | } | ||
461 | 431 | ||
462 | public abstract BulletShape GetCollisionShape2(BulletBody obj); | 432 | public override bool IsKinematicObject(BulletBody obj) |
433 | { | ||
434 | return BSAPICPP.IsKinematicObject2(obj.ptr); | ||
435 | } | ||
463 | 436 | ||
464 | public abstract int GetActivationState2(BulletBody obj); | 437 | public override bool IsStaticOrKinematicObject(BulletBody obj) |
438 | { | ||
439 | return BSAPICPP.IsStaticOrKinematicObject2(obj.ptr); | ||
440 | } | ||
465 | 441 | ||
466 | public abstract void SetActivationState2(BulletBody obj, int state); | 442 | public override bool HasContactResponse(BulletBody obj) |
443 | { | ||
444 | return BSAPICPP.HasContactResponse2(obj.ptr); | ||
445 | } | ||
467 | 446 | ||
468 | public abstract void SetDeactivationTime2(BulletBody obj, float dtime); | 447 | public override void SetCollisionShape(BulletWorld sim, BulletBody obj, BulletShape shape) |
448 | { | ||
449 | BSAPICPP.SetCollisionShape2(sim.ptr, obj.ptr, shape.ptr); | ||
450 | } | ||
469 | 451 | ||
470 | public abstract float GetDeactivationTime2(BulletBody obj); | 452 | public override BulletShape GetCollisionShape(BulletBody obj) |
453 | { | ||
454 | return new BulletShape(BSAPICPP.GetCollisionShape2(obj.ptr)); | ||
455 | } | ||
471 | 456 | ||
472 | public abstract void ForceActivationState2(BulletBody obj, ActivationState state); | 457 | public override int GetActivationState(BulletBody obj) |
458 | { | ||
459 | return BSAPICPP.GetActivationState2(obj.ptr); | ||
460 | } | ||
473 | 461 | ||
474 | public abstract void Activate2(BulletBody obj, bool forceActivation); | 462 | public override void SetActivationState(BulletBody obj, int state) |
463 | { | ||
464 | BSAPICPP.SetActivationState2(obj.ptr, state); | ||
465 | } | ||
475 | 466 | ||
476 | public abstract bool IsActive2(BulletBody obj); | 467 | public override void SetDeactivationTime(BulletBody obj, float dtime) |
468 | { | ||
469 | BSAPICPP.SetDeactivationTime2(obj.ptr, dtime); | ||
470 | } | ||
477 | 471 | ||
478 | public abstract void SetRestitution2(BulletBody obj, float val); | 472 | public override float GetDeactivationTime(BulletBody obj) |
473 | { | ||
474 | return BSAPICPP.GetDeactivationTime2(obj.ptr); | ||
475 | } | ||
479 | 476 | ||
480 | public abstract float GetRestitution2(BulletBody obj); | 477 | public override void ForceActivationState(BulletBody obj, ActivationState state) |
478 | { | ||
479 | BSAPICPP.ForceActivationState2(obj.ptr, state); | ||
480 | } | ||
481 | 481 | ||
482 | public abstract void SetFriction2(BulletBody obj, float val); | 482 | public override void Activate(BulletBody obj, bool forceActivation) |
483 | { | ||
484 | BSAPICPP.Activate2(obj.ptr, forceActivation); | ||
485 | } | ||
483 | 486 | ||
484 | public abstract float GetFriction2(BulletBody obj); | 487 | public override bool IsActive(BulletBody obj) |
488 | { | ||
489 | return BSAPICPP.IsActive2(obj.ptr); | ||
490 | } | ||
485 | 491 | ||
486 | /* Haven't defined the type 'Transform' | 492 | public override void SetRestitution(BulletBody obj, float val) |
487 | public abstract Transform GetWorldTransform2(BulletBody obj); | 493 | { |
494 | BSAPICPP.SetRestitution2(obj.ptr, val); | ||
495 | } | ||
488 | 496 | ||
489 | public abstract void setWorldTransform2(BulletBody obj, Transform trans); | 497 | public override float GetRestitution(BulletBody obj) |
490 | */ | 498 | { |
499 | return BSAPICPP.GetRestitution2(obj.ptr); | ||
500 | } | ||
491 | 501 | ||
492 | public abstract Vector3 GetPosition2(BulletBody obj); | 502 | public override void SetFriction(BulletBody obj, float val) |
503 | { | ||
504 | BSAPICPP.SetFriction2(obj.ptr, val); | ||
505 | } | ||
493 | 506 | ||
494 | public abstract Quaternion GetOrientation2(BulletBody obj); | 507 | public override float GetFriction(BulletBody obj) |
508 | { | ||
509 | return BSAPICPP.GetFriction2(obj.ptr); | ||
510 | } | ||
495 | 511 | ||
496 | public abstract void SetTranslation2(BulletBody obj, Vector3 position, Quaternion rotation); | 512 | public override Vector3 GetPosition(BulletBody obj) |
513 | { | ||
514 | return BSAPICPP.GetPosition2(obj.ptr); | ||
515 | } | ||
497 | 516 | ||
498 | public abstract IntPtr GetBroadphaseHandle2(BulletBody obj); | 517 | public override Quaternion GetOrientation(BulletBody obj) |
518 | { | ||
519 | return BSAPICPP.GetOrientation2(obj.ptr); | ||
520 | } | ||
499 | 521 | ||
500 | public abstract void SetBroadphaseHandle2(BulletBody obj, IntPtr handle); | 522 | public override void SetTranslation(BulletBody obj, Vector3 position, Quaternion rotation) |
523 | { | ||
524 | BSAPICPP.SetTranslation2(obj.ptr, position, rotation); | ||
525 | } | ||
501 | 526 | ||
502 | /* | 527 | /* |
503 | public abstract Transform GetInterpolationWorldTransform2(IntPtr obj); | 528 | public override IntPtr GetBroadphaseHandle(BulletBody obj) |
529 | { | ||
530 | return BSAPICPP.GetBroadphaseHandle2(obj.ptr); | ||
531 | } | ||
504 | 532 | ||
505 | public abstract void SetInterpolationWorldTransform2(IntPtr obj, Transform trans); | 533 | public override void SetBroadphaseHandle(BulletBody obj, IntPtr handle) |
534 | { | ||
535 | BSAPICPP.SetUserPointer2(obj.ptr, handle); | ||
536 | } | ||
506 | */ | 537 | */ |
507 | 538 | ||
508 | public abstract void SetInterpolationLinearVelocity2(BulletBody obj, Vector3 vel); | 539 | public override void SetInterpolationLinearVelocity(BulletBody obj, Vector3 vel) |
540 | { | ||
541 | BSAPICPP.SetInterpolationLinearVelocity2(obj.ptr, vel); | ||
542 | } | ||
509 | 543 | ||
510 | public abstract void SetInterpolationAngularVelocity2(BulletBody obj, Vector3 vel); | 544 | public override void SetInterpolationAngularVelocity(BulletBody obj, Vector3 vel) |
545 | { | ||
546 | BSAPICPP.SetInterpolationAngularVelocity2(obj.ptr, vel); | ||
547 | } | ||
511 | 548 | ||
512 | public abstract void SetInterpolationVelocity2(BulletBody obj, Vector3 linearVel, Vector3 angularVel); | 549 | public override void SetInterpolationVelocity(BulletBody obj, Vector3 linearVel, Vector3 angularVel) |
550 | { | ||
551 | BSAPICPP.SetInterpolationVelocity2(obj.ptr, linearVel, angularVel); | ||
552 | } | ||
513 | 553 | ||
514 | public abstract float GetHitFraction2(BulletBody obj); | 554 | public override float GetHitFraction(BulletBody obj) |
555 | { | ||
556 | return BSAPICPP.GetHitFraction2(obj.ptr); | ||
557 | } | ||
515 | 558 | ||
516 | public abstract void SetHitFraction2(BulletBody obj, float val); | 559 | public override void SetHitFraction(BulletBody obj, float val) |
560 | { | ||
561 | BSAPICPP.SetHitFraction2(obj.ptr, val); | ||
562 | } | ||
517 | 563 | ||
518 | public abstract CollisionFlags GetCollisionFlags2(BulletBody obj); | 564 | public override CollisionFlags GetCollisionFlags(BulletBody obj) |
565 | { | ||
566 | return BSAPICPP.GetCollisionFlags2(obj.ptr); | ||
567 | } | ||
519 | 568 | ||
520 | public abstract CollisionFlags SetCollisionFlags2(BulletBody obj, CollisionFlags flags); | 569 | public override CollisionFlags SetCollisionFlags(BulletBody obj, CollisionFlags flags) |
570 | { | ||
571 | return BSAPICPP.SetCollisionFlags2(obj.ptr, flags); | ||
572 | } | ||
521 | 573 | ||
522 | public abstract CollisionFlags AddToCollisionFlags2(BulletBody obj, CollisionFlags flags); | 574 | public override CollisionFlags AddToCollisionFlags(BulletBody obj, CollisionFlags flags) |
575 | { | ||
576 | return BSAPICPP.AddToCollisionFlags2(obj.ptr, flags); | ||
577 | } | ||
523 | 578 | ||
524 | public abstract CollisionFlags RemoveFromCollisionFlags2(BulletBody obj, CollisionFlags flags); | 579 | public override CollisionFlags RemoveFromCollisionFlags(BulletBody obj, CollisionFlags flags) |
580 | { | ||
581 | return BSAPICPP.RemoveFromCollisionFlags2(obj.ptr, flags); | ||
582 | } | ||
525 | 583 | ||
526 | public abstract float GetCcdMotionThreshold2(BulletBody obj); | 584 | public override float GetCcdMotionThreshold(BulletBody obj) |
585 | { | ||
586 | return BSAPICPP.GetCcdMotionThreshold2(obj.ptr); | ||
587 | } | ||
527 | 588 | ||
528 | public abstract void SetCcdMotionThreshold2(BulletBody obj, float val); | ||
529 | 589 | ||
530 | public abstract float GetCcdSweptSphereRadius2(BulletBody obj); | 590 | public override void SetCcdMotionThreshold(BulletBody obj, float val) |
591 | { | ||
592 | BSAPICPP.SetCcdMotionThreshold2(obj.ptr, val); | ||
593 | } | ||
531 | 594 | ||
532 | public abstract void SetCcdSweptSphereRadius2(BulletBody obj, float val); | 595 | public override float GetCcdSweptSphereRadius(BulletBody obj) |
596 | { | ||
597 | return BSAPICPP.GetCcdSweptSphereRadius2(obj.ptr); | ||
598 | } | ||
533 | 599 | ||
534 | public abstract IntPtr GetUserPointer2(BulletBody obj); | 600 | public override void SetCcdSweptSphereRadius(BulletBody obj, float val) |
601 | { | ||
602 | BSAPICPP.SetCcdSweptSphereRadius2(obj.ptr, val); | ||
603 | } | ||
535 | 604 | ||
536 | public abstract void SetUserPointer2(BulletBody obj, IntPtr val); | 605 | public override IntPtr GetUserPointer(BulletBody obj) |
606 | { | ||
607 | return BSAPICPP.GetUserPointer2(obj.ptr); | ||
608 | } | ||
609 | |||
610 | public override void SetUserPointer(BulletBody obj, IntPtr val) | ||
611 | { | ||
612 | BSAPICPP.SetUserPointer2(obj.ptr, val); | ||
613 | } | ||
537 | 614 | ||
538 | // ===================================================================================== | 615 | // ===================================================================================== |
539 | // btRigidBody entries | 616 | // btRigidBody entries |
540 | public abstract void ApplyGravity2(BulletBody obj); | 617 | public override void ApplyGravity(BulletBody obj) |
541 | 618 | { | |
542 | public abstract void SetGravity2(BulletBody obj, Vector3 val); | 619 | BSAPICPP.ApplyGravity2(obj.ptr); |
543 | 620 | } | |
544 | public abstract Vector3 GetGravity2(BulletBody obj); | ||
545 | 621 | ||
546 | public abstract void SetDamping2(BulletBody obj, float lin_damping, float ang_damping); | 622 | public override void SetGravity(BulletBody obj, Vector3 val) |
623 | { | ||
624 | BSAPICPP.SetGravity2(obj.ptr, val); | ||
625 | } | ||
547 | 626 | ||
548 | public abstract void SetLinearDamping2(BulletBody obj, float lin_damping); | 627 | public override Vector3 GetGravity(BulletBody obj) |
628 | { | ||
629 | return BSAPICPP.GetGravity2(obj.ptr); | ||
630 | } | ||
549 | 631 | ||
550 | public abstract void SetAngularDamping2(BulletBody obj, float ang_damping); | 632 | public override void SetDamping(BulletBody obj, float lin_damping, float ang_damping) |
633 | { | ||
634 | BSAPICPP.SetDamping2(obj.ptr, lin_damping, ang_damping); | ||
635 | } | ||
551 | 636 | ||
552 | public abstract float GetLinearDamping2(BulletBody obj); | 637 | public override void SetLinearDamping(BulletBody obj, float lin_damping) |
638 | { | ||
639 | BSAPICPP.SetLinearDamping2(obj.ptr, lin_damping); | ||
640 | } | ||
553 | 641 | ||
554 | public abstract float GetAngularDamping2(BulletBody obj); | 642 | public override void SetAngularDamping(BulletBody obj, float ang_damping) |
643 | { | ||
644 | BSAPICPP.SetAngularDamping2(obj.ptr, ang_damping); | ||
645 | } | ||
555 | 646 | ||
556 | public abstract float GetLinearSleepingThreshold2(BulletBody obj); | 647 | public override float GetLinearDamping(BulletBody obj) |
648 | { | ||
649 | return BSAPICPP.GetLinearDamping2(obj.ptr); | ||
650 | } | ||
557 | 651 | ||
652 | public override float GetAngularDamping(BulletBody obj) | ||
653 | { | ||
654 | return BSAPICPP.GetAngularDamping2(obj.ptr); | ||
655 | } | ||
558 | 656 | ||
559 | public abstract void ApplyDamping2(BulletBody obj, float timeStep); | 657 | public override float GetLinearSleepingThreshold(BulletBody obj) |
658 | { | ||
659 | return BSAPICPP.GetLinearSleepingThreshold2(obj.ptr); | ||
660 | } | ||
560 | 661 | ||
561 | public abstract void SetMassProps2(BulletBody obj, float mass, Vector3 inertia); | 662 | public override void ApplyDamping(BulletBody obj, float timeStep) |
663 | { | ||
664 | BSAPICPP.ApplyDamping2(obj.ptr, timeStep); | ||
665 | } | ||
562 | 666 | ||
563 | public abstract Vector3 GetLinearFactor2(BulletBody obj); | 667 | public override void SetMassProps(BulletBody obj, float mass, Vector3 inertia) |
668 | { | ||
669 | BSAPICPP.SetMassProps2(obj.ptr, mass, inertia); | ||
670 | } | ||
564 | 671 | ||
565 | public abstract void SetLinearFactor2(BulletBody obj, Vector3 factor); | 672 | public override Vector3 GetLinearFactor(BulletBody obj) |
673 | { | ||
674 | return BSAPICPP.GetLinearFactor2(obj.ptr); | ||
675 | } | ||
566 | 676 | ||
567 | /* | 677 | public override void SetLinearFactor(BulletBody obj, Vector3 factor) |
568 | public abstract void SetCenterOfMassTransform2(BulletBody obj, Transform trans); | 678 | { |
569 | */ | 679 | BSAPICPP.SetLinearFactor2(obj.ptr, factor); |
680 | } | ||
570 | 681 | ||
571 | public abstract void SetCenterOfMassByPosRot2(BulletBody obj, Vector3 pos, Quaternion rot); | 682 | public override void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot) |
683 | { | ||
684 | BSAPICPP.SetCenterOfMassByPosRot2(obj.ptr, pos, rot); | ||
685 | } | ||
572 | 686 | ||
573 | // Add a force to the object as if its mass is one. | 687 | // Add a force to the object as if its mass is one. |
574 | public abstract void ApplyCentralForce2(BulletBody obj, Vector3 force); | 688 | public override void ApplyCentralForce(BulletBody obj, Vector3 force) |
689 | { | ||
690 | BSAPICPP.ApplyCentralForce2(obj.ptr, force); | ||
691 | } | ||
575 | 692 | ||
576 | // Set the force being applied to the object as if its mass is one. | 693 | // Set the force being applied to the object as if its mass is one. |
577 | public abstract void SetObjectForce2(BulletBody obj, Vector3 force); | 694 | public override void SetObjectForce(BulletBody obj, Vector3 force) |
695 | { | ||
696 | BSAPICPP.SetObjectForce2(obj.ptr, force); | ||
697 | } | ||
578 | 698 | ||
579 | public abstract Vector3 GetTotalForce2(BulletBody obj); | 699 | public override Vector3 GetTotalForce(BulletBody obj) |
700 | { | ||
701 | return BSAPICPP.GetTotalForce2(obj.ptr); | ||
702 | } | ||
580 | 703 | ||
581 | public abstract Vector3 GetTotalTorque2(BulletBody obj); | 704 | public override Vector3 GetTotalTorque(BulletBody obj) |
705 | { | ||
706 | return BSAPICPP.GetTotalTorque2(obj.ptr); | ||
707 | } | ||
582 | 708 | ||
583 | public abstract Vector3 GetInvInertiaDiagLocal2(BulletBody obj); | 709 | public override Vector3 GetInvInertiaDiagLocal(BulletBody obj) |
710 | { | ||
711 | return BSAPICPP.GetInvInertiaDiagLocal2(obj.ptr); | ||
712 | } | ||
584 | 713 | ||
585 | public abstract void SetInvInertiaDiagLocal2(BulletBody obj, Vector3 inert); | 714 | public override void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert) |
715 | { | ||
716 | BSAPICPP.SetInvInertiaDiagLocal2(obj.ptr, inert); | ||
717 | } | ||
586 | 718 | ||
587 | public abstract void SetSleepingThresholds2(BulletBody obj, float lin_threshold, float ang_threshold); | 719 | public override void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold) |
720 | { | ||
721 | BSAPICPP.SetSleepingThresholds2(obj.ptr, lin_threshold, ang_threshold); | ||
722 | } | ||
588 | 723 | ||
589 | public abstract void ApplyTorque2(BulletBody obj, Vector3 torque); | 724 | public override void ApplyTorque(BulletBody obj, Vector3 torque) |
725 | { | ||
726 | BSAPICPP.ApplyTorque2(obj.ptr, torque); | ||
727 | } | ||
590 | 728 | ||
591 | // Apply force at the given point. Will add torque to the object. | 729 | // Apply force at the given point. Will add torque to the object. |
592 | public abstract void ApplyForce2(BulletBody obj, Vector3 force, Vector3 pos); | 730 | public override void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos) |
731 | { | ||
732 | BSAPICPP.ApplyForce2(obj.ptr, force, pos); | ||
733 | } | ||
593 | 734 | ||
594 | // Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass. | 735 | // Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass. |
595 | public abstract void ApplyCentralImpulse2(BulletBody obj, Vector3 imp); | 736 | public override void ApplyCentralImpulse(BulletBody obj, Vector3 imp) |
737 | { | ||
738 | BSAPICPP.ApplyCentralImpulse2(obj.ptr, imp); | ||
739 | } | ||
596 | 740 | ||
597 | // Apply impulse to the object's torque. Force is scaled by object's mass. | 741 | // Apply impulse to the object's torque. Force is scaled by object's mass. |
598 | public abstract void ApplyTorqueImpulse2(BulletBody obj, Vector3 imp); | 742 | public override void ApplyTorqueImpulse(BulletBody obj, Vector3 imp) |
743 | { | ||
744 | BSAPICPP.ApplyTorqueImpulse2(obj.ptr, imp); | ||
745 | } | ||
599 | 746 | ||
600 | // Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces. | 747 | // Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces. |
601 | public abstract void ApplyImpulse2(BulletBody obj, Vector3 imp, Vector3 pos); | 748 | public override void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos) |
602 | 749 | { | |
603 | public abstract void ClearForces2(BulletBody obj); | 750 | BSAPICPP.ApplyImpulse2(obj.ptr, imp, pos); |
604 | 751 | } | |
605 | public abstract void ClearAllForces2(BulletBody obj); | ||
606 | 752 | ||
607 | public abstract void UpdateInertiaTensor2(BulletBody obj); | 753 | public override void ClearForces(BulletBody obj) |
754 | { | ||
755 | BSAPICPP.ClearForces2(obj.ptr); | ||
756 | } | ||
608 | 757 | ||
758 | public override void ClearAllForces(BulletBody obj) | ||
759 | { | ||
760 | BSAPICPP.ClearAllForces2(obj.ptr); | ||
761 | } | ||
609 | 762 | ||
610 | /* | 763 | public override void UpdateInertiaTensor(BulletBody obj) |
611 | public abstract Transform GetCenterOfMassTransform2(BulletBody obj); | 764 | { |
612 | */ | 765 | BSAPICPP.UpdateInertiaTensor2(obj.ptr); |
766 | } | ||
613 | 767 | ||
614 | public abstract Vector3 GetLinearVelocity2(BulletBody obj); | 768 | public override Vector3 GetLinearVelocity(BulletBody obj) |
769 | { | ||
770 | return BSAPICPP.GetLinearVelocity2(obj.ptr); | ||
771 | } | ||
615 | 772 | ||
616 | public abstract Vector3 GetAngularVelocity2(BulletBody obj); | 773 | public override Vector3 GetAngularVelocity(BulletBody obj) |
774 | { | ||
775 | return BSAPICPP.GetAngularVelocity2(obj.ptr); | ||
776 | } | ||
617 | 777 | ||
618 | public abstract void SetLinearVelocity2(BulletBody obj, Vector3 val); | 778 | public override void SetLinearVelocity(BulletBody obj, Vector3 vel) |
779 | { | ||
780 | BSAPICPP.SetLinearVelocity2(obj.ptr, vel); | ||
781 | } | ||
619 | 782 | ||
620 | public abstract void SetAngularVelocity2(BulletBody obj, Vector3 angularVelocity); | 783 | public override void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity) |
784 | { | ||
785 | BSAPICPP.SetAngularVelocity2(obj.ptr, angularVelocity); | ||
786 | } | ||
621 | 787 | ||
622 | public abstract Vector3 GetVelocityInLocalPoint2(BulletBody obj, Vector3 pos); | 788 | public override Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos) |
789 | { | ||
790 | return BSAPICPP.GetVelocityInLocalPoint2(obj.ptr, pos); | ||
791 | } | ||
623 | 792 | ||
624 | public abstract void Translate2(BulletBody obj, Vector3 trans); | 793 | public override void Translate(BulletBody obj, Vector3 trans) |
794 | { | ||
795 | BSAPICPP.Translate2(obj.ptr, trans); | ||
796 | } | ||
625 | 797 | ||
626 | public abstract void UpdateDeactivation2(BulletBody obj, float timeStep); | 798 | public override void UpdateDeactivation(BulletBody obj, float timeStep) |
799 | { | ||
800 | BSAPICPP.UpdateDeactivation2(obj.ptr, timeStep); | ||
801 | } | ||
627 | 802 | ||
628 | public abstract bool WantsSleeping2(BulletBody obj); | 803 | public override bool WantsSleeping(BulletBody obj) |
804 | { | ||
805 | return BSAPICPP.WantsSleeping2(obj.ptr); | ||
806 | } | ||
629 | 807 | ||
630 | public abstract void SetAngularFactor2(BulletBody obj, float factor); | 808 | public override void SetAngularFactor(BulletBody obj, float factor) |
809 | { | ||
810 | BSAPICPP.SetAngularFactor2(obj.ptr, factor); | ||
811 | } | ||
631 | 812 | ||
632 | public abstract void SetAngularFactorV2(BulletBody obj, Vector3 factor); | 813 | public override void SetAngularFactorV(BulletBody obj, Vector3 factor) |
814 | { | ||
815 | BSAPICPP.SetAngularFactorV2(obj.ptr, factor); | ||
816 | } | ||
633 | 817 | ||
634 | public abstract Vector3 GetAngularFactor2(BulletBody obj); | 818 | public override Vector3 GetAngularFactor(BulletBody obj) |
819 | { | ||
820 | return BSAPICPP.GetAngularFactor2(obj.ptr); | ||
821 | } | ||
635 | 822 | ||
636 | public abstract bool IsInWorld2(BulletBody obj); | 823 | public override bool IsInWorld(BulletBody obj) |
824 | { | ||
825 | return BSAPICPP.IsInWorld2(obj.ptr); | ||
826 | } | ||
637 | 827 | ||
638 | public abstract void AddConstraintRef2(BulletBody obj, BulletConstraint constrain); | 828 | public override void AddConstraintRef(BulletBody obj, BulletConstraint constrain) |
829 | { | ||
830 | BSAPICPP.AddConstraintRef2(obj.ptr, constrain.ptr); | ||
831 | } | ||
639 | 832 | ||
640 | public abstract void RemoveConstraintRef2(BulletBody obj, BulletConstraint constrain); | 833 | public override void RemoveConstraintRef(BulletBody obj, BulletConstraint constrain) |
834 | { | ||
835 | BSAPICPP.RemoveConstraintRef2(obj.ptr, constrain.ptr); | ||
836 | } | ||
641 | 837 | ||
642 | public abstract BulletConstraint GetConstraintRef2(BulletBody obj, int index); | 838 | public override BulletConstraint GetConstraintRef(BulletBody obj, int index) |
839 | { | ||
840 | return new BulletConstraint(BSAPICPP.GetConstraintRef2(obj.ptr, index)); | ||
841 | } | ||
643 | 842 | ||
644 | public abstract int GetNumConstraintRefs2(BulletBody obj); | 843 | public override int GetNumConstraintRefs(BulletBody obj) |
844 | { | ||
845 | return BSAPICPP.GetNumConstraintRefs2(obj.ptr); | ||
846 | } | ||
645 | 847 | ||
646 | public abstract bool SetCollisionGroupMask2(BulletBody body, uint filter, uint mask); | 848 | public override bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask) |
849 | { | ||
850 | return BSAPICPP.SetCollisionGroupMask2(body.ptr, filter, mask); | ||
851 | } | ||
647 | 852 | ||
648 | // ===================================================================================== | 853 | // ===================================================================================== |
649 | // btCollisionShape entries | 854 | // btCollisionShape entries |
650 | 855 | ||
651 | public abstract float GetAngularMotionDisc2(BulletShape shape); | 856 | public override float GetAngularMotionDisc(BulletShape shape) |
857 | { | ||
858 | return BSAPICPP.GetAngularMotionDisc2(shape.ptr); | ||
859 | } | ||
860 | |||
861 | public override float GetContactBreakingThreshold(BulletShape shape, float defaultFactor) | ||
862 | { | ||
863 | return BSAPICPP.GetContactBreakingThreshold2(shape.ptr, defaultFactor); | ||
864 | } | ||
865 | |||
866 | public override bool IsPolyhedral(BulletShape shape) | ||
867 | { | ||
868 | return BSAPICPP.IsPolyhedral2(shape.ptr); | ||
869 | } | ||
870 | |||
871 | public override bool IsConvex2d(BulletShape shape) | ||
872 | { | ||
873 | return BSAPICPP.IsConvex2d2(shape.ptr); | ||
874 | } | ||
652 | 875 | ||
653 | public abstract float GetContactBreakingThreshold2(BulletShape shape, float defaultFactor); | 876 | public override bool IsConvex(BulletShape shape) |
877 | { | ||
878 | return BSAPICPP.IsConvex2(shape.ptr); | ||
879 | } | ||
654 | 880 | ||
655 | public abstract bool IsPolyhedral2(BulletShape shape); | 881 | public override bool IsNonMoving(BulletShape shape) |
882 | { | ||
883 | return BSAPICPP.IsNonMoving2(shape.ptr); | ||
884 | } | ||
656 | 885 | ||
657 | public abstract bool IsConvex2d2(BulletShape shape); | 886 | public override bool IsConcave(BulletShape shape) |
887 | { | ||
888 | return BSAPICPP.IsConcave2(shape.ptr); | ||
889 | } | ||
658 | 890 | ||
659 | public abstract bool IsConvex2(BulletShape shape); | 891 | public override bool IsCompound(BulletShape shape) |
892 | { | ||
893 | return BSAPICPP.IsCompound2(shape.ptr); | ||
894 | } | ||
660 | 895 | ||
661 | public abstract bool IsNonMoving2(BulletShape shape); | 896 | public override bool IsSoftBody(BulletShape shape) |
897 | { | ||
898 | return BSAPICPP.IsSoftBody2(shape.ptr); | ||
899 | } | ||
900 | |||
901 | public override bool IsInfinite(BulletShape shape) | ||
902 | { | ||
903 | return BSAPICPP.IsInfinite2(shape.ptr); | ||
904 | } | ||
905 | |||
906 | public override void SetLocalScaling(BulletShape shape, Vector3 scale) | ||
907 | { | ||
908 | BSAPICPP.SetLocalScaling2(shape.ptr, scale); | ||
909 | } | ||
910 | |||
911 | public override Vector3 GetLocalScaling(BulletShape shape) | ||
912 | { | ||
913 | return BSAPICPP.GetLocalScaling2(shape.ptr); | ||
914 | } | ||
662 | 915 | ||
663 | public abstract bool IsConcave2(BulletShape shape); | 916 | public override Vector3 CalculateLocalInertia(BulletShape shape, float mass) |
917 | { | ||
918 | return BSAPICPP.CalculateLocalInertia2(shape.ptr, mass); | ||
919 | } | ||
664 | 920 | ||
665 | public abstract bool IsCompound2(BulletShape shape); | 921 | public override int GetShapeType(BulletShape shape) |
922 | { | ||
923 | return BSAPICPP.GetShapeType2(shape.ptr); | ||
924 | } | ||
666 | 925 | ||
667 | public abstract bool IsSoftBody2(BulletShape shape); | 926 | public override void SetMargin(BulletShape shape, float val) |
927 | { | ||
928 | BSAPICPP.SetMargin2(shape.ptr, val); | ||
929 | } | ||
668 | 930 | ||
669 | public abstract bool IsInfinite2(BulletShape shape); | 931 | public override float GetMargin(BulletShape shape) |
932 | { | ||
933 | return BSAPICPP.GetMargin2(shape.ptr); | ||
934 | } | ||
670 | 935 | ||
671 | public abstract void SetLocalScaling2(BulletShape shape, Vector3 scale); | 936 | // ===================================================================================== |
937 | // Debugging | ||
938 | public override void DumpRigidBody(BulletWorld sim, BulletBody collisionObject) | ||
939 | { | ||
940 | BSAPICPP.DumpRigidBody2(sim.ptr, collisionObject.ptr); | ||
941 | } | ||
672 | 942 | ||
673 | public abstract Vector3 GetLocalScaling2(BulletShape shape); | 943 | public override void DumpCollisionShape(BulletWorld sim, BulletShape collisionShape) |
944 | { | ||
945 | BSAPICPP.DumpCollisionShape2(sim.ptr, collisionShape.ptr); | ||
946 | } | ||
674 | 947 | ||
675 | public abstract Vector3 CalculateLocalInertia2(BulletShape shape, float mass); | 948 | public override void DumpConstraint(BulletWorld sim, BulletConstraint constrain) |
949 | { | ||
950 | BSAPICPP.DumpConstraint2(sim.ptr, constrain.ptr); | ||
951 | } | ||
676 | 952 | ||
677 | public abstract int GetShapeType2(BulletShape shape); | 953 | public override void DumpActivationInfo(BulletWorld sim) |
954 | { | ||
955 | BSAPICPP.DumpActivationInfo2(sim.ptr); | ||
956 | } | ||
678 | 957 | ||
679 | public abstract void SetMargin2(BulletShape shape, float val); | 958 | public override void DumpAllInfo(BulletWorld sim) |
959 | { | ||
960 | BSAPICPP.DumpAllInfo2(sim.ptr); | ||
961 | } | ||
680 | 962 | ||
681 | public abstract float GetMargin2(BulletShape shape); | 963 | public override void DumpPhysicsStatistics(BulletWorld sim) |
964 | { | ||
965 | BSAPICPP.DumpPhysicsStatistics2(sim.ptr); | ||
966 | } | ||
682 | 967 | ||
683 | }; | ||
684 | 968 | ||
685 | // =============================================================================== | 969 | // ===================================================================================== |
686 | static class BulletSimAPI { | 970 | // ===================================================================================== |
971 | // ===================================================================================== | ||
972 | // ===================================================================================== | ||
973 | // ===================================================================================== | ||
974 | // The actual interface to the unmanaged code | ||
975 | static class BSAPICPP | ||
976 | { | ||
687 | // =============================================================================== | 977 | // =============================================================================== |
688 | // Link back to the managed code for outputting log messages | 978 | // Link back to the managed code for outputting log messages |
689 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] | 979 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
@@ -698,23 +988,17 @@ public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms, | |||
698 | DebugLogCallback logRoutine); | 988 | DebugLogCallback logRoutine); |
699 | 989 | ||
700 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 990 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
701 | public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value); | 991 | public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep, |
702 | 992 | out int updatedEntityCount, out int collidersCount); | |
703 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
704 | public static extern void SetHeightMap2(IntPtr world, float[] heightmap); | ||
705 | 993 | ||
706 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 994 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
707 | public static extern void Shutdown2(IntPtr sim); | 995 | public static extern void Shutdown2(IntPtr sim); |
708 | 996 | ||
709 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 997 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
710 | public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep, | 998 | public static extern bool PushUpdate2(IntPtr obj); |
711 | out int updatedEntityCount, | ||
712 | out IntPtr updatedEntitiesPtr, | ||
713 | out int collidersCount, | ||
714 | out IntPtr collidersPtr); | ||
715 | 999 | ||
716 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1000 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
717 | public static extern bool PushUpdate2(IntPtr obj); | 1001 | public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value); |
718 | 1002 | ||
719 | // ===================================================================================== | 1003 | // ===================================================================================== |
720 | // Mesh, hull, shape and body creation helper routines | 1004 | // Mesh, hull, shape and body creation helper routines |
@@ -737,7 +1021,7 @@ public static extern IntPtr BuildNativeShape2(IntPtr world, ShapeData shapeData) | |||
737 | public static extern bool IsNativeShape2(IntPtr shape); | 1021 | public static extern bool IsNativeShape2(IntPtr shape); |
738 | 1022 | ||
739 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1023 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
740 | public static extern void SetShapeCollisionMargin(IntPtr shape, float margin); | 1024 | public static extern void SetShapeCollisionMargin2(IntPtr shape, float margin); |
741 | 1025 | ||
742 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1026 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
743 | public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale); | 1027 | public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale); |
@@ -767,9 +1051,6 @@ public static extern void RecalculateCompoundShapeLocalAabb2(IntPtr cShape); | |||
767 | public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id); | 1051 | public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id); |
768 | 1052 | ||
769 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1053 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
770 | public static extern IntPtr CreateBodyFromShapeAndInfo2(IntPtr sim, IntPtr shape, uint id, IntPtr constructionInfo); | ||
771 | |||
772 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
773 | public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape); | 1054 | public static extern bool DeleteCollisionShape2(IntPtr world, IntPtr shape); |
774 | 1055 | ||
775 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1056 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -785,32 +1066,17 @@ public static extern IntPtr CreateBodyWithDefaultMotionState2(IntPtr shape, uint | |||
785 | public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot); | 1066 | public static extern IntPtr CreateGhostFromShape2(IntPtr sim, IntPtr shape, uint id, Vector3 pos, Quaternion rot); |
786 | 1067 | ||
787 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1068 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
788 | public static extern IntPtr AllocateBodyInfo2(IntPtr obj); | ||
789 | |||
790 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
791 | public static extern void ReleaseBodyInfo2(IntPtr obj); | ||
792 | |||
793 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
794 | public static extern void DestroyObject2(IntPtr sim, IntPtr obj); | 1069 | public static extern void DestroyObject2(IntPtr sim, IntPtr obj); |
795 | 1070 | ||
796 | // ===================================================================================== | 1071 | // ===================================================================================== |
797 | // Terrain creation and helper routines | 1072 | // Terrain creation and helper routines |
798 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1073 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
799 | public static extern IntPtr CreateHeightMapInfo2(IntPtr sim, uint id, Vector3 minCoords, Vector3 maxCoords, | ||
800 | [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin); | ||
801 | |||
802 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
803 | public static extern IntPtr FillHeightMapInfo2(IntPtr sim, IntPtr mapInfo, uint id, Vector3 minCoords, Vector3 maxCoords, | ||
804 | [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, float collisionMargin); | ||
805 | |||
806 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
807 | public static extern bool ReleaseHeightMapInfo2(IntPtr heightMapInfo); | ||
808 | |||
809 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
810 | public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin); | 1074 | public static extern IntPtr CreateGroundPlaneShape2(uint id, float height, float collisionMargin); |
811 | 1075 | ||
812 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 1076 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
813 | public static extern IntPtr CreateTerrainShape2(IntPtr mapInfo); | 1077 | public static extern IntPtr CreateTerrainShape2(uint id, Vector3 size, float minHeight, float maxHeight, |
1078 | [MarshalAs(UnmanagedType.LPArray)] float[] heightMap, | ||
1079 | float scaleFactor, float collisionMargin); | ||
814 | 1080 | ||
815 | // ===================================================================================== | 1081 | // ===================================================================================== |
816 | // Constraint creation and helper routines | 1082 | // Constraint creation and helper routines |
@@ -1273,4 +1539,7 @@ public static extern void DumpAllInfo2(IntPtr sim); | |||
1273 | public static extern void DumpPhysicsStatistics2(IntPtr sim); | 1539 | public static extern void DumpPhysicsStatistics2(IntPtr sim); |
1274 | 1540 | ||
1275 | } | 1541 | } |
1542 | |||
1543 | } | ||
1544 | |||
1276 | } | 1545 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs new file mode 100755 index 0000000..8ed791e --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | |||
@@ -0,0 +1,39 @@ | |||
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.Linq; | ||
30 | using System.Text; | ||
31 | |||
32 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
33 | { | ||
34 | /* | ||
35 | public sealed class BSAPIXNA : BSAPITemplate | ||
36 | { | ||
37 | } | ||
38 | */ | ||
39 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs new file mode 100644 index 0000000..699f055 --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs | |||
@@ -0,0 +1,662 @@ | |||
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.Runtime.InteropServices; | ||
30 | using System.Security; | ||
31 | using System.Text; | ||
32 | using OpenMetaverse; | ||
33 | |||
34 | namespace OpenSim.Region.Physics.BulletSPlugin { | ||
35 | |||
36 | // Constraint type values as defined by Bullet | ||
37 | public enum ConstraintType : int | ||
38 | { | ||
39 | POINT2POINT_CONSTRAINT_TYPE = 3, | ||
40 | HINGE_CONSTRAINT_TYPE, | ||
41 | CONETWIST_CONSTRAINT_TYPE, | ||
42 | D6_CONSTRAINT_TYPE, | ||
43 | SLIDER_CONSTRAINT_TYPE, | ||
44 | CONTACT_CONSTRAINT_TYPE, | ||
45 | D6_SPRING_CONSTRAINT_TYPE, | ||
46 | MAX_CONSTRAINT_TYPE | ||
47 | } | ||
48 | |||
49 | // =============================================================================== | ||
50 | [StructLayout(LayoutKind.Sequential)] | ||
51 | public struct ConvexHull | ||
52 | { | ||
53 | Vector3 Offset; | ||
54 | int VertexCount; | ||
55 | Vector3[] Vertices; | ||
56 | } | ||
57 | public enum BSPhysicsShapeType | ||
58 | { | ||
59 | SHAPE_UNKNOWN = 0, | ||
60 | SHAPE_CAPSULE = 1, | ||
61 | SHAPE_BOX = 2, | ||
62 | SHAPE_CONE = 3, | ||
63 | SHAPE_CYLINDER = 4, | ||
64 | SHAPE_SPHERE = 5, | ||
65 | SHAPE_MESH = 6, | ||
66 | SHAPE_HULL = 7, | ||
67 | // following defined by BulletSim | ||
68 | SHAPE_GROUNDPLANE = 20, | ||
69 | SHAPE_TERRAIN = 21, | ||
70 | SHAPE_COMPOUND = 22, | ||
71 | SHAPE_HEIGHTMAP = 23, | ||
72 | SHAPE_AVATAR = 24, | ||
73 | }; | ||
74 | |||
75 | // The native shapes have predefined shape hash keys | ||
76 | public enum FixedShapeKey : ulong | ||
77 | { | ||
78 | KEY_NONE = 0, | ||
79 | KEY_BOX = 1, | ||
80 | KEY_SPHERE = 2, | ||
81 | KEY_CONE = 3, | ||
82 | KEY_CYLINDER = 4, | ||
83 | KEY_CAPSULE = 5, | ||
84 | KEY_AVATAR = 6, | ||
85 | } | ||
86 | |||
87 | [StructLayout(LayoutKind.Sequential)] | ||
88 | public struct ShapeData | ||
89 | { | ||
90 | public uint ID; | ||
91 | public BSPhysicsShapeType Type; | ||
92 | public Vector3 Position; | ||
93 | public Quaternion Rotation; | ||
94 | public Vector3 Velocity; | ||
95 | public Vector3 Scale; | ||
96 | public float Mass; | ||
97 | public float Buoyancy; | ||
98 | public System.UInt64 HullKey; | ||
99 | public System.UInt64 MeshKey; | ||
100 | public float Friction; | ||
101 | public float Restitution; | ||
102 | public float Collidable; // true of things bump into this | ||
103 | public float Static; // true if a static object. Otherwise gravity, etc. | ||
104 | public float Solid; // true if object cannot be passed through | ||
105 | public Vector3 Size; | ||
106 | |||
107 | // note that bools are passed as floats since bool size changes by language and architecture | ||
108 | public const float numericTrue = 1f; | ||
109 | public const float numericFalse = 0f; | ||
110 | } | ||
111 | [StructLayout(LayoutKind.Sequential)] | ||
112 | public struct SweepHit | ||
113 | { | ||
114 | public uint ID; | ||
115 | public float Fraction; | ||
116 | public Vector3 Normal; | ||
117 | public Vector3 Point; | ||
118 | } | ||
119 | [StructLayout(LayoutKind.Sequential)] | ||
120 | public struct RaycastHit | ||
121 | { | ||
122 | public uint ID; | ||
123 | public float Fraction; | ||
124 | public Vector3 Normal; | ||
125 | } | ||
126 | [StructLayout(LayoutKind.Sequential)] | ||
127 | public struct CollisionDesc | ||
128 | { | ||
129 | public uint aID; | ||
130 | public uint bID; | ||
131 | public Vector3 point; | ||
132 | public Vector3 normal; | ||
133 | } | ||
134 | [StructLayout(LayoutKind.Sequential)] | ||
135 | public struct EntityProperties | ||
136 | { | ||
137 | public uint ID; | ||
138 | public Vector3 Position; | ||
139 | public Quaternion Rotation; | ||
140 | public Vector3 Velocity; | ||
141 | public Vector3 Acceleration; | ||
142 | public Vector3 RotationalVelocity; | ||
143 | } | ||
144 | |||
145 | // Format of this structure must match the definition in the C++ code | ||
146 | // NOTE: adding the X causes compile breaks if used. These are unused symbols | ||
147 | // that can be removed from both here and the unmanaged definition of this structure. | ||
148 | [StructLayout(LayoutKind.Sequential)] | ||
149 | public struct ConfigurationParameters | ||
150 | { | ||
151 | public float defaultFriction; | ||
152 | public float defaultDensity; | ||
153 | public float defaultRestitution; | ||
154 | public float collisionMargin; | ||
155 | public float gravity; | ||
156 | |||
157 | public float XlinearDamping; | ||
158 | public float XangularDamping; | ||
159 | public float XdeactivationTime; | ||
160 | public float XlinearSleepingThreshold; | ||
161 | public float XangularSleepingThreshold; | ||
162 | public float XccdMotionThreshold; | ||
163 | public float XccdSweptSphereRadius; | ||
164 | public float XcontactProcessingThreshold; | ||
165 | |||
166 | public float XterrainImplementation; | ||
167 | public float XterrainFriction; | ||
168 | public float XterrainHitFraction; | ||
169 | public float XterrainRestitution; | ||
170 | public float XterrainCollisionMargin; | ||
171 | |||
172 | public float XavatarFriction; | ||
173 | public float XavatarStandingFriction; | ||
174 | public float XavatarDensity; | ||
175 | public float XavatarRestitution; | ||
176 | public float XavatarCapsuleWidth; | ||
177 | public float XavatarCapsuleDepth; | ||
178 | public float XavatarCapsuleHeight; | ||
179 | public float XavatarContactProcessingThreshold; | ||
180 | |||
181 | public float XvehicleAngularDamping; | ||
182 | |||
183 | public float maxPersistantManifoldPoolSize; | ||
184 | public float maxCollisionAlgorithmPoolSize; | ||
185 | public float shouldDisableContactPoolDynamicAllocation; | ||
186 | public float shouldForceUpdateAllAabbs; | ||
187 | public float shouldRandomizeSolverOrder; | ||
188 | public float shouldSplitSimulationIslands; | ||
189 | public float shouldEnableFrictionCaching; | ||
190 | public float numberOfSolverIterations; | ||
191 | |||
192 | public float XlinksetImplementation; | ||
193 | public float XlinkConstraintUseFrameOffset; | ||
194 | public float XlinkConstraintEnableTransMotor; | ||
195 | public float XlinkConstraintTransMotorMaxVel; | ||
196 | public float XlinkConstraintTransMotorMaxForce; | ||
197 | public float XlinkConstraintERP; | ||
198 | public float XlinkConstraintCFM; | ||
199 | public float XlinkConstraintSolverIterations; | ||
200 | |||
201 | public float physicsLoggingFrames; | ||
202 | |||
203 | public const float numericTrue = 1f; | ||
204 | public const float numericFalse = 0f; | ||
205 | } | ||
206 | |||
207 | |||
208 | // The states a bullet collision object can have | ||
209 | public enum ActivationState : uint | ||
210 | { | ||
211 | ACTIVE_TAG = 1, | ||
212 | ISLAND_SLEEPING, | ||
213 | WANTS_DEACTIVATION, | ||
214 | DISABLE_DEACTIVATION, | ||
215 | DISABLE_SIMULATION, | ||
216 | } | ||
217 | |||
218 | public enum CollisionObjectTypes : int | ||
219 | { | ||
220 | CO_COLLISION_OBJECT = 1 << 0, | ||
221 | CO_RIGID_BODY = 1 << 1, | ||
222 | CO_GHOST_OBJECT = 1 << 2, | ||
223 | CO_SOFT_BODY = 1 << 3, | ||
224 | CO_HF_FLUID = 1 << 4, | ||
225 | CO_USER_TYPE = 1 << 5, | ||
226 | } | ||
227 | |||
228 | // Values used by Bullet and BulletSim to control object properties. | ||
229 | // Bullet's "CollisionFlags" has more to do with operations on the | ||
230 | // object (if collisions happen, if gravity effects it, ...). | ||
231 | public enum CollisionFlags : uint | ||
232 | { | ||
233 | CF_STATIC_OBJECT = 1 << 0, | ||
234 | CF_KINEMATIC_OBJECT = 1 << 1, | ||
235 | CF_NO_CONTACT_RESPONSE = 1 << 2, | ||
236 | CF_CUSTOM_MATERIAL_CALLBACK = 1 << 3, | ||
237 | CF_CHARACTER_OBJECT = 1 << 4, | ||
238 | CF_DISABLE_VISUALIZE_OBJECT = 1 << 5, | ||
239 | CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6, | ||
240 | // Following used by BulletSim to control collisions and updates | ||
241 | BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, | ||
242 | BS_FLOATS_ON_WATER = 1 << 11, | ||
243 | BS_VEHICLE_COLLISIONS = 1 << 12, | ||
244 | BS_NONE = 0, | ||
245 | BS_ALL = 0xFFFFFFFF | ||
246 | }; | ||
247 | |||
248 | // Values f collisions groups and masks | ||
249 | public enum CollisionFilterGroups : uint | ||
250 | { | ||
251 | // Don't use the bit definitions!! Define the use in a | ||
252 | // filter/mask definition below. This way collision interactions | ||
253 | // are more easily found and debugged. | ||
254 | BNoneGroup = 0, | ||
255 | BDefaultGroup = 1 << 0, // 0001 | ||
256 | BStaticGroup = 1 << 1, // 0002 | ||
257 | BKinematicGroup = 1 << 2, // 0004 | ||
258 | BDebrisGroup = 1 << 3, // 0008 | ||
259 | BSensorTrigger = 1 << 4, // 0010 | ||
260 | BCharacterGroup = 1 << 5, // 0020 | ||
261 | BAllGroup = 0x000FFFFF, | ||
262 | // Filter groups defined by BulletSim | ||
263 | BGroundPlaneGroup = 1 << 10, // 0400 | ||
264 | BTerrainGroup = 1 << 11, // 0800 | ||
265 | BRaycastGroup = 1 << 12, // 1000 | ||
266 | BSolidGroup = 1 << 13, // 2000 | ||
267 | // BLinksetGroup = xx // a linkset proper is either static or dynamic | ||
268 | BLinksetChildGroup = 1 << 14, // 4000 | ||
269 | }; | ||
270 | |||
271 | // CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0 | ||
272 | // ERP controls amount of correction per tick. Usable range=0.1..0.8. Default=0.2. | ||
273 | public enum ConstraintParams : int | ||
274 | { | ||
275 | BT_CONSTRAINT_ERP = 1, // this one is not used in Bullet as of 20120730 | ||
276 | BT_CONSTRAINT_STOP_ERP, | ||
277 | BT_CONSTRAINT_CFM, | ||
278 | BT_CONSTRAINT_STOP_CFM, | ||
279 | }; | ||
280 | public enum ConstraintParamAxis : int | ||
281 | { | ||
282 | AXIS_LINEAR_X = 0, | ||
283 | AXIS_LINEAR_Y, | ||
284 | AXIS_LINEAR_Z, | ||
285 | AXIS_ANGULAR_X, | ||
286 | AXIS_ANGULAR_Y, | ||
287 | AXIS_ANGULAR_Z, | ||
288 | AXIS_LINEAR_ALL = 20, // these last three added by BulletSim so we don't have to do zillions of calls | ||
289 | AXIS_ANGULAR_ALL, | ||
290 | AXIS_ALL | ||
291 | }; | ||
292 | |||
293 | public abstract class BSAPITemplate | ||
294 | { | ||
295 | // Returns the name of the underlying Bullet engine | ||
296 | public abstract string BulletEngineName { get; } | ||
297 | public abstract string BulletEngineVersion { get; protected set;} | ||
298 | |||
299 | // Initialization and simulation | ||
300 | public abstract BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms, | ||
301 | int maxCollisions, ref CollisionDesc[] collisionArray, | ||
302 | int maxUpdates, ref EntityProperties[] updateArray | ||
303 | ); | ||
304 | |||
305 | public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, | ||
306 | out int updatedEntityCount, out int collidersCount); | ||
307 | |||
308 | public abstract bool UpdateParameter(BulletWorld world, uint localID, String parm, float value); | ||
309 | |||
310 | public abstract void Shutdown(BulletWorld sim); | ||
311 | |||
312 | public abstract bool PushUpdate(BulletBody obj); | ||
313 | |||
314 | // ===================================================================================== | ||
315 | // Mesh, hull, shape and body creation helper routines | ||
316 | public abstract BulletShape CreateMeshShape(BulletWorld world, | ||
317 | int indicesCount, int[] indices, | ||
318 | int verticesCount, float[] vertices ); | ||
319 | |||
320 | public abstract BulletShape CreateHullShape(BulletWorld world, | ||
321 | int hullCount, float[] hulls); | ||
322 | |||
323 | public abstract BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape); | ||
324 | |||
325 | public abstract BulletShape BuildNativeShape(BulletWorld world, ShapeData shapeData); | ||
326 | |||
327 | public abstract bool IsNativeShape(BulletShape shape); | ||
328 | |||
329 | public abstract void SetShapeCollisionMargin(BulletShape shape, float margin); | ||
330 | |||
331 | public abstract BulletShape BuildCapsuleShape(BulletWorld world, float radius, float height, Vector3 scale); | ||
332 | |||
333 | public abstract BulletShape CreateCompoundShape(BulletWorld sim, bool enableDynamicAabbTree); | ||
334 | |||
335 | public abstract int GetNumberOfCompoundChildren(BulletShape cShape); | ||
336 | |||
337 | public abstract void AddChildShapeToCompoundShape(BulletShape cShape, BulletShape addShape, Vector3 pos, Quaternion rot); | ||
338 | |||
339 | public abstract BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx); | ||
340 | |||
341 | public abstract BulletShape RemoveChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx); | ||
342 | |||
343 | public abstract void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape); | ||
344 | |||
345 | public abstract void RecalculateCompoundShapeLocalAabb(BulletShape cShape); | ||
346 | |||
347 | public abstract BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id); | ||
348 | |||
349 | |||
350 | public abstract bool DeleteCollisionShape(BulletWorld world, BulletShape shape); | ||
351 | |||
352 | public abstract int GetBodyType(BulletBody obj); | ||
353 | |||
354 | public abstract BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot); | ||
355 | |||
356 | public abstract BulletBody CreateBodyWithDefaultMotionState(BulletShape shape, uint id, Vector3 pos, Quaternion rot); | ||
357 | |||
358 | public abstract BulletBody CreateGhostFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot); | ||
359 | |||
360 | public abstract void DestroyObject(BulletWorld sim, BulletBody obj); | ||
361 | |||
362 | // ===================================================================================== | ||
363 | public abstract BulletShape CreateGroundPlaneShape(uint id, float height, float collisionMargin); | ||
364 | |||
365 | public abstract BulletShape CreateTerrainShape(uint id, Vector3 size, float minHeight, float maxHeight, float[] heightMap, | ||
366 | float scaleFactor, float collisionMargin); | ||
367 | |||
368 | // ===================================================================================== | ||
369 | // Constraint creation and helper routines | ||
370 | public abstract BulletConstraint Create6DofConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, | ||
371 | Vector3 frame1loc, Quaternion frame1rot, | ||
372 | Vector3 frame2loc, Quaternion frame2rot, | ||
373 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | ||
374 | |||
375 | public abstract BulletConstraint Create6DofConstraintToPoint(BulletWorld world, BulletBody obj1, BulletBody obj2, | ||
376 | Vector3 joinPoint, | ||
377 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | ||
378 | |||
379 | public abstract BulletConstraint CreateHingeConstraint(BulletWorld world, BulletBody obj1, BulletBody obj2, | ||
380 | Vector3 pivotinA, Vector3 pivotinB, | ||
381 | Vector3 axisInA, Vector3 axisInB, | ||
382 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); | ||
383 | |||
384 | public abstract void SetConstraintEnable(BulletConstraint constrain, float numericTrueFalse); | ||
385 | |||
386 | public abstract void SetConstraintNumSolverIterations(BulletConstraint constrain, float iterations); | ||
387 | |||
388 | public abstract bool SetFrames(BulletConstraint constrain, | ||
389 | Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot); | ||
390 | |||
391 | public abstract bool SetLinearLimits(BulletConstraint constrain, Vector3 low, Vector3 hi); | ||
392 | |||
393 | public abstract bool SetAngularLimits(BulletConstraint constrain, Vector3 low, Vector3 hi); | ||
394 | |||
395 | public abstract bool UseFrameOffset(BulletConstraint constrain, float enable); | ||
396 | |||
397 | public abstract bool TranslationalLimitMotor(BulletConstraint constrain, float enable, float targetVel, float maxMotorForce); | ||
398 | |||
399 | public abstract bool SetBreakingImpulseThreshold(BulletConstraint constrain, float threshold); | ||
400 | |||
401 | public abstract bool CalculateTransforms(BulletConstraint constrain); | ||
402 | |||
403 | public abstract bool SetConstraintParam(BulletConstraint constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis); | ||
404 | |||
405 | public abstract bool DestroyConstraint(BulletWorld world, BulletConstraint constrain); | ||
406 | |||
407 | // ===================================================================================== | ||
408 | // btCollisionWorld entries | ||
409 | public abstract void UpdateSingleAabb(BulletWorld world, BulletBody obj); | ||
410 | |||
411 | public abstract void UpdateAabbs(BulletWorld world); | ||
412 | |||
413 | public abstract bool GetForceUpdateAllAabbs(BulletWorld world); | ||
414 | |||
415 | public abstract void SetForceUpdateAllAabbs(BulletWorld world, bool force); | ||
416 | |||
417 | // ===================================================================================== | ||
418 | // btDynamicsWorld entries | ||
419 | public abstract bool AddObjectToWorld(BulletWorld world, BulletBody obj); | ||
420 | |||
421 | public abstract bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj); | ||
422 | |||
423 | public abstract bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects); | ||
424 | |||
425 | public abstract bool RemoveConstraintFromWorld(BulletWorld world, BulletConstraint constrain); | ||
426 | // ===================================================================================== | ||
427 | // btCollisionObject entries | ||
428 | public abstract Vector3 GetAnisotripicFriction(BulletConstraint constrain); | ||
429 | |||
430 | public abstract Vector3 SetAnisotripicFriction(BulletConstraint constrain, Vector3 frict); | ||
431 | |||
432 | public abstract bool HasAnisotripicFriction(BulletConstraint constrain); | ||
433 | |||
434 | public abstract void SetContactProcessingThreshold(BulletBody obj, float val); | ||
435 | |||
436 | public abstract float GetContactProcessingThreshold(BulletBody obj); | ||
437 | |||
438 | public abstract bool IsStaticObject(BulletBody obj); | ||
439 | |||
440 | public abstract bool IsKinematicObject(BulletBody obj); | ||
441 | |||
442 | public abstract bool IsStaticOrKinematicObject(BulletBody obj); | ||
443 | |||
444 | public abstract bool HasContactResponse(BulletBody obj); | ||
445 | |||
446 | public abstract void SetCollisionShape(BulletWorld sim, BulletBody obj, BulletShape shape); | ||
447 | |||
448 | public abstract BulletShape GetCollisionShape(BulletBody obj); | ||
449 | |||
450 | public abstract int GetActivationState(BulletBody obj); | ||
451 | |||
452 | public abstract void SetActivationState(BulletBody obj, int state); | ||
453 | |||
454 | public abstract void SetDeactivationTime(BulletBody obj, float dtime); | ||
455 | |||
456 | public abstract float GetDeactivationTime(BulletBody obj); | ||
457 | |||
458 | public abstract void ForceActivationState(BulletBody obj, ActivationState state); | ||
459 | |||
460 | public abstract void Activate(BulletBody obj, bool forceActivation); | ||
461 | |||
462 | public abstract bool IsActive(BulletBody obj); | ||
463 | |||
464 | public abstract void SetRestitution(BulletBody obj, float val); | ||
465 | |||
466 | public abstract float GetRestitution(BulletBody obj); | ||
467 | |||
468 | public abstract void SetFriction(BulletBody obj, float val); | ||
469 | |||
470 | public abstract float GetFriction(BulletBody obj); | ||
471 | |||
472 | public abstract Vector3 GetPosition(BulletBody obj); | ||
473 | |||
474 | public abstract Quaternion GetOrientation(BulletBody obj); | ||
475 | |||
476 | public abstract void SetTranslation(BulletBody obj, Vector3 position, Quaternion rotation); | ||
477 | |||
478 | // public abstract IntPtr GetBroadphaseHandle(BulletBody obj); | ||
479 | |||
480 | // public abstract void SetBroadphaseHandle(BulletBody obj, IntPtr handle); | ||
481 | |||
482 | public abstract void SetInterpolationLinearVelocity(BulletBody obj, Vector3 vel); | ||
483 | |||
484 | public abstract void SetInterpolationAngularVelocity(BulletBody obj, Vector3 vel); | ||
485 | |||
486 | public abstract void SetInterpolationVelocity(BulletBody obj, Vector3 linearVel, Vector3 angularVel); | ||
487 | |||
488 | public abstract float GetHitFraction(BulletBody obj); | ||
489 | |||
490 | public abstract void SetHitFraction(BulletBody obj, float val); | ||
491 | |||
492 | public abstract CollisionFlags GetCollisionFlags(BulletBody obj); | ||
493 | |||
494 | public abstract CollisionFlags SetCollisionFlags(BulletBody obj, CollisionFlags flags); | ||
495 | |||
496 | public abstract CollisionFlags AddToCollisionFlags(BulletBody obj, CollisionFlags flags); | ||
497 | |||
498 | public abstract CollisionFlags RemoveFromCollisionFlags(BulletBody obj, CollisionFlags flags); | ||
499 | |||
500 | public abstract float GetCcdMotionThreshold(BulletBody obj); | ||
501 | |||
502 | public abstract void SetCcdMotionThreshold(BulletBody obj, float val); | ||
503 | |||
504 | public abstract float GetCcdSweptSphereRadius(BulletBody obj); | ||
505 | |||
506 | public abstract void SetCcdSweptSphereRadius(BulletBody obj, float val); | ||
507 | |||
508 | public abstract IntPtr GetUserPointer(BulletBody obj); | ||
509 | |||
510 | public abstract void SetUserPointer(BulletBody obj, IntPtr val); | ||
511 | |||
512 | // ===================================================================================== | ||
513 | // btRigidBody entries | ||
514 | public abstract void ApplyGravity(BulletBody obj); | ||
515 | |||
516 | public abstract void SetGravity(BulletBody obj, Vector3 val); | ||
517 | |||
518 | public abstract Vector3 GetGravity(BulletBody obj); | ||
519 | |||
520 | public abstract void SetDamping(BulletBody obj, float lin_damping, float ang_damping); | ||
521 | |||
522 | public abstract void SetLinearDamping(BulletBody obj, float lin_damping); | ||
523 | |||
524 | public abstract void SetAngularDamping(BulletBody obj, float ang_damping); | ||
525 | |||
526 | public abstract float GetLinearDamping(BulletBody obj); | ||
527 | |||
528 | public abstract float GetAngularDamping(BulletBody obj); | ||
529 | |||
530 | public abstract float GetLinearSleepingThreshold(BulletBody obj); | ||
531 | |||
532 | public abstract void ApplyDamping(BulletBody obj, float timeStep); | ||
533 | |||
534 | public abstract void SetMassProps(BulletBody obj, float mass, Vector3 inertia); | ||
535 | |||
536 | public abstract Vector3 GetLinearFactor(BulletBody obj); | ||
537 | |||
538 | public abstract void SetLinearFactor(BulletBody obj, Vector3 factor); | ||
539 | |||
540 | public abstract void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot); | ||
541 | |||
542 | // Add a force to the object as if its mass is one. | ||
543 | public abstract void ApplyCentralForce(BulletBody obj, Vector3 force); | ||
544 | |||
545 | // Set the force being applied to the object as if its mass is one. | ||
546 | public abstract void SetObjectForce(BulletBody obj, Vector3 force); | ||
547 | |||
548 | public abstract Vector3 GetTotalForce(BulletBody obj); | ||
549 | |||
550 | public abstract Vector3 GetTotalTorque(BulletBody obj); | ||
551 | |||
552 | public abstract Vector3 GetInvInertiaDiagLocal(BulletBody obj); | ||
553 | |||
554 | public abstract void SetInvInertiaDiagLocal(BulletBody obj, Vector3 inert); | ||
555 | |||
556 | public abstract void SetSleepingThresholds(BulletBody obj, float lin_threshold, float ang_threshold); | ||
557 | |||
558 | public abstract void ApplyTorque(BulletBody obj, Vector3 torque); | ||
559 | |||
560 | // Apply force at the given point. Will add torque to the object. | ||
561 | public abstract void ApplyForce(BulletBody obj, Vector3 force, Vector3 pos); | ||
562 | |||
563 | // Apply impulse to the object. Same as "ApplycentralForce" but force scaled by object's mass. | ||
564 | public abstract void ApplyCentralImpulse(BulletBody obj, Vector3 imp); | ||
565 | |||
566 | // Apply impulse to the object's torque. Force is scaled by object's mass. | ||
567 | public abstract void ApplyTorqueImpulse(BulletBody obj, Vector3 imp); | ||
568 | |||
569 | // Apply impulse at the point given. For is scaled by object's mass and effects both linear and angular forces. | ||
570 | public abstract void ApplyImpulse(BulletBody obj, Vector3 imp, Vector3 pos); | ||
571 | |||
572 | public abstract void ClearForces(BulletBody obj); | ||
573 | |||
574 | public abstract void ClearAllForces(BulletBody obj); | ||
575 | |||
576 | public abstract void UpdateInertiaTensor(BulletBody obj); | ||
577 | |||
578 | public abstract Vector3 GetLinearVelocity(BulletBody obj); | ||
579 | |||
580 | public abstract Vector3 GetAngularVelocity(BulletBody obj); | ||
581 | |||
582 | public abstract void SetLinearVelocity(BulletBody obj, Vector3 val); | ||
583 | |||
584 | public abstract void SetAngularVelocity(BulletBody obj, Vector3 angularVelocity); | ||
585 | |||
586 | public abstract Vector3 GetVelocityInLocalPoint(BulletBody obj, Vector3 pos); | ||
587 | |||
588 | public abstract void Translate(BulletBody obj, Vector3 trans); | ||
589 | |||
590 | public abstract void UpdateDeactivation(BulletBody obj, float timeStep); | ||
591 | |||
592 | public abstract bool WantsSleeping(BulletBody obj); | ||
593 | |||
594 | public abstract void SetAngularFactor(BulletBody obj, float factor); | ||
595 | |||
596 | public abstract void SetAngularFactorV(BulletBody obj, Vector3 factor); | ||
597 | |||
598 | public abstract Vector3 GetAngularFactor(BulletBody obj); | ||
599 | |||
600 | public abstract bool IsInWorld(BulletBody obj); | ||
601 | |||
602 | public abstract void AddConstraintRef(BulletBody obj, BulletConstraint constrain); | ||
603 | |||
604 | public abstract void RemoveConstraintRef(BulletBody obj, BulletConstraint constrain); | ||
605 | |||
606 | public abstract BulletConstraint GetConstraintRef(BulletBody obj, int index); | ||
607 | |||
608 | public abstract int GetNumConstraintRefs(BulletBody obj); | ||
609 | |||
610 | public abstract bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask); | ||
611 | |||
612 | // ===================================================================================== | ||
613 | // btCollisionShape entries | ||
614 | |||
615 | public abstract float GetAngularMotionDisc(BulletShape shape); | ||
616 | |||
617 | public abstract float GetContactBreakingThreshold(BulletShape shape, float defaultFactor); | ||
618 | |||
619 | public abstract bool IsPolyhedral(BulletShape shape); | ||
620 | |||
621 | public abstract bool IsConvex2d(BulletShape shape); | ||
622 | |||
623 | public abstract bool IsConvex(BulletShape shape); | ||
624 | |||
625 | public abstract bool IsNonMoving(BulletShape shape); | ||
626 | |||
627 | public abstract bool IsConcave(BulletShape shape); | ||
628 | |||
629 | public abstract bool IsCompound(BulletShape shape); | ||
630 | |||
631 | public abstract bool IsSoftBody(BulletShape shape); | ||
632 | |||
633 | public abstract bool IsInfinite(BulletShape shape); | ||
634 | |||
635 | public abstract void SetLocalScaling(BulletShape shape, Vector3 scale); | ||
636 | |||
637 | public abstract Vector3 GetLocalScaling(BulletShape shape); | ||
638 | |||
639 | public abstract Vector3 CalculateLocalInertia(BulletShape shape, float mass); | ||
640 | |||
641 | public abstract int GetShapeType(BulletShape shape); | ||
642 | |||
643 | public abstract void SetMargin(BulletShape shape, float val); | ||
644 | |||
645 | public abstract float GetMargin(BulletShape shape); | ||
646 | |||
647 | // ===================================================================================== | ||
648 | // Debugging | ||
649 | public abstract void DumpRigidBody(BulletWorld sim, BulletBody collisionObject); | ||
650 | |||
651 | public abstract void DumpCollisionShape(BulletWorld sim, BulletShape collisionShape); | ||
652 | |||
653 | public abstract void DumpConstraint(BulletWorld sim, BulletConstraint constrain); | ||
654 | |||
655 | public abstract void DumpActivationInfo(BulletWorld sim); | ||
656 | |||
657 | public abstract void DumpAllInfo(BulletWorld sim); | ||
658 | |||
659 | public abstract void DumpPhysicsStatistics(BulletWorld sim); | ||
660 | |||
661 | }; | ||
662 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 3b77e49..103d8fc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -137,7 +137,7 @@ public sealed class BSCharacter : BSPhysObject | |||
137 | 137 | ||
138 | private void SetPhysicalProperties() | 138 | private void SetPhysicalProperties() |
139 | { | 139 | { |
140 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 140 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); |
141 | 141 | ||
142 | ZeroMotion(true); | 142 | ZeroMotion(true); |
143 | ForcePosition = _position; | 143 | ForcePosition = _position; |
@@ -152,32 +152,32 @@ public sealed class BSCharacter : BSPhysObject | |||
152 | // Needs to be reset especially when an avatar is recreated after crossing a region boundry. | 152 | // Needs to be reset especially when an avatar is recreated after crossing a region boundry. |
153 | Flying = _flying; | 153 | Flying = _flying; |
154 | 154 | ||
155 | BulletSimAPI.SetRestitution2(PhysBody.ptr, BSParam.AvatarRestitution); | 155 | PhysicsScene.PE.SetRestitution(PhysBody, BSParam.AvatarRestitution); |
156 | BulletSimAPI.SetMargin2(PhysShape.ptr, PhysicsScene.Params.collisionMargin); | 156 | PhysicsScene.PE.SetMargin(PhysShape, PhysicsScene.Params.collisionMargin); |
157 | BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); | 157 | PhysicsScene.PE.SetLocalScaling(PhysShape, Scale); |
158 | BulletSimAPI.SetContactProcessingThreshold2(PhysBody.ptr, BSParam.ContactProcessingThreshold); | 158 | PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); |
159 | if (BSParam.CcdMotionThreshold > 0f) | 159 | if (BSParam.CcdMotionThreshold > 0f) |
160 | { | 160 | { |
161 | BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold); | 161 | PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); |
162 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius); | 162 | PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); |
163 | } | 163 | } |
164 | 164 | ||
165 | UpdatePhysicalMassProperties(RawMass, false); | 165 | UpdatePhysicalMassProperties(RawMass, false); |
166 | 166 | ||
167 | // Make so capsule does not fall over | 167 | // Make so capsule does not fall over |
168 | BulletSimAPI.SetAngularFactorV2(PhysBody.ptr, OMV.Vector3.Zero); | 168 | PhysicsScene.PE.SetAngularFactorV(PhysBody, OMV.Vector3.Zero); |
169 | 169 | ||
170 | BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT); | 170 | PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_CHARACTER_OBJECT); |
171 | 171 | ||
172 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 172 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody); |
173 | 173 | ||
174 | // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG); | 174 | // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG); |
175 | BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_DEACTIVATION); | 175 | PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_DEACTIVATION); |
176 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); | 176 | PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody); |
177 | 177 | ||
178 | // Do this after the object has been added to the world | 178 | // Do this after the object has been added to the world |
179 | PhysBody.collisionType = CollisionType.Avatar; | 179 | PhysBody.collisionType = CollisionType.Avatar; |
180 | PhysBody.ApplyCollisionMask(); | 180 | PhysBody.ApplyCollisionMask(PhysicsScene); |
181 | } | 181 | } |
182 | 182 | ||
183 | // The avatar's movement is controlled by this motor that speeds up and slows down | 183 | // The avatar's movement is controlled by this motor that speeds up and slows down |
@@ -210,8 +210,7 @@ public sealed class BSCharacter : BSPhysObject | |||
210 | if (!Flying && !IsColliding) | 210 | if (!Flying && !IsColliding) |
211 | { | 211 | { |
212 | stepVelocity.Z = _velocity.Z; | 212 | stepVelocity.Z = _velocity.Z; |
213 | DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", | 213 | // DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity); |
214 | LocalID, stepVelocity); | ||
215 | } | 214 | } |
216 | 215 | ||
217 | // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. | 216 | // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. |
@@ -231,8 +230,7 @@ public sealed class BSCharacter : BSPhysObject | |||
231 | AddForce(moveForce, false, true); | 230 | AddForce(moveForce, false, true); |
232 | } | 231 | } |
233 | */ | 232 | */ |
234 | DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", | 233 | // DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce); |
235 | LocalID, stepVelocity, _velocity, Mass, moveForce); | ||
236 | AddForce(moveForce, false, true); | 234 | AddForce(moveForce, false, true); |
237 | }); | 235 | }); |
238 | } | 236 | } |
@@ -267,10 +265,10 @@ public sealed class BSCharacter : BSPhysObject | |||
267 | { | 265 | { |
268 | if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape) | 266 | if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape) |
269 | { | 267 | { |
270 | BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); | 268 | PhysicsScene.PE.SetLocalScaling(PhysShape, Scale); |
271 | UpdatePhysicalMassProperties(RawMass, true); | 269 | UpdatePhysicalMassProperties(RawMass, true); |
272 | // Make sure this change appears as a property update event | 270 | // Make sure this change appears as a property update event |
273 | BulletSimAPI.PushUpdate2(PhysBody.ptr); | 271 | PhysicsScene.PE.PushUpdate(PhysBody); |
274 | } | 272 | } |
275 | }); | 273 | }); |
276 | 274 | ||
@@ -311,7 +309,7 @@ public sealed class BSCharacter : BSPhysObject | |||
311 | PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() | 309 | PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() |
312 | { | 310 | { |
313 | if (PhysBody.HasPhysicalBody) | 311 | if (PhysBody.HasPhysicalBody) |
314 | BulletSimAPI.ClearAllForces2(PhysBody.ptr); | 312 | PhysicsScene.PE.ClearAllForces(PhysBody); |
315 | }); | 313 | }); |
316 | } | 314 | } |
317 | public override void ZeroAngularMotion(bool inTaintTime) | 315 | public override void ZeroAngularMotion(bool inTaintTime) |
@@ -322,10 +320,10 @@ public sealed class BSCharacter : BSPhysObject | |||
322 | { | 320 | { |
323 | if (PhysBody.HasPhysicalBody) | 321 | if (PhysBody.HasPhysicalBody) |
324 | { | 322 | { |
325 | BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); | 323 | PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, OMV.Vector3.Zero); |
326 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); | 324 | PhysicsScene.PE.SetAngularVelocity(PhysBody, OMV.Vector3.Zero); |
327 | // The next also get rid of applied linear force but the linear velocity is untouched. | 325 | // The next also get rid of applied linear force but the linear velocity is untouched. |
328 | BulletSimAPI.ClearForces2(PhysBody.ptr); | 326 | PhysicsScene.PE.ClearForces(PhysBody); |
329 | } | 327 | } |
330 | }); | 328 | }); |
331 | } | 329 | } |
@@ -341,7 +339,7 @@ public sealed class BSCharacter : BSPhysObject | |||
341 | public override OMV.Vector3 Position { | 339 | public override OMV.Vector3 Position { |
342 | get { | 340 | get { |
343 | // Don't refetch the position because this function is called a zillion times | 341 | // Don't refetch the position because this function is called a zillion times |
344 | // _position = BulletSimAPI.GetObjectPosition2(Scene.World.ptr, LocalID); | 342 | // _position = PhysicsScene.PE.GetObjectPosition(Scene.World, LocalID); |
345 | return _position; | 343 | return _position; |
346 | } | 344 | } |
347 | set { | 345 | set { |
@@ -352,19 +350,19 @@ public sealed class BSCharacter : BSPhysObject | |||
352 | { | 350 | { |
353 | DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 351 | DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
354 | if (PhysBody.HasPhysicalBody) | 352 | if (PhysBody.HasPhysicalBody) |
355 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 353 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
356 | }); | 354 | }); |
357 | } | 355 | } |
358 | } | 356 | } |
359 | public override OMV.Vector3 ForcePosition { | 357 | public override OMV.Vector3 ForcePosition { |
360 | get { | 358 | get { |
361 | _position = BulletSimAPI.GetPosition2(PhysBody.ptr); | 359 | _position = PhysicsScene.PE.GetPosition(PhysBody); |
362 | return _position; | 360 | return _position; |
363 | } | 361 | } |
364 | set { | 362 | set { |
365 | _position = value; | 363 | _position = value; |
366 | PositionSanityCheck(); | 364 | PositionSanityCheck(); |
367 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 365 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
368 | } | 366 | } |
369 | } | 367 | } |
370 | 368 | ||
@@ -420,7 +418,7 @@ public sealed class BSCharacter : BSPhysObject | |||
420 | { | 418 | { |
421 | DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 419 | DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
422 | if (PhysBody.HasPhysicalBody) | 420 | if (PhysBody.HasPhysicalBody) |
423 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 421 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
424 | }); | 422 | }); |
425 | ret = true; | 423 | ret = true; |
426 | } | 424 | } |
@@ -435,8 +433,8 @@ public sealed class BSCharacter : BSPhysObject | |||
435 | } | 433 | } |
436 | public override void UpdatePhysicalMassProperties(float physMass, bool inWorld) | 434 | public override void UpdatePhysicalMassProperties(float physMass, bool inWorld) |
437 | { | 435 | { |
438 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); | 436 | OMV.Vector3 localInertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape, physMass); |
439 | BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, localInertia); | 437 | PhysicsScene.PE.SetMassProps(PhysBody, physMass, localInertia); |
440 | } | 438 | } |
441 | 439 | ||
442 | public override OMV.Vector3 Force { | 440 | public override OMV.Vector3 Force { |
@@ -448,7 +446,7 @@ public sealed class BSCharacter : BSPhysObject | |||
448 | { | 446 | { |
449 | DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force); | 447 | DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force); |
450 | if (PhysBody.HasPhysicalBody) | 448 | if (PhysBody.HasPhysicalBody) |
451 | BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); | 449 | PhysicsScene.PE.SetObjectForce(PhysBody, _force); |
452 | }); | 450 | }); |
453 | } | 451 | } |
454 | } | 452 | } |
@@ -522,7 +520,7 @@ public sealed class BSCharacter : BSPhysObject | |||
522 | { | 520 | { |
523 | _currentFriction = BSParam.AvatarStandingFriction; | 521 | _currentFriction = BSParam.AvatarStandingFriction; |
524 | if (PhysBody.HasPhysicalBody) | 522 | if (PhysBody.HasPhysicalBody) |
525 | BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction); | 523 | PhysicsScene.PE.SetFriction(PhysBody, _currentFriction); |
526 | } | 524 | } |
527 | } | 525 | } |
528 | else | 526 | else |
@@ -531,12 +529,12 @@ public sealed class BSCharacter : BSPhysObject | |||
531 | { | 529 | { |
532 | _currentFriction = BSParam.AvatarFriction; | 530 | _currentFriction = BSParam.AvatarFriction; |
533 | if (PhysBody.HasPhysicalBody) | 531 | if (PhysBody.HasPhysicalBody) |
534 | BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction); | 532 | PhysicsScene.PE.SetFriction(PhysBody, _currentFriction); |
535 | } | 533 | } |
536 | } | 534 | } |
537 | 535 | ||
538 | BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); | 536 | PhysicsScene.PE.SetLinearVelocity(PhysBody, _velocity); |
539 | BulletSimAPI.Activate2(PhysBody.ptr, true); | 537 | PhysicsScene.PE.Activate(PhysBody, true); |
540 | } | 538 | } |
541 | } | 539 | } |
542 | public override OMV.Vector3 Torque { | 540 | public override OMV.Vector3 Torque { |
@@ -578,7 +576,7 @@ public sealed class BSCharacter : BSPhysObject | |||
578 | { | 576 | { |
579 | get | 577 | get |
580 | { | 578 | { |
581 | _orientation = BulletSimAPI.GetOrientation2(PhysBody.ptr); | 579 | _orientation = PhysicsScene.PE.GetOrientation(PhysBody); |
582 | return _orientation; | 580 | return _orientation; |
583 | } | 581 | } |
584 | set | 582 | set |
@@ -586,8 +584,8 @@ public sealed class BSCharacter : BSPhysObject | |||
586 | _orientation = value; | 584 | _orientation = value; |
587 | if (PhysBody.HasPhysicalBody) | 585 | if (PhysBody.HasPhysicalBody) |
588 | { | 586 | { |
589 | // _position = BulletSimAPI.GetPosition2(BSBody.ptr); | 587 | // _position = PhysicsScene.PE.GetPosition(BSBody); |
590 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 588 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
591 | } | 589 | } |
592 | } | 590 | } |
593 | } | 591 | } |
@@ -638,9 +636,9 @@ public sealed class BSCharacter : BSPhysObject | |||
638 | if (PhysBody.HasPhysicalBody) | 636 | if (PhysBody.HasPhysicalBody) |
639 | { | 637 | { |
640 | if (_floatOnWater) | 638 | if (_floatOnWater) |
641 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 639 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); |
642 | else | 640 | else |
643 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 641 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); |
644 | } | 642 | } |
645 | }); | 643 | }); |
646 | } | 644 | } |
@@ -678,7 +676,7 @@ public sealed class BSCharacter : BSPhysObject | |||
678 | // Buoyancy is faked by changing the gravity applied to the object | 676 | // Buoyancy is faked by changing the gravity applied to the object |
679 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); | 677 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); |
680 | if (PhysBody.HasPhysicalBody) | 678 | if (PhysBody.HasPhysicalBody) |
681 | BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav)); | 679 | PhysicsScene.PE.SetGravity(PhysBody, new OMV.Vector3(0f, 0f, grav)); |
682 | } | 680 | } |
683 | } | 681 | } |
684 | 682 | ||
@@ -736,10 +734,10 @@ public sealed class BSCharacter : BSPhysObject | |||
736 | PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() | 734 | PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() |
737 | { | 735 | { |
738 | // Bullet adds this central force to the total force for this tick | 736 | // Bullet adds this central force to the total force for this tick |
739 | DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce); | 737 | // DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce); |
740 | if (PhysBody.HasPhysicalBody) | 738 | if (PhysBody.HasPhysicalBody) |
741 | { | 739 | { |
742 | BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce); | 740 | PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce); |
743 | } | 741 | } |
744 | }); | 742 | }); |
745 | } | 743 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index 59584b2..b813974 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs | |||
@@ -37,6 +37,7 @@ public abstract class BSConstraint : IDisposable | |||
37 | private static string LogHeader = "[BULLETSIM CONSTRAINT]"; | 37 | private static string LogHeader = "[BULLETSIM CONSTRAINT]"; |
38 | 38 | ||
39 | protected BulletWorld m_world; | 39 | protected BulletWorld m_world; |
40 | protected BSScene PhysicsScene; | ||
40 | protected BulletBody m_body1; | 41 | protected BulletBody m_body1; |
41 | protected BulletBody m_body2; | 42 | protected BulletBody m_body2; |
42 | protected BulletConstraint m_constraint; | 43 | protected BulletConstraint m_constraint; |
@@ -48,8 +49,10 @@ public abstract class BSConstraint : IDisposable | |||
48 | public abstract ConstraintType Type { get; } | 49 | public abstract ConstraintType Type { get; } |
49 | public bool IsEnabled { get { return m_enabled; } } | 50 | public bool IsEnabled { get { return m_enabled; } } |
50 | 51 | ||
51 | public BSConstraint() | 52 | public BSConstraint(BulletWorld world) |
52 | { | 53 | { |
54 | m_world = world; | ||
55 | PhysicsScene = m_world.physicsScene; | ||
53 | } | 56 | } |
54 | 57 | ||
55 | public virtual void Dispose() | 58 | public virtual void Dispose() |
@@ -59,11 +62,11 @@ public abstract class BSConstraint : IDisposable | |||
59 | m_enabled = false; | 62 | m_enabled = false; |
60 | if (m_constraint.HasPhysicalConstraint) | 63 | if (m_constraint.HasPhysicalConstraint) |
61 | { | 64 | { |
62 | bool success = BulletSimAPI.DestroyConstraint2(m_world.ptr, m_constraint.ptr); | 65 | bool success = PhysicsScene.PE.DestroyConstraint(m_world, m_constraint); |
63 | m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}", | 66 | m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}", |
64 | BSScene.DetailLogZero, | 67 | BSScene.DetailLogZero, |
65 | m_body1.ID, m_body1.ptr.ToString("X"), | 68 | m_body1.ID, m_body1.AddrString, |
66 | m_body2.ID, m_body2.ptr.ToString("X"), | 69 | m_body2.ID, m_body2.AddrString, |
67 | success); | 70 | success); |
68 | m_constraint.Clear(); | 71 | m_constraint.Clear(); |
69 | } | 72 | } |
@@ -74,7 +77,7 @@ public abstract class BSConstraint : IDisposable | |||
74 | { | 77 | { |
75 | bool ret = false; | 78 | bool ret = false; |
76 | if (m_enabled) | 79 | if (m_enabled) |
77 | ret = BulletSimAPI.SetLinearLimits2(m_constraint.ptr, low, high); | 80 | ret = PhysicsScene.PE.SetLinearLimits(m_constraint, low, high); |
78 | return ret; | 81 | return ret; |
79 | } | 82 | } |
80 | 83 | ||
@@ -82,7 +85,7 @@ public abstract class BSConstraint : IDisposable | |||
82 | { | 85 | { |
83 | bool ret = false; | 86 | bool ret = false; |
84 | if (m_enabled) | 87 | if (m_enabled) |
85 | ret = BulletSimAPI.SetAngularLimits2(m_constraint.ptr, low, high); | 88 | ret = PhysicsScene.PE.SetAngularLimits(m_constraint, low, high); |
86 | return ret; | 89 | return ret; |
87 | } | 90 | } |
88 | 91 | ||
@@ -91,7 +94,7 @@ public abstract class BSConstraint : IDisposable | |||
91 | bool ret = false; | 94 | bool ret = false; |
92 | if (m_enabled) | 95 | if (m_enabled) |
93 | { | 96 | { |
94 | BulletSimAPI.SetConstraintNumSolverIterations2(m_constraint.ptr, cnt); | 97 | PhysicsScene.PE.SetConstraintNumSolverIterations(m_constraint, cnt); |
95 | ret = true; | 98 | ret = true; |
96 | } | 99 | } |
97 | return ret; | 100 | return ret; |
@@ -103,7 +106,7 @@ public abstract class BSConstraint : IDisposable | |||
103 | if (m_enabled) | 106 | if (m_enabled) |
104 | { | 107 | { |
105 | // Recompute the internal transforms | 108 | // Recompute the internal transforms |
106 | BulletSimAPI.CalculateTransforms2(m_constraint.ptr); | 109 | PhysicsScene.PE.CalculateTransforms(m_constraint); |
107 | ret = true; | 110 | ret = true; |
108 | } | 111 | } |
109 | return ret; | 112 | return ret; |
@@ -122,7 +125,7 @@ public abstract class BSConstraint : IDisposable | |||
122 | // Setting an object's mass to zero (making it static like when it's selected) | 125 | // Setting an object's mass to zero (making it static like when it's selected) |
123 | // automatically disables the constraints. | 126 | // automatically disables the constraints. |
124 | // If the link is enabled, be sure to set the constraint itself to enabled. | 127 | // If the link is enabled, be sure to set the constraint itself to enabled. |
125 | BulletSimAPI.SetConstraintEnable2(m_constraint.ptr, BSParam.NumericBool(true)); | 128 | PhysicsScene.PE.SetConstraintEnable(m_constraint, BSParam.NumericBool(true)); |
126 | } | 129 | } |
127 | else | 130 | else |
128 | { | 131 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs index b946870..ecb1b32 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs | |||
@@ -43,46 +43,44 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
43 | Vector3 frame1, Quaternion frame1rot, | 43 | Vector3 frame1, Quaternion frame1rot, |
44 | Vector3 frame2, Quaternion frame2rot, | 44 | Vector3 frame2, Quaternion frame2rot, |
45 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 45 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
46 | : base(world) | ||
46 | { | 47 | { |
47 | m_world = world; | ||
48 | m_body1 = obj1; | 48 | m_body1 = obj1; |
49 | m_body2 = obj2; | 49 | m_body2 = obj2; |
50 | m_constraint = new BulletConstraint( | 50 | m_constraint = PhysicsScene.PE.Create6DofConstraint(m_world, m_body1, m_body2, |
51 | BulletSimAPI.Create6DofConstraint2(m_world.ptr, m_body1.ptr, m_body2.ptr, | ||
52 | frame1, frame1rot, | 51 | frame1, frame1rot, |
53 | frame2, frame2rot, | 52 | frame2, frame2rot, |
54 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | 53 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); |
55 | m_enabled = true; | 54 | m_enabled = true; |
56 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | 55 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", |
57 | BSScene.DetailLogZero, world.worldID, | 56 | BSScene.DetailLogZero, world.worldID, |
58 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 57 | obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); |
59 | } | 58 | } |
60 | 59 | ||
61 | public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2, | 60 | public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2, |
62 | Vector3 joinPoint, | 61 | Vector3 joinPoint, |
63 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 62 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
63 | : base(world) | ||
64 | { | 64 | { |
65 | m_world = world; | ||
66 | m_body1 = obj1; | 65 | m_body1 = obj1; |
67 | m_body2 = obj2; | 66 | m_body2 = obj2; |
68 | if (!obj1.HasPhysicalBody || !obj2.HasPhysicalBody) | 67 | if (!obj1.HasPhysicalBody || !obj2.HasPhysicalBody) |
69 | { | 68 | { |
70 | world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | 69 | world.physicsScene.DetailLog("{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", |
71 | BSScene.DetailLogZero, world.worldID, | 70 | BSScene.DetailLogZero, world.worldID, |
72 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 71 | obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); |
73 | world.physicsScene.Logger.ErrorFormat("{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | 72 | world.physicsScene.Logger.ErrorFormat("{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", |
74 | LogHeader, world.worldID, obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 73 | LogHeader, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); |
75 | m_enabled = false; | 74 | m_enabled = false; |
76 | } | 75 | } |
77 | else | 76 | else |
78 | { | 77 | { |
79 | m_constraint = new BulletConstraint( | 78 | m_constraint = PhysicsScene.PE.Create6DofConstraintToPoint(m_world, m_body1, m_body2, |
80 | BulletSimAPI.Create6DofConstraintToPoint2(m_world.ptr, m_body1.ptr, m_body2.ptr, | ||
81 | joinPoint, | 79 | joinPoint, |
82 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | 80 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); |
83 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}", | 81 | PhysicsScene.DetailLog("{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}", |
84 | BSScene.DetailLogZero, world.worldID, m_constraint.ptr.ToString("X"), | 82 | BSScene.DetailLogZero, world.worldID, m_constraint.AddrString, |
85 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 83 | obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); |
86 | if (!m_constraint.HasPhysicalConstraint) | 84 | if (!m_constraint.HasPhysicalConstraint) |
87 | { | 85 | { |
88 | world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}", | 86 | world.physicsScene.Logger.ErrorFormat("{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}", |
@@ -101,7 +99,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
101 | bool ret = false; | 99 | bool ret = false; |
102 | if (m_enabled) | 100 | if (m_enabled) |
103 | { | 101 | { |
104 | BulletSimAPI.SetFrames2(m_constraint.ptr, frameA, frameArot, frameB, frameBrot); | 102 | PhysicsScene.PE.SetFrames(m_constraint, frameA, frameArot, frameB, frameBrot); |
105 | ret = true; | 103 | ret = true; |
106 | } | 104 | } |
107 | return ret; | 105 | return ret; |
@@ -112,9 +110,9 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
112 | bool ret = false; | 110 | bool ret = false; |
113 | if (m_enabled) | 111 | if (m_enabled) |
114 | { | 112 | { |
115 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | 113 | PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); |
116 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); | 114 | PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); |
117 | BulletSimAPI.SetConstraintParam2(m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); | 115 | PhysicsScene.PE.SetConstraintParam(m_constraint, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); |
118 | ret = true; | 116 | ret = true; |
119 | } | 117 | } |
120 | return ret; | 118 | return ret; |
@@ -125,7 +123,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
125 | bool ret = false; | 123 | bool ret = false; |
126 | float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | 124 | float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; |
127 | if (m_enabled) | 125 | if (m_enabled) |
128 | ret = BulletSimAPI.UseFrameOffset2(m_constraint.ptr, onOff); | 126 | ret = PhysicsScene.PE.UseFrameOffset(m_constraint, onOff); |
129 | return ret; | 127 | return ret; |
130 | } | 128 | } |
131 | 129 | ||
@@ -135,7 +133,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
135 | float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | 133 | float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; |
136 | if (m_enabled) | 134 | if (m_enabled) |
137 | { | 135 | { |
138 | ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.ptr, onOff, targetVelocity, maxMotorForce); | 136 | ret = PhysicsScene.PE.TranslationalLimitMotor(m_constraint, onOff, targetVelocity, maxMotorForce); |
139 | m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}", | 137 | m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}", |
140 | BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce); | 138 | BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce); |
141 | } | 139 | } |
@@ -146,7 +144,7 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
146 | { | 144 | { |
147 | bool ret = false; | 145 | bool ret = false; |
148 | if (m_enabled) | 146 | if (m_enabled) |
149 | ret = BulletSimAPI.SetBreakingImpulseThreshold2(m_constraint.ptr, threshold); | 147 | ret = PhysicsScene.PE.SetBreakingImpulseThreshold(m_constraint, threshold); |
150 | return ret; | 148 | return ret; |
151 | } | 149 | } |
152 | } | 150 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintHinge.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintHinge.cs index a5378b9..7714a03 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintHinge.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintHinge.cs | |||
@@ -40,15 +40,13 @@ public sealed class BSConstraintHinge : BSConstraint | |||
40 | Vector3 pivotInA, Vector3 pivotInB, | 40 | Vector3 pivotInA, Vector3 pivotInB, |
41 | Vector3 axisInA, Vector3 axisInB, | 41 | Vector3 axisInA, Vector3 axisInB, |
42 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 42 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
43 | : base(world) | ||
43 | { | 44 | { |
44 | m_world = world; | ||
45 | m_body1 = obj1; | 45 | m_body1 = obj1; |
46 | m_body2 = obj2; | 46 | m_body2 = obj2; |
47 | m_constraint = new BulletConstraint( | 47 | m_constraint = PhysicsScene.PE.CreateHingeConstraint(world, obj1, obj2, |
48 | BulletSimAPI.CreateHingeConstraint2(m_world.ptr, m_body1.ptr, m_body2.ptr, | 48 | pivotInA, pivotInB, axisInA, axisInB, |
49 | pivotInA, pivotInB, | 49 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); |
50 | axisInA, axisInB, | ||
51 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | ||
52 | m_enabled = true; | 50 | m_enabled = true; |
53 | } | 51 | } |
54 | 52 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 0bdfbe3..13c2539 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -558,30 +558,30 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
558 | 558 | ||
559 | // Friction affects are handled by this vehicle code | 559 | // Friction affects are handled by this vehicle code |
560 | float friction = 0f; | 560 | float friction = 0f; |
561 | BulletSimAPI.SetFriction2(Prim.PhysBody.ptr, friction); | 561 | PhysicsScene.PE.SetFriction(Prim.PhysBody, friction); |
562 | 562 | ||
563 | // Moderate angular movement introduced by Bullet. | 563 | // Moderate angular movement introduced by Bullet. |
564 | // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. | 564 | // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. |
565 | // Maybe compute linear and angular factor and damping from params. | 565 | // Maybe compute linear and angular factor and damping from params. |
566 | float angularDamping = BSParam.VehicleAngularDamping; | 566 | float angularDamping = BSParam.VehicleAngularDamping; |
567 | BulletSimAPI.SetAngularDamping2(Prim.PhysBody.ptr, angularDamping); | 567 | PhysicsScene.PE.SetAngularDamping(Prim.PhysBody, angularDamping); |
568 | 568 | ||
569 | // Vehicles report collision events so we know when it's on the ground | 569 | // Vehicles report collision events so we know when it's on the ground |
570 | BulletSimAPI.AddToCollisionFlags2(Prim.PhysBody.ptr, CollisionFlags.BS_VEHICLE_COLLISIONS); | 570 | PhysicsScene.PE.AddToCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); |
571 | 571 | ||
572 | Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(Prim.PhysShape.ptr, m_vehicleMass); | 572 | Vector3 localInertia = PhysicsScene.PE.CalculateLocalInertia(Prim.PhysShape, m_vehicleMass); |
573 | BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia); | 573 | PhysicsScene.PE.SetMassProps(Prim.PhysBody, m_vehicleMass, localInertia); |
574 | BulletSimAPI.UpdateInertiaTensor2(Prim.PhysBody.ptr); | 574 | PhysicsScene.PE.UpdateInertiaTensor(Prim.PhysBody); |
575 | 575 | ||
576 | Vector3 grav = PhysicsScene.DefaultGravity * (1f - Prim.Buoyancy); | 576 | Vector3 grav = PhysicsScene.DefaultGravity * (1f - Prim.Buoyancy); |
577 | BulletSimAPI.SetGravity2(Prim.PhysBody.ptr, grav); | 577 | PhysicsScene.PE.SetGravity(Prim.PhysBody, grav); |
578 | 578 | ||
579 | VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4}", | 579 | VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4}", |
580 | Prim.LocalID, m_vehicleMass, friction, localInertia, angularDamping); | 580 | Prim.LocalID, m_vehicleMass, friction, localInertia, angularDamping); |
581 | } | 581 | } |
582 | else | 582 | else |
583 | { | 583 | { |
584 | BulletSimAPI.RemoveFromCollisionFlags2(Prim.PhysBody.ptr, CollisionFlags.BS_VEHICLE_COLLISIONS); | 584 | PhysicsScene.PE.RemoveFromCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); |
585 | } | 585 | } |
586 | } | 586 | } |
587 | 587 | ||
@@ -651,7 +651,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
651 | if ((m_knownChanged & m_knownChangedVelocity) != 0) | 651 | if ((m_knownChanged & m_knownChangedVelocity) != 0) |
652 | { | 652 | { |
653 | Prim.ForceVelocity = m_knownVelocity; | 653 | Prim.ForceVelocity = m_knownVelocity; |
654 | BulletSimAPI.SetInterpolationLinearVelocity2(Prim.PhysBody.ptr, VehicleVelocity); | 654 | PhysicsScene.PE.SetInterpolationLinearVelocity(Prim.PhysBody, VehicleVelocity); |
655 | } | 655 | } |
656 | 656 | ||
657 | if ((m_knownChanged & m_knownChangedForce) != 0) | 657 | if ((m_knownChanged & m_knownChangedForce) != 0) |
@@ -661,7 +661,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
661 | { | 661 | { |
662 | Prim.ForceRotationalVelocity = m_knownRotationalVelocity; | 662 | Prim.ForceRotationalVelocity = m_knownRotationalVelocity; |
663 | // Fake out Bullet by making it think the velocity is the same as last time. | 663 | // Fake out Bullet by making it think the velocity is the same as last time. |
664 | BulletSimAPI.SetInterpolationAngularVelocity2(Prim.PhysBody.ptr, m_knownRotationalVelocity); | 664 | PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity); |
665 | } | 665 | } |
666 | 666 | ||
667 | if ((m_knownChanged & m_knownChangedRotationalForce) != 0) | 667 | if ((m_knownChanged & m_knownChangedRotationalForce) != 0) |
@@ -669,7 +669,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
669 | 669 | ||
670 | // If we set one of the values (ie, the physics engine didn't do it) we must force | 670 | // If we set one of the values (ie, the physics engine didn't do it) we must force |
671 | // an UpdateProperties event to send the changes up to the simulator. | 671 | // an UpdateProperties event to send the changes up to the simulator. |
672 | BulletSimAPI.PushUpdate2(Prim.PhysBody.ptr); | 672 | PhysicsScene.PE.PushUpdate(Prim.PhysBody); |
673 | } | 673 | } |
674 | m_knownChanged = 0; | 674 | m_knownChanged = 0; |
675 | } | 675 | } |
@@ -823,7 +823,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
823 | if (!IsActive) return; | 823 | if (!IsActive) return; |
824 | 824 | ||
825 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) | 825 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) |
826 | BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, Prim.PhysBody.ptr); | 826 | PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody); |
827 | 827 | ||
828 | ForgetKnownVehicleProperties(); | 828 | ForgetKnownVehicleProperties(); |
829 | 829 | ||
@@ -840,7 +840,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
840 | PushKnownChanged(); | 840 | PushKnownChanged(); |
841 | 841 | ||
842 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) | 842 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) |
843 | BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, Prim.PhysBody.ptr); | 843 | PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody); |
844 | 844 | ||
845 | VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", | 845 | VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", |
846 | Prim.LocalID, VehiclePosition, Prim.Force, VehicleVelocity, VehicleRotationalVelocity); | 846 | Prim.LocalID, VehiclePosition, Prim.Force, VehicleVelocity, VehicleRotationalVelocity); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 19ce62b..bd03d31 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | |||
@@ -131,10 +131,10 @@ public sealed class BSLinksetCompound : BSLinkset | |||
131 | { | 131 | { |
132 | // The origional prims are removed from the world as the shape of the root compound | 132 | // The origional prims are removed from the world as the shape of the root compound |
133 | // shape takes over. | 133 | // shape takes over. |
134 | BulletSimAPI.AddToCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 134 | PhysicsScene.PE.AddToCollisionFlags(child.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
135 | BulletSimAPI.ForceActivationState2(child.PhysBody.ptr, ActivationState.DISABLE_SIMULATION); | 135 | PhysicsScene.PE.ForceActivationState(child.PhysBody, ActivationState.DISABLE_SIMULATION); |
136 | // We don't want collisions from the old linkset children. | 136 | // We don't want collisions from the old linkset children. |
137 | BulletSimAPI.RemoveFromCollisionFlags2(child.PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 137 | PhysicsScene.PE.RemoveFromCollisionFlags(child.PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
138 | 138 | ||
139 | child.PhysBody.collisionType = CollisionType.LinksetChild; | 139 | child.PhysBody.collisionType = CollisionType.LinksetChild; |
140 | 140 | ||
@@ -159,12 +159,12 @@ public sealed class BSLinksetCompound : BSLinkset | |||
159 | else | 159 | else |
160 | { | 160 | { |
161 | // The non-physical children can come back to life. | 161 | // The non-physical children can come back to life. |
162 | BulletSimAPI.RemoveFromCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 162 | PhysicsScene.PE.RemoveFromCollisionFlags(child.PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
163 | 163 | ||
164 | child.PhysBody.collisionType = CollisionType.LinksetChild; | 164 | child.PhysBody.collisionType = CollisionType.LinksetChild; |
165 | 165 | ||
166 | // Don't force activation so setting of DISABLE_SIMULATION can stay if used. | 166 | // Don't force activation so setting of DISABLE_SIMULATION can stay if used. |
167 | BulletSimAPI.Activate2(child.PhysBody.ptr, false); | 167 | PhysicsScene.PE.Activate(child.PhysBody, false); |
168 | ret = true; | 168 | ret = true; |
169 | } | 169 | } |
170 | return ret; | 170 | return ret; |
@@ -196,7 +196,7 @@ public sealed class BSLinksetCompound : BSLinkset | |||
196 | bool ret = false; | 196 | bool ret = false; |
197 | 197 | ||
198 | DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}", | 198 | DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}", |
199 | child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), IsRoot(child)); | 199 | child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, IsRoot(child)); |
200 | 200 | ||
201 | if (!IsRoot(child)) | 201 | if (!IsRoot(child)) |
202 | { | 202 | { |
@@ -280,8 +280,8 @@ public sealed class BSLinksetCompound : BSLinkset | |||
280 | { | 280 | { |
281 | DetailLog("{0},BSLinksetCompound.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}", | 281 | DetailLog("{0},BSLinksetCompound.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}", |
282 | child.LocalID, | 282 | child.LocalID, |
283 | LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), | 283 | LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, |
284 | child.LocalID, child.PhysBody.ptr.ToString("X")); | 284 | child.LocalID, child.PhysBody.AddrString); |
285 | 285 | ||
286 | // Cause the child's body to be rebuilt and thus restored to normal operation | 286 | // Cause the child's body to be rebuilt and thus restored to normal operation |
287 | RecomputeChildWorldPosition(child, false); | 287 | RecomputeChildWorldPosition(child, false); |
@@ -359,7 +359,7 @@ public sealed class BSLinksetCompound : BSLinkset | |||
359 | PhysicsScene.Shapes.CreateGeomMeshOrHull(cPrim, null); | 359 | PhysicsScene.Shapes.CreateGeomMeshOrHull(cPrim, null); |
360 | BulletShape newShape = cPrim.PhysShape; | 360 | BulletShape newShape = cPrim.PhysShape; |
361 | cPrim.PhysShape = saveShape; | 361 | cPrim.PhysShape = saveShape; |
362 | BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, newShape.ptr, lci.OffsetPos, lci.OffsetRot); | 362 | PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, newShape, lci.OffsetPos, lci.OffsetRot); |
363 | } | 363 | } |
364 | else | 364 | else |
365 | { | 365 | { |
@@ -371,7 +371,7 @@ public sealed class BSLinksetCompound : BSLinkset | |||
371 | PhysicsScene.Logger.ErrorFormat("{0} Rebuilt sharable shape when building linkset! Region={1}, primID={2}, shape={3}", | 371 | PhysicsScene.Logger.ErrorFormat("{0} Rebuilt sharable shape when building linkset! Region={1}, primID={2}, shape={3}", |
372 | LogHeader, PhysicsScene.RegionName, cPrim.LocalID, cPrim.PhysShape); | 372 | LogHeader, PhysicsScene.RegionName, cPrim.LocalID, cPrim.PhysShape); |
373 | } | 373 | } |
374 | BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, cPrim.PhysShape.ptr, lci.OffsetPos, lci.OffsetRot); | 374 | PhysicsScene.PE.AddChildShapeToCompoundShape(LinksetRoot.PhysShape, cPrim.PhysShape, lci.OffsetPos, lci.OffsetRot); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | return false; // 'false' says to move onto the next child in the list | 377 | return false; // 'false' says to move onto the next child in the list |
@@ -386,12 +386,7 @@ public sealed class BSLinksetCompound : BSLinkset | |||
386 | Rebuilding = false; | 386 | Rebuilding = false; |
387 | } | 387 | } |
388 | 388 | ||
389 | BulletSimAPI.RecalculateCompoundShapeLocalAabb2(LinksetRoot.PhysShape.ptr); | 389 | PhysicsScene.PE.RecalculateCompoundShapeLocalAabb(LinksetRoot.PhysShape); |
390 | |||
391 | // DEBUG: see of inter-linkset collisions are causing problems for constraint linksets. | ||
392 | // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr, | ||
393 | // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask); | ||
394 | |||
395 | } | 390 | } |
396 | } | 391 | } |
397 | } \ No newline at end of file | 392 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index 6b592e7..d0b2a56 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | |||
@@ -48,12 +48,15 @@ public sealed class BSLinksetConstraints : BSLinkset | |||
48 | { | 48 | { |
49 | base.Refresh(requestor); | 49 | base.Refresh(requestor); |
50 | 50 | ||
51 | // Queue to happen after all the other taint processing | 51 | if (HasAnyChildren && IsRoot(requestor)) |
52 | PhysicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() | 52 | { |
53 | { | 53 | // Queue to happen after all the other taint processing |
54 | if (HasAnyChildren && IsRoot(requestor)) | 54 | PhysicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() |
55 | RecomputeLinksetConstraints(); | 55 | { |
56 | }); | 56 | if (HasAnyChildren && IsRoot(requestor)) |
57 | RecomputeLinksetConstraints(); | ||
58 | }); | ||
59 | } | ||
57 | } | 60 | } |
58 | 61 | ||
59 | // The object is going dynamic (physical). Do any setup necessary | 62 | // The object is going dynamic (physical). Do any setup necessary |
@@ -95,7 +98,7 @@ public sealed class BSLinksetConstraints : BSLinkset | |||
95 | bool ret = false; | 98 | bool ret = false; |
96 | 99 | ||
97 | DetailLog("{0},BSLinksetConstraint.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2}", | 100 | DetailLog("{0},BSLinksetConstraint.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2}", |
98 | child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X")); | 101 | child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString); |
99 | 102 | ||
100 | lock (m_linksetActivityLock) | 103 | lock (m_linksetActivityLock) |
101 | { | 104 | { |
@@ -144,8 +147,8 @@ public sealed class BSLinksetConstraints : BSLinkset | |||
144 | 147 | ||
145 | DetailLog("{0},BSLinksetConstraints.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}", | 148 | DetailLog("{0},BSLinksetConstraints.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}", |
146 | childx.LocalID, | 149 | childx.LocalID, |
147 | rootx.LocalID, rootx.PhysBody.ptr.ToString("X"), | 150 | rootx.LocalID, rootx.PhysBody.AddrString, |
148 | childx.LocalID, childx.PhysBody.ptr.ToString("X")); | 151 | childx.LocalID, childx.PhysBody.AddrString); |
149 | 152 | ||
150 | PhysicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate() | 153 | PhysicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate() |
151 | { | 154 | { |
@@ -184,8 +187,8 @@ public sealed class BSLinksetConstraints : BSLinkset | |||
184 | 187 | ||
185 | DetailLog("{0},BSLinksetConstraint.BuildConstraint,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", | 188 | DetailLog("{0},BSLinksetConstraint.BuildConstraint,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", |
186 | rootPrim.LocalID, | 189 | rootPrim.LocalID, |
187 | rootPrim.LocalID, rootPrim.PhysBody.ptr.ToString("X"), | 190 | rootPrim.LocalID, rootPrim.PhysBody.AddrString, |
188 | childPrim.LocalID, childPrim.PhysBody.ptr.ToString("X"), | 191 | childPrim.LocalID, childPrim.PhysBody.AddrString, |
189 | rootPrim.Position, childPrim.Position, midPoint); | 192 | rootPrim.Position, childPrim.Position, midPoint); |
190 | 193 | ||
191 | // create a constraint that allows no freedom of movement between the two objects | 194 | // create a constraint that allows no freedom of movement between the two objects |
@@ -249,14 +252,14 @@ public sealed class BSLinksetConstraints : BSLinkset | |||
249 | bool ret = false; | 252 | bool ret = false; |
250 | DetailLog("{0},BSLinksetConstraint.PhysicallyUnlinkAChildFromRoot,taint,root={1},rBody={2},child={3},cBody={4}", | 253 | DetailLog("{0},BSLinksetConstraint.PhysicallyUnlinkAChildFromRoot,taint,root={1},rBody={2},child={3},cBody={4}", |
251 | rootPrim.LocalID, | 254 | rootPrim.LocalID, |
252 | rootPrim.LocalID, rootPrim.PhysBody.ptr.ToString("X"), | 255 | rootPrim.LocalID, rootPrim.PhysBody.AddrString, |
253 | childPrim.LocalID, childPrim.PhysBody.ptr.ToString("X")); | 256 | childPrim.LocalID, childPrim.PhysBody.AddrString); |
254 | 257 | ||
255 | // Find the constraint for this link and get rid of it from the overall collection and from my list | 258 | // Find the constraint for this link and get rid of it from the overall collection and from my list |
256 | if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) | 259 | if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) |
257 | { | 260 | { |
258 | // Make the child refresh its location | 261 | // Make the child refresh its location |
259 | BulletSimAPI.PushUpdate2(childPrim.PhysBody.ptr); | 262 | PhysicsScene.PE.PushUpdate(childPrim.PhysBody); |
260 | ret = true; | 263 | ret = true; |
261 | } | 264 | } |
262 | 265 | ||
@@ -283,11 +286,8 @@ public sealed class BSLinksetConstraints : BSLinkset | |||
283 | float linksetMass = LinksetMass; | 286 | float linksetMass = LinksetMass; |
284 | LinksetRoot.UpdatePhysicalMassProperties(linksetMass, true); | 287 | LinksetRoot.UpdatePhysicalMassProperties(linksetMass, true); |
285 | 288 | ||
286 | // DEBUG: see of inter-linkset collisions are causing problems | ||
287 | // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr, | ||
288 | // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask); | ||
289 | DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", | 289 | DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", |
290 | LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), linksetMass); | 290 | LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass); |
291 | 291 | ||
292 | foreach (BSPhysObject child in m_children) | 292 | foreach (BSPhysObject child in m_children) |
293 | { | 293 | { |
@@ -304,11 +304,7 @@ public sealed class BSLinksetConstraints : BSLinkset | |||
304 | } | 304 | } |
305 | constrain.RecomputeConstraintVariables(linksetMass); | 305 | constrain.RecomputeConstraintVariables(linksetMass); |
306 | 306 | ||
307 | // DEBUG: see of inter-linkset collisions are causing problems | 307 | // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG |
308 | // BulletSimAPI.SetCollisionFilterMask2(child.BSBody.ptr, | ||
309 | // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask); | ||
310 | |||
311 | // BulletSimAPI.DumpConstraint2(PhysicsScene.World.ptr, constrain.Constraint.ptr); // DEBUG DEBUG | ||
312 | } | 308 | } |
313 | 309 | ||
314 | } | 310 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 5c8553a..339722e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | |||
@@ -280,7 +280,7 @@ public static class BSParam | |||
280 | (s,cf,p,v) => { s.UnmanagedParams[0].gravity = cf.GetFloat(p, v); }, | 280 | (s,cf,p,v) => { s.UnmanagedParams[0].gravity = cf.GetFloat(p, v); }, |
281 | (s) => { return s.UnmanagedParams[0].gravity; }, | 281 | (s) => { return s.UnmanagedParams[0].gravity; }, |
282 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{s.UnmanagedParams[0].gravity=x;}, p, PhysParameterEntry.APPLY_TO_NONE, v); }, | 282 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{s.UnmanagedParams[0].gravity=x;}, p, PhysParameterEntry.APPLY_TO_NONE, v); }, |
283 | (s,o,v) => { BulletSimAPI.SetGravity2(s.World.ptr, new Vector3(0f,0f,v)); } ), | 283 | (s,o,v) => { s.PE.SetGravity(o.PhysBody, new Vector3(0f,0f,v)); } ), |
284 | 284 | ||
285 | 285 | ||
286 | new ParameterDefn("LinearDamping", "Factor to damp linear movement per second (0.0 - 1.0)", | 286 | new ParameterDefn("LinearDamping", "Factor to damp linear movement per second (0.0 - 1.0)", |
@@ -288,49 +288,49 @@ public static class BSParam | |||
288 | (s,cf,p,v) => { LinearDamping = cf.GetFloat(p, v); }, | 288 | (s,cf,p,v) => { LinearDamping = cf.GetFloat(p, v); }, |
289 | (s) => { return LinearDamping; }, | 289 | (s) => { return LinearDamping; }, |
290 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearDamping=x;}, p, l, v); }, | 290 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearDamping=x;}, p, l, v); }, |
291 | (s,o,v) => { BulletSimAPI.SetDamping2(o.PhysBody.ptr, v, AngularDamping); } ), | 291 | (s,o,v) => { s.PE.SetDamping(o.PhysBody, v, AngularDamping); } ), |
292 | new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)", | 292 | new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)", |
293 | 0f, | 293 | 0f, |
294 | (s,cf,p,v) => { AngularDamping = cf.GetFloat(p, v); }, | 294 | (s,cf,p,v) => { AngularDamping = cf.GetFloat(p, v); }, |
295 | (s) => { return AngularDamping; }, | 295 | (s) => { return AngularDamping; }, |
296 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularDamping=x;}, p, l, v); }, | 296 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularDamping=x;}, p, l, v); }, |
297 | (s,o,v) => { BulletSimAPI.SetDamping2(o.PhysBody.ptr, LinearDamping, v); } ), | 297 | (s,o,v) => { s.PE.SetDamping(o.PhysBody, LinearDamping, v); } ), |
298 | new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static", | 298 | new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static", |
299 | 0.2f, | 299 | 0.2f, |
300 | (s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); }, | 300 | (s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); }, |
301 | (s) => { return DeactivationTime; }, | 301 | (s) => { return DeactivationTime; }, |
302 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{DeactivationTime=x;}, p, l, v); }, | 302 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{DeactivationTime=x;}, p, l, v); }, |
303 | (s,o,v) => { BulletSimAPI.SetDeactivationTime2(o.PhysBody.ptr, v); } ), | 303 | (s,o,v) => { s.PE.SetDeactivationTime(o.PhysBody, v); } ), |
304 | new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static", | 304 | new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static", |
305 | 0.8f, | 305 | 0.8f, |
306 | (s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); }, | 306 | (s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); }, |
307 | (s) => { return LinearSleepingThreshold; }, | 307 | (s) => { return LinearSleepingThreshold; }, |
308 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearSleepingThreshold=x;}, p, l, v); }, | 308 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearSleepingThreshold=x;}, p, l, v); }, |
309 | (s,o,v) => { BulletSimAPI.SetSleepingThresholds2(o.PhysBody.ptr, v, v); } ), | 309 | (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ), |
310 | new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static", | 310 | new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static", |
311 | 1.0f, | 311 | 1.0f, |
312 | (s,cf,p,v) => { AngularSleepingThreshold = cf.GetFloat(p, v); }, | 312 | (s,cf,p,v) => { AngularSleepingThreshold = cf.GetFloat(p, v); }, |
313 | (s) => { return AngularSleepingThreshold; }, | 313 | (s) => { return AngularSleepingThreshold; }, |
314 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); }, | 314 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); }, |
315 | (s,o,v) => { BulletSimAPI.SetSleepingThresholds2(o.PhysBody.ptr, v, v); } ), | 315 | (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ), |
316 | new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , | 316 | new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , |
317 | 0f, // set to zero to disable | 317 | 0f, // set to zero to disable |
318 | (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); }, | 318 | (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); }, |
319 | (s) => { return CcdMotionThreshold; }, | 319 | (s) => { return CcdMotionThreshold; }, |
320 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); }, | 320 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); }, |
321 | (s,o,v) => { BulletSimAPI.SetCcdMotionThreshold2(o.PhysBody.ptr, v); } ), | 321 | (s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ), |
322 | new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" , | 322 | new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" , |
323 | 0f, | 323 | 0f, |
324 | (s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); }, | 324 | (s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); }, |
325 | (s) => { return CcdSweptSphereRadius; }, | 325 | (s) => { return CcdSweptSphereRadius; }, |
326 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); }, | 326 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); }, |
327 | (s,o,v) => { BulletSimAPI.SetCcdSweptSphereRadius2(o.PhysBody.ptr, v); } ), | 327 | (s,o,v) => { s.PE.SetCcdSweptSphereRadius(o.PhysBody, v); } ), |
328 | new ParameterDefn("ContactProcessingThreshold", "Distance between contacts before doing collision check" , | 328 | new ParameterDefn("ContactProcessingThreshold", "Distance between contacts before doing collision check" , |
329 | 0.1f, | 329 | 0.1f, |
330 | (s,cf,p,v) => { ContactProcessingThreshold = cf.GetFloat(p, v); }, | 330 | (s,cf,p,v) => { ContactProcessingThreshold = cf.GetFloat(p, v); }, |
331 | (s) => { return ContactProcessingThreshold; }, | 331 | (s) => { return ContactProcessingThreshold; }, |
332 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{ContactProcessingThreshold=x;}, p, l, v); }, | 332 | (s,p,l,v) => { s.UpdateParameterObject((x)=>{ContactProcessingThreshold=x;}, p, l, v); }, |
333 | (s,o,v) => { BulletSimAPI.SetContactProcessingThreshold2(o.PhysBody.ptr, v); } ), | 333 | (s,o,v) => { s.PE.SetContactProcessingThreshold(o.PhysBody, v); } ), |
334 | 334 | ||
335 | new ParameterDefn("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)", | 335 | new ParameterDefn("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)", |
336 | (float)BSTerrainPhys.TerrainImplementation.Mesh, | 336 | (float)BSTerrainPhys.TerrainImplementation.Mesh, |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 73b5764..e7cb3e0 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -67,6 +67,11 @@ public abstract class BSPhysObject : PhysicsActor | |||
67 | PhysObjectName = name; | 67 | PhysObjectName = name; |
68 | TypeName = typeName; | 68 | TypeName = typeName; |
69 | 69 | ||
70 | // We don't have any physical representation yet. | ||
71 | PhysBody = new BulletBody(localID); | ||
72 | PhysShape = new BulletShape(); | ||
73 | |||
74 | // A linkset of just me | ||
70 | Linkset = BSLinkset.Factory(PhysicsScene, this); | 75 | Linkset = BSLinkset.Factory(PhysicsScene, this); |
71 | LastAssetBuildFailed = false; | 76 | LastAssetBuildFailed = false; |
72 | 77 | ||
@@ -303,7 +308,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
303 | PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate() | 308 | PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate() |
304 | { | 309 | { |
305 | if (PhysBody.HasPhysicalBody) | 310 | if (PhysBody.HasPhysicalBody) |
306 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 311 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
307 | }); | 312 | }); |
308 | } | 313 | } |
309 | else | 314 | else |
@@ -319,7 +324,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
319 | { | 324 | { |
320 | // Make sure there is a body there because sometimes destruction happens in an un-ideal order. | 325 | // Make sure there is a body there because sometimes destruction happens in an un-ideal order. |
321 | if (PhysBody.HasPhysicalBody) | 326 | if (PhysBody.HasPhysicalBody) |
322 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 327 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
323 | }); | 328 | }); |
324 | } | 329 | } |
325 | // Return 'true' if the simulator wants collision events | 330 | // Return 'true' if the simulator wants collision events |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 5f3f0d1..064ce3c 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -111,10 +111,7 @@ public sealed class BSPrim : BSPhysObject | |||
111 | 111 | ||
112 | _mass = CalculateMass(); | 112 | _mass = CalculateMass(); |
113 | 113 | ||
114 | // No body or shape yet | 114 | // Cause linkset variables to be initialized (like mass) |
115 | PhysBody = new BulletBody(LocalID); | ||
116 | PhysShape = new BulletShape(); | ||
117 | |||
118 | Linkset.Refresh(this); | 115 | Linkset.Refresh(this); |
119 | 116 | ||
120 | DetailLog("{0},BSPrim.constructor,call", LocalID); | 117 | DetailLog("{0},BSPrim.constructor,call", LocalID); |
@@ -123,7 +120,7 @@ public sealed class BSPrim : BSPhysObject | |||
123 | { | 120 | { |
124 | CreateGeomAndObject(true); | 121 | CreateGeomAndObject(true); |
125 | 122 | ||
126 | CurrentCollisionFlags = BulletSimAPI.GetCollisionFlags2(PhysBody.ptr); | 123 | CurrentCollisionFlags = PhysicsScene.PE.GetCollisionFlags(PhysBody); |
127 | }); | 124 | }); |
128 | } | 125 | } |
129 | 126 | ||
@@ -256,7 +253,7 @@ public sealed class BSPrim : BSPhysObject | |||
256 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() | 253 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() |
257 | { | 254 | { |
258 | if (PhysBody.HasPhysicalBody) | 255 | if (PhysBody.HasPhysicalBody) |
259 | BulletSimAPI.ClearAllForces2(PhysBody.ptr); | 256 | PhysicsScene.PE.ClearAllForces(PhysBody); |
260 | }); | 257 | }); |
261 | } | 258 | } |
262 | public override void ZeroAngularMotion(bool inTaintTime) | 259 | public override void ZeroAngularMotion(bool inTaintTime) |
@@ -268,8 +265,8 @@ public sealed class BSPrim : BSPhysObject | |||
268 | // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); | 265 | // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); |
269 | if (PhysBody.HasPhysicalBody) | 266 | if (PhysBody.HasPhysicalBody) |
270 | { | 267 | { |
271 | BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, _rotationalVelocity); | 268 | PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); |
272 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); | 269 | PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); |
273 | } | 270 | } |
274 | }); | 271 | }); |
275 | } | 272 | } |
@@ -295,7 +292,7 @@ public sealed class BSPrim : BSPhysObject | |||
295 | */ | 292 | */ |
296 | 293 | ||
297 | // don't do the GetObjectPosition for root elements because this function is called a zillion times. | 294 | // don't do the GetObjectPosition for root elements because this function is called a zillion times. |
298 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); | 295 | // _position = PhysicsScene.PE.GetObjectPosition2(PhysicsScene.World, BSBody); |
299 | return _position; | 296 | return _position; |
300 | } | 297 | } |
301 | set { | 298 | set { |
@@ -321,14 +318,14 @@ public sealed class BSPrim : BSPhysObject | |||
321 | } | 318 | } |
322 | public override OMV.Vector3 ForcePosition { | 319 | public override OMV.Vector3 ForcePosition { |
323 | get { | 320 | get { |
324 | _position = BulletSimAPI.GetPosition2(PhysBody.ptr); | 321 | _position = PhysicsScene.PE.GetPosition(PhysBody); |
325 | return _position; | 322 | return _position; |
326 | } | 323 | } |
327 | set { | 324 | set { |
328 | _position = value; | 325 | _position = value; |
329 | if (PhysBody.HasPhysicalBody) | 326 | if (PhysBody.HasPhysicalBody) |
330 | { | 327 | { |
331 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 328 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
332 | ActivateIfPhysical(false); | 329 | ActivateIfPhysical(false); |
333 | } | 330 | } |
334 | } | 331 | } |
@@ -408,10 +405,10 @@ public sealed class BSPrim : BSPhysObject | |||
408 | { | 405 | { |
409 | if (IsStatic) | 406 | if (IsStatic) |
410 | { | 407 | { |
411 | BulletSimAPI.SetGravity2(PhysBody.ptr, PhysicsScene.DefaultGravity); | 408 | PhysicsScene.PE.SetGravity(PhysBody, PhysicsScene.DefaultGravity); |
412 | Inertia = OMV.Vector3.Zero; | 409 | Inertia = OMV.Vector3.Zero; |
413 | BulletSimAPI.SetMassProps2(PhysBody.ptr, 0f, Inertia); | 410 | PhysicsScene.PE.SetMassProps(PhysBody, 0f, Inertia); |
414 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); | 411 | PhysicsScene.PE.UpdateInertiaTensor(PhysBody); |
415 | } | 412 | } |
416 | else | 413 | else |
417 | { | 414 | { |
@@ -422,18 +419,18 @@ public sealed class BSPrim : BSPhysObject | |||
422 | // Changing interesting properties doesn't change proxy and collision cache | 419 | // Changing interesting properties doesn't change proxy and collision cache |
423 | // information. The Bullet solution is to re-add the object to the world | 420 | // information. The Bullet solution is to re-add the object to the world |
424 | // after parameters are changed. | 421 | // after parameters are changed. |
425 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 422 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); |
426 | } | 423 | } |
427 | 424 | ||
428 | // The computation of mass props requires gravity to be set on the object. | 425 | // The computation of mass props requires gravity to be set on the object. |
429 | BulletSimAPI.SetGravity2(PhysBody.ptr, grav); | 426 | PhysicsScene.PE.SetGravity(PhysBody, grav); |
430 | 427 | ||
431 | Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); | 428 | Inertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape, physMass); |
432 | BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia); | 429 | PhysicsScene.PE.SetMassProps(PhysBody, physMass, Inertia); |
433 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); | 430 | PhysicsScene.PE.UpdateInertiaTensor(PhysBody); |
434 | 431 | ||
435 | // center of mass is at the zero of the object | 432 | // center of mass is at the zero of the object |
436 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation); | 433 | // DEBUG DEBUG PhysicsScene.PE.SetCenterOfMassByPosRot(PhysBody, ForcePosition, ForceOrientation); |
437 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", LocalID, physMass, Inertia, grav, inWorld); | 434 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", LocalID, physMass, Inertia, grav, inWorld); |
438 | 435 | ||
439 | if (inWorld) | 436 | if (inWorld) |
@@ -443,7 +440,7 @@ public sealed class BSPrim : BSPhysObject | |||
443 | 440 | ||
444 | // Must set gravity after it has been added to the world because, for unknown reasons, | 441 | // Must set gravity after it has been added to the world because, for unknown reasons, |
445 | // adding the object resets the object's gravity to world gravity | 442 | // adding the object resets the object's gravity to world gravity |
446 | BulletSimAPI.SetGravity2(PhysBody.ptr, grav); | 443 | PhysicsScene.PE.SetGravity(PhysBody, grav); |
447 | 444 | ||
448 | } | 445 | } |
449 | } | 446 | } |
@@ -486,7 +483,7 @@ public sealed class BSPrim : BSPhysObject | |||
486 | DetailLog("{0},BSPrim.setForce,preStep,force={1}", LocalID, _force); | 483 | DetailLog("{0},BSPrim.setForce,preStep,force={1}", LocalID, _force); |
487 | if (PhysBody.HasPhysicalBody) | 484 | if (PhysBody.HasPhysicalBody) |
488 | { | 485 | { |
489 | BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, _force); | 486 | PhysicsScene.PE.ApplyCentralForce(PhysBody, _force); |
490 | ActivateIfPhysical(false); | 487 | ActivateIfPhysical(false); |
491 | } | 488 | } |
492 | } | 489 | } |
@@ -586,7 +583,7 @@ public sealed class BSPrim : BSPhysObject | |||
586 | _velocity = value; | 583 | _velocity = value; |
587 | if (PhysBody.HasPhysicalBody) | 584 | if (PhysBody.HasPhysicalBody) |
588 | { | 585 | { |
589 | BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); | 586 | PhysicsScene.PE.SetLinearVelocity(PhysBody, _velocity); |
590 | ActivateIfPhysical(false); | 587 | ActivateIfPhysical(false); |
591 | } | 588 | } |
592 | } | 589 | } |
@@ -652,9 +649,9 @@ public sealed class BSPrim : BSPhysObject | |||
652 | { | 649 | { |
653 | if (PhysBody.HasPhysicalBody) | 650 | if (PhysBody.HasPhysicalBody) |
654 | { | 651 | { |
655 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); | 652 | // _position = PhysicsScene.PE.GetObjectPosition(PhysicsScene.World, BSBody); |
656 | // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 653 | // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
657 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 654 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
658 | } | 655 | } |
659 | }); | 656 | }); |
660 | } | 657 | } |
@@ -664,13 +661,13 @@ public sealed class BSPrim : BSPhysObject | |||
664 | { | 661 | { |
665 | get | 662 | get |
666 | { | 663 | { |
667 | _orientation = BulletSimAPI.GetOrientation2(PhysBody.ptr); | 664 | _orientation = PhysicsScene.PE.GetOrientation(PhysBody); |
668 | return _orientation; | 665 | return _orientation; |
669 | } | 666 | } |
670 | set | 667 | set |
671 | { | 668 | { |
672 | _orientation = value; | 669 | _orientation = value; |
673 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 670 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
674 | } | 671 | } |
675 | } | 672 | } |
676 | public override int PhysicsActorType { | 673 | public override int PhysicsActorType { |
@@ -726,7 +723,7 @@ public sealed class BSPrim : BSPhysObject | |||
726 | 723 | ||
727 | // Mangling all the physical properties requires the object not be in the physical world. | 724 | // Mangling all the physical properties requires the object not be in the physical world. |
728 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). | 725 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). |
729 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 726 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); |
730 | 727 | ||
731 | // Set up the object physicalness (does gravity and collisions move this object) | 728 | // Set up the object physicalness (does gravity and collisions move this object) |
732 | MakeDynamic(IsStatic); | 729 | MakeDynamic(IsStatic); |
@@ -743,7 +740,7 @@ public sealed class BSPrim : BSPhysObject | |||
743 | AddObjectToPhysicalWorld(); | 740 | AddObjectToPhysicalWorld(); |
744 | 741 | ||
745 | // Rebuild its shape | 742 | // Rebuild its shape |
746 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); | 743 | PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody); |
747 | 744 | ||
748 | // Recompute any linkset parameters. | 745 | // Recompute any linkset parameters. |
749 | // When going from non-physical to physical, this re-enables the constraints that | 746 | // When going from non-physical to physical, this re-enables the constraints that |
@@ -765,28 +762,28 @@ public sealed class BSPrim : BSPhysObject | |||
765 | if (makeStatic) | 762 | if (makeStatic) |
766 | { | 763 | { |
767 | // Become a Bullet 'static' object type | 764 | // Become a Bullet 'static' object type |
768 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 765 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); |
769 | // Stop all movement | 766 | // Stop all movement |
770 | ZeroMotion(true); | 767 | ZeroMotion(true); |
771 | 768 | ||
772 | // Set various physical properties so other object interact properly | 769 | // Set various physical properties so other object interact properly |
773 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); | 770 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); |
774 | BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction); | 771 | PhysicsScene.PE.SetFriction(PhysBody, matAttrib.friction); |
775 | BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution); | 772 | PhysicsScene.PE.SetRestitution(PhysBody, matAttrib.restitution); |
776 | 773 | ||
777 | // Mass is zero which disables a bunch of physics stuff in Bullet | 774 | // Mass is zero which disables a bunch of physics stuff in Bullet |
778 | UpdatePhysicalMassProperties(0f, false); | 775 | UpdatePhysicalMassProperties(0f, false); |
779 | // Set collision detection parameters | 776 | // Set collision detection parameters |
780 | if (BSParam.CcdMotionThreshold > 0f) | 777 | if (BSParam.CcdMotionThreshold > 0f) |
781 | { | 778 | { |
782 | BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold); | 779 | PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); |
783 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius); | 780 | PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); |
784 | } | 781 | } |
785 | 782 | ||
786 | // The activation state is 'disabled' so Bullet will not try to act on it. | 783 | // The activation state is 'disabled' so Bullet will not try to act on it. |
787 | // BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_SIMULATION); | 784 | // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_SIMULATION); |
788 | // Start it out sleeping and physical actions could wake it up. | 785 | // Start it out sleeping and physical actions could wake it up. |
789 | BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ISLAND_SLEEPING); | 786 | PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ISLAND_SLEEPING); |
790 | 787 | ||
791 | // This collides like a static object | 788 | // This collides like a static object |
792 | PhysBody.collisionType = CollisionType.Static; | 789 | PhysBody.collisionType = CollisionType.Static; |
@@ -797,22 +794,22 @@ public sealed class BSPrim : BSPhysObject | |||
797 | else | 794 | else |
798 | { | 795 | { |
799 | // Not a Bullet static object | 796 | // Not a Bullet static object |
800 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 797 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); |
801 | 798 | ||
802 | // Set various physical properties so other object interact properly | 799 | // Set various physical properties so other object interact properly |
803 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true); | 800 | MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true); |
804 | BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction); | 801 | PhysicsScene.PE.SetFriction(PhysBody, matAttrib.friction); |
805 | BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution); | 802 | PhysicsScene.PE.SetRestitution(PhysBody, matAttrib.restitution); |
806 | 803 | ||
807 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 | 804 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 |
808 | // Since this can be called multiple times, only zero forces when becoming physical | 805 | // Since this can be called multiple times, only zero forces when becoming physical |
809 | // BulletSimAPI.ClearAllForces2(BSBody.ptr); | 806 | // PhysicsScene.PE.ClearAllForces(BSBody); |
810 | 807 | ||
811 | // For good measure, make sure the transform is set through to the motion state | 808 | // For good measure, make sure the transform is set through to the motion state |
812 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); | 809 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); |
813 | 810 | ||
814 | // Center of mass is at the center of the object | 811 | // Center of mass is at the center of the object |
815 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody.ptr, _position, _orientation); | 812 | // DEBUG DEBUG PhysicsScene.PE.SetCenterOfMassByPosRot(Linkset.LinksetRoot.PhysBody, _position, _orientation); |
816 | 813 | ||
817 | // A dynamic object has mass | 814 | // A dynamic object has mass |
818 | UpdatePhysicalMassProperties(RawMass, false); | 815 | UpdatePhysicalMassProperties(RawMass, false); |
@@ -820,22 +817,22 @@ public sealed class BSPrim : BSPhysObject | |||
820 | // Set collision detection parameters | 817 | // Set collision detection parameters |
821 | if (BSParam.CcdMotionThreshold > 0f) | 818 | if (BSParam.CcdMotionThreshold > 0f) |
822 | { | 819 | { |
823 | BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, BSParam.CcdMotionThreshold); | 820 | PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); |
824 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, BSParam.CcdSweptSphereRadius); | 821 | PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); |
825 | } | 822 | } |
826 | 823 | ||
827 | // Various values for simulation limits | 824 | // Various values for simulation limits |
828 | BulletSimAPI.SetDamping2(PhysBody.ptr, BSParam.LinearDamping, BSParam.AngularDamping); | 825 | PhysicsScene.PE.SetDamping(PhysBody, BSParam.LinearDamping, BSParam.AngularDamping); |
829 | BulletSimAPI.SetDeactivationTime2(PhysBody.ptr, BSParam.DeactivationTime); | 826 | PhysicsScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime); |
830 | BulletSimAPI.SetSleepingThresholds2(PhysBody.ptr, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold); | 827 | PhysicsScene.PE.SetSleepingThresholds(PhysBody, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold); |
831 | BulletSimAPI.SetContactProcessingThreshold2(PhysBody.ptr, BSParam.ContactProcessingThreshold); | 828 | PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); |
832 | 829 | ||
833 | // This collides like an object. | 830 | // This collides like an object. |
834 | PhysBody.collisionType = CollisionType.Dynamic; | 831 | PhysBody.collisionType = CollisionType.Dynamic; |
835 | 832 | ||
836 | // Force activation of the object so Bullet will act on it. | 833 | // Force activation of the object so Bullet will act on it. |
837 | // Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects. | 834 | // Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects. |
838 | BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ACTIVE_TAG); | 835 | PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG); |
839 | 836 | ||
840 | // There might be special things needed for implementing linksets. | 837 | // There might be special things needed for implementing linksets. |
841 | Linkset.MakeDynamic(this); | 838 | Linkset.MakeDynamic(this); |
@@ -848,7 +845,7 @@ public sealed class BSPrim : BSPhysObject | |||
848 | // the functions after this one set up the state of a possibly newly created collision body. | 845 | // the functions after this one set up the state of a possibly newly created collision body. |
849 | private void MakeSolid(bool makeSolid) | 846 | private void MakeSolid(bool makeSolid) |
850 | { | 847 | { |
851 | CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(PhysBody.ptr); | 848 | CollisionObjectTypes bodyType = (CollisionObjectTypes)PhysicsScene.PE.GetBodyType(PhysBody); |
852 | if (makeSolid) | 849 | if (makeSolid) |
853 | { | 850 | { |
854 | // Verify the previous code created the correct shape for this type of thing. | 851 | // Verify the previous code created the correct shape for this type of thing. |
@@ -856,7 +853,7 @@ public sealed class BSPrim : BSPhysObject | |||
856 | { | 853 | { |
857 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType); | 854 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType); |
858 | } | 855 | } |
859 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 856 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
860 | } | 857 | } |
861 | else | 858 | else |
862 | { | 859 | { |
@@ -864,7 +861,7 @@ public sealed class BSPrim : BSPhysObject | |||
864 | { | 861 | { |
865 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); | 862 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); |
866 | } | 863 | } |
867 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 864 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
868 | 865 | ||
869 | // Change collision info from a static object to a ghosty collision object | 866 | // Change collision info from a static object to a ghosty collision object |
870 | PhysBody.collisionType = CollisionType.VolumeDetect; | 867 | PhysBody.collisionType = CollisionType.VolumeDetect; |
@@ -877,7 +874,7 @@ public sealed class BSPrim : BSPhysObject | |||
877 | private void ActivateIfPhysical(bool forceIt) | 874 | private void ActivateIfPhysical(bool forceIt) |
878 | { | 875 | { |
879 | if (IsPhysical && PhysBody.HasPhysicalBody) | 876 | if (IsPhysical && PhysBody.HasPhysicalBody) |
880 | BulletSimAPI.Activate2(PhysBody.ptr, forceIt); | 877 | PhysicsScene.PE.Activate(PhysBody, forceIt); |
881 | } | 878 | } |
882 | 879 | ||
883 | // Turn on or off the flag controlling whether collision events are returned to the simulator. | 880 | // Turn on or off the flag controlling whether collision events are returned to the simulator. |
@@ -885,11 +882,11 @@ public sealed class BSPrim : BSPhysObject | |||
885 | { | 882 | { |
886 | if (wantsCollisionEvents) | 883 | if (wantsCollisionEvents) |
887 | { | 884 | { |
888 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 885 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
889 | } | 886 | } |
890 | else | 887 | else |
891 | { | 888 | { |
892 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 889 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
893 | } | 890 | } |
894 | } | 891 | } |
895 | 892 | ||
@@ -900,14 +897,14 @@ public sealed class BSPrim : BSPhysObject | |||
900 | { | 897 | { |
901 | if (PhysBody.HasPhysicalBody) | 898 | if (PhysBody.HasPhysicalBody) |
902 | { | 899 | { |
903 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 900 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody); |
904 | 901 | ||
905 | // TODO: Fix this. Total kludge because adding object to world resets its gravity to default. | 902 | // TODO: Fix this. Total kludge because adding object to world resets its gravity to default. |
906 | // Replace this when the new AddObjectToWorld function is complete. | 903 | // Replace this when the new AddObjectToWorld function is complete. |
907 | BulletSimAPI.SetGravity2(PhysBody.ptr, ComputeGravity()); | 904 | PhysicsScene.PE.SetGravity(PhysBody, ComputeGravity()); |
908 | 905 | ||
909 | // Collision filter can be set only when the object is in the world | 906 | // Collision filter can be set only when the object is in the world |
910 | if (!PhysBody.ApplyCollisionMask()) | 907 | if (!PhysBody.ApplyCollisionMask(PhysicsScene)) |
911 | { | 908 | { |
912 | m_log.ErrorFormat("{0} Failed setting object collision mask: id={1}", LogHeader, LocalID); | 909 | m_log.ErrorFormat("{0} Failed setting object collision mask: id={1}", LogHeader, LocalID); |
913 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,failedSetMaskGroup,cType={1}", LocalID, PhysBody.collisionType); | 910 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,failedSetMaskGroup,cType={1}", LocalID, PhysBody.collisionType); |
@@ -944,9 +941,9 @@ public sealed class BSPrim : BSPhysObject | |||
944 | PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate() | 941 | PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate() |
945 | { | 942 | { |
946 | if (_floatOnWater) | 943 | if (_floatOnWater) |
947 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 944 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); |
948 | else | 945 | else |
949 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 946 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); |
950 | }); | 947 | }); |
951 | } | 948 | } |
952 | } | 949 | } |
@@ -972,7 +969,7 @@ public sealed class BSPrim : BSPhysObject | |||
972 | _rotationalVelocity = value; | 969 | _rotationalVelocity = value; |
973 | if (PhysBody.HasPhysicalBody) | 970 | if (PhysBody.HasPhysicalBody) |
974 | { | 971 | { |
975 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); | 972 | PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); |
976 | ActivateIfPhysical(false); | 973 | ActivateIfPhysical(false); |
977 | } | 974 | } |
978 | } | 975 | } |
@@ -1064,7 +1061,7 @@ public sealed class BSPrim : BSPhysObject | |||
1064 | DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce); | 1061 | DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce); |
1065 | if (PhysBody.HasPhysicalBody) | 1062 | if (PhysBody.HasPhysicalBody) |
1066 | { | 1063 | { |
1067 | BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce); | 1064 | PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce); |
1068 | ActivateIfPhysical(false); | 1065 | ActivateIfPhysical(false); |
1069 | } | 1066 | } |
1070 | }); | 1067 | }); |
@@ -1088,7 +1085,7 @@ public sealed class BSPrim : BSPhysObject | |||
1088 | { | 1085 | { |
1089 | if (PhysBody.HasPhysicalBody) | 1086 | if (PhysBody.HasPhysicalBody) |
1090 | { | 1087 | { |
1091 | BulletSimAPI.ApplyTorque2(PhysBody.ptr, angForce); | 1088 | PhysicsScene.PE.ApplyTorque(PhysBody, angForce); |
1092 | ActivateIfPhysical(false); | 1089 | ActivateIfPhysical(false); |
1093 | } | 1090 | } |
1094 | }); | 1091 | }); |
@@ -1111,7 +1108,7 @@ public sealed class BSPrim : BSPhysObject | |||
1111 | { | 1108 | { |
1112 | if (PhysBody.HasPhysicalBody) | 1109 | if (PhysBody.HasPhysicalBody) |
1113 | { | 1110 | { |
1114 | BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse); | 1111 | PhysicsScene.PE.ApplyTorqueImpulse(PhysBody, applyImpulse); |
1115 | ActivateIfPhysical(false); | 1112 | ActivateIfPhysical(false); |
1116 | } | 1113 | } |
1117 | }); | 1114 | }); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 4133107..258b72f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | ||
29 | using System.Runtime.InteropServices; | 30 | using System.Runtime.InteropServices; |
30 | using System.Text; | 31 | using System.Text; |
31 | using System.Threading; | 32 | using System.Threading; |
@@ -42,14 +43,18 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
42 | { | 43 | { |
43 | public sealed class BSScene : PhysicsScene, IPhysicsParameters | 44 | public sealed class BSScene : PhysicsScene, IPhysicsParameters |
44 | { | 45 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 46 | internal static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
46 | private static readonly string LogHeader = "[BULLETS SCENE]"; | 47 | internal static readonly string LogHeader = "[BULLETS SCENE]"; |
47 | 48 | ||
48 | // The name of the region we're working for. | 49 | // The name of the region we're working for. |
49 | public string RegionName { get; private set; } | 50 | public string RegionName { get; private set; } |
50 | 51 | ||
51 | public string BulletSimVersion = "?"; | 52 | public string BulletSimVersion = "?"; |
52 | 53 | ||
54 | // The handle to the underlying managed or unmanaged version of Bullet being used. | ||
55 | public string BulletEngineName { get; private set; } | ||
56 | public BSAPITemplate PE; | ||
57 | |||
53 | public Dictionary<uint, BSPhysObject> PhysObjects; | 58 | public Dictionary<uint, BSPhysObject> PhysObjects; |
54 | public BSShapeCollection Shapes; | 59 | public BSShapeCollection Shapes; |
55 | 60 | ||
@@ -99,11 +104,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
99 | // Pinned memory used to pass step information between managed and unmanaged | 104 | // Pinned memory used to pass step information between managed and unmanaged |
100 | internal int m_maxCollisionsPerFrame; | 105 | internal int m_maxCollisionsPerFrame; |
101 | internal CollisionDesc[] m_collisionArray; | 106 | internal CollisionDesc[] m_collisionArray; |
102 | internal GCHandle m_collisionArrayPinnedHandle; | ||
103 | 107 | ||
104 | internal int m_maxUpdatesPerFrame; | 108 | internal int m_maxUpdatesPerFrame; |
105 | internal EntityProperties[] m_updateArray; | 109 | internal EntityProperties[] m_updateArray; |
106 | internal GCHandle m_updateArrayPinnedHandle; | ||
107 | 110 | ||
108 | public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero | 111 | public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero |
109 | public const uint GROUNDPLANE_ID = 1; | 112 | public const uint GROUNDPLANE_ID = 1; |
@@ -149,12 +152,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
149 | // A pointer to an instance if this structure is passed to the C++ code | 152 | // A pointer to an instance if this structure is passed to the C++ code |
150 | // Used to pass basic configuration values to the unmanaged code. | 153 | // Used to pass basic configuration values to the unmanaged code. |
151 | internal ConfigurationParameters[] UnmanagedParams; | 154 | internal ConfigurationParameters[] UnmanagedParams; |
152 | GCHandle m_paramsHandle; | ||
153 | |||
154 | // Handle to the callback used by the unmanaged code to call into the managed code. | ||
155 | // Used for debug logging. | ||
156 | // Need to store the handle in a persistant variable so it won't be freed. | ||
157 | private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle; | ||
158 | 155 | ||
159 | // Sometimes you just have to log everything. | 156 | // Sometimes you just have to log everything. |
160 | public Logging.LogWriter PhysicsLogging; | 157 | public Logging.LogWriter PhysicsLogging; |
@@ -187,16 +184,12 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
187 | 184 | ||
188 | // Allocate pinned memory to pass parameters. | 185 | // Allocate pinned memory to pass parameters. |
189 | UnmanagedParams = new ConfigurationParameters[1]; | 186 | UnmanagedParams = new ConfigurationParameters[1]; |
190 | m_paramsHandle = GCHandle.Alloc(UnmanagedParams, GCHandleType.Pinned); | ||
191 | 187 | ||
192 | // Set default values for physics parameters plus any overrides from the ini file | 188 | // Set default values for physics parameters plus any overrides from the ini file |
193 | GetInitialParameterValues(config); | 189 | GetInitialParameterValues(config); |
194 | 190 | ||
195 | // allocate more pinned memory close to the above in an attempt to get the memory all together | 191 | // Get the connection to the physics engine (could be native or one of many DLLs) |
196 | m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame]; | 192 | PE = SelectUnderlyingBulletEngine(BulletEngineName); |
197 | m_collisionArrayPinnedHandle = GCHandle.Alloc(m_collisionArray, GCHandleType.Pinned); | ||
198 | m_updateArray = new EntityProperties[m_maxUpdatesPerFrame]; | ||
199 | m_updateArrayPinnedHandle = GCHandle.Alloc(m_updateArray, GCHandleType.Pinned); | ||
200 | 193 | ||
201 | // Enable very detailed logging. | 194 | // Enable very detailed logging. |
202 | // By creating an empty logger when not logging, the log message invocation code | 195 | // By creating an empty logger when not logging, the log message invocation code |
@@ -211,22 +204,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
211 | PhysicsLogging = new Logging.LogWriter(); | 204 | PhysicsLogging = new Logging.LogWriter(); |
212 | } | 205 | } |
213 | 206 | ||
214 | // If Debug logging level, enable logging from the unmanaged code | 207 | // Allocate memory for returning of the updates and collisions from the physics engine |
215 | m_DebugLogCallbackHandle = null; | 208 | m_collisionArray = new CollisionDesc[m_maxCollisionsPerFrame]; |
216 | if (m_log.IsDebugEnabled || PhysicsLogging.Enabled) | 209 | m_updateArray = new EntityProperties[m_maxUpdatesPerFrame]; |
217 | { | ||
218 | m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader); | ||
219 | if (PhysicsLogging.Enabled) | ||
220 | // The handle is saved in a variable to make sure it doesn't get freed after this call | ||
221 | m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLoggerPhysLog); | ||
222 | else | ||
223 | m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger); | ||
224 | } | ||
225 | |||
226 | // Get the version of the DLL | ||
227 | // TODO: this doesn't work yet. Something wrong with marshaling the returned string. | ||
228 | // BulletSimVersion = BulletSimAPI.GetVersion(); | ||
229 | // m_log.WarnFormat("{0}: BulletSim.dll version='{1}'", LogHeader, BulletSimVersion); | ||
230 | 210 | ||
231 | // The bounding box for the simulated world. The origin is 0,0,0 unless we're | 211 | // The bounding box for the simulated world. The origin is 0,0,0 unless we're |
232 | // a child in a mega-region. | 212 | // a child in a mega-region. |
@@ -234,11 +214,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
234 | // area. It tracks active objects no matter where they are. | 214 | // area. It tracks active objects no matter where they are. |
235 | Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); | 215 | Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); |
236 | 216 | ||
237 | // m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader); | 217 | World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray, m_maxUpdatesPerFrame, ref m_updateArray); |
238 | World = new BulletWorld(0, this, BulletSimAPI.Initialize2(worldExtent, m_paramsHandle.AddrOfPinnedObject(), | ||
239 | m_maxCollisionsPerFrame, m_collisionArrayPinnedHandle.AddrOfPinnedObject(), | ||
240 | m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject(), | ||
241 | m_DebugLogCallbackHandle)); | ||
242 | 218 | ||
243 | Constraints = new BSConstraintCollection(World); | 219 | Constraints = new BSConstraintCollection(World); |
244 | 220 | ||
@@ -268,6 +244,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
268 | { | 244 | { |
269 | BSParam.SetParameterConfigurationValues(this, pConfig); | 245 | BSParam.SetParameterConfigurationValues(this, pConfig); |
270 | 246 | ||
247 | // There are two Bullet implementations to choose from | ||
248 | BulletEngineName = pConfig.GetString("BulletEngine", "BulletUnmanaged"); | ||
249 | |||
271 | // Very detailed logging for physics debugging | 250 | // Very detailed logging for physics debugging |
272 | // TODO: the boolean values can be moved to the normal parameter processing. | 251 | // TODO: the boolean values can be moved to the normal parameter processing. |
273 | m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false); | 252 | m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false); |
@@ -309,16 +288,41 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
309 | return ret; | 288 | return ret; |
310 | } | 289 | } |
311 | 290 | ||
312 | // Called directly from unmanaged code so don't do much | 291 | // Select the connection to the actual Bullet implementation. |
313 | private void BulletLogger(string msg) | 292 | // The main engine selection is the engineName up to the first hypen. |
293 | // So "Bullet-2.80-OpenCL-Intel" specifies the 'bullet' class here and the whole name | ||
294 | // is passed to the engine to do its special selection, etc. | ||
295 | private BSAPITemplate SelectUnderlyingBulletEngine(string engineName) | ||
314 | { | 296 | { |
315 | m_log.Debug("[BULLETS UNMANAGED]:" + msg); | 297 | // For the moment, do a simple switch statement. |
316 | } | 298 | // Someday do fancyness with looking up the interfaces in the assembly. |
299 | BSAPITemplate ret = null; | ||
317 | 300 | ||
318 | // Called directly from unmanaged code so don't do much | 301 | string selectionName = engineName.ToLower(); |
319 | private void BulletLoggerPhysLog(string msg) | 302 | int hyphenIndex = engineName.IndexOf("-"); |
320 | { | 303 | if (hyphenIndex > 0) |
321 | DetailLog("[BULLETS UNMANAGED]:" + msg); | 304 | selectionName = engineName.ToLower().Substring(0, hyphenIndex - 1); |
305 | |||
306 | switch (selectionName) | ||
307 | { | ||
308 | case "bulletunmanaged": | ||
309 | ret = new BSAPIUnman(engineName, this); | ||
310 | break; | ||
311 | case "bulletxna": | ||
312 | // ret = new BSAPIXNA(engineName, this); | ||
313 | break; | ||
314 | } | ||
315 | |||
316 | if (ret == null) | ||
317 | { | ||
318 | m_log.ErrorFormat("{0) COULD NOT SELECT BULLET ENGINE: '[BulletSim]PhysicsEngine' must be either 'BulletUnmanaged-*' or 'BulletXNA-*'", LogHeader); | ||
319 | } | ||
320 | else | ||
321 | { | ||
322 | m_log.WarnFormat("{0} Selected bullet engine {1} -> {2}/{3}", LogHeader, engineName, ret.BulletEngineName, ret.BulletEngineVersion); | ||
323 | } | ||
324 | |||
325 | return ret; | ||
322 | } | 326 | } |
323 | 327 | ||
324 | public override void Dispose() | 328 | public override void Dispose() |
@@ -355,7 +359,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
355 | } | 359 | } |
356 | 360 | ||
357 | // Anything left in the unmanaged code should be cleaned out | 361 | // Anything left in the unmanaged code should be cleaned out |
358 | BulletSimAPI.Shutdown2(World.ptr); | 362 | PE.Shutdown(World); |
359 | 363 | ||
360 | // Not logging any more | 364 | // Not logging any more |
361 | PhysicsLogging.Close(); | 365 | PhysicsLogging.Close(); |
@@ -468,9 +472,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
468 | LastTimeStep = timeStep; | 472 | LastTimeStep = timeStep; |
469 | 473 | ||
470 | int updatedEntityCount = 0; | 474 | int updatedEntityCount = 0; |
471 | IntPtr updatedEntitiesPtr; | ||
472 | int collidersCount = 0; | 475 | int collidersCount = 0; |
473 | IntPtr collidersPtr; | ||
474 | 476 | ||
475 | int beforeTime = 0; | 477 | int beforeTime = 0; |
476 | int simTime = 0; | 478 | int simTime = 0; |
@@ -486,6 +488,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
486 | TriggerPreStepEvent(timeStep); | 488 | TriggerPreStepEvent(timeStep); |
487 | 489 | ||
488 | // the prestep actions might have added taints | 490 | // the prestep actions might have added taints |
491 | numTaints += _taintOperations.Count; | ||
489 | ProcessTaints(); | 492 | ProcessTaints(); |
490 | 493 | ||
491 | InTaintTime = false; // Only used for debugging so locking is not necessary. | 494 | InTaintTime = false; // Only used for debugging so locking is not necessary. |
@@ -493,23 +496,25 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
493 | // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. | 496 | // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. |
494 | // Only enable this in a limited test world with few objects. | 497 | // Only enable this in a limited test world with few objects. |
495 | if (m_physicsPhysicalDumpEnabled) | 498 | if (m_physicsPhysicalDumpEnabled) |
496 | BulletSimAPI.DumpAllInfo2(World.ptr); | 499 | PE.DumpAllInfo(World); |
497 | 500 | ||
498 | // step the physical world one interval | 501 | // step the physical world one interval |
499 | m_simulationStep++; | 502 | m_simulationStep++; |
500 | int numSubSteps = 0; | 503 | int numSubSteps = 0; |
501 | |||
502 | try | 504 | try |
503 | { | 505 | { |
504 | if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount(); | 506 | if (PhysicsLogging.Enabled) |
507 | beforeTime = Util.EnvironmentTickCount(); | ||
505 | 508 | ||
506 | numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep, | 509 | numSubSteps = PE.PhysicsStep(World, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out collidersCount); |
507 | out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); | ||
508 | 510 | ||
509 | if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime); | 511 | if (PhysicsLogging.Enabled) |
510 | DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}", | 512 | { |
511 | DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, | 513 | simTime = Util.EnvironmentTickCountSubtract(beforeTime); |
512 | updatedEntityCount, collidersCount, ObjectsWithCollisions.Count); | 514 | DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}", |
515 | DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, | ||
516 | updatedEntityCount, collidersCount, ObjectsWithCollisions.Count); | ||
517 | } | ||
513 | } | 518 | } |
514 | catch (Exception e) | 519 | catch (Exception e) |
515 | { | 520 | { |
@@ -521,8 +526,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
521 | collidersCount = 0; | 526 | collidersCount = 0; |
522 | } | 527 | } |
523 | 528 | ||
524 | // Don't have to use the pointers passed back since we know it is the same pinned memory we passed in. | ||
525 | |||
526 | // Get a value for 'now' so all the collision and update routines don't have to get their own. | 529 | // Get a value for 'now' so all the collision and update routines don't have to get their own. |
527 | SimulationNowTime = Util.EnvironmentTickCount(); | 530 | SimulationNowTime = Util.EnvironmentTickCount(); |
528 | 531 | ||
@@ -564,7 +567,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
564 | // Objects that are done colliding are removed from the ObjectsWithCollisions list. | 567 | // Objects that are done colliding are removed from the ObjectsWithCollisions list. |
565 | // Not done above because it is inside an iteration of ObjectWithCollisions. | 568 | // Not done above because it is inside an iteration of ObjectWithCollisions. |
566 | // This complex collision processing is required to create an empty collision | 569 | // This complex collision processing is required to create an empty collision |
567 | // event call after all collisions have happened on an object. This enables | 570 | // event call after all real collisions have happened on an object. This enables |
568 | // the simulator to generate the 'collision end' event. | 571 | // the simulator to generate the 'collision end' event. |
569 | if (ObjectsWithNoMoreCollisions.Count > 0) | 572 | if (ObjectsWithNoMoreCollisions.Count > 0) |
570 | { | 573 | { |
@@ -593,11 +596,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
593 | // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. | 596 | // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. |
594 | // Only enable this in a limited test world with few objects. | 597 | // Only enable this in a limited test world with few objects. |
595 | if (m_physicsPhysicalDumpEnabled) | 598 | if (m_physicsPhysicalDumpEnabled) |
596 | BulletSimAPI.DumpAllInfo2(World.ptr); | 599 | PE.DumpAllInfo(World); |
597 | 600 | ||
598 | // The physics engine returns the number of milliseconds it simulated this call. | 601 | // The physics engine returns the number of milliseconds it simulated this call. |
599 | // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. | 602 | // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. |
600 | // Multiply by 55 to give a nominal frame rate of 55. | 603 | // Multiply by a fixed nominal frame rate to give a rate similar to the simulator (usually 55). |
601 | return (float)numSubSteps * m_fixedTimeStep * 1000f * NominalFrameRate; | 604 | return (float)numSubSteps * m_fixedTimeStep * 1000f * NominalFrameRate; |
602 | } | 605 | } |
603 | 606 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 0cc51b0..cd77581 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -141,9 +141,9 @@ public sealed class BSShapeCollection : IDisposable | |||
141 | if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body); | 141 | if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body); |
142 | PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.ReferenceBody", delegate() | 142 | PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.ReferenceBody", delegate() |
143 | { | 143 | { |
144 | if (!BulletSimAPI.IsInWorld2(body.ptr)) | 144 | if (!PhysicsScene.PE.IsInWorld(body)) |
145 | { | 145 | { |
146 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, body.ptr); | 146 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body); |
147 | if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body); | 147 | if (DDetail) DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body); |
148 | } | 148 | } |
149 | }); | 149 | }); |
@@ -166,15 +166,15 @@ public sealed class BSShapeCollection : IDisposable | |||
166 | // If the caller needs to know the old body is going away, pass the event up. | 166 | // If the caller needs to know the old body is going away, pass the event up. |
167 | if (bodyCallback != null) bodyCallback(body); | 167 | if (bodyCallback != null) bodyCallback(body); |
168 | 168 | ||
169 | if (BulletSimAPI.IsInWorld2(body.ptr)) | 169 | if (PhysicsScene.PE.IsInWorld(body)) |
170 | { | 170 | { |
171 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, body.ptr); | 171 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body); |
172 | if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body); | 172 | if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body); |
173 | } | 173 | } |
174 | 174 | ||
175 | // Zero any reference to the shape so it is not freed when the body is deleted. | 175 | // Zero any reference to the shape so it is not freed when the body is deleted. |
176 | BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, body.ptr, IntPtr.Zero); | 176 | PhysicsScene.PE.SetCollisionShape(PhysicsScene.World, body, new BulletShape()); |
177 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, body.ptr); | 177 | PhysicsScene.PE.DestroyObject(PhysicsScene.World, body); |
178 | }); | 178 | }); |
179 | } | 179 | } |
180 | } | 180 | } |
@@ -259,9 +259,9 @@ public sealed class BSShapeCollection : IDisposable | |||
259 | { | 259 | { |
260 | // Native shapes are not tracked and are released immediately | 260 | // Native shapes are not tracked and are released immediately |
261 | if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1},taintTime={2}", | 261 | if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1},taintTime={2}", |
262 | BSScene.DetailLogZero, shape.ptr.ToString("X"), inTaintTime); | 262 | BSScene.DetailLogZero, shape.AddrString, inTaintTime); |
263 | if (shapeCallback != null) shapeCallback(shape); | 263 | if (shapeCallback != null) shapeCallback(shape); |
264 | BulletSimAPI.DeleteCollisionShape2(PhysicsScene.World.ptr, shape.ptr); | 264 | PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape); |
265 | } | 265 | } |
266 | else | 266 | else |
267 | { | 267 | { |
@@ -332,36 +332,36 @@ public sealed class BSShapeCollection : IDisposable | |||
332 | // Called at taint-time. | 332 | // Called at taint-time. |
333 | private void DereferenceCompound(BulletShape shape, ShapeDestructionCallback shapeCallback) | 333 | private void DereferenceCompound(BulletShape shape, ShapeDestructionCallback shapeCallback) |
334 | { | 334 | { |
335 | if (!BulletSimAPI.IsCompound2(shape.ptr)) | 335 | if (!PhysicsScene.PE.IsCompound(shape)) |
336 | { | 336 | { |
337 | // Failed the sanity check!! | 337 | // Failed the sanity check!! |
338 | PhysicsScene.Logger.ErrorFormat("{0} Attempt to free a compound shape that is not compound!! type={1}, ptr={2}", | 338 | PhysicsScene.Logger.ErrorFormat("{0} Attempt to free a compound shape that is not compound!! type={1}, ptr={2}", |
339 | LogHeader, shape.type, shape.ptr.ToString("X")); | 339 | LogHeader, shape.type, shape.AddrString); |
340 | if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceCompound,notACompoundShape,type={1},ptr={2}", | 340 | if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceCompound,notACompoundShape,type={1},ptr={2}", |
341 | BSScene.DetailLogZero, shape.type, shape.ptr.ToString("X")); | 341 | BSScene.DetailLogZero, shape.type, shape.AddrString); |
342 | return; | 342 | return; |
343 | } | 343 | } |
344 | 344 | ||
345 | int numChildren = BulletSimAPI.GetNumberOfCompoundChildren2(shape.ptr); | 345 | int numChildren = PhysicsScene.PE.GetNumberOfCompoundChildren(shape); |
346 | if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceCompound,shape={1},children={2}", BSScene.DetailLogZero, shape, numChildren); | 346 | if (DDetail) DetailLog("{0},BSShapeCollection.DereferenceCompound,shape={1},children={2}", BSScene.DetailLogZero, shape, numChildren); |
347 | 347 | ||
348 | for (int ii = numChildren - 1; ii >= 0; ii--) | 348 | for (int ii = numChildren - 1; ii >= 0; ii--) |
349 | { | 349 | { |
350 | IntPtr childShape = BulletSimAPI.RemoveChildShapeFromCompoundShapeIndex2(shape.ptr, ii); | 350 | BulletShape childShape = PhysicsScene.PE.RemoveChildShapeFromCompoundShapeIndex(shape, ii); |
351 | DereferenceAnonCollisionShape(childShape); | 351 | DereferenceAnonCollisionShape(childShape); |
352 | } | 352 | } |
353 | BulletSimAPI.DeleteCollisionShape2(PhysicsScene.World.ptr, shape.ptr); | 353 | PhysicsScene.PE.DeleteCollisionShape(PhysicsScene.World, shape); |
354 | } | 354 | } |
355 | 355 | ||
356 | // Sometimes we have a pointer to a collision shape but don't know what type it is. | 356 | // Sometimes we have a pointer to a collision shape but don't know what type it is. |
357 | // Figure out type and call the correct dereference routine. | 357 | // Figure out type and call the correct dereference routine. |
358 | // Called at taint-time. | 358 | // Called at taint-time. |
359 | private void DereferenceAnonCollisionShape(IntPtr cShape) | 359 | private void DereferenceAnonCollisionShape(BulletShape shapeInfo) |
360 | { | 360 | { |
361 | MeshDesc meshDesc; | 361 | MeshDesc meshDesc; |
362 | HullDesc hullDesc; | 362 | HullDesc hullDesc; |
363 | 363 | ||
364 | BulletShape shapeInfo = new BulletShape(cShape); | 364 | IntPtr cShape = shapeInfo.ptr; |
365 | if (TryGetMeshByPtr(cShape, out meshDesc)) | 365 | if (TryGetMeshByPtr(cShape, out meshDesc)) |
366 | { | 366 | { |
367 | shapeInfo.type = BSPhysicsShapeType.SHAPE_MESH; | 367 | shapeInfo.type = BSPhysicsShapeType.SHAPE_MESH; |
@@ -376,13 +376,13 @@ public sealed class BSShapeCollection : IDisposable | |||
376 | } | 376 | } |
377 | else | 377 | else |
378 | { | 378 | { |
379 | if (BulletSimAPI.IsCompound2(cShape)) | 379 | if (PhysicsScene.PE.IsCompound(shapeInfo)) |
380 | { | 380 | { |
381 | shapeInfo.type = BSPhysicsShapeType.SHAPE_COMPOUND; | 381 | shapeInfo.type = BSPhysicsShapeType.SHAPE_COMPOUND; |
382 | } | 382 | } |
383 | else | 383 | else |
384 | { | 384 | { |
385 | if (BulletSimAPI.IsNativeShape2(cShape)) | 385 | if (PhysicsScene.PE.IsNativeShape(shapeInfo)) |
386 | { | 386 | { |
387 | shapeInfo.isNativeShape = true; | 387 | shapeInfo.isNativeShape = true; |
388 | shapeInfo.type = BSPhysicsShapeType.SHAPE_BOX; // (technically, type doesn't matter) | 388 | shapeInfo.type = BSPhysicsShapeType.SHAPE_BOX; // (technically, type doesn't matter) |
@@ -400,7 +400,7 @@ public sealed class BSShapeCollection : IDisposable | |||
400 | else | 400 | else |
401 | { | 401 | { |
402 | PhysicsScene.Logger.ErrorFormat("{0} Could not decypher shape type. Region={1}, addr={2}", | 402 | PhysicsScene.Logger.ErrorFormat("{0} Could not decypher shape type. Region={1}, addr={2}", |
403 | LogHeader, PhysicsScene.RegionName, cShape.ToString("X")); | 403 | LogHeader, PhysicsScene.RegionName, shapeInfo.AddrString); |
404 | } | 404 | } |
405 | } | 405 | } |
406 | 406 | ||
@@ -467,7 +467,7 @@ public sealed class BSShapeCollection : IDisposable | |||
467 | // Get the scale of any existing shape so we can see if the new shape is same native type and same size. | 467 | // Get the scale of any existing shape so we can see if the new shape is same native type and same size. |
468 | OMV.Vector3 scaleOfExistingShape = OMV.Vector3.Zero; | 468 | OMV.Vector3 scaleOfExistingShape = OMV.Vector3.Zero; |
469 | if (prim.PhysShape.HasPhysicalShape) | 469 | if (prim.PhysShape.HasPhysicalShape) |
470 | scaleOfExistingShape = BulletSimAPI.GetLocalScaling2(prim.PhysShape.ptr); | 470 | scaleOfExistingShape = PhysicsScene.PE.GetLocalScaling(prim.PhysShape); |
471 | 471 | ||
472 | if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}", | 472 | if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}", |
473 | prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.type); | 473 | prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.type); |
@@ -570,19 +570,15 @@ public sealed class BSShapeCollection : IDisposable | |||
570 | 570 | ||
571 | if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) | 571 | if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) |
572 | { | 572 | { |
573 | // The proper scale has been calculated in the prim. | 573 | |
574 | newShape = new BulletShape( | 574 | newShape = PhysicsScene.PE.BuildCapsuleShape(PhysicsScene.World, 1f, 1f, prim.Scale); |
575 | // Bullet's capsule total height is the passed "height + (radius * 2)" so, the base | ||
576 | // capsule is radius of 0.5f (1 diameter) and height of two (1.0f + 0.5f * 2)". | ||
577 | // This must be taken into account when computing the scaling of the capsule. | ||
578 | BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale) | ||
579 | , shapeType); | ||
580 | if (DDetail) DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); | 575 | if (DDetail) DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); |
581 | } | 576 | } |
582 | else | 577 | else |
583 | { | 578 | { |
584 | // Native shapes are scaled in Bullet so set the scaling to the size | 579 | // Native shapes are scaled in Bullet so set the scaling to the size |
585 | newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType); | 580 | newShape = PhysicsScene.PE.BuildNativeShape(PhysicsScene.World, nativeShapeData); |
581 | |||
586 | } | 582 | } |
587 | if (!newShape.HasPhysicalShape) | 583 | if (!newShape.HasPhysicalShape) |
588 | { | 584 | { |
@@ -629,13 +625,14 @@ public sealed class BSShapeCollection : IDisposable | |||
629 | 625 | ||
630 | private BulletShape CreatePhysicalMesh(string objName, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) | 626 | private BulletShape CreatePhysicalMesh(string objName, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) |
631 | { | 627 | { |
628 | BulletShape newShape = new BulletShape(); | ||
632 | IMesh meshData = null; | 629 | IMesh meshData = null; |
633 | IntPtr meshPtr = IntPtr.Zero; | 630 | |
634 | MeshDesc meshDesc; | 631 | MeshDesc meshDesc; |
635 | if (Meshes.TryGetValue(newMeshKey, out meshDesc)) | 632 | if (Meshes.TryGetValue(newMeshKey, out meshDesc)) |
636 | { | 633 | { |
637 | // If the mesh has already been built just use it. | 634 | // If the mesh has already been built just use it. |
638 | meshPtr = meshDesc.ptr; | 635 | newShape = new BulletShape(meshDesc.ptr, BSPhysicsShapeType.SHAPE_MESH); |
639 | } | 636 | } |
640 | else | 637 | else |
641 | { | 638 | { |
@@ -658,11 +655,10 @@ public sealed class BSShapeCollection : IDisposable | |||
658 | // m_log.DebugFormat("{0}: BSShapeCollection.CreatePhysicalMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}", | 655 | // m_log.DebugFormat("{0}: BSShapeCollection.CreatePhysicalMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}", |
659 | // LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count); | 656 | // LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count); |
660 | 657 | ||
661 | meshPtr = BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr, | 658 | newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, |
662 | indices.GetLength(0), indices, vertices.Count, verticesAsFloats); | 659 | indices.GetLength(0), indices, vertices.Count, verticesAsFloats); |
663 | } | 660 | } |
664 | } | 661 | } |
665 | BulletShape newShape = new BulletShape(meshPtr, BSPhysicsShapeType.SHAPE_MESH); | ||
666 | newShape.shapeKey = newMeshKey; | 662 | newShape.shapeKey = newMeshKey; |
667 | 663 | ||
668 | return newShape; | 664 | return newShape; |
@@ -700,12 +696,14 @@ public sealed class BSShapeCollection : IDisposable | |||
700 | private BulletShape CreatePhysicalHull(string objName, System.UInt64 newHullKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) | 696 | private BulletShape CreatePhysicalHull(string objName, System.UInt64 newHullKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) |
701 | { | 697 | { |
702 | 698 | ||
699 | BulletShape newShape = new BulletShape(); | ||
703 | IntPtr hullPtr = IntPtr.Zero; | 700 | IntPtr hullPtr = IntPtr.Zero; |
701 | |||
704 | HullDesc hullDesc; | 702 | HullDesc hullDesc; |
705 | if (Hulls.TryGetValue(newHullKey, out hullDesc)) | 703 | if (Hulls.TryGetValue(newHullKey, out hullDesc)) |
706 | { | 704 | { |
707 | // If the hull shape already is created, just use it. | 705 | // If the hull shape already is created, just use it. |
708 | hullPtr = hullDesc.ptr; | 706 | newShape = new BulletShape(hullDesc.ptr, BSPhysicsShapeType.SHAPE_HULL); |
709 | } | 707 | } |
710 | else | 708 | else |
711 | { | 709 | { |
@@ -793,11 +791,10 @@ public sealed class BSShapeCollection : IDisposable | |||
793 | } | 791 | } |
794 | } | 792 | } |
795 | // create the hull data structure in Bullet | 793 | // create the hull data structure in Bullet |
796 | hullPtr = BulletSimAPI.CreateHullShape2(PhysicsScene.World.ptr, hullCount, convHulls); | 794 | newShape = PhysicsScene.PE.CreateHullShape(PhysicsScene.World, hullCount, convHulls); |
797 | } | 795 | } |
798 | } | 796 | } |
799 | 797 | ||
800 | BulletShape newShape = new BulletShape(hullPtr, BSPhysicsShapeType.SHAPE_HULL); | ||
801 | newShape.shapeKey = newHullKey; | 798 | newShape.shapeKey = newHullKey; |
802 | 799 | ||
803 | return newShape; | 800 | return newShape; |
@@ -819,12 +816,12 @@ public sealed class BSShapeCollection : IDisposable | |||
819 | // Don't need to do this as the shape is freed when the new root shape is created below. | 816 | // Don't need to do this as the shape is freed when the new root shape is created below. |
820 | // DereferenceShape(prim.PhysShape, true, shapeCallback); | 817 | // DereferenceShape(prim.PhysShape, true, shapeCallback); |
821 | 818 | ||
822 | BulletShape cShape = new BulletShape( | 819 | |
823 | BulletSimAPI.CreateCompoundShape2(PhysicsScene.World.ptr, false), BSPhysicsShapeType.SHAPE_COMPOUND); | 820 | BulletShape cShape = PhysicsScene.PE.CreateCompoundShape(PhysicsScene.World, false); |
824 | 821 | ||
825 | // Create the shape for the root prim and add it to the compound shape. Cannot be a native shape. | 822 | // Create the shape for the root prim and add it to the compound shape. Cannot be a native shape. |
826 | CreateGeomMeshOrHull(prim, shapeCallback); | 823 | CreateGeomMeshOrHull(prim, shapeCallback); |
827 | BulletSimAPI.AddChildShapeToCompoundShape2(cShape.ptr, prim.PhysShape.ptr, OMV.Vector3.Zero, OMV.Quaternion.Identity); | 824 | PhysicsScene.PE.AddChildShapeToCompoundShape(cShape, prim.PhysShape, OMV.Vector3.Zero, OMV.Quaternion.Identity); |
828 | if (DDetail) DetailLog("{0},BSShapeCollection.GetReferenceToCompoundShape,addRootPrim,compShape={1},rootShape={2}", | 825 | if (DDetail) DetailLog("{0},BSShapeCollection.GetReferenceToCompoundShape,addRootPrim,compShape={1},rootShape={2}", |
829 | prim.LocalID, cShape, prim.PhysShape); | 826 | prim.LocalID, cShape, prim.PhysShape); |
830 | 827 | ||
@@ -932,7 +929,7 @@ public sealed class BSShapeCollection : IDisposable | |||
932 | // If not a solid object, body is a GhostObject. Otherwise a RigidBody. | 929 | // If not a solid object, body is a GhostObject. Otherwise a RigidBody. |
933 | if (!mustRebuild) | 930 | if (!mustRebuild) |
934 | { | 931 | { |
935 | CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(prim.PhysBody.ptr); | 932 | CollisionObjectTypes bodyType = (CollisionObjectTypes)PhysicsScene.PE.GetBodyType(prim.PhysBody); |
936 | if (prim.IsSolid && bodyType != CollisionObjectTypes.CO_RIGID_BODY | 933 | if (prim.IsSolid && bodyType != CollisionObjectTypes.CO_RIGID_BODY |
937 | || !prim.IsSolid && bodyType != CollisionObjectTypes.CO_GHOST_OBJECT) | 934 | || !prim.IsSolid && bodyType != CollisionObjectTypes.CO_GHOST_OBJECT) |
938 | { | 935 | { |
@@ -947,20 +944,16 @@ public sealed class BSShapeCollection : IDisposable | |||
947 | DereferenceBody(prim.PhysBody, true, bodyCallback); | 944 | DereferenceBody(prim.PhysBody, true, bodyCallback); |
948 | 945 | ||
949 | BulletBody aBody; | 946 | BulletBody aBody; |
950 | IntPtr bodyPtr = IntPtr.Zero; | ||
951 | if (prim.IsSolid) | 947 | if (prim.IsSolid) |
952 | { | 948 | { |
953 | bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr, | 949 | aBody = PhysicsScene.PE.CreateBodyFromShape(sim, shape, prim.LocalID, prim.RawPosition, prim.RawOrientation); |
954 | prim.LocalID, prim.RawPosition, prim.RawOrientation); | 950 | if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,mesh,body={1}", prim.LocalID, aBody); |
955 | if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); | ||
956 | } | 951 | } |
957 | else | 952 | else |
958 | { | 953 | { |
959 | bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr, | 954 | aBody = PhysicsScene.PE.CreateGhostFromShape(sim, shape, prim.LocalID, prim.RawPosition, prim.RawOrientation); |
960 | prim.LocalID, prim.RawPosition, prim.RawOrientation); | 955 | if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,ghost,body={1}", prim.LocalID, aBody); |
961 | if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); | ||
962 | } | 956 | } |
963 | aBody = new BulletBody(prim.LocalID, bodyPtr); | ||
964 | 957 | ||
965 | ReferenceBody(aBody, true); | 958 | ReferenceBody(aBody, true); |
966 | 959 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index c7885c6..c75eb9b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | |||
@@ -91,11 +91,17 @@ public abstract class BSShape | |||
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 | // Returns a string for debugging that uniquily identifies the memory used by this instance | ||
95 | public string AddrString | ||
96 | { | ||
97 | get { return ptr.ToString("X"); } | ||
98 | } | ||
99 | |||
94 | public override string ToString() | 100 | public override string ToString() |
95 | { | 101 | { |
96 | StringBuilder buff = new StringBuilder(); | 102 | StringBuilder buff = new StringBuilder(); |
97 | buff.Append("<p="); | 103 | buff.Append("<p="); |
98 | buff.Append(ptr.ToString("X")); | 104 | buff.Append(AddrString); |
99 | buff.Append(",s="); | 105 | buff.Append(",s="); |
100 | buff.Append(type.ToString()); | 106 | buff.Append(type.ToString()); |
101 | buff.Append(",k="); | 107 | buff.Append(",k="); |
@@ -126,7 +132,8 @@ public class BSShapeNative : BSShape | |||
126 | BSPhysicsShapeType shapeType, FixedShapeKey shapeKey) | 132 | BSPhysicsShapeType shapeType, FixedShapeKey shapeKey) |
127 | { | 133 | { |
128 | // Native shapes are not shared and are always built anew. | 134 | // Native shapes are not shared and are always built anew. |
129 | return new BSShapeNative(physicsScene, prim, shapeType, shapeKey); | 135 | //return new BSShapeNative(physicsScene, prim, shapeType, shapeKey); |
136 | return null; | ||
130 | } | 137 | } |
131 | 138 | ||
132 | private BSShapeNative(BSScene physicsScene, BSPhysObject prim, | 139 | private BSShapeNative(BSScene physicsScene, BSPhysObject prim, |
@@ -141,14 +148,15 @@ public class BSShapeNative : BSShape | |||
141 | nativeShapeData.HullKey = (ulong)shapeKey; | 148 | nativeShapeData.HullKey = (ulong)shapeKey; |
142 | 149 | ||
143 | 150 | ||
151 | /* | ||
144 | if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) | 152 | if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) |
145 | { | 153 | { |
146 | ptr = BulletSimAPI.BuildCapsuleShape2(physicsScene.World.ptr, 1f, 1f, prim.Scale); | 154 | ptr = PhysicsScene.PE.BuildCapsuleShape(physicsScene.World, 1f, 1f, prim.Scale); |
147 | physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); | 155 | physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); |
148 | } | 156 | } |
149 | else | 157 | else |
150 | { | 158 | { |
151 | ptr = BulletSimAPI.BuildNativeShape2(physicsScene.World.ptr, nativeShapeData); | 159 | ptr = PhysicsScene.PE.BuildNativeShape(physicsScene.World, nativeShapeData); |
152 | } | 160 | } |
153 | if (ptr == IntPtr.Zero) | 161 | if (ptr == IntPtr.Zero) |
154 | { | 162 | { |
@@ -157,15 +165,18 @@ public class BSShapeNative : BSShape | |||
157 | } | 165 | } |
158 | type = shapeType; | 166 | type = shapeType; |
159 | key = (UInt64)shapeKey; | 167 | key = (UInt64)shapeKey; |
168 | */ | ||
160 | } | 169 | } |
161 | // Make this reference to the physical shape go away since native shapes are not shared. | 170 | // Make this reference to the physical shape go away since native shapes are not shared. |
162 | public override void Dereference(BSScene physicsScene) | 171 | public override void Dereference(BSScene physicsScene) |
163 | { | 172 | { |
173 | /* | ||
164 | // Native shapes are not tracked and are released immediately | 174 | // Native shapes are not tracked and are released immediately |
165 | physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this); | 175 | physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this); |
166 | BulletSimAPI.DeleteCollisionShape2(physicsScene.World.ptr, ptr); | 176 | PhysicsScene.PE.DeleteCollisionShape(physicsScene.World, this); |
167 | ptr = IntPtr.Zero; | 177 | ptr = IntPtr.Zero; |
168 | // Garbage collection will free up this instance. | 178 | // Garbage collection will free up this instance. |
179 | */ | ||
169 | } | 180 | } |
170 | } | 181 | } |
171 | 182 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs index 07a9fd8..114c0aa 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs | |||
@@ -44,7 +44,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
44 | { | 44 | { |
45 | static string LogHeader = "[BULLETSIM TERRAIN HEIGHTMAP]"; | 45 | static string LogHeader = "[BULLETSIM TERRAIN HEIGHTMAP]"; |
46 | 46 | ||
47 | BulletHeightMapInfo m_mapInfo = null; | 47 | BulletHMapInfo m_mapInfo = null; |
48 | 48 | ||
49 | // Constructor to build a default, flat heightmap terrain. | 49 | // Constructor to build a default, flat heightmap terrain. |
50 | public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, Vector3 regionSize) | 50 | public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, Vector3 regionSize) |
@@ -58,7 +58,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
58 | { | 58 | { |
59 | initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION; | 59 | initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION; |
60 | } | 60 | } |
61 | m_mapInfo = new BulletHeightMapInfo(id, initialMap, IntPtr.Zero); | 61 | m_mapInfo = new BulletHMapInfo(id, initialMap); |
62 | m_mapInfo.minCoords = minTerrainCoords; | 62 | m_mapInfo.minCoords = minTerrainCoords; |
63 | m_mapInfo.maxCoords = maxTerrainCoords; | 63 | m_mapInfo.maxCoords = maxTerrainCoords; |
64 | m_mapInfo.terrainRegionBase = TerrainBase; | 64 | m_mapInfo.terrainRegionBase = TerrainBase; |
@@ -72,7 +72,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
72 | Vector3 minCoords, Vector3 maxCoords) | 72 | Vector3 minCoords, Vector3 maxCoords) |
73 | : base(physicsScene, regionBase, id) | 73 | : base(physicsScene, regionBase, id) |
74 | { | 74 | { |
75 | m_mapInfo = new BulletHeightMapInfo(id, initialMap, IntPtr.Zero); | 75 | m_mapInfo = new BulletHMapInfo(id, initialMap); |
76 | m_mapInfo.minCoords = minCoords; | 76 | m_mapInfo.minCoords = minCoords; |
77 | m_mapInfo.maxCoords = maxCoords; | 77 | m_mapInfo.maxCoords = maxCoords; |
78 | m_mapInfo.minZ = minCoords.Z; | 78 | m_mapInfo.minZ = minCoords.Z; |
@@ -91,13 +91,11 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
91 | // Using the information in m_mapInfo, create the physical representation of the heightmap. | 91 | // Using the information in m_mapInfo, create the physical representation of the heightmap. |
92 | private void BuildHeightmapTerrain() | 92 | private void BuildHeightmapTerrain() |
93 | { | 93 | { |
94 | m_mapInfo.Ptr = BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, m_mapInfo.ID, | ||
95 | m_mapInfo.minCoords, m_mapInfo.maxCoords, | ||
96 | m_mapInfo.heightMap, BSParam.TerrainCollisionMargin); | ||
97 | |||
98 | // Create the terrain shape from the mapInfo | 94 | // Create the terrain shape from the mapInfo |
99 | m_mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(m_mapInfo.Ptr), | 95 | m_mapInfo.terrainShape = PhysicsScene.PE.CreateTerrainShape( m_mapInfo.ID, |
100 | BSPhysicsShapeType.SHAPE_TERRAIN); | 96 | new Vector3(m_mapInfo.sizeX, m_mapInfo.sizeY, 0), m_mapInfo.minZ, m_mapInfo.maxZ, |
97 | m_mapInfo.heightMap, 1f, BSParam.TerrainCollisionMargin); | ||
98 | |||
101 | 99 | ||
102 | // The terrain object initial position is at the center of the object | 100 | // The terrain object initial position is at the center of the object |
103 | Vector3 centerPos; | 101 | Vector3 centerPos; |
@@ -105,27 +103,26 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
105 | centerPos.Y = m_mapInfo.minCoords.Y + (m_mapInfo.sizeY / 2f); | 103 | centerPos.Y = m_mapInfo.minCoords.Y + (m_mapInfo.sizeY / 2f); |
106 | centerPos.Z = m_mapInfo.minZ + ((m_mapInfo.maxZ - m_mapInfo.minZ) / 2f); | 104 | centerPos.Z = m_mapInfo.minZ + ((m_mapInfo.maxZ - m_mapInfo.minZ) / 2f); |
107 | 105 | ||
108 | m_mapInfo.terrainBody = new BulletBody(m_mapInfo.ID, | 106 | m_mapInfo.terrainBody = PhysicsScene.PE.CreateBodyWithDefaultMotionState(m_mapInfo.terrainShape, |
109 | BulletSimAPI.CreateBodyWithDefaultMotionState2(m_mapInfo.terrainShape.ptr, | 107 | m_mapInfo.ID, centerPos, Quaternion.Identity); |
110 | m_mapInfo.ID, centerPos, Quaternion.Identity)); | ||
111 | 108 | ||
112 | // Set current terrain attributes | 109 | // Set current terrain attributes |
113 | BulletSimAPI.SetFriction2(m_mapInfo.terrainBody.ptr, BSParam.TerrainFriction); | 110 | PhysicsScene.PE.SetFriction(m_mapInfo.terrainBody, BSParam.TerrainFriction); |
114 | BulletSimAPI.SetHitFraction2(m_mapInfo.terrainBody.ptr, BSParam.TerrainHitFraction); | 111 | PhysicsScene.PE.SetHitFraction(m_mapInfo.terrainBody, BSParam.TerrainHitFraction); |
115 | BulletSimAPI.SetRestitution2(m_mapInfo.terrainBody.ptr, BSParam.TerrainRestitution); | 112 | PhysicsScene.PE.SetRestitution(m_mapInfo.terrainBody, BSParam.TerrainRestitution); |
116 | BulletSimAPI.SetCollisionFlags2(m_mapInfo.terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 113 | PhysicsScene.PE.SetCollisionFlags(m_mapInfo.terrainBody, CollisionFlags.CF_STATIC_OBJECT); |
117 | 114 | ||
118 | // Return the new terrain to the world of physical objects | 115 | // Return the new terrain to the world of physical objects |
119 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); | 116 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_mapInfo.terrainBody); |
120 | 117 | ||
121 | // redo its bounding box now that it is in the world | 118 | // redo its bounding box now that it is in the world |
122 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); | 119 | PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_mapInfo.terrainBody); |
123 | 120 | ||
124 | m_mapInfo.terrainBody.collisionType = CollisionType.Terrain; | 121 | m_mapInfo.terrainBody.collisionType = CollisionType.Terrain; |
125 | m_mapInfo.terrainBody.ApplyCollisionMask(); | 122 | m_mapInfo.terrainBody.ApplyCollisionMask(PhysicsScene); |
126 | 123 | ||
127 | // Make it so the terrain will not move or be considered for movement. | 124 | // Make it so the terrain will not move or be considered for movement. |
128 | BulletSimAPI.ForceActivationState2(m_mapInfo.terrainBody.ptr, ActivationState.DISABLE_SIMULATION); | 125 | PhysicsScene.PE.ForceActivationState(m_mapInfo.terrainBody, ActivationState.DISABLE_SIMULATION); |
129 | 126 | ||
130 | return; | 127 | return; |
131 | } | 128 | } |
@@ -137,10 +134,9 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
137 | { | 134 | { |
138 | if (m_mapInfo.terrainBody.HasPhysicalBody) | 135 | if (m_mapInfo.terrainBody.HasPhysicalBody) |
139 | { | 136 | { |
140 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); | 137 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_mapInfo.terrainBody); |
141 | // Frees both the body and the shape. | 138 | // Frees both the body and the shape. |
142 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); | 139 | PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_mapInfo.terrainBody); |
143 | BulletSimAPI.ReleaseHeightMapInfo2(m_mapInfo.Ptr); | ||
144 | } | 140 | } |
145 | } | 141 | } |
146 | m_mapInfo = null; | 142 | m_mapInfo = null; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index 86ccfbb..2e9db39 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -133,20 +133,17 @@ public sealed class BSTerrainManager : IDisposable | |||
133 | public void CreateInitialGroundPlaneAndTerrain() | 133 | public void CreateInitialGroundPlaneAndTerrain() |
134 | { | 134 | { |
135 | // The ground plane is here to catch things that are trying to drop to negative infinity | 135 | // The ground plane is here to catch things that are trying to drop to negative infinity |
136 | BulletShape groundPlaneShape = new BulletShape( | 136 | BulletShape groundPlaneShape = PhysicsScene.PE.CreateGroundPlaneShape(BSScene.GROUNDPLANE_ID, 1f, BSParam.TerrainCollisionMargin); |
137 | BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, | 137 | m_groundPlane = PhysicsScene.PE.CreateBodyWithDefaultMotionState(groundPlaneShape, |
138 | BSParam.TerrainCollisionMargin), | 138 | BSScene.GROUNDPLANE_ID, Vector3.Zero, Quaternion.Identity); |
139 | BSPhysicsShapeType.SHAPE_GROUNDPLANE); | 139 | |
140 | m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID, | 140 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_groundPlane); |
141 | BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID, | 141 | PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_groundPlane); |
142 | Vector3.Zero, Quaternion.Identity)); | ||
143 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr); | ||
144 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_groundPlane.ptr); | ||
145 | // Ground plane does not move | 142 | // Ground plane does not move |
146 | BulletSimAPI.ForceActivationState2(m_groundPlane.ptr, ActivationState.DISABLE_SIMULATION); | 143 | PhysicsScene.PE.ForceActivationState(m_groundPlane, ActivationState.DISABLE_SIMULATION); |
147 | // Everything collides with the ground plane. | 144 | // Everything collides with the ground plane. |
148 | m_groundPlane.collisionType = CollisionType.Groundplane; | 145 | m_groundPlane.collisionType = CollisionType.Groundplane; |
149 | m_groundPlane.ApplyCollisionMask(); | 146 | m_groundPlane.ApplyCollisionMask(PhysicsScene); |
150 | 147 | ||
151 | // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain. | 148 | // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain. |
152 | BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize); | 149 | BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize); |
@@ -158,9 +155,9 @@ public sealed class BSTerrainManager : IDisposable | |||
158 | { | 155 | { |
159 | if (m_groundPlane.HasPhysicalBody) | 156 | if (m_groundPlane.HasPhysicalBody) |
160 | { | 157 | { |
161 | if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_groundPlane.ptr)) | 158 | if (PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_groundPlane)) |
162 | { | 159 | { |
163 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_groundPlane.ptr); | 160 | PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_groundPlane); |
164 | } | 161 | } |
165 | m_groundPlane.Clear(); | 162 | m_groundPlane.Clear(); |
166 | } | 163 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs index 061e232..1d55ce3 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs | |||
@@ -91,9 +91,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys | |||
91 | PhysicsScene.DetailLog("{0},BSTerrainMesh.create,meshed,indices={1},indSz={2},vertices={3},vertSz={4}", | 91 | PhysicsScene.DetailLog("{0},BSTerrainMesh.create,meshed,indices={1},indSz={2},vertices={3},vertSz={4}", |
92 | ID, indicesCount, indices.Length, verticesCount, vertices.Length); | 92 | ID, indicesCount, indices.Length, verticesCount, vertices.Length); |
93 | 93 | ||
94 | m_terrainShape = new BulletShape(BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr, | 94 | m_terrainShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World, indicesCount, indices, verticesCount, vertices); |
95 | indicesCount, indices, verticesCount, vertices), | ||
96 | BSPhysicsShapeType.SHAPE_MESH); | ||
97 | if (!m_terrainShape.HasPhysicalShape) | 95 | if (!m_terrainShape.HasPhysicalShape) |
98 | { | 96 | { |
99 | // DISASTER!! | 97 | // DISASTER!! |
@@ -106,7 +104,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys | |||
106 | Vector3 pos = regionBase; | 104 | Vector3 pos = regionBase; |
107 | Quaternion rot = Quaternion.Identity; | 105 | Quaternion rot = Quaternion.Identity; |
108 | 106 | ||
109 | m_terrainBody = new BulletBody(id, BulletSimAPI.CreateBodyWithDefaultMotionState2( m_terrainShape.ptr, ID, pos, rot)); | 107 | m_terrainBody = PhysicsScene.PE.CreateBodyWithDefaultMotionState(m_terrainShape, ID, pos, rot); |
110 | if (!m_terrainBody.HasPhysicalBody) | 108 | if (!m_terrainBody.HasPhysicalBody) |
111 | { | 109 | { |
112 | // DISASTER!! | 110 | // DISASTER!! |
@@ -116,34 +114,34 @@ public sealed class BSTerrainMesh : BSTerrainPhys | |||
116 | } | 114 | } |
117 | 115 | ||
118 | // Set current terrain attributes | 116 | // Set current terrain attributes |
119 | BulletSimAPI.SetFriction2(m_terrainBody.ptr, BSParam.TerrainFriction); | 117 | PhysicsScene.PE.SetFriction(m_terrainBody, BSParam.TerrainFriction); |
120 | BulletSimAPI.SetHitFraction2(m_terrainBody.ptr, BSParam.TerrainHitFraction); | 118 | PhysicsScene.PE.SetHitFraction(m_terrainBody, BSParam.TerrainHitFraction); |
121 | BulletSimAPI.SetRestitution2(m_terrainBody.ptr, BSParam.TerrainRestitution); | 119 | PhysicsScene.PE.SetRestitution(m_terrainBody, BSParam.TerrainRestitution); |
122 | BulletSimAPI.SetCollisionFlags2(m_terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 120 | PhysicsScene.PE.SetCollisionFlags(m_terrainBody, CollisionFlags.CF_STATIC_OBJECT); |
123 | 121 | ||
124 | // Static objects are not very massive. | 122 | // Static objects are not very massive. |
125 | BulletSimAPI.SetMassProps2(m_terrainBody.ptr, 0f, Vector3.Zero); | 123 | PhysicsScene.PE.SetMassProps(m_terrainBody, 0f, Vector3.Zero); |
126 | 124 | ||
127 | // Put the new terrain to the world of physical objects | 125 | // Put the new terrain to the world of physical objects |
128 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_terrainBody.ptr); | 126 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_terrainBody); |
129 | 127 | ||
130 | // Redo its bounding box now that it is in the world | 128 | // Redo its bounding box now that it is in the world |
131 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_terrainBody.ptr); | 129 | PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_terrainBody); |
132 | 130 | ||
133 | m_terrainBody.collisionType = CollisionType.Terrain; | 131 | m_terrainBody.collisionType = CollisionType.Terrain; |
134 | m_terrainBody.ApplyCollisionMask(); | 132 | m_terrainBody.ApplyCollisionMask(PhysicsScene); |
135 | 133 | ||
136 | // Make it so the terrain will not move or be considered for movement. | 134 | // Make it so the terrain will not move or be considered for movement. |
137 | BulletSimAPI.ForceActivationState2(m_terrainBody.ptr, ActivationState.DISABLE_SIMULATION); | 135 | PhysicsScene.PE.ForceActivationState(m_terrainBody, ActivationState.DISABLE_SIMULATION); |
138 | } | 136 | } |
139 | 137 | ||
140 | public override void Dispose() | 138 | public override void Dispose() |
141 | { | 139 | { |
142 | if (m_terrainBody.HasPhysicalBody) | 140 | if (m_terrainBody.HasPhysicalBody) |
143 | { | 141 | { |
144 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_terrainBody.ptr); | 142 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_terrainBody); |
145 | // Frees both the body and the shape. | 143 | // Frees both the body and the shape. |
146 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_terrainBody.ptr); | 144 | PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_terrainBody); |
147 | } | 145 | } |
148 | } | 146 | } |
149 | 147 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs index 5ad6746..681d21e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs | |||
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
35 | // These hold pointers to allocated objects in the unmanaged space. | 35 | // These hold pointers to allocated objects in the unmanaged space. |
36 | 36 | ||
37 | // The physics engine controller class created at initialization | 37 | // The physics engine controller class created at initialization |
38 | public struct BulletWorld | 38 | public class BulletWorld |
39 | { | 39 | { |
40 | public BulletWorld(uint worldId, BSScene bss, IntPtr xx) | 40 | public BulletWorld(uint worldId, BSScene bss, IntPtr xx) |
41 | { | 41 | { |
@@ -50,7 +50,7 @@ public struct BulletWorld | |||
50 | } | 50 | } |
51 | 51 | ||
52 | // An allocated Bullet btRigidBody | 52 | // An allocated Bullet btRigidBody |
53 | public struct BulletBody | 53 | public class BulletBody |
54 | { | 54 | { |
55 | public BulletBody(uint id) : this(id, IntPtr.Zero) | 55 | public BulletBody(uint id) : this(id, IntPtr.Zero) |
56 | { | 56 | { |
@@ -72,23 +72,32 @@ public struct BulletBody | |||
72 | public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } } | 72 | public bool HasPhysicalBody { get { return ptr != IntPtr.Zero; } } |
73 | 73 | ||
74 | // Apply the specificed collision mask into the physical world | 74 | // Apply the specificed collision mask into the physical world |
75 | public bool ApplyCollisionMask() | 75 | public bool ApplyCollisionMask(BSScene physicsScene) |
76 | { | 76 | { |
77 | // Should assert the body has been added to the physical world. | 77 | // Should assert the body has been added to the physical world. |
78 | // (The collision masks are stored in the collision proxy cache which only exists for | 78 | // (The collision masks are stored in the collision proxy cache which only exists for |
79 | // a collision body that is in the world.) | 79 | // a collision body that is in the world.) |
80 | return BulletSimAPI.SetCollisionGroupMask2(ptr, | 80 | return physicsScene.PE.SetCollisionGroupMask(this, |
81 | BulletSimData.CollisionTypeMasks[collisionType].group, | 81 | BulletSimData.CollisionTypeMasks[collisionType].group, |
82 | BulletSimData.CollisionTypeMasks[collisionType].mask); | 82 | BulletSimData.CollisionTypeMasks[collisionType].mask); |
83 | } | 83 | } |
84 | 84 | ||
85 | // Used for log messages for a unique display of the memory/object allocated to this instance | ||
86 | public string AddrString | ||
87 | { | ||
88 | get | ||
89 | { | ||
90 | return ptr.ToString("X"); | ||
91 | } | ||
92 | } | ||
93 | |||
85 | public override string ToString() | 94 | public override string ToString() |
86 | { | 95 | { |
87 | StringBuilder buff = new StringBuilder(); | 96 | StringBuilder buff = new StringBuilder(); |
88 | buff.Append("<id="); | 97 | buff.Append("<id="); |
89 | buff.Append(ID.ToString()); | 98 | buff.Append(ID.ToString()); |
90 | buff.Append(",p="); | 99 | buff.Append(",p="); |
91 | buff.Append(ptr.ToString("X")); | 100 | buff.Append(AddrString); |
92 | buff.Append(",c="); | 101 | buff.Append(",c="); |
93 | buff.Append(collisionType); | 102 | buff.Append(collisionType); |
94 | buff.Append(">"); | 103 | buff.Append(">"); |
@@ -96,9 +105,14 @@ public struct BulletBody | |||
96 | } | 105 | } |
97 | } | 106 | } |
98 | 107 | ||
99 | public struct BulletShape | 108 | public class BulletShape |
100 | { | 109 | { |
101 | public BulletShape(IntPtr xx) : this(xx, BSPhysicsShapeType.SHAPE_UNKNOWN) | 110 | public BulletShape() |
111 | : this(IntPtr.Zero, BSPhysicsShapeType.SHAPE_UNKNOWN) | ||
112 | { | ||
113 | } | ||
114 | public BulletShape(IntPtr xx) | ||
115 | : this(xx, BSPhysicsShapeType.SHAPE_UNKNOWN) | ||
102 | { | 116 | { |
103 | } | 117 | } |
104 | public BulletShape(IntPtr xx, BSPhysicsShapeType typ) | 118 | public BulletShape(IntPtr xx, BSPhysicsShapeType typ) |
@@ -119,11 +133,20 @@ public struct BulletShape | |||
119 | } | 133 | } |
120 | public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } } | 134 | public bool HasPhysicalShape { get { return ptr != IntPtr.Zero; } } |
121 | 135 | ||
136 | // Used for log messages for a unique display of the memory/object allocated to this instance | ||
137 | public string AddrString | ||
138 | { | ||
139 | get | ||
140 | { | ||
141 | return ptr.ToString("X"); | ||
142 | } | ||
143 | } | ||
144 | |||
122 | public override string ToString() | 145 | public override string ToString() |
123 | { | 146 | { |
124 | StringBuilder buff = new StringBuilder(); | 147 | StringBuilder buff = new StringBuilder(); |
125 | buff.Append("<p="); | 148 | buff.Append("<p="); |
126 | buff.Append(ptr.ToString("X")); | 149 | buff.Append(AddrString); |
127 | buff.Append(",s="); | 150 | buff.Append(",s="); |
128 | buff.Append(type.ToString()); | 151 | buff.Append(type.ToString()); |
129 | buff.Append(",k="); | 152 | buff.Append(",k="); |
@@ -136,7 +159,7 @@ public struct BulletShape | |||
136 | } | 159 | } |
137 | 160 | ||
138 | // An allocated Bullet btConstraint | 161 | // An allocated Bullet btConstraint |
139 | public struct BulletConstraint | 162 | public class BulletConstraint |
140 | { | 163 | { |
141 | public BulletConstraint(IntPtr xx) | 164 | public BulletConstraint(IntPtr xx) |
142 | { | 165 | { |
@@ -149,17 +172,25 @@ public struct BulletConstraint | |||
149 | ptr = IntPtr.Zero; | 172 | ptr = IntPtr.Zero; |
150 | } | 173 | } |
151 | public bool HasPhysicalConstraint { get { return ptr != IntPtr.Zero; } } | 174 | public bool HasPhysicalConstraint { get { return ptr != IntPtr.Zero; } } |
175 | |||
176 | // Used for log messages for a unique display of the memory/object allocated to this instance | ||
177 | public string AddrString | ||
178 | { | ||
179 | get | ||
180 | { | ||
181 | return ptr.ToString("X"); | ||
182 | } | ||
183 | } | ||
152 | } | 184 | } |
153 | 185 | ||
154 | // An allocated HeightMapThing which holds various heightmap info. | 186 | // An allocated HeightMapThing which holds various heightmap info. |
155 | // Made a class rather than a struct so there would be only one | 187 | // Made a class rather than a struct so there would be only one |
156 | // instance of this and C# will pass around pointers rather | 188 | // instance of this and C# will pass around pointers rather |
157 | // than making copies. | 189 | // than making copies. |
158 | public class BulletHeightMapInfo | 190 | public class BulletHMapInfo |
159 | { | 191 | { |
160 | public BulletHeightMapInfo(uint id, float[] hm, IntPtr xx) { | 192 | public BulletHMapInfo(uint id, float[] hm) { |
161 | ID = id; | 193 | ID = id; |
162 | Ptr = xx; | ||
163 | heightMap = hm; | 194 | heightMap = hm; |
164 | terrainRegionBase = OMV.Vector3.Zero; | 195 | terrainRegionBase = OMV.Vector3.Zero; |
165 | minCoords = new OMV.Vector3(100f, 100f, 25f); | 196 | minCoords = new OMV.Vector3(100f, 100f, 25f); |
@@ -168,7 +199,6 @@ public class BulletHeightMapInfo | |||
168 | sizeX = sizeY = 256f; | 199 | sizeX = sizeY = 256f; |
169 | } | 200 | } |
170 | public uint ID; | 201 | public uint ID; |
171 | public IntPtr Ptr; | ||
172 | public float[] heightMap; | 202 | public float[] heightMap; |
173 | public OMV.Vector3 terrainRegionBase; | 203 | public OMV.Vector3 terrainRegionBase; |
174 | public OMV.Vector3 minCoords; | 204 | public OMV.Vector3 minCoords; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index f805836..a8a4ff5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt | |||
@@ -31,6 +31,7 @@ CRASHES | |||
31 | 31 | ||
32 | VEHICLES TODO LIST: | 32 | VEHICLES TODO LIST: |
33 | ================================================= | 33 | ================================================= |
34 | Angular motor direction is global coordinates rather than local coordinates | ||
34 | Border crossing with linked vehicle causes crash | 35 | Border crossing with linked vehicle causes crash |
35 | Vehicles (Move smoothly) | 36 | Vehicles (Move smoothly) |
36 | Add vehicle collisions so IsColliding is properly reported. | 37 | Add vehicle collisions so IsColliding is properly reported. |
@@ -60,7 +61,8 @@ Incorporate inter-relationship of angular corrections. For instance, angularDefl | |||
60 | 61 | ||
61 | BULLETSIM TODO LIST: | 62 | BULLETSIM TODO LIST: |
62 | ================================================= | 63 | ================================================= |
63 | Avatar density is WAY off. Compare and calibrate with what's in SL. | 64 | Implement an avatar mesh shape. The Bullet capsule is way too limited. |
65 | Consider just hand creating a vertex/index array in a new BSShapeAvatar. | ||
64 | Revisit CollisionMargin. Builders notice the 0.04 spacing between prims. | 66 | Revisit CollisionMargin. Builders notice the 0.04 spacing between prims. |
65 | Duplicating a physical prim causes old prim to jump away | 67 | Duplicating a physical prim causes old prim to jump away |
66 | Dup a phys prim and the original become unselected and thus interacts w/ selected prim. | 68 | Dup a phys prim and the original become unselected and thus interacts w/ selected prim. |
@@ -78,7 +80,7 @@ Small physical objects do not interact correctly | |||
78 | Create chain of .5x.5x.1 torui and make all but top physical so to hang. | 80 | Create chain of .5x.5x.1 torui and make all but top physical so to hang. |
79 | The chain will fall apart and pairs will dance around on ground | 81 | The chain will fall apart and pairs will dance around on ground |
80 | Chains of 1x1x.2 will stay connected but will dance. | 82 | Chains of 1x1x.2 will stay connected but will dance. |
81 | Chains above 2x2x.4 are move stable and get stablier as torui get larger. | 83 | Chains above 2x2x.4 are more stable and get stablier as torui get larger. |
82 | Add PID motor for avatar movement (slow to stop, ...) | 84 | Add PID motor for avatar movement (slow to stop, ...) |
83 | setForce should set a constant force. Different than AddImpulse. | 85 | setForce should set a constant force. Different than AddImpulse. |
84 | Implement raycast. | 86 | Implement raycast. |
@@ -97,9 +99,16 @@ Selecting and deselecting physical objects causes CPU processing time to jump | |||
97 | Re-implement buoyancy as a separate force on the object rather than diddling gravity. | 99 | Re-implement buoyancy as a separate force on the object rather than diddling gravity. |
98 | Register a pre-step event to add the force. | 100 | Register a pre-step event to add the force. |
99 | More efficient memory usage when passing hull information from BSPrim to BulletSim | 101 | More efficient memory usage when passing hull information from BSPrim to BulletSim |
102 | Avatar movement motor check for zero or small movement. Somehow suppress small movements | ||
103 | when avatar has stopped and is just standing. Simple test for near zero has | ||
104 | the problem of preventing starting up (increase from zero) especially when falling. | ||
105 | Physical and phantom will drop through the terrain | ||
106 | |||
100 | 107 | ||
101 | LINKSETS | 108 | LINKSETS |
102 | ====================================================== | 109 | ====================================================== |
110 | Offset the center of the linkset to be the geometric center of all the prims | ||
111 | Not quite the same as the center-of-gravity | ||
103 | Linksets should allow collisions to individual children | 112 | Linksets should allow collisions to individual children |
104 | Add LocalID to children shapes in LinksetCompound and create events for individuals | 113 | Add LocalID to children shapes in LinksetCompound and create events for individuals |
105 | LinksetCompound: when one of the children changes orientation (like tires | 114 | LinksetCompound: when one of the children changes orientation (like tires |
@@ -162,6 +171,9 @@ Avatar attachments have no mass? http://forums-archive.secondlife.com/54/f0/3179 | |||
162 | 171 | ||
163 | INTERNAL IMPROVEMENT/CLEANUP | 172 | INTERNAL IMPROVEMENT/CLEANUP |
164 | ================================================= | 173 | ================================================= |
174 | Create the physical wrapper classes (BulletBody, BulletShape) by methods on | ||
175 | BSAPITemplate and make their actual implementation Bullet engine specific. | ||
176 | For the short term, just call the existing functions in ShapeCollection. | ||
165 | Consider moving prim/character body and shape destruction in destroy() | 177 | Consider moving prim/character body and shape destruction in destroy() |
166 | to postTimeTime rather than protecting all the potential sets that | 178 | to postTimeTime rather than protecting all the potential sets that |
167 | might have been queued up. | 179 | might have been queued up. |
@@ -195,6 +207,9 @@ Should taints check for existance or activeness of target? | |||
195 | keeps the object from being freed, but that is just an accident. | 207 | keeps the object from being freed, but that is just an accident. |
196 | Possibly have and 'active' flag that is checked by the taint processor? | 208 | Possibly have and 'active' flag that is checked by the taint processor? |
197 | Parameters for physics logging should be moved from BSScene to BSParam (at least boolean ones) | 209 | Parameters for physics logging should be moved from BSScene to BSParam (at least boolean ones) |
210 | Can some of the physical wrapper classes (BulletBody, BulletWorld, BulletShape) be 'sealed'? | ||
211 | There are TOO MANY interfaces from BulletSim core to Bullet itself | ||
212 | Think of something to eliminate one or more of the layers | ||
198 | 213 | ||
199 | THREADING | 214 | THREADING |
200 | ================================================= | 215 | ================================================= |
@@ -253,3 +268,5 @@ llApplyImpulse() | |||
253 | (Resolution: tested on SL and OS. AddForce scales the force for timestep) | 268 | (Resolution: tested on SL and OS. AddForce scales the force for timestep) |
254 | llSetBuoyancy() (DONE) | 269 | llSetBuoyancy() (DONE) |
255 | (Resolution: Bullet resets object gravity when added to world. Moved set gravity) | 270 | (Resolution: Bullet resets object gravity when added to world. Moved set gravity) |
271 | Avatar density is WAY off. Compare and calibrate with what's in SL. (DONE) | ||
272 | (Resolution: set default density to 3.5 (from 60) which is closer to SL) | ||
diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index 8587a2b..8ccfda5 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs | |||
@@ -30,7 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using log4net; | 33 | using log4net; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | 35 | ||
36 | namespace OpenSim.Region.Physics.Manager | 36 | namespace OpenSim.Region.Physics.Manager |