Initial cleanup and logic update for Prop2DInstance, and Prop2DInstanceMerger.

This commit is contained in:
Relintai 2022-02-25 23:50:40 +01:00
parent 38a3678422
commit 4eb6cf82de
6 changed files with 98 additions and 486 deletions

View File

@ -23,6 +23,7 @@
#include "./props/prop_2d_data_light.h" #include "./props/prop_2d_data_light.h"
#include "./props/prop_2d_data_prop.h" #include "./props/prop_2d_data_prop.h"
#include "./props/prop_2d_data_scene.h" #include "./props/prop_2d_data_scene.h"
#include "./props/prop_2d_data_sprite.h"
#include "./props/prop_2d_data_tiled_wall_2d.h" #include "./props/prop_2d_data_tiled_wall_2d.h"
#include "tiled_wall/tiled_wall_2d.h" #include "tiled_wall/tiled_wall_2d.h"
@ -44,13 +45,6 @@ void Prop2DInstance::set_prop_data(const Ref<Prop2DData> &data) {
} }
} }
Ref<Material> Prop2DInstance::get_material() {
return _material;
}
void Prop2DInstance::set_material(const Ref<Material> &material) {
_material = material;
}
uint32_t Prop2DInstance::get_collision_layer() const { uint32_t Prop2DInstance::get_collision_layer() const {
return _collision_layer; return _collision_layer;
} }
@ -115,7 +109,7 @@ void Prop2DInstance::_build() {
if (!_prop_data.is_valid()) if (!_prop_data.is_valid())
return; return;
prop_preprocess(Transform(), _prop_data); prop_preprocess(Transform2D(), _prop_data);
} }
void Prop2DInstance::_build_finished() { void Prop2DInstance::_build_finished() {
@ -126,11 +120,11 @@ void Prop2DInstance::_build_finished() {
} }
} }
void Prop2DInstance::prop_preprocess(Transform transform, const Ref<Prop2DData> &prop) { void Prop2DInstance::prop_preprocess(Transform2D transform, const Ref<Prop2DData> &prop) {
call("_prop_preprocess", transform, prop); call("_prop_preprocess", transform, prop);
} }
void Prop2DInstance::_prop_preprocess(Transform transform, const Ref<Prop2DData> &prop) { void Prop2DInstance::_prop_preprocess(Transform2D transform, const Ref<Prop2DData> &prop) {
//don't set owners, to help working with the editor //don't set owners, to help working with the editor
ERR_FAIL_COND(!prop.is_valid()); ERR_FAIL_COND(!prop.is_valid());
@ -142,7 +136,7 @@ void Prop2DInstance::_prop_preprocess(Transform transform, const Ref<Prop2DData>
if (!e.is_valid()) if (!e.is_valid())
continue; continue;
Transform t = transform * e->get_transform(); Transform2D t = transform * e->get_transform_2d();
Ref<Prop2DDataProp2D> prop_entry_data = e; Ref<Prop2DDataProp2D> prop_entry_data = e;
@ -160,14 +154,7 @@ void Prop2DInstance::_prop_preprocess(Transform transform, const Ref<Prop2DData>
Ref<Prop2DDataTiledWall2D> tiled_wall_data = e; Ref<Prop2DDataTiledWall2D> tiled_wall_data = e;
if (tiled_wall_data.is_valid()) { if (tiled_wall_data.is_valid()) {
TiledWall2D *twn = memnew(TiledWall2D); Node *twn = tiled_wall_data->_processor_get_node_for(t);
twn->set_width(tiled_wall_data->get_width());
twn->set_heigth(tiled_wall_data->get_heigth());
twn->set_data(tiled_wall_data->get_data());
//twn->set_collision(tiled_wall_data->get_collision());
//twn->set_transform(t);
add_child(twn); add_child(twn);
@ -185,10 +172,10 @@ void Prop2DInstance::_prop_preprocess(Transform transform, const Ref<Prop2DData>
Node *n = sc->instance(); Node *n = sc->instance();
add_child(n); add_child(n);
Spatial *sp = Object::cast_to<Spatial>(n); Node2D *n2d = Object::cast_to<Node2D>(n);
if (sp) { if (n2d) {
sp->set_transform(t); n2d->set_transform(t);
} }
continue; continue;
@ -197,16 +184,26 @@ void Prop2DInstance::_prop_preprocess(Transform transform, const Ref<Prop2DData>
Ref<Prop2DDataLight> light_data = e; Ref<Prop2DDataLight> light_data = e;
if (light_data.is_valid()) { if (light_data.is_valid()) {
OmniLight *light = memnew(OmniLight); Node *light = light_data->_processor_get_node_for(t);
add_child(light); add_child(light);
light->set_color(light_data->get_light_color());
//light->set_param(Light::PARAM_RANGE, light_data->get_light_size()); continue;
light->set_transform(t); }
Ref<Prop2DDataSprite> sprite_data = e;
if (sprite_data.is_valid()) {
Node *sp = sprite_data->_processor_get_node_for(t);
add_child(sp);
continue; continue;
} }
#if MESH_DATA_RESOURCE_PRESENT #if MESH_DATA_RESOURCE_PRESENT
//TODO
/*
Ref<Prop2DDataMeshData> mesh_data = e; Ref<Prop2DDataMeshData> mesh_data = e;
if (mesh_data.is_valid()) { if (mesh_data.is_valid()) {
@ -224,22 +221,6 @@ void Prop2DInstance::_prop_preprocess(Transform transform, const Ref<Prop2DData>
Ref<Material> mat = _material->duplicate(); Ref<Material> mat = _material->duplicate();
Ref<Texture> texture = mdi->get_texture(); Ref<Texture> texture = mdi->get_texture();
if (texture.is_valid()) {
//texture is valid, try to set it into the material
Ref<SpatialMaterial> spmat = mat;
if (spmat.is_valid()) {
spmat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture);
} else {
Ref<ShaderMaterial> shmat = mat;
if (shmat.is_valid()) {
shmat->set_shader_param("texture_albedo", texture);
}
}
}
mdi->set_material(mat); mdi->set_material(mat);
} }
@ -247,6 +228,7 @@ void Prop2DInstance::_prop_preprocess(Transform transform, const Ref<Prop2DData>
continue; continue;
} }
*/
#endif #endif
} }
} }
@ -280,10 +262,6 @@ void Prop2DInstance::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_prop_data", "value"), &Prop2DInstance::set_prop_data); ClassDB::bind_method(D_METHOD("set_prop_data", "value"), &Prop2DInstance::set_prop_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DData"), "set_prop_data", "get_prop_data"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DData"), "set_prop_data", "get_prop_data");
ClassDB::bind_method(D_METHOD("get_material"), &Prop2DInstance::get_material);
ClassDB::bind_method(D_METHOD("set_material", "material"), &Prop2DInstance::set_material);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_material", "get_material");
ClassDB::bind_method(D_METHOD("get_collision_layer"), &Prop2DInstance::get_collision_layer); ClassDB::bind_method(D_METHOD("get_collision_layer"), &Prop2DInstance::get_collision_layer);
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &Prop2DInstance::set_collision_layer); ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &Prop2DInstance::set_collision_layer);

View File

@ -25,13 +25,7 @@ SOFTWARE.
#include "core/version.h" #include "core/version.h"
#if VERSION_MAJOR < 4 #include "scene/2d/node_2d.h"
#include "scene/3d/spatial.h"
#else
#include "scene/3d/node_3d.h"
#define Spatial Node3D
#endif
#include "scene/resources/material.h" #include "scene/resources/material.h"
@ -39,16 +33,13 @@ SOFTWARE.
#include "props/prop_2d_data.h" #include "props/prop_2d_data.h"
class Prop2DInstance : public Spatial { class Prop2DInstance : public Node2D {
GDCLASS(Prop2DInstance, Spatial); GDCLASS(Prop2DInstance, Node2D);
public: public:
Ref<Prop2DData> get_prop_data(); Ref<Prop2DData> get_prop_data();
void set_prop_data(const Ref<Prop2DData> &data); void set_prop_data(const Ref<Prop2DData> &data);
Ref<Material> get_material();
void set_material(const Ref<Material> &material);
uint32_t get_collision_layer() const; uint32_t get_collision_layer() const;
void set_collision_layer(uint32_t p_layer); void set_collision_layer(uint32_t p_layer);
@ -68,8 +59,8 @@ public:
virtual void _build(); virtual void _build();
virtual void _build_finished(); virtual void _build_finished();
void prop_preprocess(Transform tarnsform, const Ref<Prop2DData> &prop); void prop_preprocess(Transform2D tarnsform, const Ref<Prop2DData> &prop);
virtual void _prop_preprocess(Transform tarnsform, const Ref<Prop2DData> &prop); virtual void _prop_preprocess(Transform2D tarnsform, const Ref<Prop2DData> &prop);
Prop2DInstance(); Prop2DInstance();
~Prop2DInstance(); ~Prop2DInstance();
@ -80,7 +71,6 @@ protected:
protected: protected:
Ref<Prop2DData> _prop_data; Ref<Prop2DData> _prop_data;
Ref<Material> _material;
uint32_t _collision_layer; uint32_t _collision_layer;
uint32_t _collision_mask; uint32_t _collision_mask;

View File

@ -19,8 +19,6 @@
#include "servers/rendering_server.h" #include "servers/rendering_server.h"
typedef class RenderingServer VS; typedef class RenderingServer VS;
#define GET_WORLD get_world_3d
#else #else
#include "core/engine.h" #include "core/engine.h"
@ -33,8 +31,6 @@ typedef class RenderingServer VS;
#include "servers/visual_server.h" #include "servers/visual_server.h"
#define GET_WORLD get_world
#endif #endif
#if MESH_DATA_RESOURCE_PRESENT #if MESH_DATA_RESOURCE_PRESENT
@ -66,8 +62,6 @@ typedef class RenderingServer VS;
#include "scene/resources/box_shape.h" #include "scene/resources/box_shape.h"
const float Prop2DInstanceMerger::LOD_CHECK_INTERVAL = 2;
bool Prop2DInstanceMerger::get_building() { bool Prop2DInstanceMerger::get_building() {
return _building; return _building;
} }
@ -75,47 +69,9 @@ void Prop2DInstanceMerger::set_building(const bool value) {
_building = value; _building = value;
set_physics_process_internal(_building); set_physics_process_internal(_building);
if (!_auto_lod_on) {
set_process_internal(_building); set_process_internal(_building);
}
} }
int Prop2DInstanceMerger::get_lod_level() {
return _lod_level;
}
void Prop2DInstanceMerger::set_lod_level(const int value) {
_lod_level = value;
if (_lod_level < 0) {
_lod_level = 0;
}
apply_lod_level();
}
bool Prop2DInstanceMerger::get_auto_lod() {
return _auto_lod;
}
void Prop2DInstanceMerger::set_auto_lod(const bool value) {
_auto_lod = value;
check_auto_lod();
}
float Prop2DInstanceMerger::get_first_lod_distance_squared() {
return _first_lod_distance_squared;
}
void Prop2DInstanceMerger::set_first_lod_distance_squared(const float dist) {
_first_lod_distance_squared = dist;
}
float Prop2DInstanceMerger::get_lod_reduction_distance_squared() {
return _lod_reduction_distance_squared;
}
void Prop2DInstanceMerger::set_lod_reduction_distance_squared(const float dist) {
_lod_reduction_distance_squared = dist;
}
Ref<Prop2DInstanceJob> Prop2DInstanceMerger::get_job() { Ref<Prop2DInstanceJob> Prop2DInstanceMerger::get_job() {
return _job; return _job;
@ -128,60 +84,15 @@ void Prop2DInstanceMerger::set_job(const Ref<Prop2DInstanceJob> &job) {
} }
} }
//Materials
Ref<Material> Prop2DInstanceMerger::material_get(const int index) {
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>(NULL));
return _materials[index];
}
void Prop2DInstanceMerger::material_add(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_materials.push_back(value);
}
int Prop2DInstanceMerger::material_get_num() const {
return _materials.size();
}
void Prop2DInstanceMerger::materials_clear() {
_materials.clear();
}
Vector<Variant> Prop2DInstanceMerger::materials_get() {
VARIANT_ARRAY_GET(_materials);
}
void Prop2DInstanceMerger::materials_set(const Vector<Variant> &materials) {
_materials.clear();
for (int i = 0; i < materials.size(); i++) {
Ref<Material> material = Ref<Material>(materials[i]);
_materials.push_back(material);
}
}
//Meshes //Meshes
RID Prop2DInstanceMerger::mesh_get(const int index) { RID Prop2DInstanceMerger::mesh_get(const int index) {
ERR_FAIL_INDEX_V(index, _meshes.size(), RID()); ERR_FAIL_INDEX_V(index, _meshes.size(), RID());
return _meshes[index].mesh; return _meshes[index];
} }
RID Prop2DInstanceMerger::mesh_instance_get(const int index) { void Prop2DInstanceMerger::mesh_add(const RID mesh) {
ERR_FAIL_INDEX_V(index, _meshes.size(), RID()); _meshes.push_back(mesh);
return _meshes[index].mesh_instance;
}
void Prop2DInstanceMerger::mesh_add(const RID mesh_instance, const RID mesh) {
MeshEntry e;
e.mesh = mesh;
e.mesh_instance = mesh_instance;
_meshes.push_back(e);
} }
int Prop2DInstanceMerger::mesh_get_num() const { int Prop2DInstanceMerger::mesh_get_num() const {
@ -196,38 +107,16 @@ void Prop2DInstanceMerger::meshes_create(const int num) {
free_meshes(); free_meshes();
for (int i = 0; i < num; ++i) { for (int i = 0; i < num; ++i) {
RID mesh_instance_rid = VS::get_singleton()->instance_create();
if (GET_WORLD().is_valid())
VS::get_singleton()->instance_set_scenario(mesh_instance_rid, GET_WORLD()->get_scenario());
RID mesh_rid = VS::get_singleton()->mesh_create(); RID mesh_rid = VS::get_singleton()->mesh_create();
VS::get_singleton()->instance_set_base(mesh_instance_rid, mesh_rid); _meshes.push_back(mesh_rid);
VS::get_singleton()->instance_set_transform(mesh_instance_rid, get_transform());
VS::get_singleton()->instance_set_visible(mesh_instance_rid, false);
MeshEntry e;
e.mesh = mesh_rid;
e.mesh_instance = mesh_instance_rid;
_meshes.push_back(e);
} }
apply_lod_level();
} }
Vector<Variant> Prop2DInstanceMerger::meshes_get() { Vector<Variant> Prop2DInstanceMerger::meshes_get() {
Vector<Variant> r; Vector<Variant> r;
for (int i = 0; i < _meshes.size(); i++) { for (int i = 0; i < _meshes.size(); i++) {
Array a; r.push_back(_meshes[i]);
a.push_back(_meshes[i].mesh);
a.push_back(_meshes[i].mesh_instance);
r.push_back(a);
} }
return r; return r;
} }
@ -236,22 +125,14 @@ void Prop2DInstanceMerger::meshes_set(const Vector<Variant> &meshs) {
_meshes.clear(); _meshes.clear();
for (int i = 0; i < _meshes.size(); i++) { for (int i = 0; i < _meshes.size(); i++) {
Array arr = Array(meshs[i]); _meshes.push_back(meshs[i]);
ERR_CONTINUE(arr.size() != 2);
MeshEntry e;
e.mesh = RID(arr[0]);
e.mesh_instance = RID(arr[1]);
_meshes.push_back(e);
} }
} }
//Collider //Collider
Transform Prop2DInstanceMerger::collider_local_transform_get(const int index) { Transform2D Prop2DInstanceMerger::collider_local_transform_get(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), Transform()); ERR_FAIL_INDEX_V(index, _colliders.size(), Transform2D());
return _colliders[index].transform; return _colliders[index].transform;
} }
@ -262,8 +143,8 @@ RID Prop2DInstanceMerger::collider_body_get(const int index) {
return _colliders[index].body; return _colliders[index].body;
} }
Ref<Shape> Prop2DInstanceMerger::collider_shape_get(const int index) { Ref<Shape2D> Prop2DInstanceMerger::collider_shape_get(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), Ref<Shape>()); ERR_FAIL_INDEX_V(index, _colliders.size(), Ref<Shape2D>());
return _colliders[index].shape; return _colliders[index].shape;
} }
@ -274,7 +155,7 @@ RID Prop2DInstanceMerger::collider_shape_rid_get(const int index) {
return _colliders[index].shape_rid; return _colliders[index].shape_rid;
} }
int Prop2DInstanceMerger::collider_add(const Transform &local_transform, const Ref<Shape> &shape, const RID &shape_rid, const RID &body, const bool owns_shape) { int Prop2DInstanceMerger::collider_add(const Transform2D &local_transform, const Ref<Shape2D> &shape, const RID &shape_rid, const RID &body, const bool owns_shape) {
ERR_FAIL_COND_V(!shape.is_valid() && shape_rid == RID(), 0); ERR_FAIL_COND_V(!shape.is_valid() && shape_rid == RID(), 0);
int index = _colliders.size(); int index = _colliders.size();
@ -320,87 +201,12 @@ void Prop2DInstanceMerger::colliders_set(const Vector<Variant> &colliders) {
} }
} }
void Prop2DInstanceMerger::check_auto_lod() {
if (!_auto_lod) {
_auto_lod_on = false;
return;
}
if (_meshes.size() <= 1) {
_auto_lod_on = false;
if (!_building) {
set_process_internal(false);
}
return;
}
_auto_lod_on = true;
set_process_internal(true);
}
void Prop2DInstanceMerger::apply_lod_level() {
if (_meshes.size() == 0) {
return;
}
VisualServer *vs = VisualServer::get_singleton();
for (int i = 0; i < _meshes.size(); ++i) {
RID mi = _meshes[i].mesh_instance;
if (mi == RID()) {
continue;
}
vs->instance_set_visible(mi, false);
}
if (!is_inside_tree()) {
return;
}
if (!is_visible_in_tree()) {
return;
}
int indx = _lod_level;
if (_meshes.size() <= _lod_level) {
indx = _meshes.size() - 1;
}
RID mi = _meshes[indx].mesh_instance;
if (mi == RID()) {
return;
}
vs->instance_set_visible(mi, true);
}
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 = VisualServer::get_singleton()->mesh_create();
} }
if (_debug_mesh_instance == RID()) {
_debug_mesh_instance = VisualServer::get_singleton()->instance_create();
if (GET_WORLD().is_valid())
VS::get_singleton()->instance_set_scenario(_debug_mesh_instance, GET_WORLD()->get_scenario());
VS::get_singleton()->instance_set_base(_debug_mesh_instance, _debug_mesh_rid);
VS::get_singleton()->instance_set_transform(_debug_mesh_instance, get_transform());
VS::get_singleton()->instance_set_visible(_debug_mesh_instance, true);
}
} }
void Prop2DInstanceMerger::debug_mesh_free() { void Prop2DInstanceMerger::debug_mesh_free() {
if (_debug_mesh_instance != RID()) {
VisualServer::get_singleton()->free(_debug_mesh_instance);
}
if (_debug_mesh_rid != RID()) { if (_debug_mesh_rid != RID()) {
VisualServer::get_singleton()->free(_debug_mesh_rid); VisualServer::get_singleton()->free(_debug_mesh_rid);
} }
@ -416,7 +222,7 @@ void Prop2DInstanceMerger::debug_mesh_clear() {
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 PoolVector3Array &arr) { void Prop2DInstanceMerger::debug_mesh_add_vertices_to(const PoolVector2Array &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) {
@ -438,10 +244,6 @@ void Prop2DInstanceMerger::debug_mesh_send() {
VisualServer::get_singleton()->mesh_add_surface_from_arrays(_debug_mesh_rid, VisualServer::PRIMITIVE_LINES, arr); VisualServer::get_singleton()->mesh_add_surface_from_arrays(_debug_mesh_rid, VisualServer::PRIMITIVE_LINES, arr);
if (st) {
VisualServer::get_singleton()->mesh_surface_set_material(_debug_mesh_rid, 0, SceneTree::get_singleton()->get_debug_collision_material()->get_rid());
}
debug_mesh_array_clear(); debug_mesh_array_clear();
} }
@ -451,15 +253,17 @@ void Prop2DInstanceMerger::draw_debug_mdr_colliders() {
} }
for (int i = 0; i < collider_get_num(); ++i) { for (int i = 0; i < collider_get_num(); ++i) {
Ref<Shape> shape = collider_shape_get(i); Ref<Shape2D> shape = collider_shape_get(i);
if (!shape.is_valid()) { if (!shape.is_valid()) {
continue; continue;
} }
Transform t = collider_local_transform_get(i); Transform2D t = collider_local_transform_get(i);
shape->add_vertices_to_array(_debug_mesh_array, t); VisualServer::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());
} }
debug_mesh_send(); debug_mesh_send();
@ -469,18 +273,13 @@ void Prop2DInstanceMerger::free_meshes() {
RID rid; RID rid;
for (int i = 0; i < _meshes.size(); ++i) { for (int i = 0; i < _meshes.size(); ++i) {
MeshEntry &e = _meshes.write[i]; RID &e = _meshes.write[i];
if (e.mesh_instance != rid) { if (e != rid) {
VS::get_singleton()->free(e.mesh_instance); VS::get_singleton()->free(e);
} }
if (e.mesh != rid) { e = rid;
VS::get_singleton()->free(e.mesh);
}
e.mesh_instance = rid;
e.mesh = rid;
} }
} }
@ -507,7 +306,7 @@ void Prop2DInstanceMerger::_build() {
return; return;
} }
if (!is_inside_tree() || !get_world().is_valid()) { if (!is_inside_tree() || !get_world_2d().is_valid()) {
queue_build(); queue_build();
return; return;
} }
@ -565,7 +364,7 @@ void Prop2DInstanceMerger::_build() {
_job->set_material_cache(cache); _job->set_material_cache(cache);
prop_preprocess(Transform(), _prop_data); prop_preprocess(Transform2D(), _prop_data);
/* /*
@ -582,9 +381,6 @@ Don't submit here, as it starts in physics process mode
void Prop2DInstanceMerger::_build_finished() { void Prop2DInstanceMerger::_build_finished() {
set_building(false); set_building(false);
apply_lod_level();
check_auto_lod();
notification(NOTIFICATION_TRANSFORM_CHANGED); notification(NOTIFICATION_TRANSFORM_CHANGED);
if (_build_queued) { if (_build_queued) {
@ -592,7 +388,7 @@ void Prop2DInstanceMerger::_build_finished() {
} }
} }
void Prop2DInstanceMerger::_prop_preprocess(Transform transform, const Ref<Prop2DData> &prop) { void Prop2DInstanceMerger::_prop_preprocess(Transform2D transform, const Ref<Prop2DData> &prop) {
ERR_FAIL_COND(!prop.is_valid()); ERR_FAIL_COND(!prop.is_valid());
int count = prop->get_prop_count(); int count = prop->get_prop_count();
@ -602,7 +398,7 @@ void Prop2DInstanceMerger::_prop_preprocess(Transform transform, const Ref<Prop2
if (!e.is_valid()) if (!e.is_valid())
continue; continue;
Transform t = transform * e->get_transform(); Transform2D t = transform * e->get_transform_2d();
Ref<Prop2DDataProp2D> prop_entry_data = e; Ref<Prop2DDataProp2D> prop_entry_data = e;
@ -631,9 +427,9 @@ void Prop2DInstanceMerger::_prop_preprocess(Transform transform, const Ref<Prop2
tws->set_extents(Vector3(hew, heh, 0.01)); tws->set_extents(Vector3(hew, heh, 0.01));
Transform tt = t; Transform2D tt = t;
//tt.origin += Vector3(hew, heh, 0); //tt.origin += Vector3(hew, heh, 0);
tt.translate(hew, heh, 0); tt.translate(hew, heh);
_job->add_collision_shape(tws, tt, true); _job->add_collision_shape(tws, tt, true);
} }
@ -653,7 +449,7 @@ void Prop2DInstanceMerger::_prop_preprocess(Transform transform, const Ref<Prop2
add_child(n); add_child(n);
n->set_owner(this); n->set_owner(this);
Spatial *sp = Object::cast_to<Spatial>(n); Node2D *sp = Object::cast_to<Node2D>(n);
if (sp) { if (sp) {
sp->set_transform(t); sp->set_transform(t);
@ -670,9 +466,9 @@ void Prop2DInstanceMerger::_prop_preprocess(Transform transform, const Ref<Prop2
Ref<Prop2DLight> light; Ref<Prop2DLight> light;
light.instance(); light.instance();
Vector3 v = t.xform(Vector3()); Vector2 v = t.xform(Vector2());
//light->set_position(v); light->set_position(v);
light->set_color(light_data->get_light_color()); light->set_color(light_data->get_light_color());
//light->set_size(light_data->get_light_size()); //light->set_size(light_data->get_light_size());
@ -691,10 +487,11 @@ void Prop2DInstanceMerger::_prop_preprocess(Transform transform, const Ref<Prop2
continue; continue;
_job->add_mesh(mesh_data, t); _job->add_mesh(mesh_data, t);
/*
for (int j = 0; j < mdr->get_collision_shape_count(); ++j) { for (int j = 0; j < mdr->get_collision_shape_count(); ++j) {
_job->add_collision_shape(mdr->get_collision_shape(j), t * mdr->get_collision_shape_offset(j)); _job->add_collision_shape(mdr->get_collision_shape(j), t * mdr->get_collision_shape_offset(j));
} }
*/
} }
#endif #endif
} }
@ -726,19 +523,10 @@ void Prop2DInstanceMerger::_create_job() {
Prop2DInstanceMerger::Prop2DInstanceMerger() { Prop2DInstanceMerger::Prop2DInstanceMerger() {
_build_queued = false; _build_queued = false;
_auto_lod = true;
_auto_lod_on = false;
_lod_level = 0;
//randomize so even if there is a lot they won't check for this at the same frame
_lod_check_timer = Math::randf() * LOD_CHECK_INTERVAL;
set_building(false); set_building(false);
set_notify_transform(true); set_notify_transform(true);
_first_lod_distance_squared = 1000;
_lod_reduction_distance_squared = 600;
} }
Prop2DInstanceMerger::~Prop2DInstanceMerger() { Prop2DInstanceMerger::~Prop2DInstanceMerger() {
@ -746,8 +534,6 @@ Prop2DInstanceMerger::~Prop2DInstanceMerger() {
_prop_data.unref(); _prop_data.unref();
_materials.clear();
free_meshes(); free_meshes();
free_colliders(); free_colliders();
meshes_clear(); meshes_clear();
@ -823,61 +609,12 @@ void Prop2DInstanceMerger::_notification(int p_what) {
#endif #endif
} }
} }
} else {
if (!_auto_lod_on) {
return;
}
if (_meshes.size() == 0) {
return;
}
_lod_check_timer += get_process_delta_time();
if (_lod_check_timer > LOD_CHECK_INTERVAL) {
_lod_check_timer = 0;
if (!is_visible_in_tree()) {
return;
}
SceneTree *st = get_tree();
if (st) {
Viewport *vp = st->get_root();
if (vp) {
Camera *cam = vp->get_camera();
if (cam) {
Vector3 cam_world_pos = cam->get_global_transform().xform(Vector3());
Vector3 world_pos = get_global_transform().xform(Vector3());
Vector3 dstv = cam_world_pos - world_pos;
float dst = dstv.length_squared();
if (dst <= _first_lod_distance_squared) {
set_lod_level(0);
return;
}
dst -= _first_lod_distance_squared;
dst /= _lod_reduction_distance_squared;
int dstl = static_cast<int>(dst);
//the lod udpate method handles it if it's higher that the max generated lod level
set_lod_level(dstl + 1);
}
}
}
}
} }
break; break;
} }
case NOTIFICATION_TRANSFORM_CHANGED: { case NOTIFICATION_TRANSFORM_CHANGED: {
Transform new_transform = get_global_transform(); Transform2D new_transform = get_global_transform();
//Don't do this check, so this can be used to setmesh positions after a build //Don't do this check, so this can be used to setmesh positions after a build
//if (new_transform == _last_transform) { //if (new_transform == _last_transform) {
@ -885,21 +622,7 @@ void Prop2DInstanceMerger::_notification(int p_what) {
//} //}
_last_transform = new_transform; _last_transform = new_transform;
/*
VisualServer *vs = VisualServer::get_singleton();
for (int i = 0; i < _meshes.size(); ++i) {
RID mir = _meshes[i].mesh_instance;
if (mir != RID()) {
vs->instance_set_transform(mir, new_transform);
}
}
if (_debug_mesh_instance != RID()) {
vs->instance_set_transform(_debug_mesh_instance, new_transform);
}
for (int i = 0; i < _colliders.size(); ++i) { for (int i = 0; i < _colliders.size(); ++i) {
const ColliderBody &c = _colliders[i]; const ColliderBody &c = _colliders[i];
@ -907,11 +630,10 @@ void Prop2DInstanceMerger::_notification(int p_what) {
PhysicsServer::get_singleton()->body_set_shape_transform(c.body, 0, new_transform * c.transform); PhysicsServer::get_singleton()->body_set_shape_transform(c.body, 0, new_transform * c.transform);
} }
} }
*/
break; break;
} }
case NOTIFICATION_VISIBILITY_CHANGED: { case NOTIFICATION_DRAW: {
apply_lod_level();
break; break;
} }
} }
@ -925,36 +647,9 @@ void Prop2DInstanceMerger::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_job", "value"), &Prop2DInstanceMerger::set_job); ClassDB::bind_method(D_METHOD("set_job", "value"), &Prop2DInstanceMerger::set_job);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "job", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DInstanceJob", 0), "set_job", "get_job"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "job", PROPERTY_HINT_RESOURCE_TYPE, "Prop2DInstanceJob", 0), "set_job", "get_job");
ClassDB::bind_method(D_METHOD("get_lod_level"), &Prop2DInstanceMerger::get_lod_level);
ClassDB::bind_method(D_METHOD("set_lod_level", "value"), &Prop2DInstanceMerger::set_lod_level);
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_level"), "set_lod_level", "get_lod_level");
ClassDB::bind_method(D_METHOD("get_auto_lod"), &Prop2DInstanceMerger::get_auto_lod);
ClassDB::bind_method(D_METHOD("set_auto_lod", "value"), &Prop2DInstanceMerger::set_auto_lod);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_lod"), "set_auto_lod", "get_auto_lod");
ClassDB::bind_method(D_METHOD("get_first_lod_distance_squared"), &Prop2DInstanceMerger::get_first_lod_distance_squared);
ClassDB::bind_method(D_METHOD("set_first_lod_distance_squared", "value"), &Prop2DInstanceMerger::set_first_lod_distance_squared);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "first_lod_distance_squared"), "set_first_lod_distance_squared", "get_first_lod_distance_squared");
ClassDB::bind_method(D_METHOD("get_lod_reduction_distance_squared"), &Prop2DInstanceMerger::get_lod_reduction_distance_squared);
ClassDB::bind_method(D_METHOD("set_lod_reduction_distance_squared", "value"), &Prop2DInstanceMerger::set_lod_reduction_distance_squared);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "lod_reduction_distance_squared"), "set_lod_reduction_distance_squared", "get_lod_reduction_distance_squared");
///Materials
ClassDB::bind_method(D_METHOD("material_get", "index"), &Prop2DInstanceMerger::material_get);
ClassDB::bind_method(D_METHOD("material_add", "value"), &Prop2DInstanceMerger::material_add);
ClassDB::bind_method(D_METHOD("material_get_num"), &Prop2DInstanceMerger::material_get_num);
ClassDB::bind_method(D_METHOD("materials_clear"), &Prop2DInstanceMerger::materials_clear);
ClassDB::bind_method(D_METHOD("materials_get"), &Prop2DInstanceMerger::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &Prop2DInstanceMerger::materials_set);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get");
//Meshes //Meshes
ClassDB::bind_method(D_METHOD("mesh_get", "index"), &Prop2DInstanceMerger::mesh_get); ClassDB::bind_method(D_METHOD("mesh_get", "index"), &Prop2DInstanceMerger::mesh_get);
ClassDB::bind_method(D_METHOD("mesh_instance_get", "index"), &Prop2DInstanceMerger::mesh_instance_get); ClassDB::bind_method(D_METHOD("mesh_add", "mesh"), &Prop2DInstanceMerger::mesh_add);
ClassDB::bind_method(D_METHOD("mesh_add", "mesh_instance", "mesh"), &Prop2DInstanceMerger::mesh_add);
ClassDB::bind_method(D_METHOD("mesh_get_num"), &Prop2DInstanceMerger::mesh_get_num); ClassDB::bind_method(D_METHOD("mesh_get_num"), &Prop2DInstanceMerger::mesh_get_num);
ClassDB::bind_method(D_METHOD("meshes_clear"), &Prop2DInstanceMerger::meshes_clear); ClassDB::bind_method(D_METHOD("meshes_clear"), &Prop2DInstanceMerger::meshes_clear);
@ -982,9 +677,6 @@ void Prop2DInstanceMerger::_bind_methods() {
ClassDB::bind_method(D_METHOD("debug_mesh_send"), &Prop2DInstanceMerger::debug_mesh_send); ClassDB::bind_method(D_METHOD("debug_mesh_send"), &Prop2DInstanceMerger::debug_mesh_send);
ClassDB::bind_method(D_METHOD("draw_debug_mdr_colliders"), &Prop2DInstanceMerger::draw_debug_mdr_colliders); ClassDB::bind_method(D_METHOD("draw_debug_mdr_colliders"), &Prop2DInstanceMerger::draw_debug_mdr_colliders);
ClassDB::bind_method(D_METHOD("check_auto_lod"), &Prop2DInstanceMerger::check_auto_lod);
ClassDB::bind_method(D_METHOD("apply_lod_level"), &Prop2DInstanceMerger::apply_lod_level);
//--- //---
ClassDB::bind_method(D_METHOD("free_meshes"), &Prop2DInstanceMerger::free_meshes); ClassDB::bind_method(D_METHOD("free_meshes"), &Prop2DInstanceMerger::free_meshes);
ClassDB::bind_method(D_METHOD("free_colliders"), &Prop2DInstanceMerger::free_colliders); ClassDB::bind_method(D_METHOD("free_colliders"), &Prop2DInstanceMerger::free_colliders);

View File

@ -27,13 +27,8 @@ SOFTWARE.
#include "core/version.h" #include "core/version.h"
#if VERSION_MAJOR < 4 #include "scene/2d/node_2d.h"
#include "scene/3d/spatial.h" #include "scene/resources/shape_2d.h"
#else
#include "scene/3d/node_3d.h"
#define Spatial Node3D
#endif
#include "core/math/vector3.h" #include "core/math/vector3.h"
@ -47,39 +42,15 @@ class Prop2DInstanceMerger : public Prop2DInstance {
GDCLASS(Prop2DInstanceMerger, Prop2DInstance); GDCLASS(Prop2DInstanceMerger, Prop2DInstance);
public: public:
static const float LOD_CHECK_INTERVAL;
bool get_building(); bool get_building();
void set_building(const bool value); void set_building(const bool value);
int get_lod_level();
void set_lod_level(const int value);
bool get_auto_lod();
void set_auto_lod(const bool value);
float get_first_lod_distance_squared();
void set_first_lod_distance_squared(const float dist);
float get_lod_reduction_distance_squared();
void set_lod_reduction_distance_squared(const float dist);
Ref<Prop2DInstanceJob> get_job(); Ref<Prop2DInstanceJob> get_job();
void set_job(const Ref<Prop2DInstanceJob> &job); void set_job(const Ref<Prop2DInstanceJob> &job);
///Materials
Ref<Material> material_get(const int index);
void material_add(const Ref<Material> &value);
int material_get_num() const;
void materials_clear();
Vector<Variant> materials_get();
void materials_set(const Vector<Variant> &materials);
//Meshes //Meshes
RID mesh_get(const int index); RID mesh_get(const int index);
RID mesh_instance_get(const int index); void mesh_add(const RID mesh);
void mesh_add(const RID mesh_instance, const RID mesh);
int mesh_get_num() const; int mesh_get_num() const;
void meshes_clear(); void meshes_clear();
void meshes_create(const int num); void meshes_create(const int num);
@ -88,27 +59,24 @@ public:
void meshes_set(const Vector<Variant> &meshes); void meshes_set(const Vector<Variant> &meshes);
//Colliders //Colliders
Transform collider_local_transform_get(const int index); Transform2D collider_local_transform_get(const int index);
RID collider_body_get(const int index); RID collider_body_get(const int index);
Ref<Shape> collider_shape_get(const int index); Ref<Shape2D> collider_shape_get(const int index);
RID collider_shape_rid_get(const int index); RID collider_shape_rid_get(const int index);
int collider_add(const Transform &local_transform, const Ref<Shape> &shape, const RID &shape_rid, const RID &body, const bool owns_shape = false); int collider_add(const Transform2D &local_transform, const Ref<Shape2D> &shape, const RID &shape_rid, const RID &body, const bool owns_shape = false);
int collider_get_num() const; int collider_get_num() const;
void colliders_clear(); void colliders_clear();
Vector<Variant> colliders_get(); Vector<Variant> colliders_get();
void colliders_set(const Vector<Variant> &colliders); void colliders_set(const Vector<Variant> &colliders);
void check_auto_lod();
void apply_lod_level();
//Debug //Debug
void debug_mesh_allocate(); void debug_mesh_allocate();
void debug_mesh_free(); void debug_mesh_free();
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 PoolVector3Array &arr); void debug_mesh_add_vertices_to(const PoolVector2Array &arr);
void debug_mesh_send(); void debug_mesh_send();
void draw_debug_mdr_colliders(); void draw_debug_mdr_colliders();
@ -120,7 +88,7 @@ public:
virtual void _build(); virtual void _build();
virtual void _build_finished(); virtual void _build_finished();
void _prop_preprocess(Transform tarnsform, const Ref<Prop2DData> &prop); void _prop_preprocess(Transform2D tarnsform, const Ref<Prop2DData> &prop);
void collision_layer_changed(); void collision_layer_changed();
void collision_mask_changed(); void collision_mask_changed();
@ -136,9 +104,9 @@ protected:
protected: protected:
struct ColliderBody { struct ColliderBody {
Transform transform; Transform2D transform;
RID body; RID body;
Ref<Shape> shape; Ref<Shape2D> shape;
RID shape_rid; RID shape_rid;
bool owns_shape; bool owns_shape;
@ -147,35 +115,20 @@ protected:
} }
}; };
struct MeshEntry {
RID mesh;
RID mesh_instance;
};
private: private:
bool _build_queued; bool _build_queued;
bool _building; bool _building;
int _lod_level; Transform2D _last_transform;
Transform _last_transform;
Ref<Prop2DInstanceProp2DJob> _job; Ref<Prop2DInstanceProp2DJob> _job;
Vector<Ref<Material>> _materials; Vector<RID> _meshes;
Vector<MeshEntry> _meshes;
Vector<ColliderBody> _colliders; Vector<ColliderBody> _colliders;
bool _auto_lod;
bool _auto_lod_on;
float _first_lod_distance_squared;
float _lod_reduction_distance_squared;
float _lod_check_timer;
//debug //debug
RID _debug_mesh_rid; RID _debug_mesh_rid;
RID _debug_mesh_instance; PoolVector2Array _debug_mesh_array;
PoolVector3Array _debug_mesh_array;
}; };
#endif #endif

View File

@ -24,12 +24,6 @@ SOFTWARE.
#include "core/version.h" #include "core/version.h"
#if VERSION_MAYOR > 3
#define GET_WORLD get_world_3d
#else
#define GET_WORLD get_world
#endif
#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 "prop_2d_instance.h" #include "prop_2d_instance.h"
@ -67,7 +61,7 @@ void Prop2DInstanceProp2DJob::set_material_cache(const Ref<Prop2DMaterialCache>
_material_cache = cache; _material_cache = cache;
} }
void Prop2DInstanceProp2DJob::add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape) { void Prop2DInstanceProp2DJob::add_collision_shape(const Ref<Shape2D> &shape, const Transform2D &transform, const bool owns_shape) {
CollisionShapeEntry e; CollisionShapeEntry e;
e.shape = shape; e.shape = shape;
@ -99,7 +93,7 @@ void Prop2DInstanceProp2DJob::set_prop_mesher(const Ref<Prop2DMesher> &mesher) {
} }
#if MESH_DATA_RESOURCE_PRESENT #if MESH_DATA_RESOURCE_PRESENT
void Prop2DInstanceProp2DJob::add_mesh(const Ref<Prop2DDataMeshData> &mesh_data, const Transform &base_transform) { void Prop2DInstanceProp2DJob::add_mesh(const Ref<Prop2DDataMeshData> &mesh_data, const Transform2D &base_transform) {
PMDREntry e; PMDREntry e;
e.mesh_data = mesh_data; e.mesh_data = mesh_data;
e.base_transform = base_transform; e.base_transform = base_transform;
@ -112,7 +106,7 @@ void Prop2DInstanceProp2DJob::clear_meshes() {
} }
#endif #endif
void Prop2DInstanceProp2DJob::add_tiled_wall(const Ref<Prop2DDataTiledWall2D> &data, const Transform &base_transform) { void Prop2DInstanceProp2DJob::add_tiled_wall(const Ref<Prop2DDataTiledWall2D> &data, const Transform2D &base_transform) {
PTWEntry e; PTWEntry e;
e.data = data; e.data = data;
e.base_transform = base_transform; e.base_transform = base_transform;
@ -194,7 +188,7 @@ void Prop2DInstanceProp2DJob::phase_physics_process() {
_prop_instace->free_colliders(); _prop_instace->free_colliders();
_prop_instace->colliders_clear(); _prop_instace->colliders_clear();
/*
for (int i = 0; i < _collision_shapes.size(); ++i) { for (int i = 0; i < _collision_shapes.size(); ++i) {
CollisionShapeEntry &e = _collision_shapes.write[i]; CollisionShapeEntry &e = _collision_shapes.write[i];
@ -211,7 +205,7 @@ void Prop2DInstanceProp2DJob::phase_physics_process() {
PhysicsServer::get_singleton()->body_set_collision_mask(body, _prop_instace->get_collision_mask()); PhysicsServer::get_singleton()->body_set_collision_mask(body, _prop_instace->get_collision_mask());
if (_prop_instace->is_inside_tree() && _prop_instace->is_inside_world()) { if (_prop_instace->is_inside_tree() && _prop_instace->is_inside_world()) {
Ref<World> world = _prop_instace->GET_WORLD(); Ref<World2D> world = _prop_instace->get_world_2d();
if (world.is_valid() && world->get_space() != RID()) { if (world.is_valid() && world->get_space() != RID()) {
PhysicsServer::get_singleton()->body_set_space(body, world->get_space()); PhysicsServer::get_singleton()->body_set_space(body, world->get_space());
@ -222,11 +216,14 @@ void Prop2DInstanceProp2DJob::phase_physics_process() {
_prop_instace->collider_add(e.transform, e.shape, e.shape->get_rid(), body, e.owns_shape); _prop_instace->collider_add(e.transform, e.shape, e.shape->get_rid(), body, e.owns_shape);
} }
*/
#if TOOLS_ENABLED #if TOOLS_ENABLED
/*
if (SceneTree::get_singleton()->is_debugging_collisions_hint() && _prop_instace->collider_get_num() > 0) { if (SceneTree::get_singleton()->is_debugging_collisions_hint() && _prop_instace->collider_get_num() > 0) {
_prop_instace->draw_debug_mdr_colliders(); _prop_instace->draw_debug_mdr_colliders();
} }
*/
#endif #endif
set_build_phase_type(BUILD_PHASE_TYPE_NORMAL); set_build_phase_type(BUILD_PHASE_TYPE_NORMAL);
@ -297,7 +294,7 @@ void Prop2DInstanceProp2DJob::phase_prop() {
Ref<Prop2DDataTiledWall2D> pdtw = e.data; Ref<Prop2DDataTiledWall2D> pdtw = e.data;
//Transform t = pdtw->get_transform(); //Transform t = pdtw->get_transform();
Transform 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);
} }

View File

@ -25,6 +25,8 @@ SOFTWARE.
#include "prop_2d_instance_job.h" #include "prop_2d_instance_job.h"
#include "scene/resources/shape_2d.h"
class Prop2DMesher; class Prop2DMesher;
class Prop2DInstance; class Prop2DInstance;
class Prop2DInstanceMerger; class Prop2DInstanceMerger;
@ -45,7 +47,7 @@ public:
Ref<Prop2DMaterialCache> get_material_cache(); Ref<Prop2DMaterialCache> get_material_cache();
void set_material_cache(const Ref<Prop2DMaterialCache> &cache); void set_material_cache(const Ref<Prop2DMaterialCache> &cache);
void add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape = false); void add_collision_shape(const Ref<Shape2D> &shape, const Transform2D &transform, const bool owns_shape = false);
void clear_collision_shapes(); void clear_collision_shapes();
Prop2DInstanceMerger *get_prop_instace(); Prop2DInstanceMerger *get_prop_instace();
@ -56,11 +58,11 @@ public:
void set_prop_mesher(const Ref<Prop2DMesher> &mesher); void set_prop_mesher(const Ref<Prop2DMesher> &mesher);
#if MESH_DATA_RESOURCE_PRESENT #if MESH_DATA_RESOURCE_PRESENT
void add_mesh(const Ref<Prop2DDataMeshData> &mesh_data, const Transform &base_transform); void add_mesh(const Ref<Prop2DDataMeshData> &mesh_data, const Transform2D &base_transform);
void clear_meshes(); void clear_meshes();
#endif #endif
void add_tiled_wall(const Ref<Prop2DDataTiledWall2D> &data, const Transform &base_transform); void add_tiled_wall(const Ref<Prop2DDataTiledWall2D> &data, const Transform2D &base_transform);
void clear_tiled_walls(); void clear_tiled_walls();
void add_light(const Ref<Prop2DLight> &light); void add_light(const Ref<Prop2DLight> &light);
@ -92,18 +94,18 @@ protected:
#if MESH_DATA_RESOURCE_PRESENT #if MESH_DATA_RESOURCE_PRESENT
struct PMDREntry { struct PMDREntry {
Ref<Prop2DDataMeshData> mesh_data; Ref<Prop2DDataMeshData> mesh_data;
Transform base_transform; Transform2D base_transform;
}; };
#endif #endif
struct PTWEntry { struct PTWEntry {
Ref<Prop2DDataTiledWall2D> data; Ref<Prop2DDataTiledWall2D> data;
Transform base_transform; Transform2D base_transform;
}; };
struct CollisionShapeEntry { struct CollisionShapeEntry {
Ref<Shape> shape; Ref<Shape2D> shape;
Transform transform; Transform2D transform;
bool owns_shape; bool owns_shape;
CollisionShapeEntry() { CollisionShapeEntry() {