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/BsBoxCollider.h"
7#include "Components/BsCCollider.h"
8
9namespace bs
10{
11 /** @addtogroup Components-Core
12 * @{
13 */
14
15 /**
16 * @copydoc BoxCollider
17 *
18 * @note Wraps BoxCollider as a Component.
19 */
20 class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Physics,n:BoxCollider) CBoxCollider : public CCollider
21 {
22 public:
23 CBoxCollider(const HSceneObject& parent, const Vector3& extents = Vector3(0.5f, 0.5f, 0.5f));
24
25 /** @copydoc BoxCollider::setExtents */
26 BS_SCRIPT_EXPORT(n:Extents,pr:setter)
27 void setExtents(const Vector3& extents);
28
29 /** @copydoc BoxCollider::getExtents */
30 BS_SCRIPT_EXPORT(n:Extents,pr:getter)
31 Vector3 getExtents() const { return mExtents; }
32
33 /** Determines the position of the box 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 /** @name Internal
42 * @{
43 */
44
45 /** Returns the box collider that this component wraps. */
46 BoxCollider* _getInternal() const { return static_cast<BoxCollider*>(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 protected:
60 Vector3 mExtents = Vector3(0.5f, 0.5f, 0.5f);
61
62 /************************************************************************/
63 /* RTTI */
64 /************************************************************************/
65 public:
66 friend class CBoxColliderRTTI;
67 static RTTITypeBase* getRTTIStatic();
68 RTTITypeBase* getRTTI() const override;
69
70 protected:
71 CBoxCollider(); // Serialization only
72 };
73
74 /** @} */
75}