This commit is contained in:
Antoine Pilote
2023-09-15 17:57:28 -04:00
3 changed files with 65 additions and 55 deletions

View File

@@ -65,6 +65,7 @@ namespace Nuake
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
const char* icon = ICON_FA_FOLDER;
const std::string id = ICON_FA_FOLDER + std::string("##") + directory->name;
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
if (ImGui::Button(id.c_str(), ImVec2(100, 100)))
{
m_CurrentDirectory = directory;
@@ -675,6 +676,7 @@ namespace Nuake
bool child = ImGui::BeginChild("Content", avail);
ImGui::PopStyleVar();
ImGui::SameLine();
if (child)
{
int width = avail.x;
@@ -689,7 +691,7 @@ namespace Nuake
if (m_CurrentDirectory && m_CurrentDirectory != FileSystem::RootDirectory && m_CurrentDirectory->Parent)
{
ImGui::TableNextColumn();
if (ImGui::Button("..", ImVec2(100, 100)))
if (ImGui::Button("..", buttonSize))
m_CurrentDirectory = m_CurrentDirectory->Parent;
i++;
}
@@ -717,7 +719,7 @@ namespace Nuake
{
if(m_SearchKeyword.empty() || f->GetName().find(String::Sanitize(m_SearchKeyword)) != std::string::npos)
{
if (i - 1 % amount != 0 || i == 1)
if (i + 1 % amount != 0 || i == 1)
{
ImGui::TableNextColumn();
}

View File

@@ -1,63 +1,69 @@
#include "src/Core/Maths.h"
using namespace Nuake;
Quat Nuake::LookAt(Vector3 sourcePoint, Vector3 destPoint)
namespace Nuake
{
Vector3 forwardVector = glm::normalize(destPoint - sourcePoint);
Quat Nuake::LookAt(Vector3 sourcePoint, Vector3 destPoint)
{
Vector3 forwardVector = glm::normalize(destPoint - sourcePoint);
float dot = glm::dot(Vector3(0, 0, 1), forwardVector);
if (glm::abs(dot - (-1.0f)) < 0.000001f)
{
return Quat(0, 1, 0, 3.1415926535897932f);
}
if (glm::abs(dot - (1.0f)) < 0.000001f)
{
return Quat(); // identity
float dot = glm::dot(Vector3(0, 0, 1), forwardVector);
if (glm::abs(dot - (-1.0f)) < 0.000001f)
{
return Quat(0, 1, 0, 3.1415926535897932f);
}
if (glm::abs(dot - (1.0f)) < 0.000001f)
{
return Quat(); // identity
}
float rotAngle = acos(dot);
Vector3 rotAxis = glm::cross(Vector3(0, 0, 1), forwardVector);
rotAxis = glm::normalize(rotAxis);
return CreateFromAxisAngle(rotAxis, rotAngle);
}
float rotAngle = acos(dot);
Vector3 rotAxis = glm::cross(Vector3(0, 0, 1), forwardVector);
rotAxis = glm::normalize(rotAxis);
return CreateFromAxisAngle(rotAxis, rotAngle);
}
// just in case you need that function also
Quat Nuake::CreateFromAxisAngle(Vector3 axis, float angle)
{
float halfAngle = angle * .5f;
float s = sin(halfAngle);
Quat q;
q.x = axis.x * s;
q.y = axis.y * s;
q.z = axis.z * s;
q.w = cos(halfAngle);
return q;
}
// just in case you need that function also
Quat Nuake::CreateFromAxisAngle(Vector3 axis, float angle)
{
float halfAngle = angle * .5f;
float s = sin(halfAngle);
Quat q;
q.x = axis.x * s;
q.y = axis.y * s;
q.z = axis.z * s;
q.w = cos(halfAngle);
return q;
}
Quat Nuake::QuatFromEuler(float x, float y, float z)
{
Quat pitchQuat = glm::angleAxis(Rad(x), Vector3(1.0f, 0.0f, 0.0f));
Quat yawQuat = glm::angleAxis(Rad(y), Vector3(0.0f, 1.0f, 0.0f));
Quat rollQuat = glm::angleAxis(Rad(z), Vector3(0.0f, 0.0f, -1.0f));
Quat orientation = yawQuat * pitchQuat * rollQuat;
Quat Nuake::QuatFromEuler(float x, float y, float z)
{
Quat pitchQuat = glm::angleAxis(Rad(x), Vector3(1.0f, 0.0f, 0.0f));
Quat yawQuat = glm::angleAxis(Rad(y), Vector3(0.0f, 1.0f, 0.0f));
Quat rollQuat = glm::angleAxis(Rad(z), Vector3(0.0f, 0.0f, -1.0f));
Quat orientation = yawQuat * pitchQuat * rollQuat;
return glm::normalize(orientation);
}
return glm::normalize(orientation);
}
Vector3 Nuake::QuatToDirection(const Quat& quat)
{
return glm::normalize(quat * Vector3(0, 0, -1));
}
Vector3 Nuake::QuatToDirection(const Quat& quat)
{
return glm::normalize(quat * Vector3(0, 0, -1));
}
void Nuake::Decompose(const Matrix4& m, Vector3& pos, Quat& rot, Vector3& scale)
{
pos = m[3];
for (int i = 0; i < 3; i++)
scale[i] = glm::length(Vector3(m[i]));
const Matrix3 rotMtx(
Vector3(m[0]) / scale[0],
Vector3(m[1]) / scale[1],
Vector3(m[2]) / scale[2]);
rot = glm::quat_cast(rotMtx);
}
void Nuake::Decompose(const Matrix4& m, Vector3& pos, Quat& rot, Vector3& scale)
{
pos = m[3];
for (int i = 0; i < 3; i++)
scale[i] = glm::length(Vector3(m[i]));
const Matrix3 rotMtx(
Vector3(m[0]) / scale[0],
Vector3(m[1]) / scale[1],
Vector3(m[2]) / scale[2]);
rot = glm::quat_cast(rotMtx);
}
const Matrix4& Nuake::TransformToCameraTransform(const Matrix4& mat)
{
return mat;
}
}

View File

@@ -25,4 +25,6 @@ namespace Nuake
Quat QuatFromEuler(float x, float y, float z);
Vector3 QuatToDirection(const Quat& quat);
void Decompose(const Matrix4& m, Vector3& pos, Quat& rot, Vector3& scale);
const Matrix4& TransformToCameraTransform(const Matrix4& mat);
}