Merge branch 'master' into OctTree
This commit is contained in:
@@ -17,4 +17,4 @@ Libraries that are too big to be bundled with the project.
|
|||||||
|
|
||||||
| Project | Version | License | Root folder environment variable (Windows) |
|
| Project | Version | License | Root folder environment variable (Windows) |
|
||||||
| ---------------------------------------------------------- | ----------- | --------------------------------------------------------------------------- | ------------------------------------------ |
|
| ---------------------------------------------------------- | ----------- | --------------------------------------------------------------------------- | ------------------------------------------ |
|
||||||
| **[Boost](http://www.boost.org)** | 1.59.0+ | [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt) | BOOST_ROOT |
|
| **[Boost](http://www.boost.org)** | 1.60.0+ | [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt) | BOOST_ROOT |
|
||||||
|
|||||||
+1
-1
Submodule assets updated: c5f674349a...673d4a4e4c
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef EFileDropped_h__
|
||||||
|
#define EFileDropped_h__
|
||||||
|
|
||||||
|
#include "EventBroker.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct FileDropped : Event
|
||||||
|
{
|
||||||
|
std::string Path;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "ELockMouse.h"
|
#include "ELockMouse.h"
|
||||||
#include "EGamepadAxis.h"
|
#include "EGamepadAxis.h"
|
||||||
#include "EGamepadButton.h"
|
#include "EGamepadButton.h"
|
||||||
|
#include "EFileDropped.h"
|
||||||
|
|
||||||
class InputManager
|
class InputManager
|
||||||
{
|
{
|
||||||
@@ -71,6 +72,8 @@ private:
|
|||||||
static void GLFWCharCallback(GLFWwindow* window, unsigned int c);
|
static void GLFWCharCallback(GLFWwindow* window, unsigned int c);
|
||||||
static std::vector<std::pair<double, double>> GLFWScrollCallbackQueue;
|
static std::vector<std::pair<double, double>> GLFWScrollCallbackQueue;
|
||||||
static void GLFWScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
static void GLFWScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
|
static std::vector<std::string> GLFWDropCallbackQueue;
|
||||||
|
static void GLFWDropCallback(GLFWwindow* window, int count, const char* paths[]);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
#include <glm/gtx/common.hpp>
|
#include <glm/gtx/common.hpp>
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
#include "../Core/System.h"
|
#include "../Core/System.h"
|
||||||
#include "../Core/EMousePress.h"
|
#include "../Core/EMousePress.h"
|
||||||
#include "../Core/EMouseRelease.h"
|
#include "../Core/EMouseRelease.h"
|
||||||
@@ -8,6 +9,7 @@
|
|||||||
#include "../Input/EInputCommand.h"
|
#include "../Input/EInputCommand.h"
|
||||||
#include "../Rendering/IRenderer.h"
|
#include "../Rendering/IRenderer.h"
|
||||||
#include "../Rendering/EPicking.h"
|
#include "../Rendering/EPicking.h"
|
||||||
|
#include "../Core/EFileDropped.h"
|
||||||
#include "../Rendering/RenderQueueFactory.h"
|
#include "../Rendering/RenderQueueFactory.h"
|
||||||
|
|
||||||
class EditorSystem : public ImpureSystem
|
class EditorSystem : public ImpureSystem
|
||||||
@@ -41,8 +43,11 @@ private:
|
|||||||
|
|
||||||
EntityID m_Widget = 0;
|
EntityID m_Widget = 0;
|
||||||
EntityID m_WidgetX = 0;
|
EntityID m_WidgetX = 0;
|
||||||
|
EntityID m_WidgetPlaneX = 0;
|
||||||
EntityID m_WidgetY = 0;
|
EntityID m_WidgetY = 0;
|
||||||
|
EntityID m_WidgetPlaneY = 0;
|
||||||
EntityID m_WidgetZ = 0;
|
EntityID m_WidgetZ = 0;
|
||||||
|
EntityID m_WidgetPlaneZ = 0;
|
||||||
EntityID m_WidgetOrigin = 0;
|
EntityID m_WidgetOrigin = 0;
|
||||||
glm::vec3 m_WidgetCurrentAxis;
|
glm::vec3 m_WidgetCurrentAxis;
|
||||||
float m_WidgetPickingDepth = 0.f;
|
float m_WidgetPickingDepth = 0.f;
|
||||||
@@ -50,6 +55,7 @@ private:
|
|||||||
EntityID m_Selection = 0;
|
EntityID m_Selection = 0;
|
||||||
EntityID m_LastSelection = 0;
|
EntityID m_LastSelection = 0;
|
||||||
glm::vec3 m_Position;
|
glm::vec3 m_Position;
|
||||||
|
std::string m_LastDroppedFile;
|
||||||
|
|
||||||
EventRelay<EditorSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<EditorSystem, Events::InputCommand> m_EInputCommand;
|
||||||
bool OnInputCommand(const Events::InputCommand& e);
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
@@ -61,6 +67,8 @@ private:
|
|||||||
bool OnMouseMove(const Events::MouseMove& e);
|
bool OnMouseMove(const Events::MouseMove& e);
|
||||||
EventRelay<EditorSystem, Events::Picking> m_EPicking;
|
EventRelay<EditorSystem, Events::Picking> m_EPicking;
|
||||||
bool OnPicking(const Events::Picking& e);
|
bool OnPicking(const Events::Picking& e);
|
||||||
|
EventRelay<EditorSystem, Events::FileDropped> m_EFileDropped;
|
||||||
|
bool OnFileDropped(const Events::FileDropped& e);
|
||||||
|
|
||||||
void updateWidget();
|
void updateWidget();
|
||||||
void setWidgetMode(WidgetMode newMode);
|
void setWidgetMode(WidgetMode newMode);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
std::vector<unsigned int> InputManager::GLFWCharCallbackQueue;
|
std::vector<unsigned int> InputManager::GLFWCharCallbackQueue;
|
||||||
std::vector<std::pair<double, double>> InputManager::GLFWScrollCallbackQueue;
|
std::vector<std::pair<double, double>> InputManager::GLFWScrollCallbackQueue;
|
||||||
|
std::vector<std::string> InputManager::GLFWDropCallbackQueue;
|
||||||
|
|
||||||
void InputManager::Initialize()
|
void InputManager::Initialize()
|
||||||
{
|
{
|
||||||
@@ -10,6 +11,7 @@ void InputManager::Initialize()
|
|||||||
//m_LastGamepadButtonState = std::array<GamepadButtonState, XUSER_MAX_COUNT>();
|
//m_LastGamepadButtonState = std::array<GamepadButtonState, XUSER_MAX_COUNT>();
|
||||||
glfwSetCharCallback(m_GLFWWindow, &InputManager::GLFWCharCallback);
|
glfwSetCharCallback(m_GLFWWindow, &InputManager::GLFWCharCallback);
|
||||||
glfwSetScrollCallback(m_GLFWWindow, &InputManager::GLFWScrollCallback);
|
glfwSetScrollCallback(m_GLFWWindow, &InputManager::GLFWScrollCallback);
|
||||||
|
glfwSetDropCallback(m_GLFWWindow, &InputManager::GLFWDropCallback);
|
||||||
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ELockMouse, &InputManager::OnLockMouse);
|
EVENT_SUBSCRIBE_MEMBER(m_ELockMouse, &InputManager::OnLockMouse);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EUnlockMouse, &InputManager::OnUnlockMouse);
|
EVENT_SUBSCRIBE_MEMBER(m_EUnlockMouse, &InputManager::OnUnlockMouse);
|
||||||
@@ -95,6 +97,14 @@ void InputManager::Update(double dt)
|
|||||||
}
|
}
|
||||||
GLFWScrollCallbackQueue.clear();
|
GLFWScrollCallbackQueue.clear();
|
||||||
|
|
||||||
|
// File drop
|
||||||
|
for (auto& path : GLFWDropCallbackQueue) {
|
||||||
|
Events::FileDropped e;
|
||||||
|
e.Path = path;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
GLFWDropCallbackQueue.clear();
|
||||||
|
|
||||||
// // Lock mouse while holding LMB
|
// // Lock mouse while holding LMB
|
||||||
// if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT])
|
// if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT])
|
||||||
// {
|
// {
|
||||||
@@ -229,6 +239,14 @@ void InputManager::GLFWScrollCallback(GLFWwindow* window, double xoffset, double
|
|||||||
GLFWScrollCallbackQueue.push_back(std::make_pair(xoffset, yoffset));
|
GLFWScrollCallbackQueue.push_back(std::make_pair(xoffset, yoffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InputManager::GLFWDropCallback(GLFWwindow* window, int count, const char* paths[])
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
GLFWDropCallbackQueue.push_back(std::string(paths[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool InputManager::OnLockMouse(const Events::LockMouse &event)
|
bool InputManager::OnLockMouse(const Events::LockMouse &event)
|
||||||
{
|
{
|
||||||
m_MouseLocked = true;
|
m_MouseLocked = true;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ EditorSystem::EditorSystem(EventBroker* eventBroker, IRenderer* renderer)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &EditorSystem::OnMouseRelease);
|
EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &EditorSystem::OnMouseRelease);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &EditorSystem::OnMouseMove);
|
EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &EditorSystem::OnMouseMove);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPicking, &EditorSystem::OnPicking);
|
EVENT_SUBSCRIBE_MEMBER(m_EPicking, &EditorSystem::OnPicking);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EFileDropped, &EditorSystem::OnFileDropped);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorSystem::Update(World* world, double dt)
|
void EditorSystem::Update(World* world, double dt)
|
||||||
@@ -36,6 +37,11 @@ void EditorSystem::Update(World* world, double dt)
|
|||||||
updateWidget();
|
updateWidget();
|
||||||
|
|
||||||
drawUI(world, dt);
|
drawUI(world, dt);
|
||||||
|
|
||||||
|
// Clear drop queue if it wasn't handled by any UI element
|
||||||
|
if (!m_LastDroppedFile.empty()) {
|
||||||
|
m_LastDroppedFile = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorSystem::OnInputCommand(const Events::InputCommand& e)
|
bool EditorSystem::OnInputCommand(const Events::InputCommand& e)
|
||||||
@@ -79,6 +85,9 @@ bool EditorSystem::OnMouseMove(const Events::MouseMove& e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_Selection == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
||||||
glm::vec3 widgetOrientation = widgetTransform["Orientation"];
|
glm::vec3 widgetOrientation = widgetTransform["Orientation"];
|
||||||
|
|
||||||
@@ -147,6 +156,13 @@ bool EditorSystem::OnMouseMove(const Events::MouseMove& e)
|
|||||||
glm::vec3& scaleX = m_World->GetComponent(m_WidgetX, "Transform")["Scale"];
|
glm::vec3& scaleX = m_World->GetComponent(m_WidgetX, "Transform")["Scale"];
|
||||||
glm::vec3& scaleY = m_World->GetComponent(m_WidgetY, "Transform")["Scale"];
|
glm::vec3& scaleY = m_World->GetComponent(m_WidgetY, "Transform")["Scale"];
|
||||||
glm::vec3& scaleZ = m_World->GetComponent(m_WidgetZ, "Transform")["Scale"];
|
glm::vec3& scaleZ = m_World->GetComponent(m_WidgetZ, "Transform")["Scale"];
|
||||||
|
|
||||||
|
if (m_WidgetCurrentAxis.x > 0 && m_WidgetCurrentAxis.y > 0 && m_WidgetCurrentAxis.z > 0) {
|
||||||
|
float movementLength = glm::length(movement);
|
||||||
|
float dot = glm::dot((glm::vec3)widgetOrientation, movement);
|
||||||
|
movement = glm::vec3(movementLength) * glm::sign(dot);
|
||||||
|
(glm::vec3&)m_World->GetComponent(m_WidgetOrigin, "Transform")["Scale"] += movement;
|
||||||
|
}
|
||||||
if (m_WidgetCurrentAxis.x > 0) {
|
if (m_WidgetCurrentAxis.x > 0) {
|
||||||
scaleX.x += movement.x;
|
scaleX.x += movement.x;
|
||||||
}
|
}
|
||||||
@@ -156,14 +172,19 @@ bool EditorSystem::OnMouseMove(const Events::MouseMove& e)
|
|||||||
if (m_WidgetCurrentAxis.z > 0) {
|
if (m_WidgetCurrentAxis.z > 0) {
|
||||||
scaleZ.z += movement.z;
|
scaleZ.z += movement.z;
|
||||||
}
|
}
|
||||||
if (m_WidgetCurrentAxis.x > 0 && m_WidgetCurrentAxis.y > 0 && m_WidgetCurrentAxis.z > 0) {
|
|
||||||
float max = glm::max(scaleX.x, glm::max(scaleY.y, scaleZ.z));
|
|
||||||
(glm::vec3&)m_World->GetComponent(m_WidgetOrigin, "Transform")["Scale"] = glm::vec3(max);
|
|
||||||
}
|
|
||||||
(glm::vec3&)m_World->GetComponent(m_Selection, "Transform")["Scale"] += movement;
|
(glm::vec3&)m_World->GetComponent(m_Selection, "Transform")["Scale"] += movement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*LOG_DEBUG("DELTA %f", e.DeltaX);
|
||||||
|
if (e.X < 0) {
|
||||||
|
glfwSetCursorPos(m_Renderer->Window(), width - 1, e.Y);
|
||||||
|
}
|
||||||
|
if (e.X >= width) {
|
||||||
|
glfwSetCursorPos(m_Renderer->Window(), 0, e.Y);
|
||||||
|
}*/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,9 +210,9 @@ bool EditorSystem::OnPicking(const Events::Picking& e)
|
|||||||
EntityID parent = m_World->GetParent(entity);
|
EntityID parent = m_World->GetParent(entity);
|
||||||
if (parent == m_Widget) {
|
if (parent == m_Widget) {
|
||||||
m_WidgetCurrentAxis = glm::vec3(
|
m_WidgetCurrentAxis = glm::vec3(
|
||||||
(entity == m_WidgetX) || (entity == m_WidgetOrigin),
|
(entity == m_WidgetX) || (entity == m_WidgetOrigin) || (entity == m_WidgetPlaneY || entity == m_WidgetPlaneZ),
|
||||||
(entity == m_WidgetY) || (entity == m_WidgetOrigin),
|
(entity == m_WidgetY) || (entity == m_WidgetOrigin) || (entity == m_WidgetPlaneX || entity == m_WidgetPlaneZ),
|
||||||
(entity == m_WidgetZ) || (entity == m_WidgetOrigin)
|
(entity == m_WidgetZ) || (entity == m_WidgetOrigin) || (entity == m_WidgetPlaneX || entity == m_WidgetPlaneY)
|
||||||
);
|
);
|
||||||
m_WidgetPickingDepth = result.Depth;
|
m_WidgetPickingDepth = result.Depth;
|
||||||
|
|
||||||
@@ -212,6 +233,12 @@ bool EditorSystem::OnPicking(const Events::Picking& e)
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool EditorSystem::OnFileDropped(const Events::FileDropped& e)
|
||||||
|
{
|
||||||
|
m_LastDroppedFile = boost::filesystem::path(e.Path).lexically_relative(boost::filesystem::current_path()).string();
|
||||||
|
std::replace(m_LastDroppedFile.begin(), m_LastDroppedFile.end(), '\\', '/');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void EditorSystem::updateWidget()
|
void EditorSystem::updateWidget()
|
||||||
{
|
{
|
||||||
@@ -221,12 +248,24 @@ void EditorSystem::updateWidget()
|
|||||||
m_WidgetX = m_World->CreateEntity(m_Widget);
|
m_WidgetX = m_World->CreateEntity(m_Widget);
|
||||||
m_World->AttachComponent(m_WidgetX, "Transform");
|
m_World->AttachComponent(m_WidgetX, "Transform");
|
||||||
m_World->AttachComponent(m_WidgetX, "Model");
|
m_World->AttachComponent(m_WidgetX, "Model");
|
||||||
|
m_WidgetPlaneX = m_World->CreateEntity(m_Widget);
|
||||||
|
m_World->AttachComponent(m_WidgetPlaneX, "Transform");
|
||||||
|
m_World->AttachComponent(m_WidgetPlaneX, "Model");
|
||||||
|
m_World->GetComponent(m_WidgetPlaneX, "Model")["Resource"] = "Models/WidgetPlaneX.obj";
|
||||||
m_WidgetY = m_World->CreateEntity(m_Widget);
|
m_WidgetY = m_World->CreateEntity(m_Widget);
|
||||||
m_World->AttachComponent(m_WidgetY, "Transform");
|
m_World->AttachComponent(m_WidgetY, "Transform");
|
||||||
m_World->AttachComponent(m_WidgetY, "Model");
|
m_World->AttachComponent(m_WidgetY, "Model");
|
||||||
|
m_WidgetPlaneY = m_World->CreateEntity(m_Widget);
|
||||||
|
m_World->AttachComponent(m_WidgetPlaneY, "Transform");
|
||||||
|
m_World->AttachComponent(m_WidgetPlaneY, "Model");
|
||||||
|
m_World->GetComponent(m_WidgetPlaneY, "Model")["Resource"] = "Models/WidgetPlaneY.obj";
|
||||||
m_WidgetZ = m_World->CreateEntity(m_Widget);
|
m_WidgetZ = m_World->CreateEntity(m_Widget);
|
||||||
m_World->AttachComponent(m_WidgetZ, "Transform");
|
m_World->AttachComponent(m_WidgetZ, "Transform");
|
||||||
m_World->AttachComponent(m_WidgetZ, "Model");
|
m_World->AttachComponent(m_WidgetZ, "Model");
|
||||||
|
m_WidgetPlaneZ = m_World->CreateEntity(m_Widget);
|
||||||
|
m_World->AttachComponent(m_WidgetPlaneZ, "Transform");
|
||||||
|
m_World->AttachComponent(m_WidgetPlaneZ, "Model");
|
||||||
|
m_World->GetComponent(m_WidgetPlaneZ, "Model")["Resource"] = "Models/WidgetPlaneZ.obj";
|
||||||
m_WidgetOrigin = m_World->CreateEntity(m_Widget);
|
m_WidgetOrigin = m_World->CreateEntity(m_Widget);
|
||||||
m_World->AttachComponent(m_WidgetOrigin, "Transform");
|
m_World->AttachComponent(m_WidgetOrigin, "Transform");
|
||||||
m_World->AttachComponent(m_WidgetOrigin, "Model");
|
m_World->AttachComponent(m_WidgetOrigin, "Model");
|
||||||
@@ -252,15 +291,24 @@ void EditorSystem::setWidgetMode(WidgetMode newMode)
|
|||||||
auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
||||||
widgetTransform["Orientation"] = glm::vec3(0.f);
|
widgetTransform["Orientation"] = glm::vec3(0.f);
|
||||||
m_World->GetComponent(m_WidgetX, "Transform")["Scale"] = glm::vec3(1.f);
|
m_World->GetComponent(m_WidgetX, "Transform")["Scale"] = glm::vec3(1.f);
|
||||||
|
m_World->GetComponent(m_WidgetPlaneX, "Model")["Visible"] = false;
|
||||||
m_World->GetComponent(m_WidgetY, "Transform")["Scale"] = glm::vec3(1.f);
|
m_World->GetComponent(m_WidgetY, "Transform")["Scale"] = glm::vec3(1.f);
|
||||||
|
m_World->GetComponent(m_WidgetPlaneY, "Model")["Visible"] = false;
|
||||||
m_World->GetComponent(m_WidgetZ, "Transform")["Scale"] = glm::vec3(1.f);
|
m_World->GetComponent(m_WidgetZ, "Transform")["Scale"] = glm::vec3(1.f);
|
||||||
|
m_World->GetComponent(m_WidgetPlaneZ, "Model")["Visible"] = false;
|
||||||
m_World->GetComponent(m_WidgetOrigin, "Transform")["Scale"] = glm::vec3(1.f);
|
m_World->GetComponent(m_WidgetOrigin, "Transform")["Scale"] = glm::vec3(1.f);
|
||||||
|
m_World->GetComponent(m_WidgetOrigin, "Model")["Visible"] = false;
|
||||||
|
|
||||||
if (newMode == WidgetMode::Translate) {
|
if (newMode == WidgetMode::Translate) {
|
||||||
m_World->GetComponent(m_WidgetX, "Model")["Resource"] = "Models/TranslationWidgetX.obj";
|
m_World->GetComponent(m_WidgetX, "Model")["Resource"] = "Models/TranslationWidgetX.obj";
|
||||||
m_World->GetComponent(m_WidgetY, "Model")["Resource"] = "Models/TranslationWidgetY.obj";
|
m_World->GetComponent(m_WidgetY, "Model")["Resource"] = "Models/TranslationWidgetY.obj";
|
||||||
m_World->GetComponent(m_WidgetZ, "Model")["Resource"] = "Models/TranslationWidgetZ.obj";
|
m_World->GetComponent(m_WidgetZ, "Model")["Resource"] = "Models/TranslationWidgetZ.obj";
|
||||||
m_World->GetComponent(m_WidgetOrigin, "Model")["Visible"] = false;
|
// Temporarily disabled for local space until I can figure out what's wrong with the math
|
||||||
|
if (m_WidgetSpace != WidgetSpace::Local) {
|
||||||
|
m_World->GetComponent(m_WidgetPlaneX, "Model")["Visible"] = true;
|
||||||
|
m_World->GetComponent(m_WidgetPlaneY, "Model")["Visible"] = true;
|
||||||
|
m_World->GetComponent(m_WidgetPlaneZ, "Model")["Visible"] = true;
|
||||||
|
}
|
||||||
if (m_Selection != 0) {
|
if (m_Selection != 0) {
|
||||||
if (m_WidgetSpace == WidgetSpace::Local) {
|
if (m_WidgetSpace == WidgetSpace::Local) {
|
||||||
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
||||||
@@ -275,13 +323,12 @@ void EditorSystem::setWidgetMode(WidgetMode newMode)
|
|||||||
m_World->GetComponent(m_WidgetOrigin, "Model")["Resource"] = "Models/ScaleWidgetOrigin.obj";
|
m_World->GetComponent(m_WidgetOrigin, "Model")["Resource"] = "Models/ScaleWidgetOrigin.obj";
|
||||||
if (m_Selection != 0) {
|
if (m_Selection != 0) {
|
||||||
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
||||||
widgetTransform["Orientation"] = (glm::vec3)selectionTransform["Orientation"];
|
widgetTransform["Orientation"] = glm::eulerAngles(RenderQueueFactory::AbsoluteOrientation(m_World, m_Selection));
|
||||||
}
|
}
|
||||||
} else if (newMode == WidgetMode::Rotate) {
|
} else if (newMode == WidgetMode::Rotate) {
|
||||||
m_World->GetComponent(m_WidgetX, "Model")["Resource"] = "Models/RotationWidgetX.obj";
|
m_World->GetComponent(m_WidgetX, "Model")["Resource"] = "Models/RotationWidgetX.obj";
|
||||||
m_World->GetComponent(m_WidgetY, "Model")["Resource"] = "Models/RotationWidgetY.obj";
|
m_World->GetComponent(m_WidgetY, "Model")["Resource"] = "Models/RotationWidgetY.obj";
|
||||||
m_World->GetComponent(m_WidgetZ, "Model")["Resource"] = "Models/RotationWidgetZ.obj";
|
m_World->GetComponent(m_WidgetZ, "Model")["Resource"] = "Models/RotationWidgetZ.obj";
|
||||||
m_World->GetComponent(m_WidgetOrigin, "Model")["Visible"] = false;
|
|
||||||
if (m_Selection != 0) {
|
if (m_Selection != 0) {
|
||||||
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
||||||
if (m_WidgetSpace == WidgetSpace::Local) {
|
if (m_WidgetSpace == WidgetSpace::Local) {
|
||||||
@@ -389,37 +436,53 @@ void EditorSystem::drawUI(World* world, double dt)
|
|||||||
const std::string& field = pair.first;
|
const std::string& field = pair.first;
|
||||||
const std::string& type = pair.second;
|
const std::string& type = pair.second;
|
||||||
|
|
||||||
|
ImGui::PushID(field.c_str());
|
||||||
if (type == "Vector") {
|
if (type == "Vector") {
|
||||||
auto& val = component.Property<glm::vec3>(field);
|
auto& val = component.Property<glm::vec3>(field);
|
||||||
if (field == "Scale") {
|
if (field == "Scale") {
|
||||||
ImGui::DragFloat3(field.c_str(), glm::value_ptr(val), 0.1f, 0.f, std::numeric_limits<float>::max());
|
ImGui::DragFloat3("", glm::value_ptr(val), 0.1f, 0.f, std::numeric_limits<float>::max());
|
||||||
} else if (field == "Orientation") {
|
} else if (field == "Orientation") {
|
||||||
glm::vec3 tempVal = glm::fmod(val, glm::vec3(glm::two_pi<float>()));
|
glm::vec3 tempVal = glm::fmod(val, glm::vec3(glm::two_pi<float>()));
|
||||||
if (ImGui::SliderFloat3(field.c_str(), glm::value_ptr(tempVal), 0.f, glm::two_pi<float>())) {
|
if (ImGui::SliderFloat3("", glm::value_ptr(tempVal), 0.f, glm::two_pi<float>())) {
|
||||||
val = tempVal;
|
val = tempVal;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ImGui::DragFloat3(field.c_str(), glm::value_ptr(val), 0.1f, std::numeric_limits<float>::lowest(), std::numeric_limits<float>::max());
|
ImGui::DragFloat3("", glm::value_ptr(val), 0.1f, std::numeric_limits<float>::lowest(), std::numeric_limits<float>::max());
|
||||||
}
|
}
|
||||||
} else if (type == "Color") {
|
} else if (type == "Color") {
|
||||||
auto& val = component.Property<glm::vec4>(field);
|
auto& val = component.Property<glm::vec4>(field);
|
||||||
ImGui::ColorEdit4(field.c_str(), glm::value_ptr(val), true);
|
ImGui::ColorEdit4("", glm::value_ptr(val), true);
|
||||||
} else if (type == "string") {
|
} else if (type == "string") {
|
||||||
std::string& val = component.Property<std::string>(field);
|
std::string& val = component.Property<std::string>(field);
|
||||||
char tempString[1024];
|
char tempString[1024];
|
||||||
memcpy(tempString, val.c_str(), std::min(val.length() + 1, sizeof(tempString)));
|
memcpy(tempString, val.c_str(), std::min(val.length() + 1, sizeof(tempString)));
|
||||||
if (ImGui::InputText(field.c_str(), tempString, sizeof(tempString))) {
|
if (ImGui::InputText("", tempString, sizeof(tempString))) {
|
||||||
val = std::string(tempString);
|
val = std::string(tempString);
|
||||||
LOG_DEBUG("%s::%s changed!", componentType.c_str(), field.c_str());
|
LOG_DEBUG("%s::%s changed!", componentType.c_str(), field.c_str());
|
||||||
}
|
}
|
||||||
|
// DROP STUFF
|
||||||
|
if (ImGui::IsItemHovered() && !m_LastDroppedFile.empty()) {
|
||||||
|
val = m_LastDroppedFile;
|
||||||
|
m_LastDroppedFile = "";
|
||||||
|
}
|
||||||
|
|
||||||
} else if (type == "double") {
|
} else if (type == "double") {
|
||||||
float tempVal = static_cast<float>(component.Property<double>(field));
|
float tempVal = static_cast<float>(component.Property<double>(field));
|
||||||
if (ImGui::InputFloat(field.c_str(), &tempVal, 0.01f, 1.f)) {
|
if (ImGui::InputFloat("", &tempVal, 0.01f, 1.f)) {
|
||||||
component.SetProperty(field, static_cast<double>(tempVal));
|
component.SetProperty(field, static_cast<double>(tempVal));
|
||||||
}
|
}
|
||||||
} else if (type == "bool") {
|
} else if (type == "bool") {
|
||||||
auto& val = component.Property<bool>(field);
|
auto& val = component.Property<bool>(field);
|
||||||
ImGui::Checkbox(field.c_str(), &val);
|
ImGui::Checkbox("", &val);
|
||||||
|
} else {
|
||||||
|
ImGui::TextDisabled(type.c_str());
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text(field.c_str());
|
||||||
|
if (ImGui::IsItemHovered()) {
|
||||||
|
ImGui::SetTooltip("field annotation goes here");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user