16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 19:29:19 +02:00

ECS System WIP

This commit is contained in:
2026-04-07 23:40:03 +02:00
parent f6db9978d2
commit 8e9fd9225f
30 changed files with 1133 additions and 242 deletions

View File

@@ -3,11 +3,14 @@
*/
#ifndef EU07_BASICCOMPONENTS_H
#define EU07_BASICCOMPONENTS_H
#include "audio/sound.h"
#include "entt/entity/entity.hpp"
#include "glm/vec3.hpp"
#include "glm/gtc/quaternion.hpp"
#include <string>
#include "registry/FName.h"
#include "utils/uuid.hpp"
#include <cstdint>
#include <string>
namespace ECSComponent
{
@@ -16,18 +19,23 @@ namespace ECSComponent
///</summary>
struct Transform
{
glm::vec3 Position{0.f}; // object position
glm::dvec3 Position{0.f}; // object position
glm::quat Rotation{1.f, 0.f, 0.f, 0.f}; // object rotation
glm::vec3 Scale{1.f}; // object scale
};
struct Velocity
{
glm::vec3 Value{0.f}; // object velocity
};
///< summary>
/// Basic component for naming entities
/// in future for scenery hierarchy
///</summary>
struct Identification
{
std::string Name; // object name - may contain slashes for editor hierarchy "directories"
FName Name; // object name - may contain slashes for editor hierarchy "directories"
std::uint64_t Id{0}; // id in scene
};
@@ -39,6 +47,16 @@ struct Parent
entt::entity value{entt::null};
};
struct SoundComponent
{
sound_source sound; // sound source
float volume = 1.0f; // 01
float pitch = 1.0f; // speed / pitch
float range = 1.0f; // range
bool loop = false;
bool playOnStart = false;
bool isPlaying = false;
};
///< summary>
/// Empty component for entities that are disabled and should not be processed by systems
///</summary>

View File

@@ -1,6 +1,9 @@
#ifndef EU07_RENDERCOMPONENTS_H
#define EU07_RENDERCOMPONENTS_H
#include "registry/FName.h"
#include "rendering/geometrybank.h"
namespace ECSComponent
{
/// <summary>
@@ -11,6 +14,8 @@ namespace ECSComponent
/// </remarks>
struct MeshRenderer
{
gfx::geometry_handle meshHandle;
bool visible = true;
};
/// <summary>
@@ -19,7 +24,53 @@ struct MeshRenderer
/// <remarks>Currently empty
/// TODO: Add component members
/// </remarks>
struct SpotLight{};
struct SpotLight
{
glm::vec3 Color{ 1.0f, 1.0f, 1.0f };
float Intensity = 1.0f;
float Range = 25.0f;
float InnerAngle = 15.0f;
float OuterAngle = 25.0f;
bool CastShadows = false;
bool Enabled = true;
};
// TODO: AreaLight like blender
// TODO: SunLight for scene
struct ParticleEmitter
{
FName particleEffectPath = ("");
bool active = true;
};
struct Decal
{
FName decalTexturePath = ("");
float size = 1.0f;
bool active = true;
};
struct Billboard
{
FName texturePath = ("");
float size = 1.0f;
bool active = true;
};
struct Line {
glm::vec3 start{ 0.0f };
glm::vec3 end{ 1.0f, 0.0f, 0.0f };
glm::vec3 color{ 1.0f, 1.0f, 1.0f };
float thickness = 1.0f;
bool active = true;
};
/// <summary>
/// Component for entities that can be rendered with LOD