Editor version 1

This commit is contained in:
2015-12-13 20:06:21 +01:00
parent 5f3c234819
commit 2f3843e595
9 changed files with 275 additions and 16 deletions
+4
View File
@@ -21,10 +21,14 @@ public:
ComponentWrapper AttachComponent(EntityID entity, std::string componentType);
// Get a component of an entity
ComponentWrapper GetComponent(EntityID entity, std::string componentType);
// Delete a component off an entity
void DeleteComponent(EntityID entity, std::string componentType);
// Get all components of the specified type
const ComponentPool* GetComponents(std::string componentType);
// Get entity parent
EntityID GetParent(EntityID entity);
// Get all component pools
const std::unordered_map<std::string, ComponentPool*>& GetComponentPools() const { return m_ComponentPools; }
private:
EntityID m_CurrentEntityID = 1;
+18 -3
View File
@@ -1,11 +1,26 @@
#include <imgui/imgui.h>
#include "../Core/System.h"
#include "../Core/EMousePress.h"
#include "../Rendering/EPicking.h"
class EditorSystem : public ImpureSystem
{
public:
EditorSystem(EventBroker* eventBroker)
: ImpureSystem(eventBroker)
{ }
EditorSystem(EventBroker* eventBroker);
virtual void Update(World* world, double dt) override;
private:
std::vector<glm::vec2> m_PickingQueue;
EntityID m_Widget = 0;
EntityID m_Selection = 0;
EntityID m_LastSelection = 0;
EventRelay<EditorSystem, Events::MousePress> m_EMousePress;
bool OnMousePress(const Events::MousePress& e);
EventRelay<EditorSystem, Events::Picking> m_EPicking;
bool OnPicking(const Events::Picking& e);
void drawUI(World* world, double dt);
bool createDeleteButton(std::string componentType);
};
@@ -1,3 +1,4 @@
#include <imgui/imgui.h>
#include "../Input/FirstPersonInputController.h"
template <typename EventContext>
@@ -15,20 +16,31 @@ public:
{
if (e.Command == "PrimaryFire") {
if (e.Value > 0) {
LockMouse();
if (!ImGui::IsMouseHoveringAnyWindow()) {
LockMouse();
}
} else {
UnlockMouse();
}
return false;
}
if (e.Command == "Right") {
float value = std::max(-1.f, std::min(e.Value, 1.f));
m_Velocity.x = value;
}
if (e.Command == "Forward") {
float value = std::max(-1.f, std::min(e.Value, 1.f));
m_Velocity.z = -value;
if (m_MouseLocked || e.Value == 0) {
if (e.Command == "Right") {
float value = std::max(-1.f, std::min(e.Value, 1.f));
m_Velocity.x = value;
}
if (e.Command == "Forward") {
float value = std::max(-1.f, std::min(e.Value, 1.f));
m_Velocity.z = -value;
}
if (e.Command == "Sprint") {
if (e.Value > 0.f) {
m_Speed = m_BaseSpeed * 2.f * (e.Value);
} else {
m_Speed = m_BaseSpeed;
}
}
}
return FirstPersonInputController::OnCommand(e);
@@ -37,12 +49,13 @@ public:
void Update(double dt)
{
if (glm::length2(m_Velocity) > 0) {
m_Position += m_Orientation * (glm::normalize(m_Velocity) * m_BaseSpeed);
m_Position += m_Orientation * (glm::normalize(m_Velocity) * m_Speed * (float)dt);
}
}
protected:
glm::vec3 m_Position = glm::vec3(0, 0, 0);
glm::vec3 m_Velocity = glm::vec3(0, 0, 0);
float m_BaseSpeed = 0.1f;
float m_BaseSpeed = 2.0f;
float m_Speed = m_BaseSpeed;
};
+1 -1
View File
@@ -46,7 +46,7 @@ public:
if (it != PickingColorsToEntity->end()) {
pickData.Entity = it->second;
} else {
pickData.Entity = -1;
pickData.Entity = 0;
}
pickData.Position = ScreenCoords::ToWorldPos(screenCoord.x, Resolution.Width - screenCoord.y, data.Depth, Resolution, ProjectionMatrix, ViewMatrix);