PhysicsWorld.pkg 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. $#include "PhysicsWorld.h"
  2. struct PhysicsRaycastResult
  3. {
  4. PhysicsRaycastResult();
  5. Vector3 position_ @ position;
  6. Vector3 normal_ @ normal;
  7. float distance_ @ distance;
  8. RigidBody* body_ @ body;
  9. };
  10. struct DelayedWorldTransform
  11. {
  12. RigidBody* rigidBody_ @ rigidBody;
  13. RigidBody* parentRigidBody_ @ parentRigidBody;
  14. Vector3 worldPosition_ @ worldPosition;
  15. Quaternion worldRotation_ @ worldRotation;
  16. };
  17. class PhysicsWorld : public Component
  18. {
  19. void Update(float timeStep);
  20. void UpdateCollisions();
  21. void SetFps(int fps);
  22. void SetGravity(Vector3 gravity);
  23. void SetNumIterations(int num);
  24. void SetInterpolation(bool enable);
  25. void SetInternalEdge(bool enable);
  26. void SetSplitImpulse(bool enable);
  27. void SetMaxNetworkAngularVelocity(float velocity);
  28. // void RaycastSingle(PhysicsRaycastResult& result, const Ray& ray, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  29. tolua_outside PhysicsRaycastResult PhysicsWorldRaycastSingle @ RaycastSingle(const Ray& ray, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  30. // void SphereCast(PhysicsRaycastResult& result, const Ray& ray, float radius, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  31. tolua_outside PhysicsRaycastResult PhysicsWorldSphereCast @ SphereCast(const Ray& ray, float radius, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  32. Vector3 GetGravity() const;
  33. int GetNumIterations() const;
  34. bool GetInterpolation() const;
  35. bool GetInternalEdge() const;
  36. bool GetSplitImpulse() const;
  37. int GetFps() const;
  38. float GetMaxNetworkAngularVelocity() const;
  39. void AddRigidBody(RigidBody* body);
  40. void RemoveRigidBody(RigidBody* body);
  41. void AddCollisionShape(CollisionShape* shape);
  42. void RemoveCollisionShape(CollisionShape* shape);
  43. void AddConstraint(Constraint* joint);
  44. void RemoveConstraint(Constraint* joint);
  45. void AddDelayedWorldTransform(const DelayedWorldTransform& transform);
  46. void DrawDebugGeometry(bool depthTest);
  47. void SetDebugRenderer(DebugRenderer* debug);
  48. void SetDebugDepthTest(bool enable);
  49. void CleanupGeometryCache();
  50. void SetApplyingTransforms(bool enable);
  51. bool IsApplyingTransforms() const;
  52. tolua_property__get_set Vector3 gravity;
  53. tolua_property__get_set int numIterations;
  54. tolua_property__get_set bool interpolation;
  55. tolua_property__get_set bool internalEdge;
  56. tolua_property__get_set bool splitImpulse;
  57. tolua_property__get_set int fps;
  58. tolua_property__get_set float maxNetworkAngularVelocity;
  59. tolua_property__is_set bool applyingTransforms;
  60. };
  61. ${
  62. static PhysicsRaycastResult PhysicsWorldRaycastSingle(PhysicsWorld* physicsWorld, const Ray& ray, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED)
  63. {
  64. PhysicsRaycastResult result;
  65. physicsWorld->RaycastSingle(result, ray, maxDistance, collisionMask);
  66. return result;
  67. }
  68. PhysicsRaycastResult PhysicsWorldSphereCast(PhysicsWorld* physicsWorld, const Ray& ray, float radius, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED)
  69. {
  70. PhysicsRaycastResult result;
  71. physicsWorld->SphereCast(result, ray, radius, maxDistance, collisionMask);
  72. return result;
  73. }
  74. $}