mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-13 07:45:39 +07:00
collider inspectors
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../factory.hpp"
|
||||
#include "../gobject.hpp"
|
||||
#include "../inspector.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
@@ -101,6 +103,33 @@ namespace e2d
|
||||
};
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
template <>
|
||||
class component_inspector<rect_collider> final : component_inspector<> {
|
||||
public:
|
||||
static const char* title;
|
||||
|
||||
void operator()(gcomponent<rect_collider>& c) const;
|
||||
};
|
||||
|
||||
template <>
|
||||
class component_inspector<circle_collider> final : component_inspector<> {
|
||||
public:
|
||||
static const char* title;
|
||||
|
||||
void operator()(gcomponent<circle_collider>& c) const;
|
||||
};
|
||||
|
||||
template <>
|
||||
class component_inspector<polygon_collider> final : component_inspector<> {
|
||||
public:
|
||||
static const char* title;
|
||||
|
||||
void operator()(gcomponent<polygon_collider>& c) const;
|
||||
};
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
inline rect_collider& rect_collider::size(const v2f& value) noexcept {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../factory.hpp"
|
||||
#include "../gobject.hpp"
|
||||
#include "../inspector.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
@@ -16,7 +18,10 @@ namespace e2d
|
||||
public:
|
||||
rigid_body() = default;
|
||||
};
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
template <>
|
||||
class factory_loader<rigid_body> final : factory_loader<> {
|
||||
public:
|
||||
@@ -31,3 +36,14 @@ namespace e2d
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
template <>
|
||||
class component_inspector<rigid_body> final : component_inspector<> {
|
||||
public:
|
||||
static const char* title;
|
||||
|
||||
void operator()(gcomponent<rigid_body>& c) const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../factory.hpp"
|
||||
#include "../gobject.hpp"
|
||||
#include "../inspector.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
@@ -16,7 +18,10 @@ namespace e2d
|
||||
public:
|
||||
touchable() = default;
|
||||
};
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
template <>
|
||||
class factory_loader<touchable> final : factory_loader<> {
|
||||
public:
|
||||
@@ -31,3 +36,14 @@ namespace e2d
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
template <>
|
||||
class component_inspector<touchable> final : component_inspector<> {
|
||||
public:
|
||||
static const char* title;
|
||||
|
||||
void operator()(gcomponent<touchable>& c) const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "../_high_binds.hpp"
|
||||
|
||||
#include <enduro2d/high/gobject.hpp>
|
||||
#include <enduro2d/high/components/camera.hpp>
|
||||
#include <enduro2d/high/components/disabled.hpp>
|
||||
#include <enduro2d/high/components/camera.hpp>
|
||||
|
||||
namespace e2d::bindings::high
|
||||
{
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "../_high_binds.hpp"
|
||||
|
||||
#include <enduro2d/high/gobject.hpp>
|
||||
#include <enduro2d/high/components/colliders.hpp>
|
||||
#include <enduro2d/high/components/disabled.hpp>
|
||||
#include <enduro2d/high/components/colliders.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "../_high_binds.hpp"
|
||||
|
||||
#include <enduro2d/high/gobject.hpp>
|
||||
#include <enduro2d/high/components/touchable.hpp>
|
||||
#include <enduro2d/high/components/disabled.hpp>
|
||||
#include <enduro2d/high/components/touchable.hpp>
|
||||
|
||||
namespace e2d::bindings::high
|
||||
{
|
||||
|
||||
@@ -150,3 +150,78 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_inspector<rect_collider>::title = "rect_collider";
|
||||
|
||||
void component_inspector<rect_collider>::operator()(gcomponent<rect_collider>& c) const {
|
||||
if ( v2f size = c->size();
|
||||
ImGui::DragFloat2("size", size.data(), 1.f, 0.f, std::numeric_limits<f32>::max()) )
|
||||
{
|
||||
c->size(size);
|
||||
}
|
||||
|
||||
if ( v2f pivot = c->pivot();
|
||||
ImGui::DragFloat2("pivot", pivot.data(), 0.01f) )
|
||||
{
|
||||
c->pivot(pivot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_inspector<circle_collider>::title = "circle_collider";
|
||||
|
||||
void component_inspector<circle_collider>::operator()(gcomponent<circle_collider>& c) const {
|
||||
if ( f32 radius = c->radius();
|
||||
ImGui::DragFloat("radius", &radius, 1.f, 0.f, std::numeric_limits<f32>::max()) )
|
||||
{
|
||||
c->radius(radius);
|
||||
}
|
||||
|
||||
if ( v2f pivot = c->pivot();
|
||||
ImGui::DragFloat2("pivot", pivot.data(), 0.01f) )
|
||||
{
|
||||
c->pivot(pivot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_inspector<polygon_collider>::title = "polygon_collider";
|
||||
|
||||
void component_inspector<polygon_collider>::operator()(gcomponent<polygon_collider>& c) const {
|
||||
const str points_label = strings::rformat(
|
||||
"points(%0)###points",
|
||||
c->points().size());
|
||||
|
||||
if ( ImGui::TreeNode(points_label.c_str()) ) {
|
||||
E2D_DEFER([](){ ImGui::TreePop(); });
|
||||
|
||||
int count = math::numeric_cast<int>(c->points().size());
|
||||
if ( ImGui::DragInt("count", &count, 1.f, 0, std::numeric_limits<int>::max()) ) {
|
||||
c->points().resize(math::numeric_cast<std::size_t>(count));
|
||||
}
|
||||
|
||||
for ( std::size_t i = 0; i < c->points().size(); ++i ) {
|
||||
ImGui::PushID(math::numeric_cast<int>(i));
|
||||
E2D_DEFER([](){ ImGui::PopID(); });
|
||||
|
||||
if ( v2f point = c->points()[i];
|
||||
ImGui::DragFloat2("###point", point.data(), 1.f) )
|
||||
{
|
||||
c->points()[i] = point;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( v2f pivot = c->pivot();
|
||||
ImGui::DragFloat2("pivot", pivot.data(), 0.01f) )
|
||||
{
|
||||
c->pivot(pivot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,3 +32,12 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_inspector<rigid_body>::title = "rigid_body";
|
||||
|
||||
void component_inspector<rigid_body>::operator()(gcomponent<rigid_body>& c) const {
|
||||
E2D_UNUSED(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,3 +32,12 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_inspector<touchable>::title = "touchable";
|
||||
|
||||
void component_inspector<touchable>::operator()(gcomponent<touchable>& c) const {
|
||||
E2D_UNUSED(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,17 +251,22 @@ namespace e2d
|
||||
.register_component<actor>("actor")
|
||||
.register_component<behaviour>("behaviour")
|
||||
.register_component<camera>("camera")
|
||||
.register_component<rect_collider>("rect_collider")
|
||||
.register_component<circle_collider>("circle_collider")
|
||||
.register_component<polygon_collider>("polygon_collider")
|
||||
.register_component<flipbook_player>("flipbook_player")
|
||||
.register_component<label>("label")
|
||||
//.register_component<label::dirty>("label.dirty")
|
||||
.register_component<model_renderer>("model_renderer")
|
||||
.register_component<named>("named")
|
||||
.register_component<renderer>("renderer")
|
||||
.register_component<rigid_body>("rigid_body")
|
||||
.register_component<scene>("scene")
|
||||
.register_component<spine_player>("spine_player")
|
||||
//.register_component<events<spine_player_events::event>>("spine_player.events")
|
||||
//.register_component<commands<spine_player_commands::command>>("spine_player.commands")
|
||||
.register_component<sprite_renderer>("sprite_renderer");
|
||||
.register_component<sprite_renderer>("sprite_renderer")
|
||||
.register_component<touchable>("touchable");
|
||||
|
||||
safe_module_initialize<luasol>();
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
|
||||
#include <enduro2d/high/systems/input_system.hpp>
|
||||
|
||||
#include <enduro2d/high/components/colliders.hpp>
|
||||
#include <enduro2d/high/components/touchable.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace e2d;
|
||||
|
||||
@@ -22,7 +22,8 @@ namespace e2d
|
||||
internal_state() = default;
|
||||
~internal_state() noexcept = default;
|
||||
|
||||
void process(f32 dt, ecs::registry& owner) {
|
||||
void process(ecs::registry& owner) {
|
||||
E2D_UNUSED(owner);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -38,6 +39,7 @@ namespace e2d
|
||||
ecs::registry& owner,
|
||||
const ecs::after<systems::update_event>& trigger)
|
||||
{
|
||||
state_->process(trigger.event.dt, owner);
|
||||
E2D_UNUSED(trigger);
|
||||
state_->process(owner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,13 +56,17 @@ namespace
|
||||
const bool tree_node_opened =
|
||||
ImGui::TreeNodeEx(tree_node_name.c_str(), tree_node_flags);
|
||||
|
||||
E2D_DEFER([tree_node_opened](){
|
||||
if ( tree_node_opened ) {
|
||||
ImGui::TreePop();
|
||||
}
|
||||
});
|
||||
|
||||
if ( ImGui::IsItemClicked() ) {
|
||||
e.select(owner);
|
||||
}
|
||||
|
||||
if ( tree_node_opened ) {
|
||||
E2D_DEFER([](){ ImGui::TreePop(); });
|
||||
|
||||
root->for_each_child([&e, &i](const const_node_iptr& child){
|
||||
show_tree_for_node(e, i, child);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user