Skip to content

Commit dc5573f

Browse files
committed
Added tests for animation data
1 parent 263b4ad commit dc5573f

File tree

14 files changed

+240
-72
lines changed

14 files changed

+240
-72
lines changed

engine/resources/AnimationData.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
#ifndef SIEGE_ENGINE_ANIMATIONDATA_H
1111
#define SIEGE_ENGINE_ANIMATIONDATA_H
1212

13-
#include <utils/math/vec/Vec3.h>
13+
#include <utils/BinarySerialisation.h>
1414
#include <utils/math/mat/Mat4.h>
15-
16-
#include "PackFile.h"
15+
#include <utils/math/vec/Vec3.h>
1716

1817
namespace Siege
1918
{

engine/resources/PackFile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
#include <filesystem>
1919
#include <map>
2020

21+
#include "AnimationData.h"
2122
#include "PackFileData.h"
2223
#include "SceneData.h"
23-
#include "StaticMeshData.h"
2424
#include "SkeletalMeshData.h"
25+
#include "StaticMeshData.h"
2526
#include "Texture2DData.h"
2627

2728
#define PACKER_MAGIC_NUMBER_FILE "pck"

engine/resources/SkeletalMeshData.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
#ifndef SIEGE_ENGINE_SKELETALMESHDATA_H
1111
#define SIEGE_ENGINE_SKELETALMESHDATA_H
1212

13+
#include <utils/BinarySerialisation.h>
1314
#include <utils/Colour.h>
15+
#include <utils/math/mat/Mat4.h>
1416
#include <utils/math/vec/Hashing.h>
1517
#include <utils/math/vec/Vec2.h>
1618
#include <utils/math/vec/Vec3.h>
17-
#include <utils/math/mat/Mat4.h>
1819

1920
#include "StaticMeshData.h"
2021

@@ -34,7 +35,8 @@ struct SkinnedVertex : BaseVertex
3435

3536
inline bool operator==(const SkinnedVertex& left, const SkinnedVertex& right)
3637
{
37-
return static_cast<BaseVertex>(left) == static_cast<BaseVertex>(right) && left.bones == right.bones && left.weights == right.weights;
38+
return static_cast<BaseVertex>(left) == static_cast<BaseVertex>(right) &&
39+
left.bones == right.bones && left.weights == right.weights;
3840
}
3941

4042
inline bool operator!=(const SkinnedVertex& left, const SkinnedVertex& right)

engine/resources/StaticMeshData.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include <utils/math/vec/Vec2.h>
1717
#include <utils/math/vec/Vec3.h>
1818

19-
#include "PackFile.h"
20-
2119
namespace Siege
2220
{
2321

engine/utils/Colour.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ inline String ToString(const IColour& colour)
247247
return String("%d,%d,%d,%d").Formatted(colour.r, colour.g, colour.b, colour.a);
248248
}
249249

250-
251250
/**
252251
* Converts a float colour to a string
253252
* @param colour the colour to convert to a string
@@ -258,7 +257,6 @@ inline String ToString(const FColour& colour)
258257
return String("%.2f,%.2f,%.2f,%.2f").Formatted(colour.r, colour.g, colour.b, colour.a);
259258
}
260259

261-
262260
} // namespace Siege
263261

264262
namespace std

engine/utils/Logging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <variant>
1616
#include <vector>
1717

18+
#include "Colour.h"
1819
#include "Macros.h"
1920
#include "String.h"
2021
#include "Token.h"
@@ -23,7 +24,6 @@
2324
#include "math/mat/Mat2.h"
2425
#include "math/mat/Mat3.h"
2526
#include "math/vec/Format.h"
26-
#include "Colour.h"
2727

2828
// Define terminal colour wrapping macros
2929
#define _CC_LOG_COLOUR_RED "31"

examples/game/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ else ifeq ($(platform), macos)
3030
endif
3131
engineRenderBuildDir := $(binDir)/engine/render/build
3232
exampleGameAssets := $(patsubst ./%,%, $(call rwildcard,$(exampleGameSrcDir),*.sm))
33+
exampleGameAssets += $(patsubst ./%,%, $(call rwildcard,$(exampleGameSrcDir),*.sk))
34+
exampleGameAssets += $(patsubst ./%,%, $(call rwildcard,$(exampleGameSrcDir),*.ska))
3335
exampleGameAssets += $(patsubst ./%,%, $(call rwildcard,$(exampleGameSrcDir),*.png))
3436
exampleGameAssets += $(patsubst ./%,%, $(call rwildcard,$(exampleGameSrcDir),*.jpg))
3537
exampleGameAssets += $(patsubst $(engineRenderBuildDir)/%,%, $(call rwildcard,$(engineRenderBuildDir),*.spv))

packer/src/types/AnimationDataPacker.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88

99
#include "AnimationDataPacker.h"
1010

11+
#include <assimp/postprocess.h>
12+
#include <assimp/scene.h>
1113
#include <resources/AnimationData.h>
1214
#include <utils/FileSystem.h>
1315
#include <utils/Logging.h>
1416

15-
#include <assimp/postprocess.h>
16-
#include <assimp/scene.h>
17-
#include <assimp/Importer.hpp>
18-
1917
#include <algorithm>
18+
#include <assimp/Importer.hpp>
2019
#include <fstream>
2120

2221
#include "StaticMeshDataPacker.h"
@@ -29,7 +28,9 @@ static void GetAnimationData(aiAnimation* animation, OUT Siege::AnimationData& a
2928
anim.speed = animation->mTicksPerSecond;
3029

3130
Siege::String animName = animation->mName.C_Str();
32-
CC_LOG_INFO("Reading animation \"{}\" with duration of {} seconds", animName, anim.length / anim.speed)
31+
CC_LOG_INFO("Reading animation \"{}\" with duration of {} seconds",
32+
animName,
33+
anim.length / anim.speed)
3334

3435
for (uint32_t i = 0; i < animation->mNumChannels; i++)
3536
{
@@ -66,10 +67,12 @@ static void GetAnimationData(aiAnimation* animation, OUT Siege::AnimationData& a
6667
}
6768
}
6869

69-
Siege::PackFileData* PackAnimationFile(const Siege::String& filePath, const Siege::String& assetsPath)
70+
Siege::PackFileData* PackAnimationFile(const Siege::String& filePath,
71+
const Siege::String& assetsPath)
7072
{
7173
Siege::String contents = Siege::FileSystem::Read(filePath);
72-
std::map<Siege::Token, Siege::String> attributes = Siege::FileSystem::ParseAttributeFileData(contents);
74+
std::map<Siege::Token, Siege::String> attributes =
75+
Siege::FileSystem::ParseAttributeFileData(contents);
7376

7477
if (attributes.empty())
7578
{

packer/src/types/AnimationDataPacker.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <resources/PackFile.h>
1313

14-
Siege::PackFileData* PackAnimationFile(const Siege::String& filePath, const Siege::String& assetsPath);
14+
Siege::PackFileData* PackAnimationFile(const Siege::String& filePath,
15+
const Siege::String& assetsPath);
1516

1617
#endif // SIEGE_ENGINE_ANIMATIONDATAPACKER_H

packer/src/types/SkeletalMeshDataPacker.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void GetMeshData(const aiScene* scene,
3030
{
3131
Siege::SkinnedVertex vertex {};
3232
vertex.bones = {-1, -1, -1, -1};
33-
vertex.weights = {0.f, 0.f, 0.f, 0.f };
33+
vertex.weights = {0.f, 0.f, 0.f, 0.f};
3434

3535
aiVector3t<ai_real> vert = mesh->mVertices[i];
3636
vertex.position = mat * Siege::Vec4(vert.x, vert.y, vert.z, 1.f);
@@ -100,7 +100,10 @@ static void GetMeshData(const aiScene* scene,
100100
}
101101
}
102102

103-
static aiMesh* FindMeshAtPath(const aiScene* scene, aiNode* node, const Siege::String& requestPath, Siege::String currentPath)
103+
static aiMesh* FindMeshAtPath(const aiScene* scene,
104+
aiNode* node,
105+
const Siege::String& requestPath,
106+
Siege::String currentPath)
104107
{
105108
currentPath = currentPath + node->mName.C_Str();
106109
CC_LOG_INFO("Reading node at {}", currentPath)
@@ -124,10 +127,12 @@ static aiMesh* FindMeshAtPath(const aiScene* scene, aiNode* node, const Siege::S
124127
return nullptr;
125128
}
126129

127-
Siege::PackFileData* PackSkeletalMeshFile(const Siege::String& filePath, const Siege::String& assetsPath)
130+
Siege::PackFileData* PackSkeletalMeshFile(const Siege::String& filePath,
131+
const Siege::String& assetsPath)
128132
{
129133
Siege::String contents = Siege::FileSystem::Read(filePath);
130-
std::map<Siege::Token, Siege::String> attributes = Siege::FileSystem::ParseAttributeFileData(contents);
134+
std::map<Siege::Token, Siege::String> attributes =
135+
Siege::FileSystem::ParseAttributeFileData(contents);
131136

132137
if (attributes.empty())
133138
{

0 commit comments

Comments
 (0)