Compare commits
3 Commits
2d3fe57d5a
...
48d2905695
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48d2905695 | ||
|
|
af7b7d2bfa | ||
|
|
44f766863d |
@@ -1,6 +1,7 @@
|
||||
#ifndef EDITOR_HPP
|
||||
#define EDITOR_HPP
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <open_engine.hpp>
|
||||
|
||||
#include "open_engine/renderer/renderer3d.hpp"
|
||||
@@ -285,6 +286,10 @@ namespace OpenEngine {
|
||||
guizmo_operation = ImGuizmo::OPERATION::SCALE;
|
||||
break;
|
||||
}
|
||||
case KeyCode::T: {
|
||||
guizmo_operation = ImGuizmo::OPERATION::UNIVERSAL;
|
||||
break;
|
||||
}
|
||||
case KeyCode::Delete: {
|
||||
scene->MarkEntityForDeletion(selected_entity);
|
||||
scene_hierarchy.ClearSelection();
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace OpenEngine {
|
||||
void BodyOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||
void SphereShapeOnImGuiRender(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
|
||||
|
||||
@@ -283,4 +283,16 @@ namespace OpenEngine {
|
||||
"%.2f",
|
||||
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 "editor_component.hpp"
|
||||
|
||||
@@ -26,6 +27,7 @@ namespace OpenEngine {
|
||||
RegisterDrawer<PhysicsBodyComponent>("Physics Body", &BodyOnImGuiRender);
|
||||
RegisterDrawer<SphereShapeComponent>("Sphere Shape", &SphereShapeOnImGuiRender);
|
||||
RegisterDrawer<BoxShapeComponent>("Box Shape", &BoxShapeOnImGuiRender);
|
||||
RegisterDrawer<PlaneShapeComponent>("Plane Shape", &PlaneShapeOnImGuiRender);
|
||||
|
||||
scene = context;
|
||||
selected_context = {};
|
||||
@@ -74,6 +76,11 @@ namespace OpenEngine {
|
||||
selected_context.AddComponent<BoxShapeComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
if (!selected_context.HasComponent<PlaneShapeComponent>())
|
||||
if (ImGui::MenuItem("Plane shape")) {
|
||||
selected_context.AddComponent<PlaneShapeComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
void EntityPopup(Ref<Scene>& scene)
|
||||
|
||||
26
imgui.ini
26
imgui.ini
@@ -1,6 +1,6 @@
|
||||
[Window][WindowOverViewport_11111111]
|
||||
Pos=0,24
|
||||
Size=1272,1363
|
||||
Size=2560,1371
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug##Default]
|
||||
@@ -10,31 +10,31 @@ Collapsed=0
|
||||
|
||||
[Window][Statistics]
|
||||
Pos=0,24
|
||||
Size=224,437
|
||||
Size=224,439
|
||||
Collapsed=0
|
||||
DockId=0x00000003,0
|
||||
|
||||
[Window][Properties]
|
||||
Pos=822,24
|
||||
Size=450,805
|
||||
Pos=2110,24
|
||||
Size=450,810
|
||||
Collapsed=0
|
||||
DockId=0x00000007,0
|
||||
|
||||
[Window][Viewport]
|
||||
Pos=226,61
|
||||
Size=594,956
|
||||
Size=1882,964
|
||||
Collapsed=0
|
||||
DockId=0x00000012,0
|
||||
|
||||
[Window][Dear ImGui Demo]
|
||||
Pos=822,831
|
||||
Size=450,556
|
||||
Pos=2110,836
|
||||
Size=450,559
|
||||
Collapsed=0
|
||||
DockId=0x00000008,0
|
||||
|
||||
[Window][Scene]
|
||||
Pos=0,463
|
||||
Size=224,924
|
||||
Pos=0,465
|
||||
Size=224,930
|
||||
Collapsed=0
|
||||
DockId=0x00000004,0
|
||||
|
||||
@@ -143,8 +143,8 @@ Collapsed=0
|
||||
DockId=0x00000012,1
|
||||
|
||||
[Window][Assets]
|
||||
Pos=226,1019
|
||||
Size=594,368
|
||||
Pos=226,1027
|
||||
Size=1882,368
|
||||
Collapsed=0
|
||||
DockId=0x0000000C,0
|
||||
|
||||
@@ -156,12 +156,12 @@ DockId=0x0000000F,0
|
||||
|
||||
[Window][##play_state_bar]
|
||||
Pos=226,24
|
||||
Size=594,35
|
||||
Size=1882,35
|
||||
Collapsed=0
|
||||
DockId=0x00000011,0
|
||||
|
||||
[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=0x00000001 Parent=0x00000005 SizeRef=224,1386 Split=Y Selected=0xE601B12F
|
||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=255,417 Selected=0x553E127E
|
||||
|
||||
@@ -153,6 +153,11 @@ namespace OpenEngine {
|
||||
{
|
||||
float radius = 1.0f;
|
||||
};
|
||||
|
||||
struct PlaneShapeComponent
|
||||
{
|
||||
float extent = 1.0f;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // COMPONENTS_HPP
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <core/time.hpp>
|
||||
|
||||
#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/SphereShape.h>
|
||||
#include <Jolt/Physics/EActivation.h>
|
||||
@@ -34,8 +35,13 @@ namespace OpenEngine {
|
||||
auto& c = reg.get<SphereShapeComponent>(e);
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -352,4 +358,9 @@ namespace OpenEngine {
|
||||
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
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -366,6 +376,13 @@ namespace OpenEngine {
|
||||
|
||||
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