PhysicsWorld.pkg 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. $#include "PhysicsWorld.h"
  2. struct PhysicsRaycastResult
  3. {
  4. PhysicsRaycastResult();
  5. ~PhysicsRaycastResult();
  6. Vector3 position_ @ position;
  7. Vector3 normal_ @ normal;
  8. float distance_ @ distance;
  9. RigidBody* body_ @ body;
  10. };
  11. class PhysicsWorld : public Component
  12. {
  13. void Update(float timeStep);
  14. void UpdateCollisions();
  15. void SetFps(int fps);
  16. void SetGravity(Vector3 gravity);
  17. void SetNumIterations(int num);
  18. void SetInterpolation(bool enable);
  19. void SetInternalEdge(bool enable);
  20. void SetSplitImpulse(bool enable);
  21. void SetMaxNetworkAngularVelocity(float velocity);
  22. // void Raycast(const Ray& ray, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  23. tolua_outside const PODVector<PhysicsRaycastResult>& PhysicsWorldRaycast @ Raycast(const Ray& ray, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  24. // void RaycastSingle(PhysicsRaycastResult& result, const Ray& ray, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  25. tolua_outside PhysicsRaycastResult PhysicsWorldRaycastSingle @ RaycastSingle(const Ray& ray, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  26. // void SphereCast(PhysicsRaycastResult& result, const Ray& ray, float radius, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  27. tolua_outside PhysicsRaycastResult PhysicsWorldSphereCast @ SphereCast(const Ray& ray, float radius, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  28. void DrawDebugGeometry(bool depthTest);
  29. void RemoveCachedGeometry(Model* model);
  30. Vector3 GetGravity() const;
  31. int GetNumIterations() const;
  32. bool GetInterpolation() const;
  33. bool GetInternalEdge() const;
  34. bool GetSplitImpulse() const;
  35. int GetFps() const;
  36. float GetMaxNetworkAngularVelocity() const;
  37. tolua_property__get_set Vector3 gravity;
  38. tolua_property__get_set int numIterations;
  39. tolua_property__get_set bool interpolation;
  40. tolua_property__get_set bool internalEdge;
  41. tolua_property__get_set bool splitImpulse;
  42. tolua_property__get_set int fps;
  43. tolua_property__get_set float maxNetworkAngularVelocity;
  44. tolua_property__is_set bool applyingTransforms;
  45. };
  46. ${
  47. static const PODVector<PhysicsRaycastResult>& PhysicsWorldRaycast(PhysicsWorld* physicsWorld, const Ray& ray, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED)
  48. {
  49. static PODVector<PhysicsRaycastResult> result;
  50. result.Clear();
  51. physicsWorld->Raycast(result, ray, maxDistance, collisionMask);
  52. return result;
  53. }
  54. static PhysicsRaycastResult PhysicsWorldRaycastSingle(PhysicsWorld* physicsWorld, const Ray& ray, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED)
  55. {
  56. PhysicsRaycastResult result;
  57. physicsWorld->RaycastSingle(result, ray, maxDistance, collisionMask);
  58. return result;
  59. }
  60. PhysicsRaycastResult PhysicsWorldSphereCast(PhysicsWorld* physicsWorld, const Ray& ray, float radius, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED)
  61. {
  62. PhysicsRaycastResult result;
  63. physicsWorld->SphereCast(result, ray, radius, maxDistance, collisionMask);
  64. return result;
  65. }
  66. $}