diff options
author | Adam Frisby | 2008-05-09 17:17:54 +0000 |
---|---|---|
committer | Adam Frisby | 2008-05-09 17:17:54 +0000 |
commit | 93ec7f0c3c40773bf9c5c057b0ac747419440a80 (patch) | |
tree | d5d7a644a45428baa837b688627aaa212cbd8617 /OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | |
parent | Update svn properties. (diff) | |
download | opensim-SC-93ec7f0c3c40773bf9c5c057b0ac747419440a80.zip opensim-SC-93ec7f0c3c40773bf9c5c057b0ac747419440a80.tar.gz opensim-SC-93ec7f0c3c40773bf9c5c057b0ac747419440a80.tar.bz2 opensim-SC-93ec7f0c3c40773bf9c5c057b0ac747419440a80.tar.xz |
* Patch from Jed (DeepThink) - More optimisations for BulletX renderer. Trimesh collisions should now work relatively efficiently. BulletX plugin should now be functional - feedback would be appreciated as to how it performs vs ODE.
Diffstat (limited to 'OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 69db337..67de7f8 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | |||
@@ -279,30 +279,42 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
279 | // else | 279 | // else |
280 | // nameB = "null"; | 280 | // nameB = "null"; |
281 | bool needsCollision; | 281 | bool needsCollision; |
282 | int c1 = 3; | ||
283 | int c2 = 3; | ||
284 | |||
282 | //////////////////////////////////////////////////////// | 285 | //////////////////////////////////////////////////////// |
283 | //BulletX Mesh Collisions | 286 | //BulletX Mesh Collisions |
284 | //added by Jed zhu | 287 | //added by Jed zhu |
285 | //data: May 07,2005 | 288 | //data: May 07,2005 |
286 | //////////////////////////////////////////////////////// | 289 | //////////////////////////////////////////////////////// |
287 | #region BulletXMeshCollisions Fields | 290 | #region BulletXMeshCollisions Fields |
291 | |||
292 | |||
288 | if (bxcA != null && bxpB != null) | 293 | if (bxcA != null && bxpB != null) |
289 | needsCollision = Collision(bxcA, bxpB); | 294 | c1 = Collision(bxcA, bxpB); |
290 | else if (bxpA != null && bxcB != null) | 295 | if (bxpA != null && bxcB != null) |
291 | needsCollision = Collision(bxcB, bxpA); | 296 | c2 = Collision(bxcB, bxpA); |
297 | if (c1 < 2) | ||
298 | needsCollision = (c1 > 0) ? true : false; | ||
299 | else if (c2 < 2) | ||
300 | needsCollision = (c2 > 0) ? true : false; | ||
292 | else | 301 | else |
293 | needsCollision = base.NeedsCollision(bodyA, bodyB); | 302 | needsCollision = NeedsCollision(bodyA, bodyB); |
294 | 303 | ||
304 | |||
295 | #endregion | 305 | #endregion |
296 | 306 | ||
297 | 307 | ||
298 | //m_log.DebugFormat("[BulletX]: A collision was detected between {0} and {1} --> {2}", nameA, nameB, | 308 | //m_log.DebugFormat("[BulletX]: A collision was detected between {0} and {1} --> {2}", nameA, nameB, |
299 | //needsCollision); | 309 | //needsCollision); |
300 | 310 | ||
311 | |||
301 | return needsCollision; | 312 | return needsCollision; |
302 | } | 313 | } |
303 | //added by jed zhu | 314 | //added by jed zhu |
304 | //calculas the collision between the Prim and Actor | 315 | //calculas the collision between the Prim and Actor |
305 | private bool Collision(BulletXCharacter actorA, BulletXPrim primB) | 316 | // |
317 | private int Collision(BulletXCharacter actorA, BulletXPrim primB) | ||
306 | { | 318 | { |
307 | int[] indexBase; | 319 | int[] indexBase; |
308 | Vector3[] vertexBase; | 320 | Vector3[] vertexBase; |
@@ -311,18 +323,18 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
311 | 323 | ||
312 | float fdistance; | 324 | float fdistance; |
313 | if (primB == null) | 325 | if (primB == null) |
314 | return false; | 326 | return 3; |
315 | if (mesh == null) | 327 | if (mesh == null) |
316 | return false; | 328 | return 2; |
317 | if (actorA == null) | 329 | if (actorA == null) |
318 | return false; | 330 | return 3; |
319 | 331 | ||
320 | int iVertexCount = mesh.getVertexList().Count; | 332 | int iVertexCount = mesh.getVertexList().Count; |
321 | int iIndexCount = mesh.getIndexListAsInt().Length; | 333 | int iIndexCount = mesh.getIndexListAsInt().Length; |
322 | if (iVertexCount == 0) | 334 | if (iVertexCount == 0) |
323 | return false; | 335 | return 3; |
324 | if (iIndexCount == 0) | 336 | if (iIndexCount == 0) |
325 | return false; | 337 | return 3; |
326 | lock (BulletXScene.BulletXLock) | 338 | lock (BulletXScene.BulletXLock) |
327 | { | 339 | { |
328 | indexBase = mesh.getIndexListAsInt(); | 340 | indexBase = mesh.getIndexListAsInt(); |
@@ -352,21 +364,18 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
352 | { | 364 | { |
353 | if (CheckCollision(actorA, ia, ib, ic, vNormal, vertexBase) == 1) | 365 | if (CheckCollision(actorA, ia, ib, ic, vNormal, vertexBase) == 1) |
354 | { | 366 | { |
355 | PhysicsVector v = actorA.Position; | 367 | //PhysicsVector v = actorA.Position; |
356 | Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v); | 368 | //Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v); |
357 | Vector3 vp = vNormal * (fdistance - Vector3.Dot(vNormal, v3) + 0.2f); | 369 | //Vector3 vp = vNormal * (fdistance - Vector3.Dot(vNormal, v3) + 0.0f); |
358 | actorA.Position += BulletXMaths.XnaVector3ToPhysicsVector(vp); | 370 | //actorA.Position += BulletXMaths.XnaVector3ToPhysicsVector(vp); |
359 | return false; | 371 | return 1; |
360 | |||
361 | } | 372 | } |
362 | } | 373 | } |
363 | |||
364 | |||
365 | } | 374 | } |
366 | } | 375 | } |
367 | 376 | ||
368 | 377 | ||
369 | return true; | 378 | return 0; |
370 | } | 379 | } |
371 | //added by jed zhu | 380 | //added by jed zhu |
372 | //return value 1: need second check | 381 | //return value 1: need second check |
@@ -379,7 +388,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
379 | Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v); | 388 | Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v); |
380 | 389 | ||
381 | fstartSide = Vector3.Dot(vNormal, v3) - fDist; | 390 | fstartSide = Vector3.Dot(vNormal, v3) - fDist; |
382 | if (fstartSide <= 0) return 0; | 391 | if (fstartSide > 0) return 0; |
383 | else return 1; | 392 | else return 1; |
384 | } | 393 | } |
385 | //added by jed zhu | 394 | //added by jed zhu |