Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_weightvgproximity.c
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "MOD_modifiertypes.h" | #include "MOD_modifiertypes.h" | ||||
| #include "MOD_ui_common.h" | #include "MOD_ui_common.h" | ||||
| #include "MOD_util.h" | #include "MOD_util.h" | ||||
| #include "MOD_weightvg_util.h" | #include "MOD_weightvg_util.h" | ||||
| //#define USE_TIMEIT | //#define USE_TIMEIT | ||||
| #ifdef USE_TIMEIT | #ifdef USE_TIMEIT | ||||
| # include "PIL_time.h" | # include "PIL_time.h" | ||||
| # include "PIL_time_utildefines.h" | # include "PIL_time_utildefines.h" | ||||
| #endif | #endif | ||||
| /************************************** | /************************************** | ||||
| * Util functions. * | * Util functions. * | ||||
| **************************************/ | **************************************/ | ||||
| static CLG_LogRef LOG = {"bke.MOD_weightvgproximity"}; | |||||
| /* Util macro. */ | /* Util macro. */ | ||||
| #define OUT_OF_MEMORY() ((void)printf("WeightVGProximity: Out of memory.\n")) | #define CLOG_OUT_OF_MEMORY() CLOG_ERROR(&LOG, "WeightVGProximity: Out of memory.\n") | ||||
| typedef struct Vert2GeomData { | typedef struct Vert2GeomData { | ||||
| /* Read-only data */ | /* Read-only data */ | ||||
| float (*v_cos)[3]; | float (*v_cos)[3]; | ||||
| const SpaceTransform *loc2trgt; | const SpaceTransform *loc2trgt; | ||||
| BVHTreeFromMesh *treeData[3]; | BVHTreeFromMesh *treeData[3]; | ||||
| ▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | static void get_vert2geom_distance(int numVerts, | ||||
| BVHTreeFromMesh treeData_v = {NULL}; | BVHTreeFromMesh treeData_v = {NULL}; | ||||
| BVHTreeFromMesh treeData_e = {NULL}; | BVHTreeFromMesh treeData_e = {NULL}; | ||||
| BVHTreeFromMesh treeData_f = {NULL}; | BVHTreeFromMesh treeData_f = {NULL}; | ||||
| if (dist_v) { | if (dist_v) { | ||||
| /* Create a bvh-tree of the given target's verts. */ | /* Create a bvh-tree of the given target's verts. */ | ||||
| BKE_bvhtree_from_mesh_get(&treeData_v, target, BVHTREE_FROM_VERTS, 2); | BKE_bvhtree_from_mesh_get(&treeData_v, target, BVHTREE_FROM_VERTS, 2); | ||||
| if (treeData_v.tree == NULL) { | if (treeData_v.tree == NULL) { | ||||
| OUT_OF_MEMORY(); | CLOG_OUT_OF_MEMORY(); | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| if (dist_e) { | if (dist_e) { | ||||
| /* Create a bvh-tree of the given target's edges. */ | /* Create a bvh-tree of the given target's edges. */ | ||||
| BKE_bvhtree_from_mesh_get(&treeData_e, target, BVHTREE_FROM_EDGES, 2); | BKE_bvhtree_from_mesh_get(&treeData_e, target, BVHTREE_FROM_EDGES, 2); | ||||
| if (treeData_e.tree == NULL) { | if (treeData_e.tree == NULL) { | ||||
| OUT_OF_MEMORY(); | CLOG_OUT_OF_MEMORY(); | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| if (dist_f) { | if (dist_f) { | ||||
| /* Create a bvh-tree of the given target's faces. */ | /* Create a bvh-tree of the given target's faces. */ | ||||
| BKE_bvhtree_from_mesh_get(&treeData_f, target, BVHTREE_FROM_LOOPTRI, 2); | BKE_bvhtree_from_mesh_get(&treeData_f, target, BVHTREE_FROM_LOOPTRI, 2); | ||||
| if (treeData_f.tree == NULL) { | if (treeData_f.tree == NULL) { | ||||
| OUT_OF_MEMORY(); | CLOG_OUT_OF_MEMORY(); | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| data.v_cos = v_cos; | data.v_cos = v_cos; | ||||
| data.loc2trgt = loc2trgt; | data.loc2trgt = loc2trgt; | ||||
| data.treeData[0] = &treeData_v; | data.treeData[0] = &treeData_v; | ||||
| data.treeData[1] = &treeData_e; | data.treeData[1] = &treeData_e; | ||||
| ▲ Show 20 Lines • Show All 550 Lines • Show Last 20 Lines | |||||