Skip to content

Commit

Permalink
reduce API wrappers for member variables (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
T-rvw authored Dec 15, 2023
1 parent 7d597e6 commit beaa2ad
Show file tree
Hide file tree
Showing 66 changed files with 795 additions and 1,659 deletions.
1 change: 0 additions & 1 deletion private/Consumers/CDConsumer/CDConsumerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "Hashers/FileHash.hpp"
#include "Scene/Material.h"
#include "Scene/Mesh.h"
#include "Scene/ObjectID.h"
#include "Scene/SceneDatabase.h"
#include "Scene/Texture.h"

Expand Down
6 changes: 3 additions & 3 deletions private/Framework/ProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void CalculateNodeTransforms(std::vector<cd::Matrix4x4>& nodeFinalTransforms, co
nodeFinalTransforms[node.GetID().Data()] = parentTransform * localTransform;

const std::vector<cd::NodeID>& childIDs = node.GetChildIDs();
for (uint32_t childIndex = 0U; childIndex < node.GetChildCount(); ++childIndex)
for (uint32_t childIndex = 0U; childIndex < node.GetChildIDCount(); ++childIndex)
{
cd::NodeID childNodeID = childIDs[childIndex];
CalculateNodeTransforms(nodeFinalTransforms, pSceneDatabase, pSceneDatabase->GetNode(childNodeID.Data()));
Expand Down Expand Up @@ -258,7 +258,7 @@ void ProcessorImpl::FlattenSceneDatabase()
{
const cd::Node& node = m_pCurrentSceneDatabase->GetNode(nodeIndex);
const std::vector<cd::MeshID>& nodeMeshIDs = node.GetMeshIDs();
for (uint32_t nodeMeshIndex = 0U; nodeMeshIndex < node.GetMeshCount(); ++nodeMeshIndex)
for (uint32_t nodeMeshIndex = 0U; nodeMeshIndex < node.GetMeshIDCount(); ++nodeMeshIndex)
{
mapMeshIDToAssociatedNodeID[nodeMeshIDs[nodeMeshIndex].Data()] = nodeIndex;
}
Expand Down Expand Up @@ -330,7 +330,7 @@ void ProcessorImpl::EmbedTextureFiles()
{
for (auto& texture : m_pCurrentSceneDatabase->GetTextures())
{
if (texture.ExistRawData())
if (texture.GetRawData().empty())
{
continue;
}
Expand Down
1 change: 0 additions & 1 deletion private/Producers/FbxProducer/FbxProducerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "Hashers/StringHash.hpp"
#include "Scene/MaterialTextureType.h"
#include "Scene/Mesh.h"
#include "Scene/ObjectID.h"
#include "Scene/SceneDatabase.h"
#include "Scene/VertexFormat.h"

Expand Down
2 changes: 1 addition & 1 deletion private/Producers/GenericProducer/GenericProducerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ void GenericProducerImpl::KeepNodeIDAndIndexSame(cd::SceneDatabase* pSceneDataba
}

auto& childIDs = sceneNode.GetChildIDs();
for (uint32_t childIndex = 0U, childCount = sceneNode.GetChildCount(); childIndex < childCount; ++childIndex)
for (uint32_t childIndex = 0U, childCount = sceneNode.GetChildIDCount(); childIndex < childCount; ++childIndex)
{
uint32_t childNodeID = childIDs[childIndex].Data();
auto itModifiedIDNode = oldToNewNodeID.find(childNodeID);
Expand Down
2 changes: 1 addition & 1 deletion private/ProgressiveMesh/Face.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Container/DynamicArray.hpp"
#include "Math/Vector.hpp"
#include "Scene/ObjectID.h"
#include "Scene/Types.h"

#include <cassert>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion private/ProgressiveMesh/ProgressiveMeshImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "Face.h"
#include "Vertex.h"
#include "Math/Box.hpp"
#include "Scene/ObjectID.h"

#include <set>

Expand Down
2 changes: 1 addition & 1 deletion private/ProgressiveMesh/Vertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Container/DynamicArray.hpp"
#include "Math/Vector.hpp"
#include "Scene/ObjectID.h"
#include "Scene/Types.h"

#include <cassert>
#include <cfloat>
Expand Down
47 changes: 5 additions & 42 deletions private/Scene/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,11 @@ void Animation::Init(AnimationID id, std::string name)
m_pAnimationImpl->Init(id, cd::MoveTemp(name));
}

PIMPL_ID_APIS(Animation);
PIMPL_NAME_APIS(Animation);

void Animation::SetDuration(float duration)
{
m_pAnimationImpl->SetDuration(duration);
}

float Animation::GetDuration() const
{
return m_pAnimationImpl->GetDuration();
}

void Animation::SetTicksPerSecond(float ticksPerSecond)
{
m_pAnimationImpl->SetTicksPerSecond(ticksPerSecond);
}

float Animation::GetTicksPerSecnod() const
{
return m_pAnimationImpl->GetTicksPerSecnod();
}

void Animation::AddBoneTrackID(uint32_t trackID)
{
m_pAnimationImpl->AddBoneTrackID(trackID);
}

uint32_t Animation::GetBoneTrackCount() const
{
return m_pAnimationImpl->GetBoneTrackCount();
}

std::vector<TrackID>& Animation::GetBoneTrackIDs()
{
return m_pAnimationImpl->GetBoneTrackIDs();
}

const std::vector<TrackID>& Animation::GetBoneTrackIDs() const
{
return m_pAnimationImpl->GetBoneTrackIDs();
}
PIMPL_SIMPLE_TYPE_APIS(Animation, ID);
PIMPL_SIMPLE_TYPE_APIS(Animation, Duration);
PIMPL_SIMPLE_TYPE_APIS(Animation, TicksPerSecond);
PIMPL_VECTOR_TYPE_APIS(Animation, BoneTrackID);
PIMPL_STRING_TYPE_APIS(Animation, Name);

Animation& Animation::operator<<(InputArchive& inputArchive)
{
Expand Down
4 changes: 2 additions & 2 deletions private/Scene/AnimationImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ AnimationImpl::AnimationImpl(AnimationID id, std::string name)

void AnimationImpl::Init(AnimationID id, std::string name)
{
m_id = id;
m_name = cd::MoveTemp(name);
SetID(id);
SetName(cd::MoveTemp(name));
}

}
34 changes: 9 additions & 25 deletions private/Scene/AnimationImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "IO/InputArchive.hpp"
#include "IO/OutputArchive.hpp"
#include "Scene/KeyFrame.hpp"
#include "Scene/ObjectID.h"
#include "Scene/Track.h"
#include "Scene/Types.h"

#include <vector>
#include <string>
Expand All @@ -31,19 +31,11 @@ class AnimationImpl final

void Init(AnimationID id, std::string name);

IMPLEMENT_ID_APIS(AnimationID, m_id);
IMPLEMENT_NAME_APIS(m_name);

void SetDuration(float duration) { m_duration = duration; }
float GetDuration() const { return m_duration; }

void SetTicksPerSecond(float ticksPerSecond) { m_ticksPerSecond = ticksPerSecond; }
float GetTicksPerSecnod() const { return m_ticksPerSecond; }

void AddBoneTrackID(uint32_t trackID) { m_boneTrackIDs.push_back(TrackID(trackID)); }
uint32_t GetBoneTrackCount() const { return static_cast<uint32_t>(m_boneTrackIDs.size()); }
std::vector<TrackID>& GetBoneTrackIDs() { return m_boneTrackIDs; }
const std::vector<TrackID>& GetBoneTrackIDs() const { return m_boneTrackIDs; }
IMPLEMENT_SIMPLE_TYPE_APIS(Animation, ID);
IMPLEMENT_SIMPLE_TYPE_APIS(Animation, Duration);
IMPLEMENT_SIMPLE_TYPE_APIS(Animation, TicksPerSecond);
IMPLEMENT_VECTOR_TYPE_APIS(Animation, BoneTrackID);
IMPLEMENT_STRING_TYPE_APIS(Animation, Name);

template<bool SwapBytesOrder>
AnimationImpl& operator<<(TInputArchive<SwapBytesOrder>& inputArchive)
Expand All @@ -60,28 +52,20 @@ class AnimationImpl final
SetDuration(duration);
SetTicksPerSecond(ticksPerSecond);

m_boneTrackIDs.resize(boneTrackCount);
inputArchive.ImportBuffer(m_boneTrackIDs.data());
GetBoneTrackIDs().resize(boneTrackCount);
inputArchive.ImportBuffer(GetBoneTrackIDs().data());

return *this;
}

template<bool SwapBytesOrder>
const AnimationImpl& operator>>(TOutputArchive<SwapBytesOrder>& outputArchive) const
{
outputArchive << GetID().Data() << GetName() << GetDuration() << GetTicksPerSecnod() << GetBoneTrackCount();
outputArchive << GetID().Data() << GetName() << GetDuration() << GetTicksPerSecond() << GetBoneTrackIDCount();
outputArchive.ExportBuffer(GetBoneTrackIDs().data(), GetBoneTrackIDs().size());

return *this;
}

private:
AnimationID m_id;
float m_duration;
float m_ticksPerSecond;

std::string m_name;
std::vector<TrackID> m_boneTrackIDs;
};

}
68 changes: 6 additions & 62 deletions private/Scene/Bone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,68 +44,12 @@ void Bone::Init(BoneID id, std::string name)
m_pBoneImpl->Init(id, MoveTemp(name));
}

PIMPL_ID_APIS(Bone);
PIMPL_NAME_APIS(Bone);

void Bone::SetParentID(BoneID parentID)
{
m_pBoneImpl->SetParentID(parentID);
}

BoneID Bone::GetParentID() const
{
return m_pBoneImpl->GetParentID();
}

void Bone::AddChildID(BoneID childID)
{
m_pBoneImpl->AddChildID(childID);
}

uint32_t Bone::GetChildCount() const
{
return m_pBoneImpl->GetChildCount();
}

std::vector<BoneID>& Bone::GetChildIDs()
{
return m_pBoneImpl->GetChildIDs();
}

const std::vector<BoneID>& Bone::GetChildIDs() const
{
return m_pBoneImpl->GetChildIDs();
}

void Bone::SetOffset(Matrix4x4 offset)
{
m_pBoneImpl->SetOffset(MoveTemp(offset));
}

Matrix4x4& Bone::GetOffset()
{
return m_pBoneImpl->GetOffset();
}

const Matrix4x4& Bone::GetOffset() const
{
return m_pBoneImpl->GetOffset();
}

void Bone::SetTransform(Transform transform)
{
return m_pBoneImpl->SetTransform(MoveTemp(transform));
}

Transform& Bone::GetTransform()
{
return m_pBoneImpl->GetTransform();
}

const Transform& Bone::GetTransform() const
{
return m_pBoneImpl->GetTransform();
}
PIMPL_SIMPLE_TYPE_APIS(Bone, ID);
PIMPL_SIMPLE_TYPE_APIS(Bone, ParentID);
PIMPL_COMPLEX_TYPE_APIS(Bone, Offset);
PIMPL_COMPLEX_TYPE_APIS(Bone, Transform);
PIMPL_VECTOR_TYPE_APIS(Bone, ChildID);
PIMPL_STRING_TYPE_APIS(Bone, Name);

Bone& Bone::operator<<(InputArchive& inputArchive)
{
Expand Down
4 changes: 2 additions & 2 deletions private/Scene/BoneImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ BoneImpl::BoneImpl(BoneID id, std::string name)

void BoneImpl::Init(BoneID id, std::string name)
{
m_id = id;
m_name = cd::MoveTemp(name);
SetID(id);
SetName(cd::MoveTemp(name));
}

}
38 changes: 9 additions & 29 deletions private/Scene/BoneImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Base/Template.h"
#include "IO/InputArchive.hpp"
#include "IO/OutputArchive.hpp"
#include "Scene/ObjectID.h"
#include "Scene/Types.h"

#include <vector>
#include <string>
Expand All @@ -29,24 +29,12 @@ class BoneImpl final

void Init(BoneID id, std::string name);

IMPLEMENT_ID_APIS(BoneID, m_id);
IMPLEMENT_NAME_APIS(m_name);

void SetParentID(BoneID parentID) { m_parentID = parentID; }
BoneID GetParentID() const { return m_parentID; }

void AddChildID(BoneID childID) { m_childIDs.push_back(childID); }
uint32_t GetChildCount() const { return static_cast<uint32_t>(m_childIDs.size()); }
std::vector<BoneID>& GetChildIDs() { return m_childIDs; }
const std::vector<BoneID>& GetChildIDs() const { return m_childIDs; }

void SetOffset(Matrix4x4 offset) { m_offset = MoveTemp(offset); }
Matrix4x4& GetOffset() { return m_offset; }
const Matrix4x4& GetOffset() const { return m_offset; }

void SetTransform(Transform transform) { m_transform = MoveTemp(transform); }
Transform& GetTransform() { return m_transform; }
const Transform& GetTransform() const { return m_transform; }
IMPLEMENT_SIMPLE_TYPE_APIS(Bone, ID);
IMPLEMENT_SIMPLE_TYPE_APIS(Bone, ParentID);
IMPLEMENT_COMPLEX_TYPE_APIS(Bone, Offset);
IMPLEMENT_COMPLEX_TYPE_APIS(Bone, Transform);
IMPLEMENT_VECTOR_TYPE_APIS(Bone, ChildID);
IMPLEMENT_STRING_TYPE_APIS(Bone, Name);

template<bool SwapBytesOrder>
BoneImpl& operator<<(TInputArchive<SwapBytesOrder>& inputArchive)
Expand All @@ -62,7 +50,7 @@ class BoneImpl final
Init(BoneID(boneID), cd::MoveTemp(boneName));
SetParentID(BoneID(boneParentID));

m_childIDs.resize(boneChildIDCount);
GetChildIDs().resize(boneChildIDCount);
inputArchive.ImportBuffer(GetChildIDs().data());

inputArchive >> GetOffset() >> GetTransform();
Expand All @@ -73,20 +61,12 @@ class BoneImpl final
template<bool SwapBytesOrder>
const BoneImpl& operator>>(TOutputArchive<SwapBytesOrder>& outputArchive) const
{
outputArchive << GetID().Data() << GetName() << GetParentID().Data() << GetChildCount();
outputArchive << GetID().Data() << GetName() << GetParentID().Data() << GetChildIDCount();
outputArchive.ExportBuffer(GetChildIDs().data(), GetChildIDs().size());
outputArchive << GetOffset() << GetTransform();

return *this;
}

private:
BoneID m_id;
BoneID m_parentID;
Matrix4x4 m_offset;
Transform m_transform;
std::vector<BoneID> m_childIDs;
std::string m_name;
};

}
Loading

0 comments on commit beaa2ad

Please sign in to comment.