feat: Add "simple" inspector to the imgui panels
This commit is contained in:
@@ -17,6 +17,7 @@ public:
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ResolveReferences(const ObjectMap& objects) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
void SetMeshID(MeshID id);
|
||||
MeshID GetMeshID() const { return meshID; }
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
// optional setters
|
||||
void SetRadius(float r) { m_Radius = r; }
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
std::string GetTypeName() const override
|
||||
{
|
||||
|
||||
@@ -17,6 +17,8 @@ public:
|
||||
return "CapsuleCollider";
|
||||
}
|
||||
|
||||
void ImGuiInspector() override;
|
||||
|
||||
nlohmann::json Serialize() const override {
|
||||
auto data = SerializeCollider();
|
||||
data["radius"] = m_Radius;
|
||||
|
||||
@@ -12,6 +12,8 @@ public:
|
||||
|
||||
~Collider() override = default;
|
||||
|
||||
void ImGuiInspector() override;
|
||||
|
||||
[[nodiscard]] virtual PhysicsShapeDesc BuildPhysicsShape() const = 0;
|
||||
|
||||
[[nodiscard]] bool IsTrigger() const { return m_IsTrigger; }
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
std::string GetTypeName() const override
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ public:
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
std::string GetTypeName() const override
|
||||
{
|
||||
return "SphereCollider";
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
void SetDistance(float distance);
|
||||
void SetSpeed(float speed) { m_Speed = speed; }
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
|
||||
nlohmann::json Serialize() const override;
|
||||
void Deserialize(const nlohmann::json& data) override;
|
||||
void ImGuiInspector() override;
|
||||
|
||||
void SetAxis(const glm::vec3& axis) {
|
||||
m_Axis = glm::dot(axis, axis) > 0.000001f
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
virtual void LateUpdate(float dt);
|
||||
virtual void FixedUpdate(float fixedDt);
|
||||
|
||||
// Called by the editor inspector while this component is selected. A
|
||||
// component owns the controls for its editable runtime properties.
|
||||
virtual void ImGuiInspector();
|
||||
virtual void ImGuiRender();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <functional>
|
||||
|
||||
#include <destrum/Event.h>
|
||||
#include <destrum/ObjectModel/ObjectId.h>
|
||||
#include <destrum/Scene/SceneManager.h>
|
||||
|
||||
#include "destrum/Physics/JoltPhysicsWorld.h"
|
||||
@@ -120,6 +121,7 @@ private:
|
||||
|
||||
//Imgui vars
|
||||
bool m_ShowDemoWindow{false};
|
||||
ObjectId m_SelectedObjectId{InvalidObjectId};
|
||||
|
||||
std::function<void()> m_registerBindings;
|
||||
std::function<void()> m_unregisterBindings;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef DESTRUM_IMGUIUTILS_H
|
||||
#define DESTRUM_IMGUIUTILS_H
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <destrum/ObjectModel/ObjectId.h>
|
||||
|
||||
class GameObject;
|
||||
|
||||
namespace ImGuiUtils {
|
||||
[[nodiscard]] bool DrawVec3Control(
|
||||
const char* label,
|
||||
glm::vec3& value,
|
||||
float speed = 0.1f);
|
||||
|
||||
void RenderSceneInspector(
|
||||
std::string_view sceneName,
|
||||
const std::vector<std::shared_ptr<GameObject>>& objects,
|
||||
const std::vector<std::shared_ptr<GameObject>>& pendingAdditions,
|
||||
ObjectId& selectedObjectId);
|
||||
}
|
||||
|
||||
#endif // DESTRUM_IMGUIUTILS_H
|
||||
Reference in New Issue
Block a user