Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mesh_remap.c
| Show All 20 Lines | |||||
| /** \file blender/blenkernel/intern/mesh_remap.c | /** \file blender/blenkernel/intern/mesh_remap.c | ||||
| * \ingroup bke | * \ingroup bke | ||||
| * | * | ||||
| * Functions for mapping data between meshes. | * Functions for mapping data between meshes. | ||||
| */ | */ | ||||
| #include <limits.h> | #include <limits.h> | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_alloca.h" | #include "BLI_alloca.h" | ||||
| #include "BLI_astar.h" | #include "BLI_astar.h" | ||||
| #include "BLI_bitmap.h" | #include "BLI_bitmap.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_memarena.h" | #include "BLI_memarena.h" | ||||
| #include "BLI_polyfill_2d.h" | #include "BLI_polyfill_2d.h" | ||||
| #include "BLI_rand.h" | #include "BLI_rand.h" | ||||
| #include "BKE_bvhutils.h" | #include "BKE_bvhutils.h" | ||||
| #include "BKE_customdata.h" | #include "BKE_customdata.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_mesh_mapping.h" | #include "BKE_mesh_mapping.h" | ||||
| #include "BKE_mesh_remap.h" /* own include */ | #include "BKE_mesh_remap.h" /* own include */ | ||||
| #include "BKE_mesh_runtime.h" | #include "BKE_mesh_runtime.h" | ||||
| #include "BLI_strict_flags.h" | #include "BLI_strict_flags.h" | ||||
| static CLG_LogRef LOG = {"bke.mesh"}; | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Some generic helpers. | /** \name Some generic helpers. | ||||
| * \{ */ | * \{ */ | ||||
| static bool mesh_remap_bvhtree_query_nearest( | static bool mesh_remap_bvhtree_query_nearest( | ||||
| BVHTreeFromMesh *treedata, BVHTreeNearest *nearest, | BVHTreeFromMesh *treedata, BVHTreeNearest *nearest, | ||||
| const float co[3], const float max_dist_sq, float *r_hit_dist) | const float co[3], const float max_dist_sq, float *r_hit_dist) | ||||
| ▲ Show 20 Lines • Show All 548 Lines • ▼ Show 20 Lines | else if (ELEM(mode, MREMAP_MODE_VERT_POLY_NEAREST, MREMAP_MODE_VERT_POLYINTERP_NEAREST, | ||||
| } | } | ||||
| MEM_freeN(vcos_src); | MEM_freeN(vcos_src); | ||||
| MEM_freeN(vcos); | MEM_freeN(vcos); | ||||
| MEM_freeN(indices); | MEM_freeN(indices); | ||||
| MEM_freeN(weights); | MEM_freeN(weights); | ||||
| } | } | ||||
| else { | else { | ||||
| printf("WARNING! Unsupported mesh-to-mesh vertex mapping mode (%d)!\n", mode); | CLOG_WARN(&LOG, "Unsupported mesh-to-mesh vertex mapping mode (%d)!", mode); | ||||
| memset(r_map->items, 0, sizeof(*r_map->items) * (size_t)numverts_dst); | memset(r_map->items, 0, sizeof(*r_map->items) * (size_t)numverts_dst); | ||||
| } | } | ||||
| free_bvhtree_from_mesh(&treedata); | free_bvhtree_from_mesh(&treedata); | ||||
| } | } | ||||
| } | } | ||||
| void BKE_mesh_remap_calc_edges_from_mesh( | void BKE_mesh_remap_calc_edges_from_mesh( | ||||
| ▲ Show 20 Lines • Show All 310 Lines • ▼ Show 20 Lines | else if (mode == MREMAP_MODE_EDGE_EDGEINTERP_VNORPROJ) { | ||||
| BKE_mesh_remap_item_define_invalid(r_map, i); | BKE_mesh_remap_item_define_invalid(r_map, i); | ||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(indices); | MEM_freeN(indices); | ||||
| MEM_freeN(weights); | MEM_freeN(weights); | ||||
| } | } | ||||
| else { | else { | ||||
| printf("WARNING! Unsupported mesh-to-mesh edge mapping mode (%d)!\n", mode); | CLOG_WARN(&LOG, "Unsupported mesh-to-mesh edge mapping mode (%d)!", mode); | ||||
| memset(r_map->items, 0, sizeof(*r_map->items) * (size_t)numedges_dst); | memset(r_map->items, 0, sizeof(*r_map->items) * (size_t)numedges_dst); | ||||
| } | } | ||||
| free_bvhtree_from_mesh(&treedata); | free_bvhtree_from_mesh(&treedata); | ||||
| } | } | ||||
| } | } | ||||
| #define POLY_UNSET 0 | #define POLY_UNSET 0 | ||||
| ▲ Show 20 Lines • Show All 1,256 Lines • ▼ Show 20 Lines | else if (mode == MREMAP_MODE_POLY_POLYINTERP_PNORPROJ) { | ||||
| MEM_freeN(tri_vidx_2d); | MEM_freeN(tri_vidx_2d); | ||||
| MEM_freeN(poly_vcos_2d); | MEM_freeN(poly_vcos_2d); | ||||
| MEM_freeN(indices); | MEM_freeN(indices); | ||||
| MEM_freeN(weights); | MEM_freeN(weights); | ||||
| BLI_rng_free(rng); | BLI_rng_free(rng); | ||||
| } | } | ||||
| else { | else { | ||||
| printf("WARNING! Unsupported mesh-to-mesh poly mapping mode (%d)!\n", mode); | CLOG_WARN(&LOG, "Unsupported mesh-to-mesh poly mapping mode (%d)!", mode); | ||||
| memset(r_map->items, 0, sizeof(*r_map->items) * (size_t)numpolys_dst); | memset(r_map->items, 0, sizeof(*r_map->items) * (size_t)numpolys_dst); | ||||
| } | } | ||||
| free_bvhtree_from_mesh(&treedata); | free_bvhtree_from_mesh(&treedata); | ||||
| } | } | ||||
| } | } | ||||
| #undef MREMAP_RAYCAST_APPROXIMATE_NR | #undef MREMAP_RAYCAST_APPROXIMATE_NR | ||||
| #undef MREMAP_RAYCAST_APPROXIMATE_FAC | #undef MREMAP_RAYCAST_APPROXIMATE_FAC | ||||
| #undef MREMAP_RAYCAST_TRI_SAMPLES_MIN | #undef MREMAP_RAYCAST_TRI_SAMPLES_MIN | ||||
| #undef MREMAP_RAYCAST_TRI_SAMPLES_MAX | #undef MREMAP_RAYCAST_TRI_SAMPLES_MAX | ||||
| #undef MREMAP_DEFAULT_BUFSIZE | #undef MREMAP_DEFAULT_BUFSIZE | ||||
| /** \} */ | /** \} */ | ||||