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 "Mesh/BsMeshData.h" |
8 | #include "RenderAPI/BsVertexDeclaration.h" |
9 | #include "FileSystem/BsDataStream.h" |
10 | |
11 | namespace bs |
12 | { |
13 | /** @cond RTTI */ |
14 | /** @addtogroup RTTI-Impl-Core |
15 | * @{ |
16 | */ |
17 | |
18 | BS_ALLOW_MEMCPY_SERIALIZATION(IndexType); |
19 | |
20 | class BS_CORE_EXPORT MeshDataRTTI : public RTTIType<MeshData, GpuResourceData, MeshDataRTTI> |
21 | { |
22 | private: |
23 | SPtr<VertexDataDesc> getVertexData(MeshData* obj) { return obj->mVertexData; } |
24 | void setVertexData(MeshData* obj, SPtr<VertexDataDesc> value) { obj->mVertexData = value; } |
25 | |
26 | IndexType& getIndexType(MeshData* obj) { return obj->mIndexType; } |
27 | void setIndexType(MeshData* obj, IndexType& value) { obj->mIndexType = value; } |
28 | |
29 | UINT32& getNumVertices(MeshData* obj) { return obj->mNumVertices; } |
30 | void setNumVertices(MeshData* obj, UINT32& value) { obj->mNumVertices = value; } |
31 | |
32 | UINT32& getNumIndices(MeshData* obj) { return obj->mNumIndices; } |
33 | void setNumIndices(MeshData* obj, UINT32& value) { obj->mNumIndices = value; } |
34 | |
35 | SPtr<DataStream> getData(MeshData* obj, UINT32& size) |
36 | { |
37 | size = obj->getInternalBufferSize(); |
38 | |
39 | return bs_shared_ptr_new<MemoryDataStream>(obj->getData(), size, false); |
40 | } |
41 | |
42 | void setData(MeshData* obj, const SPtr<DataStream>& value, UINT32 size) |
43 | { |
44 | obj->allocateInternalBuffer(size); |
45 | value->read(obj->getData(), size); |
46 | } |
47 | |
48 | public: |
49 | MeshDataRTTI() |
50 | { |
51 | addReflectablePtrField("mVertexData" , 0, &MeshDataRTTI::getVertexData, &MeshDataRTTI::setVertexData); |
52 | |
53 | addPlainField("mIndexType" , 1, &MeshDataRTTI::getIndexType, &MeshDataRTTI::setIndexType); |
54 | addPlainField("mNumVertices" , 2, &MeshDataRTTI::getNumVertices, &MeshDataRTTI::setNumVertices); |
55 | addPlainField("mNumIndices" , 3, &MeshDataRTTI::getNumIndices, &MeshDataRTTI::setNumIndices); |
56 | |
57 | addDataBlockField("data" , 4, &MeshDataRTTI::getData, &MeshDataRTTI::setData); |
58 | } |
59 | |
60 | SPtr<IReflectable> newRTTIObject() override |
61 | { |
62 | return bs_shared_ptr<MeshData>(new (bs_alloc<MeshData>()) MeshData()); |
63 | } |
64 | |
65 | const String& getRTTIName() override |
66 | { |
67 | static String name = "MeshData" ; |
68 | return name; |
69 | } |
70 | |
71 | UINT32 getRTTIId() override |
72 | { |
73 | return TID_MeshData; |
74 | } |
75 | }; |
76 | |
77 | /** @} */ |
78 | /** @endcond */ |
79 | } |