diff --git a/editor/prop_2d_editor_plugin.cpp b/editor/prop_2d_editor_plugin.cpp index a1c7b26..49dbd59 100644 --- a/editor/prop_2d_editor_plugin.cpp +++ b/editor/prop_2d_editor_plugin.cpp @@ -25,6 +25,7 @@ SOFTWARE. #include "../props/prop_2d_data.h" #include "../singleton/prop_2d_utils.h" #include "core/os/keyboard.h" +#include "editor/editor_settings.h" #include "core/version.h" @@ -72,12 +73,12 @@ void Prop2DEditorPlugin::convert_scene(Node *root, const String &path) { res->copy_from(data); ResourceSaver s; - s.save(path, res); + s.save(res, path); res.unref(); } else { ResourceSaver s; - s.save(path, data); + s.save(data, path); } } @@ -106,8 +107,8 @@ void Prop2DEditorPlugin::_convert_selected_scene_to_prop_data(Variant param) { convert_selected_scene_to_prop_data(); } -Prop2DEditorPlugin::Prop2DEditorPlugin(EditorNode *p_node) { - editor = p_node; +Prop2DEditorPlugin::Prop2DEditorPlugin() { + editor = EditorNode::get_singleton(); #if VERSION_MAJOR < 4 editor->add_tool_menu_item("Convert active scene to Prop2DData", this, "convert_active_scene_to_prop_data"); @@ -122,7 +123,7 @@ Prop2DEditorPlugin::Prop2DEditorPlugin(EditorNode *p_node) { b->CONNECT("pressed", this, Prop2DEditorPlugin, _quick_convert_button_pressed); b->set_text("To Prop2D"); - b->set_shortcut(ED_SHORTCUT("spatial_editor/quick_prop_convert", "Quick convert scene to Prop2DData.", KEY_MASK_ALT + KEY_U)); + b->set_shortcut(ED_SHORTCUT("spatial_editor/quick_prop_convert", "Quick convert scene to Prop2DData.", KeyModifierMask::ALT + Key::U)); add_control_to_container(EditorPlugin::CONTAINER_CANVAS_EDITOR_MENU, b); } diff --git a/editor/prop_2d_editor_plugin.h b/editor/prop_2d_editor_plugin.h index eb20522..3f3c345 100644 --- a/editor/prop_2d_editor_plugin.h +++ b/editor/prop_2d_editor_plugin.h @@ -53,7 +53,7 @@ public: void _convert_selected_scene_to_prop_data(Variant param); void _quick_convert_button_pressed(); - Prop2DEditorPlugin(EditorNode *p_node); + Prop2DEditorPlugin(); ~Prop2DEditorPlugin(); }; diff --git a/material_cache/prop_2d_material_cache.cpp b/material_cache/prop_2d_material_cache.cpp index 609f3a9..f7793db 100644 --- a/material_cache/prop_2d_material_cache.cpp +++ b/material_cache/prop_2d_material_cache.cpp @@ -94,13 +94,13 @@ void Prop2DMaterialCache::material_set(const Ref &value) { _material = value; } -void Prop2DMaterialCache::texture_add(const Ref &texture) { +void Prop2DMaterialCache::texture_add(const Ref &texture) { _textures.push_back(texture); } -void Prop2DMaterialCache::texture_remove(const Ref &texture) { +void Prop2DMaterialCache::texture_remove(const Ref &texture) { for (int i = 0; i < _textures.size(); ++i) { if (_textures[i] == texture) { - _textures.remove(i); + _textures.remove_at(i); return; } } @@ -116,8 +116,8 @@ void Prop2DMaterialCache::textures_clear() { int Prop2DMaterialCache::texture_count() { return _textures.size(); } -Ref Prop2DMaterialCache::texture_get(const int index) { - ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); +Ref Prop2DMaterialCache::texture_get(const int index) { + ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); return _textures[index]; } @@ -126,10 +126,10 @@ Ref Prop2DMaterialCache::texture_get_atlas(const int index) { return texture_get_atlas_tex(_textures[index]); } -Ref Prop2DMaterialCache::texture_get_atlas_tex(const Ref &texture) { +Ref Prop2DMaterialCache::texture_get_atlas_tex(const Ref &texture) { return Ref(); } -Rect2 Prop2DMaterialCache::texture_get_rect(const Ref &texture) { +Rect2 Prop2DMaterialCache::texture_get_rect(const Ref &texture) { Ref at = texture_get_atlas_tex(texture); if (!at.is_valid()) { @@ -138,12 +138,12 @@ Rect2 Prop2DMaterialCache::texture_get_rect(const Ref &texture) { return at->get_region(); } -Rect2 Prop2DMaterialCache::texture_get_uv_rect(const Ref &texture) { +Rect2 Prop2DMaterialCache::texture_get_uv_rect(const Ref &texture) { return Rect2(0, 0, 1, 1); } -Ref Prop2DMaterialCache::texture_get_merged() { - return Ref(); +Ref Prop2DMaterialCache::texture_get_merged() { + return Ref(); } void Prop2DMaterialCache::prop_add_textures(const Ref &prop) { @@ -156,7 +156,7 @@ void Prop2DMaterialCache::prop_add_textures(const Ref &prop) { Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { - Ref tex = pdm->get_texture(); + Ref tex = pdm->get_texture(); if (!tex.is_valid()) continue; @@ -197,7 +197,7 @@ void Prop2DMaterialCache::prop_remove_textures(const Ref &prop) { Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { - Ref tex = pdm->get_texture(); + Ref tex = pdm->get_texture(); if (!tex.is_valid()) continue; @@ -215,7 +215,7 @@ void Prop2DMaterialCache::prop_remove_textures(const Ref &prop) { continue; for (int j = 0; j < twd->get_texture_count(); ++j) { - const Ref &tex = twd->get_texture(j); + const Ref &tex = twd->get_texture(j); if (tex.is_valid()) { texture_remove(tex); @@ -223,7 +223,7 @@ void Prop2DMaterialCache::prop_remove_textures(const Ref &prop) { } for (int j = 0; j < twd->get_flavour_texture_count(); ++j) { - const Ref &tex = twd->get_flavour_texture(j); + const Ref &tex = twd->get_flavour_texture(j); if (tex.is_valid()) { texture_remove(tex); @@ -263,7 +263,7 @@ void Prop2DMaterialCache::initial_setup_default() { } } -void Prop2DMaterialCache::setup_material_albedo(Ref texture) { +void Prop2DMaterialCache::setup_material_albedo(Ref texture) { if (has_method("_setup_material_albedo")) call("_setup_material_albedo", texture); } diff --git a/material_cache/prop_2d_material_cache.h b/material_cache/prop_2d_material_cache.h index ef6af3a..0d950f1 100644 --- a/material_cache/prop_2d_material_cache.h +++ b/material_cache/prop_2d_material_cache.h @@ -60,18 +60,18 @@ public: Ref material_get(); void material_set(const Ref &value); - virtual void texture_add(const Ref &texture); - virtual void texture_remove(const Ref &texture); + virtual void texture_add(const Ref &texture); + virtual void texture_remove(const Ref &texture); virtual void texture_remove_index(const int index); virtual void textures_clear(); virtual int texture_count(); - virtual Ref texture_get(const int index); + virtual Ref texture_get(const int index); virtual Ref texture_get_atlas(const int index); - virtual Ref texture_get_atlas_tex(const Ref &texture); - virtual Rect2 texture_get_rect(const Ref &texture); - virtual Rect2 texture_get_uv_rect(const Ref &texture); + virtual Ref texture_get_atlas_tex(const Ref &texture); + virtual Rect2 texture_get_rect(const Ref &texture); + virtual Rect2 texture_get_uv_rect(const Ref &texture); - virtual Ref texture_get_merged(); + virtual Ref texture_get_merged(); void prop_add_textures(const Ref &prop); void prop_remove_textures(const Ref &prop); @@ -80,7 +80,7 @@ public: virtual void initial_setup_default(); - void setup_material_albedo(Ref texture); + void setup_material_albedo(Ref texture); Prop2DMaterialCache(); ~Prop2DMaterialCache(); @@ -92,7 +92,7 @@ protected: bool _initialized; Ref _material; - Vector> _textures; + Vector> _textures; int _ref_count; diff --git a/material_cache/prop_2d_material_cache_pcm.cpp b/material_cache/prop_2d_material_cache_pcm.cpp index bafea59..9551043 100644 --- a/material_cache/prop_2d_material_cache_pcm.cpp +++ b/material_cache/prop_2d_material_cache_pcm.cpp @@ -61,14 +61,14 @@ void Prop2DMaterialCachePCM::set_margin(const int margin) { _packer->set_margin(margin); } -Ref Prop2DMaterialCachePCM::texture_get_atlas_tex(const Ref &texture) { +Ref Prop2DMaterialCachePCM::texture_get_atlas_tex(const Ref &texture) { if (!_packer->contains_texture(texture)) { return Ref(); } return _packer->get_texture(texture); } -Rect2 Prop2DMaterialCachePCM::texture_get_uv_rect(const Ref &texture) { +Rect2 Prop2DMaterialCachePCM::texture_get_uv_rect(const Ref &texture) { if (!texture.is_valid()) { return Rect2(0, 0, 1, 1); } @@ -81,13 +81,13 @@ Rect2 Prop2DMaterialCachePCM::texture_get_uv_rect(const Ref &texture) { Rect2 region = at->get_region(); - Ref tex = at->get_atlas(); + Ref tex = at->get_atlas(); if (!tex.is_valid()) { return Rect2(0, 0, 1, 1); } - Ref image = tex->get_data(); + Ref image = tex->get_image(); if (!image.is_valid()) { return Rect2(0, 0, 1, 1); @@ -102,7 +102,7 @@ Rect2 Prop2DMaterialCachePCM::texture_get_uv_rect(const Ref &texture) { return region; } -Ref Prop2DMaterialCachePCM::texture_get_merged() { +Ref Prop2DMaterialCachePCM::texture_get_merged() { return _merged_texture; } @@ -110,7 +110,7 @@ void Prop2DMaterialCachePCM::refresh_rects() { bool texture_added = false; for (int i = 0; i < _textures.size(); i++) { - Ref tex = _textures.get(i); + Ref tex = _textures.get(i); ERR_CONTINUE(!tex.is_valid()); @@ -145,7 +145,7 @@ void Prop2DMaterialCachePCM::initial_setup_default() { set_margin(pc->get_margin()); } -void Prop2DMaterialCachePCM::_setup_material_albedo(Ref texture) { +void Prop2DMaterialCachePCM::_setup_material_albedo(Ref texture) { Ref m = material_get(); Ref shmat = m; @@ -158,12 +158,9 @@ void Prop2DMaterialCachePCM::_setup_material_albedo(Ref texture) { Prop2DMaterialCachePCM::Prop2DMaterialCachePCM() { _packer.instantiate(); -#if GODOT4 #warning implement -#else - _packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER); -#endif - + //_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER); + _packer->set_max_atlas_size(1024); _packer->set_keep_original_atlases(false); _packer->set_margin(0); diff --git a/material_cache/prop_2d_material_cache_pcm.h b/material_cache/prop_2d_material_cache_pcm.h index fe59c93..d43ccb7 100644 --- a/material_cache/prop_2d_material_cache_pcm.h +++ b/material_cache/prop_2d_material_cache_pcm.h @@ -62,16 +62,16 @@ public: int get_margin() const; void set_margin(const int margin); - Ref texture_get_atlas_tex(const Ref &texture); - Rect2 texture_get_uv_rect(const Ref &texture); + Ref texture_get_atlas_tex(const Ref &texture); + Rect2 texture_get_uv_rect(const Ref &texture); - Ref texture_get_merged(); + Ref texture_get_merged(); void refresh_rects(); void initial_setup_default(); - void _setup_material_albedo(Ref texture); + void _setup_material_albedo(Ref texture); Prop2DMaterialCachePCM(); ~Prop2DMaterialCachePCM(); @@ -80,7 +80,7 @@ protected: static void _bind_methods(); Ref _packer; - Ref _merged_texture; + Ref _merged_texture; }; #endif diff --git a/prop_2d_instance_merger.cpp b/prop_2d_instance_merger.cpp index 8383f1b..695f0f2 100644 --- a/prop_2d_instance_merger.cpp +++ b/prop_2d_instance_merger.cpp @@ -48,6 +48,8 @@ typedef class RenderingServer VS; #include "material_cache/prop_2d_material_cache.h" #include "scene/3d/camera_3d.h" +#include "scene/resources/world_2d.h" + #if TEXTURE_PACKER_PRESENT #include "./singleton/prop_2d_cache.h" #endif @@ -203,12 +205,12 @@ void Prop2DInstanceMerger::colliders_set(const Vector &colliders) { void Prop2DInstanceMerger::debug_mesh_allocate() { if (_debug_mesh_rid == RID()) { - _debug_mesh_rid = VisualServer::get_singleton()->mesh_create(); + _debug_mesh_rid = RenderingServer::get_singleton()->mesh_create(); } } void Prop2DInstanceMerger::debug_mesh_free() { if (_debug_mesh_rid != RID()) { - VisualServer::get_singleton()->free(_debug_mesh_rid); + RenderingServer::get_singleton()->free(_debug_mesh_rid); } } bool Prop2DInstanceMerger::debug_mesh_has() { @@ -216,13 +218,13 @@ bool Prop2DInstanceMerger::debug_mesh_has() { } void Prop2DInstanceMerger::debug_mesh_clear() { if (_debug_mesh_rid != RID()) { - VisualServer::get_singleton()->mesh_clear(_debug_mesh_rid); + RenderingServer::get_singleton()->mesh_clear(_debug_mesh_rid); } } void Prop2DInstanceMerger::debug_mesh_array_clear() { _debug_mesh_array.resize(0); } -void Prop2DInstanceMerger::debug_mesh_add_vertices_to(const PoolVector2Array &arr) { +void Prop2DInstanceMerger::debug_mesh_add_vertices_to(const PackedVector2Array &arr) { _debug_mesh_array.append_array(arr); if (_debug_mesh_array.size() % 2 == 1) { @@ -236,13 +238,13 @@ void Prop2DInstanceMerger::debug_mesh_send() { if (_debug_mesh_array.size() == 0) return; - SceneTree *st = SceneTree::get_singleton(); + //SceneTree *st = SceneTree::get_singleton(); Array arr; - arr.resize(VisualServer::ARRAY_MAX); - arr[VisualServer::ARRAY_VERTEX] = _debug_mesh_array; + arr.resize(RenderingServer::ARRAY_MAX); + arr[RenderingServer::ARRAY_VERTEX] = _debug_mesh_array; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(_debug_mesh_rid, VisualServer::PRIMITIVE_LINES, arr); + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(_debug_mesh_rid, RenderingServer::PRIMITIVE_LINES, arr); debug_mesh_array_clear(); } @@ -261,9 +263,9 @@ void Prop2DInstanceMerger::draw_debug_mdr_colliders() { Transform2D t = collider_local_transform_get(i); - VisualServer::get_singleton()->canvas_item_add_set_transform(get_canvas_item(), t); + RenderingServer::get_singleton()->canvas_item_add_set_transform(get_canvas_item(), t); shape->draw(get_canvas_item(), Color(1, 1, 1, 1)); - VisualServer::get_singleton()->canvas_item_add_set_transform(get_canvas_item(), Transform2D()); + RenderingServer::get_singleton()->canvas_item_add_set_transform(get_canvas_item(), Transform2D()); } debug_mesh_send(); @@ -287,7 +289,7 @@ void Prop2DInstanceMerger::free_colliders() { for (int i = 0; i < _colliders.size(); ++i) { ColliderBody &e = _colliders.write[i]; - PhysicsServer::get_singleton()->free(e.body); + PhysicsServer3D::get_singleton()->free(e.body); e.body = RID(); @@ -419,17 +421,17 @@ void Prop2DInstanceMerger::_prop_preprocess(Transform2D transform, const Refadd_tiled_wall(tiled_wall_data, t); if (tiled_wall_data->get_collision()) { - Ref tws; + Ref tws; tws.instantiate(); float hew = tiled_wall_data->get_width() / 2.0; float heh = tiled_wall_data->get_heigth() / 2.0; - tws->set_extents(Vector3(hew, heh, 0.01)); + tws->set_size(Vector3(hew, heh, 0.01)); Transform2D tt = t; //tt.origin += Vector3(hew, heh, 0); - tt.translate(hew, heh); + tt.translate_local(hew, heh); _job->add_collision_shape(tws, tt, true); } @@ -502,7 +504,7 @@ void Prop2DInstanceMerger::collision_layer_changed() { const ColliderBody &c = _colliders[i]; if (c.body != RID()) { - PhysicsServer::get_singleton()->body_set_collision_layer(c.body, _collision_layer); + PhysicsServer3D::get_singleton()->body_set_collision_layer(c.body, _collision_layer); } } } @@ -511,7 +513,7 @@ void Prop2DInstanceMerger::collision_mask_changed() { const ColliderBody &c = _colliders[i]; if (c.body != RID()) { - PhysicsServer::get_singleton()->body_set_collision_mask(c.body, _collision_mask); + PhysicsServer3D::get_singleton()->body_set_collision_mask(c.body, _collision_mask); } } } diff --git a/prop_2d_instance_merger.h b/prop_2d_instance_merger.h index 7d45af4..db08bb2 100644 --- a/prop_2d_instance_merger.h +++ b/prop_2d_instance_merger.h @@ -76,7 +76,7 @@ public: bool debug_mesh_has(); void debug_mesh_clear(); void debug_mesh_array_clear(); - void debug_mesh_add_vertices_to(const PoolVector2Array &arr); + void debug_mesh_add_vertices_to(const PackedVector2Array &arr); void debug_mesh_send(); void draw_debug_mdr_colliders(); @@ -128,7 +128,7 @@ private: //debug RID _debug_mesh_rid; - PoolVector2Array _debug_mesh_array; + PackedVector2Array _debug_mesh_array; }; #endif diff --git a/prop_2d_instance_prop_job.cpp b/prop_2d_instance_prop_job.cpp index 4acd8ca..7a5d57d 100644 --- a/prop_2d_instance_prop_job.cpp +++ b/prop_2d_instance_prop_job.cpp @@ -53,6 +53,7 @@ SOFTWARE. #include "props/prop_2d_data_tiled_wall_2d.h" #include "tiled_wall/tiled_wall_2d_data.h" +#include "scene/resources/world_2d.h" Ref Prop2DInstanceProp2DJob::get_material_cache() { return _material_cache; @@ -289,15 +290,15 @@ void Prop2DInstanceProp2DJob::phase_prop() { } #endif - for (int i = 0; i < _prop_tiled_wall_datas.size(); ++i) { - PTWEntry &e = _prop_tiled_wall_datas.write[i]; + //for (int i = 0; i < _prop_tiled_wall_datas.size(); ++i) { + // PTWEntry &e = _prop_tiled_wall_datas.write[i]; - Ref pdtw = e.data; + //Ref pdtw = e.data; //Transform t = pdtw->get_transform(); - Transform2D t = e.base_transform; + //Transform2D t = e.base_transform; //_prop_mesher->add_tiled_wall_simple(pdtw->get_width(), pdtw->get_heigth(), t, pdtw->get_data(), _material_cache); - } + //} if (_prop_mesher->get_vertex_count() == 0) { //reset_meshes(); @@ -448,7 +449,7 @@ Array Prop2DInstanceProp2DJob::merge_mesh_array(Array arr) const { return arr; } -Array Prop2DInstanceProp2DJob::bake_mesh_array_uv(Array arr, Ref tex, const float mul_color) const { +Array Prop2DInstanceProp2DJob::bake_mesh_array_uv(Array arr, Ref tex, const float mul_color) const { ERR_FAIL_COND_V(arr.size() != RenderingServer::ARRAY_MAX, arr); ERR_FAIL_COND_V(!tex.is_valid(), arr); diff --git a/prop_2d_instance_prop_job.h b/prop_2d_instance_prop_job.h index 342c5a0..24aae3e 100644 --- a/prop_2d_instance_prop_job.h +++ b/prop_2d_instance_prop_job.h @@ -80,7 +80,7 @@ public: void step_type_normal(); Array merge_mesh_array(Array arr) const; - Array bake_mesh_array_uv(Array arr, Ref tex, float mul_color = 0.7) const; + Array bake_mesh_array_uv(Array arr, Ref tex, float mul_color = 0.7) const; void reset_meshes(); diff --git a/prop_2d_mesher.cpp b/prop_2d_mesher.cpp index 480a0fc..cc207b9 100644 --- a/prop_2d_mesher.cpp +++ b/prop_2d_mesher.cpp @@ -518,7 +518,7 @@ _FORCE_INLINE_ Vector2 Prop2DMesher::transform_uv(const Vector2 &uv, const Rect2 #ifdef MESH_DATA_RESOURCE_PRESENT void Prop2DMesher::add_mesh_data_resource(Ref mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) { - Transform transform = Transform(Basis(rotation).scaled(scale), position); + Transform3D transform = Transform3D(Basis::from_euler(rotation).scaled(scale), position); add_mesh_data_resource_transform(mesh, transform, uv_rect); } @@ -529,10 +529,10 @@ void Prop2DMesher::add_mesh_data_resource_transform(Ref mesh, const Array &arr = mesh->get_array(); - PoolVector2Array vertices = arr[Mesh::ARRAY_VERTEX]; - PoolVector2Array uvs = arr[Mesh::ARRAY_TEX_UV]; - PoolColorArray colors = arr[Mesh::ARRAY_COLOR]; - PoolIntArray indices = arr[Mesh::ARRAY_INDEX]; + PackedVector2Array vertices = arr[Mesh::ARRAY_VERTEX]; + PackedVector2Array uvs = arr[Mesh::ARRAY_TEX_UV]; + PackedColorArray colors = arr[Mesh::ARRAY_COLOR]; + PackedInt32Array indices = arr[Mesh::ARRAY_INDEX]; if (vertices.size() == 0) return; @@ -563,15 +563,15 @@ void Prop2DMesher::add_mesh_data_resource_transform(Ref mesh, } } -void Prop2DMesher::add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) { +void Prop2DMesher::add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PackedColorArray &colors, const Rect2 uv_rect) { if (mesh->get_array().size() == 0) return; const Array &arr = mesh->get_array(); - PoolVector2Array vertices = arr[Mesh::ARRAY_VERTEX]; - PoolVector2Array uvs = arr[Mesh::ARRAY_TEX_UV]; - PoolIntArray indices = arr[Mesh::ARRAY_INDEX]; + PackedVector2Array vertices = arr[Mesh::ARRAY_VERTEX]; + PackedVector2Array uvs = arr[Mesh::ARRAY_TEX_UV]; + PackedInt32Array indices = arr[Mesh::ARRAY_INDEX]; if (vertices.size() == 0) return; @@ -858,7 +858,7 @@ void Prop2DMesher::bake_colors_lights() { } #ifdef TERRAMAN_2D_PRESENT -void Prop2DMesher::bake_lights(MeshInstance *node, Vector> &lights) { +void Prop2DMesher::bake_lights(MeshInstance3D *node, Vector> &lights) { /* ERR_FAIL_COND(node == NULL); diff --git a/prop_2d_mesher.h b/prop_2d_mesher.h index 41ef9c5..c1e1ae3 100644 --- a/prop_2d_mesher.h +++ b/prop_2d_mesher.h @@ -142,7 +142,7 @@ public: #ifdef MESH_DATA_RESOURCE_PRESENT void add_mesh_data_resource(Ref mesh, const Vector3 position = Vector3(0, 0, 0), const Vector3 rotation = Vector3(0, 0, 0), const Vector3 scale = Vector3(1.0, 1.0, 1.0), const Rect2 uv_rect = Rect2(0, 0, 1, 1)); void add_mesh_data_resource_transform(Ref mesh, const Transform transform, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); - void add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); + void add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PackedColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); #endif void generate_ao(); @@ -165,7 +165,7 @@ public: void bake_colors_lights(); #ifdef TERRAMAN_2D_PRESENT - void bake_lights(MeshInstance *node, Vector> &lights); + void bake_lights(MeshInstance3D *node, Vector> &lights); #endif Array build_mesh(); diff --git a/props/prop_2d_data.cpp b/props/prop_2d_data.cpp index eba44ee..cf4ea69 100644 --- a/props/prop_2d_data.cpp +++ b/props/prop_2d_data.cpp @@ -106,10 +106,10 @@ void Prop2DData::set_is_room(const bool value) { _is_room = value; } -PoolVector3Array Prop2DData::get_room_bounds() { +PackedVector3Array Prop2DData::get_room_bounds() { return _room_bounds; } -void Prop2DData::set_room_bounds(const PoolVector3Array &bounds) { +void Prop2DData::set_room_bounds(const PackedVector3Array &bounds) { _room_bounds = bounds; } diff --git a/props/prop_2d_data_entry.cpp b/props/prop_2d_data_entry.cpp index 0bf3aa3..90e84ab 100644 --- a/props/prop_2d_data_entry.cpp +++ b/props/prop_2d_data_entry.cpp @@ -124,7 +124,7 @@ void Prop2DDataEntry::processor_process(Ref prop_data, Node *node, c call("_processor_process", prop_data, node, transform); } Node *Prop2DDataEntry::processor_get_node_for(const Transform2D &transform) { - return call("_processor_get_node_for", transform); + return Object::cast_to(call("_processor_get_node_for", transform)); } bool Prop2DDataEntry::processor_evaluate_children() { return call("_processor_evaluate_children"); @@ -206,7 +206,7 @@ Prop2DDataEntry::~Prop2DDataEntry() { void Prop2DDataEntry::_bind_methods() { ClassDB::bind_method(D_METHOD("get_transform"), &Prop2DDataEntry::get_transform); ClassDB::bind_method(D_METHOD("set_transform", "value"), &Prop2DDataEntry::set_transform); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform"); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform"), "set_transform", "get_transform"); ClassDB::bind_method(D_METHOD("get_transform_2d"), &Prop2DDataEntry::get_transform_2d); ClassDB::bind_method(D_METHOD("set_transform_2d", "value"), &Prop2DDataEntry::set_transform_2d); @@ -256,14 +256,14 @@ void Prop2DDataEntry::_bind_methods() { //BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "handles"), "_processor_handles")); //BIND_VMETHOD(MethodInfo("_processor_process", - PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DData"), - PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), - PropertyInfo(Variant::TRANSFORM, "transform"), - PropertyInfo(Variant::OBJECT, "entry", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DDataEntry"))); + // PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DData"), + // PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), + // PropertyInfo(Variant::TRANSFORM, "transform"), + // PropertyInfo(Variant::OBJECT, "entry", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DDataEntry"))); //BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), "_processor_get_node_for", - PropertyInfo(Variant::TRANSFORM, "transform"), - PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); + // PropertyInfo(Variant::TRANSFORM, "transform"), + // PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); //BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "evaluate"), "_processor_evaluate_children")); diff --git a/props/prop_2d_data_light.cpp b/props/prop_2d_data_light.cpp index 427799e..3ae981b 100644 --- a/props/prop_2d_data_light.cpp +++ b/props/prop_2d_data_light.cpp @@ -61,10 +61,10 @@ void Prop2DDataLight::set_energy(const float value) { _energy = value; } -Ref Prop2DDataLight::get_texture() const { +Ref Prop2DDataLight::get_texture() const { return _texture; } -void Prop2DDataLight::set_texture(const Ref value) { +void Prop2DDataLight::set_texture(const Ref value) { _texture = value; } @@ -89,7 +89,7 @@ void Prop2DDataLight::_processor_process(Ref prop_data, Node *node, l->set_light_color(i->get_color()); - Ref tex = i->get_texture(); + Ref tex;// = i->get_texture(); int w = 0; int h = 0; @@ -102,7 +102,7 @@ void Prop2DDataLight::_processor_process(Ref prop_data, Node *node, l->set_light_size_x(w); l->set_light_size_y(h); - l->set_texture_scale(i->get_texture_scale()); + //l->set_texture_scale(i->get_texture_scale()); l->set_energy(i->get_energy()); l->set_texture(tex); @@ -120,9 +120,9 @@ Node *Prop2DDataLight::_processor_get_node_for(const Transform2D &transform, Nod i->set_color(get_light_color()); - i->set_texture_scale(get_texture_scale()); + //i->set_texture_scale(get_texture_scale()); i->set_energy(get_energy()); - i->set_texture(get_texture()); + //i->set_texture(get_texture()); return Prop2DDataEntry::_processor_get_node_for(transform, i); } diff --git a/props/prop_2d_data_light.h b/props/prop_2d_data_light.h index 087f0aa..273887f 100644 --- a/props/prop_2d_data_light.h +++ b/props/prop_2d_data_light.h @@ -52,8 +52,8 @@ public: float get_energy() const; void set_energy(const float value); - Ref get_texture() const; - void set_texture(const Ref value); + Ref get_texture() const; + void set_texture(const Ref value); bool _processor_handles(Node *node); void _processor_process(Ref prop_data, Node *node, const Transform2D &transform, Ref entry = Ref()); @@ -71,7 +71,7 @@ private: int _light_size_y; float _texture_scale; float _energy; - Ref _texture; + Ref _texture; }; #endif diff --git a/props/prop_2d_data_sprite.cpp b/props/prop_2d_data_sprite.cpp index 086794d..9af2634 100644 --- a/props/prop_2d_data_sprite.cpp +++ b/props/prop_2d_data_sprite.cpp @@ -24,19 +24,19 @@ SOFTWARE. #include "prop_2d_data.h" -#include "scene/2d/sprite.h" +#include "scene/2d/sprite_2d.h" -Ref Prop2DDataSprite::get_texture() const { +Ref Prop2DDataSprite::get_texture() const { return _texture; } -void Prop2DDataSprite::set_texture(const Ref &value) { +void Prop2DDataSprite::set_texture(const Ref &value) { _texture = value; } -Ref Prop2DDataSprite::get_normal_map() const { +Ref Prop2DDataSprite::get_normal_map() const { return _normal_map; } -void Prop2DDataSprite::set_normal_map(const Ref &value) { +void Prop2DDataSprite::set_normal_map(const Ref &value) { _normal_map = _normal_map; } @@ -118,13 +118,13 @@ void Prop2DDataSprite::set_filter_clip(const bool value) { } bool Prop2DDataSprite::_processor_handles(Node *node) { - Sprite *s = Object::cast_to(node); + Sprite2D *s = Object::cast_to(node); return s; } void Prop2DDataSprite::_processor_process(Ref prop_data, Node *node, const Transform2D &transform, Ref entry) { - Sprite *s = Object::cast_to(node); + Sprite2D *s = Object::cast_to(node); ERR_FAIL_COND(!s); @@ -137,7 +137,7 @@ void Prop2DDataSprite::_processor_process(Ref prop_data, Node *node, } l->set_texture(s->get_texture()); - l->set_normal_map(s->get_normal_map()); + //l->set_normal_map(s->get_normal_map()); l->set_centered(s->is_centered()); l->set_offset(s->get_offset()); @@ -150,7 +150,7 @@ void Prop2DDataSprite::_processor_process(Ref prop_data, Node *node, l->set_animation_frame(s->get_frame()); l->set_animation_frame_coords(s->get_frame_coords()); - l->set_region_enabled(s->is_region()); + //l->set_region_enabled(s->is_region()); l->set_region(s->get_region_rect()); l->set_filter_clip(s->is_region_filter_clip_enabled()); @@ -158,16 +158,16 @@ void Prop2DDataSprite::_processor_process(Ref prop_data, Node *node, } Node *Prop2DDataSprite::_processor_get_node_for(const Transform2D &transform, Node *node) { - Sprite *n; + Sprite2D *n; if (node) { - n = Object::cast_to(node); + n = Object::cast_to(node); } else { - n = memnew(Sprite()); + n = memnew(Sprite2D()); } n->set_texture(get_texture()); - n->set_normal_map(get_normal_map()); + //n->set_normal_map(get_normal_map()); n->set_centered(get_centered()); n->set_offset(get_offset()); @@ -179,9 +179,9 @@ Node *Prop2DDataSprite::_processor_get_node_for(const Transform2D &transform, No n->set_frame(get_animation_frame()); n->set_frame_coords(get_animation_frame_coords()); - n->set_region(get_region_enabled()); + //n->set_region(get_region_enabled()); n->set_region_rect(get_region()); - n->set_region_filter_clip(get_filter_clip()); + //n->set_region_filter_clip(get_filter_clip()); return Prop2DDataEntry::_processor_get_node_for(transform, n); } diff --git a/props/prop_2d_data_sprite.h b/props/prop_2d_data_sprite.h index e5de71f..0ea61b8 100644 --- a/props/prop_2d_data_sprite.h +++ b/props/prop_2d_data_sprite.h @@ -39,11 +39,11 @@ class Prop2DDataSprite : public Prop2DDataEntry { GDCLASS(Prop2DDataSprite, Prop2DDataEntry); public: - Ref get_texture() const; - void set_texture(const Ref &value); + Ref get_texture() const; + void set_texture(const Ref &value); - Ref get_normal_map() const; - void set_normal_map(const Ref &value); + Ref get_normal_map() const; + void set_normal_map(const Ref &value); bool get_centered() const; void set_centered(const bool value); @@ -89,8 +89,8 @@ protected: static void _bind_methods(); private: - Ref _texture; - Ref _normal_map; + Ref _texture; + Ref _normal_map; bool _centered; Vector2 _offset; diff --git a/singleton/prop_2d_cache.cpp b/singleton/prop_2d_cache.cpp index a065da6..041cda9 100644 --- a/singleton/prop_2d_cache.cpp +++ b/singleton/prop_2d_cache.cpp @@ -164,7 +164,7 @@ Ref Prop2DCache::material_cache_get(const Ref & ERR_FAIL_COND_V(!prop.is_valid(), Ref()); //get pointer's value as uint64 - uint64_t k = make_uint64_t(*prop); + uint64_t k = hash_make_uint64_t(*prop); _material_cache_mutex.lock(); @@ -178,7 +178,7 @@ Ref Prop2DCache::material_cache_get(const Ref & return m; } - Prop2DMaterialCache *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); + Prop2DMaterialCache *p = Object::cast_to(ClassDB::instantiate(_default_prop_material_cache_class)); if (!p) { ERR_PRINT("Can't instance the given Prop2DMaterialCache! class_name: " + String(_default_prop_material_cache_class)); @@ -194,7 +194,7 @@ Ref Prop2DCache::material_cache_get(const Ref & } void Prop2DCache::material_cache_unref(const Ref &prop) { //get pointer's value as uint64 - uint64_t k = make_uint64_t(*prop); + uint64_t k = hash_make_uint64_t(*prop); _material_cache_mutex.lock(); @@ -220,7 +220,7 @@ Ref Prop2DCache::tiled_wall_material_cache_get(const Ref()); //get pointer's value as uint64 - uint64_t k = make_uint64_t(*twd); + uint64_t k = hash_make_uint64_t(*twd); _tiled_wall_material_cache_mutex.lock(); @@ -234,7 +234,7 @@ Ref Prop2DCache::tiled_wall_material_cache_get(const Ref(ClassDB::instance(_default_prop_material_cache_class)); + Prop2DMaterialCache *p = Object::cast_to(ClassDB::instantiate(_default_prop_material_cache_class)); if (!p) { ERR_PRINT("Can't instance the given Prop2DMaterialCache! class_name: " + String(_default_prop_material_cache_class)); @@ -250,7 +250,7 @@ Ref Prop2DCache::tiled_wall_material_cache_get(const Ref &twd) { //get pointer's value as uint64 - uint64_t k = make_uint64_t(*twd); + uint64_t k = hash_make_uint64_t(*twd); _tiled_wall_material_cache_mutex.lock(); @@ -285,7 +285,7 @@ Ref Prop2DCache::material_cache_custom_key_get(const uint64 return m; } - Prop2DMaterialCache *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); + Prop2DMaterialCache *p = Object::cast_to(ClassDB::instantiate(_default_prop_material_cache_class)); if (!p) { ERR_PRINT("Can't instance the given Prop2DMaterialCache! class_name: " + String(_default_prop_material_cache_class)); @@ -321,19 +321,7 @@ void Prop2DCache::material_cache_custom_key_unref(const uint64_t key) { } Ref Prop2DCache::load_resource(const String &path, const String &type_hint) { - _ResourceLoader *rl = _ResourceLoader::get_singleton(); - -#if VERSION_MAJOR < 4 - Ref resl = rl->load_interactive(path, type_hint); - - ERR_FAIL_COND_V(!resl.is_valid(), Ref()); - - resl->wait(); - - return resl->get_resource(); -#else - return rl->load(path, type_hint); -#endif + return ResourceLoader::load(path, type_hint); } Prop2DCache::Prop2DCache() { @@ -370,7 +358,7 @@ Prop2DCache::~Prop2DCache() { void Prop2DCache::_bind_methods() { ClassDB::bind_method(D_METHOD("get_default_pixels_per_unit"), &Prop2DCache::get_default_pixels_per_unit); ClassDB::bind_method(D_METHOD("set_default_pixels_per_unit", "value"), &Prop2DCache::set_default_pixels_per_unit); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "default_pixels_per_unit"), "set_default_pixels_per_unit", "get_default_pixels_per_unit"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "default_pixels_per_unit"), "set_default_pixels_per_unit", "get_default_pixels_per_unit"); ClassDB::bind_method(D_METHOD("get_default_prop_material_cache_class"), &Prop2DCache::get_default_prop_material_cache_class); ClassDB::bind_method(D_METHOD("set_default_prop_material_cache_class", "cls_name"), &Prop2DCache::set_default_prop_material_cache_class); diff --git a/singleton/prop_2d_cache.h b/singleton/prop_2d_cache.h index 717ded9..e88f69e 100644 --- a/singleton/prop_2d_cache.h +++ b/singleton/prop_2d_cache.h @@ -112,9 +112,9 @@ protected: StringName _default_prop_material_cache_class; - Map> _material_cache; - Map> _tiled_wall_material_cache; - Map> _custom_keyed_material_cache; + HashMap> _material_cache; + HashMap> _tiled_wall_material_cache; + HashMap> _custom_keyed_material_cache; Mutex _material_cache_mutex; Mutex _tiled_wall_material_cache_mutex; diff --git a/singleton/prop_2d_utils.cpp b/singleton/prop_2d_utils.cpp index c8a4bbf..a61d374 100644 --- a/singleton/prop_2d_utils.cpp +++ b/singleton/prop_2d_utils.cpp @@ -34,7 +34,7 @@ SOFTWARE. #include "scene/3d/room_manager.h" #endif -#include "scene/3d/mesh_instance.h" +#include "scene/3d/mesh_instance_3d.h" #if MESH_DATA_RESOURCE_PRESENT #include "../../mesh_data_resource/nodes/mesh_data_instance.h" @@ -148,7 +148,7 @@ void Prop2DUtils::swap_processors(const int index1, const int index2) { void Prop2DUtils::remove_processor(const int index) { ERR_FAIL_INDEX(index, Prop2DUtils::_processors.size()); - Prop2DUtils::_processors.remove(index); + Prop2DUtils::_processors.remove_at(index); } int Prop2DUtils::get_processor_count() { return Prop2DUtils::_processors.size(); diff --git a/tiled_wall/tiled_wall_2d.cpp b/tiled_wall/tiled_wall_2d.cpp index aa6a331..a5e0f98 100644 --- a/tiled_wall/tiled_wall_2d.cpp +++ b/tiled_wall/tiled_wall_2d.cpp @@ -214,7 +214,7 @@ void TiledWall2D::generate_mesh() { editor_point_vertices.set(i, vertices[i]); } - _editor_selection_points = Geometry::convex_hull_2d(editor_point_vertices); + _editor_selection_points = Geometry2D::convex_hull(editor_point_vertices); #endif if (vertices.size() == 0) { @@ -252,7 +252,7 @@ void TiledWall2D::draw() { return; } - RenderingServer::get_singleton()->canvas_item_add_mesh(get_canvas_item(), _mesh_rid, get_transform(), Color(1, 1, 1, 1), _texture_rid, RID()); + RenderingServer::get_singleton()->canvas_item_add_mesh(get_canvas_item(), _mesh_rid, get_transform(), Color(1, 1, 1, 1), _texture_rid); } TiledWall2D::TiledWall2D() {