diff --git a/private/Producers/FbxProducer/FbxProducerImpl.cpp b/private/Producers/FbxProducer/FbxProducerImpl.cpp index 6c9175f7..3000efee 100644 --- a/private/Producers/FbxProducer/FbxProducerImpl.cpp +++ b/private/Producers/FbxProducer/FbxProducerImpl.cpp @@ -961,7 +961,8 @@ void FbxProducerImpl::ProcessAnimation(fbxsdk::FbxScene* scene, cd::SceneDatabas const char* pJointName = pSceneDatabase->GetBone(boneIndex).GetName(); bones.push_back(scene->FindNodeByName(pJointName)); } - const int animationCount = scene->GetSrcObjectCount(); + + const uint32_t animationCount = scene->GetSrcObjectCount(); for (uint32_t animationIndex = 0; animationIndex < animationCount; ++animationIndex) { // Single-take animation information. @@ -976,14 +977,14 @@ void FbxProducerImpl::ProcessAnimation(fbxsdk::FbxScene* scene, cd::SceneDatabas cd::Animation animation(animationID, cd::MoveTemp(pAnimStackName)); float period = 1.f / 30.0f; // todo: it can make variable, like 24fps or 60fps... - int trackCount = static_cast(std::ceil((end - start) / period + 1.0f)); + uint32_t trackCount = static_cast(std::ceil((end - start) / period + 1.0f)); std::vector times; times.resize(trackCount); std::vector> worldMatrices; worldMatrices.resize(pSceneDatabase->GetBoneCount()); - for (int i = 0; i < pSceneDatabase->GetBoneCount(); i++) + for (uint32_t i = 0; i < pSceneDatabase->GetBoneCount(); ++i) { worldMatrices[i].resize(trackCount); } diff --git a/private/ProgressiveMesh/ProgressiveMeshImpl.h b/private/ProgressiveMesh/ProgressiveMeshImpl.h index 49f0ca35..3f4074c6 100644 --- a/private/ProgressiveMesh/ProgressiveMeshImpl.h +++ b/private/ProgressiveMesh/ProgressiveMeshImpl.h @@ -3,14 +3,13 @@ #include "Face.h" #include "Vertex.h" #include "Math/Box.hpp" +#include "Scene/Mesh.h" #include namespace cd { -class Mesh; - namespace pm { diff --git a/private/Scene/Animation.cpp b/private/Scene/Animation.cpp index a04e0e06..894c42ea 100644 --- a/private/Scene/Animation.cpp +++ b/private/Scene/Animation.cpp @@ -4,41 +4,13 @@ namespace cd { -Animation::Animation(InputArchive& inputArchive) -{ - m_pAnimationImpl = new AnimationImpl(inputArchive); -} - -Animation::Animation(InputArchiveSwapBytes& inputArchive) -{ - m_pAnimationImpl = new AnimationImpl(inputArchive); -} +PIMPL_SCENE_CLASS(Animation); Animation::Animation(AnimationID id, std::string name) { m_pAnimationImpl = new AnimationImpl(id, cd::MoveTemp(name)); } -Animation::Animation(Animation&& rhs) -{ - *this = cd::MoveTemp(rhs); -} - -Animation& Animation::operator=(Animation&& rhs) -{ - std::swap(m_pAnimationImpl, rhs.m_pAnimationImpl); - return *this; -} - -Animation::~Animation() -{ - if (m_pAnimationImpl) - { - delete m_pAnimationImpl; - m_pAnimationImpl = nullptr; - } -} - void Animation::Init(AnimationID id, std::string name) { m_pAnimationImpl->Init(id, cd::MoveTemp(name)); @@ -50,28 +22,4 @@ PIMPL_SIMPLE_TYPE_APIS(Animation, TicksPerSecond); PIMPL_VECTOR_TYPE_APIS(Animation, BoneTrackID); PIMPL_STRING_TYPE_APIS(Animation, Name); -Animation& Animation::operator<<(InputArchive& inputArchive) -{ - *m_pAnimationImpl << inputArchive; - return *this; -} - -Animation& Animation::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pAnimationImpl << inputArchive; - return *this; -} - -const Animation& Animation::operator>>(OutputArchive& outputArchive) const -{ - *m_pAnimationImpl >> outputArchive; - return *this; -} - -const Animation& Animation::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pAnimationImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/AnimationImpl.h b/private/Scene/AnimationImpl.h index 916809d4..ea8168b8 100644 --- a/private/Scene/AnimationImpl.h +++ b/private/Scene/AnimationImpl.h @@ -16,19 +16,9 @@ namespace cd class AnimationImpl final { public: - AnimationImpl() = delete; - template - explicit AnimationImpl(TInputArchive& inputArchive) - { - *this << inputArchive; - } - explicit AnimationImpl(AnimationID id, std::string name); - AnimationImpl(const AnimationImpl&) = default; - AnimationImpl& operator=(const AnimationImpl&) = default; - AnimationImpl(AnimationImpl&&) = default; - AnimationImpl& operator=(AnimationImpl&&) = default; - ~AnimationImpl() = default; + DECLARE_SCENE_IMPL_CLASS(Animation); + explicit AnimationImpl(AnimationID id, std::string name); void Init(AnimationID id, std::string name); IMPLEMENT_SIMPLE_TYPE_APIS(Animation, ID); diff --git a/private/Scene/Bone.cpp b/private/Scene/Bone.cpp index ddc3ecf1..a316277d 100644 --- a/private/Scene/Bone.cpp +++ b/private/Scene/Bone.cpp @@ -4,41 +4,13 @@ namespace cd { -Bone::Bone(InputArchive& inputArchive) -{ - m_pBoneImpl = new BoneImpl(inputArchive); -} - -Bone::Bone(InputArchiveSwapBytes& inputArchive) -{ - m_pBoneImpl = new BoneImpl(inputArchive); -} +PIMPL_SCENE_CLASS(Bone); Bone::Bone(BoneID id, std::string name) { m_pBoneImpl = new BoneImpl(id, cd::MoveTemp(name)); } -Bone::Bone(Bone&& rhs) -{ - *this = cd::MoveTemp(rhs); -} - -Bone& Bone::operator=(Bone&& rhs) -{ - std::swap(m_pBoneImpl, rhs.m_pBoneImpl); - return *this; -} - -Bone::~Bone() -{ - if (m_pBoneImpl) - { - delete m_pBoneImpl; - m_pBoneImpl = nullptr; - } -} - void Bone::Init(BoneID id, std::string name) { m_pBoneImpl->Init(id, MoveTemp(name)); @@ -51,28 +23,4 @@ PIMPL_COMPLEX_TYPE_APIS(Bone, Transform); PIMPL_VECTOR_TYPE_APIS(Bone, ChildID); PIMPL_STRING_TYPE_APIS(Bone, Name); -Bone& Bone::operator<<(InputArchive& inputArchive) -{ - *m_pBoneImpl << inputArchive; - return *this; -} - -Bone& Bone::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pBoneImpl << inputArchive; - return *this; -} - -const Bone& Bone::operator>>(OutputArchive& outputArchive) const -{ - *m_pBoneImpl >> outputArchive; - return *this; -} - -const Bone& Bone::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pBoneImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/BoneImpl.h b/private/Scene/BoneImpl.h index 51f4c432..bbeaaafc 100644 --- a/private/Scene/BoneImpl.h +++ b/private/Scene/BoneImpl.h @@ -14,19 +14,9 @@ namespace cd class BoneImpl final { public: - BoneImpl() = delete; - template - explicit BoneImpl(TInputArchive& inputArchive) - { - *this << inputArchive; - } - explicit BoneImpl(BoneID id, std::string name); - BoneImpl(const BoneImpl&) = default; - BoneImpl& operator=(const BoneImpl&) = default; - BoneImpl(BoneImpl&&) = default; - BoneImpl& operator=(BoneImpl&&) = default; - ~BoneImpl() = default; + DECLARE_SCENE_IMPL_CLASS(Bone); + explicit BoneImpl(BoneID id, std::string name); void Init(BoneID id, std::string name); IMPLEMENT_SIMPLE_TYPE_APIS(Bone, ID); diff --git a/private/Scene/Camera.cpp b/private/Scene/Camera.cpp index cb3b3c65..44e15fdb 100644 --- a/private/Scene/Camera.cpp +++ b/private/Scene/Camera.cpp @@ -4,41 +4,13 @@ namespace cd { -Camera::Camera(InputArchive& inputArchive) -{ - m_pCameraImpl = new CameraImpl(inputArchive); -} - -Camera::Camera(InputArchiveSwapBytes& inputArchive) -{ - m_pCameraImpl = new CameraImpl(inputArchive); -} +PIMPL_SCENE_CLASS(Camera); Camera::Camera(CameraID id, const char* pName) { m_pCameraImpl = new CameraImpl(id, pName); } -Camera::Camera(Camera&& rhs) -{ - *this = cd::MoveTemp(rhs); -} - -Camera& Camera::operator=(Camera&& rhs) -{ - std::swap(m_pCameraImpl, rhs.m_pCameraImpl); - return *this; -} - -Camera::~Camera() -{ - if (m_pCameraImpl) - { - delete m_pCameraImpl; - m_pCameraImpl = nullptr; - } -} - PIMPL_SIMPLE_TYPE_APIS(Camera, ID); PIMPL_SIMPLE_TYPE_APIS(Camera, Aspect); PIMPL_SIMPLE_TYPE_APIS(Camera, Fov); @@ -49,28 +21,4 @@ PIMPL_COMPLEX_TYPE_APIS(Camera, LookAt); PIMPL_COMPLEX_TYPE_APIS(Camera, Up); PIMPL_STRING_TYPE_APIS(Camera, Name); -Camera& Camera::operator<<(InputArchive& inputArchive) -{ - *m_pCameraImpl << inputArchive; - return *this; -} - -Camera& Camera::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pCameraImpl << inputArchive; - return *this; -} - -const Camera& Camera::operator>>(OutputArchive& outputArchive) const -{ - *m_pCameraImpl >> outputArchive; - return *this; -} - -const Camera& Camera::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pCameraImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/CameraImpl.h b/private/Scene/CameraImpl.h index 1e2b5dbb..fd6078c1 100644 --- a/private/Scene/CameraImpl.h +++ b/private/Scene/CameraImpl.h @@ -14,19 +14,9 @@ namespace cd class CameraImpl final { public: - CameraImpl() = delete; - template - explicit CameraImpl(TInputArchive& inputArchive) - { - *this << inputArchive; - } - explicit CameraImpl(CameraID id, std::string name); - CameraImpl(const CameraImpl&) = default; - CameraImpl& operator=(const CameraImpl&) = default; - CameraImpl(CameraImpl&&) = default; - CameraImpl& operator=(CameraImpl&&) = default; - ~CameraImpl() = default; + DECLARE_SCENE_IMPL_CLASS(Camera); + explicit CameraImpl(CameraID id, std::string name); void Init(CameraID id, std::string name); IMPLEMENT_SIMPLE_TYPE_APIS(Camera, ID); diff --git a/private/Scene/Light.cpp b/private/Scene/Light.cpp index 1154f06e..031a73f7 100644 --- a/private/Scene/Light.cpp +++ b/private/Scene/Light.cpp @@ -4,41 +4,13 @@ namespace cd { -Light::Light(InputArchive& inputArchive) -{ - m_pLightImpl = new LightImpl(inputArchive); -} - -Light::Light(InputArchiveSwapBytes& inputArchive) -{ - m_pLightImpl = new LightImpl(inputArchive); -} +PIMPL_SCENE_CLASS(Light); Light::Light(LightID lightID, const LightType type) { m_pLightImpl = new LightImpl(lightID, type); } -Light::Light(Light&& rhs) -{ - *this = cd::MoveTemp(rhs); -} - -Light& Light::operator=(Light&& rhs) -{ - std::swap(m_pLightImpl, rhs.m_pLightImpl); - return *this; -} - -Light::~Light() -{ - if (m_pLightImpl) - { - delete m_pLightImpl; - m_pLightImpl = nullptr; - } -} - void Light::Init(LightID lightID, LightType type) { m_pLightImpl->Init(lightID, type); @@ -64,28 +36,4 @@ PIMPL_COMPLEX_TYPE_APIS(Light, Direction); PIMPL_COMPLEX_TYPE_APIS(Light, Up); PIMPL_STRING_TYPE_APIS(Light, Name); -Light& Light::operator<<(InputArchive& inputArchive) -{ - *m_pLightImpl << inputArchive; - return *this; -} - -Light& Light::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pLightImpl << inputArchive; - return *this; -} - -const Light& Light::operator>>(OutputArchive& outputArchive) const -{ - *m_pLightImpl >> outputArchive; - return *this; -} - -const Light& Light::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pLightImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/LightImpl.cpp b/private/Scene/LightImpl.cpp index a298a4a3..1483f0ed 100644 --- a/private/Scene/LightImpl.cpp +++ b/private/Scene/LightImpl.cpp @@ -3,16 +3,6 @@ namespace cd { -LightImpl::LightImpl(InputArchive& inputArchive) -{ - *this << inputArchive; -} - -LightImpl::LightImpl(InputArchiveSwapBytes& inputArchive) -{ - *this << inputArchive; -} - LightImpl::LightImpl(LightID lightID, LightType type) { Init(lightID, type); diff --git a/private/Scene/LightImpl.h b/private/Scene/LightImpl.h index efb5a72b..e903509b 100644 --- a/private/Scene/LightImpl.h +++ b/private/Scene/LightImpl.h @@ -15,16 +15,9 @@ namespace cd class LightImpl final { public: - LightImpl() = delete; - explicit LightImpl(InputArchive& inputArchive); - explicit LightImpl(InputArchiveSwapBytes & inputArchive); - explicit LightImpl(LightID lightID, LightType type); - LightImpl(const LightImpl&) = default; - LightImpl& operator=(const LightImpl&) = default; - LightImpl(LightImpl&&) = default; - LightImpl& operator=(LightImpl&&) = default; - ~LightImpl() = default; + DECLARE_SCENE_IMPL_CLASS(Light); + explicit LightImpl(LightID lightID, LightType type); void Init(LightID lightID, LightType type); IMPLEMENT_SIMPLE_TYPE_APIS(Light, ID); @@ -54,6 +47,7 @@ class LightImpl final inputArchive >> GetName() >> GetIntensity() >> GetRange() >> GetRadius() >> GetWidth() >> GetHeight() >> GetAngleScale() >> GetAngleOffset() >> GetColor() >> GetPosition() >> GetDirection() >> GetUp(); + return *this; } diff --git a/private/Scene/Material.cpp b/private/Scene/Material.cpp index 25fc4ca1..bb7e6877 100644 --- a/private/Scene/Material.cpp +++ b/private/Scene/Material.cpp @@ -4,41 +4,13 @@ namespace cd { -Material::Material(InputArchive& inputArchive) -{ - m_pMaterialImpl = new MaterialImpl(inputArchive); -} - -Material::Material(InputArchiveSwapBytes& inputArchive) -{ - m_pMaterialImpl = new MaterialImpl(inputArchive); -} +PIMPL_SCENE_CLASS(Material); Material::Material(MaterialID materialID, const char* pMaterialName, MaterialType type) { m_pMaterialImpl = new MaterialImpl(materialID, pMaterialName, type); } -Material::Material(Material&& rhs) -{ - *this = cd::MoveTemp(rhs); -} - -Material& Material::operator=(Material&& rhs) -{ - std::swap(m_pMaterialImpl, rhs.m_pMaterialImpl); - return *this; -} - -Material::~Material() -{ - if (m_pMaterialImpl) - { - delete m_pMaterialImpl; - m_pMaterialImpl = nullptr; - } -} - void Material::Init(MaterialID materialID, const char* pMaterialName, MaterialType type) { m_pMaterialImpl->Init(materialID, pMaterialName, type); @@ -185,28 +157,4 @@ bool Material::ExistProperty(MaterialPropertyGroup propertyGroup, MaterialProper return m_pMaterialImpl->ExistProperty(propertyGroup, property); } -Material& Material::operator<<(InputArchive& inputArchive) -{ - *m_pMaterialImpl << inputArchive; - return *this; -} - -Material& Material::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pMaterialImpl << inputArchive; - return *this; -} - -const Material& Material::operator>>(OutputArchive& outputArchive) const -{ - *m_pMaterialImpl >> outputArchive; - return *this; -} - -const Material& Material::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pMaterialImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/MaterialImpl.h b/private/Scene/MaterialImpl.h index 86f2a08a..9c5519b3 100644 --- a/private/Scene/MaterialImpl.h +++ b/private/Scene/MaterialImpl.h @@ -18,19 +18,9 @@ namespace cd class MaterialImpl final { public: - MaterialImpl() = delete; - template - explicit MaterialImpl(TInputArchive& inputArchive) - { - *this << inputArchive; - } - explicit MaterialImpl(MaterialID materialID, std::string materialName, MaterialType materialType); - MaterialImpl(const MaterialImpl&) = delete; - MaterialImpl& operator=(const MaterialImpl&) = delete; - MaterialImpl(MaterialImpl&&) = default; - MaterialImpl& operator=(MaterialImpl&&) = default; - ~MaterialImpl() = default; + DECLARE_SCENE_IMPL_CLASS(Material); + explicit MaterialImpl(MaterialID materialID, std::string materialName, MaterialType materialType); void Init(MaterialID materialID, std::string materialName, MaterialType materialType); void InitBasePBR(); diff --git a/private/Scene/Mesh.cpp b/private/Scene/Mesh.cpp index 6d784349..4546583d 100644 --- a/private/Scene/Mesh.cpp +++ b/private/Scene/Mesh.cpp @@ -6,6 +6,8 @@ namespace cd { +PIMPL_SCENE_CLASS(Mesh); + Mesh Mesh::FromHalfEdgeMesh(const HalfEdgeMesh& halfEdgeMesh, ConvertStrategy strategy) { Mesh mesh; @@ -14,16 +16,6 @@ Mesh Mesh::FromHalfEdgeMesh(const HalfEdgeMesh& halfEdgeMesh, ConvertStrategy st return mesh; } -Mesh::Mesh(InputArchive& inputArchive) -{ - m_pMeshImpl = new MeshImpl(inputArchive); -} - -Mesh::Mesh(InputArchiveSwapBytes& inputArchive) -{ - m_pMeshImpl = new MeshImpl(inputArchive); -} - Mesh::Mesh(uint32_t vertexCount, uint32_t polygonCount) { m_pMeshImpl = new MeshImpl(); @@ -37,26 +29,6 @@ Mesh::Mesh(MeshID id, const char* pName, uint32_t vertexCount, uint32_t polygonC m_pMeshImpl->SetName(pName); } -Mesh::Mesh(Mesh&& rhs) -{ - *this = cd::MoveTemp(rhs); -} - -Mesh& Mesh::operator=(Mesh&& rhs) -{ - std::swap(m_pMeshImpl, rhs.m_pMeshImpl); - return *this; -} - -Mesh::~Mesh() -{ - if (m_pMeshImpl) - { - delete m_pMeshImpl; - m_pMeshImpl = nullptr; - } -} - void Mesh::Init(uint32_t vertexCount, uint32_t polygonCount) { m_pMeshImpl->Init(vertexCount, polygonCount); @@ -252,31 +224,4 @@ cd::VertexID Mesh::GetPolygonVertexID(uint32_t polygonIndex, uint32_t vertexInde return m_pMeshImpl->GetPolygonVertexID(polygonIndex, vertexIndex); } -////////////////////////////////////////////////////////////////////////// -// Serialization -////////////////////////////////////////////////////////////////////////// -Mesh& Mesh::operator<<(InputArchive& inputArchive) -{ - *m_pMeshImpl << inputArchive; - return *this; -} - -Mesh& Mesh::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pMeshImpl << inputArchive; - return *this; -} - -const Mesh& Mesh::operator>>(OutputArchive& outputArchive) const -{ - *m_pMeshImpl >> outputArchive; - return *this; -} - -const Mesh& Mesh::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pMeshImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/MeshImpl.h b/private/Scene/MeshImpl.h index 42b7ee74..2bf7a712 100644 --- a/private/Scene/MeshImpl.h +++ b/private/Scene/MeshImpl.h @@ -24,19 +24,7 @@ class MeshImpl final void FromHalfEdgeMesh(const HalfEdgeMesh& halfEdgeMesh, ConvertStrategy strategy); public: - MeshImpl() = default; - - template - explicit MeshImpl(TInputArchive& inputArchive) - { - *this << inputArchive; - } - - MeshImpl(const MeshImpl&) = delete; - MeshImpl& operator=(const MeshImpl&) = delete; - MeshImpl(MeshImpl&&) = default; - MeshImpl& operator=(MeshImpl&&) = default; - ~MeshImpl() = default; + DECLARE_SCENE_IMPL_CLASS(Mesh); void Init(uint32_t vertexCount, uint32_t polygonCount); diff --git a/private/Scene/Morph.cpp b/private/Scene/Morph.cpp index 4467b9da..3c498b5f 100644 --- a/private/Scene/Morph.cpp +++ b/private/Scene/Morph.cpp @@ -6,15 +6,7 @@ namespace cd { -Morph::Morph(InputArchive& inputArchive) -{ - m_pMorphImpl = new MorphImpl(inputArchive); -} - -Morph::Morph(InputArchiveSwapBytes& inputArchive) -{ - m_pMorphImpl = new MorphImpl(inputArchive); -} +PIMPL_SCENE_CLASS(Morph); Morph::Morph(uint32_t vertexCount) { @@ -26,26 +18,6 @@ Morph::Morph(MorphID id, MeshID sourceMeshID, const char* pName, uint32_t vertex m_pMorphImpl = new MorphImpl(id, sourceMeshID, pName, vertexCount); } -Morph::Morph(Morph&& rhs) -{ - *this = cd::MoveTemp(rhs); -} - -Morph& Morph::operator=(Morph&& rhs) -{ - std::swap(m_pMorphImpl, rhs.m_pMorphImpl); - return *this; -} - -Morph::~Morph() -{ - if (m_pMorphImpl) - { - delete m_pMorphImpl; - m_pMorphImpl = nullptr; - } -} - void Morph::Init(uint32_t vertexCount) { m_pMorphImpl->Init(vertexCount); @@ -67,28 +39,4 @@ PIMPL_VECTOR_TYPE_APIS(Morph, VertexTangent); PIMPL_VECTOR_TYPE_APIS(Morph, VertexBiTangent); PIMPL_STRING_TYPE_APIS(Morph, Name); -Morph& Morph::operator<<(InputArchive& inputArchive) -{ - *m_pMorphImpl << inputArchive; - return *this; -} - -Morph& Morph::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pMorphImpl << inputArchive; - return *this; -} - -const Morph& Morph::operator>>(OutputArchive& outputArchive) const -{ - *m_pMorphImpl >> outputArchive; - return *this; -} - -const Morph& Morph::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pMorphImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/MorphImpl.h b/private/Scene/MorphImpl.h index e0d1d139..bb021b59 100644 --- a/private/Scene/MorphImpl.h +++ b/private/Scene/MorphImpl.h @@ -15,23 +15,10 @@ namespace cd class MorphImpl final { public: - MorphImpl() = delete; - - template - explicit MorphImpl(TInputArchive& inputArchive) - { - *this << inputArchive; - } + DECLARE_SCENE_IMPL_CLASS(Morph); explicit MorphImpl(uint32_t vertexCount); explicit MorphImpl(MorphID id, MeshID sourceMeshID, std::string name, uint32_t vertexCount); - - MorphImpl(const MorphImpl&) = default; - MorphImpl& operator=(const MorphImpl&) = default; - MorphImpl(MorphImpl&&) = default; - MorphImpl& operator=(MorphImpl&&) = default; - ~MorphImpl() = default; - void Init(uint32_t vertexCount); void Init(MorphID id, std::string name, uint32_t vertexCount); diff --git a/private/Scene/Node.cpp b/private/Scene/Node.cpp index 1d13b8d8..b74e65fb 100644 --- a/private/Scene/Node.cpp +++ b/private/Scene/Node.cpp @@ -4,41 +4,13 @@ namespace cd { -Node::Node(InputArchive& inputArchive) -{ - m_pNodeImpl = new NodeImpl(inputArchive); -} - -Node::Node(InputArchiveSwapBytes& inputArchive) -{ - m_pNodeImpl = new NodeImpl(inputArchive); -} +PIMPL_SCENE_CLASS(Node); Node::Node(NodeID nodeID, std::string name) { m_pNodeImpl = new NodeImpl(nodeID, cd::MoveTemp(name)); } -Node::Node(Node&& rhs) -{ - *this = cd::MoveTemp(rhs); -} - -Node& Node::operator=(Node&& rhs) -{ - std::swap(m_pNodeImpl, rhs.m_pNodeImpl); - return *this; -} - -Node::~Node() -{ - if (m_pNodeImpl) - { - delete m_pNodeImpl; - m_pNodeImpl = nullptr; - } -} - void Node::Init(NodeID nodeID, std::string name) { m_pNodeImpl->Init(nodeID, cd::MoveTemp(name)); @@ -51,28 +23,4 @@ PIMPL_VECTOR_TYPE_APIS(Node, ChildID); PIMPL_VECTOR_TYPE_APIS(Node, MeshID); PIMPL_STRING_TYPE_APIS(Node, Name); -Node& Node::operator<<(InputArchive& inputArchive) -{ - *m_pNodeImpl << inputArchive; - return *this; -} - -Node& Node::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pNodeImpl << inputArchive; - return *this; -} - -const Node& Node::operator>>(OutputArchive& outputArchive) const -{ - *m_pNodeImpl >> outputArchive; - return *this; -} - -const Node& Node::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pNodeImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/NodeImpl.h b/private/Scene/NodeImpl.h index 12d17db9..577ef596 100644 --- a/private/Scene/NodeImpl.h +++ b/private/Scene/NodeImpl.h @@ -15,19 +15,9 @@ namespace cd class NodeImpl final { public: - NodeImpl() = delete; - template - explicit NodeImpl(TInputArchive& inputArchive) - { - *this << inputArchive; - } - explicit NodeImpl(NodeID nodeID, std::string name); - NodeImpl(const NodeImpl&) = default; - NodeImpl& operator=(const NodeImpl&) = default; - NodeImpl(NodeImpl&&) = default; - NodeImpl& operator=(NodeImpl&&) = default; - ~NodeImpl() = default; + DECLARE_SCENE_IMPL_CLASS(Node); + explicit NodeImpl(NodeID nodeID, std::string name); void Init(NodeID nodeID, std::string name); IMPLEMENT_SIMPLE_TYPE_APIS(Node, ID); diff --git a/private/Scene/ParticleEmitter.cpp b/private/Scene/ParticleEmitter.cpp index 4b758133..1bb986d2 100644 --- a/private/Scene/ParticleEmitter.cpp +++ b/private/Scene/ParticleEmitter.cpp @@ -5,41 +5,13 @@ namespace cd { -ParticleEmitter::ParticleEmitter(InputArchive& inputArchive) -{ - m_pParticleEmitterImpl = new ParticleEmitterImpl(inputArchive); -} - -ParticleEmitter::ParticleEmitter(InputArchiveSwapBytes& inputArchive) -{ - m_pParticleEmitterImpl = new ParticleEmitterImpl(inputArchive); -} +PIMPL_SCENE_CLASS(ParticleEmitter); ParticleEmitter::ParticleEmitter(ParticleEmitterID id, const char* pName) { m_pParticleEmitterImpl = new ParticleEmitterImpl(id, cd::MoveTemp(pName)); } -ParticleEmitter::ParticleEmitter(ParticleEmitter&& rhs) -{ - *this = cd::MoveTemp(rhs); -} - -ParticleEmitter& ParticleEmitter::operator=(ParticleEmitter&& rhs) -{ - std::swap(m_pParticleEmitterImpl, rhs.m_pParticleEmitterImpl); - return *this; -} - -ParticleEmitter::~ParticleEmitter() -{ - if (m_pParticleEmitterImpl) - { - delete m_pParticleEmitterImpl; - m_pParticleEmitterImpl = nullptr; - } -} - PIMPL_SIMPLE_TYPE_APIS(ParticleEmitter, ID); PIMPL_SIMPLE_TYPE_APIS(ParticleEmitter, Type); PIMPL_COMPLEX_TYPE_APIS(ParticleEmitter, Position); @@ -50,28 +22,4 @@ PIMPL_COMPLEX_TYPE_APIS(ParticleEmitter, FixedRotation); PIMPL_COMPLEX_TYPE_APIS(ParticleEmitter, FixedScale); PIMPL_STRING_TYPE_APIS(ParticleEmitter, Name); -ParticleEmitter& ParticleEmitter::operator<<(InputArchive& inputArchive) -{ - *m_pParticleEmitterImpl << inputArchive; - return *this; -} - -ParticleEmitter& ParticleEmitter::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pParticleEmitterImpl << inputArchive; - return *this; -} - -const ParticleEmitter& ParticleEmitter::operator>>(OutputArchive& outputArchive) const -{ - *m_pParticleEmitterImpl >> outputArchive; - return *this; -} - -const ParticleEmitter& ParticleEmitter::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pParticleEmitterImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/ParticleEmitterImpl.h b/private/Scene/ParticleEmitterImpl.h index 5fe654d2..4fa7c5e5 100644 --- a/private/Scene/ParticleEmitterImpl.h +++ b/private/Scene/ParticleEmitterImpl.h @@ -13,19 +13,9 @@ namespace cd class ParticleEmitterImpl final { public: - ParticleEmitterImpl() = delete; - template - explicit ParticleEmitterImpl(TInputArchive& inputArchive) - { - *this << inputArchive; - } - explicit ParticleEmitterImpl(ParticleEmitterID id, std::string name); - ParticleEmitterImpl(const ParticleEmitterImpl&) = default; - ParticleEmitterImpl& operator=(const ParticleEmitterImpl&) = default; - ParticleEmitterImpl(ParticleEmitterImpl&&) = default; - ParticleEmitterImpl& operator=(ParticleEmitterImpl&&) = default; - ~ParticleEmitterImpl() = default; + DECLARE_SCENE_IMPL_CLASS(ParticleEmitter); + explicit ParticleEmitterImpl(ParticleEmitterID id, std::string name); void Init(ParticleEmitterID id, std::string name); IMPLEMENT_SIMPLE_TYPE_APIS(ParticleEmitter, ID); diff --git a/private/Scene/SceneDatabase.cpp b/private/Scene/SceneDatabase.cpp index 6f5dbdc1..e51e7548 100644 --- a/private/Scene/SceneDatabase.cpp +++ b/private/Scene/SceneDatabase.cpp @@ -31,370 +31,25 @@ SceneDatabase::~SceneDatabase() } } -void SceneDatabase::SetName(const char* pName) -{ - m_pSceneDatabaseImpl->SetName(pName); -} - -const char* SceneDatabase::GetName() const -{ - return m_pSceneDatabaseImpl->GetName().c_str(); -} - -void SceneDatabase::SetAABB(AABB aabb) -{ - return m_pSceneDatabaseImpl->SetAABB(cd::MoveTemp(aabb)); -} - -AABB& SceneDatabase::GetAABB() -{ - return m_pSceneDatabaseImpl->GetAABB(); -} - -const AABB& SceneDatabase::GetAABB() const -{ - return m_pSceneDatabaseImpl->GetAABB(); -} - -void SceneDatabase::SetAxisSystem(AxisSystem axis) -{ - m_pSceneDatabaseImpl->SetAxisSystem(cd::MoveTemp(axis)); -} - -AxisSystem& SceneDatabase::GetAxisSystem() -{ - return m_pSceneDatabaseImpl->GetAxisSystem(); -} - -const AxisSystem& SceneDatabase::GetAxisSystem() const -{ - return m_pSceneDatabaseImpl->GetAxisSystem(); -} - -void SceneDatabase::SetUnit(Unit unit) -{ - m_pSceneDatabaseImpl->SetUnit(unit); -} - -Unit& SceneDatabase::GetUnit() -{ - return m_pSceneDatabaseImpl->GetUnit(); -} - -Unit SceneDatabase::GetUnit() const -{ - return m_pSceneDatabaseImpl->GetUnit(); -} - -/////////////////////////////////////////////////////////////////// -// Node -/////////////////////////////////////////////////////////////////// -void SceneDatabase::AddNode(Node node) -{ - return m_pSceneDatabaseImpl->AddNode(cd::MoveTemp(node)); -} - -std::vector& SceneDatabase::GetNodes() -{ - return m_pSceneDatabaseImpl->GetNodes(); -} - -const std::vector& SceneDatabase::GetNodes() const -{ - return m_pSceneDatabaseImpl->GetNodes(); -} - -void SceneDatabase::SetNodeCount(uint32_t nodeCount) -{ - return m_pSceneDatabaseImpl->SetNodeCount(nodeCount); -} - -Node& SceneDatabase::GetNode(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetNode(index); -} - -const Node& SceneDatabase::GetNode(uint32_t index) const -{ - return m_pSceneDatabaseImpl->GetNode(index); -} - -Node* SceneDatabase::GetNodeByName(const char* pName) -{ - return m_pSceneDatabaseImpl->GetNodeByName(pName); -} - -const Node* SceneDatabase::GetNodeByName(const char* pName) const -{ - return m_pSceneDatabaseImpl->GetNodeByName(pName); -} - -uint32_t SceneDatabase::GetNodeCount() const -{ - return m_pSceneDatabaseImpl->GetNodeCount(); -} - -/////////////////////////////////////////////////////////////////// -// Mesh -/////////////////////////////////////////////////////////////////// -void SceneDatabase::AddMesh(Mesh mesh) -{ - return m_pSceneDatabaseImpl->AddMesh(cd::MoveTemp(mesh)); -} - -std::vector& SceneDatabase::GetMeshes() -{ - return m_pSceneDatabaseImpl->GetMeshes(); -} - -const std::vector& SceneDatabase::GetMeshes() const -{ - return m_pSceneDatabaseImpl->GetMeshes(); -} - -void SceneDatabase::SetMeshCount(uint32_t meshCount) -{ - return m_pSceneDatabaseImpl->SetMeshCount(meshCount); -} - -Mesh& SceneDatabase::GetMesh(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetMesh(index); -} - -const Mesh& SceneDatabase::GetMesh(uint32_t index) const -{ - return m_pSceneDatabaseImpl->GetMesh(index); -} - -uint32_t SceneDatabase::GetMeshCount() const -{ - return m_pSceneDatabaseImpl->GetMeshCount(); -} - -/////////////////////////////////////////////////////////////////// -// Morph -/////////////////////////////////////////////////////////////////// -void SceneDatabase::AddMorph(Morph morph) -{ - return m_pSceneDatabaseImpl->AddMorph(cd::MoveTemp(morph)); -} - -std::vector& SceneDatabase::GetMorphs() -{ - return m_pSceneDatabaseImpl->GetMorphs(); -} - -const std::vector& SceneDatabase::GetMorphs() const -{ - return m_pSceneDatabaseImpl->GetMorphs(); -} - -void SceneDatabase::SetMorphCount(uint32_t morphCount) -{ - return m_pSceneDatabaseImpl->SetMorphCount(morphCount); -} - -Morph& SceneDatabase::GetMorph(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetMorph(index); -} - -const Morph& SceneDatabase::GetMorph(uint32_t index) const -{ - return m_pSceneDatabaseImpl->GetMorph(index); -} - -uint32_t SceneDatabase::GetMorphCount() const -{ - return m_pSceneDatabaseImpl->GetMorphCount(); -} - -/////////////////////////////////////////////////////////////////// -// Material -/////////////////////////////////////////////////////////////////// -void SceneDatabase::AddMaterial(Material material) -{ - return m_pSceneDatabaseImpl->AddMaterial(cd::MoveTemp(material)); -} - -std::vector& SceneDatabase::GetMaterials() -{ - return m_pSceneDatabaseImpl->GetMaterials(); -} - -const std::vector& SceneDatabase::GetMaterials() const -{ - return m_pSceneDatabaseImpl->GetMaterials(); -} - -void SceneDatabase::SetMaterialCount(uint32_t materialCount) -{ - return m_pSceneDatabaseImpl->SetMaterialCount(materialCount); -} - -Material& SceneDatabase::GetMaterial(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetMaterial(index); -} - -const Material& SceneDatabase::GetMaterial(uint32_t index) const -{ - return m_pSceneDatabaseImpl->GetMaterial(index); -} - -uint32_t SceneDatabase::GetMaterialCount() const -{ - return m_pSceneDatabaseImpl->GetMaterialCount(); -} - -/////////////////////////////////////////////////////////////////// -// Texture -/////////////////////////////////////////////////////////////////// -void SceneDatabase::AddTexture(Texture texture) -{ - return m_pSceneDatabaseImpl->AddTexture(cd::MoveTemp(texture)); -} - -std::vector& SceneDatabase::GetTextures() -{ - return m_pSceneDatabaseImpl->GetTextures(); -} - -const std::vector& SceneDatabase::GetTextures() const -{ - return m_pSceneDatabaseImpl->GetTextures(); -} - -void SceneDatabase::SetTextureCount(uint32_t textureCount) -{ - return m_pSceneDatabaseImpl->SetTextureCount(textureCount); -} - -Texture& SceneDatabase::GetTexture(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetTexture(index); -} - -const Texture& SceneDatabase::GetTexture(uint32_t index) const -{ - return m_pSceneDatabaseImpl->GetTexture(index); -} - -uint32_t SceneDatabase::GetTextureCount() const -{ - return m_pSceneDatabaseImpl->GetTextureCount(); -} - -/////////////////////////////////////////////////////////////////// -// Camera -/////////////////////////////////////////////////////////////////// -void SceneDatabase::AddCamera(Camera camera) -{ - return m_pSceneDatabaseImpl->AddCamera(cd::MoveTemp(camera)); -} - -std::vector& SceneDatabase::GetCameras() -{ - return m_pSceneDatabaseImpl->GetCameras(); -} - -const std::vector& SceneDatabase::GetCameras() const -{ - return m_pSceneDatabaseImpl->GetCameras(); -} - -void SceneDatabase::SetCameraCount(uint32_t cameraCount) -{ - return m_pSceneDatabaseImpl->SetCameraCount(cameraCount); -} - -Camera& SceneDatabase::GetCamera(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetCamera(index); -} - -const Camera& SceneDatabase::GetCamera(uint32_t index) const -{ - return m_pSceneDatabaseImpl->GetCamera(index); -} - -uint32_t SceneDatabase::GetCameraCount() const -{ - return m_pSceneDatabaseImpl->GetCameraCount(); -} - -/////////////////////////////////////////////////////////////////// -// Light -/////////////////////////////////////////////////////////////////// -void SceneDatabase::AddLight(Light light) -{ - return m_pSceneDatabaseImpl->AddLight(cd::MoveTemp(light)); -} - -std::vector& SceneDatabase::GetLights() -{ - return m_pSceneDatabaseImpl->GetLights(); -} - -const std::vector& SceneDatabase::GetLights() const -{ - return m_pSceneDatabaseImpl->GetLights(); -} - -void SceneDatabase::SetLightCount(uint32_t lightCount) -{ - return m_pSceneDatabaseImpl->SetLightCount(lightCount); -} - -Light& SceneDatabase::GetLight(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetLight(index); -} - -const Light& SceneDatabase::GetLight(uint32_t index) const -{ - return m_pSceneDatabaseImpl->GetLight(index); -} - -uint32_t SceneDatabase::GetLightCount() const -{ - return m_pSceneDatabaseImpl->GetLightCount(); -} +PIMPL_SIMPLE_TYPE_APIS(SceneDatabase, Unit); +PIMPL_COMPLEX_TYPE_APIS(SceneDatabase, AABB); +PIMPL_COMPLEX_TYPE_APIS(SceneDatabase, AxisSystem); +PIMPL_VECTOR_TYPE_APIS(SceneDatabase, Animation); +PIMPL_VECTOR_TYPE_APIS(SceneDatabase, Bone); +PIMPL_VECTOR_TYPE_APIS(SceneDatabase, Camera); +PIMPL_VECTOR_TYPE_APIS(SceneDatabase, Light); +PIMPL_VECTOR_TYPE_APIS(SceneDatabase, Material); +PIMPL_VECTOR_TYPE_APIS_WITH_PLURAL(SceneDatabase, Mesh, es); +PIMPL_VECTOR_TYPE_APIS(SceneDatabase, Morph); +PIMPL_VECTOR_TYPE_APIS(SceneDatabase, Node); +PIMPL_VECTOR_TYPE_APIS(SceneDatabase, ParticleEmitter); +PIMPL_VECTOR_TYPE_APIS(SceneDatabase, Texture); +PIMPL_VECTOR_TYPE_APIS(SceneDatabase, Track); +PIMPL_STRING_TYPE_APIS(SceneDatabase, Name); /////////////////////////////////////////////////////////////////// // Bone /////////////////////////////////////////////////////////////////// -void SceneDatabase::AddBone(Bone bone) -{ - return m_pSceneDatabaseImpl->AddBone(cd::MoveTemp(bone)); -} - -std::vector& SceneDatabase::GetBones() -{ - return m_pSceneDatabaseImpl->GetBones(); -} - -const std::vector& SceneDatabase::GetBones() const -{ - return m_pSceneDatabaseImpl->GetBones(); -} - -void SceneDatabase::SetBoneCount(uint32_t boneCount) -{ - return m_pSceneDatabaseImpl->SetBoneCount(boneCount); -} - -Bone& SceneDatabase::GetBone(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetBone(index); -} - -const Bone& SceneDatabase::GetBone(uint32_t index) const -{ - return m_pSceneDatabaseImpl->GetBone(index); -} - Bone* SceneDatabase::GetBoneByName(const char* pName) { return m_pSceneDatabaseImpl->GetBoneByName(pName); @@ -405,80 +60,25 @@ const Bone* SceneDatabase::GetBoneByName(const char* pName) const return m_pSceneDatabaseImpl->GetBoneByName(pName); } -uint32_t SceneDatabase::GetBoneCount() const -{ - return m_pSceneDatabaseImpl->GetBoneCount(); -} - /////////////////////////////////////////////////////////////////// -// Animation +// Node /////////////////////////////////////////////////////////////////// -void SceneDatabase::AddAnimation(Animation animation) -{ - return m_pSceneDatabaseImpl->AddAnimation(cd::MoveTemp(animation)); -} - -std::vector& SceneDatabase::GetAnimations() -{ - return m_pSceneDatabaseImpl->GetAnimations(); -} - -const std::vector& SceneDatabase::GetAnimations() const -{ - return m_pSceneDatabaseImpl->GetAnimations(); -} - -void SceneDatabase::SetAnimationCount(uint32_t animationCount) -{ - return m_pSceneDatabaseImpl->SetAnimationCount(animationCount); -} - -Animation& SceneDatabase::GetAnimation(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetAnimation(index); -} - -const Animation& SceneDatabase::GetAnimation(uint32_t index) const +Node* SceneDatabase::GetNodeByName(const char* pName) { - return m_pSceneDatabaseImpl->GetAnimation(index); + return m_pSceneDatabaseImpl->GetNodeByName(pName); } -uint32_t SceneDatabase::GetAnimationCount() const +const Node* SceneDatabase::GetNodeByName(const char* pName) const { - return m_pSceneDatabaseImpl->GetAnimationCount(); + return m_pSceneDatabaseImpl->GetNodeByName(pName); } /////////////////////////////////////////////////////////////////// // Track /////////////////////////////////////////////////////////////////// -void SceneDatabase::AddTrack(Track track) -{ - return m_pSceneDatabaseImpl->AddTrack(cd::MoveTemp(track)); -} - -std::vector& SceneDatabase::GetTracks() +Track* SceneDatabase::GetTrackByName(const char* pName) { - return m_pSceneDatabaseImpl->GetTracks(); -} - -const std::vector& SceneDatabase::GetTracks() const -{ - return m_pSceneDatabaseImpl->GetTracks(); -} - -void SceneDatabase::SetTrackCount(uint32_t animationCount) -{ - return m_pSceneDatabaseImpl->SetTrackCount(animationCount); -} - -Track& SceneDatabase::GetTrack(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetTrack(index); -} - -const Track& SceneDatabase::GetTrack(uint32_t index) const -{ - return m_pSceneDatabaseImpl->GetTrack(index); + return m_pSceneDatabaseImpl->GetTrackByName(pName); } const Track* SceneDatabase::GetTrackByName(const char* pName) const @@ -486,49 +86,6 @@ const Track* SceneDatabase::GetTrackByName(const char* pName) const return m_pSceneDatabaseImpl->GetTrackByName(pName); } -uint32_t SceneDatabase::GetTrackCount() const -{ - return m_pSceneDatabaseImpl->GetTrackCount(); -} - -/////////////////////////////////////////////////////////////////// -// ParticleEmitter -/////////////////////////////////////////////////////////////////// -void SceneDatabase::AddParticleEmitter(ParticleEmitter emitter) -{ - return m_pSceneDatabaseImpl->AddParticleEmitter(cd::MoveTemp(emitter)); -} - -std::vector& SceneDatabase::GetParticleEmitters() -{ - return m_pSceneDatabaseImpl->GetParticleEmitters(); -} - -const std::vector& SceneDatabase::GetParticleEmitters() const -{ - return m_pSceneDatabaseImpl->GetParticleEmitters(); -} - -void SceneDatabase::SetParticleEmitterCount(uint32_t emitterCount) -{ - return m_pSceneDatabaseImpl->SetParticleEmitterCount(emitterCount); -} - -ParticleEmitter& SceneDatabase::GetParticleEmitter(uint32_t index) -{ - return m_pSceneDatabaseImpl->GetParticleEmitter(index); -} - -const ParticleEmitter& SceneDatabase::GetParticleEmitter(uint32_t index) const -{ - return m_pSceneDatabaseImpl->GetParticleEmitter(index); -} - -uint32_t SceneDatabase::GetParticleEmitterCount() const -{ - return m_pSceneDatabaseImpl->GetParticleEmitterCount(); -} - /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// void SceneDatabase::Dump() const diff --git a/private/Scene/SceneDatabaseImpl.cpp b/private/Scene/SceneDatabaseImpl.cpp index 79239623..a74981a3 100644 --- a/private/Scene/SceneDatabaseImpl.cpp +++ b/private/Scene/SceneDatabaseImpl.cpp @@ -49,13 +49,13 @@ namespace cd SceneDatabaseImpl::SceneDatabaseImpl() { - m_aabb.Clear(); + GetAABB().Clear(); // By default, it will be CDEngine for conveniences. // If you are outside user in other platforms, you can set it by yourself. // TODO : add a update method to change axis system for SceneDatabase dynamicly. - m_axisSystem = AxisSystem::CDEngine(); - m_unit = Unit::CenterMeter; + SetAxisSystem(AxisSystem::CDEngine()); + SetUnit(Unit::CenterMeter); } /////////////////////////////////////////////////////////////////// @@ -63,7 +63,7 @@ SceneDatabaseImpl::SceneDatabaseImpl() /////////////////////////////////////////////////////////////////// Node* SceneDatabaseImpl::GetNodeByName(const char* pName) { - for (auto& node : m_nodes) + for (auto& node : GetNodes()) { if (0 == strcmp(pName, node.GetName())) { @@ -76,7 +76,7 @@ Node* SceneDatabaseImpl::GetNodeByName(const char* pName) const Node* SceneDatabaseImpl::GetNodeByName(const char* pName) const { - for (const auto& node : m_nodes) + for (const auto& node : GetNodes()) { if (0 == strcmp(pName, node.GetName())) { @@ -92,7 +92,7 @@ const Node* SceneDatabaseImpl::GetNodeByName(const char* pName) const /////////////////////////////////////////////////////////////////// Bone* SceneDatabaseImpl::GetBoneByName(const char* pName) { - for (auto& bone : m_bones) + for (auto& bone : GetBones()) { if (0 == strcmp(pName, bone.GetName())) { @@ -105,7 +105,7 @@ Bone* SceneDatabaseImpl::GetBoneByName(const char* pName) const Bone* SceneDatabaseImpl::GetBoneByName(const char* pName) const { - for (const auto& bone : m_bones) + for (const auto& bone : GetBones()) { if (0 == strcmp(pName, bone.GetName())) { @@ -119,9 +119,22 @@ const Bone* SceneDatabaseImpl::GetBoneByName(const char* pName) const /////////////////////////////////////////////////////////////////// // Track /////////////////////////////////////////////////////////////////// +Track* SceneDatabaseImpl::GetTrackByName(const char* pName) +{ + for (auto& track : GetTracks()) + { + if (0 == strcmp(pName, track.GetName())) + { + return &track; + } + } + + return nullptr; +} + const Track* SceneDatabaseImpl::GetTrackByName(const char* pName) const { - for (const auto& track : m_tracks) + for (const auto& track : GetTracks()) { if (0 == strcmp(pName, track.GetName())) { diff --git a/private/Scene/SceneDatabaseImpl.h b/private/Scene/SceneDatabaseImpl.h index 060fefe8..6e66f5d5 100644 --- a/private/Scene/SceneDatabaseImpl.h +++ b/private/Scene/SceneDatabaseImpl.h @@ -17,6 +17,7 @@ #include #include +#include namespace cd { @@ -34,128 +35,33 @@ class SceneDatabaseImpl SceneDatabaseImpl& operator=(SceneDatabaseImpl&&) = default; ~SceneDatabaseImpl() = default; - // Identity - void SetName(std::string sceneName) { m_name = MoveTemp(sceneName); } - const std::string& GetName() const { return m_name; } - - // Volumn - void SetAABB(AABB aabb) { m_aabb = MoveTemp(aabb); } - AABB& GetAABB() { return m_aabb; } - const AABB& GetAABB() const { return m_aabb; } - - // AxisSystem - void SetAxisSystem(AxisSystem axis) { m_axisSystem = MoveTemp(axis); } - AxisSystem& GetAxisSystem() { return m_axisSystem; } - const AxisSystem& GetAxisSystem() const { return m_axisSystem; } - - // Unit - void SetUnit(Unit unit) { m_unit = unit; } - Unit& GetUnit() { return m_unit; } - Unit GetUnit() const { return m_unit; } - - // Node - void AddNode(Node node) { m_nodes.emplace_back(MoveTemp(node)); } - std::vector& GetNodes() { return m_nodes; } - const std::vector& GetNodes() const { return m_nodes; } - void SetNodeCount(uint32_t count) { m_nodes.reserve(count); } - Node& GetNode(uint32_t index) { return m_nodes[index]; } - const Node& GetNode(uint32_t index) const { return m_nodes[index]; } - Node* GetNodeByName(const char* pName); - const Node* GetNodeByName(const char* pName) const; - uint32_t GetNodeCount() const { return static_cast(m_nodes.size()); } - - // Mesh - void AddMesh(Mesh mesh) { m_meshes.emplace_back(MoveTemp(mesh)); } - std::vector& GetMeshes() { return m_meshes; } - const std::vector& GetMeshes() const { return m_meshes; } - void SetMeshCount(uint32_t count) { m_meshes.reserve(count); } - Mesh& GetMesh(uint32_t index) { return m_meshes[index]; } - const Mesh& GetMesh(uint32_t index) const { return m_meshes[index]; } - uint32_t GetMeshCount() const { return static_cast(m_meshes.size()); } - - // Morph - void AddMorph(Morph morph) { m_morphs.emplace_back(MoveTemp(morph)); } - std::vector& GetMorphs() { return m_morphs; } - const std::vector& GetMorphs() const { return m_morphs; } - void SetMorphCount(uint32_t count) { m_morphs.reserve(count); } - Morph& GetMorph(uint32_t index) { return m_morphs[index]; } - const Morph& GetMorph(uint32_t index) const { return m_morphs[index]; } - uint32_t GetMorphCount() const { return static_cast(m_morphs.size()); } - - // Texture - void AddTexture(Texture texture) { m_textures.emplace_back(MoveTemp(texture)); } - std::vector& GetTextures() { return m_textures; } - const std::vector& GetTextures() const { return m_textures; } - void SetTextureCount(uint32_t count) { m_textures.reserve(count); } - Texture& GetTexture(uint32_t index) { return m_textures[index]; } - const Texture& GetTexture(uint32_t index) const { return m_textures[index]; } - uint32_t GetTextureCount() const { return static_cast(m_textures.size()); } - - // Material - void AddMaterial(Material material) { m_materials.emplace_back(MoveTemp(material)); } - std::vector& GetMaterials() { return m_materials; } - const std::vector& GetMaterials() const { return m_materials; } - void SetMaterialCount(uint32_t count) { m_materials.reserve(count); } - Material& GetMaterial(uint32_t index) { return m_materials[index]; } - const Material& GetMaterial(uint32_t index) const { return m_materials[index]; } - uint32_t GetMaterialCount() const { return static_cast(m_materials.size()); } - - // Camera - void AddCamera(Camera camera) { m_cameras.emplace_back(MoveTemp(camera)); } - std::vector& GetCameras() { return m_cameras; } - const std::vector& GetCameras() const { return m_cameras; } - void SetCameraCount(uint32_t count) { m_cameras.reserve(count); } - Camera& GetCamera(uint32_t index) { return m_cameras[index]; } - const Camera& GetCamera(uint32_t index) const { return m_cameras[index]; } - uint32_t GetCameraCount() const { return static_cast(m_cameras.size()); } - - // Light - void AddLight(Light light) { m_lights.emplace_back(MoveTemp(light)); } - std::vector& GetLights() { return m_lights; } - const std::vector& GetLights() const { return m_lights; } - void SetLightCount(uint32_t count) { m_lights.reserve(count); } - Light& GetLight(uint32_t index) { return m_lights[index]; } - const Light& GetLight(uint32_t index) const { return m_lights[index]; } - uint32_t GetLightCount() const { return static_cast(m_lights.size()); } + IMPLEMENT_SIMPLE_TYPE_APIS(SceneDatabase, Unit); + IMPLEMENT_COMPLEX_TYPE_APIS(SceneDatabase, AABB); + IMPLEMENT_COMPLEX_TYPE_APIS(SceneDatabase, AxisSystem); + IMPLEMENT_VECTOR_TYPE_APIS(SceneDatabase, Animation); + IMPLEMENT_VECTOR_TYPE_APIS(SceneDatabase, Bone); + IMPLEMENT_VECTOR_TYPE_APIS(SceneDatabase, Camera); + IMPLEMENT_VECTOR_TYPE_APIS(SceneDatabase, Light); + IMPLEMENT_VECTOR_TYPE_APIS(SceneDatabase, Material); + IMPLEMENT_VECTOR_TYPE_APIS_WITH_PLURAL(SceneDatabase, Mesh, es); + IMPLEMENT_VECTOR_TYPE_APIS(SceneDatabase, Morph); + IMPLEMENT_VECTOR_TYPE_APIS(SceneDatabase, Node); + IMPLEMENT_VECTOR_TYPE_APIS(SceneDatabase, ParticleEmitter); + IMPLEMENT_VECTOR_TYPE_APIS(SceneDatabase, Texture); + IMPLEMENT_VECTOR_TYPE_APIS(SceneDatabase, Track); + IMPLEMENT_STRING_TYPE_APIS(SceneDatabase, Name); // Bone - void AddBone(Bone bone) { m_bones.emplace_back(MoveTemp(bone)); } - std::vector& GetBones() { return m_bones; } - const std::vector& GetBones() const { return m_bones; } - void SetBoneCount(uint32_t count) { m_bones.reserve(count); } - Bone& GetBone(uint32_t index) { return m_bones[index]; } - const Bone& GetBone(uint32_t index) const { return m_bones[index]; } Bone* GetBoneByName(const char* pName); const Bone* GetBoneByName(const char* pName) const; - uint32_t GetBoneCount() const { return static_cast(m_bones.size()); } - // Animation - void AddAnimation(Animation animation) { m_animations.emplace_back(MoveTemp(animation)); } - std::vector& GetAnimations() { return m_animations; } - const std::vector& GetAnimations() const { return m_animations; } - void SetAnimationCount(uint32_t count) { m_animations.reserve(count); } - Animation& GetAnimation(uint32_t index) { return m_animations[index]; } - const Animation& GetAnimation(uint32_t index) const { return m_animations[index]; } - uint32_t GetAnimationCount() const { return static_cast(m_animations.size()); } + // Node + Node* GetNodeByName(const char* pName); + const Node* GetNodeByName(const char* pName) const; // Track - void AddTrack(Track Track) { m_tracks.emplace_back(MoveTemp(Track)); } - std::vector& GetTracks() { return m_tracks; } - const std::vector& GetTracks() const { return m_tracks; } - void SetTrackCount(uint32_t count) { m_tracks.reserve(count); } - Track& GetTrack(uint32_t index) { return m_tracks[index]; } - const Track& GetTrack(uint32_t index) const { return m_tracks[index]; } + Track* GetTrackByName(const char* pName); const Track* GetTrackByName(const char* pName) const; - uint32_t GetTrackCount() const { return static_cast(m_tracks.size()); } - - // ParticleEmitter - void AddParticleEmitter(ParticleEmitter emitter) { m_particleEmitters.emplace_back(MoveTemp(emitter)); } - std::vector& GetParticleEmitters() { return m_particleEmitters; } - const std::vector& GetParticleEmitters() const { return m_particleEmitters; } - void SetParticleEmitterCount(uint32_t count) { m_particleEmitters.reserve(count); } - ParticleEmitter& GetParticleEmitter(uint32_t index) { return m_particleEmitters[index]; } - const ParticleEmitter& GetParticleEmitter(uint32_t index) const { return m_particleEmitters[index]; } - uint32_t GetParticleEmitterCount() const { return static_cast(m_particleEmitters.size()); } void Dump() const; void Validate() const; @@ -345,35 +251,6 @@ class SceneDatabaseImpl return *this; } - -private: - std::string m_name; - AABB m_aabb; - AxisSystem m_axisSystem; - Unit m_unit; - - // Hierarchy data to present relationships between meshes. - std::vector m_nodes; - - // Mesh data both for StatciMesh and SkinMesh. - std::vector m_meshes; - std::vector m_morphs; - - // Texturing data. - std::vector m_materials; - std::vector m_textures; - - // Scene objects. - std::vector m_cameras; - std::vector m_lights; - - // Animation data. - std::vector m_bones; - std::vector m_animations; - std::vector m_tracks; - - //Particle data - std::vector m_particleEmitters; }; } \ No newline at end of file diff --git a/private/Scene/Texture.cpp b/private/Scene/Texture.cpp index 8e726cbc..27567a34 100644 --- a/private/Scene/Texture.cpp +++ b/private/Scene/Texture.cpp @@ -4,41 +4,13 @@ namespace cd { -Texture::Texture(InputArchive& inputArchive) -{ - m_pTextureImpl = new TextureImpl(inputArchive); -} - -Texture::Texture(InputArchiveSwapBytes& inputArchive) -{ - m_pTextureImpl = new TextureImpl(inputArchive); -} +PIMPL_SCENE_CLASS(Texture); Texture::Texture(TextureID textureID, const char* pName, MaterialTextureType textureType) { m_pTextureImpl = new TextureImpl(textureID, pName, textureType); } -Texture::Texture(Texture&& rhs) noexcept -{ - *this = cd::MoveTemp(rhs); -} - -Texture& Texture::operator=(Texture&& rhs) noexcept -{ - std::swap(m_pTextureImpl, rhs.m_pTextureImpl); - return *this; -} - -Texture::~Texture() -{ - if (m_pTextureImpl) - { - delete m_pTextureImpl; - m_pTextureImpl = nullptr; - } -} - PIMPL_SIMPLE_TYPE_APIS(Texture, ID); PIMPL_SIMPLE_TYPE_APIS(Texture, Type); PIMPL_SIMPLE_TYPE_APIS(Texture, Format); @@ -54,28 +26,4 @@ PIMPL_COMPLEX_TYPE_APIS(Texture, RawData); PIMPL_STRING_TYPE_APIS(Texture, Name); PIMPL_STRING_TYPE_APIS(Texture, Path); -Texture& Texture::operator<<(InputArchive& inputArchive) -{ - *m_pTextureImpl << inputArchive; - return *this; -} - -Texture& Texture::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pTextureImpl << inputArchive; - return *this; -} - -const Texture& Texture::operator>>(OutputArchive& outputArchive) const -{ - *m_pTextureImpl >> outputArchive; - return *this; -} - -const Texture& Texture::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pTextureImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/TextureImpl.h b/private/Scene/TextureImpl.h index 742cb5af..6c03337b 100644 --- a/private/Scene/TextureImpl.h +++ b/private/Scene/TextureImpl.h @@ -16,19 +16,9 @@ namespace cd class TextureImpl final { public: - TextureImpl() = delete; - template - explicit TextureImpl(TInputArchive& inputArchive) - { - *this << inputArchive; - } - explicit TextureImpl(TextureID textureID, const char* pName, MaterialTextureType textureType); - TextureImpl(const TextureImpl&) = default; - TextureImpl& operator=(const TextureImpl&) = default; - TextureImpl(TextureImpl&&) = default; - TextureImpl& operator=(TextureImpl&&) = default; - ~TextureImpl() = default; + DECLARE_SCENE_IMPL_CLASS(Texture); + explicit TextureImpl(TextureID textureID, const char* pName, MaterialTextureType textureType); void Init(TextureID textureID, std::string name, MaterialTextureType textureType); IMPLEMENT_SIMPLE_TYPE_APIS(Texture, ID); diff --git a/private/Scene/Track.cpp b/private/Scene/Track.cpp index 601e651c..4b6ce424 100644 --- a/private/Scene/Track.cpp +++ b/private/Scene/Track.cpp @@ -4,41 +4,13 @@ namespace cd { -Track::Track(InputArchive& inputArchive) -{ - m_pTrackImpl = new TrackImpl(inputArchive); -} - -Track::Track(InputArchiveSwapBytes& inputArchive) -{ - m_pTrackImpl = new TrackImpl(inputArchive); -} +PIMPL_SCENE_CLASS(Track); Track::Track(TrackID id, std::string name) { m_pTrackImpl = new TrackImpl(id, cd::MoveTemp(name)); } -Track::Track(Track&& rhs) -{ - *this = cd::MoveTemp(rhs); -} - -Track& Track::operator=(Track&& rhs) -{ - std::swap(m_pTrackImpl, rhs.m_pTrackImpl); - return *this; -} - -Track::~Track() -{ - if (m_pTrackImpl) - { - delete m_pTrackImpl; - m_pTrackImpl = nullptr; - } -} - void Track::Init(TrackID id, std::string name) { m_pTrackImpl->Init(id, cd::MoveTemp(name)); @@ -50,28 +22,4 @@ PIMPL_VECTOR_TYPE_APIS(Track, TranslationKey); PIMPL_VECTOR_TYPE_APIS(Track, RotationKey); PIMPL_VECTOR_TYPE_APIS(Track, ScaleKey); -Track& Track::operator<<(InputArchive& inputArchive) -{ - *m_pTrackImpl << inputArchive; - return *this; -} - -Track& Track::operator<<(InputArchiveSwapBytes& inputArchive) -{ - *m_pTrackImpl << inputArchive; - return *this; -} - -const Track& Track::operator>>(OutputArchive& outputArchive) const -{ - *m_pTrackImpl >> outputArchive; - return *this; -} - -const Track& Track::operator>>(OutputArchiveSwapBytes& outputArchive) const -{ - *m_pTrackImpl >> outputArchive; - return *this; -} - } \ No newline at end of file diff --git a/private/Scene/TrackImpl.h b/private/Scene/TrackImpl.h index c39a0deb..60df49a6 100644 --- a/private/Scene/TrackImpl.h +++ b/private/Scene/TrackImpl.h @@ -15,19 +15,9 @@ namespace cd class TrackImpl final { public: - TrackImpl() = delete; - template - explicit TrackImpl(TInputArchive& inputArchive) - { - *this << inputArchive; - } - explicit TrackImpl(TrackID id, std::string name); - TrackImpl(const TrackImpl&) = default; - TrackImpl& operator=(const TrackImpl&) = default; - TrackImpl(TrackImpl&&) = default; - TrackImpl& operator=(TrackImpl&&) = default; - ~TrackImpl() = default; + DECLARE_SCENE_IMPL_CLASS(Track); + explicit TrackImpl(TrackID id, std::string name); void Init(TrackID id, std::string name); IMPLEMENT_SIMPLE_TYPE_APIS(Track, ID); diff --git a/public/Math/MeshGenerator.h b/public/Math/MeshGenerator.h index af2514f9..7e4b8272 100644 --- a/public/Math/MeshGenerator.h +++ b/public/Math/MeshGenerator.h @@ -1,6 +1,7 @@ #pragma once #include "Base/Export.h" +#include "Scene/Mesh.h" #include #include @@ -12,8 +13,6 @@ namespace cd template class TBox; -class Mesh; - template class TPlane; diff --git a/public/Scene/APIMacros.h b/public/Scene/APIMacros.h index 65f31dea..886ef4e5 100644 --- a/public/Scene/APIMacros.h +++ b/public/Scene/APIMacros.h @@ -1,5 +1,56 @@ #pragma once +//////////////////////////////////////////////////////////////////////////////////////// +// Class Declration +//////////////////////////////////////////////////////////////////////////////////////// +#define DECLARE_SCENE_CLASS(Class) \ + static const char* GetClassName() { return #Class; } \ +public: \ + Class(); \ + explicit Class(InputArchive& inputArchive); \ + explicit Class(InputArchiveSwapBytes& inputArchive); \ + Class(const Class&) = delete; \ + Class& operator=(const Class&) = delete; \ + Class(Class&&); \ + Class& operator=(Class&&); \ + ~Class(); \ + Class& operator<<(InputArchive& inputArchive); \ + Class& operator<<(InputArchiveSwapBytes& inputArchive); \ + const Class& operator>>(OutputArchive& outputArchive) const; \ + const Class& operator>>(OutputArchiveSwapBytes& outputArchive) const; \ +private: \ + Class##Impl* m_p##Class##Impl = nullptr; \ +public: \ + +#define PIMPL_SCENE_CLASS(Class) \ + Class::Class() { m_p##Class##Impl = new Class##Impl(); } \ + Class::Class(InputArchive& inputArchive) { m_p##Class##Impl = new Class##Impl(inputArchive); } \ + Class::Class(InputArchiveSwapBytes& inputArchive) { m_p##Class##Impl = new Class##Impl(inputArchive); } \ + Class::Class(Class&& rhs) { *this = cd::MoveTemp(rhs); } \ + Class& Class::operator=(Class&& rhs) { std::swap(m_p##Class##Impl, rhs.m_p##Class##Impl); return *this; } \ + Class::~Class() \ + { \ + if (m_p##Class##Impl) \ + { \ + delete m_p##Class##Impl; \ + m_p##Class##Impl = nullptr; \ + } \ + } \ + Class& Class::operator<<(InputArchive& inputArchive) { *m_p##Class##Impl << inputArchive; return *this; } \ + Class& Class::operator<<(InputArchiveSwapBytes& inputArchive) { *m_p##Class##Impl << inputArchive; return *this; } \ + const Class& Class::operator>>(OutputArchive& inputArchive) const { *m_p##Class##Impl >> inputArchive; return *this; } \ + const Class& Class::operator>>(OutputArchiveSwapBytes& inputArchive) const { *m_p##Class##Impl >> inputArchive; return *this; } \ + +#define DECLARE_SCENE_IMPL_CLASS(Class) \ + Class##Impl() = default; \ + template \ + explicit Class##Impl(TInputArchive& inputArchive) { *this << inputArchive; } \ + Class##Impl(const Class##Impl&) = default; \ + Class##Impl& operator=(const Class##Impl&) = default; \ + Class##Impl(Class##Impl&&) = default; \ + Class##Impl& operator=(Class##Impl&&) = default; \ + ~Class##Impl() = default; \ + //////////////////////////////////////////////////////////////////////////////////////// // String Type //////////////////////////////////////////////////////////////////////////////////////// @@ -18,7 +69,7 @@ public: \ const Class##TypeTraits::Type& Get##Type() const { return m_##Type; } \ private: \ Class##TypeTraits::Type m_##Type; \ -public: +public: \ //////////////////////////////////////////////////////////////////////////////////////// // Simple Type : bool, char, int, uint, float, double, ... in small size @@ -31,7 +82,7 @@ private: \ #define PIMPL_SIMPLE_TYPE_APIS(Class, Type) \ void Class::Set##Type(Class##TypeTraits::Type value) { return m_p##Class##Impl->Set##Type(cd::MoveTemp(value)); } \ Class##TypeTraits::Type& Class::Get##Type() { return m_p##Class##Impl->Get##Type(); } \ - Class##TypeTraits::Type Class::Get##Type() const { return m_p##Class##Impl->Get##Type(); } + Class##TypeTraits::Type Class::Get##Type() const { return m_p##Class##Impl->Get##Type(); } \ #define IMPLEMENT_SIMPLE_TYPE_APIS(Class, Type) \ public: \ @@ -40,7 +91,7 @@ public: \ Class##TypeTraits::Type Get##Type() const { return m_##Type; } \ private: \ Class##TypeTraits::Type m_##Type; \ -public: +public: \ //////////////////////////////////////////////////////////////////////////////////////// // Complex Type : customized class, ... in large size @@ -62,47 +113,52 @@ public: \ const Class##TypeTraits::Type& Get##Type() const { return m_##Type; } \ private: \ Class##TypeTraits::Type m_##Type; \ -public: +public: \ //////////////////////////////////////////////////////////////////////////////////////// // Vector Type //////////////////////////////////////////////////////////////////////////////////////// -#define EXPORT_VECTOR_TYPE_APIS(Class, Type) \ +#define EXPORT_VECTOR_TYPE_APIS_WITH_PLURAL(Class, Type, Plural) \ void Set##Type##Capacity(uint32_t count); \ void Set##Type##Count(uint32_t count); \ uint32_t Get##Type##Count() const; \ - void Set##Type##s(std::vector elements); \ + void Set##Type##Plural(std::vector elements); \ void Set##Type(uint32_t index, Class##TypeTraits::Type element); \ - std::vector& Get##Type##s(); \ - const std::vector& Get##Type##s() const; \ + std::vector& Get##Type##Plural(); \ + const std::vector& Get##Type##Plural() const; \ Class##TypeTraits::Type& Get##Type(uint32_t index); \ const Class##TypeTraits::Type& Get##Type(uint32_t index) const; \ - void Add##Type(Class##TypeTraits::Type element); + void Add##Type(Class##TypeTraits::Type element); \ -#define PIMPL_VECTOR_TYPE_APIS(Class, Type) \ +#define PIMPL_VECTOR_TYPE_APIS_WITH_PLURAL(Class, Type, Plural) \ void Class::Set##Type##Capacity(uint32_t count) { m_p##Class##Impl->Set##Type##Capacity(count); } \ void Class::Set##Type##Count(uint32_t count) { m_p##Class##Impl->Set##Type##Count(count); } \ uint32_t Class::Get##Type##Count() const { return m_p##Class##Impl->Get##Type##Count(); } \ - void Class::Set##Type##s(std::vector elements) { m_p##Class##Impl->Set##Type##s(cd::MoveTemp(elements)); } \ + void Class::Set##Type##Plural(std::vector elements) { m_p##Class##Impl->Set##Type##Plural(cd::MoveTemp(elements)); } \ void Class::Set##Type(uint32_t index, Class##TypeTraits::Type element) { m_p##Class##Impl->Set##Type(index, cd::MoveTemp(element)); } \ - std::vector& Class::Get##Type##s() { return m_p##Class##Impl->Get##Type##s(); } \ - const std::vector& Class::Get##Type##s() const { return m_p##Class##Impl->Get##Type##s(); } \ + std::vector& Class::Get##Type##Plural() { return m_p##Class##Impl->Get##Type##Plural(); } \ + const std::vector& Class::Get##Type##Plural() const { return m_p##Class##Impl->Get##Type##Plural(); } \ Class##TypeTraits::Type& Class::Get##Type(uint32_t index) { return m_p##Class##Impl->Get##Type(index); } \ const Class##TypeTraits::Type& Class::Get##Type(uint32_t index) const { return m_p##Class##Impl->Get##Type(index); } \ - void Class::Add##Type(Class##TypeTraits::Type element) { m_p##Class##Impl->Add##Type(cd::MoveTemp(element)); } + void Class::Add##Type(Class##TypeTraits::Type element) { m_p##Class##Impl->Add##Type(cd::MoveTemp(element)); } \ -#define IMPLEMENT_VECTOR_TYPE_APIS(Class, Type) \ +#define IMPLEMENT_VECTOR_TYPE_APIS_WITH_PLURAL(Class, Type, Plural) \ public: \ - void Set##Type##Capacity(uint32_t count) { m_##Type##s.reserve(count); } \ - void Set##Type##Count(uint32_t count) { m_##Type##s.resize(count); } \ - uint32_t Get##Type##Count() const { return static_cast(m_##Type##s.size()); } \ - void Set##Type##s(std::vector elements) { m_##Type##s = cd::MoveTemp(elements); } \ - void Set##Type(uint32_t index, Class##TypeTraits::Type element) { m_##Type##s[index] = cd::MoveTemp(element); } \ - std::vector& Get##Type##s() { return m_##Type##s; } \ - const std::vector& Get##Type##s() const { return m_##Type##s; } \ - Class##TypeTraits::Type& Get##Type(uint32_t index) { return m_##Type##s[index]; } \ - const Class##TypeTraits::Type& Get##Type(uint32_t index) const { return m_##Type##s[index]; } \ - void Add##Type(Class##TypeTraits::Type element) { m_##Type##s.push_back(cd::MoveTemp(element)); } \ + void Set##Type##Capacity(uint32_t count) { m_##Type##Plural.reserve(count); } \ + void Set##Type##Count(uint32_t count) { m_##Type##Plural.resize(count); } \ + uint32_t Get##Type##Count() const { return static_cast(m_##Type##Plural.size()); } \ + void Set##Type##Plural(std::vector elements) { m_##Type##Plural = cd::MoveTemp(elements); } \ + void Set##Type(uint32_t index, Class##TypeTraits::Type element) { m_##Type##Plural[index] = cd::MoveTemp(element); } \ + std::vector& Get##Type##Plural() { return m_##Type##Plural; } \ + const std::vector& Get##Type##Plural() const { return m_##Type##Plural; } \ + Class##TypeTraits::Type& Get##Type(uint32_t index) { return m_##Type##Plural[index]; } \ + const Class##TypeTraits::Type& Get##Type(uint32_t index) const { return m_##Type##Plural[index]; } \ + void Add##Type(Class##TypeTraits::Type element) { m_##Type##Plural.push_back(cd::MoveTemp(element)); } \ private: \ - std::vector m_##Type##s; \ -public: \ No newline at end of file + std::vector m_##Type##Plural; \ +public: \ + +// Default plural is using "s". But sometimes you will need to use "es" such as Meshes. +#define EXPORT_VECTOR_TYPE_APIS(Class, Type) EXPORT_VECTOR_TYPE_APIS_WITH_PLURAL(Class, Type, s) +#define PIMPL_VECTOR_TYPE_APIS(Class, Type) PIMPL_VECTOR_TYPE_APIS_WITH_PLURAL(Class, Type, s) +#define IMPLEMENT_VECTOR_TYPE_APIS(Class, Type) IMPLEMENT_VECTOR_TYPE_APIS_WITH_PLURAL(Class, Type, s) \ No newline at end of file diff --git a/public/Scene/APITypeTraits.inl b/public/Scene/APITypeTraits.inl index 83d3b9ef..c680c23f 100644 --- a/public/Scene/APITypeTraits.inl +++ b/public/Scene/APITypeTraits.inl @@ -1,5 +1,47 @@ #pragma once +namespace cd +{ + +class Animation; +class Bone; +class Camera; +class Light; +class Material; +class Mesh; +class Morph; +class Node; +class ParticleEmitter; +class Texture; +class Track; + +// SceneDatabase +struct SceneDatabaseTypeTraits +{ + // Simple + using Unit = cd::Unit; + + // Complex + using AABB = cd::AABB; + using AxisSystem = cd::AxisSystem; + + // Vector + using Animation = cd::Animation; + using Bone = cd::Bone; + using Camera = cd::Camera; + using Light = cd::Light; + using Material = cd::Material; + using Mesh = cd::Mesh; + using Morph = cd::Morph; + using Node = cd::Node; + using ParticleEmitter = cd::ParticleEmitter; + using Texture = cd::Texture; + using Track = cd::Track; + + // String + using Name = std::string; +}; + // Animation struct AnimationTypeTraits { @@ -204,4 +246,6 @@ struct TrackTypeTraits // String using Name = std::string; -}; \ No newline at end of file +}; + +} \ No newline at end of file diff --git a/public/Scene/Animation.h b/public/Scene/Animation.h index 524be38c..fcd32062 100644 --- a/public/Scene/Animation.h +++ b/public/Scene/Animation.h @@ -17,19 +17,8 @@ class AnimationImpl; class CORE_API Animation final { public: - static const char* GetClassName() { return "Animation"; } - -public: - Animation() = delete; - explicit Animation(InputArchive& inputArchive); - explicit Animation(InputArchiveSwapBytes& inputArchive); + DECLARE_SCENE_CLASS(Animation); explicit Animation(AnimationID id, std::string name); - Animation(const Animation&) = delete; - Animation& operator=(const Animation&) = delete; - Animation(Animation&&); - Animation& operator=(Animation&&); - ~Animation(); - void Init(AnimationID id, std::string name); EXPORT_SIMPLE_TYPE_APIS(Animation, ID); @@ -37,14 +26,6 @@ class CORE_API Animation final EXPORT_SIMPLE_TYPE_APIS(Animation, TicksPerSecond); EXPORT_VECTOR_TYPE_APIS(Animation, BoneTrackID); EXPORT_STRING_TYPE_APIS(Animation, Name); - - Animation& operator<<(InputArchive& inputArchive); - Animation& operator<<(InputArchiveSwapBytes& inputArchive); - const Animation& operator>>(OutputArchive& outputArchive) const; - const Animation& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - AnimationImpl* m_pAnimationImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/Bone.h b/public/Scene/Bone.h index 152c3fb8..3d619330 100644 --- a/public/Scene/Bone.h +++ b/public/Scene/Bone.h @@ -16,19 +16,8 @@ class BoneImpl; class CORE_API Bone final { public: - static const char* GetClassName() { return "Bone"; } - -public: - Bone() = delete; - explicit Bone(InputArchive& inputArchive); - explicit Bone(InputArchiveSwapBytes& inputArchive); + DECLARE_SCENE_CLASS(Bone); explicit Bone(BoneID id, std::string name); - Bone(const Bone&) = delete; - Bone& operator=(const Bone&) = delete; - Bone(Bone&&); - Bone& operator=(Bone&&); - ~Bone(); - void Init(BoneID id, std::string name); EXPORT_SIMPLE_TYPE_APIS(Bone, ID); @@ -37,14 +26,6 @@ class CORE_API Bone final EXPORT_COMPLEX_TYPE_APIS(Bone, Transform); EXPORT_VECTOR_TYPE_APIS(Bone, ChildID); EXPORT_STRING_TYPE_APIS(Bone, Name); - - Bone& operator<<(InputArchive& inputArchive); - Bone& operator<<(InputArchiveSwapBytes& inputArchive); - const Bone& operator>>(OutputArchive& outputArchive) const; - const Bone& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - BoneImpl* m_pBoneImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/Camera.h b/public/Scene/Camera.h index d0332737..91f1c2f5 100644 --- a/public/Scene/Camera.h +++ b/public/Scene/Camera.h @@ -15,18 +15,8 @@ class CameraImpl; class CORE_API Camera final { public: - static const char* GetClassName() { return "Camera"; } - -public: - Camera() = delete; - explicit Camera(InputArchive& inputArchive); - explicit Camera(InputArchiveSwapBytes& inputArchive); + DECLARE_SCENE_CLASS(Camera); explicit Camera(CameraID id, const char* pName); - Camera(const Camera&) = delete; - Camera& operator=(const Camera&) = delete; - Camera(Camera&&); - Camera& operator=(Camera&&); - ~Camera(); EXPORT_SIMPLE_TYPE_APIS(Camera, ID); EXPORT_SIMPLE_TYPE_APIS(Camera, Aspect); @@ -37,14 +27,6 @@ class CORE_API Camera final EXPORT_COMPLEX_TYPE_APIS(Camera, LookAt); EXPORT_COMPLEX_TYPE_APIS(Camera, Up); EXPORT_STRING_TYPE_APIS(Camera, Name); - - Camera& operator<<(InputArchive& inputArchive); - Camera& operator<<(InputArchiveSwapBytes& inputArchive); - const Camera& operator>>(OutputArchive& outputArchive) const; - const Camera& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - CameraImpl* m_pCameraImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/Light.h b/public/Scene/Light.h index d720b590..619ffdae 100644 --- a/public/Scene/Light.h +++ b/public/Scene/Light.h @@ -15,19 +15,8 @@ class LightImpl; class CORE_API Light final { public: - static const char* GetClassName() { return "Light"; } - -public: - Light() = delete; - explicit Light(InputArchive& inputArchive); - explicit Light(InputArchiveSwapBytes & inputArchive); + DECLARE_SCENE_CLASS(Light); explicit Light(LightID lightID, LightType type); - Light(const Light&) = delete; - Light& operator=(const Light&) = delete; - Light(Light&&); - Light& operator=(Light&&); - ~Light(); - void Init(LightID lightID, LightType type); EXPORT_SIMPLE_TYPE_APIS(Light, ID); @@ -46,14 +35,6 @@ class CORE_API Light final EXPORT_STRING_TYPE_APIS(Light, Name); std::pair CalculateScaleAndOffset(float innerAngle, float outerAngle) const; - - Light& operator<<(InputArchive& inputArchive); - Light& operator<<(InputArchiveSwapBytes& inputArchive); - const Light& operator>>(OutputArchive& outputArchive) const; - const Light& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - LightImpl* m_pLightImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/Material.h b/public/Scene/Material.h index 9165dafa..e479fd90 100644 --- a/public/Scene/Material.h +++ b/public/Scene/Material.h @@ -19,19 +19,8 @@ class MaterialImpl; class CORE_API Material final { public: - static const char* GetClassName() { return "Material"; } - -public: - Material() = delete; - explicit Material(InputArchive& inputArchive); - explicit Material(InputArchiveSwapBytes& inputArchive); + DECLARE_SCENE_CLASS(Material); explicit Material(MaterialID materialID, const char* pMaterialName, MaterialType type); - Material(const Material&) = delete; - Material& operator=(const Material&) = delete; - Material(Material&&); - Material& operator=(Material&&); - ~Material(); - void Init(MaterialID materialID, const char* pMaterialName, MaterialType type); EXPORT_SIMPLE_TYPE_APIS(Material, ID); @@ -69,14 +58,6 @@ class CORE_API Material final std::optional GetVec2fProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const; bool ExistProperty(MaterialPropertyGroup propertyGroup, MaterialProperty property) const; - - Material& operator<<(InputArchive& inputArchive); - Material& operator<<(InputArchiveSwapBytes& inputArchive); - const Material& operator>>(OutputArchive& outputArchive) const; - const Material& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - MaterialImpl* m_pMaterialImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/Mesh.h b/public/Scene/Mesh.h index 188cc999..c5967023 100644 --- a/public/Scene/Mesh.h +++ b/public/Scene/Mesh.h @@ -19,21 +19,12 @@ class VertexFormat; class CORE_API Mesh final { public: - static const char* GetClassName() { return "Mesh"; } static Mesh FromHalfEdgeMesh(const HalfEdgeMesh& halfEdgeMesh, ConvertStrategy strategy); public: - Mesh() = default; - explicit Mesh(InputArchive& inputArchive); - explicit Mesh(InputArchiveSwapBytes & inputArchive); + DECLARE_SCENE_CLASS(Mesh); explicit Mesh(uint32_t vertexCount, uint32_t polygonCount); explicit Mesh(MeshID id, const char* pName, uint32_t vertexCount, uint32_t polygonCount); - Mesh(const Mesh&) = delete; - Mesh& operator=(const Mesh&) = delete; - Mesh(Mesh&&); - Mesh& operator=(Mesh&&); - ~Mesh(); - void Init(uint32_t vertexCount, uint32_t polygonCount); EXPORT_SIMPLE_TYPE_APIS(Mesh, ID); @@ -86,14 +77,6 @@ class CORE_API Mesh final Polygon& GetPolygon(uint32_t polygonIndex); const Polygon& GetPolygon(uint32_t polygonIndex) const; cd::VertexID GetPolygonVertexID(uint32_t polygonIndex, uint32_t vertexIndex) const; - - Mesh& operator<<(InputArchive& inputArchive); - Mesh& operator<<(InputArchiveSwapBytes& inputArchive); - const Mesh& operator>>(OutputArchive& outputArchive) const; - const Mesh& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - MeshImpl* m_pMeshImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/Morph.h b/public/Scene/Morph.h index ac404b1b..13de4b16 100644 --- a/public/Scene/Morph.h +++ b/public/Scene/Morph.h @@ -16,19 +16,9 @@ class MorphImpl; class CORE_API Morph final { public: - static const char* GetClassName() { return "Morph"; } - -public: - Morph() = delete; - explicit Morph(InputArchive& inputArchive); - explicit Morph(InputArchiveSwapBytes & inputArchive); explicit Morph(uint32_t vertexCount); explicit Morph(MorphID id, MeshID sourceMeshID, const char* pName, uint32_t vertexCount); - Morph(const Morph&) = delete; - Morph& operator=(const Morph&) = delete; - Morph(Morph&&); - Morph& operator=(Morph&&); - ~Morph(); + DECLARE_SCENE_CLASS(Morph); void Init(uint32_t vertexCount); void Init(MorphID id, const char* pName, uint32_t vertexCount); @@ -43,14 +33,6 @@ class CORE_API Morph final EXPORT_VECTOR_TYPE_APIS(Morph, VertexTangent); EXPORT_VECTOR_TYPE_APIS(Morph, VertexBiTangent); EXPORT_STRING_TYPE_APIS(Morph, Name); - - Morph& operator<<(InputArchive& inputArchive); - Morph& operator<<(InputArchiveSwapBytes& inputArchive); - const Morph& operator>>(OutputArchive& outputArchive) const; - const Morph& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - MorphImpl* m_pMorphImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/Node.h b/public/Scene/Node.h index 21f9d749..7d2437b8 100644 --- a/public/Scene/Node.h +++ b/public/Scene/Node.h @@ -17,19 +17,8 @@ class NodeImpl; class CORE_API Node final { public: - static const char* GetClassName() { return "Node"; } - -public: - Node() = delete; - explicit Node(InputArchive& inputArchive); - explicit Node(InputArchiveSwapBytes& inputArchive); + DECLARE_SCENE_CLASS(Node); explicit Node(NodeID nodeID, std::string name); - Node(const Node&) = delete; - Node& operator=(const Node&) = delete; - Node(Node&&); - Node& operator=(Node&&); - ~Node(); - void Init(NodeID nodeID, std::string name); EXPORT_SIMPLE_TYPE_APIS(Node, ID); @@ -38,14 +27,6 @@ class CORE_API Node final EXPORT_VECTOR_TYPE_APIS(Node, ChildID); EXPORT_VECTOR_TYPE_APIS(Node, MeshID); EXPORT_STRING_TYPE_APIS(Node, Name); - - Node& operator<<(InputArchive& inputArchive); - Node& operator<<(InputArchiveSwapBytes& inputArchive); - const Node& operator>>(OutputArchive& outputArchive) const; - const Node& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - NodeImpl* m_pNodeImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/ParticleEmitter.h b/public/Scene/ParticleEmitter.h index 1ba19cee..d2ec7d1d 100644 --- a/public/Scene/ParticleEmitter.h +++ b/public/Scene/ParticleEmitter.h @@ -13,18 +13,8 @@ class ParticleEmitterImpl; class CORE_API ParticleEmitter final { public: - static const char* GetClassName() { return "ParticleEmitter"; } - -public: - ParticleEmitter() = delete; - explicit ParticleEmitter(InputArchive& inputArchive); - explicit ParticleEmitter(InputArchiveSwapBytes& inputArchive); + DECLARE_SCENE_CLASS(ParticleEmitter); explicit ParticleEmitter(ParticleEmitterID id, const char* pName); - ParticleEmitter(const ParticleEmitter&) = delete; - ParticleEmitter& operator=(const ParticleEmitter&) = delete; - ParticleEmitter(ParticleEmitter&&); - ParticleEmitter& operator=(ParticleEmitter&&); - ~ParticleEmitter(); EXPORT_SIMPLE_TYPE_APIS(ParticleEmitter, ID); EXPORT_SIMPLE_TYPE_APIS(ParticleEmitter, Type); @@ -35,14 +25,6 @@ class CORE_API ParticleEmitter final EXPORT_COMPLEX_TYPE_APIS(ParticleEmitter, FixedRotation); EXPORT_COMPLEX_TYPE_APIS(ParticleEmitter, FixedScale); EXPORT_STRING_TYPE_APIS(ParticleEmitter, Name); - - ParticleEmitter& operator<<(InputArchive& inputArchive); - ParticleEmitter& operator<<(InputArchiveSwapBytes& inputArchive); - const ParticleEmitter& operator>>(OutputArchive& outputArchive) const; - const ParticleEmitter& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - ParticleEmitterImpl* m_pParticleEmitterImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/SceneDatabase.h b/public/Scene/SceneDatabase.h index 496a0533..2727a63b 100644 --- a/public/Scene/SceneDatabase.h +++ b/public/Scene/SceneDatabase.h @@ -37,128 +37,33 @@ class CORE_API SceneDatabase final SceneDatabase& operator=(SceneDatabase&&); ~SceneDatabase(); - // Identify - void SetName(const char* pName); - const char* GetName() const; - - // Volumn - void SetAABB(AABB aabb); - AABB& GetAABB(); - const AABB& GetAABB() const; - - // AxisSystem - void SetAxisSystem(AxisSystem axis); - AxisSystem& GetAxisSystem(); - const AxisSystem& GetAxisSystem() const; - - // Unit - void SetUnit(Unit unit); - Unit& GetUnit(); - Unit GetUnit() const; - - // Node - void AddNode(Node node); - std::vector& GetNodes(); - const std::vector& GetNodes() const; - void SetNodeCount(uint32_t nodeCount); - Node& GetNode(uint32_t index); - const Node& GetNode(uint32_t index) const; - Node* GetNodeByName(const char* pName); - const Node* GetNodeByName(const char* pName) const; - uint32_t GetNodeCount() const; - - // Mesh - void AddMesh(Mesh mesh); - std::vector& GetMeshes(); - const std::vector& GetMeshes() const; - void SetMeshCount(uint32_t meshCount); - Mesh& GetMesh(uint32_t index); - const Mesh& GetMesh(uint32_t index) const; - uint32_t GetMeshCount() const; - - // Morph - void AddMorph(Morph morph); - std::vector& GetMorphs(); - const std::vector& GetMorphs() const; - void SetMorphCount(uint32_t morphCount); - Morph& GetMorph(uint32_t index); - const Morph& GetMorph(uint32_t index) const; - uint32_t GetMorphCount() const; - - // Material - void AddMaterial(Material material); - std::vector& GetMaterials(); - const std::vector& GetMaterials() const; - void SetMaterialCount(uint32_t materialCount); - Material& GetMaterial(uint32_t index); - const Material& GetMaterial(uint32_t index) const; - uint32_t GetMaterialCount() const; - - // Texture - void AddTexture(Texture texture); - std::vector& GetTextures(); - const std::vector& GetTextures() const; - void SetTextureCount(uint32_t textureCount); - Texture& GetTexture(uint32_t index); - const Texture& GetTexture(uint32_t index) const; - uint32_t GetTextureCount() const; - - // Camera - void AddCamera(Camera camera); - std::vector& GetCameras(); - const std::vector& GetCameras() const; - void SetCameraCount(uint32_t cameraCount); - Camera& GetCamera(uint32_t index); - const Camera& GetCamera(uint32_t index) const; - uint32_t GetCameraCount() const; - - // Light - void AddLight(Light light); - std::vector& GetLights(); - const std::vector& GetLights() const; - void SetLightCount(uint32_t lightCount); - Light& GetLight(uint32_t index); - const Light& GetLight(uint32_t index) const; - uint32_t GetLightCount() const; + EXPORT_SIMPLE_TYPE_APIS(SceneDatabase, Unit); + EXPORT_COMPLEX_TYPE_APIS(SceneDatabase, AABB); + EXPORT_COMPLEX_TYPE_APIS(SceneDatabase, AxisSystem); + EXPORT_VECTOR_TYPE_APIS(SceneDatabase, Animation); + EXPORT_VECTOR_TYPE_APIS(SceneDatabase, Bone); + EXPORT_VECTOR_TYPE_APIS(SceneDatabase, Camera); + EXPORT_VECTOR_TYPE_APIS(SceneDatabase, Light); + EXPORT_VECTOR_TYPE_APIS(SceneDatabase, Material); + EXPORT_VECTOR_TYPE_APIS_WITH_PLURAL(SceneDatabase, Mesh, es); + EXPORT_VECTOR_TYPE_APIS(SceneDatabase, Morph); + EXPORT_VECTOR_TYPE_APIS(SceneDatabase, Node); + EXPORT_VECTOR_TYPE_APIS(SceneDatabase, ParticleEmitter); + EXPORT_VECTOR_TYPE_APIS(SceneDatabase, Texture); + EXPORT_VECTOR_TYPE_APIS(SceneDatabase, Track); + EXPORT_STRING_TYPE_APIS(SceneDatabase, Name); // Bone - void AddBone(Bone bone); - std::vector& GetBones(); - const std::vector& GetBones() const; - void SetBoneCount(uint32_t boneCount); - Bone& GetBone(uint32_t index); - const Bone& GetBone(uint32_t index) const; Bone* GetBoneByName(const char* pName); const Bone* GetBoneByName(const char* pName) const; - uint32_t GetBoneCount() const; - // Animation - void AddAnimation(Animation animation); - std::vector& GetAnimations(); - const std::vector& GetAnimations() const; - void SetAnimationCount(uint32_t animationCount); - Animation& GetAnimation(uint32_t index); - const Animation& GetAnimation(uint32_t index) const; - uint32_t GetAnimationCount() const; + // Node + Node* GetNodeByName(const char* pName); + const Node* GetNodeByName(const char* pName) const; // Track - void AddTrack(Track Track); - std::vector& GetTracks(); - const std::vector& GetTracks() const; - void SetTrackCount(uint32_t TrackCount); - Track& GetTrack(uint32_t index); - const Track& GetTrack(uint32_t index) const; + Track* GetTrackByName(const char* pName); const Track* GetTrackByName(const char* pName) const; - uint32_t GetTrackCount() const; - - //ParticleEmitter - void AddParticleEmitter(ParticleEmitter emitter); - std::vector& GetParticleEmitters(); - const std::vector& GetParticleEmitters() const; - void SetParticleEmitterCount(uint32_t emitterCount); - ParticleEmitter& GetParticleEmitter(uint32_t index); - const ParticleEmitter& GetParticleEmitter(uint32_t index) const; - uint32_t GetParticleEmitterCount() const; // Operations void Dump() const; diff --git a/public/Scene/Texture.h b/public/Scene/Texture.h index 127f1572..ac7383ae 100644 --- a/public/Scene/Texture.h +++ b/public/Scene/Texture.h @@ -17,18 +17,8 @@ class TextureImpl; class CORE_API Texture final { public: - static const char* GetClassName() { return "Texture"; } - -public: - Texture() = delete; - explicit Texture(InputArchive& inputArchive); - explicit Texture(InputArchiveSwapBytes& inputArchive); + DECLARE_SCENE_CLASS(Texture); explicit Texture(TextureID textureID, const char* pName, MaterialTextureType textureType); - Texture(const Texture&) = delete; - Texture& operator=(const Texture&) = delete; - Texture(Texture&&) noexcept; - Texture& operator=(Texture&&) noexcept; - ~Texture(); EXPORT_SIMPLE_TYPE_APIS(Texture, ID); EXPORT_SIMPLE_TYPE_APIS(Texture, Type); @@ -44,14 +34,6 @@ class CORE_API Texture final EXPORT_COMPLEX_TYPE_APIS(Texture, RawData); EXPORT_STRING_TYPE_APIS(Texture, Name); EXPORT_STRING_TYPE_APIS(Texture, Path); - - Texture& operator<<(InputArchive& inputArchive); - Texture& operator<<(InputArchiveSwapBytes& inputArchive); - const Texture& operator>>(OutputArchive& outputArchive) const; - const Texture& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - TextureImpl* m_pTextureImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/Track.h b/public/Scene/Track.h index 6ea202e4..1ac9678c 100644 --- a/public/Scene/Track.h +++ b/public/Scene/Track.h @@ -17,19 +17,8 @@ class TrackImpl; class CORE_API Track final { public: - static const char* GetClassName() { return "Track"; } - -public: - Track() = delete; - explicit Track(InputArchive& inputArchive); - explicit Track(InputArchiveSwapBytes& inputArchive); + DECLARE_SCENE_CLASS(Track); explicit Track(TrackID id, std::string name); - Track(const Track&) = delete; - Track& operator=(const Track&) = delete; - Track(Track&&); - Track& operator=(Track&&); - ~Track(); - void Init(TrackID id, std::string name); EXPORT_SIMPLE_TYPE_APIS(Track, ID); @@ -37,14 +26,6 @@ class CORE_API Track final EXPORT_VECTOR_TYPE_APIS(Track, TranslationKey); EXPORT_VECTOR_TYPE_APIS(Track, RotationKey); EXPORT_VECTOR_TYPE_APIS(Track, ScaleKey); - - Track& operator<<(InputArchive& inputArchive); - Track& operator<<(InputArchiveSwapBytes& inputArchive); - const Track& operator>>(OutputArchive& outputArchive) const; - const Track& operator>>(OutputArchiveSwapBytes& outputArchive) const; - -private: - TrackImpl* m_pTrackImpl = nullptr; }; } \ No newline at end of file diff --git a/public/Scene/Types.h b/public/Scene/Types.h index 7ee8f528..1845d795 100644 --- a/public/Scene/Types.h +++ b/public/Scene/Types.h @@ -1,5 +1,6 @@ #pragma once +#include "Math/UnitSystem.hpp" #include "Math/Transform.hpp" #include "Scene/APIMacros.h" #include "Scene/KeyFrame.hpp" @@ -50,7 +51,7 @@ using Color = cd::Vec4f; using UV = cd::Vec2f; using RGB = cd::Vec3f; -// Scene API -#include "Scene/APITypeTraits.inl" +} -} \ No newline at end of file +// Scene API +#include "Scene/APITypeTraits.inl" \ No newline at end of file