Remove _mmi_parent and dump_tree function. Handle instancer visibility
This commit is contained in:
parent
a996c9cd05
commit
6b2eb3c0d1
|
|
@ -93,7 +93,6 @@ private:
|
|||
|
||||
// Parent containers for child nodes
|
||||
Node3D *_label_parent;
|
||||
Node3D *_mmi_parent;
|
||||
|
||||
void _initialize();
|
||||
void __physics_process(const double p_delta);
|
||||
|
|
@ -138,7 +137,6 @@ public:
|
|||
Ref<Terrain3DAssets> get_assets() const { return _assets; }
|
||||
Terrain3DCollision *get_collision() const { return _collision; }
|
||||
Terrain3DInstancer *get_instancer() const { return _instancer; }
|
||||
Node *get_mmi_parent() const { return _mmi_parent; }
|
||||
void set_editor(Terrain3DEditor *p_editor);
|
||||
Terrain3DEditor *get_editor() const { return _editor; }
|
||||
void set_plugin(Object *p_plugin);
|
||||
|
|
@ -188,8 +186,8 @@ public:
|
|||
real_t get_cull_margin() const { return _cull_margin; };
|
||||
void set_free_editor_textures(const bool p_free_textures) { _free_editor_textures = p_free_textures; }
|
||||
bool get_free_editor_textures() const { return _free_editor_textures; };
|
||||
void set_show_instances(const bool p_visible) { _mmi_parent ? _mmi_parent->set_visible(p_visible) : void(); }
|
||||
bool get_show_instances() const { return _mmi_parent ? _mmi_parent->is_visible() : false; }
|
||||
void set_show_instances(const bool p_visible) { _instancer ? _instancer->set_show_instances(p_visible) : void(); }
|
||||
bool get_show_instances() const { return _instancer ? _instancer->get_show_instances() : true; }
|
||||
|
||||
// Utility
|
||||
Vector3 get_intersection(const Vector3 &p_src_pos, const Vector3 &p_direction, const bool p_gpu_mode = false);
|
||||
|
|
|
|||
|
|
@ -31,10 +31,11 @@ void Terrain3DInstancer::_process_updates() {
|
|||
bool update_all = false;
|
||||
if (_queued_updates.find({ V2I_MAX, -2 }) != _queued_updates.end()) {
|
||||
destroy();
|
||||
update_all = true;
|
||||
update_all = _show_instances;
|
||||
} else if (_queued_updates.find({ V2I_MAX, -1 }) != _queued_updates.end()) {
|
||||
update_all = true;
|
||||
update_all = _show_instances;
|
||||
}
|
||||
|
||||
if (update_all) {
|
||||
LOG(DEBUG, "Updating all regions, all mesh_ids");
|
||||
for (int i = 0; i < region_locations.size(); i++) {
|
||||
|
|
@ -1292,20 +1293,13 @@ void Terrain3DInstancer::update_mmis(const int p_mesh_id, const Vector2i &p_regi
|
|||
}
|
||||
}
|
||||
|
||||
void Terrain3DInstancer::dump_mmis() {
|
||||
LOG(WARN, "Dumping MMI tree");
|
||||
LOG(MESG, "_mmi tree: ");
|
||||
_terrain->get_mmi_parent()->print_tree();
|
||||
LOG(MESG, "_mmi_nodes size: ", int(_mmi_nodes.size()));
|
||||
for (auto &i : _region_mmis) {
|
||||
//LOG(MESG, "_mmi_nodes region: ", i.first, ", dict ptr: ", ptr_to_str(&i.second));
|
||||
for (auto &j : i.second) {
|
||||
//LOG(MESG, "mesh_mmi_dict mesh: ", j.first, ", dict ptr: ", &j.second.first);
|
||||
for (auto &k : j.second) {
|
||||
//LOG(MESG, "cell_mmi_dict cell: ", k.first, ", mmi ptr: ", (k.second));
|
||||
}
|
||||
}
|
||||
void Terrain3DInstancer::set_show_instances(const bool p_visible) {
|
||||
if (_show_instances == p_visible) {
|
||||
return;
|
||||
}
|
||||
LOG(INFO, "Setting instancer visibility to: ", p_visible);
|
||||
_show_instances = p_visible;
|
||||
update_mmis(-1, V2I_MAX, true);
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
|
|
@ -1326,5 +1320,6 @@ void Terrain3DInstancer::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_closest_mesh_id", "global_position"), &Terrain3DInstancer::get_closest_mesh_id);
|
||||
ClassDB::bind_method(D_METHOD("update_mmis", "mesh_id", "region_location", "rebuild_all"), &Terrain3DInstancer::update_mmis, DEFVAL(-1), DEFVAL(V2I_MAX), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("swap_ids", "src_id", "dest_id"), &Terrain3DInstancer::swap_ids);
|
||||
ClassDB::bind_method(D_METHOD("dump_mmis"), &Terrain3DInstancer::dump_mmis);
|
||||
ClassDB::bind_method(D_METHOD("set_show_instances", "p_visible"), &Terrain3DInstancer::set_show_instances);
|
||||
ClassDB::bind_method(D_METHOD("get_show_instances"), &Terrain3DInstancer::get_show_instances);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ private:
|
|||
V2IIntPair _queued_updates;
|
||||
|
||||
uint32_t _density_counter = 0;
|
||||
bool _show_instances = true;
|
||||
|
||||
uint32_t _get_density_count(const real_t p_density);
|
||||
void _process_updates();
|
||||
|
|
@ -84,7 +85,8 @@ public:
|
|||
void update_mmis(const int p_mesh_id = -1, const Vector2i &p_region_loc = V2I_MAX, const bool p_rebuild = false);
|
||||
|
||||
void reset_density_counter() { _density_counter = 0; }
|
||||
void dump_mmis();
|
||||
void set_show_instances(const bool p_visible);
|
||||
bool get_show_instances() const { return _show_instances; }
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
|
|
|||
Loading…
Reference in New Issue