Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f76a4cf
Reworked static meshes to reference source data through .sm files
jonjondev Jan 19, 2025
dfa6f3d
Updated entity file parsing to use key-value pairs in dynamic map
jonjondev Jan 19, 2025
492a67f
Centralised attribute file parsing logic across project
jonjondev Jan 19, 2025
b3b188c
Added string token class with initialisation time field macro
jonjondev Jan 26, 2025
9b87269
Refactored entity type and serialisation register to utilise string t…
jonjondev Jan 23, 2025
7ea0954
Refactored attribute files to use utilise tokens for keying values
jonjondev Jan 22, 2025
8604ede
Added assimp library dependency for asset importing, linked to packer…
jonjondev Jan 23, 2025
1da4b82
Removed Wavefront packer and tiny obj dependency
jonjondev Jan 24, 2025
f0c551e
Added Wavefront static mesh import for single meshes
jonjondev Jan 24, 2025
2d294e9
Added static mesh import mesh merging for multi-mesh scenes
jonjondev Jan 26, 2025
d7fa3f9
Added begins with function for string class
jonjondev Jan 30, 2025
1f8fc63
Added test for heap allocated string tokens
jonjondev Jan 30, 2025
e0fbc53
Updated static mesh data packer to support node path import property
jonjondev Jan 30, 2025
e39aa7c
Added additional logging for pack process on all packers
jonjondev Feb 2, 2025
bc0594a
Simplified process for string token class static registration
jonjondev Feb 2, 2025
af94a8d
Added axis flipping options for static mesh file import
jonjondev Feb 16, 2025
18e2e36
Fixed crashes from loading unknown pack file data
jonjondev Jul 13, 2025
fab554d
Added bool conversion and reverse utility functions to string class
jonjondev Jul 13, 2025
7005b74
Updated packed formatting
jonjondev Jul 13, 2025
f960b6b
Pinned Zlib, LibPng, and FreeType dependencies in setup scripts
jonjondev Jul 13, 2025
37ccbdf
Fixed UV set assignment for static mesh packer, restructured test and…
jonjondev Jul 13, 2025
fc02788
Fixed powershell setup scripts
Raelr Jul 13, 2025
ad5439a
Fixed missing imports of <algorithm> for windows
Raelr Jul 13, 2025
01020ce
Fixed Assimp linking for zlib on Windows, pinned version to v6.0.2
jonjondev Jul 21, 2025
c04d3fe
Removed GLM dependency from vendor
jonjondev Jul 21, 2025
0eb1194
Pinned GLFW version to 3.4
jonjondev Jul 21, 2025
9f91e54
Cleaned up and formatted setup scripts
jonjondev Jul 22, 2025
43bc64f
Fixed numerous warnings surrounding the use of VLAs
jonjondev Jul 27, 2025
bfea516
Added gizmo static mesh to render example scene
jonjondev Jul 30, 2025
806c6fd
Added tests for wide character construction for string class
jonjondev Aug 3, 2025
7743a36
Fixed copyrights across resource headers
jonjondev Aug 3, 2025
e310e84
Removed include for tinyobjloader, updated docs
jonjondev Aug 3, 2025
b7fcc94
Removed assimp matrices and vectors and added conversion functions
Raelr Aug 4, 2025
fbd3167
Switched out alloca calls for file buffers to heap allocate
jonjondev Aug 4, 2025
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@
[submodule "vendor/vulkan/Vulkan-Utility-Libraries"]
path = vendor/vulkan/Vulkan-Utility-Libraries
url = https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git
[submodule "vendor/assimp"]
path = vendor/assimp
url = https://github.com/assimp/assimp.git
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ clean:
$(RM) $(call platformpth,$(outputDir))
$(RM) $(call platformpth,$(buildFlagsFile))

clean-deps:
git submodule foreach --recursive git clean -xfd
git submodule foreach --recursive git reset --hard
$(RM) $(call platformpth,$(vendorDir)/include)
$(RM) $(call platformpth,$(vendorDir)/vulkan/include)
$(RM) $(call platformpth,$(vendorDir)/vulkan/lib)

clean-all: clean clean-deps

# Check file formatting program across all source files
format-check:
$(formatScript) "$(engineDir) $(examplesDir) $(testsDir) $(packerDir)" --check
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,14 @@ You can see examples of this in any of the application targets under `examples`.
├─[engine]
│ ├─[core] <- the engine's core library
│ ├─[render] <- the engine's renderer
| ├─[resources] <- the engine's resource types and loading system
│ ├─[window] <- the engine's windowing and input library
│ ├─[utils] <- the engine's utils library
├─[examples]
│ ├─[game] <- an example app utilising all of the engine's libraries
│ ├─[render] <- an example app demonstrating the renderer
│ ├─[render] <- an example app demonstrating the renderer for 3D
| ├─[tilemap] <- an example app demonstrating the renderer for a tilemap
├─[make] <- additional Make file utilities for the build system
├─[packer] <- an asset packing app for bundling game assets in a pack file on build
Expand Down
2 changes: 1 addition & 1 deletion engine/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include $(makeDir)/Functions.mk
include $(makeDir)/Platform.mk

# Set source build vars
coreSrcDir := .
coreSrcDir := ./
coreBinDir := $(binDir)/engine/core
coreSources := $(call rwildcard,$(coreSrcDir)/,*.cpp)
coreObjects := $(call findobjs,$(coreSrcDir),$(coreBinDir),$(coreSources))
Expand Down
11 changes: 4 additions & 7 deletions engine/core/entity/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@

namespace Siege
{
// Static member initialisation
const String Entity::ENTITY_NAME("Entity");

Entity::Entity(const String& name, const Xform& transform, int zIndex) :
Entity::Entity(Token type, const Xform& transform, int zIndex) :
transform(transform),
name(name),
type(type),
index(GenerationalIndex()),
zIndex(zIndex)
{}
Expand All @@ -42,9 +39,9 @@ void Entity::QueueFree()
EntitySystem::QueueFree(this);
}

const String& Entity::GetName() const
Token Entity::GetType() const
{
return name;
return type;
}

const GenerationalIndex& Entity::GetIndex() const
Expand Down
32 changes: 14 additions & 18 deletions engine/core/entity/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
#define SIEGE_ENGINE_ENTITY_H

#include <utils/String.h>
#include <utils/Token.h>
#include <utils/math/Maths.h>
#include <utils/math/Xform.h>

#include "EntityPtr.h"
#include "IndexAllocator.h"

REGISTER_TOKEN(Entity);

namespace Siege
{
/**
Expand All @@ -26,36 +29,30 @@ class Entity
{
public:

// Public constants

static const String ENTITY_NAME;

// 'Structors

/**
* Zero-param constructor for Entity, initialises both
* position and rotation to zero, and name to "Entity"
* position and rotation to zero, and type to Entity
*/
Entity() : Entity(ENTITY_NAME) {};
Entity() : Entity(TOKEN_Entity) {};

/**
* Single-param constructor for Entity that simply defines
* a custom name for the Entity
* @param name - a const reference to the name of the
* entity as a string
* @param type - a token for the entity to use as its type
*/
Entity(const String& name) : Entity(name, {Vec3::Zero(), 0.f}) {};
Entity(Token type) : Entity(type, {Vec3::Zero(), 0.f}) {};

/**
* Delegate constructor for Entity, initialises
* generational index to zero
* @param name - a const reference to the name of the
* entity as a string
* @param type - a token for the entity to use as its type
* @param transform - the initial transition of the entity
* @param zIndex - the initial z-index of the entity,
* defaults to zero
*/
Entity(const String& name, const Xform& transform, int zIndex = 0);
Entity(Token type, const Xform& transform, int zIndex = 0);

/**
* Default virtual destructor for Entity
Expand Down Expand Up @@ -121,11 +118,10 @@ class Entity
// Public getters

/**
* Getter method for the entity's vanity name
* @return a constant reference to the entity's name
* as a string
* Getter method for the entity's type
* @return a token for the entity's type
*/
const String& GetName() const;
Token GetType() const;

/**
* Getter method for the entity's generational index
Expand Down Expand Up @@ -234,9 +230,9 @@ class Entity
// Private fields

/**
* The name of the entity type
* The type of the entity type
*/
const String& name;
Token type;

/**
* The generational index of the entity
Expand Down
8 changes: 4 additions & 4 deletions engine/core/entity/EntitySystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ void EntitySystem::QueueFree(Entity* entity)
EntitySystem* system = FindInGlobalRegister(entity);
if (system)
{
CC_LOG_INFO("Freeing {} at ({})", entity->GetName(), entity->GetIndex().ToString());
CC_LOG_INFO("Freeing {} at ({})", entity->GetType(), entity->GetIndex().ToString());
system->AddToFreeQueue(entity);
}
else
{
CC_LOG_WARNING("Could not find storage for {} at {}",
entity->GetName(),
entity->GetType(),
entity->GetIndex().ToString());
}
}
Expand All @@ -90,7 +90,7 @@ void EntitySystem::Resort(Entity* entity, int oldZIdx)
else
{
CC_LOG_WARNING("Could not find storage for {} at {}",
entity->GetName(),
entity->GetType(),
entity->GetIndex().ToString());
}
}
Expand Down Expand Up @@ -141,7 +141,7 @@ void EntitySystem::RegisterEntities()
// If the entity's given index already exists then override the existing entry
if (entity->GetIndex().index < entities.size()) entities[entity->GetIndex().index] = entity;
else entities.push_back(entity);
CC_LOG_INFO("Registered {} at ({})", entity->GetName(), entity->GetIndex().ToString());
CC_LOG_INFO("Registered {} at ({})", entity->GetType(), entity->GetIndex().ToString());

packedEntities.push_back(entity);
AddToGlobalRegister(entity, this);
Expand Down
72 changes: 45 additions & 27 deletions engine/core/scene/SceneFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
#include <resources/PackFile.h>
#include <resources/ResourceSystem.h>
#include <resources/SceneData.h>
#include <utils/FileSystem.h>
#include <utils/Logging.h>

#include <algorithm>

#include "SceneSystem.h"
#include "resources/GenericFileData.h"

REGISTER_TOKEN(TYPE);
REGISTER_TOKEN(ROTATION);
REGISTER_TOKEN(Z_INDEX);
REGISTER_TOKEN(POSITION);

namespace Siege
{
void SceneFile::RegisterSerialisable(const String& name,
void SceneFile::RegisterSerialisable(Token type,
const Serialiser& serialise,
const Deserialiser& deserialise)
{
GetSerialisables().emplace(name, std::make_pair(serialise, deserialise));
GetSerialisables().emplace(type, std::make_pair(serialise, deserialise));
}

bool SceneFile::Serialise(const std::vector<Entity*>& entities)
Expand Down Expand Up @@ -65,14 +68,14 @@ bool SceneFile::SerialiseToString(Entity* entity, String& fileData)
auto& serialisables = GetSerialisables();

// Only serialise entities that register a serialisable interface
auto it = serialisables.find(entity->GetName());
auto it = serialisables.find(entity->GetType());
if (it == serialisables.end()) return false;

// Serialise the general entity information
fileData += (entity->GetName() + LINE_SEP);
fileData += DefineField("POSITION", ToString(entity->GetPosition()));
fileData += DefineField("ROTATION", String::FromFloat(entity->GetRotation().y));
fileData += DefineField("Z-INDEX", String::FromInt(entity->GetZIndex()));
fileData += DefineField(TOKEN_TYPE, entity->GetType().GetId());
fileData += DefineField(TOKEN_POSITION, ToString(entity->GetPosition()));
fileData += DefineField(TOKEN_ROTATION, String::FromFloat(entity->GetRotation().y));
fileData += DefineField(TOKEN_Z_INDEX, String::FromInt(entity->GetZIndex()));

// Apply its serialiser if it
Serialiser serialiser = it->second.first;
Expand Down Expand Up @@ -141,34 +144,25 @@ bool SceneFile::Deserialise(std::vector<Entity*>& entities)

Entity* SceneFile::DeserialiseFromString(const String& fileData)
{
if (fileData.IsEmpty())
{
CC_LOG_WARNING("Found empty entity during deserialisation");
return nullptr;
}

// Split the file into arguments and strip the labels from each item
std::vector<String> args = fileData.Split(LINE_SEP);
for (String& arg : args) arg = arg.SubString((int) arg.Find(NAME_SEP) + 1);
std::map<Token, String> attributes = Siege::FileSystem::ParseAttributeFileData(fileData);

// Get the standard entity fields
EntityData data;
if (!(args.size() >= 4 && args[ENTITY_ROT].GetFloat(data.rotation) &&
args[ENTITY_Z_IDX].GetInt(data.zIndex) && FromString(data.position, args[ENTITY_POS])))
if (attributes.empty())
{
CC_LOG_WARNING("Failed to deserialise fields for entity \"{}\"", args[ENTITY_NAME]);
CC_LOG_WARNING("Found empty entity during deserialisation!");
return nullptr;
}

// Check if the entity has a relevant serialisable interface registered
auto& serialisables = GetSerialisables();
auto it = serialisables.find(args[ENTITY_NAME]);
Token typeToken(attributes[TOKEN_TYPE]);
auto it = serialisables.find(typeToken);
if (it != serialisables.end())
{
// Apply its deserialiser
Deserialiser deserialiser = it->second.second;
if (deserialiser) return deserialiser(data, args);
if (deserialiser) return deserialiser(attributes);
}
else CC_LOG_WARNING("\"{}\" has no deserialisation protocols defined", args[ENTITY_NAME]);
else CC_LOG_WARNING("\"{}\" has no deserialisation protocols defined", attributes[TOKEN_TYPE]);
return nullptr;
}

Expand All @@ -190,6 +184,29 @@ void SceneFile::InitialiseEntityPathMappings()
}
}

EntityData SceneFile::GetBaseEntityData(const std::map<Token, String>& attributes)
{
EntityData data;
auto it = attributes.find(TOKEN_ROTATION);
if (it == attributes.end() || !it->second.GetFloat(data.rotation))
{
CC_LOG_WARNING("Failed to deserialise ROTATION field for entity attributes");
}

it = attributes.find(TOKEN_Z_INDEX);
if (it == attributes.end() || !it->second.GetInt(data.zIndex))
{
CC_LOG_WARNING("Failed to deserialise Z_INDEX field for entity attributes");
}

it = attributes.find(TOKEN_POSITION);
if (it == attributes.end() || !FromString(data.position, it->second))
{
CC_LOG_WARNING("Failed to deserialise POSITION field for entity attributes");
}
return data;
}

String SceneFile::GetOrCreateEntityFilepath(Entity* entity)
{
// Try to find the entity path amongst the deserialised
Expand All @@ -212,7 +229,8 @@ String SceneFile::GetOrCreateEntityFilepath(Entity* entity)

// Failed attempts to find a file index are serialised as 0
String index = result ? String::FromInt(newFileIndex) : "0";
return MakeScenePath(sceneName) + '/' + entity->GetName() + '.' + index + ENTITY_FILE_EXT;
return MakeScenePath(sceneName) + '/' + entity->GetType().GetId() + '.' + index +
ENTITY_FILE_EXT;
}

String SceneFile::MakeScenePath(const String& sceneName)
Expand Down
Loading
Loading