feat: add imguizmo + trigger buxfix
This commit is contained in:
@@ -13,6 +13,8 @@ public:
|
||||
|
||||
~Collider() override = default;
|
||||
|
||||
[[nodiscard]] bool AffectsPhysics() const override { return true; }
|
||||
|
||||
void ImGuiInspector() override;
|
||||
|
||||
[[nodiscard]] virtual PhysicsShapeDesc BuildPhysicsShape() const = 0;
|
||||
|
||||
@@ -15,6 +15,8 @@ public:
|
||||
|
||||
~Rigidbody() override;
|
||||
|
||||
[[nodiscard]] bool AffectsPhysics() const override { return true; }
|
||||
|
||||
void Update(float) override {}
|
||||
void Start() override;
|
||||
void Destroy() override;
|
||||
|
||||
@@ -126,6 +126,9 @@ public:
|
||||
void SetMovementSpeed(float speed) { m_movementSpeed = speed; }
|
||||
[[nodiscard]] float GetMovementSpeed() const { return m_movementSpeed; }
|
||||
|
||||
void SetMouseSensitivity(float sensitivity) { m_mouseSensitivity = sensitivity; }
|
||||
[[nodiscard]] float GetMouseSensitivity() const { return m_mouseSensitivity; }
|
||||
|
||||
void SetRotation(float yawRadians, float pitchRadians);
|
||||
void SetRotation(const glm::vec2& yawPitchRadians);
|
||||
void SetOrientation(const glm::vec3& forward, const glm::vec3& up);
|
||||
@@ -168,6 +171,7 @@ private:
|
||||
Frustum m_frustum{};
|
||||
|
||||
float m_movementSpeed{2.0f};
|
||||
float m_mouseSensitivity{0.003f};
|
||||
|
||||
float m_yaw = 0.0f; // radians
|
||||
float m_pitch = 0.0f; // radians
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
void init(SDL_Window* window, const std::string& appName, bool vSync);
|
||||
void cleanup();
|
||||
|
||||
void recreateSwapchain(int width, int height);
|
||||
[[nodiscard]] bool recreateSwapchain(int width, int height);
|
||||
|
||||
VkCommandBuffer beginFrame();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
std::uint32_t height,
|
||||
bool vSync);
|
||||
|
||||
void recreateSwapchain(
|
||||
[[nodiscard]] bool recreateSwapchain(
|
||||
VkDevice device,
|
||||
vkb::Device vkbDevice,
|
||||
VkSurfaceKHR surface,
|
||||
|
||||
@@ -33,6 +33,8 @@ public:
|
||||
virtual void Start();
|
||||
virtual void SetEnabled(bool enabled);
|
||||
|
||||
[[nodiscard]] virtual bool AffectsPhysics() const { return false; }
|
||||
|
||||
// Reason for keeping No DT function -> i am tired and lazy
|
||||
// If im feeling frisky im gonna claim backwards compatibility
|
||||
virtual void Update(float dt);
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
|
||||
void CleanupComponents();
|
||||
void RefreshPhysics();
|
||||
void RefreshPhysicsInHierarchy();
|
||||
|
||||
void SetActive(bool active) {
|
||||
if (active == m_Active) {
|
||||
@@ -36,7 +37,7 @@ public:
|
||||
|
||||
m_Active = active;
|
||||
SetActiveDirty();
|
||||
RefreshPhysics();
|
||||
RefreshPhysicsInHierarchy();
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsActive() const { return m_Active; }
|
||||
@@ -76,7 +77,9 @@ public:
|
||||
auto& addedComponent = m_Components.emplace_back(
|
||||
std::make_unique<TComponent>(*this, std::forward<Args>(args)...));
|
||||
|
||||
RefreshPhysics();
|
||||
if (addedComponent->AffectsPhysics()) {
|
||||
RefreshPhysics();
|
||||
}
|
||||
return static_cast<TComponent*>(addedComponent.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
return m_objects;
|
||||
}
|
||||
[[nodiscard]] GameObject* FindGameObject(ObjectId id) const;
|
||||
[[nodiscard]] GameObject* GetSelectedObject() const { return FindGameObject(m_SelectedObjectId); }
|
||||
|
||||
void SetRegisterBindings(std::function<void()> registerBindings) {
|
||||
m_registerBindings = std::move(registerBindings);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef DESTRUM_TRANSFORMGIZMO_H
|
||||
#define DESTRUM_TRANSFORMGIZMO_H
|
||||
|
||||
class Camera;
|
||||
class GameObject;
|
||||
|
||||
enum class GizmoOperation {
|
||||
Translate,
|
||||
Rotate,
|
||||
Scale,
|
||||
};
|
||||
|
||||
enum class GizmoSpace {
|
||||
World,
|
||||
Local,
|
||||
};
|
||||
|
||||
class TransformGizmo final {
|
||||
public:
|
||||
void HandleShortcuts();
|
||||
void DrawToolbar();
|
||||
bool Manipulate(GameObject& object, const Camera& camera);
|
||||
|
||||
[[nodiscard]] bool IsUsing() const;
|
||||
[[nodiscard]] bool IsOver() const;
|
||||
|
||||
GizmoOperation operation{GizmoOperation::Translate};
|
||||
GizmoSpace space{GizmoSpace::World};
|
||||
bool snap{false};
|
||||
float translationSnap{0.5f};
|
||||
float rotationSnapDegrees{15.0f};
|
||||
float scaleSnap{0.1f};
|
||||
};
|
||||
|
||||
#endif // DESTRUM_TRANSFORMGIZMO_H
|
||||
Reference in New Issue
Block a user