mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-14 10:17:20 +01:00
Now the mesher will set the material for the generated meshes directly, also it sets the material as surface material instead of an override material.
This commit is contained in:
parent
22bf841298
commit
ce4020962e
@ -63,10 +63,8 @@ void VoxelMesher::build_mesh(RID mesh) {
|
||||
|
||||
_surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
|
||||
|
||||
if (_material.is_valid())
|
||||
_surface_tool->set_material(_material);
|
||||
else
|
||||
_surface_tool->set_material(_library->get_material());
|
||||
//if (_material.is_valid())
|
||||
// _surface_tool->set_material(_material);
|
||||
|
||||
if (_colors.size() != _vertices.size()) {
|
||||
print_error("Colors.size() != vertices.size() -> " + String::num(_colors.size()) + " " + String::num(_vertices.size()));
|
||||
@ -102,6 +100,9 @@ void VoxelMesher::build_mesh(RID mesh) {
|
||||
Array arr = _surface_tool->commit_to_arrays();
|
||||
|
||||
VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VisualServer::PRIMITIVE_TRIANGLES, arr);
|
||||
|
||||
if (_material.is_valid())
|
||||
VS::get_singleton()->mesh_surface_set_material(mesh, 0, _library->get_material()->get_rid());
|
||||
}
|
||||
|
||||
void VoxelMesher::reset() {
|
||||
|
@ -466,6 +466,7 @@ void VoxelChunk::finalize_mesh() {
|
||||
allocate_main_mesh();
|
||||
}
|
||||
|
||||
_mesher->set_material(get_library()->get_material());
|
||||
get_mesher()->build_mesh(_mesh_rid);
|
||||
}
|
||||
|
||||
@ -784,7 +785,7 @@ void VoxelChunk::process_props() {
|
||||
call("_process_props");
|
||||
|
||||
_mesher->bake_colors(this);
|
||||
|
||||
_mesher->set_material(get_library()->get_material());
|
||||
_mesher->build_mesh(_prop_mesh_rid);
|
||||
}
|
||||
|
||||
@ -794,7 +795,7 @@ void VoxelChunk::build_prop_meshes() {
|
||||
}
|
||||
|
||||
_mesher->bake_colors(this);
|
||||
|
||||
_mesher->set_material(get_library()->get_material());
|
||||
_mesher->build_mesh(_prop_mesh_rid);
|
||||
}
|
||||
|
||||
@ -802,14 +803,9 @@ void VoxelChunk::allocate_main_mesh() {
|
||||
ERR_FAIL_COND(_voxel_world == NULL);
|
||||
|
||||
ERR_FAIL_COND(!get_library().is_valid());
|
||||
ERR_FAIL_COND(!get_library()->get_material().is_valid());
|
||||
|
||||
_mesh_instance_rid = VS::get_singleton()->instance_create();
|
||||
|
||||
if (get_library()->get_material().is_valid()) {
|
||||
VS::get_singleton()->instance_geometry_set_material_override(_mesh_instance_rid, get_library()->get_material()->get_rid());
|
||||
}
|
||||
|
||||
if (get_voxel_world()->get_world().is_valid())
|
||||
VS::get_singleton()->instance_set_scenario(_mesh_instance_rid, get_voxel_world()->get_world()->get_scenario());
|
||||
|
||||
@ -833,14 +829,9 @@ void VoxelChunk::free_main_mesh() {
|
||||
void VoxelChunk::allocate_prop_mesh() {
|
||||
ERR_FAIL_COND(_voxel_world == NULL);
|
||||
ERR_FAIL_COND(!get_library().is_valid());
|
||||
ERR_FAIL_COND(!get_library()->get_prop_material().is_valid());
|
||||
|
||||
_prop_mesh_instance_rid = VS::get_singleton()->instance_create();
|
||||
|
||||
if (get_library()->get_prop_material().is_valid()) {
|
||||
VS::get_singleton()->instance_geometry_set_material_override(_prop_mesh_instance_rid, get_library()->get_prop_material()->get_rid());
|
||||
}
|
||||
|
||||
if (get_voxel_world()->get_world().is_valid())
|
||||
VS::get_singleton()->instance_set_scenario(_prop_mesh_instance_rid, get_voxel_world()->get_world()->get_scenario());
|
||||
|
||||
@ -898,14 +889,9 @@ void VoxelChunk::allocate_liquid_mesh() {
|
||||
ERR_FAIL_COND(_voxel_world == NULL);
|
||||
|
||||
ERR_FAIL_COND(!get_library().is_valid());
|
||||
ERR_FAIL_COND(!get_library()->get_liquid_material().is_valid());
|
||||
|
||||
_liquid_mesh_instance_rid = VS::get_singleton()->instance_create();
|
||||
|
||||
if (get_library()->get_liquid_material().is_valid()) {
|
||||
VS::get_singleton()->instance_geometry_set_material_override(_liquid_mesh_instance_rid, get_library()->get_liquid_material()->get_rid());
|
||||
}
|
||||
|
||||
if (get_voxel_world()->get_world().is_valid())
|
||||
VS::get_singleton()->instance_set_scenario(_liquid_mesh_instance_rid, get_voxel_world()->get_world()->get_scenario());
|
||||
|
||||
@ -931,14 +917,9 @@ void VoxelChunk::allocate_clutter_mesh() {
|
||||
ERR_FAIL_COND(_voxel_world == NULL);
|
||||
|
||||
ERR_FAIL_COND(!get_library().is_valid());
|
||||
ERR_FAIL_COND(!get_library()->get_clutter_material().is_valid());
|
||||
|
||||
_clutter_mesh_instance_rid = VS::get_singleton()->instance_create();
|
||||
|
||||
if (get_library()->get_clutter_material().is_valid()) {
|
||||
VS::get_singleton()->instance_geometry_set_material_override(_clutter_mesh_instance_rid, get_library()->get_clutter_material()->get_rid());
|
||||
}
|
||||
|
||||
if (get_voxel_world()->get_world().is_valid())
|
||||
VS::get_singleton()->instance_set_scenario(_clutter_mesh_instance_rid, get_voxel_world()->get_world()->get_scenario());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user