Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new scene object types #267

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions private/Producers/FbxProducer/FbxProducerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<fbxsdk::FbxAnimStack>();

const uint32_t animationCount = scene->GetSrcObjectCount<fbxsdk::FbxAnimStack>();
for (uint32_t animationIndex = 0; animationIndex < animationCount; ++animationIndex)
{
// Single-take animation information.
Expand All @@ -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<int>(std::ceil((end - start) / period + 1.0f));
uint32_t trackCount = static_cast<uint32_t>(std::ceil((end - start) / period + 1.0f));

std::vector<float> times;
times.resize(trackCount);

std::vector<std::vector<cd::Matrix4x4>> 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);
}
Expand Down
3 changes: 1 addition & 2 deletions private/ProgressiveMesh/ProgressiveMeshImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
#include "Face.h"
#include "Vertex.h"
#include "Math/Box.hpp"
#include "Scene/Mesh.h"

#include <set>

namespace cd
{

class Mesh;

namespace pm
{

Expand Down
54 changes: 1 addition & 53 deletions private/Scene/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
}

}
14 changes: 2 additions & 12 deletions private/Scene/AnimationImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,9 @@ namespace cd
class AnimationImpl final
{
public:
AnimationImpl() = delete;
template<bool SwapBytesOrder>
explicit AnimationImpl(TInputArchive<SwapBytesOrder>& 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);
Expand Down
54 changes: 1 addition & 53 deletions private/Scene/Bone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
}

}
14 changes: 2 additions & 12 deletions private/Scene/BoneImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,9 @@ namespace cd
class BoneImpl final
{
public:
BoneImpl() = delete;
template<bool SwapBytesOrder>
explicit BoneImpl(TInputArchive<SwapBytesOrder>& 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);
Expand Down
54 changes: 1 addition & 53 deletions private/Scene/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

}
14 changes: 2 additions & 12 deletions private/Scene/CameraImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,9 @@ namespace cd
class CameraImpl final
{
public:
CameraImpl() = delete;
template<bool SwapBytesOrder>
explicit CameraImpl(TInputArchive<SwapBytesOrder>& 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);
Expand Down
Loading