From 32873d14ae97f9c8ad69c1bc3427efdfe98207e7 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 23 Oct 2025 20:32:12 +0200 Subject: [PATCH] chore: rename `transform` to `Transform` --- engine/include/engine/components/batch.h | 2 +- engine/include/engine/components/transform.h | 2 +- engine/src/renderer/renderer.cpp | 12 ++++++------ sandbox/src/main.cpp | 16 ++++++++-------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/engine/include/engine/components/batch.h b/engine/include/engine/components/batch.h index 54800a3..19af3a6 100644 --- a/engine/include/engine/components/batch.h +++ b/engine/include/engine/components/batch.h @@ -9,7 +9,7 @@ namespace Core { struct ENGINE_API batch { friend class Renderer; public: - // requires transform component + // requires Transform component struct item { unsigned int batchId; }; diff --git a/engine/include/engine/components/transform.h b/engine/include/engine/components/transform.h index 5ae554e..906b60b 100644 --- a/engine/include/engine/components/transform.h +++ b/engine/include/engine/components/transform.h @@ -5,7 +5,7 @@ #include "engine/export.h" namespace Core { -struct ENGINE_API transform { +struct ENGINE_API Transform { glm::vec3 position; glm::vec3 rotation; glm::vec3 scale; diff --git a/engine/src/renderer/renderer.cpp b/engine/src/renderer/renderer.cpp index 0376d53..d0c9fd6 100644 --- a/engine/src/renderer/renderer.cpp +++ b/engine/src/renderer/renderer.cpp @@ -67,7 +67,7 @@ void Renderer::ApplyLights(Shader &shader) { size_t lightIndex = 0; for (auto entity : lights) { auto &l = m_scene->m_registry.get(entity); - auto &transf = m_scene->m_registry.get(entity); + auto &transf = m_scene->m_registry.get(entity); shader.setInt("lights[" + std::to_string(lightIndex) + "].type", static_cast(l.type)); shader.setVec3("lights[" + std::to_string(lightIndex) + "].position", transf.position); @@ -111,8 +111,8 @@ void Renderer::EnsureShadowResources(light& l) { void Renderer::UpdateView() { auto camView = m_scene->m_registry.view(); auto camTransform = camView.size() > 0 ? - m_scene->m_registry.get(camView.back()) : - transform {glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(1.f, 1.f, 1.f)}; + m_scene->m_registry.get(camView.back()) : + Transform {glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(1.f, 1.f, 1.f)}; m_view = glm::lookAt( camTransform.position, @@ -149,7 +149,7 @@ void Renderer::RenderScene(Shader &shader) { models.reserve(batchItems.size()); for (auto item : batchItems) { - auto &t = m_scene->m_registry.get(item); + auto &t = m_scene->m_registry.get(item); glm::mat4 rotation = glm::yawPitchRoll(t.rotation.y, t.rotation.x, t.rotation.z); auto itemModel = glm::translate(glm::mat4(1.f), t.position) * rotation; models.push_back(itemModel); @@ -165,7 +165,7 @@ void Renderer::RenderScene(Shader &shader) { } shader.setBool("u_isInstanced", false); - for (auto [entity, transf, mesh] : m_scene->m_registry.view(entt::exclude).each()) { + for (auto [entity, transf, mesh] : m_scene->m_registry.view(entt::exclude).each()) { if (mesh.object == nullptr) { std::cerr << "WARN: Entity doesn't have a mesh to render" << std::endl; return; @@ -206,7 +206,7 @@ void Renderer::Render() { glCullFace(GL_FRONT); - const auto lights = m_scene->m_registry.view(); + const auto lights = m_scene->m_registry.view(); for (auto [_, l, t] : lights.each()) { // TODO: support other light types when ready diff --git a/sandbox/src/main.cpp b/sandbox/src/main.cpp index 1bda3bc..047e4f4 100644 --- a/sandbox/src/main.cpp +++ b/sandbox/src/main.cpp @@ -36,20 +36,20 @@ public: Object* lightObj = Object::LoadFile("./assets/common/sphere/sphere.obj"); lightEntity = scene->CreateEntity(); - lightEntity.AddComponent(glm::vec3(5.f, 5.f, 5.f), glm::vec3(0.f)); + lightEntity.AddComponent(glm::vec3(5.f, 5.f, 5.f), glm::vec3(0.f)); lightEntity.AddComponent(light::LightType::DIRECTIONAL, glm::vec3(1.f, 1.f, 1.f), 1.5f); lightEntity.AddComponent(std::shared_ptr(lightObj)); assert(lightEntity.HasComponent() && "light doesn't have any mesh!"); cameraEntity = scene->CreateEntity(); cameraEntity.AddComponent(); - cameraEntity.AddComponent(glm::vec3(0.f, 2.f, 2.f)); + cameraEntity.AddComponent(glm::vec3(0.f, 2.f, 2.f)); assert(cameraEntity.HasComponent() && "Camera doesn't have required 'camera' component"); - assert(cameraEntity.HasComponent() && "Camera doesn't have 'transform' component"); + assert(cameraEntity.HasComponent() && "Camera doesn't have 'transform' component"); Object* targetObj = Object::LoadFile("./assets/wizard/wizard.obj"); modelEntity = scene->CreateEntity(); - modelEntity.AddComponent(glm::vec3(0.f, 0.0f, 0.f)); + modelEntity.AddComponent(glm::vec3(0.f, 0.0f, 0.f)); modelEntity.AddComponent(std::shared_ptr(targetObj)); modelEntity.AddComponent(); assert(modelEntity.HasComponent() && "model doesn't have any mesh!"); @@ -70,14 +70,14 @@ public: float y = static_cast(rand()) / RAND_MAX * 10.f; // range [0, 10] float z = static_cast(rand()) / RAND_MAX * 200.f - 100.f; // range [-100, 100] - cubeEntity.AddComponent(glm::vec3(x, y, z)); + cubeEntity.AddComponent(glm::vec3(x, y, z)); cubeEntity.AddComponent(); cubeEntity.AddComponent(cubeBatch.id()); } Object* floorObj = Object::LoadFile("./assets/common/plane/plane.obj"); auto floorEntt = scene->CreateEntity(); - floorEntt.AddComponent(glm::vec3(0.f)); + floorEntt.AddComponent(glm::vec3(0.f)); floorEntt.AddComponent(std::shared_ptr(floorObj)); assert(floorEntt.HasComponent() && "floor doesn't have any mesh component!"); @@ -120,7 +120,7 @@ public: if (Input::IsKeyPressed(SDL_SCANCODE_SPACE)) velocity.y += 1.f; if (Input::IsKeyPressed(SDL_SCANCODE_LSHIFT)) velocity.y -= 1.f; - auto& camTransform = cameraEntity.GetComponent(); + auto& camTransform = cameraEntity.GetComponent(); camTransform.position += velocity * (float)dt * 2.5f; // speed is e.g. 2.5f camTransform.rotation = cameraViewDirection; @@ -154,7 +154,7 @@ public: // Update the directional light in the registry auto& l = lightEntity.GetComponent(); - auto& t = lightEntity.GetComponent(); + auto& t = lightEntity.GetComponent(); if (l.type == light::LightType::DIRECTIONAL) { // "position" for directional light often stores direction vector // If your system instead uses transform.rotation, adjust accordingly