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/BsCapsuleCollider.h"
7#include "Components/BsCCollider.h"
8
9namespace bs
10{
11 /** @addtogroup Components-Core
12 * @{
13 */
14
15 /**
16 * @copydoc CapsuleCollider
17 *
18 * @note Wraps CapsuleCollider as a Component.
19 */
20 class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Physics,n:CapsuleCollider) CCapsuleCollider : public CCollider
21 {
22 public:
23 CCapsuleCollider(const HSceneObject& parent, float radius = 1.0f, float halfHeight = 0.5f);
24
25 /** Normal vector that determines how is the capsule oriented. */
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 position of the capsule shape, relative to the component's scene object. */
34 BS_SCRIPT_EXPORT(n:Center,pr:setter)
35 void setCenter(const Vector3& center);
36
37 /** @copydoc setCenter() */
38 BS_SCRIPT_EXPORT(n:Center,pr:getter)
39 Vector3 getCenter() const { return mLocalPosition; }
40
41 /** @copydoc CapsuleCollider::setHalfHeight() */
42 BS_SCRIPT_EXPORT(n:HalfHeight,pr:setter)
43 void setHalfHeight(float halfHeight);
44
45 /** @copydoc CapsuleCollider::getHalfHeight() */
46 BS_SCRIPT_EXPORT(n:HalfHeight,pr:getter)
47 float getHalfHeight() const { return mHalfHeight; }
48
49 /** @copydoc CapsuleCollider::setRadius() */
50 BS_SCRIPT_EXPORT(n:Radius,pr:setter)
51 void setRadius(float radius);
52
53 /** @copydoc CapsuleCollider::getRadius() */
54 BS_SCRIPT_EXPORT(n:Radius,pr:getter)
55 float getRadius() const { return mRadius; }
56
57 /** @name Internal
58 * @{
59 */
60
61 /** Returns the capsule collider that this component wraps. */
62 CapsuleCollider* _getInternal() const { return static_cast<CapsuleCollider*>(mInternal.get()); }
63
64 /** @} */
65
66 /************************************************************************/
67 /* COMPONENT OVERRIDES */
68 /************************************************************************/
69 protected:
70 friend class SceneObject;
71
72 /** @copydoc CCollider::createInternal */
73 SPtr<Collider> createInternal() override;
74
75 protected:
76 Vector3 mNormal = Vector3::UNIT_Y;
77 float mRadius = 1.0f;
78 float mHalfHeight = 0.5f;
79
80 /************************************************************************/
81 /* RTTI */
82 /************************************************************************/
83 public:
84 friend class CCapsuleColliderRTTI;
85 static RTTITypeBase* getRTTIStatic();
86 RTTITypeBase* getRTTI() const override;
87
88 protected:
89 CCapsuleCollider(); // Serialization only
90 };
91
92 /** @} */
93}