From 2fd59b77adf03d2d879fd2edfd80dea8a7159da7 Mon Sep 17 00:00:00 2001 From: Karsten Bock Date: Mon, 31 Oct 2022 13:36:23 +0100 Subject: [PATCH 01/36] Update compatibility for 4.0 beta3 (35cfaafda8073f700c9d2fe42a43d3d81eaaea67) --- README.md | 2 +- modules/bullet_physics/components_gizmos.cpp | 96 +++++++++---------- .../godot/components/transform_component.cpp | 12 +-- .../components_mesh_gizmo_3d.cpp | 2 +- .../components_transform_gizmo_3d.cpp | 2 +- .../godot/editor_plugins/editor_world_ecs.cpp | 43 ++++++++- .../godot/editor_plugins/editor_world_ecs.h | 1 + modules/godot/nodes/ecs_world.cpp | 4 +- modules/godot/nodes/ecs_world.h | 2 +- 9 files changed, 99 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 565fc4c4..a1613e6c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Godex is a Godot Engine ecs library. **Disclaimer:** this module is still in development, open an [issues](https://github.com/GodotECS/godex/issues) to report any problem or a new [discussion](https://github.com/GodotECS/godex/discussions) if you need any help. Any form of contribution is welcome. ### The tested Godot version -Is `master` `35cfaafda8073f700c9d2fe42a43d3d81eaaea67`, please open an issue if the current master is not working or doesn't compile. +Is `master` `01ae26d31befb6679ecd92cd3c73aa5a76162e95`, please open an issue if the current master is not working or doesn't compile. ### What is ECS Shortened as ECS, the Entity Component System is an architectural design pattern that allow to organize the data in a way so that the workload can be split into small and easy programs. diff --git a/modules/bullet_physics/components_gizmos.cpp b/modules/bullet_physics/components_gizmos.cpp index f9aad4e6..d86eb9e2 100644 --- a/modules/bullet_physics/components_gizmos.cpp +++ b/modules/bullet_physics/components_gizmos.cpp @@ -18,7 +18,7 @@ void BtBoxGizmo::init() { } void BtBoxGizmo::redraw(EditorNode3DGizmo *p_gizmo) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); if (entity->has_component(box_component_name)) { @@ -55,7 +55,7 @@ void BtBoxGizmo::redraw(EditorNode3DGizmo *p_gizmo) { } int BtBoxGizmo::get_handle_count(const EditorNode3DGizmo *p_gizmo) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, 0); if (entity->has_component(box_component_name)) { @@ -76,7 +76,7 @@ String BtBoxGizmo::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) } Variant BtBoxGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, Variant()); ERR_FAIL_COND_V(entity->has_component(box_component_name) == false, Variant()); @@ -86,7 +86,7 @@ Variant BtBoxGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_idx } void BtBoxGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(box_component_name) == false); @@ -118,7 +118,7 @@ void BtBoxGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Camera3 } void BtBoxGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(box_component_name) == false); @@ -127,7 +127,7 @@ void BtBoxGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, cons if (p_cancel) { entity->set_component_value(box_component_name, half_extents_name, p_restore); } else { - UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Shape Box Half Extent")); ur->add_do_method(entity, "set_component_value", box_component_name, half_extents_name, half_extents); Vector3 restore = half_extents; @@ -143,7 +143,7 @@ void BtSphereGizmo::init() { } void BtSphereGizmo::redraw(EditorNode3DGizmo *p_gizmo) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); if (entity->has_component(sphere_component_name)) { @@ -156,8 +156,8 @@ void BtSphereGizmo::redraw(EditorNode3DGizmo *p_gizmo) { Vector points; for (int i = 0; i <= 360; i++) { - float ra = Math::deg2rad((float)i); - float rb = Math::deg2rad((float)i + 1); + float ra = Math::deg_to_rad((float)i); + float rb = Math::deg_to_rad((float)i + 1); Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius; @@ -194,7 +194,7 @@ void BtSphereGizmo::redraw(EditorNode3DGizmo *p_gizmo) { } int BtSphereGizmo::get_handle_count(const EditorNode3DGizmo *p_gizmo) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, 0); if (entity->has_component(sphere_component_name)) { @@ -209,7 +209,7 @@ String BtSphereGizmo::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id } Variant BtSphereGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, Variant()); ERR_FAIL_COND_V(entity->has_component(sphere_component_name) == false, Variant()); @@ -217,7 +217,7 @@ Variant BtSphereGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_ } void BtSphereGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(sphere_component_name) == false); @@ -244,7 +244,7 @@ void BtSphereGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Came } void BtSphereGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(sphere_component_name) == false); @@ -253,7 +253,7 @@ void BtSphereGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, c if (p_cancel) { entity->set_component_value(sphere_component_name, radius_name, p_restore); } else { - UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Shape Sphere Radius")); ur->add_do_method(entity, "set_component_value", sphere_component_name, radius_name, radius); ur->add_undo_method(entity, "set_component_value", sphere_component_name, radius_name, p_restore); @@ -267,7 +267,7 @@ void BtCapsuleGizmo::init() { } void BtCapsuleGizmo::redraw(EditorNode3DGizmo *p_gizmo) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); if (entity->has_component(capsule_component_name)) { @@ -282,8 +282,8 @@ void BtCapsuleGizmo::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 d(0, height * 0.5, 0); for (int i = 0; i < 360; i++) { - float ra = Math::deg2rad((float)i); - float rb = Math::deg2rad((float)i + 1); + float ra = Math::deg_to_rad((float)i); + float rb = Math::deg_to_rad((float)i + 1); Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius; @@ -345,7 +345,7 @@ void BtCapsuleGizmo::redraw(EditorNode3DGizmo *p_gizmo) { } int BtCapsuleGizmo::get_handle_count(const EditorNode3DGizmo *p_gizmo) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, 0); if (entity->has_component(capsule_component_name)) { @@ -364,7 +364,7 @@ String BtCapsuleGizmo::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_i } Variant BtCapsuleGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, Variant()); ERR_FAIL_COND_V(entity->has_component(capsule_component_name) == false, Variant()); @@ -376,7 +376,7 @@ Variant BtCapsuleGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p } void BtCapsuleGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(capsule_component_name) == false); @@ -414,7 +414,7 @@ void BtCapsuleGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Cam } void BtCapsuleGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(capsule_component_name) == false); @@ -423,7 +423,7 @@ void BtCapsuleGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, if (p_cancel) { entity->set_component_value(capsule_component_name, p_idx == 0 ? radius_name : height_name, p_restore); } else { - UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Shape Capsule Radius")); ur->add_do_method(entity, "set_component_value", capsule_component_name, p_idx == 0 ? radius_name : height_name, v); ur->add_undo_method(entity, "set_component_value", capsule_component_name, p_idx == 0 ? radius_name : height_name, p_restore); @@ -437,7 +437,7 @@ void BtConeGizmo::init() { } void BtConeGizmo::redraw(EditorNode3DGizmo *p_gizmo) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); if (entity->has_component(cone_component_name)) { @@ -452,8 +452,8 @@ void BtConeGizmo::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 d(0, height * 0.5, 0); for (int i = 0; i < 360; i++) { - float ra = Math::deg2rad((float)i); - float rb = Math::deg2rad((float)i + 1); + float ra = Math::deg_to_rad((float)i); + float rb = Math::deg_to_rad((float)i + 1); Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius; @@ -495,7 +495,7 @@ void BtConeGizmo::redraw(EditorNode3DGizmo *p_gizmo) { } int BtConeGizmo::get_handle_count(const EditorNode3DGizmo *p_gizmo) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, 0); if (entity->has_component(cone_component_name)) { @@ -514,7 +514,7 @@ String BtConeGizmo::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) } Variant BtConeGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, Variant()); ERR_FAIL_COND_V(entity->has_component(cone_component_name) == false, Variant()); @@ -526,7 +526,7 @@ Variant BtConeGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id } void BtConeGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(cone_component_name) == false); @@ -560,7 +560,7 @@ void BtConeGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Camera } void BtConeGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(cone_component_name) == false); @@ -569,7 +569,7 @@ void BtConeGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, con if (p_cancel) { entity->set_component_value(cone_component_name, p_idx == 0 ? radius_name : height_name, p_restore); } else { - UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Shape Cone Radius")); ur->add_do_method(entity, "set_component_value", cone_component_name, p_idx == 0 ? radius_name : height_name, v); ur->add_undo_method(entity, "set_component_value", cone_component_name, p_idx == 0 ? radius_name : height_name, p_restore); @@ -583,7 +583,7 @@ void BtCylinderGizmo::init() { } void BtCylinderGizmo::redraw(EditorNode3DGizmo *p_gizmo) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); if (entity->has_component(cylinder_component_name)) { @@ -598,8 +598,8 @@ void BtCylinderGizmo::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 d(0, height * 0.5, 0); for (int i = 0; i < 360; i++) { - float ra = Math::deg2rad((float)i); - float rb = Math::deg2rad((float)i + 1); + float ra = Math::deg_to_rad((float)i); + float rb = Math::deg_to_rad((float)i + 1); Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius; @@ -659,7 +659,7 @@ void BtCylinderGizmo::redraw(EditorNode3DGizmo *p_gizmo) { } int BtCylinderGizmo::get_handle_count(const EditorNode3DGizmo *p_gizmo) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, 0); if (entity->has_component(cylinder_component_name)) { @@ -678,7 +678,7 @@ String BtCylinderGizmo::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_ } Variant BtCylinderGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, Variant()); ERR_FAIL_COND_V(entity->has_component(cylinder_component_name) == false, Variant()); @@ -690,7 +690,7 @@ Variant BtCylinderGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int } void BtCylinderGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(cylinder_component_name) == false); @@ -723,7 +723,7 @@ void BtCylinderGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Ca } void BtCylinderGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(cylinder_component_name) == false); @@ -732,7 +732,7 @@ void BtCylinderGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, if (p_cancel) { entity->set_component_value(cylinder_component_name, p_idx == 0 ? radius_name : height_name, p_restore); } else { - UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Shape Capsule Radius")); ur->add_do_method(entity, "set_component_value", cylinder_component_name, p_idx == 0 ? radius_name : height_name, v); ur->add_undo_method(entity, "set_component_value", cylinder_component_name, p_idx == 0 ? radius_name : height_name, p_restore); @@ -752,7 +752,7 @@ void BtConvexGizmo::init() { } void BtConvexGizmo::redraw(EditorNode3DGizmo *p_gizmo) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); if (entity->has_component(convex_component_name)) { @@ -804,7 +804,7 @@ void BtTrimeshGizmo::init() { } void BtTrimeshGizmo::redraw(EditorNode3DGizmo *p_gizmo) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); if (entity->has_component(trimesh_component_name)) { @@ -859,7 +859,7 @@ void BtPawnGizmo::init() { } void BtPawnGizmo::redraw(EditorNode3DGizmo *p_gizmo) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); if (entity->has_component(pawn_component_name)) { @@ -904,8 +904,8 @@ void BtPawnGizmo::redraw_capsule(EditorNode3DGizmo *p_gizmo, const Ref Vector3 d(0, p_height * 0.5, 0); for (int i = 0; i < 360; i++) { - float ra = Math::deg2rad((float)i); - float rb = Math::deg2rad((float)i + 1); + float ra = Math::deg_to_rad((float)i); + float rb = Math::deg_to_rad((float)i + 1); Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * p_radius; Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * p_radius; @@ -967,7 +967,7 @@ void BtPawnGizmo::redraw_capsule(EditorNode3DGizmo *p_gizmo, const Ref } int BtPawnGizmo::get_handle_count(const EditorNode3DGizmo *p_gizmo) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, 0); if (entity->has_component(pawn_component_name)) { @@ -990,7 +990,7 @@ String BtPawnGizmo::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) } Variant BtPawnGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND_V(entity == nullptr, Variant()); ERR_FAIL_COND_V(entity->has_component(pawn_component_name) == false, Variant()); @@ -1006,7 +1006,7 @@ Variant BtPawnGizmo::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id } void BtPawnGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(pawn_component_name) == false); @@ -1059,7 +1059,7 @@ void BtPawnGizmo::set_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, Camera } void BtPawnGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); ERR_FAIL_COND(entity == nullptr); ERR_FAIL_COND(entity->has_component(pawn_component_name) == false); @@ -1079,7 +1079,7 @@ void BtPawnGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, con if (p_cancel) { entity->set_component_value(pawn_component_name, prop_name, p_restore); } else { - UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Shape Capsule Radius")); ur->add_do_method(entity, "set_component_value", pawn_component_name, prop_name, v); ur->add_undo_method(entity, "set_component_value", pawn_component_name, prop_name, p_restore); diff --git a/modules/godot/components/transform_component.cpp b/modules/godot/components/transform_component.cpp index e80000df..26b14999 100644 --- a/modules/godot/components/transform_component.cpp +++ b/modules/godot/components/transform_component.cpp @@ -38,17 +38,17 @@ const Vector3 TransformComponent::get_rotation() const { void TransformComponent::set_rotation_deg(const Vector3 &p_euler) { set_rotation(Vector3( - Math::deg2rad(p_euler[0]), - Math::deg2rad(p_euler[1]), - Math::deg2rad(p_euler[2]))); + Math::deg_to_rad(p_euler[0]), + Math::deg_to_rad(p_euler[1]), + Math::deg_to_rad(p_euler[2]))); } const Vector3 TransformComponent::get_rotation_deg() const { const Vector3 r = get_rotation(); return Vector3( - Math::rad2deg(r[0]), - Math::rad2deg(r[1]), - Math::rad2deg(r[2])); + Math::rad_to_deg(r[0]), + Math::rad_to_deg(r[1]), + Math::rad_to_deg(r[2])); } void TransformComponent::set_scale(const Vector3 &p_scale) { diff --git a/modules/godot/editor_plugins/components_mesh_gizmo_3d.cpp b/modules/godot/editor_plugins/components_mesh_gizmo_3d.cpp index 7f512dc7..2e1cbf6c 100644 --- a/modules/godot/editor_plugins/components_mesh_gizmo_3d.cpp +++ b/modules/godot/editor_plugins/components_mesh_gizmo_3d.cpp @@ -28,7 +28,7 @@ void MeshComponentGizmo::init() {} void MeshComponentGizmo::redraw(EditorNode3DGizmo *p_gizmo) { #ifdef TOOLS_ENABLED - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); RID scenario = entity->get_world_3d()->get_scenario(); Ref component_data = entity->get_component_depot(SNAME("MeshComponent")); diff --git a/modules/godot/editor_plugins/components_transform_gizmo_3d.cpp b/modules/godot/editor_plugins/components_transform_gizmo_3d.cpp index 1d12a7a0..026e251f 100644 --- a/modules/godot/editor_plugins/components_transform_gizmo_3d.cpp +++ b/modules/godot/editor_plugins/components_transform_gizmo_3d.cpp @@ -16,7 +16,7 @@ void TransformComponentGizmo::init() { } void TransformComponentGizmo::redraw(EditorNode3DGizmo *p_gizmo) { - Entity3D *entity = static_cast(p_gizmo->get_spatial_node()); + Entity3D *entity = static_cast(p_gizmo->get_node_3d()); if (entity->has_component(transform_component_name) == false) { // Nothing to do. diff --git a/modules/godot/editor_plugins/editor_world_ecs.cpp b/modules/godot/editor_plugins/editor_world_ecs.cpp index 9af61dde..f02c4cdd 100644 --- a/modules/godot/editor_plugins/editor_world_ecs.cpp +++ b/modules/godot/editor_plugins/editor_world_ecs.cpp @@ -1275,10 +1275,43 @@ void EditorWorldECS::add_warning(const String &p_msg) { errors_warnings_container->add_child(lbl); } +void EditorWorldECS::remove_node_and_reparent_children(Node *p_node) { + Node *new_owner = p_node->get_owner(); + + List children; + + while (true) { + bool clear = true; + for (int i = 0; i < p_node->get_child_count(false); i++) { + Node* c_node = p_node->get_child(i, false); + if (!c_node->get_owner()) { + continue; + } + + p_node->remove_child(c_node); + children.push_back(c_node); + clear = false; + break; + } + + if (clear) { + break; + } + } + + while (!children.is_empty()) { + Node *c_node = children.front()->get(); + p_node->get_parent()->add_child(c_node); + children.pop_front(); + } + + p_node->get_parent()->remove_child(p_node); +} + void EditorWorldECS::clear_errors_warnings() { for (int i = errors_warnings_container->get_child_count() - 1; i >= 0; i -= 1) { Node *n = errors_warnings_container->get_child(i); - errors_warnings_container->get_child(i)->remove_and_skip(); + remove_node_and_reparent_children(n); memdelete(n); } } @@ -1304,7 +1337,7 @@ PipelineElementInfoBox *EditorWorldECS::pipeline_panel_add_entry() { void EditorWorldECS::pipeline_panel_clear() { for (int i = pipeline_panel->get_child_count() - 1; i >= 0; i -= 1) { Node *n = pipeline_panel->get_child(i); - pipeline_panel->get_child(i)->remove_and_skip(); + remove_node_and_reparent_children(n); memdelete(n); } } @@ -1318,7 +1351,7 @@ DispatcherPipelineView *EditorWorldECS::pipeline_view_add_dispatcher() { void EditorWorldECS::pipeline_view_clear() { for (int i = pipeline_view_panel->get_child_count() - 1; i >= 0; i -= 1) { Node *n = pipeline_view_panel->get_child(i); - pipeline_view_panel->get_child(i)->remove_and_skip(); + remove_node_and_reparent_children(n); memdelete(n); } } @@ -1326,12 +1359,12 @@ void EditorWorldECS::pipeline_view_clear() { WorldECSEditorPlugin::WorldECSEditorPlugin(EditorNode *p_node) : editor(p_node) { ecs_editor = memnew(EditorWorldECS(p_node)); - editor->get_main_control()->add_child(ecs_editor); + editor->get_main_screen_control()->add_child(ecs_editor); ecs_editor->hide_editor(); } WorldECSEditorPlugin::~WorldECSEditorPlugin() { - editor->get_main_control()->remove_child(ecs_editor); + editor->get_main_screen_control()->remove_child(ecs_editor); memdelete(ecs_editor); ecs_editor = nullptr; } diff --git a/modules/godot/editor_plugins/editor_world_ecs.h b/modules/godot/editor_plugins/editor_world_ecs.h index 5fabde60..061af5bf 100644 --- a/modules/godot/editor_plugins/editor_world_ecs.h +++ b/modules/godot/editor_plugins/editor_world_ecs.h @@ -204,6 +204,7 @@ class EditorWorldECS : public PanelContainer { DispatcherPipelineView *pipeline_view_add_dispatcher(); void pipeline_view_clear(); + static void remove_node_and_reparent_children(Node *p_node); }; class WorldECSEditorPlugin : public EditorPlugin { diff --git a/modules/godot/nodes/ecs_world.cpp b/modules/godot/nodes/ecs_world.cpp index 8a2ad428..e0ed01e2 100644 --- a/modules/godot/nodes/ecs_world.cpp +++ b/modules/godot/nodes/ecs_world.cpp @@ -414,8 +414,8 @@ World *WorldECS::get_world() const { return world; } -TypedArray WorldECS::get_configuration_warnings() const { - TypedArray warnings = Node::get_configuration_warnings(); +PackedStringArray WorldECS::get_configuration_warnings() const { + Vector warnings = Node::get_configuration_warnings(); if (!is_inside_tree()) { return warnings; diff --git a/modules/godot/nodes/ecs_world.h b/modules/godot/nodes/ecs_world.h index 172baad6..f7fe36b7 100644 --- a/modules/godot/nodes/ecs_world.h +++ b/modules/godot/nodes/ecs_world.h @@ -122,7 +122,7 @@ class WorldECS : public Node { /// `ECS::get_singleton()->get_commands()` World *get_world() const; - virtual TypedArray get_configuration_warnings() const override; + virtual PackedStringArray get_configuration_warnings() const override; void set_pipelines(Vector> p_pipelines); const Vector> &get_pipelines() const; From c5bba890e6905c2f495723eeaf4d8ef73ecb9996 Mon Sep 17 00:00:00 2001 From: Karsten Bock Date: Thu, 3 Nov 2022 12:36:41 +0100 Subject: [PATCH 02/36] Update compatibility to 889868cbbc8beac74d5f49f9b7ef41efc4ae7d5a --- README.md | 2 +- modules/bullet_physics/components_gizmos.cpp | 16 +++--- modules/bullet_physics/debug_utilities.cpp | 4 +- .../godot/editor_plugins/editor_world_ecs.cpp | 55 ++++++++++--------- .../editor_plugins/entity_editor_plugin.cpp | 37 +++++++------ 5 files changed, 58 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index a1613e6c..e128a113 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Godex is a Godot Engine ecs library. **Disclaimer:** this module is still in development, open an [issues](https://github.com/GodotECS/godex/issues) to report any problem or a new [discussion](https://github.com/GodotECS/godex/discussions) if you need any help. Any form of contribution is welcome. ### The tested Godot version -Is `master` `01ae26d31befb6679ecd92cd3c73aa5a76162e95`, please open an issue if the current master is not working or doesn't compile. +Is `master` `889868cbbc8beac74d5f49f9b7ef41efc4ae7d5a`, please open an issue if the current master is not working or doesn't compile. ### What is ECS Shortened as ECS, the Entity Component System is an architectural design pattern that allow to organize the data in a way so that the workload can be split into small and easy programs. diff --git a/modules/bullet_physics/components_gizmos.cpp b/modules/bullet_physics/components_gizmos.cpp index d86eb9e2..d9788f4b 100644 --- a/modules/bullet_physics/components_gizmos.cpp +++ b/modules/bullet_physics/components_gizmos.cpp @@ -1,10 +1,10 @@ #include "components_gizmos.h" -#include "../godot/nodes/entity.h" #include "debug_utilities.h" #include "editor/editor_settings.h" #include "editor/plugins/node_3d_editor_plugin.h" -#include "scene/3d/camera_3d.h" +#include "editor/editor_node.h" +#include "editor/editor_undo_redo_manager.h" void BtBoxGizmo::init() { const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); @@ -127,7 +127,7 @@ void BtBoxGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, cons if (p_cancel) { entity->set_component_value(box_component_name, half_extents_name, p_restore); } else { - Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Change Shape Box Half Extent")); ur->add_do_method(entity, "set_component_value", box_component_name, half_extents_name, half_extents); Vector3 restore = half_extents; @@ -253,7 +253,7 @@ void BtSphereGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, c if (p_cancel) { entity->set_component_value(sphere_component_name, radius_name, p_restore); } else { - Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Change Shape Sphere Radius")); ur->add_do_method(entity, "set_component_value", sphere_component_name, radius_name, radius); ur->add_undo_method(entity, "set_component_value", sphere_component_name, radius_name, p_restore); @@ -423,7 +423,7 @@ void BtCapsuleGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, if (p_cancel) { entity->set_component_value(capsule_component_name, p_idx == 0 ? radius_name : height_name, p_restore); } else { - Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Change Shape Capsule Radius")); ur->add_do_method(entity, "set_component_value", capsule_component_name, p_idx == 0 ? radius_name : height_name, v); ur->add_undo_method(entity, "set_component_value", capsule_component_name, p_idx == 0 ? radius_name : height_name, p_restore); @@ -569,7 +569,7 @@ void BtConeGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, con if (p_cancel) { entity->set_component_value(cone_component_name, p_idx == 0 ? radius_name : height_name, p_restore); } else { - Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Change Shape Cone Radius")); ur->add_do_method(entity, "set_component_value", cone_component_name, p_idx == 0 ? radius_name : height_name, v); ur->add_undo_method(entity, "set_component_value", cone_component_name, p_idx == 0 ? radius_name : height_name, p_restore); @@ -732,7 +732,7 @@ void BtCylinderGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, if (p_cancel) { entity->set_component_value(cylinder_component_name, p_idx == 0 ? radius_name : height_name, p_restore); } else { - Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Change Shape Capsule Radius")); ur->add_do_method(entity, "set_component_value", cylinder_component_name, p_idx == 0 ? radius_name : height_name, v); ur->add_undo_method(entity, "set_component_value", cylinder_component_name, p_idx == 0 ? radius_name : height_name, p_restore); @@ -1079,7 +1079,7 @@ void BtPawnGizmo::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_idx, con if (p_cancel) { entity->set_component_value(pawn_component_name, prop_name, p_restore); } else { - Ref ur = Node3DEditor::get_singleton()->get_undo_redo(); + Ref ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Change Shape Capsule Radius")); ur->add_do_method(entity, "set_component_value", pawn_component_name, prop_name, v); ur->add_undo_method(entity, "set_component_value", pawn_component_name, prop_name, p_restore); diff --git a/modules/bullet_physics/debug_utilities.cpp b/modules/bullet_physics/debug_utilities.cpp index 477755f3..6ba43a38 100644 --- a/modules/bullet_physics/debug_utilities.cpp +++ b/modules/bullet_physics/debug_utilities.cpp @@ -66,8 +66,8 @@ Ref generate_mesh_from_points(const Vector &p_points) { if (err == OK) { lines.resize(md.edges.size() * 2); for (int i = 0; i < md.edges.size(); i++) { - lines.write[i * 2 + 0] = md.vertices[md.edges[i].a]; - lines.write[i * 2 + 1] = md.vertices[md.edges[i].b]; + lines.write[i * 2 + 0] = md.vertices[md.edges[i].vertex_a]; + lines.write[i * 2 + 1] = md.vertices[md.edges[i].vertex_b]; } } } diff --git a/modules/godot/editor_plugins/editor_world_ecs.cpp b/modules/godot/editor_plugins/editor_world_ecs.cpp index f02c4cdd..17461d7d 100644 --- a/modules/godot/editor_plugins/editor_world_ecs.cpp +++ b/modules/godot/editor_plugins/editor_world_ecs.cpp @@ -11,6 +11,7 @@ #include "scene/gui/color_rect.h" #include "scene/gui/reference_rect.h" #include "scene/gui/separator.h" +#include "editor/editor_undo_redo_manager.h" PipelineElementInfoBox::PipelineElementInfoBox(EditorNode *p_editor, EditorWorldECS *p_editor_world_ecs) : editor(p_editor), @@ -841,10 +842,10 @@ void EditorWorldECS::pipeline_change_name(const String &p_name) { return; } - editor->get_undo_redo()->create_action(TTR("Change pipeline name")); - editor->get_undo_redo()->add_do_method(pipeline.ptr(), SNAME("set_pipeline_name"), p_name); - editor->get_undo_redo()->add_undo_method(pipeline.ptr(), SNAME("set_pipeline_name"), pipeline->get_pipeline_name()); - editor->get_undo_redo()->commit_action(); + EditorNode::get_undo_redo()->create_action(TTR("Change pipeline name")); + EditorNode::get_undo_redo()->add_do_method(pipeline.ptr(), SNAME("set_pipeline_name"), p_name); + EditorNode::get_undo_redo()->add_undo_method(pipeline.ptr(), SNAME("set_pipeline_name"), pipeline->get_pipeline_name()); + EditorNode::get_undo_redo()->commit_action(); } void EditorWorldECS::pipeline_list_update() { @@ -914,10 +915,10 @@ void EditorWorldECS::pipeline_add() { pip->set_pipeline_name(name); set_pipeline(pip); - editor->get_undo_redo()->create_action(TTR("Add pipeline")); - editor->get_undo_redo()->add_do_method(world_ecs, SNAME("add_pipeline"), pip); - editor->get_undo_redo()->add_undo_method(world_ecs, SNAME("remove_pipeline"), pip); - editor->get_undo_redo()->commit_action(); + EditorNode::get_undo_redo()->create_action(TTR("Add pipeline")); + EditorNode::get_undo_redo()->add_do_method(world_ecs, SNAME("add_pipeline"), pip); + EditorNode::get_undo_redo()->add_undo_method(world_ecs, SNAME("remove_pipeline"), pip); + EditorNode::get_undo_redo()->commit_action(); } void EditorWorldECS::pipeline_rename_show_window() { @@ -937,10 +938,10 @@ void EditorWorldECS::pipeline_remove() { return; } - editor->get_undo_redo()->create_action(TTR("Pipeline remove")); - editor->get_undo_redo()->add_do_method(world_ecs, SNAME("remove_pipeline"), pipeline); - editor->get_undo_redo()->add_undo_method(world_ecs, SNAME("add_pipeline"), pipeline); - editor->get_undo_redo()->commit_action(); + EditorNode::get_undo_redo()->create_action(TTR("Pipeline remove")); + EditorNode::get_undo_redo()->add_do_method(world_ecs, SNAME("remove_pipeline"), pipeline); + EditorNode::get_undo_redo()->add_undo_method(world_ecs, SNAME("add_pipeline"), pipeline); + EditorNode::get_undo_redo()->commit_action(); } void EditorWorldECS::pipeline_toggle_pipeline_view() { @@ -1092,10 +1093,10 @@ void EditorWorldECS::pipeline_system_bundle_remove(const StringName &p_name) { return; } - editor->get_undo_redo()->create_action(TTR("Remove system")); - editor->get_undo_redo()->add_do_method(pipeline.ptr(), SNAME("remove_system_bundle"), p_name); - editor->get_undo_redo()->add_undo_method(pipeline.ptr(), SNAME("add_system_bundle"), p_name); - editor->get_undo_redo()->commit_action(); + EditorNode::get_undo_redo()->create_action(TTR("Remove system")); + EditorNode::get_undo_redo()->add_do_method(pipeline.ptr(), SNAME("remove_system_bundle"), p_name); + EditorNode::get_undo_redo()->add_undo_method(pipeline.ptr(), SNAME("add_system_bundle"), p_name); + EditorNode::get_undo_redo()->commit_action(); } void EditorWorldECS::pipeline_system_remove(const StringName &p_name) { @@ -1103,10 +1104,10 @@ void EditorWorldECS::pipeline_system_remove(const StringName &p_name) { return; } - editor->get_undo_redo()->create_action(TTR("Remove system")); - editor->get_undo_redo()->add_do_method(pipeline.ptr(), SNAME("remove_system"), p_name); - editor->get_undo_redo()->add_undo_method(pipeline.ptr(), SNAME("insert_system"), p_name); - editor->get_undo_redo()->commit_action(); + EditorNode::get_undo_redo()->create_action(TTR("Remove system")); + EditorNode::get_undo_redo()->add_do_method(pipeline.ptr(), SNAME("remove_system"), p_name); + EditorNode::get_undo_redo()->add_undo_method(pipeline.ptr(), SNAME("insert_system"), p_name); + EditorNode::get_undo_redo()->commit_action(); } void EditorWorldECS::add_sys_show() { @@ -1238,15 +1239,15 @@ void EditorWorldECS::add_sys_add() { } if (selected->has_meta("system_name")) { - editor->get_undo_redo()->create_action(TTR("Add system")); - editor->get_undo_redo()->add_do_method(pipeline.ptr(), SNAME("insert_system"), selected->get_meta("system_name")); - editor->get_undo_redo()->add_undo_method(pipeline.ptr(), SNAME("remove_system"), selected->get_meta("system_name")); + EditorNode::get_undo_redo()->create_action(TTR("Add system")); + EditorNode::get_undo_redo()->add_do_method(pipeline.ptr(), SNAME("insert_system"), selected->get_meta("system_name")); + EditorNode::get_undo_redo()->add_undo_method(pipeline.ptr(), SNAME("remove_system"), selected->get_meta("system_name")); } else { - editor->get_undo_redo()->create_action(TTR("Add system bundle")); - editor->get_undo_redo()->add_do_method(pipeline.ptr(), SNAME("add_system_bundle"), selected->get_meta("system_bundle_name")); - editor->get_undo_redo()->add_undo_method(pipeline.ptr(), SNAME("remove_system_bundle"), selected->get_meta("system_bundle_name")); + EditorNode::get_undo_redo()->create_action(TTR("Add system bundle")); + EditorNode::get_undo_redo()->add_do_method(pipeline.ptr(), SNAME("add_system_bundle"), selected->get_meta("system_bundle_name")); + EditorNode::get_undo_redo()->add_undo_method(pipeline.ptr(), SNAME("remove_system_bundle"), selected->get_meta("system_bundle_name")); } - editor->get_undo_redo()->commit_action(); + EditorNode::get_undo_redo()->commit_action(); } void EditorWorldECS::components_manage_show() { diff --git a/modules/godot/editor_plugins/entity_editor_plugin.cpp b/modules/godot/editor_plugins/entity_editor_plugin.cpp index b70fd2af..2fc31725 100644 --- a/modules/godot/editor_plugins/entity_editor_plugin.cpp +++ b/modules/godot/editor_plugins/entity_editor_plugin.cpp @@ -4,6 +4,7 @@ #include "core/io/marshalls.h" #include "editor/editor_properties.h" #include "editor/editor_properties_array_dict.h" +#include "editor/editor_undo_redo_manager.h" void EntityEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("update_editors"), &EntityEditor::update_editors); @@ -67,7 +68,7 @@ void EntityEditor::update_editors() { if (components_section) { // Remove old childs. for (int i = components_section->get_vbox()->get_child_count() - 1; i >= 0; i -= 1) { - components_section->get_vbox()->get_child(i)->queue_delete(); // TODO is this enough to also destroy the internally created things? + components_section->get_vbox()->get_child(i)->queue_free(); // TODO is this enough to also destroy the internally created things? } components_properties.clear(); @@ -660,21 +661,21 @@ void EntityEditor::_add_component_pressed(uint32_t p_index) { component_name = add_component_menu->get_popup()->get_item_text(p_index); } - editor->get_undo_redo()->create_action(TTR("Add component")); - editor->get_undo_redo()->add_do_method(entity, SNAME("add_component"), component_name); - editor->get_undo_redo()->add_do_method(this, SNAME("update_editors")); - editor->get_undo_redo()->add_undo_method(entity, SNAME("remove_component"), component_name); - editor->get_undo_redo()->add_undo_method(this, SNAME("update_editors")); - editor->get_undo_redo()->commit_action(); + EditorNode::get_undo_redo()->create_action(TTR("Add component")); + EditorNode::get_undo_redo()->add_do_method(entity, SNAME("add_component"), component_name); + EditorNode::get_undo_redo()->add_do_method(this, SNAME("update_editors")); + EditorNode::get_undo_redo()->add_undo_method(entity, SNAME("remove_component"), component_name); + EditorNode::get_undo_redo()->add_undo_method(this, SNAME("update_editors")); + EditorNode::get_undo_redo()->commit_action(); } void EntityEditor::_remove_component_pressed(StringName p_component_name) { - editor->get_undo_redo()->create_action(TTR("Drop component")); - editor->get_undo_redo()->add_do_method(entity, SNAME("remove_component"), p_component_name); - editor->get_undo_redo()->add_do_method(this, SNAME("update_editors")); - editor->get_undo_redo()->add_undo_method(entity, SNAME("add_component"), p_component_name, entity_get_component_props_data(p_component_name)); - editor->get_undo_redo()->add_undo_method(this, SNAME("update_editors")); - editor->get_undo_redo()->commit_action(); + EditorNode::get_undo_redo()->create_action(TTR("Drop component")); + EditorNode::get_undo_redo()->add_do_method(entity, SNAME("remove_component"), p_component_name); + EditorNode::get_undo_redo()->add_do_method(this, SNAME("update_editors")); + EditorNode::get_undo_redo()->add_undo_method(entity, SNAME("add_component"), p_component_name, entity_get_component_props_data(p_component_name)); + EditorNode::get_undo_redo()->add_undo_method(this, SNAME("update_editors")); + EditorNode::get_undo_redo()->commit_action(); } void EntityEditor::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) { @@ -683,11 +684,11 @@ void EntityEditor::_property_changed(const String &p_path, const Variant &p_valu return; } - editor->get_undo_redo()->create_action(TTR("Set component value")); - editor->get_undo_redo()->add_do_method(entity, SNAME("set"), p_path, p_value); - editor->get_undo_redo()->add_undo_method(entity, SNAME("set"), p_path, entity->get(p_path)); - editor->get_undo_redo()->add_undo_method(this, SNAME("update_editors")); - editor->get_undo_redo()->commit_action(); + EditorNode::get_undo_redo()->create_action(TTR("Set component value")); + EditorNode::get_undo_redo()->add_do_method(entity, SNAME("set"), p_path, p_value); + EditorNode::get_undo_redo()->add_undo_method(entity, SNAME("set"), p_path, entity->get(p_path)); + EditorNode::get_undo_redo()->add_undo_method(this, SNAME("update_editors")); + EditorNode::get_undo_redo()->commit_action(); if (p_value.get_type() != Variant::STRING) { // This is needed because string update is special: If string is updated From b99963af22317837cf0e397ce32383b4cff6ad56 Mon Sep 17 00:00:00 2001 From: Karsten Bock Date: Thu, 3 Nov 2022 20:36:40 +0100 Subject: [PATCH 03/36] Ignore script name when checking properties --- ecs.cpp | 3 +++ modules/godot/nodes/ecs_utilities.cpp | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/ecs.cpp b/ecs.cpp index 9c75da92..d1bfcda5 100644 --- a/ecs.cpp +++ b/ecs.cpp @@ -1070,6 +1070,9 @@ uint32_t ECS::register_or_update_script_component( // Validate and initialize the parameters. for (uint32_t i = 0; i < p_properties.size(); i += 1) { + if (p_properties[i].property.name == p_name) { + continue ; + } // Is type supported? switch (p_properties[i].property.type) { case Variant::NIL: diff --git a/modules/godot/nodes/ecs_utilities.cpp b/modules/godot/nodes/ecs_utilities.cpp index 7816ca53..ac87e28c 100644 --- a/modules/godot/nodes/ecs_utilities.cpp +++ b/modules/godot/nodes/ecs_utilities.cpp @@ -143,6 +143,12 @@ String System::validate_script(Ref