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 "Reflection/BsRTTIType.h"
7#include "Physics/BsPhysicsMesh.h"
8#include "Physics/BsPhysics.h"
9
10namespace bs
11{
12 /** @cond RTTI */
13 /** @addtogroup RTTI-Impl-Core
14 * @{
15 */
16
17 class BS_CORE_EXPORT PhysicsMeshRTTI : public RTTIType<PhysicsMesh, Resource, PhysicsMeshRTTI>
18 {
19 private:
20 BS_BEGIN_RTTI_MEMBERS
21 BS_RTTI_MEMBER_REFLPTR(mInternal, 0)
22 BS_END_RTTI_MEMBERS
23
24 public:
25 void onDeserializationEnded(IReflectable* obj, SerializationContext* context) override
26 {
27 PhysicsMesh* mesh = static_cast<PhysicsMesh*>(obj);
28 mesh->initialize();
29 }
30
31 const String& getRTTIName() override
32 {
33 static String name = "PhysicsMesh";
34 return name;
35 }
36
37 UINT32 getRTTIId() override
38 {
39 return TID_PhysicsMesh;
40 }
41
42 SPtr<IReflectable> newRTTIObject() override
43 {
44 SPtr<PhysicsMesh> mesh = gPhysics().createMesh(nullptr, PhysicsMeshType::Convex);
45 mesh->_setThisPtr(mesh);
46
47 return mesh;
48 }
49 };
50
51 class BS_CORE_EXPORT FPhysicsMeshRTTI : public RTTIType<FPhysicsMesh, IReflectable, FPhysicsMeshRTTI>
52 {
53 private:
54 BS_BEGIN_RTTI_MEMBERS
55 BS_RTTI_MEMBER_PLAIN(mType, 0)
56 BS_END_RTTI_MEMBERS
57 public:
58 const String& getRTTIName() override
59 {
60 static String name = "FPhysicsMesh";
61 return name;
62 }
63
64 UINT32 getRTTIId() override
65 {
66 return TID_FPhysicsMesh;
67 }
68
69 SPtr<IReflectable> newRTTIObject() override
70 {
71 BS_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
72 return nullptr;
73 }
74 };
75
76 /** @} */
77 /** @endcond */
78}
79