PhysicsWorld.pkg 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. void RaycastSingle(PhysicsRaycastResult& result, const Ray& ray, float maxDistance);
  30. void SphereCast(PhysicsRaycastResult& result, const Ray& ray, float radius, float maxDistance, unsigned collisionMask = M_MAX_UNSIGNED);
  31. void SphereCast(PhysicsRaycastResult& result, const Ray& ray, float radius, float maxDistance);
  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. // Properties:
  53. tolua_property__get_set Vector3 gravity;
  54. tolua_property__get_set int numIterations;
  55. tolua_property__get_set bool interpolation;
  56. tolua_property__get_set bool internalEdge;
  57. tolua_property__get_set bool splitImpulse;
  58. tolua_property__get_set int fps;
  59. tolua_property__get_set float maxNetworkAngularVelocity;
  60. tolua_property__is_set bool applyingTransforms;
  61. };