adding plane shape and universal guizmo (this is the wrong branch)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#ifndef EDITOR_HPP
|
#ifndef EDITOR_HPP
|
||||||
#define EDITOR_HPP
|
#define EDITOR_HPP
|
||||||
|
|
||||||
|
#include <X11/X.h>
|
||||||
#include <open_engine.hpp>
|
#include <open_engine.hpp>
|
||||||
|
|
||||||
#include "open_engine/renderer/renderer3d.hpp"
|
#include "open_engine/renderer/renderer3d.hpp"
|
||||||
@@ -285,6 +286,10 @@ namespace OpenEngine {
|
|||||||
guizmo_operation = ImGuizmo::OPERATION::SCALE;
|
guizmo_operation = ImGuizmo::OPERATION::SCALE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case KeyCode::T: {
|
||||||
|
guizmo_operation = ImGuizmo::OPERATION::UNIVERSAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case KeyCode::Delete: {
|
case KeyCode::Delete: {
|
||||||
scene->MarkEntityForDeletion(selected_entity);
|
scene->MarkEntityForDeletion(selected_entity);
|
||||||
scene_hierarchy.ClearSelection();
|
scene_hierarchy.ClearSelection();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace OpenEngine {
|
|||||||
void BodyOnImGuiRender(entt::registry& registry, entt::entity entity);
|
void BodyOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||||
void SphereShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
void SphereShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||||
void BoxShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
void BoxShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||||
|
void PlaneShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EDITOR_COMPONENT_HPP
|
#endif // EDITOR_COMPONENT_HPP
|
||||||
|
|||||||
@@ -283,4 +283,16 @@ namespace OpenEngine {
|
|||||||
"%.2f",
|
"%.2f",
|
||||||
ImGuiSliderFlags_AlwaysClamp);
|
ImGuiSliderFlags_AlwaysClamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlaneShapeOnImGuiRender(entt::registry& registry, entt::entity entity)
|
||||||
|
{
|
||||||
|
auto& planed_comp = registry.get<PlaneShapeComponent>(entity);
|
||||||
|
|
||||||
|
ImGui::DragFloat("Size",
|
||||||
|
&planed_comp.extent,
|
||||||
|
0.1f,
|
||||||
|
0.01f, FLT_MAX,
|
||||||
|
"%.2f",
|
||||||
|
ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "open_engine/scene/components.hpp"
|
||||||
#include "open_engine/scene/entity.hpp"
|
#include "open_engine/scene/entity.hpp"
|
||||||
#include "editor_component.hpp"
|
#include "editor_component.hpp"
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ namespace OpenEngine {
|
|||||||
RegisterDrawer<PhysicsBodyComponent>("Physics Body", &BodyOnImGuiRender);
|
RegisterDrawer<PhysicsBodyComponent>("Physics Body", &BodyOnImGuiRender);
|
||||||
RegisterDrawer<SphereShapeComponent>("Sphere Shape", &SphereShapeOnImGuiRender);
|
RegisterDrawer<SphereShapeComponent>("Sphere Shape", &SphereShapeOnImGuiRender);
|
||||||
RegisterDrawer<BoxShapeComponent>("Box Shape", &BoxShapeOnImGuiRender);
|
RegisterDrawer<BoxShapeComponent>("Box Shape", &BoxShapeOnImGuiRender);
|
||||||
|
RegisterDrawer<PlaneShapeComponent>("Plane Shape", &PlaneShapeOnImGuiRender);
|
||||||
|
|
||||||
scene = context;
|
scene = context;
|
||||||
selected_context = {};
|
selected_context = {};
|
||||||
@@ -74,6 +76,11 @@ namespace OpenEngine {
|
|||||||
selected_context.AddComponent<BoxShapeComponent>();
|
selected_context.AddComponent<BoxShapeComponent>();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
if (!selected_context.HasComponent<PlaneShapeComponent>())
|
||||||
|
if (ImGui::MenuItem("Plane shape")) {
|
||||||
|
selected_context.AddComponent<PlaneShapeComponent>();
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityPopup(Ref<Scene>& scene)
|
void EntityPopup(Ref<Scene>& scene)
|
||||||
|
|||||||
26
imgui.ini
26
imgui.ini
@@ -1,6 +1,6 @@
|
|||||||
[Window][WindowOverViewport_11111111]
|
[Window][WindowOverViewport_11111111]
|
||||||
Pos=0,24
|
Pos=0,24
|
||||||
Size=1272,1363
|
Size=2560,1371
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
@@ -10,31 +10,31 @@ Collapsed=0
|
|||||||
|
|
||||||
[Window][Statistics]
|
[Window][Statistics]
|
||||||
Pos=0,24
|
Pos=0,24
|
||||||
Size=224,437
|
Size=224,439
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000003,0
|
DockId=0x00000003,0
|
||||||
|
|
||||||
[Window][Properties]
|
[Window][Properties]
|
||||||
Pos=822,24
|
Pos=2110,24
|
||||||
Size=450,805
|
Size=450,810
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,0
|
DockId=0x00000007,0
|
||||||
|
|
||||||
[Window][Viewport]
|
[Window][Viewport]
|
||||||
Pos=226,61
|
Pos=226,61
|
||||||
Size=594,956
|
Size=1882,964
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000012,0
|
DockId=0x00000012,0
|
||||||
|
|
||||||
[Window][Dear ImGui Demo]
|
[Window][Dear ImGui Demo]
|
||||||
Pos=822,831
|
Pos=2110,836
|
||||||
Size=450,556
|
Size=450,559
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000008,0
|
DockId=0x00000008,0
|
||||||
|
|
||||||
[Window][Scene]
|
[Window][Scene]
|
||||||
Pos=0,463
|
Pos=0,465
|
||||||
Size=224,924
|
Size=224,930
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,0
|
DockId=0x00000004,0
|
||||||
|
|
||||||
@@ -143,8 +143,8 @@ Collapsed=0
|
|||||||
DockId=0x00000012,1
|
DockId=0x00000012,1
|
||||||
|
|
||||||
[Window][Assets]
|
[Window][Assets]
|
||||||
Pos=226,1019
|
Pos=226,1027
|
||||||
Size=594,368
|
Size=1882,368
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000C,0
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
@@ -156,12 +156,12 @@ DockId=0x0000000F,0
|
|||||||
|
|
||||||
[Window][##play_state_bar]
|
[Window][##play_state_bar]
|
||||||
Pos=226,24
|
Pos=226,24
|
||||||
Size=594,35
|
Size=1882,35
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000011,0
|
DockId=0x00000011,0
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,24 Size=1272,1363 Split=X
|
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,24 Size=2560,1371 Split=X
|
||||||
DockNode ID=0x00000005 Parent=0x08BD597D SizeRef=820,1386 Split=X
|
DockNode ID=0x00000005 Parent=0x08BD597D SizeRef=820,1386 Split=X
|
||||||
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=224,1386 Split=Y Selected=0xE601B12F
|
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=224,1386 Split=Y Selected=0xE601B12F
|
||||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=255,417 Selected=0x553E127E
|
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=255,417 Selected=0x553E127E
|
||||||
|
|||||||
@@ -153,6 +153,11 @@ namespace OpenEngine {
|
|||||||
{
|
{
|
||||||
float radius = 1.0f;
|
float radius = 1.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PlaneShapeComponent
|
||||||
|
{
|
||||||
|
float extent = 1.0f;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // COMPONENTS_HPP
|
#endif // COMPONENTS_HPP
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <core/time.hpp>
|
#include <core/time.hpp>
|
||||||
|
|
||||||
#include <Jolt/Physics/Collision/Shape/Shape.h>
|
#include <Jolt/Physics/Collision/Shape/Shape.h>
|
||||||
|
#include <Jolt/Physics/Collision/Shape/PlaneShape.h>
|
||||||
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
|
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
|
||||||
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
||||||
#include <Jolt/Physics/EActivation.h>
|
#include <Jolt/Physics/EActivation.h>
|
||||||
@@ -34,8 +35,13 @@ namespace OpenEngine {
|
|||||||
auto& c = reg.get<SphereShapeComponent>(e);
|
auto& c = reg.get<SphereShapeComponent>(e);
|
||||||
return CreateRef<SphereShapeSettings>(c.radius);
|
return CreateRef<SphereShapeSettings>(c.radius);
|
||||||
}
|
}
|
||||||
|
if (reg.any_of<PlaneShapeComponent>(e)) {
|
||||||
|
auto& c = reg.get<PlaneShapeComponent>(e);
|
||||||
|
const Plane plane({ 0.0f, 1.0f, 0.0f }, 0);
|
||||||
|
return CreateRef<PlaneShapeSettings>(plane, nullptr, c.extent);
|
||||||
|
}
|
||||||
|
|
||||||
OE_CORE_ERROR("Entity has no shape component!");
|
OE_CORE_ERROR("Entity {} has no shape component!", reg.get<TagComponent>(e).tag);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -352,4 +358,9 @@ namespace OpenEngine {
|
|||||||
void Scene::OnComponentAdded<IDComponent>(Entity entity, IDComponent& component)
|
void Scene::OnComponentAdded<IDComponent>(Entity entity, IDComponent& component)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void Scene::OnComponentAdded<PlaneShapeComponent>(Entity entity, PlaneShapeComponent& component)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,6 +214,16 @@ namespace OpenEngine {
|
|||||||
out << YAML::EndMap; //SphereShapeComponent
|
out << YAML::EndMap; //SphereShapeComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entity.HasComponent<PlaneShapeComponent>()) {
|
||||||
|
out << YAML::Key << "PlaneShapeComponent";
|
||||||
|
out << YAML::BeginMap; //PlaneShapeComponent
|
||||||
|
|
||||||
|
auto& psc = entity.GetComponents<PlaneShapeComponent>();
|
||||||
|
out << YAML::Key << "Extent" << YAML::Value << psc.extent;
|
||||||
|
|
||||||
|
out << YAML::EndMap; //PlaneShapeComponent
|
||||||
|
}
|
||||||
|
|
||||||
out << YAML::EndMap;
|
out << YAML::EndMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,6 +376,13 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
ssc.radius = sphere_shape_component["Radius"].as<float>();
|
ssc.radius = sphere_shape_component["Radius"].as<float>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto plane_shape_component = entity["PlaneShapeComponent"];
|
||||||
|
if (sphere_shape_component) {
|
||||||
|
auto& psc = deserializedEntity.AddComponent<PlaneShapeComponent>();
|
||||||
|
|
||||||
|
psc.extent = plane_shape_component["Extent"].as<float>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user