BsCollider.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsPhysicsCommon.h"
  6. #include "BsVector3.h"
  7. #include "BsQuaternion.h"
  8. namespace BansheeEngine
  9. {
  10. class BS_CORE_EXPORT Collider
  11. {
  12. public:
  13. virtual ~Collider() { }
  14. inline Vector3 getPosition() const;
  15. inline Quaternion getRotation() const;
  16. inline void setTransform(const Vector3& pos, const Quaternion& rot);
  17. virtual void setScale(const Vector3& scale);
  18. inline Vector3 getScale() const;
  19. inline void setIsTrigger(bool value);
  20. inline bool getIsTrigger() const;
  21. inline void setRigidbody(const SPtr<Rigidbody>& value);
  22. SPtr<Rigidbody> getRigidbody() const { return mRigidbody; }
  23. inline void setMass(float mass);
  24. inline float getMass() const;
  25. inline void setMaterial(const HPhysicsMaterial& material);
  26. inline HPhysicsMaterial getMaterial() const;
  27. inline void setContactOffset(float value);
  28. inline float getContactOffset();
  29. inline void setRestOffset(float value);
  30. inline float getRestOffset();
  31. inline void setLayer(UINT64 layer);
  32. inline UINT64 getLayer() const;
  33. Event<void(const CollisionData&)> onCollisionBegin;
  34. Event<void(const CollisionData&)> onCollisionStay;
  35. Event<void(const CollisionData&)> onCollisionEnd;
  36. /** @cond INTERNAL */
  37. FCollider* _getInternal() const { return mInternal; }
  38. /**
  39. * Sets the object that owns this physics object, if any. Used for high level systems so they can easily map their
  40. * high level physics objects from the low level ones returned by various queries and events.
  41. */
  42. void _setOwner(PhysicsOwnerType type, void* owner) { mOwner.type = type; mOwner.ownerData = owner; }
  43. /**
  44. * Gets the object that owns this physics object, if any. Used for high level systems so they can easily map their
  45. * high level physics objects from the low level ones returned by various queries and events.
  46. */
  47. void* _getOwner(PhysicsOwnerType type) const { return mOwner.type == type ? mOwner.ownerData : nullptr; }
  48. /** @endcond */
  49. protected:
  50. FCollider* mInternal = nullptr;
  51. PhysicsObjectOwner mOwner;
  52. SPtr<Rigidbody> mRigidbody;
  53. Vector3 mScale = Vector3::ONE;
  54. };
  55. }