Work on fixing compile.

This commit is contained in:
Relintai 2023-01-09 14:10:32 +01:00
parent 38e4bb3203
commit 60c28df4a9
18 changed files with 115 additions and 178 deletions

View File

@ -54,14 +54,14 @@ GroundClutter2D::~GroundClutter2D() {
void GroundClutter2D::_bind_methods() { void GroundClutter2D::_bind_methods() {
#ifdef TEXTURE_PACKER_PRESENT #ifdef TEXTURE_PACKER_PRESENT
BIND_VMETHOD(MethodInfo("_add_textures_to", PropertyInfo(Variant::OBJECT, "packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker"))); //BIND_VMETHOD(MethodInfo("_add_textures_to", PropertyInfo(Variant::OBJECT, "packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker")));
ClassDB::bind_method(D_METHOD("add_textures_to", "packer"), &GroundClutter2D::add_textures_to); ClassDB::bind_method(D_METHOD("add_textures_to", "packer"), &GroundClutter2D::add_textures_to);
#endif #endif
#ifdef VOXELMAN_PRESENT #ifdef VOXELMAN_PRESENT
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "should"), "_should_spawn", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"))); //BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "should"), "_should_spawn", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z")));
BIND_VMETHOD(MethodInfo("_add_meshes_to", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"))); //BIND_VMETHOD(MethodInfo("_add_meshes_to", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z")));
ClassDB::bind_method(D_METHOD("should_spawn", "chunk", "x", "y", "z"), &GroundClutter2D::should_spawn); ClassDB::bind_method(D_METHOD("should_spawn", "chunk", "x", "y", "z"), &GroundClutter2D::should_spawn);
ClassDB::bind_method(D_METHOD("add_meshes_to", "mesher", "chunk", "x", "y", "z"), &GroundClutter2D::add_meshes_to); ClassDB::bind_method(D_METHOD("add_meshes_to", "mesher", "chunk", "x", "y", "z"), &GroundClutter2D::add_meshes_to);

View File

@ -96,7 +96,7 @@ void Prop2DTextureJob::_bind_methods() {
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &Prop2DTextureJob::should_do, DEFVAL(false)); ClassDB::bind_method(D_METHOD("should_do", "just_check"), &Prop2DTextureJob::should_do, DEFVAL(false));
ClassDB::bind_method(D_METHOD("should_return"), &Prop2DTextureJob::should_return); ClassDB::bind_method(D_METHOD("should_return"), &Prop2DTextureJob::should_return);
BIND_VMETHOD(MethodInfo("_execute")); //BIND_VMETHOD(MethodInfo("_execute"));
ClassDB::bind_method(D_METHOD("execute"), &Prop2DTextureJob::execute); ClassDB::bind_method(D_METHOD("execute"), &Prop2DTextureJob::execute);
ADD_SIGNAL(MethodInfo("completed")); ADD_SIGNAL(MethodInfo("completed"));

View File

@ -35,8 +35,8 @@ SOFTWARE.
#include "core/color.h" #include "core/color.h"
#endif #endif
class Prop2DLight : public Reference { class Prop2DLight : public RefCounted {
GDCLASS(Prop2DLight, Reference); GDCLASS(Prop2DLight, RefCounted);
public: public:
Vector2 get_position(); Vector2 get_position();

View File

@ -292,7 +292,7 @@ void Prop2DMaterialCache::_bind_methods() {
ClassDB::bind_method(D_METHOD("inc_ref_count"), &Prop2DMaterialCache::inc_ref_count); ClassDB::bind_method(D_METHOD("inc_ref_count"), &Prop2DMaterialCache::inc_ref_count);
ClassDB::bind_method(D_METHOD("dec_ref_count"), &Prop2DMaterialCache::dec_ref_count); ClassDB::bind_method(D_METHOD("dec_ref_count"), &Prop2DMaterialCache::dec_ref_count);
BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"))); //BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")));
ClassDB::bind_method(D_METHOD("material_get"), &Prop2DMaterialCache::material_get); ClassDB::bind_method(D_METHOD("material_get"), &Prop2DMaterialCache::material_get);
ClassDB::bind_method(D_METHOD("material_set", "value"), &Prop2DMaterialCache::material_set); ClassDB::bind_method(D_METHOD("material_set", "value"), &Prop2DMaterialCache::material_set);

View File

@ -151,7 +151,7 @@ void Prop2DMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
Ref<ShaderMaterial> shmat = m; Ref<ShaderMaterial> shmat = m;
if (shmat.is_valid()) { if (shmat.is_valid()) {
shmat->set_shader_param("texture_albedo", texture); shmat->set_shader_parameter("texture_albedo", texture);
} }
} }

View File

@ -37,7 +37,6 @@ SOFTWARE.
class Prop2DESSEntity : public Spatial { class Prop2DESSEntity : public Spatial {
GDCLASS(Prop2DESSEntity, Spatial); GDCLASS(Prop2DESSEntity, Spatial);
OBJ_CATEGORY("Prop2Ds");
public: public:
Prop2DESSEntity(); Prop2DESSEntity();

View File

@ -102,7 +102,7 @@ void Prop2DInstance::_build() {
//this way we won't delete the user's nodes //this way we won't delete the user's nodes
if (n->get_owner() == NULL) { if (n->get_owner() == NULL) {
n->queue_delete(); n->queue_free();
} }
} }
@ -169,7 +169,7 @@ void Prop2DInstance::_prop_preprocess(Transform2D transform, const Ref<Prop2DDat
if (!sc.is_valid()) if (!sc.is_valid())
continue; continue;
Node *n = sc->instance(); Node *n = sc->instantiate();
add_child(n); add_child(n);
Node2D *n2d = Object::cast_to<Node2D>(n); Node2D *n2d = Object::cast_to<Node2D>(n);
@ -272,15 +272,15 @@ void Prop2DInstance::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
BIND_VMETHOD(MethodInfo("_prop_preprocess", //BIND_VMETHOD(MethodInfo("_prop_preprocess",
PropertyInfo(Variant::TRANSFORM, "tarnsform"), // PropertyInfo(Variant::TRANSFORM, "tarnsform"),
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DData"))); // PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DData")));
ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &Prop2DInstance::prop_preprocess); ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &Prop2DInstance::prop_preprocess);
ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &Prop2DInstance::_prop_preprocess); ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &Prop2DInstance::_prop_preprocess);
//--- //---
BIND_VMETHOD(MethodInfo("_init_materials")); //BIND_VMETHOD(MethodInfo("_init_materials"));
ClassDB::bind_method(D_METHOD("init_materials"), &Prop2DInstance::init_materials); ClassDB::bind_method(D_METHOD("init_materials"), &Prop2DInstance::init_materials);
ClassDB::bind_method(D_METHOD("_init_materials"), &Prop2DInstance::_init_materials); ClassDB::bind_method(D_METHOD("_init_materials"), &Prop2DInstance::_init_materials);
@ -290,8 +290,8 @@ void Prop2DInstance::_bind_methods() {
ClassDB::bind_method(D_METHOD("queue_build"), &Prop2DInstance::queue_build); ClassDB::bind_method(D_METHOD("queue_build"), &Prop2DInstance::queue_build);
ClassDB::bind_method(D_METHOD("build_finished"), &Prop2DInstance::build_finished); ClassDB::bind_method(D_METHOD("build_finished"), &Prop2DInstance::build_finished);
BIND_VMETHOD(MethodInfo("_build")); //BIND_VMETHOD(MethodInfo("_build"));
BIND_VMETHOD(MethodInfo("_build_finished")); //BIND_VMETHOD(MethodInfo("_build_finished"));
ClassDB::bind_method(D_METHOD("_build"), &Prop2DInstance::_build); ClassDB::bind_method(D_METHOD("_build"), &Prop2DInstance::_build);
ClassDB::bind_method(D_METHOD("_build_finished"), &Prop2DInstance::_build_finished); ClassDB::bind_method(D_METHOD("_build_finished"), &Prop2DInstance::_build_finished);

View File

@ -26,8 +26,6 @@ SOFTWARE.
#include "./props/prop_2d_data.h" #include "./props/prop_2d_data.h"
#include "../opensimplex/open_simplex_noise.h"
const String Prop2DInstanceJob::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process"; const String Prop2DInstanceJob::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process";
Prop2DInstanceJob::ActiveBuildPhaseType Prop2DInstanceJob::get_build_phase_type() { Prop2DInstanceJob::ActiveBuildPhaseType Prop2DInstanceJob::get_build_phase_type() {
@ -149,8 +147,8 @@ Prop2DInstanceJob::~Prop2DInstanceJob() {
} }
void Prop2DInstanceJob::_bind_methods() { void Prop2DInstanceJob::_bind_methods() {
BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta"))); //BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta")));
BIND_VMETHOD(MethodInfo("_physics_process", PropertyInfo(Variant::REAL, "delta"))); //BIND_VMETHOD(MethodInfo("_physics_process", PropertyInfo(Variant::REAL, "delta")));
ClassDB::bind_method(D_METHOD("get_build_phase_type"), &Prop2DInstanceJob::get_build_phase_type); ClassDB::bind_method(D_METHOD("get_build_phase_type"), &Prop2DInstanceJob::get_build_phase_type);
ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &Prop2DInstanceJob::set_build_phase_type); ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &Prop2DInstanceJob::set_build_phase_type);
@ -168,14 +166,14 @@ void Prop2DInstanceJob::_bind_methods() {
ClassDB::bind_method(D_METHOD("finished"), &Prop2DInstanceJob::finished); ClassDB::bind_method(D_METHOD("finished"), &Prop2DInstanceJob::finished);
BIND_VMETHOD(MethodInfo("_reset")); //BIND_VMETHOD(MethodInfo("_reset"));
ClassDB::bind_method(D_METHOD("reset"), &Prop2DInstanceJob::reset); ClassDB::bind_method(D_METHOD("reset"), &Prop2DInstanceJob::reset);
ClassDB::bind_method(D_METHOD("_reset"), &Prop2DInstanceJob::_reset); ClassDB::bind_method(D_METHOD("_reset"), &Prop2DInstanceJob::_reset);
ClassDB::bind_method(D_METHOD("_execute"), &Prop2DInstanceJob::_execute); ClassDB::bind_method(D_METHOD("_execute"), &Prop2DInstanceJob::_execute);
BIND_VMETHOD(MethodInfo("_execute_phase")); //BIND_VMETHOD(MethodInfo("_execute_phase"));
ClassDB::bind_method(D_METHOD("execute_phase"), &Prop2DInstanceJob::execute_phase); ClassDB::bind_method(D_METHOD("execute_phase"), &Prop2DInstanceJob::execute_phase);
ClassDB::bind_method(D_METHOD("_execute_phase"), &Prop2DInstanceJob::_execute_phase); ClassDB::bind_method(D_METHOD("_execute_phase"), &Prop2DInstanceJob::_execute_phase);
@ -204,7 +202,7 @@ void Prop2DInstanceJob::_bind_methods() {
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &Prop2DInstanceJob::should_do, DEFVAL(false)); ClassDB::bind_method(D_METHOD("should_do", "just_check"), &Prop2DInstanceJob::should_do, DEFVAL(false));
ClassDB::bind_method(D_METHOD("should_return"), &Prop2DInstanceJob::should_return); ClassDB::bind_method(D_METHOD("should_return"), &Prop2DInstanceJob::should_return);
BIND_VMETHOD(MethodInfo("_execute")); //BIND_VMETHOD(MethodInfo("_execute"));
ClassDB::bind_method(D_METHOD("execute"), &Prop2DInstanceJob::execute); ClassDB::bind_method(D_METHOD("execute"), &Prop2DInstanceJob::execute);
ADD_SIGNAL(MethodInfo("completed")); ADD_SIGNAL(MethodInfo("completed"));

View File

@ -46,7 +46,7 @@ typedef class RenderingServer VS;
#include "./props/prop_2d_data_scene.h" #include "./props/prop_2d_data_scene.h"
#include "lights/prop_2d_light.h" #include "lights/prop_2d_light.h"
#include "material_cache/prop_2d_material_cache.h" #include "material_cache/prop_2d_material_cache.h"
#include "scene/3d/camera.h" #include "scene/3d/camera_3d.h"
#if TEXTURE_PACKER_PRESENT #if TEXTURE_PACKER_PRESENT
#include "./singleton/prop_2d_cache.h" #include "./singleton/prop_2d_cache.h"
@ -60,7 +60,7 @@ typedef class RenderingServer VS;
#include "tiled_wall/tiled_wall_2d_data.h" #include "tiled_wall/tiled_wall_2d_data.h"
#include "scene/resources/box_shape.h" #include "scene/resources/box_shape_3d.h"
bool Prop2DInstanceMerger::get_building() { bool Prop2DInstanceMerger::get_building() {
return _building; return _building;
@ -325,7 +325,7 @@ void Prop2DInstanceMerger::_build() {
//this way we won't delete the user's nodes //this way we won't delete the user's nodes
if (n->get_owner() == NULL) { if (n->get_owner() == NULL) {
n->queue_delete(); n->queue_free();
} }
} }
@ -445,7 +445,7 @@ void Prop2DInstanceMerger::_prop_preprocess(Transform2D transform, const Ref<Pro
if (!sc.is_valid()) if (!sc.is_valid())
continue; continue;
Node *n = sc->instance(); Node *n = sc->instantiate();
add_child(n); add_child(n);
n->set_owner(this); n->set_owner(this);
@ -640,7 +640,7 @@ void Prop2DInstanceMerger::_notification(int p_what) {
} }
void Prop2DInstanceMerger::_bind_methods() { void Prop2DInstanceMerger::_bind_methods() {
BIND_VMETHOD(MethodInfo("_create_job")); //BIND_VMETHOD(MethodInfo("_create_job"));
ClassDB::bind_method(D_METHOD("_create_job"), &Prop2DInstanceMerger::_create_job); ClassDB::bind_method(D_METHOD("_create_job"), &Prop2DInstanceMerger::_create_job);
ClassDB::bind_method(D_METHOD("get_job"), &Prop2DInstanceMerger::get_job); ClassDB::bind_method(D_METHOD("get_job"), &Prop2DInstanceMerger::get_job);

View File

@ -29,7 +29,7 @@ SOFTWARE.
#include "prop_2d_instance.h" #include "prop_2d_instance.h"
#include "prop_2d_instance_merger.h" #include "prop_2d_instance_merger.h"
#include "prop_2d_mesher.h" #include "prop_2d_mesher.h"
#include "scene/resources/shape.h" #include "scene/resources/shape_3d.h"
#include "singleton/prop_2d_cache.h" #include "singleton/prop_2d_cache.h"
#ifdef MESH_DATA_RESOURCE_PRESENT #ifdef MESH_DATA_RESOURCE_PRESENT
@ -354,12 +354,8 @@ void Prop2DInstanceProp2DJob::phase_steps() {
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
RID mesh_rid = _prop_instace->mesh_get(i); RID mesh_rid = _prop_instace->mesh_get(i);
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
#if !GODOT4 RS::get_singleton()->mesh_clear(mesh_rid);
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(mesh_rid);
#endif
} }
} }
} }
@ -379,23 +375,23 @@ void Prop2DInstanceProp2DJob::step_type_normal() {
RID mesh_rid = _prop_instace->mesh_get(0); RID mesh_rid = _prop_instace->mesh_get(0);
VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); RS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
Ref<Material> lmat = _material_cache->material_get(); Ref<Material> lmat = _material_cache->material_get();
if (lmat.is_valid()) { if (lmat.is_valid()) {
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid()); RenderingServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
} }
} }
Array Prop2DInstanceProp2DJob::merge_mesh_array(Array arr) const { Array Prop2DInstanceProp2DJob::merge_mesh_array(Array arr) const {
ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr); ERR_FAIL_COND_V(arr.size() != RenderingServer::ARRAY_MAX, arr);
PoolVector3Array verts = arr[VisualServer::ARRAY_VERTEX]; PackedVector3Array verts = arr[RenderingServer::ARRAY_VERTEX];
PoolVector3Array normals = arr[VisualServer::ARRAY_NORMAL]; PackedVector3Array normals = arr[RenderingServer::ARRAY_NORMAL];
PoolVector2Array uvs = arr[VisualServer::ARRAY_TEX_UV]; PackedVector2Array uvs = arr[RenderingServer::ARRAY_TEX_UV];
PoolColorArray colors = arr[VisualServer::ARRAY_COLOR]; PackedColorArray colors = arr[RenderingServer::ARRAY_COLOR];
PoolIntArray indices = arr[VisualServer::ARRAY_INDEX]; PackedInt32Array indices = arr[RenderingServer::ARRAY_INDEX];
bool has_normals = normals.size() > 0; bool has_normals = normals.size() > 0;
bool has_uvs = uvs.size() > 0; bool has_uvs = uvs.size() > 0;
@ -417,14 +413,14 @@ Array Prop2DInstanceProp2DJob::merge_mesh_array(Array arr) const {
int rem = equals[k]; int rem = equals[k];
int remk = rem - k; int remk = rem - k;
verts.remove(remk); verts.remove_at(remk);
if (has_normals) if (has_normals)
normals.remove(remk); normals.remove_at(remk);
if (has_uvs) if (has_uvs)
uvs.remove(remk); uvs.remove_at(remk);
if (has_colors) if (has_colors)
colors.remove(remk); colors.remove_at(remk);
for (int j = 0; j < indices.size(); ++j) { for (int j = 0; j < indices.size(); ++j) {
int indx = indices[j]; int indx = indices[j];
@ -439,37 +435,37 @@ Array Prop2DInstanceProp2DJob::merge_mesh_array(Array arr) const {
++i; ++i;
} }
arr[VisualServer::ARRAY_VERTEX] = verts; arr[RenderingServer::ARRAY_VERTEX] = verts;
if (has_normals) if (has_normals)
arr[VisualServer::ARRAY_NORMAL] = normals; arr[RenderingServer::ARRAY_NORMAL] = normals;
if (has_uvs) if (has_uvs)
arr[VisualServer::ARRAY_TEX_UV] = uvs; arr[RenderingServer::ARRAY_TEX_UV] = uvs;
if (has_colors) if (has_colors)
arr[VisualServer::ARRAY_COLOR] = colors; arr[RenderingServer::ARRAY_COLOR] = colors;
arr[VisualServer::ARRAY_INDEX] = indices; arr[RenderingServer::ARRAY_INDEX] = indices;
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<Texture> tex, const float mul_color) const {
ERR_FAIL_COND_V(arr.size() != VisualServer::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);
Ref<Image> img = tex->get_data(); Ref<Image> img = tex->get_image();
ERR_FAIL_COND_V(!img.is_valid(), arr); ERR_FAIL_COND_V(!img.is_valid(), arr);
Vector2 imgsize = img->get_size(); Vector2 imgsize = img->get_size();
PoolVector2Array uvs = arr[VisualServer::ARRAY_TEX_UV]; PackedVector2Array uvs = arr[RenderingServer::ARRAY_TEX_UV];
PoolColorArray colors = arr[VisualServer::ARRAY_COLOR]; PackedColorArray colors = arr[RenderingServer::ARRAY_COLOR];
if (colors.size() < uvs.size()) if (colors.size() < uvs.size())
colors.resize(uvs.size()); colors.resize(uvs.size());
#if !GODOT4 #if !GODOT4
img->lock(); //img->lock();
#endif #endif
for (int i = 0; i < uvs.size(); ++i) { for (int i = 0; i < uvs.size(); ++i) {
@ -485,10 +481,10 @@ Array Prop2DInstanceProp2DJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, c
} }
#if !GODOT4 #if !GODOT4
img->unlock(); //img->unlock();
#endif #endif
arr[VisualServer::ARRAY_COLOR] = colors; arr[RenderingServer::ARRAY_COLOR] = colors;
return arr; return arr;
} }
@ -505,12 +501,8 @@ void Prop2DInstanceProp2DJob::reset_meshes() {
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
RID mesh_rid = _prop_instace->mesh_get(i); RID mesh_rid = _prop_instace->mesh_get(i);
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
#if !GODOT4 RS::get_singleton()->mesh_clear(mesh_rid);
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(mesh_rid);
#endif
} }
} }
} }

View File

@ -23,7 +23,7 @@ SOFTWARE.
#include "prop_2d_mesher.h" #include "prop_2d_mesher.h"
#include "lights/prop_2d_light.h" #include "lights/prop_2d_light.h"
#include "modules/opensimplex/open_simplex_noise.h" #include "modules/noise/fastnoise_lite.h"
#include "material_cache/prop_2d_material_cache.h" #include "material_cache/prop_2d_material_cache.h"
#include "tiled_wall/tiled_wall_2d_data.h" #include "tiled_wall/tiled_wall_2d_data.h"
@ -129,15 +129,15 @@ _FORCE_INLINE_ void Prop2DMesher::set_build_flags(const int flags) {
_build_flags = flags; _build_flags = flags;
if ((_build_flags & Prop2DMesher::BUILD_FLAG_USE_LIGHTING) != 0) { if ((_build_flags & Prop2DMesher::BUILD_FLAG_USE_LIGHTING) != 0) {
_format |= VisualServer::ARRAY_FORMAT_COLOR; _format |= RenderingServer::ARRAY_FORMAT_COLOR;
} else { } else {
_format ^= VisualServer::ARRAY_FORMAT_COLOR; _format ^= RenderingServer::ARRAY_FORMAT_COLOR;
} }
} }
Array Prop2DMesher::build_mesh() { Array Prop2DMesher::build_mesh() {
Array a; Array a;
a.resize(VisualServer::ARRAY_MAX); a.resize(RenderingServer::ARRAY_MAX);
if (_vertices.size() == 0) { if (_vertices.size() == 0) {
//Nothing to do //Nothing to do
@ -147,87 +147,43 @@ Array Prop2DMesher::build_mesh() {
{ {
PoolVector<Vector2> array; PoolVector<Vector2> array;
array.resize(_vertices.size()); array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) { for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].vertex;
#else
array.set(i, _vertices[i].vertex); array.set(i, _vertices[i].vertex);
#endif
} }
#if !GODOT4 a[RenderingServer::ARRAY_VERTEX] = array;
w.release();
#endif
a[VisualServer::ARRAY_VERTEX] = array;
} }
if ((_format & VisualServer::ARRAY_FORMAT_COLOR) != 0) { if ((_format & RenderingServer::ARRAY_FORMAT_COLOR) != 0) {
PoolVector<Color> array; PoolVector<Color> array;
array.resize(_vertices.size()); array.resize(_vertices.size());
#if !GODOT4
PoolVector<Color>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) { for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].color;
#else
array.set(i, _vertices[i].color); array.set(i, _vertices[i].color);
#endif
} }
#if !GODOT4 a[RenderingServer::ARRAY_COLOR] = array;
w.release();
#endif
a[VisualServer::ARRAY_COLOR] = array;
} }
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV) != 0) { if ((_format & RenderingServer::ARRAY_FORMAT_TEX_UV) != 0) {
PoolVector<Vector2> array; PoolVector<Vector2> array;
array.resize(_vertices.size()); array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) { for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].uv;
#else
array.set(i, _vertices[i].uv); array.set(i, _vertices[i].uv);
#endif
} }
#if !GODOT4 a[RenderingServer::ARRAY_TEX_UV] = array;
w.release();
#endif
a[VisualServer::ARRAY_TEX_UV] = array;
} }
if (_indices.size() > 0) { if (_indices.size() > 0) {
PoolVector<int> array; PoolVector<int> array;
array.resize(_indices.size()); array.resize(_indices.size());
#if !GODOT4
PoolVector<int>::Write w = array.write();
#endif
for (int i = 0; i < _indices.size(); ++i) { for (int i = 0; i < _indices.size(); ++i) {
#if !GODOT4
w[i] = _indices[i];
#else
array.set(i, _indices[i]); array.set(i, _indices[i]);
#endif
} }
#if !GODOT4 a[RenderingServer::ARRAY_INDEX] = array;
w.release();
#endif
a[VisualServer::ARRAY_INDEX] = array;
} }
return a; return a;
@ -236,7 +192,7 @@ Array Prop2DMesher::build_mesh() {
void Prop2DMesher::build_mesh_into(RID mesh) { void Prop2DMesher::build_mesh_into(RID mesh) {
ERR_FAIL_COND(mesh == RID()); ERR_FAIL_COND(mesh == RID());
VS::get_singleton()->mesh_clear(mesh); RS::get_singleton()->mesh_clear(mesh);
if (_vertices.size() == 0) { if (_vertices.size() == 0) {
//Nothing to do //Nothing to do
@ -245,10 +201,10 @@ void Prop2DMesher::build_mesh_into(RID mesh) {
Array arr = build_mesh(); Array arr = build_mesh();
VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VisualServer::PRIMITIVE_TRIANGLES, arr); RS::get_singleton()->mesh_add_surface_from_arrays(mesh, RenderingServer::PRIMITIVE_TRIANGLES, arr);
if (_material.is_valid()) if (_material.is_valid())
VS::get_singleton()->mesh_surface_set_material(mesh, 0, _material->get_rid()); RS::get_singleton()->mesh_surface_set_material(mesh, 0, _material->get_rid());
} }
void Prop2DMesher::remove_doubles() { void Prop2DMesher::remove_doubles() {
@ -316,7 +272,7 @@ void Prop2DMesher::remove_doubles_hashed() {
for (int j = 0; j < indices.size(); ++j) { for (int j = 0; j < indices.size(); ++j) {
int index = indices[j]; int index = indices[j];
hashes.remove(index); hashes.remove_at(index);
_vertices.remove_at(index); _vertices.remove_at(index);
//make all indices that were bigger than the one we replaced one lower //make all indices that were bigger than the one we replaced one lower
@ -1027,7 +983,7 @@ Vector2 Prop2DMesher::get_vertex(const int idx) const {
} }
void Prop2DMesher::remove_vertex(const int idx) { void Prop2DMesher::remove_vertex(const int idx) {
_vertices.remove(idx); _vertices.remove_at(idx);
} }
PoolVector<Color> Prop2DMesher::get_colors() const { PoolVector<Color> Prop2DMesher::get_colors() const {
@ -1113,7 +1069,7 @@ int Prop2DMesher::get_index(const int idx) const {
} }
void Prop2DMesher::remove_index(const int idx) { void Prop2DMesher::remove_index(const int idx) {
_indices.remove(idx); _indices.remove_at(idx);
} }
Prop2DMesher::Prop2DMesher() { Prop2DMesher::Prop2DMesher() {
@ -1127,13 +1083,13 @@ Prop2DMesher::Prop2DMesher() {
_build_flags = 0; _build_flags = 0;
_format = VisualServer::ARRAY_FORMAT_TEX_UV; _format = RenderingServer::ARRAY_FORMAT_TEX_UV;
_noise.instantiate(); _noise.instantiate();
//todo add properties for these if needed //todo add properties for these if needed
_noise->set_octaves(4); _noise->set_fractal_octaves(4);
_noise->set_period(30); _noise->set_frequency(30);
_noise->set_persistence(0.3); _noise->set_fractal_lacunarity(0.3);
_rao_scale_factor = 0.6; _rao_scale_factor = 0.6;
_rao_seed = 2134; _rao_seed = 2134;
@ -1157,19 +1113,19 @@ void Prop2DMesher::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_pixels_per_unit"), &Prop2DMesher::get_pixels_per_unit); ClassDB::bind_method(D_METHOD("get_pixels_per_unit"), &Prop2DMesher::get_pixels_per_unit);
ClassDB::bind_method(D_METHOD("set_pixels_per_unit", "value"), &Prop2DMesher::set_pixels_per_unit); ClassDB::bind_method(D_METHOD("set_pixels_per_unit", "value"), &Prop2DMesher::set_pixels_per_unit);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "pixels_per_unit"), "set_pixels_per_unit", "get_pixels_per_unit"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pixels_per_unit"), "set_pixels_per_unit", "get_pixels_per_unit");
ClassDB::bind_method(D_METHOD("get_voxel_scale"), &Prop2DMesher::get_voxel_scale); ClassDB::bind_method(D_METHOD("get_voxel_scale"), &Prop2DMesher::get_voxel_scale);
ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &Prop2DMesher::set_voxel_scale); ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &Prop2DMesher::set_voxel_scale);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "voxel_scale"), "set_voxel_scale", "get_voxel_scale"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "voxel_scale"), "set_voxel_scale", "get_voxel_scale");
ClassDB::bind_method(D_METHOD("get_ao_strength"), &Prop2DMesher::get_ao_strength); ClassDB::bind_method(D_METHOD("get_ao_strength"), &Prop2DMesher::get_ao_strength);
ClassDB::bind_method(D_METHOD("set_ao_strength", "value"), &Prop2DMesher::set_ao_strength); ClassDB::bind_method(D_METHOD("set_ao_strength", "value"), &Prop2DMesher::set_ao_strength);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_strength"), "set_ao_strength", "get_ao_strength"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ao_strength"), "set_ao_strength", "get_ao_strength");
ClassDB::bind_method(D_METHOD("get_base_light_value"), &Prop2DMesher::get_base_light_value); ClassDB::bind_method(D_METHOD("get_base_light_value"), &Prop2DMesher::get_base_light_value);
ClassDB::bind_method(D_METHOD("set_base_light_value", "value"), &Prop2DMesher::set_base_light_value); ClassDB::bind_method(D_METHOD("set_base_light_value", "value"), &Prop2DMesher::set_base_light_value);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base_light_value"), "set_base_light_value", "get_base_light_value"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "base_light_value"), "set_base_light_value", "get_base_light_value");
ClassDB::bind_method(D_METHOD("get_uv_margin"), &Prop2DMesher::get_uv_margin); ClassDB::bind_method(D_METHOD("get_uv_margin"), &Prop2DMesher::get_uv_margin);
ClassDB::bind_method(D_METHOD("set_uv_margin", "value"), &Prop2DMesher::set_uv_margin); ClassDB::bind_method(D_METHOD("set_uv_margin", "value"), &Prop2DMesher::set_uv_margin);
@ -1192,7 +1148,7 @@ void Prop2DMesher::_bind_methods() {
ClassDB::bind_method(D_METHOD("generate_ao"), &Prop2DMesher::generate_ao); ClassDB::bind_method(D_METHOD("generate_ao"), &Prop2DMesher::generate_ao);
ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &Prop2DMesher::get_random_ao); ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &Prop2DMesher::get_random_ao);
BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DMesher"))); //BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DMesher")));
ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &Prop2DMesher::add_mesher); ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &Prop2DMesher::add_mesher);
ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &Prop2DMesher::_add_mesher); ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &Prop2DMesher::_add_mesher);

View File

@ -60,13 +60,13 @@ using PoolVector = Vector<N>;
#include "../terraman_2d/data/terrain_2d_light.h" #include "../terraman_2d/data/terrain_2d_light.h"
#endif #endif
class OpenSimplexNoise; class FastNoiseLite;
class Prop2DLight; class Prop2DLight;
class Prop2DMaterialCache; class Prop2DMaterialCache;
class TiledWall2DData; class TiledWall2DData;
class Prop2DMesher : public Reference { class Prop2DMesher : public RefCounted {
GDCLASS(Prop2DMesher, Reference); GDCLASS(Prop2DMesher, RefCounted);
public: public:
static const String BINDING_STRING_BUILD_FLAGS; static const String BINDING_STRING_BUILD_FLAGS;
@ -229,7 +229,7 @@ protected:
Rect2 _uv_margin; Rect2 _uv_margin;
int _build_flags; int _build_flags;
Ref<OpenSimplexNoise> _noise; Ref<FastNoiseLite> _noise;
float _rao_scale_factor; float _rao_scale_factor;
int _rao_seed; int _rao_seed;

View File

@ -30,14 +30,14 @@ void Prop2DSceneInstance::build() {
//this way we won't delete the user's nodes //this way we won't delete the user's nodes
if (n->get_owner() == NULL) { if (n->get_owner() == NULL) {
n->queue_delete(); n->queue_free();
} }
} }
if (!_scene.is_valid()) if (!_scene.is_valid())
return; return;
Node *n = _scene->instance(); Node *n = _scene->instantiate();
add_child(n); add_child(n);

View File

@ -249,23 +249,23 @@ void Prop2DDataEntry::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_parent_material"), "set_use_parent_material", "get_use_parent_material"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_parent_material"), "set_use_parent_material", "get_use_parent_material");
#if TEXTURE_PACKER_PRESENT #if TEXTURE_PACKER_PRESENT
BIND_VMETHOD(MethodInfo("_add_textures_into", PropertyInfo(Variant::OBJECT, "texture_packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker"))); //BIND_VMETHOD(MethodInfo("_add_textures_into", PropertyInfo(Variant::OBJECT, "texture_packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker")));
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &Prop2DDataEntry::add_textures_into); ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &Prop2DDataEntry::add_textures_into);
#endif #endif
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"));
ClassDB::bind_method(D_METHOD("processor_handles", "node"), &Prop2DDataEntry::processor_handles); ClassDB::bind_method(D_METHOD("processor_handles", "node"), &Prop2DDataEntry::processor_handles);
ClassDB::bind_method(D_METHOD("processor_process", "prop_data", "node", "transform"), &Prop2DDataEntry::processor_process); ClassDB::bind_method(D_METHOD("processor_process", "prop_data", "node", "transform"), &Prop2DDataEntry::processor_process);

View File

@ -44,7 +44,7 @@ SOFTWARE.
#include "../material_cache/prop_2d_material_cache.h" #include "../material_cache/prop_2d_material_cache.h"
#include "../tiled_wall/tiled_wall_2d_data.h" #include "../tiled_wall/tiled_wall_2d_data.h"
#include "core/hashfuncs.h" #include "core/templates/hashfuncs.h"
#if VERSION_MAJOR > 3 #if VERSION_MAJOR > 3

View File

@ -26,7 +26,7 @@
#include "tiled_wall_2d_data.h" #include "tiled_wall_2d_data.h"
#include "../lights/prop_2d_light.h" #include "../lights/prop_2d_light.h"
#include "core/math/geometry.h" #include "core/math/geometry_2d.h"
int TiledWall2D::get_width() const { int TiledWall2D::get_width() const {
return _width; return _width;
@ -63,13 +63,13 @@ Ref<TiledWall2DData> TiledWall2D::get_data() {
} }
void TiledWall2D::set_data(const Ref<TiledWall2DData> &data) { void TiledWall2D::set_data(const Ref<TiledWall2DData> &data) {
if (_data.is_valid()) { if (_data.is_valid()) {
_data->disconnect(CoreStringNames::get_singleton()->changed, this, "refresh"); _data->disconnect(CoreStringNames::get_singleton()->changed, Callable(this, "refresh"));
} }
_data = data; _data = data;
if (_data.is_valid()) { if (_data.is_valid()) {
_data->connect(CoreStringNames::get_singleton()->changed, this, "refresh"); _data->connect(CoreStringNames::get_singleton()->changed, Callable(this, "refresh"));
} }
call_deferred("refresh"); call_deferred("refresh");
@ -79,23 +79,21 @@ Rect2 TiledWall2D::get_rect() const {
return _rect; return _rect;
} }
PoolVector<Face3> TiledWall2D::get_faces(uint32_t p_usage_flags) const { Vector<Face3> TiledWall2D::get_faces(uint32_t p_usage_flags) const {
PoolVector<Face3> faces; Vector<Face3> faces;
if (_mesh_array.size() != Mesh::ARRAY_MAX) { if (_mesh_array.size() != Mesh::ARRAY_MAX) {
return faces; return faces;
} }
PoolVector<Vector3> vertices = _mesh_array[Mesh::ARRAY_VERTEX]; Vector<Vector3> vertices = _mesh_array[Mesh::ARRAY_VERTEX];
PoolVector<int> indices = _mesh_array[Mesh::ARRAY_INDEX]; Vector<int> indices = _mesh_array[Mesh::ARRAY_INDEX];
int ts = indices.size() / 3; int ts = indices.size() / 3;
faces.resize(ts); faces.resize(ts);
PoolVector<Face3>::Write w = faces.write(); Face3 *w = faces.ptrw();
PoolVector<Vector3>::Read rv = vertices.read(); const Vector3 *rv = vertices.ptr();
PoolVector<int>::Read ri = indices.read();
for (int i = 0; i < ts; i++) { for (int i = 0; i < ts; i++) {
int im3 = (i * 3); int im3 = (i * 3);
@ -104,8 +102,6 @@ PoolVector<Face3> TiledWall2D::get_faces(uint32_t p_usage_flags) const {
} }
} }
w.release();
return faces; return faces;
} }
@ -115,7 +111,7 @@ bool TiledWall2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tol
return false; return false;
} }
return Geometry::is_point_in_polygon(p_point, _editor_selection_points); return Geometry2D::is_point_in_polygon(p_point, _editor_selection_points);
} }
bool TiledWall2D::_edit_use_rect() const { bool TiledWall2D::_edit_use_rect() const {
@ -140,7 +136,7 @@ void TiledWall2D::refresh() {
} }
if (_mesh_rid == RID()) { if (_mesh_rid == RID()) {
_mesh_rid = VisualServer::get_singleton()->mesh_create(); _mesh_rid = RenderingServer::get_singleton()->mesh_create();
} }
Ref<Prop2DMaterialCache> old_cache; Ref<Prop2DMaterialCache> old_cache;
@ -187,12 +183,12 @@ void TiledWall2D::refresh() {
void TiledWall2D::generate_mesh() { void TiledWall2D::generate_mesh() {
if (!_data.is_valid()) { if (!_data.is_valid()) {
update(); queue_redraw();
return; return;
} }
if (!_cache.is_valid()) { if (!_cache.is_valid()) {
update(); queue_redraw();
return; return;
} }
@ -204,7 +200,7 @@ void TiledWall2D::generate_mesh() {
_mesh_array = _mesher->build_mesh(); _mesh_array = _mesher->build_mesh();
if (_mesh_array.size() != Mesh::ARRAY_MAX) { if (_mesh_array.size() != Mesh::ARRAY_MAX) {
update(); queue_redraw();
return; return;
} }
@ -222,15 +218,15 @@ void TiledWall2D::generate_mesh() {
#endif #endif
if (vertices.size() == 0) { if (vertices.size() == 0) {
update(); queue_redraw();
return; return;
} }
VisualServer::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, _mesh_array); RenderingServer::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, _mesh_array);
_aabb.size = Vector3(_width, _height, 0); _aabb.size = Vector3(_width, _height, 0);
update(); queue_redraw();
} }
void TiledWall2D::clear_mesh() { void TiledWall2D::clear_mesh() {
@ -239,18 +235,14 @@ void TiledWall2D::clear_mesh() {
_mesh_array.clear(); _mesh_array.clear();
if (_mesh_rid != RID()) { if (_mesh_rid != RID()) {
if (VS::get_singleton()->mesh_get_surface_count(_mesh_rid) > 0) if (RS::get_singleton()->mesh_get_surface_count(_mesh_rid) > 0)
#if VERSION_MAJOR < 4 RS::get_singleton()->mesh_clear(_mesh_rid);
VS::get_singleton()->mesh_remove_surface(_mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(_mesh_rid);
#endif
} }
} }
void TiledWall2D::free_mesh() { void TiledWall2D::free_mesh() {
if (_mesh_rid != RID()) { if (_mesh_rid != RID()) {
VS::get_singleton()->free(_mesh_rid); RS::get_singleton()->free(_mesh_rid);
_mesh_rid = RID(); _mesh_rid = RID();
} }
} }
@ -260,7 +252,7 @@ void TiledWall2D::draw() {
return; return;
} }
VisualServer::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, RID());
} }
TiledWall2D::TiledWall2D() { TiledWall2D::TiledWall2D() {

View File

@ -52,7 +52,7 @@ public:
void set_data(const Ref<TiledWall2DData> &data); void set_data(const Ref<TiledWall2DData> &data);
Rect2 get_rect() const; Rect2 get_rect() const;
PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; Vector<Face3> get_faces(uint32_t p_usage_flags) const;
Transform2D get_mesh_transform() const; Transform2D get_mesh_transform() const;
void set_mesh_transform(const Transform2D &value); void set_mesh_transform(const Transform2D &value);

View File

@ -309,7 +309,7 @@ void TiledWall2DData::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &TiledWall2DData::add_textures_into); ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &TiledWall2DData::add_textures_into);
#endif #endif
//BIND_VMETHOD(MethodInfo("_setup_cache", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DMaterialCache"))); ////BIND_VMETHOD(MethodInfo("_setup_cache", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DMaterialCache")));
ClassDB::bind_method(D_METHOD("setup_cache", "cache"), &TiledWall2DData::setup_cache); ClassDB::bind_method(D_METHOD("setup_cache", "cache"), &TiledWall2DData::setup_cache);
ClassDB::bind_method(D_METHOD("_setup_cache", "cache"), &TiledWall2DData::_setup_cache); ClassDB::bind_method(D_METHOD("_setup_cache", "cache"), &TiledWall2DData::_setup_cache);