Better Gizmos

Gizmos now display half opacity when occluded, same for lines
Improved editor camera, should keep updating even if not controlled
Viewport should not grab input when another imgui element is over it
This commit is contained in:
Antoine Pilote
2023-10-09 15:22:39 -04:00
parent 828f46713b
commit d3ec4e1c02
14 changed files with 122849 additions and 73485 deletions

View File

@@ -154,6 +154,13 @@ namespace Nuake
return Vector2(xpos, ypos);
}
void Input::SetMousePosition(const Vector2& position)
{
auto window = Window::Get()->GetHandle();
glfwSetCursorPos(window, position.x, position.y);
}
#pragma endregion
bool Input::Init()

View File

@@ -156,6 +156,7 @@ namespace Nuake
static float GetMouseX();
static float GetMouseY();
static Vector2 GetMousePosition();
static void SetMousePosition(const Vector2& position);
static bool Init();
static void Update();

View File

@@ -38,7 +38,7 @@ namespace Nuake
void SetSize(const Vector2& size) { m_Size = size; }
void UpdateSize(Vector2 size);
uint32_t GetRenderID() const { return m_FramebufferID; }
int ReadPixel(uint32_t attachment, const Vector2 coords);
void SetDrawBuffer(GLenum draw);
void SetReadBuffer(GLenum read);

View File

@@ -16,11 +16,11 @@ namespace Nuake
{
const auto defaultResolution = Vector2(1920, 1080);
mGBuffer = CreateScope<FrameBuffer>(false, defaultResolution);
mGBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_DEPTH_COMPONENT), GL_DEPTH_ATTACHMENT);
mGBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_DEPTH_COMPONENT), GL_DEPTH_ATTACHMENT); // Depth
mGBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RGB), GL_COLOR_ATTACHMENT0); // Albedo
mGBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RGB), GL_COLOR_ATTACHMENT1); //
mGBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RGB), GL_COLOR_ATTACHMENT1); // Normal
mGBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RGBA), GL_COLOR_ATTACHMENT2); // Material + unlit
mGBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RED_INTEGER, GL_R32I, GL_INT), GL_COLOR_ATTACHMENT3);
mGBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RED_INTEGER, GL_R32I, GL_INT), GL_COLOR_ATTACHMENT3); // Entity ID
mGBuffer->SetTexture(CreateRef<Texture>(defaultResolution, GL_RED, GL_R16F, GL_FLOAT), GL_COLOR_ATTACHMENT4); // Emissive
mShadingBuffer = CreateScope<FrameBuffer>(true, defaultResolution);

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,7 @@
#include <glm/trigonometric.hpp>
#include "src/Core/Logger.h"
#include <src/Vendors/imgui/imgui.h>
namespace Nuake
{
@@ -79,7 +80,8 @@ namespace Nuake
mouseLastY = y;
}
if (hover && Input::IsMouseButtonDown(1))
if (controlled && Input::IsMouseButtonDown(1))
{
// Should probably not have speed binding in here.
if (Input::YScroll != 0)
@@ -131,7 +133,6 @@ namespace Nuake
firstMouse = false;
}
// mouse
float diffx = x - mouseLastX;
float diffy = mouseLastY - y;
mouseLastX = x;
@@ -159,31 +160,32 @@ namespace Nuake
SetDirection(glm::normalize(Direction));
Right = glm::normalize(glm::cross(Up, Direction));
if (hover)
if (Input::IsMouseButtonDown(2))
{
if (Input::IsMouseButtonDown(2))
{
Vector3 movement = Vector3(0);
const float deltaX = x - mouseLastX;
const float deltaY = y - mouseLastY;
movement += Right * (deltaX * ts);
movement += Up * (deltaY * ts);
Translation += Vector3(movement) * 0.5f;
Vector3 movement = Vector3(0);
const float deltaX = x - mouseLastX;
const float deltaY = y - mouseLastY;
movement += Right * (deltaX * ts);
movement += Up * (deltaY * ts);
Translation += Vector3(movement) * 0.5f;
mouseLastX = x;
mouseLastY = y;
controlled = true;
mouseLastX = x;
mouseLastY = y;
controlled = true;
SetDirection(glm::normalize(Direction));
}
else if (Input::YScroll != 0)
{
Translation += Vector3(Direction) * Input::YScroll;
Input::YScroll = 0.0f;
}
SetDirection(glm::normalize(Direction));
}
else if (Input::YScroll != 0)
{
Translation += Vector3(Direction) * Input::YScroll;
Input::YScroll = 0.0f;
}
SetDirection(glm::normalize(Direction));
mouseLastX = x;
mouseLastY = y;
}

View File

@@ -7,7 +7,11 @@ namespace Nuake
{
class EditorCamera : public Camera
{
private:
bool m_IsFlying = false;
public:
EditorCamera()
{
Yaw = 0.0f;
@@ -27,6 +31,7 @@ namespace Nuake
void SetYaw(float yaw);
void SetPitch(float pitch);
bool IsFlying() const { return m_IsFlying; }
private:
bool controlled = false;
bool firstMouse = false;

View File

@@ -597,10 +597,14 @@ namespace Nuake {
});
}
for (int i = 0; i < (face_geo_inst->vertex_count - 2) * 3; ++i)
for (int i = 0; i < (face_geo_inst->vertex_count - 2) * 3; i += 3)
{
uint32_t index = face_geo_inst->indices[i];
indices.push_back((unsigned int)index);
uint32_t i1 = face_geo_inst->indices[i];
uint32_t i2 = face_geo_inst->indices[i + 1];
uint32_t i3 = face_geo_inst->indices[i + 2];
indices.push_back(i3);
indices.push_back(i2);
indices.push_back(i1);
}
m_StaticWorld[currentMaterial].push_back({vertices, indices});