mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
remove physics dummy stuff
This commit is contained in:
@@ -40,7 +40,6 @@
|
||||
#include "components/model_renderer.hpp"
|
||||
#include "components/named.hpp"
|
||||
#include "components/renderer.hpp"
|
||||
#include "components/rigid_body.hpp"
|
||||
#include "components/scene.hpp"
|
||||
#include "components/spine_player.hpp"
|
||||
#include "components/sprite_renderer.hpp"
|
||||
@@ -51,7 +50,6 @@
|
||||
#include "systems/frame_system.hpp"
|
||||
#include "systems/gizmos_system.hpp"
|
||||
#include "systems/label_system.hpp"
|
||||
#include "systems/physics_system.hpp"
|
||||
#include "systems/render_system.hpp"
|
||||
#include "systems/script_system.hpp"
|
||||
#include "systems/spine_system.hpp"
|
||||
@@ -75,7 +73,6 @@
|
||||
#include "model.hpp"
|
||||
#include "node.hpp"
|
||||
#include "node.inl"
|
||||
#include "physics.hpp"
|
||||
#include "prefab.hpp"
|
||||
#include "script.hpp"
|
||||
#include "spine.hpp"
|
||||
|
||||
@@ -60,7 +60,6 @@ namespace e2d
|
||||
class model_renderer;
|
||||
class named;
|
||||
class renderer;
|
||||
class rigid_body;
|
||||
class scene;
|
||||
class spine_player;
|
||||
class sprite_renderer;
|
||||
@@ -71,7 +70,6 @@ namespace e2d
|
||||
class frame_system;
|
||||
class gizmos_system;
|
||||
class label_system;
|
||||
class physics_system;
|
||||
class render_system;
|
||||
class script_system;
|
||||
class spine_system;
|
||||
@@ -100,7 +98,6 @@ namespace e2d
|
||||
class editor;
|
||||
class inspector;
|
||||
class luasol;
|
||||
class physics;
|
||||
class starter;
|
||||
class world;
|
||||
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "_components.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
class rigid_body final {
|
||||
public:
|
||||
ENUM_HPP_CLASS_DECL(types, u8,
|
||||
(dynamic)
|
||||
(kinematic))
|
||||
|
||||
ENUM_HPP_CLASS_DECL(sleepings, u8,
|
||||
(never)
|
||||
(start_awake)
|
||||
(start_asleep))
|
||||
|
||||
ENUM_HPP_CLASS_DECL(collisions, u8,
|
||||
(discrete)
|
||||
(continuous))
|
||||
public:
|
||||
rigid_body() = default;
|
||||
|
||||
rigid_body& type(types value) noexcept;
|
||||
[[nodiscard]] types type() const noexcept;
|
||||
|
||||
rigid_body& sleeping(sleepings value) noexcept;
|
||||
[[nodiscard]] sleepings sleeping() const noexcept;
|
||||
|
||||
rigid_body& collision(collisions value) noexcept;
|
||||
[[nodiscard]] collisions collision() const noexcept;
|
||||
|
||||
rigid_body& gravity_scale(f32 value) noexcept;
|
||||
[[nodiscard]] f32 gravity_scale() const noexcept;
|
||||
|
||||
rigid_body& fixed_rotation(bool value) noexcept;
|
||||
[[nodiscard]] bool fixed_rotation() const noexcept;
|
||||
private:
|
||||
types type_ = types::dynamic;
|
||||
sleepings sleeping_ = sleepings::start_awake;
|
||||
collisions collision_ = collisions::discrete;
|
||||
f32 gravity_scale_ = 1.f;
|
||||
bool fixed_rotation_ = false;
|
||||
};
|
||||
}
|
||||
|
||||
ENUM_HPP_REGISTER_TRAITS(e2d::rigid_body::types)
|
||||
ENUM_HPP_REGISTER_TRAITS(e2d::rigid_body::sleepings)
|
||||
ENUM_HPP_REGISTER_TRAITS(e2d::rigid_body::collisions)
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
template <>
|
||||
class factory_loader<rigid_body> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
rigid_body& component,
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
inline rigid_body& rigid_body::type(types value) noexcept {
|
||||
type_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline rigid_body::types rigid_body::type() const noexcept {
|
||||
return type_;
|
||||
}
|
||||
|
||||
inline rigid_body& rigid_body::sleeping(sleepings value) noexcept {
|
||||
sleeping_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline rigid_body::sleepings rigid_body::sleeping() const noexcept {
|
||||
return sleeping_;
|
||||
}
|
||||
|
||||
inline rigid_body& rigid_body::collision(collisions value) noexcept {
|
||||
collision_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline rigid_body::collisions rigid_body::collision() const noexcept {
|
||||
return collision_;
|
||||
}
|
||||
|
||||
inline rigid_body& rigid_body::gravity_scale(f32 value) noexcept {
|
||||
gravity_scale_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline f32 rigid_body::gravity_scale() const noexcept {
|
||||
return gravity_scale_;
|
||||
}
|
||||
|
||||
inline rigid_body& rigid_body::fixed_rotation(bool value) noexcept {
|
||||
fixed_rotation_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool rigid_body::fixed_rotation() const noexcept {
|
||||
return fixed_rotation_;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "_high.hpp"
|
||||
|
||||
#include "starter.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
class physics final : public module<physics> {
|
||||
public:
|
||||
physics(starter::physics_parameters params);
|
||||
~physics() noexcept final;
|
||||
|
||||
const v2f& gravity() const noexcept;
|
||||
u32 update_framerate() const noexcept;
|
||||
u32 velocity_iterations() const noexcept;
|
||||
u32 position_iterations() const noexcept;
|
||||
private:
|
||||
starter::physics_parameters params_;
|
||||
};
|
||||
}
|
||||
@@ -20,7 +20,6 @@ namespace e2d
|
||||
using application_uptr = std::unique_ptr<application>;
|
||||
public:
|
||||
class library_parameters;
|
||||
class physics_parameters;
|
||||
class parameters;
|
||||
public:
|
||||
starter(int argc, char *argv[], const parameters& params);
|
||||
@@ -55,28 +54,6 @@ namespace e2d
|
||||
url root_{"resources://bin/library"};
|
||||
};
|
||||
|
||||
//
|
||||
// starter::physics_parameters
|
||||
//
|
||||
|
||||
class starter::physics_parameters {
|
||||
public:
|
||||
physics_parameters& gravity(const v2f& value) noexcept;
|
||||
physics_parameters& update_framerate(u32 value) noexcept;
|
||||
physics_parameters& velocity_iterations(u32 value) noexcept;
|
||||
physics_parameters& position_iterations(u32 value) noexcept;
|
||||
|
||||
const v2f& gravity() const noexcept;
|
||||
u32 update_framerate() const noexcept;
|
||||
u32 velocity_iterations() const noexcept;
|
||||
u32 position_iterations() const noexcept;
|
||||
private:
|
||||
v2f gravity_ = v2f::zero();
|
||||
u32 update_framerate_ = 50u;
|
||||
u32 velocity_iterations_ = 6u;
|
||||
u32 position_iterations_ = 2u;
|
||||
};
|
||||
|
||||
//
|
||||
// starter::parameters
|
||||
//
|
||||
@@ -88,19 +65,15 @@ namespace e2d
|
||||
|
||||
parameters& engine_params(engine::parameters value) noexcept;
|
||||
parameters& library_params(library_parameters value) noexcept;
|
||||
parameters& physics_params(physics_parameters value) noexcept;
|
||||
|
||||
engine::parameters& engine_params() noexcept;
|
||||
library_parameters& library_params() noexcept;
|
||||
physics_parameters& physics_params() noexcept;
|
||||
|
||||
const engine::parameters& engine_params() const noexcept;
|
||||
const library_parameters& library_params() const noexcept;
|
||||
const physics_parameters& physics_params() const noexcept;
|
||||
private:
|
||||
engine::parameters engine_params_;
|
||||
library_parameters library_params_;
|
||||
physics_parameters physics_params_;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "_systems.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
class physics_system final
|
||||
: public ecs::system<ecs::after<systems::update_event>> {
|
||||
public:
|
||||
physics_system();
|
||||
~physics_system() noexcept final;
|
||||
|
||||
void process(
|
||||
ecs::registry& owner,
|
||||
const ecs::after<systems::update_event>& trigger) override;
|
||||
private:
|
||||
class internal_state;
|
||||
std::unique_ptr<internal_state> state_;
|
||||
};
|
||||
}
|
||||
@@ -48,9 +48,6 @@
|
||||
"script" : "../scripts/sample_08/ship.lua"
|
||||
},
|
||||
"touchable" : {},
|
||||
"rigid_body" : {
|
||||
"type" : "dynamic"
|
||||
},
|
||||
"circle_collider" : {
|
||||
"offset" : [10,15],
|
||||
"radius" : 33
|
||||
@@ -71,9 +68,6 @@
|
||||
"script" : "../scripts/sample_08/ship.lua"
|
||||
},
|
||||
"touchable" : {},
|
||||
"rigid_body" : {
|
||||
"type" : "dynamic"
|
||||
},
|
||||
"circle_collider" : {
|
||||
"offset" : [10,15],
|
||||
"radius" : 33
|
||||
@@ -95,9 +89,6 @@
|
||||
"script" : "../scripts/sample_08/ship.lua"
|
||||
},
|
||||
"touchable" : {},
|
||||
"rigid_body" : {
|
||||
"type" : "dynamic"
|
||||
},
|
||||
"rect_collider" : {
|
||||
"size" : [66,113]
|
||||
},
|
||||
@@ -120,9 +111,6 @@
|
||||
"actor" : {
|
||||
"translation" : [0,-240]
|
||||
},
|
||||
"rigid_body" : {
|
||||
"type" : "kinematic"
|
||||
},
|
||||
"rect_collider" : {
|
||||
"size" : [320, 50]
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
---@class rigid_body
|
||||
local rigid_body = {
|
||||
---@type boolean
|
||||
enabled = true,
|
||||
|
||||
---@type boolean
|
||||
disabled = false
|
||||
}
|
||||
|
||||
---@overload fun(self: rigid_body)
|
||||
---@param self rigid_body
|
||||
function rigid_body.enable(self) end
|
||||
|
||||
---@overload fun(self: rigid_body)
|
||||
---@param self rigid_body
|
||||
function rigid_body.disable(self) end
|
||||
|
||||
---@type rigid_body
|
||||
_G.rigid_body = _G.rigid_body or rigid_body
|
||||
@@ -39,9 +39,6 @@ local gobject = {
|
||||
---@type renderer
|
||||
renderer = nil,
|
||||
|
||||
---@type rigid_body
|
||||
rigid_body = nil,
|
||||
|
||||
---@type scene
|
||||
scene = nil,
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
---@class physics
|
||||
local physics = {
|
||||
}
|
||||
|
||||
---@type physics
|
||||
_G.the_physics = _G.the_physics or physics
|
||||
@@ -13,7 +13,6 @@ namespace e2d::bindings::high
|
||||
void bind_editor(sol::state& l);
|
||||
void bind_library(sol::state& l);
|
||||
void bind_luasol(sol::state& l);
|
||||
void bind_physics(sol::state& l);
|
||||
void bind_world(sol::state& l);
|
||||
|
||||
void bind_node(sol::state& l);
|
||||
@@ -28,7 +27,6 @@ namespace e2d::bindings::high
|
||||
void bind_model_renderer(sol::state& l);
|
||||
void bind_named(sol::state& l);
|
||||
void bind_renderer(sol::state& l);
|
||||
void bind_rigid_body(sol::state& l);
|
||||
void bind_scene(sol::state& l);
|
||||
void bind_spine_player(sol::state& l);
|
||||
void bind_sprite_renderer(sol::state& l);
|
||||
@@ -41,7 +39,6 @@ namespace e2d::bindings
|
||||
high::bind_editor(l);
|
||||
high::bind_library(l);
|
||||
high::bind_luasol(l);
|
||||
high::bind_physics(l);
|
||||
high::bind_world(l);
|
||||
|
||||
high::bind_node(l);
|
||||
@@ -56,7 +53,6 @@ namespace e2d::bindings
|
||||
high::bind_model_renderer(l);
|
||||
high::bind_named(l);
|
||||
high::bind_renderer(l);
|
||||
high::bind_rigid_body(l);
|
||||
high::bind_scene(l);
|
||||
high::bind_spine_player(l);
|
||||
high::bind_sprite_renderer(l);
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include "../_high_binds.hpp"
|
||||
|
||||
#include <enduro2d/high/gobject.hpp>
|
||||
#include <enduro2d/high/components/disabled.hpp>
|
||||
#include <enduro2d/high/components/rigid_body.hpp>
|
||||
|
||||
namespace e2d::bindings::high
|
||||
{
|
||||
void bind_rigid_body(sol::state& l) {
|
||||
l.new_usertype<gcomponent<rigid_body>>("rigid_body",
|
||||
sol::no_constructor,
|
||||
|
||||
"enable", [](gcomponent<rigid_body>& c){
|
||||
c.owner().component<disabled<rigid_body>>().remove();
|
||||
},
|
||||
|
||||
"disable", [](gcomponent<rigid_body>& c){
|
||||
c.owner().component<disabled<rigid_body>>().ensure();
|
||||
},
|
||||
|
||||
"enabled", sol::property(
|
||||
[](const gcomponent<rigid_body>& c) -> bool {
|
||||
return !c.owner().component<disabled<rigid_body>>().exists();
|
||||
},
|
||||
[](gcomponent<rigid_body>& c, bool yesno){
|
||||
if ( yesno ) {
|
||||
c.owner().component<disabled<rigid_body>>().remove();
|
||||
} else {
|
||||
c.owner().component<disabled<rigid_body>>().ensure();
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
"disabled", sol::property(
|
||||
[](const gcomponent<rigid_body>& c) -> bool {
|
||||
return c.owner().component<disabled<rigid_body>>().exists();
|
||||
},
|
||||
[](gcomponent<rigid_body>& c, bool yesno){
|
||||
if ( yesno ) {
|
||||
c.owner().component<disabled<rigid_body>>().ensure();
|
||||
} else {
|
||||
c.owner().component<disabled<rigid_body>>().remove();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <enduro2d/high/components/model_renderer.hpp>
|
||||
#include <enduro2d/high/components/named.hpp>
|
||||
#include <enduro2d/high/components/renderer.hpp>
|
||||
#include <enduro2d/high/components/rigid_body.hpp>
|
||||
#include <enduro2d/high/components/scene.hpp>
|
||||
#include <enduro2d/high/components/spine_player.hpp>
|
||||
#include <enduro2d/high/components/sprite_renderer.hpp>
|
||||
@@ -52,7 +51,6 @@ namespace e2d::bindings::high
|
||||
"model_renderer", sol::property([](gobject& go){ return component_wrapper<model_renderer>{go}; }),
|
||||
"named", sol::property([](gobject& go){ return component_wrapper<named>{go}; }),
|
||||
"renderer", sol::property([](gobject& go){ return component_wrapper<renderer>{go}; }),
|
||||
"rigid_body", sol::property([](gobject& go){ return component_wrapper<rigid_body>{go}; }),
|
||||
"scene", sol::property([](gobject& go){ return component_wrapper<scene>{go}; }),
|
||||
"spine_player", sol::property([](gobject& go){ return component_wrapper<spine_player>{go}; }),
|
||||
"sprite_renderer", sol::property([](gobject& go){ return component_wrapper<sprite_renderer>{go}; }),
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include "_high_binds.hpp"
|
||||
|
||||
#include <enduro2d/high/physics.hpp>
|
||||
|
||||
namespace e2d::bindings::high
|
||||
{
|
||||
void bind_physics(sol::state& l) {
|
||||
l.new_usertype<physics>("physics",
|
||||
sol::no_constructor
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/high/components/rigid_body.hpp>
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* factory_loader<rigid_body>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
"properties" : {
|
||||
"type" : { "$ref": "#/definitions/types" },
|
||||
"sleeping" : { "$ref": "#/definitions/sleepings" },
|
||||
"collision" : { "$ref": "#/definitions/collisions" },
|
||||
"gravity_scale" : { "type" : "number" },
|
||||
"fixed_rotation" : { "type" : "boolean" }
|
||||
},
|
||||
"definitions" : {
|
||||
"types" : {
|
||||
"type" : "string",
|
||||
"enum" : [
|
||||
"dynamic",
|
||||
"kinematic"
|
||||
]
|
||||
},
|
||||
"sleepings" : {
|
||||
"type" : "string",
|
||||
"enum" : [
|
||||
"never",
|
||||
"start_awake",
|
||||
"start_asleep"
|
||||
]
|
||||
},
|
||||
"collisions" : {
|
||||
"type" : "string",
|
||||
"enum" : [
|
||||
"discrete",
|
||||
"continuous"
|
||||
]
|
||||
}
|
||||
}
|
||||
})json";
|
||||
|
||||
bool factory_loader<rigid_body>::operator()(
|
||||
rigid_body& component,
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("type") ) {
|
||||
rigid_body::types type = component.type();
|
||||
if ( !json_utils::try_parse_value(ctx.root["type"], type) ) {
|
||||
the<debug>().error("RIGID_BODY: Incorrect formatting of 'type' property");
|
||||
return false;
|
||||
}
|
||||
component.type(type);
|
||||
}
|
||||
|
||||
if ( ctx.root.HasMember("sleeping") ) {
|
||||
rigid_body::sleepings sleeping = component.sleeping();
|
||||
if ( !json_utils::try_parse_value(ctx.root["sleeping"], sleeping) ) {
|
||||
the<debug>().error("RIGID_BODY: Incorrect formatting of 'sleeping' property");
|
||||
return false;
|
||||
}
|
||||
component.sleeping(sleeping);
|
||||
}
|
||||
|
||||
if ( ctx.root.HasMember("collision") ) {
|
||||
rigid_body::collisions collision = component.collision();
|
||||
if ( !json_utils::try_parse_value(ctx.root["collision"], collision) ) {
|
||||
the<debug>().error("RIGID_BODY: Incorrect formatting of 'collision' property");
|
||||
return false;
|
||||
}
|
||||
component.collision(collision);
|
||||
}
|
||||
|
||||
if ( ctx.root.HasMember("gravity_scale") ) {
|
||||
f32 gravity_scale = component.gravity_scale();
|
||||
if ( !json_utils::try_parse_value(ctx.root["gravity_scale"], gravity_scale) ) {
|
||||
the<debug>().error("RIGID_BODY: Incorrect formatting of 'gravity_scale' property");
|
||||
return false;
|
||||
}
|
||||
component.gravity_scale(gravity_scale);
|
||||
}
|
||||
|
||||
if ( ctx.root.HasMember("fixed_rotation") ) {
|
||||
bool fixed_rotation = component.fixed_rotation();
|
||||
if ( !json_utils::try_parse_value(ctx.root["fixed_rotation"], fixed_rotation) ) {
|
||||
the<debug>().error("RIGID_BODY: Incorrect formatting of 'fixed_rotation' property");
|
||||
return false;
|
||||
}
|
||||
component.fixed_rotation(fixed_rotation);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool factory_loader<rigid_body>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(dependencies, ctx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_inspector<rigid_body>::title = ICON_FA_WEIGHT_HANGING " rigid_body";
|
||||
|
||||
void component_inspector<rigid_body>::operator()(gcomponent<rigid_body>& c) const {
|
||||
if ( rigid_body::types type = c->type();
|
||||
imgui_utils::show_enum_combo_box("type", &type) )
|
||||
{
|
||||
c->type(type);
|
||||
}
|
||||
|
||||
if ( rigid_body::sleepings sleeping = c->sleeping();
|
||||
imgui_utils::show_enum_combo_box("sleeping", &sleeping) )
|
||||
{
|
||||
c->sleeping(sleeping);
|
||||
}
|
||||
|
||||
if ( rigid_body::collisions collision = c->collision();
|
||||
imgui_utils::show_enum_combo_box("collision", &collision) )
|
||||
{
|
||||
c->collision(collision);
|
||||
}
|
||||
|
||||
if ( f32 gravity_scale = c->gravity_scale();
|
||||
ImGui::DragFloat("gravity_scale", &gravity_scale, 0.01f) )
|
||||
{
|
||||
c->gravity_scale(gravity_scale);
|
||||
}
|
||||
|
||||
if ( bool fixed_rotation = c->fixed_rotation();
|
||||
ImGui::Checkbox("fixed_rotation", &fixed_rotation) )
|
||||
{
|
||||
c->fixed_rotation(fixed_rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/high/physics.hpp>
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
physics::physics(starter::physics_parameters params)
|
||||
: params_(std::move(params)) {}
|
||||
|
||||
physics::~physics() noexcept = default;
|
||||
|
||||
const v2f& physics::gravity() const noexcept {
|
||||
return params_.gravity();
|
||||
}
|
||||
|
||||
u32 physics::update_framerate() const noexcept {
|
||||
return params_.update_framerate();
|
||||
}
|
||||
|
||||
u32 physics::velocity_iterations() const noexcept {
|
||||
return params_.velocity_iterations();
|
||||
}
|
||||
|
||||
u32 physics::position_iterations() const noexcept {
|
||||
return params_.position_iterations();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <enduro2d/high/inspector.hpp>
|
||||
#include <enduro2d/high/library.hpp>
|
||||
#include <enduro2d/high/luasol.hpp>
|
||||
#include <enduro2d/high/physics.hpp>
|
||||
#include <enduro2d/high/world.hpp>
|
||||
|
||||
#include <enduro2d/high/components/actor.hpp>
|
||||
@@ -26,7 +25,6 @@
|
||||
#include <enduro2d/high/components/model_renderer.hpp>
|
||||
#include <enduro2d/high/components/named.hpp>
|
||||
#include <enduro2d/high/components/renderer.hpp>
|
||||
#include <enduro2d/high/components/rigid_body.hpp>
|
||||
#include <enduro2d/high/components/scene.hpp>
|
||||
#include <enduro2d/high/components/spine_player.hpp>
|
||||
#include <enduro2d/high/components/sprite_renderer.hpp>
|
||||
@@ -37,7 +35,6 @@
|
||||
#include <enduro2d/high/systems/frame_system.hpp>
|
||||
#include <enduro2d/high/systems/gizmos_system.hpp>
|
||||
#include <enduro2d/high/systems/label_system.hpp>
|
||||
#include <enduro2d/high/systems/physics_system.hpp>
|
||||
#include <enduro2d/high/systems/render_system.hpp>
|
||||
#include <enduro2d/high/systems/script_system.hpp>
|
||||
#include <enduro2d/high/systems/spine_system.hpp>
|
||||
@@ -72,8 +69,6 @@ namespace
|
||||
.add_system<gizmos_system>())
|
||||
.feature<struct label_feature>(ecs::feature()
|
||||
.add_system<label_system>())
|
||||
.feature<struct physics_feature>(ecs::feature()
|
||||
.add_system<physics_system>())
|
||||
.feature<struct render_feature>(ecs::feature()
|
||||
.add_system<render_system>())
|
||||
.feature<struct script_feature>(ecs::feature()
|
||||
@@ -144,46 +139,6 @@ namespace e2d
|
||||
return root_;
|
||||
}
|
||||
|
||||
//
|
||||
// starter::physics_parameters
|
||||
//
|
||||
|
||||
starter::physics_parameters& starter::physics_parameters::gravity(const v2f& value) noexcept {
|
||||
gravity_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
starter::physics_parameters& starter::physics_parameters::update_framerate(u32 value) noexcept {
|
||||
update_framerate_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
starter::physics_parameters& starter::physics_parameters::velocity_iterations(u32 value) noexcept {
|
||||
velocity_iterations_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
starter::physics_parameters& starter::physics_parameters::position_iterations(u32 value) noexcept {
|
||||
position_iterations_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const v2f& starter::physics_parameters::gravity() const noexcept {
|
||||
return gravity_;
|
||||
}
|
||||
|
||||
u32 starter::physics_parameters::update_framerate() const noexcept {
|
||||
return update_framerate_;
|
||||
}
|
||||
|
||||
u32 starter::physics_parameters::velocity_iterations() const noexcept {
|
||||
return velocity_iterations_;
|
||||
}
|
||||
|
||||
u32 starter::physics_parameters::position_iterations() const noexcept {
|
||||
return position_iterations_;
|
||||
}
|
||||
|
||||
//
|
||||
// starter::parameters
|
||||
//
|
||||
@@ -201,11 +156,6 @@ namespace e2d
|
||||
return *this;
|
||||
}
|
||||
|
||||
starter::parameters& starter::parameters::physics_params(physics_parameters value) noexcept {
|
||||
physics_params_ = std::move(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
engine::parameters& starter::parameters::engine_params() noexcept {
|
||||
return engine_params_;
|
||||
}
|
||||
@@ -214,10 +164,6 @@ namespace e2d
|
||||
return library_params_;
|
||||
}
|
||||
|
||||
starter::physics_parameters& starter::parameters::physics_params() noexcept {
|
||||
return physics_params_;
|
||||
}
|
||||
|
||||
const engine::parameters& starter::parameters::engine_params() const noexcept {
|
||||
return engine_params_;
|
||||
}
|
||||
@@ -226,10 +172,6 @@ namespace e2d
|
||||
return library_params_;
|
||||
}
|
||||
|
||||
const starter::physics_parameters& starter::parameters::physics_params() const noexcept {
|
||||
return physics_params_;
|
||||
}
|
||||
|
||||
//
|
||||
// starter
|
||||
//
|
||||
@@ -254,7 +196,6 @@ namespace e2d
|
||||
.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")
|
||||
@@ -279,7 +220,6 @@ namespace e2d
|
||||
.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")
|
||||
@@ -294,9 +234,6 @@ namespace e2d
|
||||
safe_module_initialize<library>(
|
||||
params.library_params());
|
||||
|
||||
safe_module_initialize<physics>(
|
||||
params.physics_params());
|
||||
|
||||
safe_module_initialize<world>();
|
||||
safe_module_initialize<editor>();
|
||||
}
|
||||
@@ -306,7 +243,6 @@ namespace e2d
|
||||
|
||||
modules::shutdown<editor>();
|
||||
modules::shutdown<world>();
|
||||
modules::shutdown<physics>();
|
||||
modules::shutdown<library>();
|
||||
modules::shutdown<luasol>();
|
||||
modules::shutdown<inspector>();
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/high/systems/physics_system.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace e2d;
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
//
|
||||
// physics_system::internal_state
|
||||
//
|
||||
|
||||
class physics_system::internal_state final : private noncopyable {
|
||||
public:
|
||||
internal_state() = default;
|
||||
~internal_state() noexcept = default;
|
||||
|
||||
void process_update(ecs::registry& owner) {
|
||||
E2D_UNUSED(owner);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// physics_system
|
||||
//
|
||||
|
||||
physics_system::physics_system()
|
||||
: state_(new internal_state()) {}
|
||||
physics_system::~physics_system() noexcept = default;
|
||||
|
||||
void physics_system::process(
|
||||
ecs::registry& owner,
|
||||
const ecs::after<systems::update_event>& trigger)
|
||||
{
|
||||
E2D_UNUSED(trigger);
|
||||
E2D_PROFILER_SCOPE("physics_system.process_update");
|
||||
state_->process_update(owner);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <enduro2d/high/editor.hpp>
|
||||
#include <enduro2d/high/library.hpp>
|
||||
#include <enduro2d/high/luasol.hpp>
|
||||
#include <enduro2d/high/physics.hpp>
|
||||
#include <enduro2d/high/world.hpp>
|
||||
|
||||
#include <enduro2d/high/components/actor.hpp>
|
||||
@@ -37,7 +36,6 @@ namespace
|
||||
s["the_editor"] = &the<editor>();
|
||||
s["the_library"] = &the<library>();
|
||||
s["the_luasol"] = &the<luasol>();
|
||||
s["the_physics"] = &the<physics>();
|
||||
s["the_world"] = &the<world>();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"components" : {
|
||||
"rigid_body" : {},
|
||||
"touchable" : {},
|
||||
|
||||
"rect_collider" : {
|
||||
|
||||
@@ -250,7 +250,6 @@ TEST_CASE("library"){
|
||||
ecs::registry w;
|
||||
ecs::entity e = w.create_entity(prefab_res->content().prototype());
|
||||
|
||||
REQUIRE(e.exists_component<rigid_body>());
|
||||
REQUIRE(e.exists_component<touchable>());
|
||||
|
||||
REQUIRE(e.exists_component<rect_collider>());
|
||||
|
||||
Reference in New Issue
Block a user