Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/shrinkwrap.c
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| typedef union { | |||||
| BVHTreeFromEditMesh emtreedata; | |||||
| BVHTreeFromMesh dmtreedata; | |||||
| } TreeData; | |||||
| static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for_render) | static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for_render) | ||||
| { | { | ||||
| /* Options about projection direction */ | /* Options about projection direction */ | ||||
| Context not available. | |||||
| * for finding the best hit, to get the real dist, | * for finding the best hit, to get the real dist, | ||||
| * measure the len_v3v3() from the input coord to hit.co */ | * measure the len_v3v3() from the input coord to hit.co */ | ||||
| BVHTreeRayHit hit; | BVHTreeRayHit hit; | ||||
| void *treeData = NULL; | void *targData = NULL; | ||||
| /* auxiliary target */ | /* auxiliary target */ | ||||
| DerivedMesh *auxMesh = NULL; | DerivedMesh *auxMesh = NULL; | ||||
| Context not available. | |||||
| /* use editmesh to avoid array allocation */ | /* use editmesh to avoid array allocation */ | ||||
| BMEditMesh *emtarget = NULL, *emaux = NULL; | BMEditMesh *emtarget = NULL, *emaux = NULL; | ||||
| BVHTreeFromEditMesh emtreedata_stack, emauxdata_stack; | TreeData targdata_stack, auxdata_stack; | ||||
| BVHTreeFromMesh dmtreedata_stack, dmauxdata_stack; | |||||
| BVHTree *targ_tree; | BVHTree *targ_tree; | ||||
| void *targ_callback; | void *targ_callback; | ||||
| if (calc->smd->target && calc->target->type == DM_TYPE_EDITBMESH) { | if (calc->smd->target && calc->target->type == DM_TYPE_EDITBMESH) { | ||||
| emtarget = BKE_editmesh_from_object(calc->smd->target); | emtarget = BKE_editmesh_from_object(calc->smd->target); | ||||
| if ((targ_tree = bvhtree_from_editmesh_looptri(&emtreedata_stack, emtarget, 0.0, 4, 6))) { | if (targ_tree = bvhtree_from_editmesh_looptri( | ||||
| targ_callback = emtreedata_stack.raycast_callback; | &targdata_stack.emtreedata, emtarget, 0.0, 4, 6, &calc->target->bvhCache)) | ||||
| treeData = &emtreedata_stack; | { | ||||
| targ_callback = targdata_stack.emtreedata.raycast_callback; | |||||
| targData = &targdata_stack.emtreedata; | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if ((targ_tree = bvhtree_from_mesh_looptri(&dmtreedata_stack, calc->target, 0.0, 4, 6))) { | if ((targ_tree = bvhtree_from_mesh_looptri( | ||||
| targ_callback = dmtreedata_stack.raycast_callback; | &targdata_stack.dmtreedata, calc->target, 0.0, 4, 6))) | ||||
| treeData = &dmtreedata_stack; | { | ||||
| targ_callback = targdata_stack.dmtreedata.raycast_callback; | |||||
| targData = &targdata_stack.dmtreedata; | |||||
| } | } | ||||
| } | } | ||||
| if (targ_tree) { | if (targ_tree) { | ||||
| Context not available. | |||||
| /* use editmesh to avoid array allocation */ | /* use editmesh to avoid array allocation */ | ||||
| if (calc->smd->auxTarget && auxMesh->type == DM_TYPE_EDITBMESH) { | if (calc->smd->auxTarget && auxMesh->type == DM_TYPE_EDITBMESH) { | ||||
| emaux = BKE_editmesh_from_object(calc->smd->auxTarget); | emaux = BKE_editmesh_from_object(calc->smd->auxTarget); | ||||
| if ((aux_tree = bvhtree_from_editmesh_looptri(&emauxdata_stack, emaux, 0.0, 4, 6)) != NULL) { | if (aux_tree = bvhtree_from_editmesh_looptri( | ||||
| aux_callback = emauxdata_stack.raycast_callback; | &auxdata_stack.emtreedata, emaux, 0.0, 4, 6, &auxMesh->bvhCache)) | ||||
| auxData = &emauxdata_stack; | { | ||||
| aux_callback = auxdata_stack.emtreedata.raycast_callback; | |||||
| auxData = &auxdata_stack.emtreedata; | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if ((aux_tree = bvhtree_from_mesh_looptri(&dmauxdata_stack, auxMesh, 0.0, 4, 6)) != NULL) { | if ((aux_tree = bvhtree_from_mesh_looptri(&auxdata_stack.dmtreedata, auxMesh, 0.0, 4, 6)) != NULL) { | ||||
| aux_callback = dmauxdata_stack.raycast_callback; | aux_callback = auxdata_stack.dmtreedata.raycast_callback; | ||||
| auxData = &dmauxdata_stack; | auxData = &auxdata_stack.dmtreedata; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* After sucessufuly build the trees, start projection vertexs */ | /* After sucessufuly build the trees, start projection vertexs */ | ||||
| ShrinkwrapCalcCBData data = { | ShrinkwrapCalcCBData data = { | ||||
| .calc = calc, | .calc = calc, | ||||
| .treeData = treeData, .targ_tree = targ_tree, .targ_callback = targ_callback, | .treeData = targData, .targ_tree = targ_tree, .targ_callback = targ_callback, | ||||
| .auxData = auxData, .aux_tree = aux_tree, .aux_callback = aux_callback, | .auxData = auxData, .aux_tree = aux_tree, .aux_callback = aux_callback, | ||||
| .proj_axis = proj_axis, .local2aux = &local2aux, | .proj_axis = proj_axis, .local2aux = &local2aux, | ||||
| }; | }; | ||||
| Context not available. | |||||
| } | } | ||||
| /* free data structures */ | /* free data structures */ | ||||
| if (treeData) { | if (targData) { | ||||
| if (emtarget) free_bvhtree_from_editmesh(treeData); | if (emtarget) free_bvhtree_from_editmesh(targData); | ||||
| else free_bvhtree_from_mesh(treeData); | else free_bvhtree_from_mesh(targData); | ||||
| } | } | ||||
| if (auxData) { | if (auxData) { | ||||
| if (emaux) free_bvhtree_from_editmesh(auxData); | if (emaux) free_bvhtree_from_editmesh(auxData); | ||||
| Context not available. | |||||