1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsCorePrerequisites.h"
6#include "Physics/BsPlaneCollider.h"
7#include "Components/BsCCollider.h"
8
9namespace bs
10{
11 /** @addtogroup Components-Core
12 * @{
13 */
14
15 /**
16 * @copydoc PlaneCollider
17 *
18 * @note Wraps PlaneCollider as a Component.
19 */
20 class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Physics,n:PlaneCollider) CPlaneCollider : public CCollider
21 {
22 public:
23 CPlaneCollider(const HSceneObject& parent);
24
25 /** Normal vector that determines the local orientation of the plane. */
26 BS_SCRIPT_EXPORT(n:Normal,pr:setter)
27 void setNormal(const Vector3& normal);
28
29 /** @copydoc setNormal() */
30 BS_SCRIPT_EXPORT(n:Normal,pr:getter)
31 Vector3 getNormal() const { return mNormal; }
32
33 /** Determines the distance of the plane from the local origin, along its normal vector. */
34 BS_SCRIPT_EXPORT(n:Distance,pr:setter)
35 void setDistance(float distance);
36
37 /** @copydoc setDistance() */
38 BS_SCRIPT_EXPORT(n:Distance,pr:getter)
39 float getDistance() const { return mDistance; }
40
41 /** @name Internal
42 * @{
43 */
44
45 /** Returns the plane collider that this component wraps. */
46 PlaneCollider* _getInternal() const { return static_cast<PlaneCollider*>(mInternal.get()); }
47
48 /** @} */
49
50 /************************************************************************/
51 /* COMPONENT OVERRIDES */
52 /************************************************************************/
53 protected:
54 friend class SceneObject;
55
56 /** @copydoc CCollider::createInternal */
57 SPtr<Collider> createInternal() override;
58
59 /** @copydoc CCollider::isValidParent */
60 bool isValidParent(const HRigidbody& parent) const override;
61
62 protected:
63 Vector3 mNormal = Vector3::UNIT_Y;
64 float mDistance = 0.0f;
65
66 /************************************************************************/
67 /* RTTI */
68 /************************************************************************/
69 public:
70 friend class CPlaneColliderRTTI;
71 static RTTITypeBase* getRTTIStatic();
72 RTTITypeBase* getRTTI() const override;
73
74 protected:
75 CPlaneCollider(); // Serialization only
76 };
77
78 /** @} */
79}