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 "BsCoreApplication.h"
8#include "Mesh/BsMeshBase.h"
9#include "Error/BsException.h"
10
11namespace bs
12{
13 /** @cond RTTI */
14 /** @addtogroup RTTI-Impl-Core
15 * @{
16 */
17
18 BS_ALLOW_MEMCPY_SERIALIZATION(SubMesh);
19
20 class MeshBaseRTTI : public RTTIType<MeshBase, Resource, MeshBaseRTTI>
21 {
22 SubMesh& getSubMesh(MeshBase* obj, UINT32 arrayIdx) { return obj->mProperties.mSubMeshes[arrayIdx]; }
23 void setSubMesh(MeshBase* obj, UINT32 arrayIdx, SubMesh& value) { obj->mProperties.mSubMeshes[arrayIdx] = value; }
24 UINT32 getNumSubmeshes(MeshBase* obj) { return (UINT32)obj->mProperties.mSubMeshes.size(); }
25 void setNumSubmeshes(MeshBase* obj, UINT32 numElements) { obj->mProperties.mSubMeshes.resize(numElements); }
26
27 UINT32& getNumVertices(MeshBase* obj) { return obj->mProperties.mNumVertices; }
28 void setNumVertices(MeshBase* obj, UINT32& value) { obj->mProperties.mNumVertices = value; }
29
30 UINT32& getNumIndices(MeshBase* obj) { return obj->mProperties.mNumIndices; }
31 void setNumIndices(MeshBase* obj, UINT32& value) { obj->mProperties.mNumIndices = value; }
32
33 public:
34 MeshBaseRTTI()
35 {
36 addPlainField("mNumVertices", 0, &MeshBaseRTTI::getNumVertices, &MeshBaseRTTI::setNumVertices);
37 addPlainField("mNumIndices", 1, &MeshBaseRTTI::getNumIndices, &MeshBaseRTTI::setNumIndices);
38
39 addPlainArrayField("mSubMeshes", 2, &MeshBaseRTTI::getSubMesh,
40 &MeshBaseRTTI::getNumSubmeshes, &MeshBaseRTTI::setSubMesh, &MeshBaseRTTI::setNumSubmeshes);
41 }
42
43 SPtr<IReflectable> newRTTIObject() override
44 {
45 BS_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
46 return nullptr;
47 }
48
49 const String& getRTTIName() override
50 {
51 static String name = "MeshBase";
52 return name;
53 }
54
55 UINT32 getRTTIId() override
56 {
57 return TID_MeshBase;
58 }
59 };
60
61 /** @} */
62 /** @endcond */
63}