imgration 14/12/2025

This commit is contained in:
2025-12-24 16:51:01 +09:00
parent 121eb8eb25
commit d8a8d9633d
46 changed files with 1866 additions and 1026 deletions

View File

@@ -0,0 +1,11 @@
#pragma once
#include "type_base.hpp"
struct Interactable_Resource : public TypeBase
{
uint16_t ResourceID;
void Parse(const ryml::ConstNodeRef& node, ParseContext& context);
void Link(const std::unordered_map<int64_t, TypeBase*>& assetsMap) {};
};

View File

@@ -0,0 +1,65 @@
#pragma once
#include <string>
#include <vector>
#include <bitset>
#include <ryml_std.hpp>
#include "type_base.hpp"
#include "transform.h"
struct GameObject : public TypeBase
{
std::string name;
uint8_t layer{ 0 };
uint8_t namMeshLayer{ 0 };
std::string tag;
Transform* transform{ nullptr };
std::vector<TypeBase*> Components;
/**
* ComponentMask is a bitset where each bit corresponds to a component type index.
* This allows for extremely fast checking of whether a GameObject has specific components.
* The bit is set during the Link() phase when components are resolved.
* Max 64 different component types are supported.
*/
std::bitset<64> ComponentMask;
void Parse(const ryml::ConstNodeRef& node, ParseContext& context);
void Link(const std::unordered_map<int64_t, TypeBase*>& assetsMap);
// Check if this GameObject has a specific component type
template <typename T>
bool HasComponent() const
{
// Type index must be set by the system
for (auto* comp : Components)
{
if (comp && comp->TypeID >= 0 && comp->TypeID < 64)
{
if (ComponentMask.test(comp->TypeID))
{
// Additional runtime check could be added here
return true;
}
}
}
return false;
}
// Get a component of a specific type
template <typename T>
T* GetComponent()
{
for (auto* comp : Components)
{
if (auto* typedComp = dynamic_cast<T*>(comp))
{
return typedComp;
}
}
return nullptr;
}
};

View File

@@ -0,0 +1,18 @@
#pragma once
#include <string>
#include "type_base.hpp"
struct GameObject;
struct MeshFilter : TypeBase
{
AssetGUID Mesh;
GameObject* GameObject{ nullptr };
void Parse(const ryml::ConstNodeRef& node, ParseContext& context);
void Link(const std::unordered_map<int64_t, TypeBase*>& assetsMap);
};

View File

@@ -0,0 +1,13 @@
#pragma once
#include "type_base.hpp"
struct PrefabInstance : public TypeBase
{
public:
void Parse(const ryml::ConstNodeRef& node, ParseContext& context);
void Link(const std::unordered_map<int64_t, TypeBase*>& assetsMap) {};
public:
std::unordered_map<int64_t, ryml::Tree> Data;
};

27
include/types/transform.h Normal file
View File

@@ -0,0 +1,27 @@
#pragma once
#include <vector>
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include "type_base.hpp"
struct GameObject;
struct Transform : public TypeBase
{
glm::quat Rotation;
glm::vec3 Position;
glm::vec3 Scale;
glm::mat4 GlobalMatrix;
GameObject* GameObject{ nullptr };
std::vector<Transform*> Children;
Transform* Parent{ nullptr };
void Parse(const ryml::ConstNodeRef& node, ParseContext& context);
void Link(const std::unordered_map<int64_t, TypeBase*>& assetsMap);
};