diff options
7 files changed, 623 insertions, 315 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs index 9d8f60d..83e12ba 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs | |||
@@ -339,10 +339,10 @@ public override bool DeleteCollisionShape(BulletWorld world, BulletShape shape) | |||
339 | return BSAPICPP.DeleteCollisionShape2(worldu.ptr, shapeu.ptr); | 339 | return BSAPICPP.DeleteCollisionShape2(worldu.ptr, shapeu.ptr); |
340 | } | 340 | } |
341 | 341 | ||
342 | public override int GetBodyType(BulletBody obj) | 342 | public override CollisionObjectTypes GetBodyType(BulletBody obj) |
343 | { | 343 | { |
344 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | 344 | BulletBodyUnman bodyu = obj as BulletBodyUnman; |
345 | return BSAPICPP.GetBodyType2(bodyu.ptr); | 345 | return (CollisionObjectTypes)BSAPICPP.GetBodyType2(bodyu.ptr); |
346 | } | 346 | } |
347 | 347 | ||
348 | public override BulletBody CreateBodyFromShape(BulletWorld world, BulletShape shape, uint id, Vector3 pos, Quaternion rot) | 348 | public override BulletBody CreateBodyFromShape(BulletWorld world, BulletShape shape, uint id, Vector3 pos, Quaternion rot) |
@@ -522,9 +522,22 @@ public override void SetForceUpdateAllAabbs(BulletWorld world, bool force) | |||
522 | // btDynamicsWorld entries | 522 | // btDynamicsWorld entries |
523 | public override bool AddObjectToWorld(BulletWorld world, BulletBody obj) | 523 | public override bool AddObjectToWorld(BulletWorld world, BulletBody obj) |
524 | { | 524 | { |
525 | // Bullet resets several variables when an object is added to the world. | ||
526 | // Gravity is reset to world default depending on the static/dynamic | ||
527 | // type. Of course, the collision flags in the broadphase proxy are initialized to default. | ||
525 | BulletWorldUnman worldu = world as BulletWorldUnman; | 528 | BulletWorldUnman worldu = world as BulletWorldUnman; |
526 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | 529 | BulletBodyUnman bodyu = obj as BulletBodyUnman; |
527 | return BSAPICPP.AddObjectToWorld2(worldu.ptr, bodyu.ptr); | 530 | |
531 | Vector3 origGrav = BSAPICPP.GetGravity2(bodyu.ptr); | ||
532 | |||
533 | bool ret = BSAPICPP.AddObjectToWorld2(worldu.ptr, bodyu.ptr); | ||
534 | |||
535 | if (ret) | ||
536 | { | ||
537 | BSAPICPP.SetGravity2(bodyu.ptr, origGrav); | ||
538 | obj.ApplyCollisionMask(world.physicsScene); | ||
539 | } | ||
540 | return ret; | ||
528 | } | 541 | } |
529 | 542 | ||
530 | public override bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj) | 543 | public override bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj) |
@@ -1061,7 +1074,7 @@ public override Vector3 GetAngularFactor(BulletBody obj) | |||
1061 | return BSAPICPP.GetAngularFactor2(bodyu.ptr); | 1074 | return BSAPICPP.GetAngularFactor2(bodyu.ptr); |
1062 | } | 1075 | } |
1063 | 1076 | ||
1064 | public override bool IsInWorld(BulletBody obj) | 1077 | public override bool IsInWorld(BulletWorld world, BulletBody obj) |
1065 | { | 1078 | { |
1066 | BulletBodyUnman bodyu = obj as BulletBodyUnman; | 1079 | BulletBodyUnman bodyu = obj as BulletBodyUnman; |
1067 | return BSAPICPP.IsInWorld2(bodyu.ptr); | 1080 | return BSAPICPP.IsInWorld2(bodyu.ptr); |
@@ -1239,7 +1252,6 @@ public override void DumpPhysicsStatistics(BulletWorld world) | |||
1239 | BSAPICPP.DumpPhysicsStatistics2(worldu.ptr); | 1252 | BSAPICPP.DumpPhysicsStatistics2(worldu.ptr); |
1240 | } | 1253 | } |
1241 | 1254 | ||
1242 | |||
1243 | // ===================================================================================== | 1255 | // ===================================================================================== |
1244 | // ===================================================================================== | 1256 | // ===================================================================================== |
1245 | // ===================================================================================== | 1257 | // ===================================================================================== |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs index f70ad30..aea10ee 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIXNA.cs | |||
@@ -26,22 +26,110 @@ | |||
26 | */ | 26 | */ |
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Linq; | 29 | using System.IO; |
30 | using System.Text; | 30 | using System.Text; |
31 | 31 | ||
32 | using OpenSim.Framework; | ||
33 | |||
34 | using OpenMetaverse; | ||
35 | |||
32 | using BulletXNA; | 36 | using BulletXNA; |
33 | using BulletXNA.LinearMath; | 37 | using BulletXNA.LinearMath; |
34 | using BulletXNA.BulletCollision; | 38 | using BulletXNA.BulletCollision; |
35 | using BulletXNA.BulletDynamics; | 39 | using BulletXNA.BulletDynamics; |
36 | using BulletXNA.BulletCollision.CollisionDispatch; | 40 | using BulletXNA.BulletCollision.CollisionDispatch; |
37 | 41 | ||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Region.Physics.BulletSPlugin | 42 | namespace OpenSim.Region.Physics.BulletSPlugin |
41 | { | 43 | { |
42 | /* | ||
43 | public sealed class BSAPIXNA : BSAPITemplate | 44 | public sealed class BSAPIXNA : BSAPITemplate |
44 | { | 45 | { |
46 | private sealed class BulletWorldXNA : BulletWorld | ||
47 | { | ||
48 | public DiscreteDynamicsWorld world; | ||
49 | public BulletWorldXNA(uint id, BSScene physScene, DiscreteDynamicsWorld xx) | ||
50 | : base(id, physScene) | ||
51 | { | ||
52 | world = xx; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | private sealed class BulletBodyXNA : BulletBody | ||
57 | { | ||
58 | public CollisionObject body; | ||
59 | public RigidBody rigidBody { get { return RigidBody.Upcast(body); } } | ||
60 | |||
61 | public BulletBodyXNA(uint id, CollisionObject xx) | ||
62 | : base(id) | ||
63 | { | ||
64 | body = xx; | ||
65 | } | ||
66 | public override bool HasPhysicalBody | ||
67 | { | ||
68 | get { return body != null; } | ||
69 | } | ||
70 | public override void Clear() | ||
71 | { | ||
72 | body = null; | ||
73 | } | ||
74 | public override string AddrString | ||
75 | { | ||
76 | get { return "XNARigidBody"; } | ||
77 | } | ||
78 | } | ||
79 | |||
80 | private sealed class BulletShapeXNA : BulletShape | ||
81 | { | ||
82 | public CollisionShape shape; | ||
83 | public BulletShapeXNA(CollisionShape xx, BSPhysicsShapeType typ) | ||
84 | : base() | ||
85 | { | ||
86 | shape = xx; | ||
87 | type = typ; | ||
88 | } | ||
89 | public override bool HasPhysicalShape | ||
90 | { | ||
91 | get { return shape != null; } | ||
92 | } | ||
93 | public override void Clear() | ||
94 | { | ||
95 | shape = null; | ||
96 | } | ||
97 | public override BulletShape Clone() | ||
98 | { | ||
99 | return new BulletShapeXNA(shape, type); | ||
100 | } | ||
101 | public override bool ReferenceSame(BulletShape other) | ||
102 | { | ||
103 | BulletShapeXNA otheru = other as BulletShapeXNA; | ||
104 | return (otheru != null) && (this.shape == otheru.shape); | ||
105 | |||
106 | } | ||
107 | public override string AddrString | ||
108 | { | ||
109 | get { return "XNACollisionShape"; } | ||
110 | } | ||
111 | } | ||
112 | private sealed class BulletConstraintXNA : BulletConstraint | ||
113 | { | ||
114 | public TypedConstraint constrain; | ||
115 | public BulletConstraintXNA(TypedConstraint xx) : base() | ||
116 | { | ||
117 | constrain = xx; | ||
118 | } | ||
119 | |||
120 | public override void Clear() | ||
121 | { | ||
122 | constrain = null; | ||
123 | } | ||
124 | public override bool HasPhysicalConstraint { get { return constrain != null; } } | ||
125 | |||
126 | // Used for log messages for a unique display of the memory/object allocated to this instance | ||
127 | public override string AddrString | ||
128 | { | ||
129 | get { return "XNAConstraint"; } | ||
130 | } | ||
131 | } | ||
132 | |||
45 | private static int m_collisionsThisFrame; | 133 | private static int m_collisionsThisFrame; |
46 | private BSScene PhysicsScene { get; set; } | 134 | private BSScene PhysicsScene { get; set; } |
47 | 135 | ||
@@ -58,112 +146,135 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
58 | /// </summary> | 146 | /// </summary> |
59 | /// <param name="p"></param> | 147 | /// <param name="p"></param> |
60 | /// <param name="p_2"></param> | 148 | /// <param name="p_2"></param> |
61 | public override bool RemoveObjectFromWorld2(object pWorld, object pBody) | 149 | public override bool RemoveObjectFromWorld(BulletWorld pWorld, BulletBody pBody) |
62 | { | 150 | { |
63 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | 151 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
64 | RigidBody body = pBody as RigidBody; | 152 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
65 | world.RemoveRigidBody(body); | 153 | world.RemoveRigidBody(body); |
66 | return true; | 154 | return true; |
67 | } | 155 | } |
68 | 156 | ||
69 | public override void SetRestitution2(object pBody, float pRestitution) | 157 | public override bool AddConstraintToWorld(BulletWorld world, BulletConstraint constrain, bool disableCollisionsBetweenLinkedObjects) |
70 | { | 158 | { |
71 | RigidBody body = pBody as RigidBody; | 159 | /* TODO */ |
160 | return false; | ||
161 | } | ||
162 | |||
163 | public override bool RemoveConstraintFromWorld(BulletWorld world, BulletConstraint constrain) | ||
164 | { | ||
165 | /* TODO */ | ||
166 | return false; | ||
167 | } | ||
168 | |||
169 | public override void SetRestitution(BulletBody pBody, float pRestitution) | ||
170 | { | ||
171 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
72 | body.SetRestitution(pRestitution); | 172 | body.SetRestitution(pRestitution); |
73 | } | 173 | } |
74 | 174 | ||
75 | public override void SetMargin2(object pShape, float pMargin) | 175 | public override int GetShapeType(BulletShape pShape) |
176 | { | ||
177 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; | ||
178 | return (int)shape.GetShapeType(); | ||
179 | } | ||
180 | public override void SetMargin(BulletShape pShape, float pMargin) | ||
76 | { | 181 | { |
77 | CollisionShape shape = pShape as CollisionShape; | 182 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
78 | shape.SetMargin(pMargin); | 183 | shape.SetMargin(pMargin); |
79 | } | 184 | } |
80 | 185 | ||
81 | public override void SetLocalScaling2(object pShape, Vector3 pScale) | 186 | public override float GetMargin(BulletShape pShape) |
187 | { | ||
188 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; | ||
189 | return shape.GetMargin(); | ||
190 | } | ||
191 | |||
192 | public override void SetLocalScaling(BulletShape pShape, Vector3 pScale) | ||
82 | { | 193 | { |
83 | CollisionShape shape = pShape as CollisionShape; | 194 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
84 | IndexedVector3 vec = new IndexedVector3(pScale.X, pScale.Y, pScale.Z); | 195 | IndexedVector3 vec = new IndexedVector3(pScale.X, pScale.Y, pScale.Z); |
85 | shape.SetLocalScaling(ref vec); | 196 | shape.SetLocalScaling(ref vec); |
86 | 197 | ||
87 | } | 198 | } |
88 | 199 | ||
89 | public override void SetContactProcessingThreshold2(object pBody, float contactprocessingthreshold) | 200 | public override void SetContactProcessingThreshold(BulletBody pBody, float contactprocessingthreshold) |
90 | { | 201 | { |
91 | RigidBody body = pBody as RigidBody; | 202 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
92 | body.SetContactProcessingThreshold(contactprocessingthreshold); | 203 | body.SetContactProcessingThreshold(contactprocessingthreshold); |
93 | } | 204 | } |
94 | 205 | ||
95 | public override void SetCcdMotionThreshold2(object pBody, float pccdMotionThreashold) | 206 | public override void SetCcdMotionThreshold(BulletBody pBody, float pccdMotionThreashold) |
96 | { | 207 | { |
97 | RigidBody body = pBody as RigidBody; | 208 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
98 | body.SetCcdMotionThreshold(pccdMotionThreashold); | 209 | body.SetCcdMotionThreshold(pccdMotionThreashold); |
99 | } | 210 | } |
100 | 211 | ||
101 | public override void SetCcdSweptSphereRadius2(object pBody, float pCcdSweptSphereRadius) | 212 | public override void SetCcdSweptSphereRadius(BulletBody pBody, float pCcdSweptSphereRadius) |
102 | { | 213 | { |
103 | RigidBody body = pBody as RigidBody; | 214 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
104 | body.SetCcdSweptSphereRadius(pCcdSweptSphereRadius); | 215 | body.SetCcdSweptSphereRadius(pCcdSweptSphereRadius); |
105 | } | 216 | } |
106 | 217 | ||
107 | public override void SetAngularFactorV2(object pBody, Vector3 pAngularFactor) | 218 | public override void SetAngularFactorV(BulletBody pBody, Vector3 pAngularFactor) |
108 | { | 219 | { |
109 | RigidBody body = pBody as RigidBody; | 220 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
110 | body.SetAngularFactor(new IndexedVector3(pAngularFactor.X, pAngularFactor.Y, pAngularFactor.Z)); | 221 | body.SetAngularFactor(new IndexedVector3(pAngularFactor.X, pAngularFactor.Y, pAngularFactor.Z)); |
111 | } | 222 | } |
112 | 223 | ||
113 | public override CollisionFlags AddToCollisionFlags2(object pBody, CollisionFlags pcollisionFlags) | 224 | public override CollisionFlags AddToCollisionFlags(BulletBody pBody, CollisionFlags pcollisionFlags) |
114 | { | 225 | { |
115 | CollisionObject body = pBody as CollisionObject; | 226 | CollisionObject body = ((BulletBodyXNA)pBody).body; |
116 | CollisionFlags existingcollisionFlags = (CollisionFlags)(uint)body.GetCollisionFlags(); | 227 | CollisionFlags existingcollisionFlags = (CollisionFlags)(uint)body.GetCollisionFlags(); |
117 | existingcollisionFlags |= pcollisionFlags; | 228 | existingcollisionFlags |= pcollisionFlags; |
118 | body.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags)(uint)existingcollisionFlags); | 229 | body.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags)(uint)existingcollisionFlags); |
119 | return (CollisionFlags) (uint) existingcollisionFlags; | 230 | return (CollisionFlags) (uint) existingcollisionFlags; |
120 | } | 231 | } |
121 | 232 | ||
122 | public override void AddObjectToWorld2(object pWorld, object pBody) | 233 | public override bool AddObjectToWorld(BulletWorld pWorld, BulletBody pBody) |
123 | { | 234 | { |
124 | RigidBody body = pBody as RigidBody; | 235 | // Bullet resets several variables when an object is added to the world. In particular, |
125 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | 236 | // BulletXNA resets position and rotation. Gravity is also reset depending on the static/dynamic |
237 | // type. Of course, the collision flags in the broadphase proxy are initialized to default. | ||
238 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; | ||
239 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
240 | |||
241 | IndexedMatrix origPos = body.GetWorldTransform(); | ||
242 | IndexedVector3 origGrav = body.GetGravity(); | ||
243 | |||
126 | //if (!(body.GetCollisionShape().GetShapeType() == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE && body.GetCollisionShape().GetShapeType() == BroadphaseNativeTypes.TERRAIN_SHAPE_PROXYTYPE)) | 244 | //if (!(body.GetCollisionShape().GetShapeType() == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE && body.GetCollisionShape().GetShapeType() == BroadphaseNativeTypes.TERRAIN_SHAPE_PROXYTYPE)) |
127 | 245 | ||
128 | world.AddRigidBody(body); | 246 | world.AddRigidBody(body); |
129 | 247 | ||
130 | //if (body.GetBroadphaseHandle() != null) | 248 | body.SetWorldTransform(origPos); |
131 | // world.UpdateSingleAabb(body); | 249 | body.SetGravity(origGrav); |
132 | } | ||
133 | 250 | ||
134 | public override void AddObjectToWorld2(object pWorld, object pBody, Vector3 _position, Quaternion _orientation) | 251 | pBody.ApplyCollisionMask(pWorld.physicsScene); |
135 | { | ||
136 | RigidBody body = pBody as RigidBody; | ||
137 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | ||
138 | //if (!(body.GetCollisionShape().GetShapeType() == BroadphaseNativeTypes.STATIC_PLANE_PROXYTYPE && body.GetCollisionShape().GetShapeType() == BroadphaseNativeTypes.TERRAIN_SHAPE_PROXYTYPE)) | ||
139 | 252 | ||
140 | world.AddRigidBody(body); | ||
141 | IndexedVector3 vposition = new IndexedVector3(_position.X, _position.Y, _position.Z); | ||
142 | IndexedQuaternion vquaternion = new IndexedQuaternion(_orientation.X, _orientation.Y, _orientation.Z, | ||
143 | _orientation.W); | ||
144 | IndexedMatrix mat = IndexedMatrix.CreateFromQuaternion(vquaternion); | ||
145 | mat._origin = vposition; | ||
146 | body.SetWorldTransform(mat); | ||
147 | //if (body.GetBroadphaseHandle() != null) | 253 | //if (body.GetBroadphaseHandle() != null) |
148 | // world.UpdateSingleAabb(body); | 254 | // world.UpdateSingleAabb(body); |
255 | return true; | ||
149 | } | 256 | } |
150 | 257 | ||
151 | public override void ForceActivationState2(object pBody, ActivationState pActivationState) | 258 | public override void ForceActivationState(BulletBody pBody, ActivationState pActivationState) |
152 | { | 259 | { |
153 | CollisionObject body = pBody as CollisionObject; | 260 | CollisionObject body = ((BulletBodyXNA)pBody).body; |
154 | body.ForceActivationState((BulletXNA.BulletCollision.ActivationState)(uint)pActivationState); | 261 | body.ForceActivationState((BulletXNA.BulletCollision.ActivationState)(uint)pActivationState); |
155 | } | 262 | } |
156 | 263 | ||
157 | public override void UpdateSingleAabb2(object pWorld, object pBody) | 264 | public override void UpdateSingleAabb(BulletWorld pWorld, BulletBody pBody) |
158 | { | 265 | { |
159 | CollisionObject body = pBody as CollisionObject; | 266 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
160 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | 267 | CollisionObject body = ((BulletBodyXNA)pBody).body; |
161 | world.UpdateSingleAabb(body); | 268 | world.UpdateSingleAabb(body); |
162 | } | 269 | } |
163 | 270 | ||
164 | public override bool SetCollisionGroupMask2(object pBody, uint pGroup, uint pMask) | 271 | public override void UpdateAabbs(BulletWorld world) { /* TODO */ } |
272 | public override bool GetForceUpdateAllAabbs(BulletWorld world) { /* TODO */ return false; } | ||
273 | public override void SetForceUpdateAllAabbs(BulletWorld world, bool force) { /* TODO */ } | ||
274 | |||
275 | public override bool SetCollisionGroupMask(BulletBody pBody, uint pGroup, uint pMask) | ||
165 | { | 276 | { |
166 | RigidBody body = pBody as RigidBody; | 277 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
167 | body.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup; | 278 | body.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup; |
168 | body.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup; | 279 | body.GetBroadphaseHandle().m_collisionFilterGroup = (BulletXNA.BulletCollision.CollisionFilterGroups) pGroup; |
169 | if ((uint) body.GetBroadphaseHandle().m_collisionFilterGroup == 0) | 280 | if ((uint) body.GetBroadphaseHandle().m_collisionFilterGroup == 0) |
@@ -171,9 +282,9 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
171 | return true; | 282 | return true; |
172 | } | 283 | } |
173 | 284 | ||
174 | public override void ClearAllForces2(object pBody) | 285 | public override void ClearAllForces(BulletBody pBody) |
175 | { | 286 | { |
176 | CollisionObject body = pBody as CollisionObject; | 287 | CollisionObject body = ((BulletBodyXNA)pBody).body; |
177 | IndexedVector3 zeroVector = new IndexedVector3(0, 0, 0); | 288 | IndexedVector3 zeroVector = new IndexedVector3(0, 0, 0); |
178 | body.SetInterpolationLinearVelocity(ref zeroVector); | 289 | body.SetInterpolationLinearVelocity(ref zeroVector); |
179 | body.SetInterpolationAngularVelocity(ref zeroVector); | 290 | body.SetInterpolationAngularVelocity(ref zeroVector); |
@@ -190,29 +301,67 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
190 | } | 301 | } |
191 | } | 302 | } |
192 | 303 | ||
193 | public override void SetInterpolationAngularVelocity2(object pBody, Vector3 pVector3) | 304 | public override void SetInterpolationAngularVelocity(BulletBody pBody, Vector3 pVector3) |
194 | { | 305 | { |
195 | RigidBody body = pBody as RigidBody; | 306 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
196 | IndexedVector3 vec = new IndexedVector3(pVector3.X, pVector3.Y, pVector3.Z); | 307 | IndexedVector3 vec = new IndexedVector3(pVector3.X, pVector3.Y, pVector3.Z); |
197 | body.SetInterpolationAngularVelocity(ref vec); | 308 | body.SetInterpolationAngularVelocity(ref vec); |
198 | } | 309 | } |
199 | 310 | ||
200 | public override void SetAngularVelocity2(object pBody, Vector3 pVector3) | 311 | public override void SetAngularVelocity(BulletBody pBody, Vector3 pVector3) |
201 | { | 312 | { |
202 | RigidBody body = pBody as RigidBody; | 313 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
203 | IndexedVector3 vec = new IndexedVector3(pVector3.X, pVector3.Y, pVector3.Z); | 314 | IndexedVector3 vec = new IndexedVector3(pVector3.X, pVector3.Y, pVector3.Z); |
204 | body.SetAngularVelocity(ref vec); | 315 | body.SetAngularVelocity(ref vec); |
205 | } | 316 | } |
317 | public override Vector3 GetTotalForce(BulletBody pBody) | ||
318 | { | ||
319 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
320 | IndexedVector3 iv3 = body.GetTotalForce(); | ||
321 | return new Vector3(iv3.X, iv3.Y, iv3.Z); | ||
322 | } | ||
323 | public override Vector3 GetTotalTorque(BulletBody pBody) | ||
324 | { | ||
325 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
326 | IndexedVector3 iv3 = body.GetTotalTorque(); | ||
327 | return new Vector3(iv3.X, iv3.Y, iv3.Z); | ||
328 | } | ||
329 | public override Vector3 GetInvInertiaDiagLocal(BulletBody pBody) | ||
330 | { | ||
331 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
332 | IndexedVector3 iv3 = body.GetInvInertiaDiagLocal(); | ||
333 | return new Vector3(iv3.X, iv3.Y, iv3.Z); | ||
334 | } | ||
335 | public override void SetInvInertiaDiagLocal(BulletBody pBody, Vector3 inert) | ||
336 | { | ||
337 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
338 | IndexedVector3 iv3 = new IndexedVector3(inert.X, inert.Y, inert.Z); | ||
339 | body.SetInvInertiaDiagLocal(ref iv3); | ||
340 | } | ||
341 | public override void ApplyForce(BulletBody pBody, Vector3 force, Vector3 pos) | ||
342 | { | ||
343 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
344 | IndexedVector3 forceiv3 = new IndexedVector3(force.X, force.Y, force.Z); | ||
345 | IndexedVector3 posiv3 = new IndexedVector3(pos.X, pos.Y, pos.Z); | ||
346 | body.ApplyForce(ref forceiv3, ref posiv3); | ||
347 | } | ||
348 | public override void ApplyImpulse(BulletBody pBody, Vector3 imp, Vector3 pos) | ||
349 | { | ||
350 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
351 | IndexedVector3 impiv3 = new IndexedVector3(imp.X, imp.Y, imp.Z); | ||
352 | IndexedVector3 posiv3 = new IndexedVector3(pos.X, pos.Y, pos.Z); | ||
353 | body.ApplyImpulse(ref impiv3, ref posiv3); | ||
354 | } | ||
206 | 355 | ||
207 | public override void ClearForces2(object pBody) | 356 | public override void ClearForces(BulletBody pBody) |
208 | { | 357 | { |
209 | RigidBody body = pBody as RigidBody; | 358 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
210 | body.ClearForces(); | 359 | body.ClearForces(); |
211 | } | 360 | } |
212 | 361 | ||
213 | public override void SetTranslation2(object pBody, Vector3 _position, Quaternion _orientation) | 362 | public override void SetTranslation(BulletBody pBody, Vector3 _position, Quaternion _orientation) |
214 | { | 363 | { |
215 | RigidBody body = pBody as RigidBody; | 364 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
216 | IndexedVector3 vposition = new IndexedVector3(_position.X, _position.Y, _position.Z); | 365 | IndexedVector3 vposition = new IndexedVector3(_position.X, _position.Y, _position.Z); |
217 | IndexedQuaternion vquaternion = new IndexedQuaternion(_orientation.X, _orientation.Y, _orientation.Z, | 366 | IndexedQuaternion vquaternion = new IndexedQuaternion(_orientation.X, _orientation.Y, _orientation.Z, |
218 | _orientation.W); | 367 | _orientation.W); |
@@ -222,90 +371,98 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
222 | 371 | ||
223 | } | 372 | } |
224 | 373 | ||
225 | public override Vector3 GetPosition2(object pBody) | 374 | public override Vector3 GetPosition(BulletBody pBody) |
226 | { | 375 | { |
227 | RigidBody body = pBody as RigidBody; | 376 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
228 | IndexedVector3 pos = body.GetInterpolationWorldTransform()._origin; | 377 | IndexedVector3 pos = body.GetInterpolationWorldTransform()._origin; |
229 | return new Vector3(pos.X, pos.Y, pos.Z); | 378 | return new Vector3(pos.X, pos.Y, pos.Z); |
230 | } | 379 | } |
231 | 380 | ||
232 | public override Vector3 CalculateLocalInertia2(object pShape, float pphysMass) | 381 | public override Vector3 CalculateLocalInertia(BulletShape pShape, float pphysMass) |
233 | { | 382 | { |
234 | CollisionShape shape = pShape as CollisionShape; | 383 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
235 | IndexedVector3 inertia = IndexedVector3.Zero; | 384 | IndexedVector3 inertia = IndexedVector3.Zero; |
236 | shape.CalculateLocalInertia(pphysMass, out inertia); | 385 | shape.CalculateLocalInertia(pphysMass, out inertia); |
237 | return new Vector3(inertia.X, inertia.Y, inertia.Z); | 386 | return new Vector3(inertia.X, inertia.Y, inertia.Z); |
238 | } | 387 | } |
239 | 388 | ||
240 | public override void SetMassProps2(object pBody, float pphysMass, Vector3 plocalInertia) | 389 | public override void SetMassProps(BulletBody pBody, float pphysMass, Vector3 plocalInertia) |
241 | { | 390 | { |
242 | RigidBody body = pBody as RigidBody; | 391 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
243 | IndexedVector3 inertia = new IndexedVector3(plocalInertia.X, plocalInertia.Y, plocalInertia.Z); | 392 | IndexedVector3 inertia = new IndexedVector3(plocalInertia.X, plocalInertia.Y, plocalInertia.Z); |
244 | body.SetMassProps(pphysMass, inertia); | 393 | body.SetMassProps(pphysMass, inertia); |
245 | } | 394 | } |
246 | 395 | ||
247 | 396 | ||
248 | public override void SetObjectForce2(object pBody, Vector3 _force) | 397 | public override void SetObjectForce(BulletBody pBody, Vector3 _force) |
249 | { | 398 | { |
250 | RigidBody body = pBody as RigidBody; | 399 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
251 | IndexedVector3 force = new IndexedVector3(_force.X, _force.Y, _force.Z); | 400 | IndexedVector3 force = new IndexedVector3(_force.X, _force.Y, _force.Z); |
252 | body.SetTotalForce(ref force); | 401 | body.SetTotalForce(ref force); |
253 | } | 402 | } |
254 | 403 | ||
255 | public override void SetFriction2(object pBody, float _currentFriction) | 404 | public override void SetFriction(BulletBody pBody, float _currentFriction) |
256 | { | 405 | { |
257 | RigidBody body = pBody as RigidBody; | 406 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
258 | body.SetFriction(_currentFriction); | 407 | body.SetFriction(_currentFriction); |
259 | } | 408 | } |
260 | 409 | ||
261 | public override void SetLinearVelocity2(object pBody, Vector3 _velocity) | 410 | public override void SetLinearVelocity(BulletBody pBody, Vector3 _velocity) |
262 | { | 411 | { |
263 | RigidBody body = pBody as RigidBody; | 412 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
264 | IndexedVector3 velocity = new IndexedVector3(_velocity.X, _velocity.Y, _velocity.Z); | 413 | IndexedVector3 velocity = new IndexedVector3(_velocity.X, _velocity.Y, _velocity.Z); |
265 | body.SetLinearVelocity(velocity); | 414 | body.SetLinearVelocity(velocity); |
266 | } | 415 | } |
267 | 416 | ||
268 | public override void Activate2(object pBody, bool pforceactivation) | 417 | public override void Activate(BulletBody pBody, bool pforceactivation) |
269 | { | 418 | { |
270 | RigidBody body = pBody as RigidBody; | 419 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
271 | body.Activate(pforceactivation); | 420 | body.Activate(pforceactivation); |
272 | 421 | ||
273 | } | 422 | } |
274 | 423 | ||
275 | public override Quaternion GetOrientation2(object pBody) | 424 | public override Quaternion GetOrientation(BulletBody pBody) |
276 | { | 425 | { |
277 | RigidBody body = pBody as RigidBody; | 426 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
278 | IndexedQuaternion mat = body.GetInterpolationWorldTransform().GetRotation(); | 427 | IndexedQuaternion mat = body.GetInterpolationWorldTransform().GetRotation(); |
279 | return new Quaternion(mat.X, mat.Y, mat.Z, mat.W); | 428 | return new Quaternion(mat.X, mat.Y, mat.Z, mat.W); |
280 | } | 429 | } |
281 | 430 | ||
282 | public override CollisionFlags RemoveFromCollisionFlags2(object pBody, CollisionFlags pcollisionFlags) | 431 | public override CollisionFlags RemoveFromCollisionFlags(BulletBody pBody, CollisionFlags pcollisionFlags) |
283 | { | 432 | { |
284 | RigidBody body = pBody as RigidBody; | 433 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
285 | CollisionFlags existingcollisionFlags = (CollisionFlags)(uint)body.GetCollisionFlags(); | 434 | CollisionFlags existingcollisionFlags = (CollisionFlags)(uint)body.GetCollisionFlags(); |
286 | existingcollisionFlags &= ~pcollisionFlags; | 435 | existingcollisionFlags &= ~pcollisionFlags; |
287 | body.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags)(uint)existingcollisionFlags); | 436 | body.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags)(uint)existingcollisionFlags); |
288 | return (CollisionFlags)(uint)existingcollisionFlags; | 437 | return (CollisionFlags)(uint)existingcollisionFlags; |
289 | } | 438 | } |
290 | 439 | ||
291 | public override void SetGravity2(object pBody, Vector3 pGravity) | 440 | public override float GetCcdMotionThreshold(BulletBody obj) { /* TODO */ return 0f; } |
441 | |||
442 | public override float GetCcdSweptSphereRadius(BulletBody obj) { /* TODO */ return 0f; } | ||
443 | |||
444 | public override IntPtr GetUserPointer(BulletBody obj) { /* TODO */ return IntPtr.Zero; } | ||
445 | |||
446 | public override void SetUserPointer(BulletBody obj, IntPtr val) { /* TODO */ } | ||
447 | |||
448 | public override void SetGravity(BulletBody pBody, Vector3 pGravity) | ||
292 | { | 449 | { |
293 | RigidBody body = pBody as RigidBody; | 450 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
294 | IndexedVector3 gravity = new IndexedVector3(pGravity.X, pGravity.Y, pGravity.Z); | 451 | IndexedVector3 gravity = new IndexedVector3(pGravity.X, pGravity.Y, pGravity.Z); |
295 | body.SetGravity(gravity); | 452 | body.SetGravity(gravity); |
296 | } | 453 | } |
297 | 454 | ||
298 | public override bool DestroyConstraint2(object pBody, object pConstraint) | 455 | public override bool DestroyConstraint(BulletWorld pWorld, BulletConstraint pConstraint) |
299 | { | 456 | { |
300 | RigidBody body = pBody as RigidBody; | 457 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
301 | TypedConstraint constraint = pConstraint as TypedConstraint; | 458 | TypedConstraint constraint = ((BulletConstraintXNA)pConstraint).constrain; |
302 | body.RemoveConstraintRef(constraint); | 459 | world.RemoveConstraint(constraint); |
303 | return true; | 460 | return true; |
304 | } | 461 | } |
305 | 462 | ||
306 | public override bool SetLinearLimits2(object pConstraint, Vector3 low, Vector3 high) | 463 | public override bool SetLinearLimits(BulletConstraint pConstraint, Vector3 low, Vector3 high) |
307 | { | 464 | { |
308 | Generic6DofConstraint constraint = pConstraint as Generic6DofConstraint; | 465 | Generic6DofConstraint constraint = ((BulletConstraintXNA)pConstraint).constrain as Generic6DofConstraint; |
309 | IndexedVector3 lowlimit = new IndexedVector3(low.X, low.Y, low.Z); | 466 | IndexedVector3 lowlimit = new IndexedVector3(low.X, low.Y, low.Z); |
310 | IndexedVector3 highlimit = new IndexedVector3(high.X, high.Y, high.Z); | 467 | IndexedVector3 highlimit = new IndexedVector3(high.X, high.Y, high.Z); |
311 | constraint.SetLinearLowerLimit(lowlimit); | 468 | constraint.SetLinearLowerLimit(lowlimit); |
@@ -313,9 +470,9 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
313 | return true; | 470 | return true; |
314 | } | 471 | } |
315 | 472 | ||
316 | public override bool SetAngularLimits2(object pConstraint, Vector3 low, Vector3 high) | 473 | public override bool SetAngularLimits(BulletConstraint pConstraint, Vector3 low, Vector3 high) |
317 | { | 474 | { |
318 | Generic6DofConstraint constraint = pConstraint as Generic6DofConstraint; | 475 | Generic6DofConstraint constraint = ((BulletConstraintXNA)pConstraint).constrain as Generic6DofConstraint; |
319 | IndexedVector3 lowlimit = new IndexedVector3(low.X, low.Y, low.Z); | 476 | IndexedVector3 lowlimit = new IndexedVector3(low.X, low.Y, low.Z); |
320 | IndexedVector3 highlimit = new IndexedVector3(high.X, high.Y, high.Z); | 477 | IndexedVector3 highlimit = new IndexedVector3(high.X, high.Y, high.Z); |
321 | constraint.SetAngularLowerLimit(lowlimit); | 478 | constraint.SetAngularLowerLimit(lowlimit); |
@@ -323,32 +480,33 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
323 | return true; | 480 | return true; |
324 | } | 481 | } |
325 | 482 | ||
326 | public override void SetConstraintNumSolverIterations2(object pConstraint, float cnt) | 483 | public override void SetConstraintNumSolverIterations(BulletConstraint pConstraint, float cnt) |
327 | { | 484 | { |
328 | Generic6DofConstraint constraint = pConstraint as Generic6DofConstraint; | 485 | Generic6DofConstraint constraint = ((BulletConstraintXNA)pConstraint).constrain as Generic6DofConstraint; |
329 | constraint.SetOverrideNumSolverIterations((int)cnt); | 486 | constraint.SetOverrideNumSolverIterations((int)cnt); |
330 | } | 487 | } |
331 | 488 | ||
332 | public override void CalculateTransforms2(object pConstraint) | 489 | public override bool CalculateTransforms(BulletConstraint pConstraint) |
333 | { | 490 | { |
334 | Generic6DofConstraint constraint = pConstraint as Generic6DofConstraint; | 491 | Generic6DofConstraint constraint = ((BulletConstraintXNA)pConstraint).constrain as Generic6DofConstraint; |
335 | constraint.CalculateTransforms(); | 492 | constraint.CalculateTransforms(); |
493 | return true; | ||
336 | } | 494 | } |
337 | 495 | ||
338 | public override void SetConstraintEnable2(object pConstraint, float p_2) | 496 | public override void SetConstraintEnable(BulletConstraint pConstraint, float p_2) |
339 | { | 497 | { |
340 | Generic6DofConstraint constraint = pConstraint as Generic6DofConstraint; | 498 | Generic6DofConstraint constraint = ((BulletConstraintXNA)pConstraint).constrain as Generic6DofConstraint; |
341 | constraint.SetEnabled((p_2 == 0) ? false : true); | 499 | constraint.SetEnabled((p_2 == 0) ? false : true); |
342 | } | 500 | } |
343 | 501 | ||
344 | 502 | ||
345 | //BulletSimAPI.Create6DofConstraint2(m_world.ptr, m_body1.ptr, m_body2.ptr,frame1, frame1rot,frame2, frame2rot,useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); | 503 | //BulletSimAPI.Create6DofConstraint(m_world.ptr, m_body1.ptr, m_body2.ptr,frame1, frame1rot,frame2, frame2rot,useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); |
346 | public override object Create6DofConstraint2(object pWorld, object pBody1, object pBody2, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies) | 504 | public override BulletConstraint Create6DofConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies) |
347 | 505 | ||
348 | { | 506 | { |
349 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | 507 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
350 | RigidBody body1 = pBody1 as RigidBody; | 508 | RigidBody body1 = ((BulletBodyXNA)pBody1).rigidBody; |
351 | RigidBody body2 = pBody2 as RigidBody; | 509 | RigidBody body2 = ((BulletBodyXNA)pBody2).rigidBody; |
352 | IndexedVector3 frame1v = new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z); | 510 | IndexedVector3 frame1v = new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z); |
353 | IndexedQuaternion frame1rot = new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W); | 511 | IndexedQuaternion frame1rot = new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W); |
354 | IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot); | 512 | IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot); |
@@ -364,7 +522,7 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
364 | consttr.CalculateTransforms(); | 522 | consttr.CalculateTransforms(); |
365 | world.AddConstraint(consttr,pdisableCollisionsBetweenLinkedBodies); | 523 | world.AddConstraint(consttr,pdisableCollisionsBetweenLinkedBodies); |
366 | 524 | ||
367 | return consttr; | 525 | return new BulletConstraintXNA(consttr); |
368 | } | 526 | } |
369 | 527 | ||
370 | 528 | ||
@@ -378,11 +536,11 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
378 | /// <param name="puseLinearReferenceFrameA"></param> | 536 | /// <param name="puseLinearReferenceFrameA"></param> |
379 | /// <param name="pdisableCollisionsBetweenLinkedBodies"></param> | 537 | /// <param name="pdisableCollisionsBetweenLinkedBodies"></param> |
380 | /// <returns></returns> | 538 | /// <returns></returns> |
381 | public override object Create6DofConstraintToPoint2(object pWorld, object pBody1, object pBody2, Vector3 pjoinPoint, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies) | 539 | public override BulletConstraint Create6DofConstraintToPoint(BulletWorld pWorld, BulletBody pBody1, BulletBody pBody2, Vector3 pjoinPoint, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies) |
382 | { | 540 | { |
383 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | 541 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
384 | RigidBody body1 = pBody1 as RigidBody; | 542 | RigidBody body1 = ((BulletBodyXNA)pBody1).rigidBody; |
385 | RigidBody body2 = pBody2 as RigidBody; | 543 | RigidBody body2 = ((BulletBodyXNA)pBody2).rigidBody; |
386 | IndexedMatrix frame1 = new IndexedMatrix(IndexedBasisMatrix.Identity, new IndexedVector3(0, 0, 0)); | 544 | IndexedMatrix frame1 = new IndexedMatrix(IndexedBasisMatrix.Identity, new IndexedVector3(0, 0, 0)); |
387 | IndexedMatrix frame2 = new IndexedMatrix(IndexedBasisMatrix.Identity, new IndexedVector3(0, 0, 0)); | 545 | IndexedMatrix frame2 = new IndexedMatrix(IndexedBasisMatrix.Identity, new IndexedVector3(0, 0, 0)); |
388 | 546 | ||
@@ -396,12 +554,12 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
396 | consttr.CalculateTransforms(); | 554 | consttr.CalculateTransforms(); |
397 | world.AddConstraint(consttr, pdisableCollisionsBetweenLinkedBodies); | 555 | world.AddConstraint(consttr, pdisableCollisionsBetweenLinkedBodies); |
398 | 556 | ||
399 | return consttr; | 557 | return new BulletConstraintXNA(consttr); |
400 | } | 558 | } |
401 | //SetFrames2(m_constraint.ptr, frameA, frameArot, frameB, frameBrot); | 559 | //SetFrames(m_constraint.ptr, frameA, frameArot, frameB, frameBrot); |
402 | public override void SetFrames2(object pConstraint, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot) | 560 | public override bool SetFrames(BulletConstraint pConstraint, Vector3 pframe1, Quaternion pframe1rot, Vector3 pframe2, Quaternion pframe2rot) |
403 | { | 561 | { |
404 | Generic6DofConstraint constraint = pConstraint as Generic6DofConstraint; | 562 | Generic6DofConstraint constraint = ((BulletConstraintXNA)pConstraint).constrain as Generic6DofConstraint; |
405 | IndexedVector3 frame1v = new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z); | 563 | IndexedVector3 frame1v = new IndexedVector3(pframe1.X, pframe1.Y, pframe1.Z); |
406 | IndexedQuaternion frame1rot = new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W); | 564 | IndexedQuaternion frame1rot = new IndexedQuaternion(pframe1rot.X, pframe1rot.Y, pframe1rot.Z, pframe1rot.W); |
407 | IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot); | 565 | IndexedMatrix frame1 = IndexedMatrix.CreateFromQuaternion(frame1rot); |
@@ -412,163 +570,279 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
412 | IndexedMatrix frame2 = IndexedMatrix.CreateFromQuaternion(frame2rot); | 570 | IndexedMatrix frame2 = IndexedMatrix.CreateFromQuaternion(frame2rot); |
413 | frame2._origin = frame1v; | 571 | frame2._origin = frame1v; |
414 | constraint.SetFrames(ref frame1, ref frame2); | 572 | constraint.SetFrames(ref frame1, ref frame2); |
573 | return true; | ||
415 | } | 574 | } |
416 | 575 | ||
576 | public override Vector3 GetLinearVelocity(BulletBody pBody) | ||
577 | { | ||
578 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
579 | IndexedVector3 iv3 = body.GetLinearVelocity(); | ||
580 | return new Vector3(iv3.X, iv3.Y, iv3.Z); | ||
581 | } | ||
582 | public override Vector3 GetAngularVelocity(BulletBody pBody) | ||
583 | { | ||
584 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
585 | IndexedVector3 iv3 = body.GetAngularVelocity(); | ||
586 | return new Vector3(iv3.X, iv3.Y, iv3.Z); | ||
587 | } | ||
588 | public override Vector3 GetVelocityInLocalPoint(BulletBody pBody, Vector3 pos) | ||
589 | { | ||
590 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
591 | IndexedVector3 posiv3 = new IndexedVector3(pos.X, pos.Y, pos.Z); | ||
592 | IndexedVector3 iv3 = body.GetVelocityInLocalPoint(ref posiv3); | ||
593 | return new Vector3(iv3.X, iv3.Y, iv3.Z); | ||
594 | } | ||
595 | public override void Translate(BulletBody pBody, Vector3 trans) | ||
596 | { | ||
597 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
598 | } | ||
599 | public override void UpdateDeactivation(BulletBody pBody, float timeStep) | ||
600 | { | ||
601 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
602 | body.UpdateDeactivation(timeStep); | ||
603 | } | ||
417 | 604 | ||
418 | 605 | public override bool WantsSleeping(BulletBody pBody) | |
606 | { | ||
607 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
608 | return body.WantsSleeping(); | ||
609 | } | ||
610 | |||
611 | public override void SetAngularFactor(BulletBody pBody, float factor) | ||
612 | { | ||
613 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
614 | body.SetAngularFactor(factor); | ||
615 | } | ||
616 | |||
617 | public override Vector3 GetAngularFactor(BulletBody pBody) | ||
618 | { | ||
619 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
620 | IndexedVector3 iv3 = body.GetAngularFactor(); | ||
621 | return new Vector3(iv3.X, iv3.Y, iv3.Z); | ||
622 | } | ||
623 | |||
624 | public override bool IsInWorld(BulletWorld pWorld, BulletBody pBody) | ||
625 | { | ||
626 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; | ||
627 | CollisionObject body = ((BulletBodyXNA)pBody).body; | ||
628 | return world.IsInWorld(body); | ||
629 | } | ||
630 | |||
631 | public override void AddConstraintRef(BulletBody pBody, BulletConstraint pConstrain) | ||
632 | { | ||
633 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
634 | TypedConstraint constrain = ((BulletConstraintXNA)pConstrain).constrain; | ||
635 | body.AddConstraintRef(constrain); | ||
636 | } | ||
637 | |||
638 | public override void RemoveConstraintRef(BulletBody pBody, BulletConstraint pConstrain) | ||
639 | { | ||
640 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
641 | TypedConstraint constrain = ((BulletConstraintXNA)pConstrain).constrain; | ||
642 | body.RemoveConstraintRef(constrain); | ||
643 | } | ||
644 | |||
645 | public override BulletConstraint GetConstraintRef(BulletBody pBody, int index) | ||
646 | { | ||
647 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; | ||
648 | return new BulletConstraintXNA(body.GetConstraintRef(index)); | ||
649 | } | ||
419 | 650 | ||
420 | public override bool IsInWorld2(object pWorld, object pShapeObj) | 651 | public override int GetNumConstraintRefs(BulletBody pBody) |
421 | { | 652 | { |
422 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | 653 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
423 | CollisionObject shape = pShapeObj as CollisionObject; | 654 | return body.GetNumConstraintRefs(); |
424 | return world.IsInWorld(shape); | ||
425 | } | 655 | } |
426 | 656 | ||
427 | public override void SetInterpolationLinearVelocity2(object pBody, Vector3 VehicleVelocity) | 657 | public override void SetInterpolationLinearVelocity(BulletBody pBody, Vector3 VehicleVelocity) |
428 | { | 658 | { |
429 | RigidBody body = pBody as RigidBody; | 659 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
430 | IndexedVector3 velocity = new IndexedVector3(VehicleVelocity.X, VehicleVelocity.Y, VehicleVelocity.Z); | 660 | IndexedVector3 velocity = new IndexedVector3(VehicleVelocity.X, VehicleVelocity.Y, VehicleVelocity.Z); |
431 | body.SetInterpolationLinearVelocity(ref velocity); | 661 | body.SetInterpolationLinearVelocity(ref velocity); |
432 | } | 662 | } |
433 | 663 | ||
434 | public override bool UseFrameOffset2(object pConstraint, float onOff) | 664 | public override bool UseFrameOffset(BulletConstraint pConstraint, float onOff) |
435 | { | 665 | { |
436 | Generic6DofConstraint constraint = pConstraint as Generic6DofConstraint; | 666 | Generic6DofConstraint constraint = ((BulletConstraintXNA)pConstraint).constrain as Generic6DofConstraint; |
437 | constraint.SetUseFrameOffset((onOff == 0) ? false : true); | 667 | constraint.SetUseFrameOffset((onOff == 0) ? false : true); |
438 | return true; | 668 | return true; |
439 | } | 669 | } |
440 | //SetBreakingImpulseThreshold2(m_constraint.ptr, threshold); | 670 | //SetBreakingImpulseThreshold(m_constraint.ptr, threshold); |
441 | public override bool SetBreakingImpulseThreshold2(object pConstraint, float threshold) | 671 | public override bool SetBreakingImpulseThreshold(BulletConstraint pConstraint, float threshold) |
442 | { | 672 | { |
443 | Generic6DofConstraint constraint = pConstraint as Generic6DofConstraint; | 673 | Generic6DofConstraint constraint = ((BulletConstraintXNA)pConstraint).constrain as Generic6DofConstraint; |
444 | constraint.SetBreakingImpulseThreshold(threshold); | 674 | constraint.SetBreakingImpulseThreshold(threshold); |
445 | return true; | 675 | return true; |
446 | } | 676 | } |
447 | //BulletSimAPI.SetAngularDamping2(Prim.PhysBody.ptr, angularDamping); | 677 | //BulletSimAPI.SetAngularDamping(Prim.PhysBody.ptr, angularDamping); |
448 | public override void SetAngularDamping2(object pBody, float angularDamping) | 678 | public override void SetAngularDamping(BulletBody pBody, float angularDamping) |
449 | { | 679 | { |
450 | RigidBody body = pBody as RigidBody; | 680 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
451 | float lineardamping = body.GetLinearDamping(); | 681 | float lineardamping = body.GetLinearDamping(); |
452 | body.SetDamping(lineardamping, angularDamping); | 682 | body.SetDamping(lineardamping, angularDamping); |
453 | 683 | ||
454 | } | 684 | } |
455 | 685 | ||
456 | public override void UpdateInertiaTensor2(object pBody) | 686 | public override void UpdateInertiaTensor(BulletBody pBody) |
457 | { | 687 | { |
458 | RigidBody body = pBody as RigidBody; | 688 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
459 | body.UpdateInertiaTensor(); | 689 | body.UpdateInertiaTensor(); |
460 | } | 690 | } |
461 | 691 | ||
462 | public override void RecalculateCompoundShapeLocalAabb2( object pCompoundShape) | 692 | public override void RecalculateCompoundShapeLocalAabb(BulletShape pCompoundShape) |
463 | { | 693 | { |
464 | 694 | CompoundShape shape = ((BulletShapeXNA)pCompoundShape).shape as CompoundShape; | |
465 | CompoundShape shape = pCompoundShape as CompoundShape; | ||
466 | shape.RecalculateLocalAabb(); | 695 | shape.RecalculateLocalAabb(); |
467 | } | 696 | } |
468 | 697 | ||
469 | //BulletSimAPI.GetCollisionFlags2(PhysBody.ptr) | 698 | //BulletSimAPI.GetCollisionFlags(PhysBody.ptr) |
470 | public override CollisionFlags GetCollisionFlags2(object pBody) | 699 | public override CollisionFlags GetCollisionFlags(BulletBody pBody) |
471 | { | 700 | { |
472 | RigidBody body = pBody as RigidBody; | 701 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
473 | uint flags = (uint)body.GetCollisionFlags(); | 702 | uint flags = (uint)body.GetCollisionFlags(); |
474 | return (CollisionFlags) flags; | 703 | return (CollisionFlags) flags; |
475 | } | 704 | } |
476 | 705 | ||
477 | public override void SetDamping2(object pBody, float pLinear, float pAngular) | 706 | public override void SetDamping(BulletBody pBody, float pLinear, float pAngular) |
478 | { | 707 | { |
479 | RigidBody body = pBody as RigidBody; | 708 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
480 | body.SetDamping(pLinear, pAngular); | 709 | body.SetDamping(pLinear, pAngular); |
481 | } | 710 | } |
482 | //PhysBody.ptr, PhysicsScene.Params.deactivationTime); | 711 | //PhysBody.ptr, PhysicsScene.Params.deactivationTime); |
483 | public override void SetDeactivationTime2(object pBody, float pDeactivationTime) | 712 | public override void SetDeactivationTime(BulletBody pBody, float pDeactivationTime) |
484 | { | 713 | { |
485 | RigidBody body = pBody as RigidBody; | 714 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
486 | body.SetDeactivationTime(pDeactivationTime); | 715 | body.SetDeactivationTime(pDeactivationTime); |
487 | } | 716 | } |
488 | //SetSleepingThresholds2(PhysBody.ptr, PhysicsScene.Params.linearSleepingThreshold, PhysicsScene.Params.angularSleepingThreshold); | 717 | //SetSleepingThresholds(PhysBody.ptr, PhysicsScene.Params.linearSleepingThreshold, PhysicsScene.Params.angularSleepingThreshold); |
489 | public override void SetSleepingThresholds2(object pBody, float plinearSleepingThreshold, float pangularSleepingThreshold) | 718 | public override void SetSleepingThresholds(BulletBody pBody, float plinearSleepingThreshold, float pangularSleepingThreshold) |
490 | { | 719 | { |
491 | RigidBody body = pBody as RigidBody; | 720 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
492 | body.SetSleepingThresholds(plinearSleepingThreshold, pangularSleepingThreshold); | 721 | body.SetSleepingThresholds(plinearSleepingThreshold, pangularSleepingThreshold); |
493 | } | 722 | } |
494 | 723 | ||
495 | public override CollisionObjectTypes GetBodyType2(object pBody) | 724 | public override CollisionObjectTypes GetBodyType(BulletBody pBody) |
496 | { | 725 | { |
497 | RigidBody body = pBody as RigidBody; | 726 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
498 | return (CollisionObjectTypes)(int) body.GetInternalType(); | 727 | return (CollisionObjectTypes)(int) body.GetInternalType(); |
499 | } | 728 | } |
500 | 729 | ||
501 | //BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, fSum); | 730 | public override void ApplyGravity(BulletBody obj) { /* TODO */ } |
502 | public override void ApplyCentralForce2(object pBody, Vector3 pfSum) | 731 | |
732 | public override Vector3 GetGravity(BulletBody obj) { /* TODO */ return Vector3.Zero; } | ||
733 | |||
734 | public override void SetLinearDamping(BulletBody obj, float lin_damping) { /* TODO */ } | ||
735 | |||
736 | public override float GetLinearDamping(BulletBody obj) { /* TODO */ return 0f; } | ||
737 | |||
738 | public override float GetAngularDamping(BulletBody obj) { /* TODO */ return 0f; } | ||
739 | |||
740 | public override float GetLinearSleepingThreshold(BulletBody obj) { /* TODO */ return 0f; } | ||
741 | |||
742 | public override void ApplyDamping(BulletBody obj, float timeStep) { /* TODO */ } | ||
743 | |||
744 | public override Vector3 GetLinearFactor(BulletBody obj) { /* TODO */ return Vector3.Zero; } | ||
745 | |||
746 | public override void SetLinearFactor(BulletBody obj, Vector3 factor) { /* TODO */ } | ||
747 | |||
748 | public override void SetCenterOfMassByPosRot(BulletBody obj, Vector3 pos, Quaternion rot) { /* TODO */ } | ||
749 | |||
750 | //BulletSimAPI.ApplyCentralForce(PhysBody.ptr, fSum); | ||
751 | public override void ApplyCentralForce(BulletBody pBody, Vector3 pfSum) | ||
503 | { | 752 | { |
504 | RigidBody body = pBody as RigidBody; | 753 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
505 | IndexedVector3 fSum = new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z); | 754 | IndexedVector3 fSum = new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z); |
506 | body.ApplyCentralForce(ref fSum); | 755 | body.ApplyCentralForce(ref fSum); |
507 | } | 756 | } |
508 | public override void ApplyCentralImpulse2(object pBody, Vector3 pfSum) | 757 | public override void ApplyCentralImpulse(BulletBody pBody, Vector3 pfSum) |
509 | { | 758 | { |
510 | RigidBody body = pBody as RigidBody; | 759 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
511 | IndexedVector3 fSum = new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z); | 760 | IndexedVector3 fSum = new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z); |
512 | body.ApplyCentralImpulse(ref fSum); | 761 | body.ApplyCentralImpulse(ref fSum); |
513 | } | 762 | } |
514 | public override void ApplyTorque2(object pBody, Vector3 pfSum) | 763 | public override void ApplyTorque(BulletBody pBody, Vector3 pfSum) |
515 | { | 764 | { |
516 | RigidBody body = pBody as RigidBody; | 765 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
517 | IndexedVector3 fSum = new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z); | 766 | IndexedVector3 fSum = new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z); |
518 | body.ApplyTorque(ref fSum); | 767 | body.ApplyTorque(ref fSum); |
519 | } | 768 | } |
520 | public override void ApplyTorqueImpulse2(object pBody, Vector3 pfSum) | 769 | public override void ApplyTorqueImpulse(BulletBody pBody, Vector3 pfSum) |
521 | { | 770 | { |
522 | RigidBody body = pBody as RigidBody; | 771 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
523 | IndexedVector3 fSum = new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z); | 772 | IndexedVector3 fSum = new IndexedVector3(pfSum.X, pfSum.Y, pfSum.Z); |
524 | body.ApplyTorqueImpulse(ref fSum); | 773 | body.ApplyTorqueImpulse(ref fSum); |
525 | } | 774 | } |
526 | 775 | ||
527 | public override void DumpRigidBody2(object p, object p_2) | 776 | public override void DumpRigidBody(BulletWorld p, BulletBody p_2) |
777 | { | ||
778 | //TODO: | ||
779 | } | ||
780 | |||
781 | public override void DumpCollisionShape(BulletWorld p, BulletShape p_2) | ||
782 | { | ||
783 | //TODO: | ||
784 | } | ||
785 | public override void DumpConstraint(BulletWorld world, BulletConstraint constrain) | ||
786 | { | ||
787 | //TODO: | ||
788 | } | ||
789 | |||
790 | public override void DumpActivationInfo(BulletWorld world) | ||
791 | { | ||
792 | //TODO: | ||
793 | } | ||
794 | |||
795 | public override void DumpAllInfo(BulletWorld world) | ||
528 | { | 796 | { |
529 | //TODO: | 797 | //TODO: |
530 | } | 798 | } |
531 | 799 | ||
532 | public override void DumpCollisionShape2(object p, object p_2) | 800 | public override void DumpPhysicsStatistics(BulletWorld world) |
533 | { | 801 | { |
534 | //TODO: | 802 | //TODO: |
535 | } | 803 | } |
536 | 804 | ||
537 | public override void DestroyObject2(object p, object p_2) | 805 | public override void DestroyObject(BulletWorld p, BulletBody p_2) |
538 | { | 806 | { |
539 | //TODO: | 807 | //TODO: |
540 | } | 808 | } |
541 | 809 | ||
542 | public override void Shutdown2(object pWorld) | 810 | public override void Shutdown(BulletWorld pWorld) |
543 | { | 811 | { |
544 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | 812 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
545 | world.Cleanup(); | 813 | world.Cleanup(); |
546 | } | 814 | } |
547 | 815 | ||
548 | public override void DeleteCollisionShape2(object p, object p_2) | 816 | public override BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id) |
817 | { | ||
818 | return null; | ||
819 | } | ||
820 | |||
821 | public override bool DeleteCollisionShape(BulletWorld p, BulletShape p_2) | ||
549 | { | 822 | { |
550 | //TODO: | 823 | //TODO: |
824 | return false; | ||
551 | } | 825 | } |
552 | //(sim.ptr, shape.ptr, prim.LocalID, prim.RawPosition, prim.RawOrientation); | 826 | //(sim.ptr, shape.ptr, prim.LocalID, prim.RawPosition, prim.RawOrientation); |
553 | 827 | ||
554 | public override object CreateBodyFromShape2(object pWorld, object pShape, uint pLocalID, Vector3 pRawPosition, Quaternion pRawOrientation) | 828 | public override BulletBody CreateBodyFromShape(BulletWorld pWorld, BulletShape pShape, uint pLocalID, Vector3 pRawPosition, Quaternion pRawOrientation) |
555 | { | 829 | { |
556 | CollisionWorld world = pWorld as CollisionWorld; | 830 | CollisionWorld world = ((BulletWorldXNA)pWorld).world; |
557 | IndexedMatrix mat = | 831 | IndexedMatrix mat = |
558 | IndexedMatrix.CreateFromQuaternion(new IndexedQuaternion(pRawOrientation.X, pRawOrientation.Y, | 832 | IndexedMatrix.CreateFromQuaternion(new IndexedQuaternion(pRawOrientation.X, pRawOrientation.Y, |
559 | pRawOrientation.Z, pRawOrientation.W)); | 833 | pRawOrientation.Z, pRawOrientation.W)); |
560 | mat._origin = new IndexedVector3(pRawPosition.X, pRawPosition.Y, pRawPosition.Z); | 834 | mat._origin = new IndexedVector3(pRawPosition.X, pRawPosition.Y, pRawPosition.Z); |
561 | CollisionShape shape = pShape as CollisionShape; | 835 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
562 | //UpdateSingleAabb2(world, shape); | 836 | //UpdateSingleAabb(world, shape); |
563 | // TODO: Feed Update array into null | 837 | // TODO: Feed Update array into null |
564 | RigidBody body = new RigidBody(0,new SimMotionState(world,pLocalID,mat,null),shape,IndexedVector3.Zero); | 838 | RigidBody body = new RigidBody(0,new SimMotionState(world,pLocalID,mat,null),shape,IndexedVector3.Zero); |
565 | 839 | ||
566 | body.SetUserPointer(pLocalID); | 840 | body.SetUserPointer(pLocalID); |
567 | return body; | 841 | return new BulletBodyXNA(pLocalID, body); |
568 | } | 842 | } |
569 | 843 | ||
570 | 844 | ||
571 | public override object CreateBodyWithDefaultMotionState2( object pShape, uint pLocalID, Vector3 pRawPosition, Quaternion pRawOrientation) | 845 | public override BulletBody CreateBodyWithDefaultMotionState( BulletShape pShape, uint pLocalID, Vector3 pRawPosition, Quaternion pRawOrientation) |
572 | { | 846 | { |
573 | 847 | ||
574 | IndexedMatrix mat = | 848 | IndexedMatrix mat = |
@@ -576,39 +850,71 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
576 | pRawOrientation.Z, pRawOrientation.W)); | 850 | pRawOrientation.Z, pRawOrientation.W)); |
577 | mat._origin = new IndexedVector3(pRawPosition.X, pRawPosition.Y, pRawPosition.Z); | 851 | mat._origin = new IndexedVector3(pRawPosition.X, pRawPosition.Y, pRawPosition.Z); |
578 | 852 | ||
579 | CollisionShape shape = pShape as CollisionShape; | 853 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
580 | 854 | ||
581 | // TODO: Feed Update array into null | 855 | // TODO: Feed Update array into null |
582 | RigidBody body = new RigidBody(0, new DefaultMotionState( mat, IndexedMatrix.Identity), shape, IndexedVector3.Zero); | 856 | RigidBody body = new RigidBody(0, new DefaultMotionState( mat, IndexedMatrix.Identity), shape, IndexedVector3.Zero); |
583 | body.SetWorldTransform(mat); | 857 | body.SetWorldTransform(mat); |
584 | body.SetUserPointer(pLocalID); | 858 | body.SetUserPointer(pLocalID); |
585 | return body; | 859 | return new BulletBodyXNA(pLocalID, body); |
586 | } | 860 | } |
587 | //(m_mapInfo.terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 861 | //(m_mapInfo.terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); |
588 | public override void SetCollisionFlags2(object pBody, CollisionFlags collisionFlags) | 862 | public override CollisionFlags SetCollisionFlags(BulletBody pBody, CollisionFlags collisionFlags) |
589 | { | 863 | { |
590 | RigidBody body = pBody as RigidBody; | 864 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
591 | body.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags) (uint) collisionFlags); | 865 | body.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags) (uint) collisionFlags); |
592 | } | 866 | return (CollisionFlags)body.GetCollisionFlags(); |
867 | } | ||
868 | |||
869 | public override Vector3 GetAnisotripicFriction(BulletConstraint pconstrain) { /* TODO */ return Vector3.Zero; } | ||
870 | public override Vector3 SetAnisotripicFriction(BulletConstraint pconstrain, Vector3 frict) { /* TODO */ return Vector3.Zero; } | ||
871 | public override bool HasAnisotripicFriction(BulletConstraint pconstrain) { /* TODO */ return false; } | ||
872 | public override float GetContactProcessingThreshold(BulletBody pBody) { /* TODO */ return 0f; } | ||
873 | public override bool IsStaticObject(BulletBody pBody) { /* TODO */ return false; } | ||
874 | public override bool IsKinematicObject(BulletBody pBody) { /* TODO */ return false; } | ||
875 | public override bool IsStaticOrKinematicObject(BulletBody pBody) { /* TODO */ return false; } | ||
876 | public override bool HasContactResponse(BulletBody pBody) { /* TODO */ return false; } | ||
877 | public override int GetActivationState(BulletBody pBody) { /* TODO */ return 0; } | ||
878 | public override void SetActivationState(BulletBody pBody, int state) { /* TODO */ } | ||
879 | public override float GetDeactivationTime(BulletBody pBody) { /* TODO */ return 0f; } | ||
880 | public override bool IsActive(BulletBody pBody) { /* TODO */ return false; } | ||
881 | public override float GetRestitution(BulletBody pBody) { /* TODO */ return 0f; } | ||
882 | public override float GetFriction(BulletBody pBody) { /* TODO */ return 0f; } | ||
883 | public override void SetInterpolationVelocity(BulletBody pBody, Vector3 linearVel, Vector3 angularVel) { /* TODO */ } | ||
884 | public override float GetHitFraction(BulletBody pBody) { /* TODO */ return 0f; } | ||
885 | |||
593 | //(m_mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainHitFraction); | 886 | //(m_mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainHitFraction); |
594 | public override void SetHitFraction2(object pBody, float pHitFraction) | 887 | public override void SetHitFraction(BulletBody pBody, float pHitFraction) |
595 | { | 888 | { |
596 | RigidBody body = pBody as RigidBody; | 889 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
597 | body.SetHitFraction(pHitFraction); | 890 | body.SetHitFraction(pHitFraction); |
598 | } | 891 | } |
599 | //BuildCapsuleShape2(physicsScene.World.ptr, 1f, 1f, prim.Scale); | 892 | //BuildCapsuleShape(physicsScene.World.ptr, 1f, 1f, prim.Scale); |
600 | public override object BuildCapsuleShape2(object pWorld, float pRadius, float pHeight, Vector3 pScale) | 893 | public override BulletShape BuildCapsuleShape(BulletWorld pWorld, float pRadius, float pHeight, Vector3 pScale) |
601 | { | 894 | { |
602 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | 895 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
603 | IndexedVector3 scale = new IndexedVector3(pScale.X, pScale.Y, pScale.Z); | 896 | IndexedVector3 scale = new IndexedVector3(pScale.X, pScale.Y, pScale.Z); |
604 | CapsuleShapeZ capsuleShapeZ = new CapsuleShapeZ(pRadius, pHeight); | 897 | CapsuleShapeZ capsuleShapeZ = new CapsuleShapeZ(pRadius, pHeight); |
605 | capsuleShapeZ.SetMargin(world.WorldSettings.Params.collisionMargin); | 898 | capsuleShapeZ.SetMargin(world.WorldSettings.Params.collisionMargin); |
606 | capsuleShapeZ.SetLocalScaling(ref scale); | 899 | capsuleShapeZ.SetLocalScaling(ref scale); |
607 | 900 | ||
608 | return capsuleShapeZ; | 901 | return new BulletShapeXNA(capsuleShapeZ, BSPhysicsShapeType.SHAPE_CAPSULE); ; |
902 | } | ||
903 | |||
904 | public override BulletWorld Initialize(Vector3 maxPosition, ConfigurationParameters parms, | ||
905 | int maxCollisions, ref CollisionDesc[] collisionArray, | ||
906 | int maxUpdates, ref EntityProperties[] updateArray | ||
907 | ) | ||
908 | { | ||
909 | /* TODO */ | ||
910 | return new BulletWorldXNA(1, null, null); | ||
609 | } | 911 | } |
610 | 912 | ||
611 | public static object Initialize2(Vector3 worldExtent, ConfigurationParameters[] o, int mMaxCollisionsPerFrame, ref List<BulletXNA.CollisionDesc> collisionArray, int mMaxUpdatesPerFrame, ref List<BulletXNA.EntityProperties> updateArray, object mDebugLogCallbackHandle) | 913 | private static object Initialize2(Vector3 worldExtent, |
914 | ConfigurationParameters[] o, | ||
915 | int mMaxCollisionsPerFrame, ref List<BulletXNA.CollisionDesc> collisionArray, | ||
916 | int mMaxUpdatesPerFrame, ref List<BulletXNA.EntityProperties> updateArray, | ||
917 | object mDebugLogCallbackHandle) | ||
612 | { | 918 | { |
613 | CollisionWorld.WorldData.ParamData p = new CollisionWorld.WorldData.ParamData(); | 919 | CollisionWorld.WorldData.ParamData p = new CollisionWorld.WorldData.ParamData(); |
614 | 920 | ||
@@ -728,9 +1034,9 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
728 | return world; | 1034 | return world; |
729 | } | 1035 | } |
730 | //m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL | 1036 | //m_constraint.ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL |
731 | public override bool SetConstraintParam2(object pConstraint, ConstraintParams paramIndex, float paramvalue, ConstraintParamAxis axis) | 1037 | public override bool SetConstraintParam(BulletConstraint pConstraint, ConstraintParams paramIndex, float paramvalue, ConstraintParamAxis axis) |
732 | { | 1038 | { |
733 | Generic6DofConstraint constrain = pConstraint as Generic6DofConstraint; | 1039 | Generic6DofConstraint constrain = ((BulletConstraintXNA)pConstraint).constrain as Generic6DofConstraint; |
734 | if (axis == ConstraintParamAxis.AXIS_LINEAR_ALL || axis == ConstraintParamAxis.AXIS_ALL) | 1040 | if (axis == ConstraintParamAxis.AXIS_LINEAR_ALL || axis == ConstraintParamAxis.AXIS_ALL) |
735 | { | 1041 | { |
736 | constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams) (int) paramIndex, paramvalue, 0); | 1042 | constrain.SetParam((BulletXNA.BulletDynamics.ConstraintParams) (int) paramIndex, paramvalue, 0); |
@@ -750,10 +1056,10 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
750 | return true; | 1056 | return true; |
751 | } | 1057 | } |
752 | 1058 | ||
753 | public override bool PushUpdate2(object pCollisionObject) | 1059 | public override bool PushUpdate(BulletBody pCollisionObject) |
754 | { | 1060 | { |
755 | bool ret = false; | 1061 | bool ret = false; |
756 | RigidBody rb = pCollisionObject as RigidBody; | 1062 | RigidBody rb = ((BulletBodyXNA)pCollisionObject).rigidBody; |
757 | if (rb != null) | 1063 | if (rb != null) |
758 | { | 1064 | { |
759 | SimMotionState sms = rb.GetMotionState() as SimMotionState; | 1065 | SimMotionState sms = rb.GetMotionState() as SimMotionState; |
@@ -769,44 +1075,59 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
769 | 1075 | ||
770 | } | 1076 | } |
771 | 1077 | ||
772 | public override bool IsCompound2(object pShape) | 1078 | public override float GetAngularMotionDisc(BulletShape pShape) |
773 | { | 1079 | { |
774 | CollisionShape shape = pShape as CollisionShape; | 1080 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
1081 | return shape.GetAngularMotionDisc(); | ||
1082 | } | ||
1083 | public override float GetContactBreakingThreshold(BulletShape pShape, float defaultFactor) | ||
1084 | { | ||
1085 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; | ||
1086 | return shape.GetContactBreakingThreshold(defaultFactor); | ||
1087 | } | ||
1088 | public override bool IsCompound(BulletShape pShape) | ||
1089 | { | ||
1090 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; | ||
775 | return shape.IsCompound(); | 1091 | return shape.IsCompound(); |
776 | } | 1092 | } |
777 | public override bool IsPloyhedral2(object pShape) | 1093 | public override bool IsSoftBody(BulletShape pShape) |
1094 | { | ||
1095 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; | ||
1096 | return shape.IsSoftBody(); | ||
1097 | } | ||
1098 | public override bool IsPolyhedral(BulletShape pShape) | ||
778 | { | 1099 | { |
779 | CollisionShape shape = pShape as CollisionShape; | 1100 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
780 | return shape.IsPolyhedral(); | 1101 | return shape.IsPolyhedral(); |
781 | } | 1102 | } |
782 | public override bool IsConvex2d2(object pShape) | 1103 | public override bool IsConvex2d(BulletShape pShape) |
783 | { | 1104 | { |
784 | CollisionShape shape = pShape as CollisionShape; | 1105 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
785 | return shape.IsConvex2d(); | 1106 | return shape.IsConvex2d(); |
786 | } | 1107 | } |
787 | public override bool IsConvex2(object pShape) | 1108 | public override bool IsConvex(BulletShape pShape) |
788 | { | 1109 | { |
789 | CollisionShape shape = pShape as CollisionShape; | 1110 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
790 | return shape.IsConvex(); | 1111 | return shape.IsConvex(); |
791 | } | 1112 | } |
792 | public override bool IsNonMoving2(object pShape) | 1113 | public override bool IsNonMoving(BulletShape pShape) |
793 | { | 1114 | { |
794 | CollisionShape shape = pShape as CollisionShape; | 1115 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
795 | return shape.IsNonMoving(); | 1116 | return shape.IsNonMoving(); |
796 | } | 1117 | } |
797 | public override bool IsConcave2(object pShape) | 1118 | public override bool IsConcave(BulletShape pShape) |
798 | { | 1119 | { |
799 | CollisionShape shape = pShape as CollisionShape; | 1120 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
800 | return shape.IsConcave(); | 1121 | return shape.IsConcave(); |
801 | } | 1122 | } |
802 | public override bool IsInfinite2(object pShape) | 1123 | public override bool IsInfinite(BulletShape pShape) |
803 | { | 1124 | { |
804 | CollisionShape shape = pShape as CollisionShape; | 1125 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
805 | return shape.IsInfinite(); | 1126 | return shape.IsInfinite(); |
806 | } | 1127 | } |
807 | public override bool IsNativeShape2(object pShape) | 1128 | public override bool IsNativeShape(BulletShape pShape) |
808 | { | 1129 | { |
809 | CollisionShape shape = pShape as CollisionShape; | 1130 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
810 | bool ret; | 1131 | bool ret; |
811 | switch (shape.GetShapeType()) | 1132 | switch (shape.GetShapeType()) |
812 | { | 1133 | { |
@@ -822,33 +1143,39 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
822 | } | 1143 | } |
823 | return ret; | 1144 | return ret; |
824 | } | 1145 | } |
1146 | |||
1147 | public override void SetShapeCollisionMargin(BulletShape shape, float margin) { /* TODO */ } | ||
1148 | |||
825 | //sim.ptr, shape.ptr,prim.LocalID, prim.RawPosition, prim.RawOrientation | 1149 | //sim.ptr, shape.ptr,prim.LocalID, prim.RawPosition, prim.RawOrientation |
826 | public override object CreateGhostFromShape2(object pWorld, object pShape, uint pLocalID, Vector3 pRawPosition, Quaternion pRawOrientation) | 1150 | public override BulletBody CreateGhostFromShape(BulletWorld pWorld, BulletShape pShape, uint pLocalID, Vector3 pRawPosition, Quaternion pRawOrientation) |
827 | { | 1151 | { |
1152 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; | ||
828 | IndexedMatrix bodyTransform = new IndexedMatrix(); | 1153 | IndexedMatrix bodyTransform = new IndexedMatrix(); |
829 | bodyTransform._origin = new IndexedVector3(pRawPosition.X, pRawPosition.Y, pRawPosition.Z); | 1154 | bodyTransform._origin = new IndexedVector3(pRawPosition.X, pRawPosition.Y, pRawPosition.Z); |
830 | bodyTransform.SetRotation(new IndexedQuaternion(pRawOrientation.X,pRawOrientation.Y,pRawOrientation.Z,pRawOrientation.W)); | 1155 | bodyTransform.SetRotation(new IndexedQuaternion(pRawOrientation.X,pRawOrientation.Y,pRawOrientation.Z,pRawOrientation.W)); |
831 | GhostObject gObj = new PairCachingGhostObject(); | 1156 | GhostObject gObj = new PairCachingGhostObject(); |
832 | gObj.SetWorldTransform(bodyTransform); | 1157 | gObj.SetWorldTransform(bodyTransform); |
833 | CollisionShape shape = pShape as CollisionShape; | 1158 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
834 | gObj.SetCollisionShape(shape); | 1159 | gObj.SetCollisionShape(shape); |
835 | gObj.SetUserPointer(pLocalID); | 1160 | gObj.SetUserPointer(pLocalID); |
836 | // TODO: Add to Special CollisionObjects! | 1161 | // TODO: Add to Special CollisionObjects! |
837 | return gObj; | 1162 | return new BulletBodyXNA(pLocalID, gObj); |
838 | } | 1163 | } |
839 | 1164 | ||
840 | public static void SetCollisionShape2(object pWorld, object pObj, object pShape) | 1165 | public override void SetCollisionShape(BulletWorld pWorld, BulletBody pObj, BulletShape pShape) |
841 | { | 1166 | { |
842 | var world = pWorld as DiscreteDynamicsWorld; | 1167 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
843 | var obj = pObj as CollisionObject; | 1168 | CollisionObject obj = ((BulletBodyXNA)pObj).body; |
844 | var shape = pShape as CollisionShape; | 1169 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
845 | obj.SetCollisionShape(shape); | 1170 | obj.SetCollisionShape(shape); |
846 | 1171 | ||
847 | } | 1172 | } |
1173 | public override BulletShape GetCollisionShape(BulletBody obj) { /* TODO */ return null; } | ||
1174 | |||
848 | //(PhysicsScene.World.ptr, nativeShapeData) | 1175 | //(PhysicsScene.World.ptr, nativeShapeData) |
849 | public override object BuildNativeShape2(object pWorld, ShapeData pShapeData) | 1176 | public override BulletShape BuildNativeShape(BulletWorld pWorld, ShapeData pShapeData) |
850 | { | 1177 | { |
851 | var world = pWorld as DiscreteDynamicsWorld; | 1178 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
852 | CollisionShape shape = null; | 1179 | CollisionShape shape = null; |
853 | switch (pShapeData.Type) | 1180 | switch (pShapeData.Type) |
854 | { | 1181 | { |
@@ -873,25 +1200,25 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
873 | shape.SetLocalScaling(ref scaling); | 1200 | shape.SetLocalScaling(ref scaling); |
874 | 1201 | ||
875 | } | 1202 | } |
876 | return shape; | 1203 | return new BulletShapeXNA(shape, pShapeData.Type); |
877 | } | 1204 | } |
878 | //PhysicsScene.World.ptr, false | 1205 | //PhysicsScene.World.ptr, false |
879 | public override object CreateCompoundShape2(object pWorld, bool enableDynamicAabbTree) | 1206 | public override BulletShape CreateCompoundShape(BulletWorld pWorld, bool enableDynamicAabbTree) |
880 | { | 1207 | { |
881 | return new CompoundShape(enableDynamicAabbTree); | 1208 | return new BulletShapeXNA(new CompoundShape(enableDynamicAabbTree), BSPhysicsShapeType.SHAPE_COMPOUND); |
882 | } | 1209 | } |
883 | 1210 | ||
884 | public override int GetNumberOfCompoundChildren2(object pCompoundShape) | 1211 | public override int GetNumberOfCompoundChildren(BulletShape pCompoundShape) |
885 | { | 1212 | { |
886 | var compoundshape = pCompoundShape as CompoundShape; | 1213 | CompoundShape compoundshape = ((BulletShapeXNA)pCompoundShape).shape as CompoundShape; |
887 | return compoundshape.GetNumChildShapes(); | 1214 | return compoundshape.GetNumChildShapes(); |
888 | } | 1215 | } |
889 | //LinksetRoot.PhysShape.ptr, newShape.ptr, displacementPos, displacementRot | 1216 | //LinksetRoot.PhysShape.ptr, newShape.ptr, displacementPos, displacementRot |
890 | public override void AddChildShapeToCompoundShape2(object pCShape, object paddShape, Vector3 displacementPos, Quaternion displacementRot) | 1217 | public override void AddChildShapeToCompoundShape(BulletShape pCShape, BulletShape paddShape, Vector3 displacementPos, Quaternion displacementRot) |
891 | { | 1218 | { |
892 | IndexedMatrix relativeTransform = new IndexedMatrix(); | 1219 | IndexedMatrix relativeTransform = new IndexedMatrix(); |
893 | var compoundshape = pCShape as CompoundShape; | 1220 | CompoundShape compoundshape = ((BulletShapeXNA)pCShape).shape as CompoundShape; |
894 | var addshape = paddShape as CollisionShape; | 1221 | CollisionShape addshape = ((BulletShapeXNA)paddShape).shape; |
895 | 1222 | ||
896 | relativeTransform._origin = new IndexedVector3(displacementPos.X, displacementPos.Y, displacementPos.Z); | 1223 | relativeTransform._origin = new IndexedVector3(displacementPos.X, displacementPos.Y, displacementPos.Z); |
897 | relativeTransform.SetRotation(new IndexedQuaternion(displacementRot.X,displacementRot.Y,displacementRot.Z,displacementRot.W)); | 1224 | relativeTransform.SetRotation(new IndexedQuaternion(displacementRot.X,displacementRot.Y,displacementRot.Z,displacementRot.W)); |
@@ -899,58 +1226,47 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
899 | 1226 | ||
900 | } | 1227 | } |
901 | 1228 | ||
902 | public override object RemoveChildShapeFromCompoundShapeIndex2(object pCShape, int pii) | 1229 | public override BulletShape RemoveChildShapeFromCompoundShapeIndex(BulletShape pCShape, int pii) |
903 | { | 1230 | { |
904 | var compoundshape = pCShape as CompoundShape; | 1231 | CompoundShape compoundshape = ((BulletShapeXNA)pCShape).shape as CompoundShape; |
905 | CollisionShape ret = null; | 1232 | CollisionShape ret = null; |
906 | ret = compoundshape.GetChildShape(pii); | 1233 | ret = compoundshape.GetChildShape(pii); |
907 | compoundshape.RemoveChildShapeByIndex(pii); | 1234 | compoundshape.RemoveChildShapeByIndex(pii); |
908 | return ret; | 1235 | return new BulletShapeXNA(ret, BSPhysicsShapeType.SHAPE_UNKNOWN); |
909 | } | 1236 | } |
910 | 1237 | ||
911 | public override object CreateGroundPlaneShape2(uint pLocalId, float pheight, float pcollisionMargin) | 1238 | public override BulletShape GetChildShapeFromCompoundShapeIndex(BulletShape cShape, int indx) { /* TODO */ return null; } |
1239 | public override void RemoveChildShapeFromCompoundShape(BulletShape cShape, BulletShape removeShape) { /* TODO */ } | ||
1240 | |||
1241 | public override BulletShape CreateGroundPlaneShape(uint pLocalId, float pheight, float pcollisionMargin) | ||
912 | { | 1242 | { |
913 | StaticPlaneShape m_planeshape = new StaticPlaneShape(new IndexedVector3(0,0,1),(int)pheight ); | 1243 | StaticPlaneShape m_planeshape = new StaticPlaneShape(new IndexedVector3(0,0,1),(int)pheight ); |
914 | m_planeshape.SetMargin(pcollisionMargin); | 1244 | m_planeshape.SetMargin(pcollisionMargin); |
915 | m_planeshape.SetUserPointer(pLocalId); | 1245 | m_planeshape.SetUserPointer(pLocalId); |
916 | return m_planeshape; | 1246 | return new BulletShapeXNA(m_planeshape, BSPhysicsShapeType.SHAPE_GROUNDPLANE); |
917 | } | 1247 | } |
918 | 1248 | ||
919 | public override object CreateHingeConstraint2(object pWorld, object pBody1, object ppBody2, Vector3 ppivotInA, Vector3 ppivotInB, Vector3 paxisInA, Vector3 paxisInB, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies) | 1249 | public override BulletConstraint CreateHingeConstraint(BulletWorld pWorld, BulletBody pBody1, BulletBody ppBody2, Vector3 ppivotInA, Vector3 ppivotInB, Vector3 paxisInA, Vector3 paxisInB, bool puseLinearReferenceFrameA, bool pdisableCollisionsBetweenLinkedBodies) |
920 | { | 1250 | { |
921 | HingeConstraint constrain = null; | 1251 | HingeConstraint constrain = null; |
922 | var rb1 = pBody1 as RigidBody; | 1252 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
923 | var rb2 = ppBody2 as RigidBody; | 1253 | RigidBody rb1 = ((BulletBodyXNA)pBody1).rigidBody; |
1254 | RigidBody rb2 = ((BulletBodyXNA)ppBody2).rigidBody; | ||
924 | if (rb1 != null && rb2 != null) | 1255 | if (rb1 != null && rb2 != null) |
925 | { | 1256 | { |
926 | IndexedVector3 pivotInA = new IndexedVector3(ppivotInA.X, ppivotInA.Y, ppivotInA.Z); | 1257 | IndexedVector3 pivotInA = new IndexedVector3(ppivotInA.X, ppivotInA.Y, ppivotInA.Z); |
927 | IndexedVector3 pivotInB = new IndexedVector3(ppivotInB.X, ppivotInB.Y, ppivotInB.Z); | 1258 | IndexedVector3 pivotInB = new IndexedVector3(ppivotInB.X, ppivotInB.Y, ppivotInB.Z); |
928 | IndexedVector3 axisInA = new IndexedVector3(paxisInA.X, paxisInA.Y, paxisInA.Z); | 1259 | IndexedVector3 axisInA = new IndexedVector3(paxisInA.X, paxisInA.Y, paxisInA.Z); |
929 | IndexedVector3 axisInB = new IndexedVector3(paxisInB.X, paxisInB.Y, paxisInB.Z); | 1260 | IndexedVector3 axisInB = new IndexedVector3(paxisInB.X, paxisInB.Y, paxisInB.Z); |
930 | var world = pWorld as DiscreteDynamicsWorld; | ||
931 | world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies); | 1261 | world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies); |
932 | } | 1262 | } |
933 | return constrain; | 1263 | return new BulletConstraintXNA(constrain); |
934 | } | ||
935 | |||
936 | public override bool ReleaseHeightMapInfo2(object pMapInfo) | ||
937 | { | ||
938 | if (pMapInfo != null) | ||
939 | { | ||
940 | BulletHeightMapInfo mapinfo = pMapInfo as BulletHeightMapInfo; | ||
941 | if (mapinfo.heightMap != null) | ||
942 | mapinfo.heightMap = null; | ||
943 | |||
944 | |||
945 | } | ||
946 | return true; | ||
947 | } | 1264 | } |
948 | 1265 | ||
949 | public override object CreateHullShape2(object pWorld, int pHullCount, float[] pConvHulls) | 1266 | public override BulletShape CreateHullShape(BulletWorld pWorld, int pHullCount, float[] pConvHulls) |
950 | { | 1267 | { |
1268 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; | ||
951 | CompoundShape compoundshape = new CompoundShape(false); | 1269 | CompoundShape compoundshape = new CompoundShape(false); |
952 | var world = pWorld as DiscreteDynamicsWorld; | ||
953 | |||
954 | 1270 | ||
955 | compoundshape.SetMargin(world.WorldSettings.Params.collisionMargin); | 1271 | compoundshape.SetMargin(world.WorldSettings.Params.collisionMargin); |
956 | int ii = 1; | 1272 | int ii = 1; |
@@ -975,12 +1291,13 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
975 | compoundshape.AddChildShape(ref childTrans, convexShape); | 1291 | compoundshape.AddChildShape(ref childTrans, convexShape); |
976 | ii += (vertexCount*3 + 4); | 1292 | ii += (vertexCount*3 + 4); |
977 | } | 1293 | } |
978 | |||
979 | 1294 | ||
980 | return compoundshape; | 1295 | return new BulletShapeXNA(compoundshape, BSPhysicsShapeType.SHAPE_HULL); |
981 | } | 1296 | } |
982 | 1297 | ||
983 | public override object CreateMeshShape2(object pWorld, int pIndicesCount, int[] indices, int pVerticesCount, float[] verticesAsFloats) | 1298 | public override BulletShape BuildHullShapeFromMesh(BulletWorld world, BulletShape meshShape) { /* TODO */ return null; } |
1299 | |||
1300 | public override BulletShape CreateMeshShape(BulletWorld pWorld, int pIndicesCount, int[] indices, int pVerticesCount, float[] verticesAsFloats) | ||
984 | { | 1301 | { |
985 | //DumpRaw(indices,verticesAsFloats,pIndicesCount,pVerticesCount); | 1302 | //DumpRaw(indices,verticesAsFloats,pIndicesCount,pVerticesCount); |
986 | 1303 | ||
@@ -993,7 +1310,7 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
993 | ObjectArray<int> indicesarr = new ObjectArray<int>(indices); | 1310 | ObjectArray<int> indicesarr = new ObjectArray<int>(indices); |
994 | ObjectArray<float> vertices = new ObjectArray<float>(verticesAsFloats); | 1311 | ObjectArray<float> vertices = new ObjectArray<float>(verticesAsFloats); |
995 | DumpRaw(indicesarr,vertices,pIndicesCount,pVerticesCount); | 1312 | DumpRaw(indicesarr,vertices,pIndicesCount,pVerticesCount); |
996 | var world = pWorld as DiscreteDynamicsWorld; | 1313 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
997 | IndexedMesh mesh = new IndexedMesh(); | 1314 | IndexedMesh mesh = new IndexedMesh(); |
998 | mesh.m_indexType = PHY_ScalarType.PHY_INTEGER; | 1315 | mesh.m_indexType = PHY_ScalarType.PHY_INTEGER; |
999 | mesh.m_numTriangles = pIndicesCount/3; | 1316 | mesh.m_numTriangles = pIndicesCount/3; |
@@ -1009,7 +1326,7 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
1009 | BvhTriangleMeshShape meshShape = new BvhTriangleMeshShape(tribuilder, true,true); | 1326 | BvhTriangleMeshShape meshShape = new BvhTriangleMeshShape(tribuilder, true,true); |
1010 | meshShape.SetMargin(world.WorldSettings.Params.collisionMargin); | 1327 | meshShape.SetMargin(world.WorldSettings.Params.collisionMargin); |
1011 | // world.UpdateSingleAabb(meshShape); | 1328 | // world.UpdateSingleAabb(meshShape); |
1012 | return meshShape; | 1329 | return new BulletShapeXNA(meshShape, BSPhysicsShapeType.SHAPE_MESH); |
1013 | 1330 | ||
1014 | } | 1331 | } |
1015 | public static void DumpRaw(ObjectArray<int>indices, ObjectArray<float> vertices, int pIndicesCount,int pVerticesCount ) | 1332 | public static void DumpRaw(ObjectArray<int>indices, ObjectArray<float> vertices, int pIndicesCount,int pVerticesCount ) |
@@ -1092,52 +1409,31 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
1092 | 1409 | ||
1093 | sw.Close(); | 1410 | sw.Close(); |
1094 | } | 1411 | } |
1095 | //PhysicsScene.World.ptr, m_mapInfo.ID, m_mapInfo.minCoords, m_mapInfo.maxCoords, m_mapInfo.heightMap, PhysicsScene.Params.terrainCollisionMargin | ||
1096 | public override object CreateHeightMapInfo2(object pWorld, uint pId, Vector3 pminCoords, Vector3 pmaxCoords, float[] pheightMap, float pCollisionMargin) | ||
1097 | { | ||
1098 | BulletHeightMapInfo mapInfo = new BulletHeightMapInfo(pId, pheightMap, null); | ||
1099 | mapInfo.heightMap = null; | ||
1100 | mapInfo.minCoords = pminCoords; | ||
1101 | mapInfo.maxCoords = pmaxCoords; | ||
1102 | mapInfo.sizeX = (int) (pmaxCoords.X - pminCoords.X); | ||
1103 | mapInfo.sizeY = (int) (pmaxCoords.Y - pminCoords.Y); | ||
1104 | mapInfo.ID = pId; | ||
1105 | mapInfo.minZ = pminCoords.Z; | ||
1106 | mapInfo.maxZ = pmaxCoords.Z; | ||
1107 | mapInfo.collisionMargin = pCollisionMargin; | ||
1108 | if (mapInfo.minZ == mapInfo.maxZ) | ||
1109 | mapInfo.minZ -= 0.2f; | ||
1110 | mapInfo.heightMap = pheightMap; | ||
1111 | |||
1112 | return mapInfo; | ||
1113 | |||
1114 | } | ||
1115 | 1412 | ||
1116 | public override object CreateTerrainShape2(object pMapInfo) | 1413 | public override BulletShape CreateTerrainShape(uint id, Vector3 size, float minHeight, float maxHeight, float[] heightMap, |
1414 | float scaleFactor, float collisionMargin) | ||
1117 | { | 1415 | { |
1118 | BulletHeightMapInfo mapinfo = pMapInfo as BulletHeightMapInfo; | ||
1119 | const int upAxis = 2; | 1416 | const int upAxis = 2; |
1120 | const float scaleFactor = 1.0f; | 1417 | HeightfieldTerrainShape terrainShape = new HeightfieldTerrainShape((int)size.X, (int)size.Y, |
1121 | HeightfieldTerrainShape terrainShape = new HeightfieldTerrainShape((int)mapinfo.sizeX, (int)mapinfo.sizeY, | 1418 | heightMap, scaleFactor, |
1122 | mapinfo.heightMap, scaleFactor, | 1419 | minHeight, maxHeight, upAxis, |
1123 | mapinfo.minZ, mapinfo.maxZ, upAxis, | ||
1124 | false); | 1420 | false); |
1125 | terrainShape.SetMargin(mapinfo.collisionMargin + 0.5f); | 1421 | terrainShape.SetMargin(collisionMargin + 0.5f); |
1126 | terrainShape.SetUseDiamondSubdivision(true); | 1422 | terrainShape.SetUseDiamondSubdivision(true); |
1127 | terrainShape.SetUserPointer(mapinfo.ID); | 1423 | terrainShape.SetUserPointer(id); |
1128 | return terrainShape; | 1424 | return new BulletShapeXNA(terrainShape, BSPhysicsShapeType.SHAPE_TERRAIN); |
1129 | } | 1425 | } |
1130 | 1426 | ||
1131 | public override bool TranslationalLimitMotor2(object pConstraint, float ponOff, float targetVelocity, float maxMotorForce) | 1427 | public override bool TranslationalLimitMotor(BulletConstraint pConstraint, float ponOff, float targetVelocity, float maxMotorForce) |
1132 | { | 1428 | { |
1133 | TypedConstraint tconstrain = pConstraint as TypedConstraint; | 1429 | TypedConstraint tconstrain = ((BulletConstraintXNA)pConstraint).constrain; |
1134 | bool onOff = ponOff != 0; | 1430 | bool onOff = ponOff != 0; |
1135 | bool ret = false; | 1431 | bool ret = false; |
1136 | 1432 | ||
1137 | switch (tconstrain.GetConstraintType()) | 1433 | switch (tconstrain.GetConstraintType()) |
1138 | { | 1434 | { |
1139 | case TypedConstraintType.D6_CONSTRAINT_TYPE: | 1435 | case TypedConstraintType.D6_CONSTRAINT_TYPE: |
1140 | Generic6DofConstraint constrain = pConstraint as Generic6DofConstraint; | 1436 | Generic6DofConstraint constrain = tconstrain as Generic6DofConstraint; |
1141 | constrain.GetTranslationalLimitMotor().m_enableMotor[0] = onOff; | 1437 | constrain.GetTranslationalLimitMotor().m_enableMotor[0] = onOff; |
1142 | constrain.GetTranslationalLimitMotor().m_targetVelocity[0] = targetVelocity; | 1438 | constrain.GetTranslationalLimitMotor().m_targetVelocity[0] = targetVelocity; |
1143 | constrain.GetTranslationalLimitMotor().m_maxMotorForce[0] = maxMotorForce; | 1439 | constrain.GetTranslationalLimitMotor().m_maxMotorForce[0] = maxMotorForce; |
@@ -1150,14 +1446,25 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
1150 | 1446 | ||
1151 | } | 1447 | } |
1152 | 1448 | ||
1153 | public override int PhysicsStep2(object pWorld, float timeStep, int m_maxSubSteps, float m_fixedTimeStep, out int updatedEntityCount, out List<BulletXNA.EntityProperties> updatedEntities, out int collidersCount, out List<BulletXNA.CollisionDesc>colliders) | 1449 | public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, |
1450 | out int updatedEntityCount, out int collidersCount) | ||
1451 | { | ||
1452 | /* TODO */ | ||
1453 | updatedEntityCount = 0; | ||
1454 | collidersCount = 0; | ||
1455 | return 1; | ||
1456 | } | ||
1457 | |||
1458 | private int PhysicsStep2(BulletWorld pWorld, float timeStep, int m_maxSubSteps, float m_fixedTimeStep, | ||
1459 | out int updatedEntityCount, out List<BulletXNA.EntityProperties> updatedEntities, | ||
1460 | out int collidersCount, out List<BulletXNA.CollisionDesc>colliders) | ||
1154 | { | 1461 | { |
1155 | int epic = PhysicsStepint2(pWorld, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out updatedEntities, | 1462 | int epic = PhysicsStepint(pWorld, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out updatedEntities, |
1156 | out collidersCount, out colliders); | 1463 | out collidersCount, out colliders); |
1157 | return epic; | 1464 | return epic; |
1158 | } | 1465 | } |
1159 | 1466 | ||
1160 | private static int PhysicsStepint2(object pWorld,float timeStep, int m_maxSubSteps, float m_fixedTimeStep, out int updatedEntityCount, out List<BulletXNA.EntityProperties> updatedEntities, out int collidersCount, out List<BulletXNA.CollisionDesc> colliders) | 1467 | private static int PhysicsStepint(BulletWorld pWorld,float timeStep, int m_maxSubSteps, float m_fixedTimeStep, out int updatedEntityCount, out List<BulletXNA.EntityProperties> updatedEntities, out int collidersCount, out List<BulletXNA.CollisionDesc> colliders) |
1161 | { | 1468 | { |
1162 | int numSimSteps = 0; | 1469 | int numSimSteps = 0; |
1163 | 1470 | ||
@@ -1169,9 +1476,9 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
1169 | // colliders = new List<BulletXNA.CollisionDesc>(); | 1476 | // colliders = new List<BulletXNA.CollisionDesc>(); |
1170 | 1477 | ||
1171 | 1478 | ||
1172 | if (pWorld is DiscreteDynamicsWorld) | 1479 | if (pWorld is BulletWorldXNA) |
1173 | { | 1480 | { |
1174 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | 1481 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
1175 | 1482 | ||
1176 | numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep); | 1483 | numSimSteps = world.StepSimulation(timeStep, m_maxSubSteps, m_fixedTimeStep); |
1177 | int updates = 0; | 1484 | int updates = 0; |
@@ -1224,7 +1531,7 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
1224 | return numSimSteps; | 1531 | return numSimSteps; |
1225 | } | 1532 | } |
1226 | 1533 | ||
1227 | private static void RecordCollision(CollisionWorld world,CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm) | 1534 | private static void RecordCollision(CollisionWorld world, CollisionObject objA, CollisionObject objB, IndexedVector3 contact, IndexedVector3 norm) |
1228 | { | 1535 | { |
1229 | 1536 | ||
1230 | IndexedVector3 contactNormal = norm; | 1537 | IndexedVector3 contactNormal = norm; |
@@ -1257,11 +1564,11 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
1257 | 1564 | ||
1258 | 1565 | ||
1259 | } | 1566 | } |
1260 | private static EntityProperties GetDebugProperties(object pWorld, object pBody) | 1567 | private static EntityProperties GetDebugProperties(BulletWorld pWorld, BulletBody pBody) |
1261 | { | 1568 | { |
1262 | EntityProperties ent = new EntityProperties(); | 1569 | EntityProperties ent = new EntityProperties(); |
1263 | DiscreteDynamicsWorld world = pWorld as DiscreteDynamicsWorld; | 1570 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
1264 | RigidBody body = pBody as RigidBody; | 1571 | RigidBody body = ((BulletBodyXNA)pBody).rigidBody; |
1265 | IndexedMatrix transform = body.GetWorldTransform(); | 1572 | IndexedMatrix transform = body.GetWorldTransform(); |
1266 | IndexedVector3 LinearVelocity = body.GetInterpolationLinearVelocity(); | 1573 | IndexedVector3 LinearVelocity = body.GetInterpolationLinearVelocity(); |
1267 | IndexedVector3 AngularVelocity = body.GetInterpolationAngularVelocity(); | 1574 | IndexedVector3 AngularVelocity = body.GetInterpolationAngularVelocity(); |
@@ -1275,34 +1582,35 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
1275 | return ent; | 1582 | return ent; |
1276 | } | 1583 | } |
1277 | 1584 | ||
1278 | public override Vector3 GetLocalScaling2(object pBody) | 1585 | public override bool UpdateParameter(BulletWorld world, uint localID, String parm, float value) { /* TODO */ return false; } |
1586 | |||
1587 | public override Vector3 GetLocalScaling(BulletShape pShape) | ||
1279 | { | 1588 | { |
1280 | CollisionShape shape = pBody as CollisionShape; | 1589 | CollisionShape shape = ((BulletShapeXNA)pShape).shape; |
1281 | IndexedVector3 scale = shape.GetLocalScaling(); | 1590 | IndexedVector3 scale = shape.GetLocalScaling(); |
1282 | return new Vector3(scale.X,scale.Y,scale.Z); | 1591 | return new Vector3(scale.X,scale.Y,scale.Z); |
1283 | } | 1592 | } |
1284 | 1593 | ||
1285 | public override bool RayCastGround(object pWorld, Vector3 _RayOrigin, float pRayHeight, object NotMe) | 1594 | public bool RayCastGround(BulletWorld pWorld, Vector3 _RayOrigin, float pRayHeight, BulletBody NotMe) |
1286 | { | 1595 | { |
1287 | DynamicsWorld world = pWorld as DynamicsWorld; | 1596 | DiscreteDynamicsWorld world = ((BulletWorldXNA)pWorld).world; |
1288 | if (world != null) | 1597 | if (world != null) |
1289 | { | 1598 | { |
1290 | if (NotMe is CollisionObject || NotMe is RigidBody) | 1599 | if (NotMe is BulletBodyXNA && NotMe.HasPhysicalBody) |
1291 | { | 1600 | { |
1292 | CollisionObject AvoidBody = NotMe as CollisionObject; | 1601 | CollisionObject AvoidBody = ((BulletBodyXNA)NotMe).body; |
1293 | 1602 | ||
1294 | IndexedVector3 rOrigin = new IndexedVector3(_RayOrigin.X, _RayOrigin.Y, _RayOrigin.Z); | 1603 | IndexedVector3 rOrigin = new IndexedVector3(_RayOrigin.X, _RayOrigin.Y, _RayOrigin.Z); |
1295 | IndexedVector3 rEnd = new IndexedVector3(_RayOrigin.X, _RayOrigin.Y, _RayOrigin.Z - pRayHeight); | 1604 | IndexedVector3 rEnd = new IndexedVector3(_RayOrigin.X, _RayOrigin.Y, _RayOrigin.Z - pRayHeight); |
1296 | using ( | 1605 | using ( |
1297 | ClosestNotMeRayResultCallback rayCallback = new ClosestNotMeRayResultCallback(rOrigin, | 1606 | ClosestNotMeRayResultCallback rayCallback = |
1298 | rEnd, AvoidBody) | 1607 | new ClosestNotMeRayResultCallback(rOrigin, rEnd, AvoidBody) |
1299 | ) | 1608 | ) |
1300 | { | 1609 | { |
1301 | world.RayTest(ref rOrigin, ref rEnd, rayCallback); | 1610 | world.RayTest(ref rOrigin, ref rEnd, rayCallback); |
1302 | if (rayCallback.HasHit()) | 1611 | if (rayCallback.HasHit()) |
1303 | { | 1612 | { |
1304 | IndexedVector3 hitLocation = rayCallback.m_hitPointWorld; | 1613 | IndexedVector3 hitLocation = rayCallback.m_hitPointWorld; |
1305 | |||
1306 | } | 1614 | } |
1307 | return rayCallback.HasHit(); | 1615 | return rayCallback.HasHit(); |
1308 | } | 1616 | } |
@@ -1311,5 +1619,4 @@ public sealed class BSAPIXNA : BSAPITemplate | |||
1311 | return false; | 1619 | return false; |
1312 | } | 1620 | } |
1313 | } | 1621 | } |
1314 | */ | ||
1315 | } | 1622 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index 2350f59..1735be2 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs | |||
@@ -346,10 +346,9 @@ public abstract void RecalculateCompoundShapeLocalAabb(BulletShape cShape); | |||
346 | 346 | ||
347 | public abstract BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id); | 347 | public abstract BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id); |
348 | 348 | ||
349 | |||
350 | public abstract bool DeleteCollisionShape(BulletWorld world, BulletShape shape); | 349 | public abstract bool DeleteCollisionShape(BulletWorld world, BulletShape shape); |
351 | 350 | ||
352 | public abstract int GetBodyType(BulletBody obj); | 351 | public abstract CollisionObjectTypes GetBodyType(BulletBody obj); |
353 | 352 | ||
354 | public abstract BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot); | 353 | public abstract BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot); |
355 | 354 | ||
@@ -416,6 +415,7 @@ public abstract void SetForceUpdateAllAabbs(BulletWorld world, bool force); | |||
416 | 415 | ||
417 | // ===================================================================================== | 416 | // ===================================================================================== |
418 | // btDynamicsWorld entries | 417 | // btDynamicsWorld entries |
418 | // public abstract bool AddObjectToWorld(BulletWorld world, BulletBody obj, Vector3 pos, Quaternion rot); | ||
419 | public abstract bool AddObjectToWorld(BulletWorld world, BulletBody obj); | 419 | public abstract bool AddObjectToWorld(BulletWorld world, BulletBody obj); |
420 | 420 | ||
421 | public abstract bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj); | 421 | public abstract bool RemoveObjectFromWorld(BulletWorld world, BulletBody obj); |
@@ -597,7 +597,7 @@ public abstract void SetAngularFactorV(BulletBody obj, Vector3 factor); | |||
597 | 597 | ||
598 | public abstract Vector3 GetAngularFactor(BulletBody obj); | 598 | public abstract Vector3 GetAngularFactor(BulletBody obj); |
599 | 599 | ||
600 | public abstract bool IsInWorld(BulletBody obj); | 600 | public abstract bool IsInWorld(BulletWorld world, BulletBody obj); |
601 | 601 | ||
602 | public abstract void AddConstraintRef(BulletBody obj, BulletConstraint constrain); | 602 | public abstract void AddConstraintRef(BulletBody obj, BulletConstraint constrain); |
603 | 603 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index d4e2e87..826261c 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -898,17 +898,6 @@ public sealed class BSPrim : BSPhysObject | |||
898 | if (PhysBody.HasPhysicalBody) | 898 | if (PhysBody.HasPhysicalBody) |
899 | { | 899 | { |
900 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody); | 900 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody); |
901 | |||
902 | // TODO: Fix this. Total kludge because adding object to world resets its gravity to default. | ||
903 | // Replace this when the new AddObjectToWorld function is complete. | ||
904 | PhysicsScene.PE.SetGravity(PhysBody, ComputeGravity()); | ||
905 | |||
906 | // Collision filter can be set only when the object is in the world | ||
907 | if (!PhysBody.ApplyCollisionMask(PhysicsScene)) | ||
908 | { | ||
909 | m_log.ErrorFormat("{0} Failed setting object collision mask: id={1}", LogHeader, LocalID); | ||
910 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,failedSetMaskGroup,cType={1}", LocalID, PhysBody.collisionType); | ||
911 | } | ||
912 | } | 901 | } |
913 | else | 902 | else |
914 | { | 903 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 258b72f..3340cda 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -309,7 +309,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
309 | ret = new BSAPIUnman(engineName, this); | 309 | ret = new BSAPIUnman(engineName, this); |
310 | break; | 310 | break; |
311 | case "bulletxna": | 311 | case "bulletxna": |
312 | // ret = new BSAPIXNA(engineName, this); | 312 | ret = new BSAPIXNA(engineName, this); |
313 | break; | 313 | break; |
314 | } | 314 | } |
315 | 315 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 2b652f5..d361f18 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -141,7 +141,7 @@ 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 (!PhysicsScene.PE.IsInWorld(body)) | 144 | if (!PhysicsScene.PE.IsInWorld(PhysicsScene.World, body)) |
145 | { | 145 | { |
146 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, body); | 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); |
@@ -166,7 +166,7 @@ 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 (PhysicsScene.PE.IsInWorld(body)) | 169 | if (PhysicsScene.PE.IsInWorld(PhysicsScene.World, body)) |
170 | { | 170 | { |
171 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, body); | 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); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs index 114c0aa..e4fecc3 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs | |||
@@ -92,8 +92,8 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
92 | private void BuildHeightmapTerrain() | 92 | private void BuildHeightmapTerrain() |
93 | { | 93 | { |
94 | // Create the terrain shape from the mapInfo | 94 | // Create the terrain shape from the mapInfo |
95 | m_mapInfo.terrainShape = PhysicsScene.PE.CreateTerrainShape( m_mapInfo.ID, | 95 | m_mapInfo.terrainShape = PhysicsScene.PE.CreateTerrainShape( m_mapInfo.ID, |
96 | new Vector3(m_mapInfo.sizeX, m_mapInfo.sizeY, 0), m_mapInfo.minZ, m_mapInfo.maxZ, | 96 | new Vector3(m_mapInfo.sizeX, m_mapInfo.sizeY, 0), m_mapInfo.minZ, m_mapInfo.maxZ, |
97 | m_mapInfo.heightMap, 1f, BSParam.TerrainCollisionMargin); | 97 | m_mapInfo.heightMap, 1f, BSParam.TerrainCollisionMargin); |
98 | 98 | ||
99 | 99 | ||