| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsCorePrerequisites.h"
- #include "BsRTTIType.h"
- #include "BsCoreApplication.h"
- #include "BsMesh.h"
- #include "BsSkeleton.h"
- #include "BsMorphShapes.h"
- #include "BsCoreThread.h"
- namespace bs
- {
- /** @cond RTTI */
- /** @addtogroup RTTI-Impl-Core
- * @{
- */
- class MeshRTTI : public RTTIType<Mesh, MeshBase, MeshRTTI>
- {
- BS_BEGIN_RTTI_MEMBERS
- BS_RTTI_MEMBER_REFLPTR(mVertexDesc, 0)
- BS_RTTI_MEMBER_PLAIN(mIndexType, 1)
- BS_RTTI_MEMBER_PLAIN(mUsage, 2)
- BS_RTTI_MEMBER_REFLPTR(mSkeleton, 4)
- BS_RTTI_MEMBER_REFLPTR(mMorphShapes, 5)
- BS_END_RTTI_MEMBERS
- SPtr<MeshData> getMeshData(Mesh* obj)
- {
- SPtr<MeshData> meshData = obj->allocBuffer();
- int usage = obj->mUsage;
- if((usage & MU_CPUREADABLE) || BS_EDITOR_BUILD)
- {
- obj->readData(meshData);
- gCoreThread().submit(true);
- return meshData;
- }
- if(usage & MU_CPUCACHED)
- {
- obj->readCachedData(*meshData);
- return meshData;
- }
- LOGERR("Attempting to save a mesh that isn't flagged with either MU_CPUCACHED OR MU_GPUREADABLE flags.");
- return meshData;
- }
- void setMeshData(Mesh* obj, SPtr<MeshData> meshData)
- {
- obj->mCPUData = meshData;
- }
- public:
- MeshRTTI()
- :mInitMembers(this)
- {
- addReflectablePtrField("mMeshData", 3, &MeshRTTI::getMeshData, &MeshRTTI::setMeshData);
- }
- void onDeserializationEnded(IReflectable* obj, const UnorderedMap<String, UINT64>& params) override
- {
- Mesh* mesh = static_cast<Mesh*>(obj);
- mesh->initialize();
- }
- SPtr<IReflectable> newRTTIObject() override
- {
- return Mesh::createEmpty();
- }
- const String& getRTTIName() override
- {
- static String name = "Mesh";
- return name;
- }
- UINT32 getRTTIId() override
- {
- return TID_Mesh;
- }
- };
- /** @} */
- /** @endcond */
- }
|