Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
| Show First 20 Lines • Show All 619 Lines • ▼ Show 20 Lines | static void gradientVert_update(WPGradient_userData *grad_data, int index) | ||||
| } | } | ||||
| } | } | ||||
| static void gradientVertUpdate__mapFunc( | static void gradientVertUpdate__mapFunc( | ||||
| void *userData, int index, const float UNUSED(co[3]), | void *userData, int index, const float UNUSED(co[3]), | ||||
| const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) | const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) | ||||
| { | { | ||||
| WPGradient_userData *grad_data = userData; | WPGradient_userData *grad_data = userData; | ||||
| Mesh *me = grad_data->me; | |||||
| if ((grad_data->use_select == false) || (me->mvert[index].flag & SELECT)) { | |||||
| WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index]; | WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index]; | ||||
| if (vs->sco[0] != FLT_MAX) { | |||||
| gradientVert_update(grad_data, index); | if (vs->sco[0] == FLT_MAX) { | ||||
| } | return; | ||||
| } | } | ||||
| gradientVert_update(grad_data, index); | |||||
| } | } | ||||
| static void gradientVertInit__mapFunc( | static void gradientVertInit__mapFunc( | ||||
| void *userData, int index, const float co[3], | void *userData, int index, const float co[3], | ||||
| const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) | const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) | ||||
| { | { | ||||
| WPGradient_userData *grad_data = userData; | WPGradient_userData *grad_data = userData; | ||||
| Mesh *me = grad_data->me; | Mesh *me = grad_data->me; | ||||
| WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index]; | |||||
| if (grad_data->use_select && !(me->mvert[index].flag & SELECT)) { | |||||
| copy_v2_fl(vs->sco, FLT_MAX); | |||||
| return; | |||||
| } | |||||
JacquesLucke: Actually, maybe `copy_v2_fl(vs->sco, FLT_MAX);` is necessary here as well.
It wasn't there… | |||||
Not Done Inline ActionsThe same test exists in gradientVertUpdate__mapFunc, so it's not strictly necessary. Code style: use {}, put return on new line. Also, keep the code in both functions consistent. brecht: The same test exists in `gradientVertUpdate__mapFunc`, so it's not strictly necessary.
Code… | |||||
| if (me->mvert[index].flag & ME_HIDE) { | |||||
| copy_v2_fl(vs->sco, FLT_MAX); | |||||
| return; | |||||
| } | |||||
| if ((grad_data->use_select == false) || (me->mvert[index].flag & SELECT)) { | |||||
| /* run first pass only, | /* run first pass only, | ||||
| * the screen coords of the verts need to be cached because | * the screen coords of the verts need to be cached because | ||||
| * updating the mesh may move them about (entering feedback loop) */ | * updating the mesh may move them about (entering feedback loop) */ | ||||
| if (BLI_BITMAP_TEST(grad_data->vert_visit, index)) { | |||||
| copy_v2_fl(vs->sco, FLT_MAX); | |||||
| return; | |||||
| } | |||||
| if (BLI_BITMAP_TEST(grad_data->vert_visit, index) == 0) { | |||||
| WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index]; | |||||
| if (ED_view3d_project_float_object( | if (ED_view3d_project_float_object( | ||||
| grad_data->ar, | grad_data->ar, | ||||
| co, vs->sco, | co, vs->sco, | ||||
| V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) | V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) != V3D_PROJ_RET_OK) | ||||
| { | { | ||||
| /* ok */ | return; | ||||
| } | |||||
| MDeformVert *dv = &me->dvert[index]; | MDeformVert *dv = &me->dvert[index]; | ||||
| const MDeformWeight *dw; | const MDeformWeight *dw = defvert_find_index(dv, grad_data->def_nr); | ||||
| dw = defvert_find_index(dv, grad_data->def_nr); | |||||
| if (dw) { | if (dw) { | ||||
| vs->weight_orig = dw->weight; | vs->weight_orig = dw->weight; | ||||
| vs->flag = VGRAD_STORE_DW_EXIST; | vs->flag = VGRAD_STORE_DW_EXIST; | ||||
| } | } | ||||
| else { | else { | ||||
| vs->weight_orig = 0.0f; | vs->weight_orig = 0.0f; | ||||
| vs->flag = VGRAD_STORE_NOP; | vs->flag = VGRAD_STORE_NOP; | ||||
| } | } | ||||
| BLI_BITMAP_ENABLE(grad_data->vert_visit, index); | BLI_BITMAP_ENABLE(grad_data->vert_visit, index); | ||||
| gradientVert_update(grad_data, index); | gradientVert_update(grad_data, index); | ||||
| } | } | ||||
| else { | |||||
| /* no go */ | |||||
| copy_v2_fl(vs->sco, FLT_MAX); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEvent *event) | static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| wmGesture *gesture = op->customdata; | wmGesture *gesture = op->customdata; | ||||
| WPGradient_vertStoreBase *vert_cache = gesture->userdata; | WPGradient_vertStoreBase *vert_cache = gesture->userdata; | ||||
| int ret = WM_gesture_straightline_modal(C, op, event); | int ret = WM_gesture_straightline_modal(C, op, event); | ||||
| if (ret & OPERATOR_RUNNING_MODAL) { | if (ret & OPERATOR_RUNNING_MODAL) { | ||||
| ▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines | |||||
Actually, maybe copy_v2_fl(vs->sco, FLT_MAX); is necessary here as well.
It wasn't there before, so I did not insert it.