From d95760ac9e27fbc09372b8cba60052ae9f9bea4d Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 18 Mar 2022 00:54:25 +0100 Subject: [PATCH] Cleanups to voxelman. --- modules/voxelman/defines.h | 89 -------------- modules/voxelman/register_types.cpp | 2 +- modules/voxelman/register_types.h | 3 - modules/voxelman/world/voxel_structure.cpp | 8 -- modules/voxelman/world/voxel_structure.h | 13 -- modules/voxelman/world/voxel_world.cpp | 112 ------------------ modules/voxelman/world/voxel_world.h | 38 ++---- modules/voxelman/world/voxel_world_editor.cpp | 93 +-------------- modules/voxelman/world/voxel_world_editor.h | 17 --- 9 files changed, 10 insertions(+), 365 deletions(-) diff --git a/modules/voxelman/defines.h b/modules/voxelman/defines.h index e465d40cc..978ef8c1a 100644 --- a/modules/voxelman/defines.h +++ b/modules/voxelman/defines.h @@ -2,32 +2,6 @@ #ifndef VOXEL_DEFINES_H #define VOXEL_DEFINES_H -#include "core/version.h" - -#if VERSION_MAJOR >= 4 -#define GODOT4 true -#endif - -//includes -#if GODOT4 -#define core_input_h "core/input/input_event.h" -#define spatial_editor_plugin_h "editor/plugins/node_3d_editor_plugin.h" -#define camera_h "scene/3d/camera_3d.h" -#define spatial_h "scene/3d/node_3d.h" -#define navigation_h "scene/3d/node_3d.h" -#define Navigation3D Node3D -#define light_h "scene/3d/light_3d.h" -#define visual_server_h "servers/rendering_server.h" -#define mesh_instance_h "scene/3d/mesh_instance_3d.h" -#define pool_vector_h "core/templates/vector.h" -#define physics_server_h "servers/physics_server_3d.h" -#define immediate_geometry_h "scene/3d/immediate_geometry_3d.h" -#define include_pool_vector \ - template \ - class Vector; \ - template \ - using PoolVector = Vector; -#else #define core_input_h "core/os/input.h" #define spatial_editor_plugin_h "editor/plugins/spatial_editor_plugin.h" #define camera_h "scene/3d/camera.h" @@ -40,57 +14,6 @@ #define physics_server_h "servers/physics_server.h" #define immediate_geometry_h "scene/3d/immediate_geometry.h" #define include_pool_vector -#endif - -//Type Defines -#if GODOT4 -#define PhysicsDirectSpaceState PhysicsDirectSpaceState3D -#define SpatialEditor Node3DEditor -#define SpatialEditorPlugin Node3DEditorPlugin -#define SpatialEditorViewport Node3DEditorViewport -#define PoolStringArray PackedStringArray -#define REAL FLOAT -#define POOL_STRING_ARRAY PACKED_STRING_ARRAY -#define POOL_BYTE_ARRAY PACKED_BYTE_ARRAY -#define Spatial Node3D -#define SpatialMaterial StandardMaterial3D -#define PoolVector3Array PackedVector3Array -#define PoolVector2Array PackedVector2Array -#define PoolColorArray PackedColorArray -#define PoolIntArray PackedInt64Array -#define PoolRealArray PackedFloat32Array -#define PoolByteArray PackedByteArray -#define MeshInstance MeshInstance3D -#define Camera Camera3D -#define ToolButton Button -#define Shape Shape3D -#define Reference RefCounted - -typedef class World3D World; - -#define DirectionalLight DirectionalLight3D - -typedef class ImmediateGeometry3D ImmediateGeometry; -typedef class Navigation3D Navigation; -typedef class PhysicsServer3D PhysicsServer; -typedef class RenderingServer VisualServer; -typedef class RenderingServer VS; -//typedef class StandardMaterial3D SpatialMaterial; - -//toodo figure out a way to have this -//#define Variant::CallError Callable::CallError -#endif - -#if GODOT4 - -#define VARIANT_ARRAY_GET(arr) \ - Vector r; \ - for (int i = 0; i < arr.size(); i++) { \ - r.push_back(arr[i]); \ - } \ - return r; - -#else #define VARIANT_ARRAY_GET(arr) \ Vector r; \ @@ -99,8 +22,6 @@ typedef class RenderingServer VS; } \ return r; -#endif - #define VARIANT_ARRAY_SET(arr, arr_into, type) \ arr_into.clear(); \ for (int i = 0; i < arr.size(); i++) { \ @@ -108,21 +29,11 @@ typedef class RenderingServer VS; arr_into.push_back(e); \ } -#if GODOT4 -//TODO do this properly -#define INSTANCE_VALIDATE(var) var -#define CONNECT(sig, obj, target_method_class, method) connect(sig, callable_mp(obj, &target_method_class::method)) -#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method)) -#define GET_WORLD get_world_3d -#define INSTANCE instantiate -#define VREMOVE remove_at -#else #define INSTANCE_VALIDATE(var) ObjectDB::instance_validate(var) #define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method) #define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, obj, #method) #define GET_WORLD get_world #define INSTANCE instance #define VREMOVE remove -#endif #endif diff --git a/modules/voxelman/register_types.cpp b/modules/voxelman/register_types.cpp index aaa299079..96c3feb5e 100644 --- a/modules/voxelman/register_types.cpp +++ b/modules/voxelman/register_types.cpp @@ -77,9 +77,9 @@ SOFTWARE. #include "world/jobs/voxel_job.h" #include "world/jobs/voxel_light_job.h" +#include "world/jobs/voxel_mesher_job_step.h" #include "world/jobs/voxel_prop_job.h" #include "world/jobs/voxel_terrain_job.h" -#include "world/jobs/voxel_mesher_job_step.h" void register_voxelman_types() { ClassDB::register_class(); diff --git a/modules/voxelman/register_types.h b/modules/voxelman/register_types.h index ca49745f5..8406818e6 100644 --- a/modules/voxelman/register_types.h +++ b/modules/voxelman/register_types.h @@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - - - void register_voxelman_types(); void unregister_voxelman_types(); diff --git a/modules/voxelman/world/voxel_structure.cpp b/modules/voxelman/world/voxel_structure.cpp index 5cb189ae2..cdc5b2812 100644 --- a/modules/voxelman/world/voxel_structure.cpp +++ b/modules/voxelman/world/voxel_structure.cpp @@ -66,13 +66,9 @@ void VoxelStructure::set_position(const int x, const int y, const int z) { void VoxelStructure::write_to_chunk(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); -#if VERSION_MAJOR < 4 if (has_method("_write_to_chunk")) { call("_write_to_chunk", chunk); } -#else - GDVIRTUAL_CALL(_write_to_chunk, chunk); -#endif } VoxelStructure::VoxelStructure() { @@ -86,11 +82,7 @@ VoxelStructure::~VoxelStructure() { } void VoxelStructure::_bind_methods() { -#if VERSION_MAJOR < 4 BIND_VMETHOD(MethodInfo("_write_to_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); -#else - GDVIRTUAL_BIND(_write_to_chunk, "chunk"); -#endif ClassDB::bind_method(D_METHOD("get_use_aabb"), &VoxelStructure::get_use_aabb); ClassDB::bind_method(D_METHOD("set_use_aabb", "value"), &VoxelStructure::set_use_aabb); diff --git a/modules/voxelman/world/voxel_structure.h b/modules/voxelman/world/voxel_structure.h index c7c70ef01..d917af74d 100644 --- a/modules/voxelman/world/voxel_structure.h +++ b/modules/voxelman/world/voxel_structure.h @@ -23,17 +23,8 @@ SOFTWARE. */ - - -#include "core/version.h" - -#if VERSION_MAJOR > 3 -#include "core/io/resource.h" -#include "core/templates/hash_map.h" -#else #include "core/hash_map.h" #include "core/resource.h" -#endif #include "../defines.h" @@ -65,10 +56,6 @@ public: void write_to_chunk(Ref chunk); -#if VERSION_MAJOR >= 4 - GDVIRTUAL1(_write_to_chunk, Ref); -#endif - VoxelStructure(); ~VoxelStructure(); diff --git a/modules/voxelman/world/voxel_world.cpp b/modules/voxelman/world/voxel_world.cpp index e55979f46..447ee2d01 100644 --- a/modules/voxelman/world/voxel_world.cpp +++ b/modules/voxelman/world/voxel_world.cpp @@ -22,8 +22,6 @@ SOFTWARE. #include "voxel_world.h" -#include "core/version.h" - #include "voxel_chunk.h" #include "voxel_structure.h" @@ -197,11 +195,7 @@ void VoxelWorld::world_area_add(const Ref &area) { void VoxelWorld::world_area_remove(const int index) { ERR_FAIL_INDEX(index, _world_areas.size()); -#if VERSION_MAJOR < 4 _world_areas.remove(index); -#else - _world_areas.remove_at(index); -#endif } void VoxelWorld::world_areas_clear() { _world_areas.clear(); @@ -227,21 +221,13 @@ void VoxelWorld::voxel_structure_remove(const Ref &structure) { int index = _voxel_structures.find(structure); if (index != -1) { -#if VERSION_MAJOR < 4 _voxel_structures.remove(index); -#else - _voxel_structures.remove_at(index); -#endif } } void VoxelWorld::voxel_structure_remove_index(const int index) { ERR_FAIL_INDEX(index, _voxel_structures.size()); -#if VERSION_MAJOR < 4 _voxel_structures.remove(index); -#else - _voxel_structures.remove_at(index); -#endif } void VoxelWorld::voxel_structures_clear() { _voxel_structures.clear(); @@ -294,11 +280,7 @@ void VoxelWorld::chunk_add(Ref chunk, const int x, const int y, cons chunk->enter_tree(); if (has_method("_chunk_added")) { -#if VERSION_MAJOR < 4 call("_chunk_added", chunk); -#else - GDVIRTUAL_CALL(_chunk_added, chunk); -#endif } } bool VoxelWorld::chunk_has(const int x, const int y, const int z) const { @@ -322,11 +304,7 @@ Ref VoxelWorld::chunk_remove(const int x, const int y, const int z) for (int i = 0; i < _chunks_vector.size(); ++i) { if (_chunks_vector.get(i) == chunk) { -#if VERSION_MAJOR < 4 _chunks_vector.remove(i); -#else - _chunks_vector.remove_at(i); -#endif break; } } @@ -343,11 +321,7 @@ Ref VoxelWorld::chunk_remove_index(const int index) { ERR_FAIL_INDEX_V(index, _chunks_vector.size(), NULL); Ref chunk = _chunks_vector.get(index); -#if VERSION_MAJOR < 4 _chunks_vector.remove(index); -#else - _chunks_vector.remove_at(index); -#endif _chunks.erase(IntPos(chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z())); chunk->exit_tree(); @@ -387,12 +361,7 @@ Ref VoxelWorld::chunk_get_or_create(int x, int y, int z) { } Ref VoxelWorld::chunk_create(const int x, const int y, const int z) { -#if VERSION_MAJOR < 4 Ref c = call("_create_chunk", x, y, z, Ref()); -#else - Ref c; - GDVIRTUAL_CALL(_create_chunk, x, y, z, Ref(), c); -#endif generation_queue_add_to(c); @@ -402,21 +371,12 @@ Ref VoxelWorld::chunk_create(const int x, const int y, const int z) void VoxelWorld::chunk_setup(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); -#if VERSION_MAJOR < 4 call("_create_chunk", chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z(), chunk); -#else - Ref c; - GDVIRTUAL_CALL(_create_chunk, chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z(), chunk, c); -#endif } Ref VoxelWorld::_create_chunk(const int x, const int y, const int z, Ref chunk) { if (!chunk.is_valid()) { -#if VERSION_MAJOR < 4 chunk.instance(); -#else - chunk.instantiate(); -#endif } //no meshers here @@ -446,18 +406,10 @@ void VoxelWorld::chunk_generate(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); if (has_method("_prepare_chunk_for_generation")) { -#if VERSION_MAJOR < 4 call("_prepare_chunk_for_generation", chunk); -#else - GDVIRTUAL_CALL(_prepare_chunk_for_generation, chunk); -#endif } -#if VERSION_MAJOR < 4 call("_generate_chunk", chunk); -#else - GDVIRTUAL_CALL(_generate_chunk, chunk); -#endif chunk->build(); } @@ -566,11 +518,7 @@ Ref VoxelWorld::generation_queue_get_index(int index) { void VoxelWorld::generation_queue_remove_index(int index) { ERR_FAIL_INDEX(index, _generation_queue.size()); -#if VERSION_MAJOR < 4 _generation_queue.remove(index); -#else - _generation_queue.remove_at(index); -#endif } int VoxelWorld::generation_queue_get_size() const { return _generation_queue.size(); @@ -589,11 +537,7 @@ Ref VoxelWorld::generation_get_index(const int index) { void VoxelWorld::generation_remove_index(const int index) { ERR_FAIL_INDEX(index, _generating.size()); -#if VERSION_MAJOR < 4 _generating.remove(index); -#else - _generating.remove_at(index); -#endif } int VoxelWorld::generation_get_size() const { return _generating.size(); @@ -646,11 +590,7 @@ void VoxelWorld::prop_add(Transform tarnsform, const Ref &prop, const if (!sc.is_valid()) continue; -#if VERSION_MAJOR < 4 Node *n = sc->instance(); -#else - Node *n = sc->instantiate(); -#endif add_child(n); n->set_owner(this); @@ -667,11 +607,7 @@ void VoxelWorld::prop_add(Transform tarnsform, const Ref &prop, const if (light_data.is_valid()) { Ref light; -#if VERSION_MAJOR < 4 light.instance(); -#else - light.instantiate(); -#endif light->set_world_position(wp.x / get_voxel_scale(), wp.y / get_voxel_scale(), wp.z / get_voxel_scale()); light->set_color(light_data->get_light_color()); @@ -903,24 +839,11 @@ Ref VoxelWorld::get_or_create_chunk_at_world_position(const Vector3 } void VoxelWorld::set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel) { -#if VERSION_MAJOR < 4 call("_set_voxel_with_tool", mode_add, hit_position, hit_normal, selected_voxel, isolevel); -#else - GDVIRTUAL_CALL(_set_voxel_with_tool, mode_add, hit_position, hit_normal, selected_voxel, isolevel); -#endif } int VoxelWorld::get_channel_index_info(const VoxelWorld::ChannelTypeInfo channel_type) { -#if VERSION_MAJOR < 4 return call("_get_channel_index_info", channel_type); -#else - int ret; - if (GDVIRTUAL_CALL(_get_channel_index_info, channel_type, ret)) { - return ret; - } - - return 0; -#endif } VoxelWorld::VoxelWorld() { @@ -1023,18 +946,10 @@ void VoxelWorld::_notification(int p_what) { } } -#if VERSION_MAJOR > 3 - if (_is_priority_generation && _generation_queue.is_empty() && _generating.is_empty()) { -#else if (_is_priority_generation && _generation_queue.empty() && _generating.empty()) { -#endif _is_priority_generation = false; -#if VERSION_MAJOR < 4 call("_generation_finished"); -#else - GDVIRTUAL_CALL(_generation_finished); -#endif emit_signal("generation_finished"); @@ -1045,11 +960,7 @@ void VoxelWorld::_notification(int p_what) { Ref chunk = _generating.get(i); if (!chunk.is_valid() || !chunk->get_is_generating()) { -#if VERSION_MAJOR < 4 _generating.remove(i); -#else - _generating.remove_at(i); -#endif --i; continue; } @@ -1064,11 +975,7 @@ void VoxelWorld::_notification(int p_what) { while (_generating.size() < _max_concurrent_generations && _generation_queue.size() != 0) { Ref chunk = _generation_queue.get(0); -#if VERSION_MAJOR < 4 _generation_queue.remove(0); -#else - _generation_queue.remove_at(0); -#endif ERR_FAIL_COND(!chunk.is_valid()); @@ -1204,11 +1111,7 @@ void VoxelWorld::_bind_methods() { ClassDB::bind_method(D_METHOD("voxel_structures_set"), &VoxelWorld::voxel_structures_set); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "17/17:VoxelStructure", PROPERTY_USAGE_DEFAULT, "VoxelStructure"), "voxel_structures_set", "voxel_structures_get"); -#if VERSION_MAJOR < 4 BIND_VMETHOD(MethodInfo("_chunk_added", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); -#else - GDVIRTUAL_BIND(_chunk_added, "chunk"); -#endif ClassDB::bind_method(D_METHOD("chunk_add", "chunk", "x", "y", "z"), &VoxelWorld::chunk_add); ClassDB::bind_method(D_METHOD("chunk_has", "x", "y", "z"), &VoxelWorld::chunk_has); @@ -1237,18 +1140,11 @@ void VoxelWorld::_bind_methods() { ADD_SIGNAL(MethodInfo("generation_finished")); -#if VERSION_MAJOR < 4 BIND_VMETHOD(MethodInfo("_generation_finished")); BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), "_create_chunk", PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); BIND_VMETHOD(MethodInfo("_prepare_chunk_for_generation", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); -#else - GDVIRTUAL_BIND(_generation_finished); - GDVIRTUAL_BIND(_create_chunk, "chunk", "x", "y", "z", "chunk", "ret"); - GDVIRTUAL_BIND(_prepare_chunk_for_generation, "chunk"); - GDVIRTUAL_BIND(_generate_chunk, "chunk"); -#endif ClassDB::bind_method(D_METHOD("chunk_get_or_create", "x", "y", "z"), &VoxelWorld::chunk_get_or_create); ClassDB::bind_method(D_METHOD("chunk_create", "x", "y", "z"), &VoxelWorld::chunk_create); @@ -1280,25 +1176,17 @@ void VoxelWorld::_bind_methods() { ClassDB::bind_method(D_METHOD("get_chunk_at_world_position", "world_position"), &VoxelWorld::get_chunk_at_world_position); ClassDB::bind_method(D_METHOD("get_or_create_chunk_at_world_position", "world_position"), &VoxelWorld::get_or_create_chunk_at_world_position); -#if VERSION_MAJOR < 4 BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "ret"), "_get_channel_index_info", PropertyInfo(Variant::INT, "channel_type", PROPERTY_HINT_ENUM, BINDING_STRING_CHANNEL_TYPE_INFO))); -#else - GDVIRTUAL_BIND(_get_channel_index_info, "channel_type", "ret"); -#endif ClassDB::bind_method(D_METHOD("get_channel_index_info", "channel_type"), &VoxelWorld::get_channel_index_info); ClassDB::bind_method(D_METHOD("_get_channel_index_info", "channel_type"), &VoxelWorld::_get_channel_index_info); -#if VERSION_MAJOR < 4 BIND_VMETHOD(MethodInfo("_set_voxel_with_tool", PropertyInfo(Variant::BOOL, "mode_add"), PropertyInfo(Variant::VECTOR3, "hit_position"), PropertyInfo(Variant::VECTOR3, "hit_normal"), PropertyInfo(Variant::INT, "selected_voxel"), PropertyInfo(Variant::INT, "isolevel"))); -#else - GDVIRTUAL_BIND(_set_voxel_with_tool, "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"); -#endif ClassDB::bind_method(D_METHOD("set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &VoxelWorld::set_voxel_with_tool); ClassDB::bind_method(D_METHOD("_set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &VoxelWorld::_set_voxel_with_tool); diff --git a/modules/voxelman/world/voxel_world.h b/modules/voxelman/world/voxel_world.h index 457999b0f..cef1e4032 100644 --- a/modules/voxelman/world/voxel_world.h +++ b/modules/voxelman/world/voxel_world.h @@ -22,18 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - - - -#include "core/version.h" - -#if VERSION_MAJOR > 3 -#include "core/templates/hash_map.h" -#include "core/config/engine.h" -#else -#include "core/hash_map.h" #include "core/engine.h" -#endif +#include "core/hash_map.h" #include "../defines.h" @@ -193,20 +183,6 @@ public: int get_channel_index_info(const ChannelTypeInfo channel_type); -#if VERSION_MAJOR >= 4 - GDVIRTUAL1(_chunk_added, Ref); - - GDVIRTUAL0(_generation_finished); - - GDVIRTUAL4R(Ref, _create_chunk, int, int, int, Ref); - GDVIRTUAL1(_prepare_chunk_for_generation, Ref); - GDVIRTUAL1(_generate_chunk, Ref); - - GDVIRTUAL1R(int, _get_channel_index_info, int); - - GDVIRTUAL5(_set_voxel_with_tool, bool, Vector3, Vector3, int, int); -#endif - VoxelWorld(); ~VoxelWorld(); @@ -270,23 +246,23 @@ private: int _chunk_spawn_range; HashMap, IntPosHasher> _chunks; - Vector > _chunks_vector; + Vector> _chunks_vector; - Vector > _world_areas; + Vector> _world_areas; - Vector > _voxel_structures; + Vector> _voxel_structures; NodePath _player_path; Spatial *_player; bool _use_threads; int _max_concurrent_generations; - Vector > _generation_queue; - Vector > _generating; + Vector> _generation_queue; + Vector> _generating; int _max_frame_chunk_build_steps; int _num_frame_chunk_build_steps; - Vector > _lights; + Vector> _lights; }; _FORCE_INLINE_ bool operator==(const VoxelWorld::IntPos &a, const VoxelWorld::IntPos &b) { diff --git a/modules/voxelman/world/voxel_world_editor.cpp b/modules/voxelman/world/voxel_world_editor.cpp index 029cb828a..773ec8d14 100644 --- a/modules/voxelman/world/voxel_world_editor.cpp +++ b/modules/voxelman/world/voxel_world_editor.cpp @@ -22,8 +22,6 @@ SOFTWARE. #include "voxel_world_editor.h" -#include "core/version.h" - #include "editor/editor_scale.h" #include "editor/editor_settings.h" @@ -33,10 +31,10 @@ SOFTWARE. #include "voxel_chunk.h" -#include "../library/voxel_surface.h" #include "../library/voxel_library.h" -#include "servers/physics_server.h" +#include "../library/voxel_surface.h" #include "scene/resources/world.h" +#include "servers/physics_server.h" #include "../defines.h" @@ -44,7 +42,6 @@ SOFTWARE. #include spatial_editor_plugin_h #include camera_h -#if VERSION_MAJOR < 4 bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { if (!_world || !_world->get_editable()) { return false; @@ -71,39 +68,6 @@ bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { - if (!_world || !_world->get_editable()) { - return EditorPlugin::AFTER_GUI_INPUT_PASS; - } - - Ref mb = p_event; - - if (mb.is_valid()) { - if (mb->is_pressed()) { - Ref lib = _world->get_library(); - - if (!lib.is_valid()) - return EditorPlugin::AFTER_GUI_INPUT_PASS; - - if (mb->get_button_index() == MouseButton::LEFT) { - if (do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true)) { - return EditorPlugin::AFTER_GUI_INPUT_STOP; - } else { - return EditorPlugin::AFTER_GUI_INPUT_PASS; - } - } else { - return EditorPlugin::AFTER_GUI_INPUT_PASS; - } - - //return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); - } - } - - return EditorPlugin::AFTER_GUI_INPUT_PASS; -} - -#endif bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) { if (!spatial_editor || !_world || !_world->is_inside_world()) @@ -121,18 +85,7 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, PhysicsDirectSpaceState::RayResult res; -#if VERSION_MAJOR >= 4 - PhysicsDirectSpaceState::RayParameters keyparams; - keyparams.from = from; - keyparams.to = to; -#endif - - -#if VERSION_MAJOR < 4 if (ss->intersect_ray(from, to, res)) { -#else - if (ss->intersect_ray(keyparams, res)) { -#endif int selected_voxel = 0; int channel = 0; @@ -205,11 +158,7 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) { Button *button = memnew(Button); button->set_text(text); -#if VERSION_MAJOR < 4 button->set_text_align(Button::ALIGN_LEFT); -#else - button->set_text_alignment(HorizontalAlignment::HORIZONTAL_ALIGNMENT_LEFT); -#endif button->set_meta("index", i); button->set_toggle_mode(true); button->set_button_group(_surfaces_button_group); @@ -247,18 +196,10 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { spatial_editor_hb = memnew(HBoxContainer); spatial_editor_hb->set_h_size_flags(SIZE_EXPAND_FILL); -#if VERSION_MAJOR < 4 spatial_editor_hb->set_alignment(BoxContainer::ALIGN_BEGIN); -#else - spatial_editor_hb->set_alignment(BoxContainer::ALIGNMENT_BEGIN); -#endif SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb); -#if VERSION_MAJOR < 4 _tool_button_group.instance(); -#else - _tool_button_group.instantiate(); -#endif ToolButton *add_button = memnew(ToolButton); add_button->set_text("Add"); @@ -269,11 +210,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { add_button->CONNECT("button_up", this, VoxelWorldEditor, _on_tool_button_pressed); -#if VERSION_MAJOR < 4 add_button->set_shortcut(ED_SHORTCUT("voxel_world_editor/add_mode", "Add Mode", KEY_A)); -#else - add_button->set_shortcut(ED_SHORTCUT("voxel_world_editor/add_mode", "Add Mode", Key::A)); -#endif spatial_editor_hb->add_child(add_button); @@ -285,11 +222,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { remove_button->CONNECT("button_up", this, VoxelWorldEditor, _on_tool_button_pressed); -#if VERSION_MAJOR < 4 remove_button->set_shortcut(ED_SHORTCUT("voxel_world_editor/remove_mode", "Remove Mode", KEY_S)); -#else - remove_button->set_shortcut(ED_SHORTCUT("voxel_world_editor/remove_mode", "Remove Mode", Key::S)); -#endif spatial_editor_hb->add_child(remove_button); @@ -298,11 +231,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { insert_buton->CONNECT("button_up", this, VoxelWorldEditor, _on_insert_block_at_camera_button_pressed); -#if VERSION_MAJOR < 4 insert_buton->set_shortcut(ED_SHORTCUT("voxel_world_editor/instert_block_at_camera", "Insert at camera", KEY_B)); -#else - insert_buton->set_shortcut(ED_SHORTCUT("voxel_world_editor/instert_block_at_camera", "Insert at camera", Key::B)); -#endif spatial_editor_hb->add_child(insert_buton); @@ -330,11 +259,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { scs->add_child(_surfaces_vbox_container); _surfaces_vbox_container->set_h_size_flags(SIZE_EXPAND_FILL); -#if VERSION_MAJOR < 4 _surfaces_button_group.instance(); -#else - _surfaces_button_group.instantiate(); -#endif } VoxelWorldEditor::~VoxelWorldEditor() { _world = NULL; @@ -377,12 +302,7 @@ void VoxelWorldEditor::_on_insert_block_at_camera_button_pressed() { if (!vp) return; - -#if VERSION_MAJOR < 4 Camera *cam = vp->get_camera(); -#else - Camera *cam = vp->get_camera_3d(); -#endif if (!cam) return; @@ -413,21 +333,12 @@ void VoxelWorldEditor::_bind_methods() { void VoxelWorldEditorPlugin::_notification(int p_what) { if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { switch ((int)EditorSettings::get_singleton()->get("editors/voxel/editor_side")) { -#if VERSION_MAJOR <= 3 && VERSION_MINOR < 5 - case 0: { // Left. - SpatialEditor::get_singleton()->get_palette_split()->move_child(voxel_world_editor, 0); - } break; - case 1: { // Right. - SpatialEditor::get_singleton()->get_palette_split()->move_child(voxel_world_editor, 1); - } break; -#else case 0: { // Left. SpatialEditor::get_singleton()->move_control_to_left_panel(voxel_world_editor); } break; case 1: { // Right. SpatialEditor::get_singleton()->move_control_to_right_panel(voxel_world_editor); } break; -#endif } } } diff --git a/modules/voxelman/world/voxel_world_editor.h b/modules/voxelman/world/voxel_world_editor.h index 39a9635f8..4104b96b2 100644 --- a/modules/voxelman/world/voxel_world_editor.h +++ b/modules/voxelman/world/voxel_world_editor.h @@ -22,19 +22,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - - - #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "../defines.h" -#if VERSION_MAJOR > 3 -#include "core/math/transform_3d.h" -typedef class Transform3D Transform; -#endif - class VoxelWorld; class SpatialEditorPlugin; @@ -48,11 +40,7 @@ public: }; public: -#if VERSION_MAJOR < 4 bool forward_spatial_input_event(Camera *p_camera, const Ref &p_event); -#else - EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref &p_event); -#endif void edit(VoxelWorld *p_world); bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); @@ -102,13 +90,8 @@ protected: void _notification(int p_what); public: -#if VERSION_MAJOR < 4 bool forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } -#else - EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } - virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } -#endif virtual String get_name() const { return "VoxelWorldEditor"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object);