From eb00ac527488bddfdb0c815862fc0cffba9d9917 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Sun, 28 Jul 2024 12:28:06 -0400 Subject: [PATCH] Added ability to set different color for gizmos --- Editor/src/Misc/Gizmos/CylinderGizmo.cpp | 31 +++++++++++++----------- Editor/src/Misc/Gizmos/CylinderGizmo.h | 6 +++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Editor/src/Misc/Gizmos/CylinderGizmo.cpp b/Editor/src/Misc/Gizmos/CylinderGizmo.cpp index 89d26df7..f28977fb 100644 --- a/Editor/src/Misc/Gizmos/CylinderGizmo.cpp +++ b/Editor/src/Misc/Gizmos/CylinderGizmo.cpp @@ -2,9 +2,10 @@ #include -CylinderGizmo::CylinderGizmo() : +CylinderGizmo::CylinderGizmo(Nuake::Color color) : _Radius(0.0f), - _Height(0.0f) + _Height(0.0f), + _Color(color) { } @@ -13,15 +14,17 @@ void CylinderGizmo::Bind() _CylinderBuffer->Bind(); } -void CylinderGizmo::UpdateShape(float radius, float height) +void CylinderGizmo::UpdateShape(float radius, float height, Nuake::Color color) { - if (_Radius == radius && _Height == height) + if (_Radius == radius && _Height == height && _Color == color) { return; } _Radius = radius; _Height = height; + _Color = color; + CreateMesh(); } @@ -62,21 +65,21 @@ void CylinderGizmo::CreateMesh() vert2 = Vector3(x2, bottomCircleHeight, z2); } - _CylinderVertices.push_back(LineVertex{ vert1, Color(1.0, 0, 0.0, 0.5) }); - _CylinderVertices.push_back(LineVertex{ vert2, Color(1.0, 0, 0.0, 0.5) }); + _CylinderVertices.push_back(LineVertex{ vert1, _Color }); + _CylinderVertices.push_back(LineVertex{ vert2, _Color }); } - _CylinderVertices.push_back(LineVertex{ Vector3(radius, bottomCircleHeight, 0), Color(1.0, 0, 0.0, 0.5) }); - _CylinderVertices.push_back(LineVertex{ Vector3(radius, topCircleHeight, 0), Color(1.0, 0, 0.0, 0.5) }); + _CylinderVertices.push_back(LineVertex{ Vector3(radius, bottomCircleHeight, 0), _Color }); + _CylinderVertices.push_back(LineVertex{ Vector3(radius, topCircleHeight, 0), _Color }); - _CylinderVertices.push_back(LineVertex{ Vector3(-radius, bottomCircleHeight, 0), Color(1.0, 0, 0.0, 0.5) }); - _CylinderVertices.push_back(LineVertex{ Vector3(-radius, topCircleHeight, 0), Color(1.0, 0, 0.0, 0.5) }); + _CylinderVertices.push_back(LineVertex{ Vector3(-radius, bottomCircleHeight, 0), _Color }); + _CylinderVertices.push_back(LineVertex{ Vector3(-radius, topCircleHeight, 0), _Color }); - _CylinderVertices.push_back(LineVertex{ Vector3(0, bottomCircleHeight, radius), Color(1.0, 0, 0.0, 0.5) }); - _CylinderVertices.push_back(LineVertex{ Vector3(0, topCircleHeight, radius), Color(1.0, 0, 0.0, 0.5) }); + _CylinderVertices.push_back(LineVertex{ Vector3(0, bottomCircleHeight, radius), _Color }); + _CylinderVertices.push_back(LineVertex{ Vector3(0, topCircleHeight, radius), _Color }); - _CylinderVertices.push_back(LineVertex{ Vector3(0, bottomCircleHeight, -radius), Color(1.0, 0, 0.0, 0.5) }); - _CylinderVertices.push_back(LineVertex{ Vector3(0, topCircleHeight, -radius), Color(1.0, 0, 0.0, 0.5) }); + _CylinderVertices.push_back(LineVertex{ Vector3(0, bottomCircleHeight, -radius), _Color }); + _CylinderVertices.push_back(LineVertex{ Vector3(0, topCircleHeight, -radius), _Color }); _CylinderBuffer = CreateRef(); _CylinderBuffer->Bind(); diff --git a/Editor/src/Misc/Gizmos/CylinderGizmo.h b/Editor/src/Misc/Gizmos/CylinderGizmo.h index cecb7c6e..f0eb1a5b 100644 --- a/Editor/src/Misc/Gizmos/CylinderGizmo.h +++ b/Editor/src/Misc/Gizmos/CylinderGizmo.h @@ -1,5 +1,6 @@ #pragma once #include +#include "src/Core/Maths.h" #include #include #include @@ -15,12 +16,13 @@ private: float _Radius; float _Height; + Nuake::Color _Color; public: - CylinderGizmo(); + CylinderGizmo(Nuake::Color color = Nuake::Color(1, 0, 0, 1)); ~CylinderGizmo() = default; - void UpdateShape(float radius, float height); + void UpdateShape(float radius, float height, Nuake::Color color = Nuake::Color(1, 0, 0, 1)); void CreateMesh(); void Bind(); }; \ No newline at end of file