Work on fixing compile.

This commit is contained in:
Relintai 2023-01-09 20:06:10 +01:00
parent 60c28df4a9
commit 04f382e23d
22 changed files with 141 additions and 152 deletions

View File

@ -25,6 +25,7 @@ SOFTWARE.
#include "../props/prop_2d_data.h" #include "../props/prop_2d_data.h"
#include "../singleton/prop_2d_utils.h" #include "../singleton/prop_2d_utils.h"
#include "core/os/keyboard.h" #include "core/os/keyboard.h"
#include "editor/editor_settings.h"
#include "core/version.h" #include "core/version.h"
@ -72,12 +73,12 @@ void Prop2DEditorPlugin::convert_scene(Node *root, const String &path) {
res->copy_from(data); res->copy_from(data);
ResourceSaver s; ResourceSaver s;
s.save(path, res); s.save(res, path);
res.unref(); res.unref();
} else { } else {
ResourceSaver s; 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(); convert_selected_scene_to_prop_data();
} }
Prop2DEditorPlugin::Prop2DEditorPlugin(EditorNode *p_node) { Prop2DEditorPlugin::Prop2DEditorPlugin() {
editor = p_node; editor = EditorNode::get_singleton();
#if VERSION_MAJOR < 4 #if VERSION_MAJOR < 4
editor->add_tool_menu_item("Convert active scene to Prop2DData", this, "convert_active_scene_to_prop_data"); 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->CONNECT("pressed", this, Prop2DEditorPlugin, _quick_convert_button_pressed);
b->set_text("To Prop2D"); 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); add_control_to_container(EditorPlugin::CONTAINER_CANVAS_EDITOR_MENU, b);
} }

View File

@ -53,7 +53,7 @@ public:
void _convert_selected_scene_to_prop_data(Variant param); void _convert_selected_scene_to_prop_data(Variant param);
void _quick_convert_button_pressed(); void _quick_convert_button_pressed();
Prop2DEditorPlugin(EditorNode *p_node); Prop2DEditorPlugin();
~Prop2DEditorPlugin(); ~Prop2DEditorPlugin();
}; };

View File

@ -94,13 +94,13 @@ void Prop2DMaterialCache::material_set(const Ref<Material> &value) {
_material = value; _material = value;
} }
void Prop2DMaterialCache::texture_add(const Ref<Texture> &texture) { void Prop2DMaterialCache::texture_add(const Ref<Texture2D> &texture) {
_textures.push_back(texture); _textures.push_back(texture);
} }
void Prop2DMaterialCache::texture_remove(const Ref<Texture> &texture) { void Prop2DMaterialCache::texture_remove(const Ref<Texture2D> &texture) {
for (int i = 0; i < _textures.size(); ++i) { for (int i = 0; i < _textures.size(); ++i) {
if (_textures[i] == texture) { if (_textures[i] == texture) {
_textures.remove(i); _textures.remove_at(i);
return; return;
} }
} }
@ -116,8 +116,8 @@ void Prop2DMaterialCache::textures_clear() {
int Prop2DMaterialCache::texture_count() { int Prop2DMaterialCache::texture_count() {
return _textures.size(); return _textures.size();
} }
Ref<Texture> Prop2DMaterialCache::texture_get(const int index) { Ref<Texture2D> Prop2DMaterialCache::texture_get(const int index) {
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<Texture>()); ERR_FAIL_INDEX_V(index, _textures.size(), Ref<Texture2D>());
return _textures[index]; return _textures[index];
} }
@ -126,10 +126,10 @@ Ref<AtlasTexture> Prop2DMaterialCache::texture_get_atlas(const int index) {
return texture_get_atlas_tex(_textures[index]); return texture_get_atlas_tex(_textures[index]);
} }
Ref<AtlasTexture> Prop2DMaterialCache::texture_get_atlas_tex(const Ref<Texture> &texture) { Ref<AtlasTexture> Prop2DMaterialCache::texture_get_atlas_tex(const Ref<Texture2D> &texture) {
return Ref<AtlasTexture>(); return Ref<AtlasTexture>();
} }
Rect2 Prop2DMaterialCache::texture_get_rect(const Ref<Texture> &texture) { Rect2 Prop2DMaterialCache::texture_get_rect(const Ref<Texture2D> &texture) {
Ref<AtlasTexture> at = texture_get_atlas_tex(texture); Ref<AtlasTexture> at = texture_get_atlas_tex(texture);
if (!at.is_valid()) { if (!at.is_valid()) {
@ -138,12 +138,12 @@ Rect2 Prop2DMaterialCache::texture_get_rect(const Ref<Texture> &texture) {
return at->get_region(); return at->get_region();
} }
Rect2 Prop2DMaterialCache::texture_get_uv_rect(const Ref<Texture> &texture) { Rect2 Prop2DMaterialCache::texture_get_uv_rect(const Ref<Texture2D> &texture) {
return Rect2(0, 0, 1, 1); return Rect2(0, 0, 1, 1);
} }
Ref<Texture> Prop2DMaterialCache::texture_get_merged() { Ref<Texture2D> Prop2DMaterialCache::texture_get_merged() {
return Ref<Texture>(); return Ref<Texture2D>();
} }
void Prop2DMaterialCache::prop_add_textures(const Ref<Prop2DData> &prop) { void Prop2DMaterialCache::prop_add_textures(const Ref<Prop2DData> &prop) {
@ -156,7 +156,7 @@ void Prop2DMaterialCache::prop_add_textures(const Ref<Prop2DData> &prop) {
Ref<Prop2DDataMeshData> pdm = prop->get_prop(i); Ref<Prop2DDataMeshData> pdm = prop->get_prop(i);
if (pdm.is_valid()) { if (pdm.is_valid()) {
Ref<Texture> tex = pdm->get_texture(); Ref<Texture2D> tex = pdm->get_texture();
if (!tex.is_valid()) if (!tex.is_valid())
continue; continue;
@ -197,7 +197,7 @@ void Prop2DMaterialCache::prop_remove_textures(const Ref<Prop2DData> &prop) {
Ref<Prop2DDataMeshData> pdm = prop->get_prop(i); Ref<Prop2DDataMeshData> pdm = prop->get_prop(i);
if (pdm.is_valid()) { if (pdm.is_valid()) {
Ref<Texture> tex = pdm->get_texture(); Ref<Texture2D> tex = pdm->get_texture();
if (!tex.is_valid()) if (!tex.is_valid())
continue; continue;
@ -215,7 +215,7 @@ void Prop2DMaterialCache::prop_remove_textures(const Ref<Prop2DData> &prop) {
continue; continue;
for (int j = 0; j < twd->get_texture_count(); ++j) { for (int j = 0; j < twd->get_texture_count(); ++j) {
const Ref<Texture> &tex = twd->get_texture(j); const Ref<Texture2D> &tex = twd->get_texture(j);
if (tex.is_valid()) { if (tex.is_valid()) {
texture_remove(tex); texture_remove(tex);
@ -223,7 +223,7 @@ void Prop2DMaterialCache::prop_remove_textures(const Ref<Prop2DData> &prop) {
} }
for (int j = 0; j < twd->get_flavour_texture_count(); ++j) { for (int j = 0; j < twd->get_flavour_texture_count(); ++j) {
const Ref<Texture> &tex = twd->get_flavour_texture(j); const Ref<Texture2D> &tex = twd->get_flavour_texture(j);
if (tex.is_valid()) { if (tex.is_valid()) {
texture_remove(tex); texture_remove(tex);
@ -263,7 +263,7 @@ void Prop2DMaterialCache::initial_setup_default() {
} }
} }
void Prop2DMaterialCache::setup_material_albedo(Ref<Texture> texture) { void Prop2DMaterialCache::setup_material_albedo(Ref<Texture2D> texture) {
if (has_method("_setup_material_albedo")) if (has_method("_setup_material_albedo"))
call("_setup_material_albedo", texture); call("_setup_material_albedo", texture);
} }

View File

@ -60,18 +60,18 @@ public:
Ref<Material> material_get(); Ref<Material> material_get();
void material_set(const Ref<Material> &value); void material_set(const Ref<Material> &value);
virtual void texture_add(const Ref<Texture> &texture); virtual void texture_add(const Ref<Texture2D> &texture);
virtual void texture_remove(const Ref<Texture> &texture); virtual void texture_remove(const Ref<Texture2D> &texture);
virtual void texture_remove_index(const int index); virtual void texture_remove_index(const int index);
virtual void textures_clear(); virtual void textures_clear();
virtual int texture_count(); virtual int texture_count();
virtual Ref<Texture> texture_get(const int index); virtual Ref<Texture2D> texture_get(const int index);
virtual Ref<AtlasTexture> texture_get_atlas(const int index); virtual Ref<AtlasTexture> texture_get_atlas(const int index);
virtual Ref<AtlasTexture> texture_get_atlas_tex(const Ref<Texture> &texture); virtual Ref<AtlasTexture> texture_get_atlas_tex(const Ref<Texture2D> &texture);
virtual Rect2 texture_get_rect(const Ref<Texture> &texture); virtual Rect2 texture_get_rect(const Ref<Texture2D> &texture);
virtual Rect2 texture_get_uv_rect(const Ref<Texture> &texture); virtual Rect2 texture_get_uv_rect(const Ref<Texture2D> &texture);
virtual Ref<Texture> texture_get_merged(); virtual Ref<Texture2D> texture_get_merged();
void prop_add_textures(const Ref<Prop2DData> &prop); void prop_add_textures(const Ref<Prop2DData> &prop);
void prop_remove_textures(const Ref<Prop2DData> &prop); void prop_remove_textures(const Ref<Prop2DData> &prop);
@ -80,7 +80,7 @@ public:
virtual void initial_setup_default(); virtual void initial_setup_default();
void setup_material_albedo(Ref<Texture> texture); void setup_material_albedo(Ref<Texture2D> texture);
Prop2DMaterialCache(); Prop2DMaterialCache();
~Prop2DMaterialCache(); ~Prop2DMaterialCache();
@ -92,7 +92,7 @@ protected:
bool _initialized; bool _initialized;
Ref<Material> _material; Ref<Material> _material;
Vector<Ref<Texture>> _textures; Vector<Ref<Texture2D>> _textures;
int _ref_count; int _ref_count;

View File

@ -61,14 +61,14 @@ void Prop2DMaterialCachePCM::set_margin(const int margin) {
_packer->set_margin(margin); _packer->set_margin(margin);
} }
Ref<AtlasTexture> Prop2DMaterialCachePCM::texture_get_atlas_tex(const Ref<Texture> &texture) { Ref<AtlasTexture> Prop2DMaterialCachePCM::texture_get_atlas_tex(const Ref<Texture2D> &texture) {
if (!_packer->contains_texture(texture)) { if (!_packer->contains_texture(texture)) {
return Ref<AtlasTexture>(); return Ref<AtlasTexture>();
} }
return _packer->get_texture(texture); return _packer->get_texture(texture);
} }
Rect2 Prop2DMaterialCachePCM::texture_get_uv_rect(const Ref<Texture> &texture) { Rect2 Prop2DMaterialCachePCM::texture_get_uv_rect(const Ref<Texture2D> &texture) {
if (!texture.is_valid()) { if (!texture.is_valid()) {
return Rect2(0, 0, 1, 1); return Rect2(0, 0, 1, 1);
} }
@ -81,13 +81,13 @@ Rect2 Prop2DMaterialCachePCM::texture_get_uv_rect(const Ref<Texture> &texture) {
Rect2 region = at->get_region(); Rect2 region = at->get_region();
Ref<Texture> tex = at->get_atlas(); Ref<Texture2D> tex = at->get_atlas();
if (!tex.is_valid()) { if (!tex.is_valid()) {
return Rect2(0, 0, 1, 1); return Rect2(0, 0, 1, 1);
} }
Ref<Image> image = tex->get_data(); Ref<Image> image = tex->get_image();
if (!image.is_valid()) { if (!image.is_valid()) {
return Rect2(0, 0, 1, 1); return Rect2(0, 0, 1, 1);
@ -102,7 +102,7 @@ Rect2 Prop2DMaterialCachePCM::texture_get_uv_rect(const Ref<Texture> &texture) {
return region; return region;
} }
Ref<Texture> Prop2DMaterialCachePCM::texture_get_merged() { Ref<Texture2D> Prop2DMaterialCachePCM::texture_get_merged() {
return _merged_texture; return _merged_texture;
} }
@ -110,7 +110,7 @@ void Prop2DMaterialCachePCM::refresh_rects() {
bool texture_added = false; bool texture_added = false;
for (int i = 0; i < _textures.size(); i++) { for (int i = 0; i < _textures.size(); i++) {
Ref<Texture> tex = _textures.get(i); Ref<Texture2D> tex = _textures.get(i);
ERR_CONTINUE(!tex.is_valid()); ERR_CONTINUE(!tex.is_valid());
@ -145,7 +145,7 @@ void Prop2DMaterialCachePCM::initial_setup_default() {
set_margin(pc->get_margin()); set_margin(pc->get_margin());
} }
void Prop2DMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) { void Prop2DMaterialCachePCM::_setup_material_albedo(Ref<Texture2D> texture) {
Ref<Material> m = material_get(); Ref<Material> m = material_get();
Ref<ShaderMaterial> shmat = m; Ref<ShaderMaterial> shmat = m;
@ -158,12 +158,9 @@ void Prop2DMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
Prop2DMaterialCachePCM::Prop2DMaterialCachePCM() { Prop2DMaterialCachePCM::Prop2DMaterialCachePCM() {
_packer.instantiate(); _packer.instantiate();
#if GODOT4
#warning implement #warning implement
#else //_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
#endif
_packer->set_max_atlas_size(1024); _packer->set_max_atlas_size(1024);
_packer->set_keep_original_atlases(false); _packer->set_keep_original_atlases(false);
_packer->set_margin(0); _packer->set_margin(0);

View File

@ -62,16 +62,16 @@ public:
int get_margin() const; int get_margin() const;
void set_margin(const int margin); void set_margin(const int margin);
Ref<AtlasTexture> texture_get_atlas_tex(const Ref<Texture> &texture); Ref<AtlasTexture> texture_get_atlas_tex(const Ref<Texture2D> &texture);
Rect2 texture_get_uv_rect(const Ref<Texture> &texture); Rect2 texture_get_uv_rect(const Ref<Texture2D> &texture);
Ref<Texture> texture_get_merged(); Ref<Texture2D> texture_get_merged();
void refresh_rects(); void refresh_rects();
void initial_setup_default(); void initial_setup_default();
void _setup_material_albedo(Ref<Texture> texture); void _setup_material_albedo(Ref<Texture2D> texture);
Prop2DMaterialCachePCM(); Prop2DMaterialCachePCM();
~Prop2DMaterialCachePCM(); ~Prop2DMaterialCachePCM();
@ -80,7 +80,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
Ref<TexturePacker> _packer; Ref<TexturePacker> _packer;
Ref<Texture> _merged_texture; Ref<Texture2D> _merged_texture;
}; };
#endif #endif

View File

@ -48,6 +48,8 @@ typedef class RenderingServer VS;
#include "material_cache/prop_2d_material_cache.h" #include "material_cache/prop_2d_material_cache.h"
#include "scene/3d/camera_3d.h" #include "scene/3d/camera_3d.h"
#include "scene/resources/world_2d.h"
#if TEXTURE_PACKER_PRESENT #if TEXTURE_PACKER_PRESENT
#include "./singleton/prop_2d_cache.h" #include "./singleton/prop_2d_cache.h"
#endif #endif
@ -203,12 +205,12 @@ void Prop2DInstanceMerger::colliders_set(const Vector<Variant> &colliders) {
void Prop2DInstanceMerger::debug_mesh_allocate() { void Prop2DInstanceMerger::debug_mesh_allocate() {
if (_debug_mesh_rid == RID()) { 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() { void Prop2DInstanceMerger::debug_mesh_free() {
if (_debug_mesh_rid != RID()) { if (_debug_mesh_rid != RID()) {
VisualServer::get_singleton()->free(_debug_mesh_rid); RenderingServer::get_singleton()->free(_debug_mesh_rid);
} }
} }
bool Prop2DInstanceMerger::debug_mesh_has() { bool Prop2DInstanceMerger::debug_mesh_has() {
@ -216,13 +218,13 @@ bool Prop2DInstanceMerger::debug_mesh_has() {
} }
void Prop2DInstanceMerger::debug_mesh_clear() { void Prop2DInstanceMerger::debug_mesh_clear() {
if (_debug_mesh_rid != RID()) { 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() { void Prop2DInstanceMerger::debug_mesh_array_clear() {
_debug_mesh_array.resize(0); _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); _debug_mesh_array.append_array(arr);
if (_debug_mesh_array.size() % 2 == 1) { if (_debug_mesh_array.size() % 2 == 1) {
@ -236,13 +238,13 @@ void Prop2DInstanceMerger::debug_mesh_send() {
if (_debug_mesh_array.size() == 0) if (_debug_mesh_array.size() == 0)
return; return;
SceneTree *st = SceneTree::get_singleton(); //SceneTree *st = SceneTree::get_singleton();
Array arr; Array arr;
arr.resize(VisualServer::ARRAY_MAX); arr.resize(RenderingServer::ARRAY_MAX);
arr[VisualServer::ARRAY_VERTEX] = _debug_mesh_array; 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(); debug_mesh_array_clear();
} }
@ -261,9 +263,9 @@ void Prop2DInstanceMerger::draw_debug_mdr_colliders() {
Transform2D t = collider_local_transform_get(i); 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)); 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(); debug_mesh_send();
@ -287,7 +289,7 @@ void Prop2DInstanceMerger::free_colliders() {
for (int i = 0; i < _colliders.size(); ++i) { for (int i = 0; i < _colliders.size(); ++i) {
ColliderBody &e = _colliders.write[i]; ColliderBody &e = _colliders.write[i];
PhysicsServer::get_singleton()->free(e.body); PhysicsServer3D::get_singleton()->free(e.body);
e.body = RID(); e.body = RID();
@ -419,17 +421,17 @@ void Prop2DInstanceMerger::_prop_preprocess(Transform2D transform, const Ref<Pro
_job->add_tiled_wall(tiled_wall_data, t); _job->add_tiled_wall(tiled_wall_data, t);
if (tiled_wall_data->get_collision()) { if (tiled_wall_data->get_collision()) {
Ref<BoxShape> tws; Ref<BoxShape3D> tws;
tws.instantiate(); tws.instantiate();
float hew = tiled_wall_data->get_width() / 2.0; float hew = tiled_wall_data->get_width() / 2.0;
float heh = tiled_wall_data->get_heigth() / 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; Transform2D tt = t;
//tt.origin += Vector3(hew, heh, 0); //tt.origin += Vector3(hew, heh, 0);
tt.translate(hew, heh); tt.translate_local(hew, heh);
_job->add_collision_shape(tws, tt, true); _job->add_collision_shape(tws, tt, true);
} }
@ -502,7 +504,7 @@ void Prop2DInstanceMerger::collision_layer_changed() {
const ColliderBody &c = _colliders[i]; const ColliderBody &c = _colliders[i];
if (c.body != RID()) { 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]; const ColliderBody &c = _colliders[i];
if (c.body != RID()) { 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);
} }
} }
} }

View File

@ -76,7 +76,7 @@ public:
bool debug_mesh_has(); bool debug_mesh_has();
void debug_mesh_clear(); void debug_mesh_clear();
void debug_mesh_array_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 debug_mesh_send();
void draw_debug_mdr_colliders(); void draw_debug_mdr_colliders();
@ -128,7 +128,7 @@ private:
//debug //debug
RID _debug_mesh_rid; RID _debug_mesh_rid;
PoolVector2Array _debug_mesh_array; PackedVector2Array _debug_mesh_array;
}; };
#endif #endif

View File

@ -53,6 +53,7 @@ SOFTWARE.
#include "props/prop_2d_data_tiled_wall_2d.h" #include "props/prop_2d_data_tiled_wall_2d.h"
#include "tiled_wall/tiled_wall_2d_data.h" #include "tiled_wall/tiled_wall_2d_data.h"
#include "scene/resources/world_2d.h"
Ref<Prop2DMaterialCache> Prop2DInstanceProp2DJob::get_material_cache() { Ref<Prop2DMaterialCache> Prop2DInstanceProp2DJob::get_material_cache() {
return _material_cache; return _material_cache;
@ -289,15 +290,15 @@ void Prop2DInstanceProp2DJob::phase_prop() {
} }
#endif #endif
for (int i = 0; i < _prop_tiled_wall_datas.size(); ++i) { //for (int i = 0; i < _prop_tiled_wall_datas.size(); ++i) {
PTWEntry &e = _prop_tiled_wall_datas.write[i]; // PTWEntry &e = _prop_tiled_wall_datas.write[i];
Ref<Prop2DDataTiledWall2D> pdtw = e.data; //Ref<Prop2DDataTiledWall2D> pdtw = e.data;
//Transform t = pdtw->get_transform(); //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); //_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) { if (_prop_mesher->get_vertex_count() == 0) {
//reset_meshes(); //reset_meshes();
@ -448,7 +449,7 @@ Array Prop2DInstanceProp2DJob::merge_mesh_array(Array arr) const {
return arr; return arr;
} }
Array Prop2DInstanceProp2DJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mul_color) const { Array Prop2DInstanceProp2DJob::bake_mesh_array_uv(Array arr, Ref<Texture2D> tex, const float mul_color) const {
ERR_FAIL_COND_V(arr.size() != RenderingServer::ARRAY_MAX, arr); ERR_FAIL_COND_V(arr.size() != RenderingServer::ARRAY_MAX, arr);
ERR_FAIL_COND_V(!tex.is_valid(), arr); ERR_FAIL_COND_V(!tex.is_valid(), arr);

View File

@ -80,7 +80,7 @@ public:
void step_type_normal(); void step_type_normal();
Array merge_mesh_array(Array arr) const; Array merge_mesh_array(Array arr) const;
Array bake_mesh_array_uv(Array arr, Ref<Texture> tex, float mul_color = 0.7) const; Array bake_mesh_array_uv(Array arr, Ref<Texture2D> tex, float mul_color = 0.7) const;
void reset_meshes(); void reset_meshes();

View File

@ -518,7 +518,7 @@ _FORCE_INLINE_ Vector2 Prop2DMesher::transform_uv(const Vector2 &uv, const Rect2
#ifdef MESH_DATA_RESOURCE_PRESENT #ifdef MESH_DATA_RESOURCE_PRESENT
void Prop2DMesher::add_mesh_data_resource(Ref<MeshDataResource> mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) { void Prop2DMesher::add_mesh_data_resource(Ref<MeshDataResource> 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); add_mesh_data_resource_transform(mesh, transform, uv_rect);
} }
@ -529,10 +529,10 @@ void Prop2DMesher::add_mesh_data_resource_transform(Ref<MeshDataResource> mesh,
const Array &arr = mesh->get_array(); const Array &arr = mesh->get_array();
PoolVector2Array vertices = arr[Mesh::ARRAY_VERTEX]; PackedVector2Array vertices = arr[Mesh::ARRAY_VERTEX];
PoolVector2Array uvs = arr[Mesh::ARRAY_TEX_UV]; PackedVector2Array uvs = arr[Mesh::ARRAY_TEX_UV];
PoolColorArray colors = arr[Mesh::ARRAY_COLOR]; PackedColorArray colors = arr[Mesh::ARRAY_COLOR];
PoolIntArray indices = arr[Mesh::ARRAY_INDEX]; PackedInt32Array indices = arr[Mesh::ARRAY_INDEX];
if (vertices.size() == 0) if (vertices.size() == 0)
return; return;
@ -563,15 +563,15 @@ void Prop2DMesher::add_mesh_data_resource_transform(Ref<MeshDataResource> mesh,
} }
} }
void Prop2DMesher::add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) { void Prop2DMesher::add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform transform, const PackedColorArray &colors, const Rect2 uv_rect) {
if (mesh->get_array().size() == 0) if (mesh->get_array().size() == 0)
return; return;
const Array &arr = mesh->get_array(); const Array &arr = mesh->get_array();
PoolVector2Array vertices = arr[Mesh::ARRAY_VERTEX]; PackedVector2Array vertices = arr[Mesh::ARRAY_VERTEX];
PoolVector2Array uvs = arr[Mesh::ARRAY_TEX_UV]; PackedVector2Array uvs = arr[Mesh::ARRAY_TEX_UV];
PoolIntArray indices = arr[Mesh::ARRAY_INDEX]; PackedInt32Array indices = arr[Mesh::ARRAY_INDEX];
if (vertices.size() == 0) if (vertices.size() == 0)
return; return;
@ -858,7 +858,7 @@ void Prop2DMesher::bake_colors_lights() {
} }
#ifdef TERRAMAN_2D_PRESENT #ifdef TERRAMAN_2D_PRESENT
void Prop2DMesher::bake_lights(MeshInstance *node, Vector<Ref<Terrain2DLight>> &lights) { void Prop2DMesher::bake_lights(MeshInstance3D *node, Vector<Ref<Terrain2DLight>> &lights) {
/* /*
ERR_FAIL_COND(node == NULL); ERR_FAIL_COND(node == NULL);

View File

@ -142,7 +142,7 @@ public:
#ifdef MESH_DATA_RESOURCE_PRESENT #ifdef MESH_DATA_RESOURCE_PRESENT
void add_mesh_data_resource(Ref<MeshDataResource> 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(Ref<MeshDataResource> 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<MeshDataResource> mesh, const Transform transform, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); void add_mesh_data_resource_transform(Ref<MeshDataResource> mesh, const Transform transform, const Rect2 uv_rect = Rect2(0, 0, 1, 1));
void add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); void add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform transform, const PackedColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1));
#endif #endif
void generate_ao(); void generate_ao();
@ -165,7 +165,7 @@ public:
void bake_colors_lights(); void bake_colors_lights();
#ifdef TERRAMAN_2D_PRESENT #ifdef TERRAMAN_2D_PRESENT
void bake_lights(MeshInstance *node, Vector<Ref<Terrain2DLight>> &lights); void bake_lights(MeshInstance3D *node, Vector<Ref<Terrain2DLight>> &lights);
#endif #endif
Array build_mesh(); Array build_mesh();

View File

@ -106,10 +106,10 @@ void Prop2DData::set_is_room(const bool value) {
_is_room = value; _is_room = value;
} }
PoolVector3Array Prop2DData::get_room_bounds() { PackedVector3Array Prop2DData::get_room_bounds() {
return _room_bounds; return _room_bounds;
} }
void Prop2DData::set_room_bounds(const PoolVector3Array &bounds) { void Prop2DData::set_room_bounds(const PackedVector3Array &bounds) {
_room_bounds = bounds; _room_bounds = bounds;
} }

View File

@ -124,7 +124,7 @@ void Prop2DDataEntry::processor_process(Ref<Prop2DData> prop_data, Node *node, c
call("_processor_process", prop_data, node, transform); call("_processor_process", prop_data, node, transform);
} }
Node *Prop2DDataEntry::processor_get_node_for(const Transform2D &transform) { Node *Prop2DDataEntry::processor_get_node_for(const Transform2D &transform) {
return call("_processor_get_node_for", transform); return Object::cast_to<Node>(call("_processor_get_node_for", transform));
} }
bool Prop2DDataEntry::processor_evaluate_children() { bool Prop2DDataEntry::processor_evaluate_children() {
return call("_processor_evaluate_children"); return call("_processor_evaluate_children");
@ -206,7 +206,7 @@ Prop2DDataEntry::~Prop2DDataEntry() {
void Prop2DDataEntry::_bind_methods() { void Prop2DDataEntry::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_transform"), &Prop2DDataEntry::get_transform); ClassDB::bind_method(D_METHOD("get_transform"), &Prop2DDataEntry::get_transform);
ClassDB::bind_method(D_METHOD("set_transform", "value"), &Prop2DDataEntry::set_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("get_transform_2d"), &Prop2DDataEntry::get_transform_2d);
ClassDB::bind_method(D_METHOD("set_transform_2d", "value"), &Prop2DDataEntry::set_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(PropertyInfo(Variant::BOOL, "handles"), "_processor_handles"));
//BIND_VMETHOD(MethodInfo("_processor_process", //BIND_VMETHOD(MethodInfo("_processor_process",
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DData"), // PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DData"),
PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), // PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"),
PropertyInfo(Variant::TRANSFORM, "transform"), // PropertyInfo(Variant::TRANSFORM, "transform"),
PropertyInfo(Variant::OBJECT, "entry", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DDataEntry"))); // 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", //BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), "_processor_get_node_for",
PropertyInfo(Variant::TRANSFORM, "transform"), // PropertyInfo(Variant::TRANSFORM, "transform"),
PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); // PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
//BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "evaluate"), "_processor_evaluate_children")); //BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "evaluate"), "_processor_evaluate_children"));

View File

@ -61,10 +61,10 @@ void Prop2DDataLight::set_energy(const float value) {
_energy = value; _energy = value;
} }
Ref<Texture> Prop2DDataLight::get_texture() const { Ref<Texture2D> Prop2DDataLight::get_texture() const {
return _texture; return _texture;
} }
void Prop2DDataLight::set_texture(const Ref<Texture> value) { void Prop2DDataLight::set_texture(const Ref<Texture2D> value) {
_texture = value; _texture = value;
} }
@ -89,7 +89,7 @@ void Prop2DDataLight::_processor_process(Ref<Prop2DData> prop_data, Node *node,
l->set_light_color(i->get_color()); l->set_light_color(i->get_color());
Ref<Texture> tex = i->get_texture(); Ref<Texture2D> tex;// = i->get_texture();
int w = 0; int w = 0;
int h = 0; int h = 0;
@ -102,7 +102,7 @@ void Prop2DDataLight::_processor_process(Ref<Prop2DData> prop_data, Node *node,
l->set_light_size_x(w); l->set_light_size_x(w);
l->set_light_size_y(h); 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_energy(i->get_energy());
l->set_texture(tex); 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_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_energy(get_energy());
i->set_texture(get_texture()); //i->set_texture(get_texture());
return Prop2DDataEntry::_processor_get_node_for(transform, i); return Prop2DDataEntry::_processor_get_node_for(transform, i);
} }

View File

@ -52,8 +52,8 @@ public:
float get_energy() const; float get_energy() const;
void set_energy(const float value); void set_energy(const float value);
Ref<Texture> get_texture() const; Ref<Texture2D> get_texture() const;
void set_texture(const Ref<Texture> value); void set_texture(const Ref<Texture2D> value);
bool _processor_handles(Node *node); bool _processor_handles(Node *node);
void _processor_process(Ref<Prop2DData> prop_data, Node *node, const Transform2D &transform, Ref<Prop2DDataEntry> entry = Ref<Prop2DDataEntry>()); void _processor_process(Ref<Prop2DData> prop_data, Node *node, const Transform2D &transform, Ref<Prop2DDataEntry> entry = Ref<Prop2DDataEntry>());
@ -71,7 +71,7 @@ private:
int _light_size_y; int _light_size_y;
float _texture_scale; float _texture_scale;
float _energy; float _energy;
Ref<Texture> _texture; Ref<Texture2D> _texture;
}; };
#endif #endif

View File

@ -24,19 +24,19 @@ SOFTWARE.
#include "prop_2d_data.h" #include "prop_2d_data.h"
#include "scene/2d/sprite.h" #include "scene/2d/sprite_2d.h"
Ref<Texture> Prop2DDataSprite::get_texture() const { Ref<Texture2D> Prop2DDataSprite::get_texture() const {
return _texture; return _texture;
} }
void Prop2DDataSprite::set_texture(const Ref<Texture> &value) { void Prop2DDataSprite::set_texture(const Ref<Texture2D> &value) {
_texture = value; _texture = value;
} }
Ref<Texture> Prop2DDataSprite::get_normal_map() const { Ref<Texture2D> Prop2DDataSprite::get_normal_map() const {
return _normal_map; return _normal_map;
} }
void Prop2DDataSprite::set_normal_map(const Ref<Texture> &value) { void Prop2DDataSprite::set_normal_map(const Ref<Texture2D> &value) {
_normal_map = _normal_map; _normal_map = _normal_map;
} }
@ -118,13 +118,13 @@ void Prop2DDataSprite::set_filter_clip(const bool value) {
} }
bool Prop2DDataSprite::_processor_handles(Node *node) { bool Prop2DDataSprite::_processor_handles(Node *node) {
Sprite *s = Object::cast_to<Sprite>(node); Sprite2D *s = Object::cast_to<Sprite2D>(node);
return s; return s;
} }
void Prop2DDataSprite::_processor_process(Ref<Prop2DData> prop_data, Node *node, const Transform2D &transform, Ref<Prop2DDataEntry> entry) { void Prop2DDataSprite::_processor_process(Ref<Prop2DData> prop_data, Node *node, const Transform2D &transform, Ref<Prop2DDataEntry> entry) {
Sprite *s = Object::cast_to<Sprite>(node); Sprite2D *s = Object::cast_to<Sprite2D>(node);
ERR_FAIL_COND(!s); ERR_FAIL_COND(!s);
@ -137,7 +137,7 @@ void Prop2DDataSprite::_processor_process(Ref<Prop2DData> prop_data, Node *node,
} }
l->set_texture(s->get_texture()); 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_centered(s->is_centered());
l->set_offset(s->get_offset()); l->set_offset(s->get_offset());
@ -150,7 +150,7 @@ void Prop2DDataSprite::_processor_process(Ref<Prop2DData> prop_data, Node *node,
l->set_animation_frame(s->get_frame()); l->set_animation_frame(s->get_frame());
l->set_animation_frame_coords(s->get_frame_coords()); 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_region(s->get_region_rect());
l->set_filter_clip(s->is_region_filter_clip_enabled()); l->set_filter_clip(s->is_region_filter_clip_enabled());
@ -158,16 +158,16 @@ void Prop2DDataSprite::_processor_process(Ref<Prop2DData> prop_data, Node *node,
} }
Node *Prop2DDataSprite::_processor_get_node_for(const Transform2D &transform, Node *node) { Node *Prop2DDataSprite::_processor_get_node_for(const Transform2D &transform, Node *node) {
Sprite *n; Sprite2D *n;
if (node) { if (node) {
n = Object::cast_to<Sprite>(node); n = Object::cast_to<Sprite2D>(node);
} else { } else {
n = memnew(Sprite()); n = memnew(Sprite2D());
} }
n->set_texture(get_texture()); 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_centered(get_centered());
n->set_offset(get_offset()); 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(get_animation_frame());
n->set_frame_coords(get_animation_frame_coords()); 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_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); return Prop2DDataEntry::_processor_get_node_for(transform, n);
} }

View File

@ -39,11 +39,11 @@ class Prop2DDataSprite : public Prop2DDataEntry {
GDCLASS(Prop2DDataSprite, Prop2DDataEntry); GDCLASS(Prop2DDataSprite, Prop2DDataEntry);
public: public:
Ref<Texture> get_texture() const; Ref<Texture2D> get_texture() const;
void set_texture(const Ref<Texture> &value); void set_texture(const Ref<Texture2D> &value);
Ref<Texture> get_normal_map() const; Ref<Texture2D> get_normal_map() const;
void set_normal_map(const Ref<Texture> &value); void set_normal_map(const Ref<Texture2D> &value);
bool get_centered() const; bool get_centered() const;
void set_centered(const bool value); void set_centered(const bool value);
@ -89,8 +89,8 @@ protected:
static void _bind_methods(); static void _bind_methods();
private: private:
Ref<Texture> _texture; Ref<Texture2D> _texture;
Ref<Texture> _normal_map; Ref<Texture2D> _normal_map;
bool _centered; bool _centered;
Vector2 _offset; Vector2 _offset;

View File

@ -164,7 +164,7 @@ Ref<Prop2DMaterialCache> Prop2DCache::material_cache_get(const Ref<Prop2DData> &
ERR_FAIL_COND_V(!prop.is_valid(), Ref<Prop2DMaterialCache>()); ERR_FAIL_COND_V(!prop.is_valid(), Ref<Prop2DMaterialCache>());
//get pointer's value as uint64 //get pointer's value as uint64
uint64_t k = make_uint64_t<const Prop2DData *>(*prop); uint64_t k = hash_make_uint64_t<const Prop2DData *>(*prop);
_material_cache_mutex.lock(); _material_cache_mutex.lock();
@ -178,7 +178,7 @@ Ref<Prop2DMaterialCache> Prop2DCache::material_cache_get(const Ref<Prop2DData> &
return m; return m;
} }
Prop2DMaterialCache *p = Object::cast_to<Prop2DMaterialCache>(ClassDB::instance(_default_prop_material_cache_class)); Prop2DMaterialCache *p = Object::cast_to<Prop2DMaterialCache>(ClassDB::instantiate(_default_prop_material_cache_class));
if (!p) { if (!p) {
ERR_PRINT("Can't instance the given Prop2DMaterialCache! class_name: " + String(_default_prop_material_cache_class)); ERR_PRINT("Can't instance the given Prop2DMaterialCache! class_name: " + String(_default_prop_material_cache_class));
@ -194,7 +194,7 @@ Ref<Prop2DMaterialCache> Prop2DCache::material_cache_get(const Ref<Prop2DData> &
} }
void Prop2DCache::material_cache_unref(const Ref<Prop2DData> &prop) { void Prop2DCache::material_cache_unref(const Ref<Prop2DData> &prop) {
//get pointer's value as uint64 //get pointer's value as uint64
uint64_t k = make_uint64_t<const Prop2DData *>(*prop); uint64_t k = hash_make_uint64_t<const Prop2DData *>(*prop);
_material_cache_mutex.lock(); _material_cache_mutex.lock();
@ -220,7 +220,7 @@ Ref<Prop2DMaterialCache> Prop2DCache::tiled_wall_material_cache_get(const Ref<Ti
ERR_FAIL_COND_V(!twd.is_valid(), Ref<Prop2DMaterialCache>()); ERR_FAIL_COND_V(!twd.is_valid(), Ref<Prop2DMaterialCache>());
//get pointer's value as uint64 //get pointer's value as uint64
uint64_t k = make_uint64_t<const TiledWall2DData *>(*twd); uint64_t k = hash_make_uint64_t<const TiledWall2DData *>(*twd);
_tiled_wall_material_cache_mutex.lock(); _tiled_wall_material_cache_mutex.lock();
@ -234,7 +234,7 @@ Ref<Prop2DMaterialCache> Prop2DCache::tiled_wall_material_cache_get(const Ref<Ti
return m; return m;
} }
Prop2DMaterialCache *p = Object::cast_to<Prop2DMaterialCache>(ClassDB::instance(_default_prop_material_cache_class)); Prop2DMaterialCache *p = Object::cast_to<Prop2DMaterialCache>(ClassDB::instantiate(_default_prop_material_cache_class));
if (!p) { if (!p) {
ERR_PRINT("Can't instance the given Prop2DMaterialCache! class_name: " + String(_default_prop_material_cache_class)); ERR_PRINT("Can't instance the given Prop2DMaterialCache! class_name: " + String(_default_prop_material_cache_class));
@ -250,7 +250,7 @@ Ref<Prop2DMaterialCache> Prop2DCache::tiled_wall_material_cache_get(const Ref<Ti
} }
void Prop2DCache::tiled_wall_material_cache_unref(const Ref<TiledWall2DData> &twd) { void Prop2DCache::tiled_wall_material_cache_unref(const Ref<TiledWall2DData> &twd) {
//get pointer's value as uint64 //get pointer's value as uint64
uint64_t k = make_uint64_t<const TiledWall2DData *>(*twd); uint64_t k = hash_make_uint64_t<const TiledWall2DData *>(*twd);
_tiled_wall_material_cache_mutex.lock(); _tiled_wall_material_cache_mutex.lock();
@ -285,7 +285,7 @@ Ref<Prop2DMaterialCache> Prop2DCache::material_cache_custom_key_get(const uint64
return m; return m;
} }
Prop2DMaterialCache *p = Object::cast_to<Prop2DMaterialCache>(ClassDB::instance(_default_prop_material_cache_class)); Prop2DMaterialCache *p = Object::cast_to<Prop2DMaterialCache>(ClassDB::instantiate(_default_prop_material_cache_class));
if (!p) { if (!p) {
ERR_PRINT("Can't instance the given Prop2DMaterialCache! class_name: " + String(_default_prop_material_cache_class)); 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<Resource> Prop2DCache::load_resource(const String &path, const String &type_hint) { Ref<Resource> Prop2DCache::load_resource(const String &path, const String &type_hint) {
_ResourceLoader *rl = _ResourceLoader::get_singleton(); return ResourceLoader::load(path, type_hint);
#if VERSION_MAJOR < 4
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, type_hint);
ERR_FAIL_COND_V(!resl.is_valid(), Ref<Resource>());
resl->wait();
return resl->get_resource();
#else
return rl->load(path, type_hint);
#endif
} }
Prop2DCache::Prop2DCache() { Prop2DCache::Prop2DCache() {
@ -370,7 +358,7 @@ Prop2DCache::~Prop2DCache() {
void Prop2DCache::_bind_methods() { 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("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); 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("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); ClassDB::bind_method(D_METHOD("set_default_prop_material_cache_class", "cls_name"), &Prop2DCache::set_default_prop_material_cache_class);

View File

@ -112,9 +112,9 @@ protected:
StringName _default_prop_material_cache_class; StringName _default_prop_material_cache_class;
Map<uint64_t, Ref<Prop2DMaterialCache>> _material_cache; HashMap<uint64_t, Ref<Prop2DMaterialCache>> _material_cache;
Map<uint64_t, Ref<Prop2DMaterialCache>> _tiled_wall_material_cache; HashMap<uint64_t, Ref<Prop2DMaterialCache>> _tiled_wall_material_cache;
Map<uint64_t, Ref<Prop2DMaterialCache>> _custom_keyed_material_cache; HashMap<uint64_t, Ref<Prop2DMaterialCache>> _custom_keyed_material_cache;
Mutex _material_cache_mutex; Mutex _material_cache_mutex;
Mutex _tiled_wall_material_cache_mutex; Mutex _tiled_wall_material_cache_mutex;

View File

@ -34,7 +34,7 @@ SOFTWARE.
#include "scene/3d/room_manager.h" #include "scene/3d/room_manager.h"
#endif #endif
#include "scene/3d/mesh_instance.h" #include "scene/3d/mesh_instance_3d.h"
#if MESH_DATA_RESOURCE_PRESENT #if MESH_DATA_RESOURCE_PRESENT
#include "../../mesh_data_resource/nodes/mesh_data_instance.h" #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) { void Prop2DUtils::remove_processor(const int index) {
ERR_FAIL_INDEX(index, Prop2DUtils::_processors.size()); ERR_FAIL_INDEX(index, Prop2DUtils::_processors.size());
Prop2DUtils::_processors.remove(index); Prop2DUtils::_processors.remove_at(index);
} }
int Prop2DUtils::get_processor_count() { int Prop2DUtils::get_processor_count() {
return Prop2DUtils::_processors.size(); return Prop2DUtils::_processors.size();

View File

@ -214,7 +214,7 @@ void TiledWall2D::generate_mesh() {
editor_point_vertices.set(i, vertices[i]); 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 #endif
if (vertices.size() == 0) { if (vertices.size() == 0) {
@ -252,7 +252,7 @@ void TiledWall2D::draw() {
return; 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() { TiledWall2D::TiledWall2D() {