From 538b63c09fa90eb0d9f48f1ecd8b3394fd07270e Mon Sep 17 00:00:00 2001 From: SweetId <2630750+SweetId@users.noreply.github.com> Date: Thu, 12 Oct 2023 22:30:52 -0400 Subject: [PATCH] add CameraComponent reflection --- .../NazaraEditor/Core/Reflection/Graphics.hpp | 27 +++++++++++++++++++ include/NazaraEditor/Core/Reflection/Math.hpp | 15 +++++++++++ src/NazaraEditor/Editor/main.cpp | 3 +++ 3 files changed, 45 insertions(+) diff --git a/include/NazaraEditor/Core/Reflection/Graphics.hpp b/include/NazaraEditor/Core/Reflection/Graphics.hpp index ccd3ad6..652053f 100644 --- a/include/NazaraEditor/Core/Reflection/Graphics.hpp +++ b/include/NazaraEditor/Core/Reflection/Graphics.hpp @@ -30,6 +30,24 @@ namespace Nz } }; + template <> + class TypeReflect + { + public: + template + static void Reflect(TPropertyEnumerator& p, CameraComponent& obj) + { + p.AddProperty([&obj]() { return obj.GetZNear(); }, [&obj](float v) { obj.UpdateZNear(v); }, "Near", "Near plane"); + p.AddProperty([&obj]() { return obj.GetZFar(); }, [&obj](float v) { obj.UpdateZFar(v); }, "Far", "Far plane"); + p.AddProperty([&obj]() { return obj.GetFOV(); }, [&obj](Nz::DegreeAnglef v) { obj.UpdateFOV(v); }, "FOV", "Field of View"); + p.AddProperty([&obj]() { return obj.GetFOV(); }, [&obj](Nz::DegreeAnglef v) { obj.UpdateFOV(v); }, "FOV", "Field of View"); + p.AddProperty([&obj]() { return obj.GetClearColor(); }, [&obj](const Nz::Color& v) { obj.UpdateClearColor(v); }, "Clear color", "Clear color"); + p.AddProperty([&obj]() { return obj.GetRenderOrder(); }, [&obj](Nz::UInt32 v) { obj.UpdateRenderOrder(v); }, "RenderOrder", "Render order"); + p.AddProperty([&obj]() { return obj.GetRenderMask(); }, [&obj](Nz::UInt32 v) { obj.UpdateRenderMask(v); }, "RenderMask", "Render mask"); + } + }; + + namespace EditorImgui { inline bool Begin(Nz::LightComponent::LightEntry& /*obj*/, const std::string& /*name*/, const std::string& /*tooltip*/) @@ -48,5 +66,14 @@ namespace Nz inline void End(Nz::LightComponent&) { ImGui::TreePop(); } + + inline bool Begin(Nz::CameraComponent& /*obj*/, const std::string& /*name*/, const std::string& /*tooltip*/) + { + return ImGui::TreeNodeEx("CameraComponent", ImGuiTreeNodeFlags_Framed); + } + + inline void End(Nz::CameraComponent&) { + ImGui::TreePop(); + } } } \ No newline at end of file diff --git a/include/NazaraEditor/Core/Reflection/Math.hpp b/include/NazaraEditor/Core/Reflection/Math.hpp index 7fe9efa..05785c7 100644 --- a/include/NazaraEditor/Core/Reflection/Math.hpp +++ b/include/NazaraEditor/Core/Reflection/Math.hpp @@ -78,6 +78,21 @@ namespace Nz } inline void End(Nz::Quaternionf&) {} + + template + inline bool Begin(Nz::Angle& obj, const std::string& name, const std::string& tooltip) + { + auto angle = obj.To(); + if (ImGui::DragFloat(name.c_str(), &angle, 1.f, std::numeric_limits::min(), std::numeric_limits::max())) + { + obj.From(angle); + } + Tooltip(tooltip); + return false; + } + + template + inline void End(Nz::Angle& obj) {} } } \ No newline at end of file diff --git a/src/NazaraEditor/Editor/main.cpp b/src/NazaraEditor/Editor/main.cpp index fa0ef9f..ce5a14b 100644 --- a/src/NazaraEditor/Editor/main.cpp +++ b/src/NazaraEditor/Editor/main.cpp @@ -37,6 +37,9 @@ int WinMain(int argc, char* argv[]) entt::meta() .type(entt::type_hash::value()) .func<&Nz::ReflectComponent, Nz::NodeComponent>>(entt::hashed_string("Reflect")); + entt::meta() + .type(entt::type_hash::value()) + .func<&Nz::ReflectComponent, Nz::CameraComponent>>(entt::hashed_string("Reflect")); entt::meta() .type(entt::type_hash::value()) .func<&Nz::ReflectComponent, Nz::LightComponent>>(entt::hashed_string("Reflect"));