Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mesh_remesh_voxel.c
| Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | struct OpenVDBLevelSet *BKE_mesh_remesh_voxel_ovdb_mesh_to_level_set_create( | ||||
| for (unsigned int i = 0; i < totfaces; i++) { | for (unsigned int i = 0; i < totfaces; i++) { | ||||
| MVertTri *vt = &verttri[i]; | MVertTri *vt = &verttri[i]; | ||||
| faces[i * 3] = vt->tri[0]; | faces[i * 3] = vt->tri[0]; | ||||
| faces[i * 3 + 1] = vt->tri[1]; | faces[i * 3 + 1] = vt->tri[1]; | ||||
| faces[i * 3 + 2] = vt->tri[2]; | faces[i * 3 + 2] = vt->tri[2]; | ||||
| } | } | ||||
| struct OpenVDBLevelSet *level_set = OpenVDBLevelSet_create(false, NULL); | struct OpenVDBLevelSet *level_set = OpenVDBLevelSet_create(false, 0.0f, 0.0f); | ||||
| OpenVDBLevelSet_mesh_to_level_set(level_set, verts, faces, totverts, totfaces, transform); | OpenVDBLevelSet_mesh_to_level_set( | ||||
| level_set, verts, faces, totverts, totfaces, transform, true, false, 0); | |||||
| MEM_freeN(verts); | MEM_freeN(verts); | ||||
| MEM_freeN(faces); | MEM_freeN(faces); | ||||
| MEM_freeN(verttri); | MEM_freeN(verttri); | ||||
| return level_set; | return level_set; | ||||
| } | } | ||||
| Mesh *BKE_mesh_remesh_voxel_ovdb_volume_to_mesh_nomain(struct OpenVDBLevelSet *level_set, | Mesh *BKE_mesh_remesh_voxel_ovdb_volume_to_mesh_nomain(struct OpenVDBLevelSet *level_set, | ||||
| double isovalue, | double isovalue, | ||||
| double adaptivity, | double adaptivity, | ||||
| bool relax_disoriented_triangles) | bool relax_disoriented_triangles) | ||||
| { | { | ||||
| # ifdef WITH_OPENVDB | # ifdef WITH_OPENVDB | ||||
| struct OpenVDBVolumeToMeshData output_mesh; | struct OpenVDBVolumeToMeshData output_mesh; | ||||
| OpenVDBLevelSet_volume_to_mesh( | OpenVDBLevelSet_volume_to_mesh( | ||||
| level_set, &output_mesh, isovalue, adaptivity, relax_disoriented_triangles); | level_set, &output_mesh, isovalue, adaptivity, relax_disoriented_triangles, NULL); | ||||
| # endif | # endif | ||||
| Mesh *mesh = BKE_mesh_new_nomain(output_mesh.totvertices, | Mesh *mesh = BKE_mesh_new_nomain(output_mesh.totvertices, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| (output_mesh.totquads * 4) + (output_mesh.tottriangles * 3), | (output_mesh.totquads * 4) + (output_mesh.tottriangles * 3), | ||||
| output_mesh.totquads + output_mesh.tottriangles); | output_mesh.totquads + output_mesh.tottriangles); | ||||
| ▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | for (int i = 0; i < target->totvert; i++) { | ||||
| if (nearest.index != -1) { | if (nearest.index != -1) { | ||||
| copy_v4_v4(target_color[i].color, source_color[nearest.index].color); | copy_v4_v4(target_color[i].color, source_color[nearest.index].color); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| free_bvhtree_from_mesh(&bvhtree); | free_bvhtree_from_mesh(&bvhtree); | ||||
| } | } | ||||
| struct Mesh *BKE_mesh_remesh_voxel_fix_poles(struct Mesh *mesh) | struct Mesh *BKE_mesh_remesh_voxel_fix_poles(struct Mesh *mesh, bool UNUSED(smooth)) | ||||
| { | { | ||||
| const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh); | const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh); | ||||
| BMesh *bm; | BMesh *bm; | ||||
| bm = BM_mesh_create(&allocsize, | bm = BM_mesh_create(&allocsize, | ||||
| &((struct BMeshCreateParams){ | &((struct BMeshCreateParams){ | ||||
| .use_toolflags = true, | .use_toolflags = true, | ||||
| })); | })); | ||||
| ▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines | |||||