Same treatment to the mesh related methods in VoxelChunkDefault.

This commit is contained in:
Relintai 2020-10-27 19:04:20 +01:00
parent 9c5aed85df
commit f4ba38ecd0
4 changed files with 106 additions and 102 deletions

View File

@ -83,12 +83,12 @@ void VoxelChunkDefault::set_current_lod_level(const int value) {
if (i == _current_lod_level)
vis = true;
RID rid = get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH_INSTANCE, i);
RID rid = mesh_rid_get_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH_INSTANCE, i);
if (rid != RID())
VisualServer::get_singleton()->instance_set_visible(rid, vis);
rid = get_mesh_rid_index(MESH_INDEX_PROP, MESH_TYPE_INDEX_MESH_INSTANCE, i);
rid = mesh_rid_get_index(MESH_INDEX_PROP, MESH_TYPE_INDEX_MESH_INSTANCE, i);
if (rid != RID())
VisualServer::get_singleton()->instance_set_visible(rid, vis);
@ -104,17 +104,14 @@ void VoxelChunkDefault::emit_build_finished() {
}
//Meshes
Dictionary VoxelChunkDefault::get_mesh_rids() {
Dictionary VoxelChunkDefault::mesh_rids_get() {
return _rids;
}
void VoxelChunkDefault::set_mesh_rids(const Dictionary &rids) {
void VoxelChunkDefault::mesh_rids_set(const Dictionary &rids) {
_rids = rids;
}
void VoxelChunkDefault::clear_rids() {
_rids.clear();
}
RID VoxelChunkDefault::get_mesh_rid(const int mesh_index, const int mesh_type_index) {
RID VoxelChunkDefault::mesh_rid_get(const int mesh_index, const int mesh_type_index) {
if (!_rids.has(mesh_index))
return RID();
@ -130,7 +127,7 @@ RID VoxelChunkDefault::get_mesh_rid(const int mesh_index, const int mesh_type_in
return v;
}
void VoxelChunkDefault::set_mesh_rid(const int mesh_index, const int mesh_type_index, RID value) {
void VoxelChunkDefault::mesh_rid_set(const int mesh_index, const int mesh_type_index, RID value) {
if (!_rids.has(mesh_index))
_rids[mesh_index] = Dictionary();
@ -149,7 +146,7 @@ void VoxelChunkDefault::set_mesh_rid(const int mesh_index, const int mesh_type_i
m[mesh_type_index] = value;
_rids[mesh_index] = m;
}
RID VoxelChunkDefault::get_mesh_rid_index(const int mesh_index, const int mesh_type_index, const int index) {
RID VoxelChunkDefault::mesh_rid_get_index(const int mesh_index, const int mesh_type_index, const int index) {
if (!_rids.has(mesh_index))
return RID();
@ -169,7 +166,7 @@ RID VoxelChunkDefault::get_mesh_rid_index(const int mesh_index, const int mesh_t
return arr[index];
}
void VoxelChunkDefault::set_mesh_rid_index(const int mesh_index, const int mesh_type_index, const int index, RID value) {
void VoxelChunkDefault::mesh_rid_set_index(const int mesh_index, const int mesh_type_index, const int index, RID value) {
if (!_rids.has(mesh_index))
_rids[mesh_index] = Dictionary();
@ -199,7 +196,7 @@ void VoxelChunkDefault::set_mesh_rid_index(const int mesh_index, const int mesh_
m[mesh_type_index] = arr;
_rids[mesh_index] = m;
}
int VoxelChunkDefault::get_mesh_rid_count(const int mesh_index, const int mesh_type_index) {
int VoxelChunkDefault::mesh_rid_get_count(const int mesh_index, const int mesh_type_index) {
if (!_rids.has(mesh_index))
return 0;
@ -217,7 +214,7 @@ int VoxelChunkDefault::get_mesh_rid_count(const int mesh_index, const int mesh_t
return arr.size();
}
void VoxelChunkDefault::clear_mesh_rids(const int mesh_index, const int mesh_type_index) {
void VoxelChunkDefault::mesh_rids_clear(const int mesh_index, const int mesh_type_index) {
if (!_rids.has(mesh_index))
return;
@ -228,7 +225,7 @@ void VoxelChunkDefault::clear_mesh_rids(const int mesh_index, const int mesh_typ
m.erase(mesh_type_index);
}
Array VoxelChunkDefault::get_meshes(const int mesh_index, const int mesh_type_index) {
Array VoxelChunkDefault::meshes_get(const int mesh_index, const int mesh_type_index) {
if (!_rids.has(mesh_index))
return Array();
@ -244,7 +241,7 @@ Array VoxelChunkDefault::get_meshes(const int mesh_index, const int mesh_type_in
return v;
}
void VoxelChunkDefault::set_meshes(const int mesh_index, const int mesh_type_index, const Array &meshes) {
void VoxelChunkDefault::meshes_set(const int mesh_index, const int mesh_type_index, const Array &meshes) {
if (!_rids.has(mesh_index))
_rids[mesh_index] = Dictionary();
@ -253,7 +250,7 @@ void VoxelChunkDefault::set_meshes(const int mesh_index, const int mesh_type_ind
m[mesh_type_index] = meshes;
_rids[mesh_index] = m;
}
bool VoxelChunkDefault::has_meshes(const int mesh_index, const int mesh_type_index) {
bool VoxelChunkDefault::meshes_has(const int mesh_index, const int mesh_type_index) {
if (!_rids.has(mesh_index))
return false;
@ -265,7 +262,11 @@ bool VoxelChunkDefault::has_meshes(const int mesh_index, const int mesh_type_ind
return true;
}
void VoxelChunkDefault::free_rids() {
void VoxelChunkDefault::rids_clear() {
_rids.clear();
}
void VoxelChunkDefault::rids_free() {
List<Variant> keys;
_rids.get_key_list(&keys);
@ -280,12 +281,7 @@ void VoxelChunkDefault::free_rids() {
}
}
void VoxelChunkDefault::free_index(const int mesh_index) {
free_meshes(mesh_index);
free_colliders(mesh_index);
}
void VoxelChunkDefault::create_meshes(const int mesh_index, const int mesh_count) {
void VoxelChunkDefault::meshes_create(const int mesh_index, const int mesh_count) {
ERR_FAIL_COND(_voxel_world == NULL);
ERR_FAIL_COND(!get_library().is_valid());
@ -324,7 +320,7 @@ void VoxelChunkDefault::create_meshes(const int mesh_index, const int mesh_count
_rids[mesh_index] = m;
}
void VoxelChunkDefault::free_meshes(const int mesh_index) {
void VoxelChunkDefault::meshes_free(const int mesh_index) {
if (!_rids.has(mesh_index))
return;
@ -359,7 +355,7 @@ void VoxelChunkDefault::free_meshes(const int mesh_index) {
m.erase(MESH_TYPE_INDEX_MESH_INSTANCE);
}
void VoxelChunkDefault::create_colliders(const int mesh_index, const int layer_mask) {
void VoxelChunkDefault::colliders_create(const int mesh_index, const int layer_mask) {
ERR_FAIL_COND(_voxel_world == NULL);
ERR_FAIL_COND(PhysicsServer::get_singleton()->is_flushing_queries());
//ERR_FAIL_COND(!get_voxel_world()->is_inside_tree());
@ -394,7 +390,7 @@ void VoxelChunkDefault::create_colliders(const int mesh_index, const int layer_m
_rids[mesh_index] = m;
}
void VoxelChunkDefault::create_colliders_area(const int mesh_index, const int layer_mask) {
void VoxelChunkDefault::colliders_create_area(const int mesh_index, const int layer_mask) {
ERR_FAIL_COND(_voxel_world == NULL);
ERR_FAIL_COND(PhysicsServer::get_singleton()->is_flushing_queries());
@ -435,7 +431,7 @@ void VoxelChunkDefault::create_colliders_area(const int mesh_index, const int la
_rids[mesh_index] = m;
}
void VoxelChunkDefault::free_colliders(const int mesh_index) {
void VoxelChunkDefault::colliders_free(const int mesh_index) {
if (!_rids.has(mesh_index))
return;
@ -460,6 +456,11 @@ void VoxelChunkDefault::free_colliders(const int mesh_index) {
_rids[mesh_index] = m;
}
void VoxelChunkDefault::free_index(const int mesh_index) {
meshes_free(mesh_index);
colliders_free(mesh_index);
}
void VoxelChunkDefault::update_transforms() {
RID empty_rid;
Transform t = get_transform();
@ -702,17 +703,17 @@ void VoxelChunkDefault::_visibility_changed(bool visible) {
}
for (int i = 0; i < _lod_num + 1; ++i) {
RID rid = get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH_INSTANCE, i);
RID rid = mesh_rid_get_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH_INSTANCE, i);
if (rid != RID())
VisualServer::get_singleton()->instance_set_visible(rid, false);
rid = get_mesh_rid_index(MESH_INDEX_LIQUID, MESH_TYPE_INDEX_MESH_INSTANCE, i);
rid = mesh_rid_get_index(MESH_INDEX_LIQUID, MESH_TYPE_INDEX_MESH_INSTANCE, i);
if (rid != RID())
VisualServer::get_singleton()->instance_set_visible(rid, false);
rid = get_mesh_rid_index(MESH_INDEX_PROP, MESH_TYPE_INDEX_MESH_INSTANCE, i);
rid = mesh_rid_get_index(MESH_INDEX_PROP, MESH_TYPE_INDEX_MESH_INSTANCE, i);
if (rid != RID())
VisualServer::get_singleton()->instance_set_visible(rid, false);
@ -722,7 +723,7 @@ void VoxelChunkDefault::_visibility_changed(bool visible) {
void VoxelChunkDefault::_exit_tree() {
VoxelChunk::_exit_tree();
free_rids();
rids_free();
}
void VoxelChunkDefault::_world_transform_changed() {
@ -830,7 +831,7 @@ void VoxelChunkDefault::_world_light_removed(const Ref<VoxelLight> &light) {
}
void VoxelChunkDefault::free_chunk() {
free_rids();
rids_free();
}
void VoxelChunkDefault::_finalize_build() {
@ -888,28 +889,28 @@ void VoxelChunkDefault::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_lod_level"), "set_current_lod_level", "get_current_lod_level");
//Meshes
ClassDB::bind_method(D_METHOD("get_mesh_rids"), &VoxelChunkDefault::get_mesh_rids);
ClassDB::bind_method(D_METHOD("set_mesh_rids", "rids"), &VoxelChunkDefault::set_mesh_rids);
ClassDB::bind_method(D_METHOD("clear_rids"), &VoxelChunkDefault::clear_rids);
ClassDB::bind_method(D_METHOD("get_mesh_rids"), &VoxelChunkDefault::mesh_rids_get);
ClassDB::bind_method(D_METHOD("set_mesh_rids", "rids"), &VoxelChunkDefault::mesh_rids_set);
ClassDB::bind_method(D_METHOD("clear_rids"), &VoxelChunkDefault::rids_clear);
ClassDB::bind_method(D_METHOD("get_mesh_rid", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::get_mesh_rid);
ClassDB::bind_method(D_METHOD("set_mesh_rid", "mesh_index", "mesh_type_index", "value"), &VoxelChunkDefault::set_mesh_rid);
ClassDB::bind_method(D_METHOD("get_mesh_rid_index", "mesh_index", "mesh_type_index", "index"), &VoxelChunkDefault::get_mesh_rid_index);
ClassDB::bind_method(D_METHOD("set_mesh_rid_index", "mesh_index", "mesh_type_index", "index", "value"), &VoxelChunkDefault::set_mesh_rid_index);
ClassDB::bind_method(D_METHOD("get_mesh_rid_count", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::get_mesh_rid_count);
ClassDB::bind_method(D_METHOD("clear_mesh_rids", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::clear_mesh_rids);
ClassDB::bind_method(D_METHOD("get_meshes", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::get_meshes);
ClassDB::bind_method(D_METHOD("set_meshes", "mesh_index", "mesh_type_index", "meshes"), &VoxelChunkDefault::set_meshes);
ClassDB::bind_method(D_METHOD("has_meshes", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::has_meshes);
ClassDB::bind_method(D_METHOD("mesh_rid_get", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::mesh_rid_get);
ClassDB::bind_method(D_METHOD("mesh_rid_set", "mesh_index", "mesh_type_index", "value"), &VoxelChunkDefault::mesh_rid_set);
ClassDB::bind_method(D_METHOD("mesh_rid_get_index", "mesh_index", "mesh_type_index", "index"), &VoxelChunkDefault::mesh_rid_get_index);
ClassDB::bind_method(D_METHOD("mesh_rid_set_index", "mesh_index", "mesh_type_index", "index", "value"), &VoxelChunkDefault::mesh_rid_set_index);
ClassDB::bind_method(D_METHOD("mesh_rid_get_count", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::mesh_rid_get_count);
ClassDB::bind_method(D_METHOD("mesh_rids_clear", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::mesh_rids_clear);
ClassDB::bind_method(D_METHOD("meshes_get", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::meshes_get);
ClassDB::bind_method(D_METHOD("meshes_set", "mesh_index", "mesh_type_index", "meshes"), &VoxelChunkDefault::meshes_set);
ClassDB::bind_method(D_METHOD("meshes_has", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::meshes_has);
ClassDB::bind_method(D_METHOD("free_rids"), &VoxelChunkDefault::free_rids);
ClassDB::bind_method(D_METHOD("rids_free"), &VoxelChunkDefault::rids_free);
ClassDB::bind_method(D_METHOD("free_index", "mesh_index"), &VoxelChunkDefault::free_index);
ClassDB::bind_method(D_METHOD("create_meshes", "mesh_index", "mesh_count"), &VoxelChunkDefault::create_meshes);
ClassDB::bind_method(D_METHOD("free_meshes", "mesh_index"), &VoxelChunkDefault::free_meshes);
ClassDB::bind_method(D_METHOD("meshes_create", "mesh_index", "mesh_count"), &VoxelChunkDefault::meshes_create);
ClassDB::bind_method(D_METHOD("meshes_free", "mesh_index"), &VoxelChunkDefault::meshes_free);
ClassDB::bind_method(D_METHOD("create_colliders", "mesh_index", "layer_mask"), &VoxelChunkDefault::create_colliders, DEFVAL(1));
ClassDB::bind_method(D_METHOD("free_colliders", "mesh_index"), &VoxelChunkDefault::free_colliders);
ClassDB::bind_method(D_METHOD("create_colliders", "mesh_index", "layer_mask"), &VoxelChunkDefault::colliders_create, DEFVAL(1));
ClassDB::bind_method(D_METHOD("free_colliders", "mesh_index"), &VoxelChunkDefault::colliders_free);
//Lights
ClassDB::bind_method(D_METHOD("get_light", "index"), &VoxelChunkDefault::get_light);

View File

@ -114,30 +114,33 @@ public:
void set_current_lod_level(const int value);
//Meshes
Dictionary get_mesh_rids();
void set_mesh_rids(const Dictionary &rids);
void clear_rids();
Dictionary mesh_rids_get();
void mesh_rids_set(const Dictionary &rids);
RID get_mesh_rid(const int mesh_index, const int mesh_type_index);
void set_mesh_rid(const int mesh_index, const int mesh_type_index, RID value);
RID get_mesh_rid_index(const int mesh_index, const int mesh_type_index, const int index);
void set_mesh_rid_index(const int mesh_index, const int mesh_type_index, const int index, RID value);
int get_mesh_rid_count(const int mesh_index, const int mesh_type_index);
void clear_mesh_rids(const int mesh_index, const int mesh_type_index);
Array get_meshes(const int mesh_index, const int mesh_type_index);
void set_meshes(const int mesh_index, const int mesh_type_index, const Array &meshes);
bool has_meshes(const int mesh_index, const int mesh_type_index);
RID mesh_rid_get(const int mesh_index, const int mesh_type_index);
void mesh_rid_set(const int mesh_index, const int mesh_type_index, RID value);
RID mesh_rid_get_index(const int mesh_index, const int mesh_type_index, const int index);
void mesh_rid_set_index(const int mesh_index, const int mesh_type_index, const int index, RID value);
int mesh_rid_get_count(const int mesh_index, const int mesh_type_index);
void mesh_rids_clear(const int mesh_index, const int mesh_type_index);
Array meshes_get(const int mesh_index, const int mesh_type_index);
void meshes_set(const int mesh_index, const int mesh_type_index, const Array &meshes);
bool meshes_has(const int mesh_index, const int mesh_type_index);
void rids_clear();
void rids_free();
void meshes_create(const int mesh_index, const int mesh_count);
void meshes_free(const int mesh_index);
void colliders_create(const int mesh_index, const int layer_mask = 1);
void colliders_create_area(const int mesh_index, const int layer_mask = 1);
void colliders_free(const int mesh_index);
void free_rids();
void free_index(const int mesh_index);
void create_meshes(const int mesh_index, const int mesh_count);
void free_meshes(const int mesh_index);
void create_colliders(const int mesh_index, const int layer_mask = 1);
void create_colliders_area(const int mesh_index, const int layer_mask = 1);
void free_colliders(const int mesh_index);
//Transform
void update_transforms();

View File

@ -198,16 +198,16 @@ void VoxelPropJob::phase_prop() {
}
}
RID mesh_rid = chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
RID mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
if (should_do()) {
if (mesh_rid == RID()) {
if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) != 0)
chunk->create_meshes(VoxelChunkDefault::MESH_INDEX_PROP, chunk->get_lod_num() + 1);
chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_PROP, chunk->get_lod_num() + 1);
else
chunk->create_meshes(VoxelChunkDefault::MESH_INDEX_PROP, 1);
chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_PROP, 1);
mesh_rid = chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
}
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
@ -241,10 +241,10 @@ void VoxelPropJob::phase_prop() {
//for lod 1 just remove uv2
temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant();
VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
if (chunk->get_library()->get_prop_material(1).is_valid())
VisualServer::get_singleton()->mesh_surface_set_material(chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), 0, chunk->get_library()->get_prop_material(1)->get_rid());
VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), 0, chunk->get_library()->get_prop_material(1)->get_rid());
}
if (should_return()) {
@ -257,10 +257,10 @@ void VoxelPropJob::phase_prop() {
Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr);
temp_mesh_arr = temp_mesh_arr2;
VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr2);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr2);
if (chunk->get_library()->get_prop_material(2).is_valid())
VisualServer::get_singleton()->mesh_surface_set_material(chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), 0, chunk->get_library()->get_prop_material(2)->get_rid());
VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), 0, chunk->get_library()->get_prop_material(2)->get_rid());
}
if (should_return()) {
return;
@ -283,10 +283,10 @@ void VoxelPropJob::phase_prop() {
temp_mesh_arr = bake_mesh_array_uv(temp_mesh_arr, tex);
temp_mesh_arr[VisualServer::ARRAY_TEX_UV] = Variant();
VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
if (chunk->get_library()->get_prop_material(3).is_valid())
VisualServer::get_singleton()->mesh_surface_set_material(chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), 0, chunk->get_library()->get_prop_material(3)->get_rid());
VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), 0, chunk->get_library()->get_prop_material(3)->get_rid());
}
}
@ -303,12 +303,12 @@ void VoxelPropJob::phase_prop() {
temp_mesh_arr = fqms->get_arrays();
VisualServer::get_singleton()->mesh_add_surface_from_arrays(
chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i),
chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i),
VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
if (chunk->get_library()->get_material(i).is_valid())
VisualServer::get_singleton()->mesh_surface_set_material(
chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), 0,
chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), 0,
chunk->get_library()->get_material(i)->get_rid());
}
}

View File

@ -220,19 +220,19 @@ void VoxelTerrarinJob::phase_physics_process() {
Ref<VoxelChunkDefault> chunk = _chunk;
if (temp_arr_collider.size() != 0) {
if (!chunk->has_meshes(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_BODY)) {
chunk->create_colliders(VoxelChunkDefault::MESH_INDEX_TERRARIN);
if (!chunk->meshes_has(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_BODY)) {
chunk->colliders_create(VoxelChunkDefault::MESH_INDEX_TERRARIN);
}
PhysicsServer::get_singleton()->shape_set_data(chunk->get_mesh_rid(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_SHAPE), temp_arr_collider);
PhysicsServer::get_singleton()->shape_set_data(chunk->mesh_rid_get(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_SHAPE), temp_arr_collider);
temp_arr_collider.resize(0);
}
if (temp_arr_collider_liquid.size() != 0) {
if (Engine::get_singleton()->is_editor_hint()) {
if (!chunk->has_meshes(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_BODY)) {
chunk->create_colliders(VoxelChunkDefault::MESH_INDEX_LIQUID);
if (!chunk->meshes_has(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_BODY)) {
chunk->colliders_create(VoxelChunkDefault::MESH_INDEX_LIQUID);
}
}
/*
@ -242,7 +242,7 @@ void VoxelTerrarinJob::phase_physics_process() {
}
}*/
PhysicsServer::get_singleton()->shape_set_data(chunk->get_mesh_rid(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_SHAPE), temp_arr_collider_liquid);
PhysicsServer::get_singleton()->shape_set_data(chunk->mesh_rid_get(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_SHAPE), temp_arr_collider_liquid);
temp_arr_collider_liquid.resize(0);
}
@ -378,16 +378,16 @@ void VoxelTerrarinJob::phase_terrarin_mesh() {
}
}
RID mesh_rid = chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
RID mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
if (should_do()) {
if (mesh_rid == RID()) {
if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) != 0)
chunk->create_meshes(VoxelChunkDefault::MESH_INDEX_TERRARIN, chunk->get_lod_num() + 1);
chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_TERRARIN, chunk->get_lod_num() + 1);
else
chunk->create_meshes(VoxelChunkDefault::MESH_INDEX_TERRARIN, 1);
chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_TERRARIN, 1);
mesh_rid = chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
}
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
@ -419,10 +419,10 @@ void VoxelTerrarinJob::phase_terrarin_mesh() {
//for lod 1 just remove uv2
temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant();
VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
if (chunk->get_library()->get_material(1).is_valid())
VisualServer::get_singleton()->mesh_surface_set_material(chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), 0, chunk->get_library()->get_material(1)->get_rid());
VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), 0, chunk->get_library()->get_material(1)->get_rid());
}
if (should_return()) {
return;
@ -434,10 +434,10 @@ void VoxelTerrarinJob::phase_terrarin_mesh() {
Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr);
temp_mesh_arr = temp_mesh_arr2;
VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr2);
VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr2);
if (chunk->get_library()->get_material(2).is_valid())
VisualServer::get_singleton()->mesh_surface_set_material(chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), 0, chunk->get_library()->get_material(2)->get_rid());
VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), 0, chunk->get_library()->get_material(2)->get_rid());
}
if (should_return()) {
@ -462,12 +462,12 @@ void VoxelTerrarinJob::phase_terrarin_mesh() {
temp_mesh_arr[VisualServer::ARRAY_TEX_UV] = Variant();
VisualServer::get_singleton()->mesh_add_surface_from_arrays(
chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3),
chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3),
VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
if (chunk->get_library()->get_material(3).is_valid())
VisualServer::get_singleton()->mesh_surface_set_material(
chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), 0,
chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), 0,
chunk->get_library()->get_material(3)->get_rid());
}
}
@ -490,12 +490,12 @@ void VoxelTerrarinJob::phase_terrarin_mesh() {
temp_mesh_arr = fqms->get_arrays();
VisualServer::get_singleton()->mesh_add_surface_from_arrays(
chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i),
chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i),
VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
if (chunk->get_library()->get_material(i).is_valid())
VisualServer::get_singleton()->mesh_surface_set_material(
chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), 0,
chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), 0,
chunk->get_library()->get_material(i)->get_rid());
}
}
@ -517,13 +517,13 @@ void VoxelTerrarinJob::phase_terrarin_mesh() {
}
}
RID mesh_rid = chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
RID mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
if (should_do()) {
if (mesh_rid == RID()) {
chunk->create_meshes(VoxelChunkDefault::MESH_INDEX_LIQUID, 1);
chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_LIQUID, 1);
mesh_rid = chunk->get_mesh_rid_index(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0);
}
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)