/BulletNoXna/BulletNoXna/BulletCollision/BroadphaseCollision/BroadphaseInterface.cs

https://bitbucket.org/cjrgaming/bullet-noxna · C# · 77 lines · 35 code · 15 blank · 27 comment · 0 complexity · 1cac8679fd7fe4477b623c79e93a0c4a MD5 · raw file

  1. /*
  2. * C# / XNA port of Bullet (c) 2011 Mark Neale <xexuxjy@hotmail.com>
  3. *
  4. * Bullet Continuous Collision Detection and Physics Library
  5. * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
  6. *
  7. * This software is provided 'as-is', without any express or implied warranty.
  8. * In no event will the authors be held liable for any damages arising from
  9. * the use of this software.
  10. *
  11. * Permission is granted to anyone to use this software for any purpose,
  12. * including commercial applications, and to alter it and redistribute it
  13. * freely, subject to the following restrictions:
  14. *
  15. * 1. The origin of this software must not be misrepresented; you must not
  16. * claim that you wrote the original software. If you use this software
  17. * in a product, an acknowledgment in the product documentation would be
  18. * appreciated but is not required.
  19. * 2. Altered source versions must be plainly marked as such, and must not be
  20. * misrepresented as being the original software.
  21. * 3. This notice may not be removed or altered from any source distribution.
  22. */
  23. using System;
  24. using BulletXNA.LinearMath;
  25. namespace BulletXNA.BulletCollision
  26. {
  27. public interface IBroadphaseInterface
  28. {
  29. BroadphaseProxy CreateProxy(Vector3 aabbMin, Vector3 aabbMax, BroadphaseNativeType shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy);
  30. BroadphaseProxy CreateProxy(ref Vector3 aabbMin, ref Vector3 aabbMax, BroadphaseNativeType shapeType, Object userPtr, CollisionFilterGroups collisionFilterGroup, CollisionFilterGroups collisionFilterMask, IDispatcher dispatcher, Object multiSapProxy);
  31. void DestroyProxy(BroadphaseProxy proxy, IDispatcher dispatcher);
  32. void SetAabb(BroadphaseProxy proxy, ref Vector3 aabbMin, ref Vector3 aabbMax, IDispatcher dispatcher);
  33. void GetAabb(BroadphaseProxy proxy, out Vector3 aabbMin, out Vector3 aabbMax);
  34. void RayTest(ref Vector3 rayFrom, ref Vector3 rayTo, BroadphaseRayCallback rayCallback);
  35. void RayTest(ref Vector3 rayFrom, ref Vector3 rayTo, BroadphaseRayCallback rayCallback, ref Vector3 aabbMin, ref Vector3 aabbMax);
  36. void AabbTest(ref Vector3 aabbMin, ref Vector3 aabbMax, IBroadphaseAabbCallback callback);
  37. ///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
  38. void CalculateOverlappingPairs(IDispatcher dispatcher);
  39. IOverlappingPairCache GetOverlappingPairCache();
  40. ///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
  41. ///will add some transform later
  42. void GetBroadphaseAabb(out Vector3 aabbMin, out Vector3 aabbMax);
  43. ///reset broadphase internal structures, to ensure determinism/reproducability
  44. void ResetPool(IDispatcher dispatcher);
  45. void PrintStats();
  46. void Cleanup();
  47. }
  48. public interface IBroadphaseAabbCallback
  49. {
  50. void Cleanup();
  51. bool Process(BroadphaseProxy proxy);
  52. }
  53. public abstract class BroadphaseRayCallback : IBroadphaseAabbCallback
  54. {
  55. ///added some cached data to accelerate ray-AABB tests
  56. public Vector3 m_rayDirectionInverse;
  57. public bool[] m_signs = new bool[3];
  58. public float m_lambda_max;
  59. public virtual void Cleanup() { }
  60. public abstract bool Process(BroadphaseProxy proxy);
  61. }
  62. }