Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc
| Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | static Volume *create_volume_from_mesh(const Mesh &mesh, GeoNodeExecParams ¶ms) | ||||
| } | } | ||||
| else if (resolution.mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE) { | else if (resolution.mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE) { | ||||
| resolution.settings.voxel_size = params.get_input<float>("Voxel Size"); | resolution.settings.voxel_size = params.get_input<float>("Voxel Size"); | ||||
| if (resolution.settings.voxel_size <= 0.0f) { | if (resolution.settings.voxel_size <= 0.0f) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| } | } | ||||
| float3 min, max; | if (mesh.totvert == 0 || mesh.totpoly == 0) { | ||||
| INIT_MINMAX(min, max); | return nullptr; | ||||
| if (!BKE_mesh_wrapper_minmax(&mesh, min, max)) { | |||||
| min = float3(-1.0f); | |||||
| max = float3(1.0f); | |||||
| } | } | ||||
| const float4x4 mesh_to_volume_space_transform = float4x4::identity(); | const float4x4 mesh_to_volume_space_transform = float4x4::identity(); | ||||
| auto bounds_fn = [&](float3 &r_min, float3 &r_max) { | |||||
| float3 min{std::numeric_limits<float>::max()}; | |||||
| float3 max{-std::numeric_limits<float>::max()}; | |||||
| BKE_mesh_wrapper_minmax(&mesh, min, max); | |||||
| r_min = min; | |||||
| r_max = max; | |||||
| }; | |||||
| const float voxel_size = geometry::volume_compute_voxel_size(params.depsgraph(), | const float voxel_size = geometry::volume_compute_voxel_size(params.depsgraph(), | ||||
| min, | bounds_fn, | ||||
| max, | |||||
| resolution, | resolution, | ||||
| exterior_band_width, | exterior_band_width, | ||||
| mesh_to_volume_space_transform); | mesh_to_volume_space_transform); | ||||
| Volume *volume = (Volume *)BKE_id_new_nomain(ID_VO, nullptr); | Volume *volume = (Volume *)BKE_id_new_nomain(ID_VO, nullptr); | ||||
| BKE_volume_init_grids(volume); | BKE_volume_init_grids(volume); | ||||
| /* Convert mesh to grid and add to volume. */ | /* Convert mesh to grid and add to volume. */ | ||||
| ▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines | |||||