diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-09-28 00:30:05 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-09-28 00:35:06 +0300 |
commit | 64de8c8f0de018f5d2b075db738d7b6322d6d21a (patch) | |
tree | ff53a72ce9481e477b7fafe60f44b7c774c6845f /source | |
parent | fcdc7acd8b5963fd4f9fb0a81317c54654d577de (diff) |
Missed in last merge from master
Local changes built, but merge-commit needed amending.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/armature/armature_skinning.c | 17 | ||||
-rw-r--r-- | source/blender/editors/include/ED_armature.h | 6 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 12 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 51 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex_proj.c | 34 |
6 files changed, 77 insertions, 47 deletions
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index 3f4a80c9a27..72b4837c1b8 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -250,8 +250,9 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i } } -static void add_verts_to_dgroups(ReportList *reports, const bContext *C, Scene *scene, Object *ob, Object *par, - int heat, const bool mirror) +static void add_verts_to_dgroups( + ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *par, + int heat, const bool mirror) { /* This functions implements the automatic computation of vertex group * weights, either through envelopes or using a heat equilibrium. @@ -265,7 +266,6 @@ static void add_verts_to_dgroups(ReportList *reports, const bContext *C, Scene * * when parenting, or simply the original mesh coords. */ - EvaluationContext eval_ctx; bArmature *arm = par->data; Bone **bonelist, *bone; bDeformGroup **dgrouplist, **dgroupflip; @@ -279,8 +279,6 @@ static void add_verts_to_dgroups(ReportList *reports, const bContext *C, Scene * int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT); struct { Object *armob; void *list; int heat; } looper_data; - CTX_data_eval_ctx(C, &eval_ctx); - looper_data.armob = par; looper_data.heat = heat; looper_data.list = NULL; @@ -378,7 +376,7 @@ static void add_verts_to_dgroups(ReportList *reports, const bContext *C, Scene * if (wpmode) { /* if in weight paint mode, use final verts from derivedmesh */ - DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH); + DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH); if (dm->foreachMappedVert) { mesh_get_mapped_verts_coords(dm, verts, mesh->totvert); @@ -430,8 +428,9 @@ static void add_verts_to_dgroups(ReportList *reports, const bContext *C, Scene * MEM_freeN(verts); } -void create_vgroups_from_armature(ReportList *reports, const bContext *C, Scene *scene, Object *ob, Object *par, - const int mode, const bool mirror) +void create_vgroups_from_armature( + ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *par, + const int mode, const bool mirror) { /* Lets try to create some vertex groups * based on the bones of the parent armature. @@ -457,6 +456,6 @@ void create_vgroups_from_armature(ReportList *reports, const bContext *C, Scene * that are populated with the vertices for which the * bone is closest. */ - add_verts_to_dgroups(reports, C, scene, ob, par, (mode == ARM_GROUPS_AUTO), mirror); + add_verts_to_dgroups(reports, eval_ctx, scene, ob, par, (mode == ARM_GROUPS_AUTO), mirror); } } diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index bbc6e8912c3..d65ea8e79f0 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -39,6 +39,7 @@ struct BaseLegacy; struct bContext; struct Bone; struct bPoseChannel; +struct EvaluationContext; struct IDProperty; struct ListBase; struct MeshDeformModifierData; @@ -174,8 +175,9 @@ void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do #define ARM_GROUPS_ENVELOPE 2 #define ARM_GROUPS_AUTO 3 -void create_vgroups_from_armature(struct ReportList *reports, const struct bContext *C, struct Scene *scene, - struct Object *ob, struct Object *par, const int mode, const bool mirror); +void create_vgroups_from_armature( + struct ReportList *reports, const struct EvaluationContext *eval_ctx, struct Scene *scene, + struct Object *ob, struct Object *par, const int mode, const bool mirror); /* if bone is already in list, pass it as param to ignore it */ void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 04ac42a5471..c255ce4a45a 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -784,13 +784,15 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene, copy_v3_v3(ob->loc, vec); } else if (pararm && (ob->type == OB_MESH) && (par->type == OB_ARMATURE)) { - if (partype == PAR_ARMATURE_NAME) - create_vgroups_from_armature(reports, C, scene, ob, par, ARM_GROUPS_NAME, false); - else if (partype == PAR_ARMATURE_ENVELOPE) - create_vgroups_from_armature(reports, C, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror); + if (partype == PAR_ARMATURE_NAME) { + create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_NAME, false); + } + else if (partype == PAR_ARMATURE_ENVELOPE) { + create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror); + } else if (partype == PAR_ARMATURE_AUTO) { WM_cursor_wait(1); - create_vgroups_from_armature(reports, C, scene, ob, par, ARM_GROUPS_AUTO, xmirror); + create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_AUTO, xmirror); WM_cursor_wait(0); } /* get corrected inverse */ diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index a320cf50d72..2b866118f19 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -127,10 +127,10 @@ unsigned int vpaint_get_current_col(struct Scene *scene, struct VPaint *vp); /* paint_vertex_proj.c */ struct VertProjHandle; struct VertProjHandle *ED_vpaint_proj_handle_create( - const struct bContext *C, struct Scene *scene, struct Object *ob, + const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct DMCoNo **r_vcosnos); void ED_vpaint_proj_handle_update( - const struct bContext *C, struct VertProjHandle *vp_handle, + const struct EvaluationContext *eval_ctx, struct VertProjHandle *vp_handle, /* runtime vars */ struct ARegion *ar, const float mval_fl[2]); void ED_vpaint_proj_handle_free( diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 0a82ac88403..9046a768eaf 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1727,11 +1727,11 @@ static void do_weight_paint_vertex( /* Toggle operator for turning vertex paint mode on or off (copied from sculpt.c) */ -static void vertex_paint_init_session(Scene *scene, Object *ob) +static void vertex_paint_init_session(const EvaluationContext *eval_ctx, Scene *scene, Object *ob) { if (ob->sculpt == NULL) { ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); - BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0, false); + BKE_sculpt_update_mesh_elements(eval_ctx, scene, scene->toolsettings->sculpt, ob, 0, false); } } @@ -1848,6 +1848,10 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) paint_cursor_delete_textures(); } else { + EvaluationContext eval_ctx; + + CTX_data_eval_ctx(C, &eval_ctx); + ob->mode |= mode_flag; if (wp == NULL) @@ -1865,8 +1869,10 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) if (ob->sculpt) { BKE_sculptsession_free(ob); } - vertex_paint_init_session(scene, ob); + vertex_paint_init_session(&eval_ctx, scene, ob); } + + BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL); /* Weightpaint works by overriding colors in mesh, * so need to make sure we recalc on enter and @@ -2142,6 +2148,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo bool *defbase_sel; SculptSession *ss = ob->sculpt; VPaint *vd = CTX_data_tool_settings(C)->wpaint; + EvaluationContext eval_ctx; float mat[4][4], imat[4][4]; @@ -2149,6 +2156,8 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo return false; } + CTX_data_eval_ctx(C, &eval_ctx); + { /* check if we are attempting to paint onto a locked vertex group, * and other options disallow it from doing anything useful */ @@ -2242,7 +2251,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo /* painting on subsurfs should give correct points too, this returns me->totvert amount */ ob->sculpt->building_vp_handle = true; - wpd->vp_handle = ED_vpaint_proj_handle_create(scene, ob, &wpd->vertexcosnos); + wpd->vp_handle = ED_vpaint_proj_handle_create(&eval_ctx, scene, ob, &wpd->vertexcosnos); ob->sculpt->building_vp_handle = false; /* imat for normals */ @@ -2251,7 +2260,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo copy_m3_m4(wpd->wpimat, imat); /* If not previously created, create vertex/weight paint mode session data */ - vertex_paint_init_session(scene, ob); + vertex_paint_init_session(&eval_ctx, scene, ob); vwpaint_update_cache_invariants(C, vd, ss, op, mouse); vertex_paint_init_session_data(ts, ob); @@ -2900,6 +2909,8 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* also needed for "View Selected" on last stroke */ paint_last_stroke_update(scene, vc->ar, mval); + BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL); + DEG_id_tag_update(ob->data, 0); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); swap_m4m4(wpd->vc.rv3d->persmat, mat); @@ -3117,6 +3128,10 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op) paint_cursor_delete_textures(); } else { + EvaluationContext eval_ctx; + + CTX_data_eval_ctx(C, &eval_ctx); + ob->mode |= mode_flag; if (me->mloopcol == NULL) { @@ -3138,9 +3153,11 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op) } BKE_sculptsession_free(ob); } - vertex_paint_init_session(scene, ob); + vertex_paint_init_session(&eval_ctx, scene, ob); } - + + BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL); + /* update modifier stack for mapping requirements */ DEG_id_tag_update(&me->id, 0); @@ -3224,6 +3241,9 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f Mesh *me; float mat[4][4], imat[4][4]; SculptSession *ss = ob->sculpt; + EvaluationContext eval_ctx; + + CTX_data_eval_ctx(C, &eval_ctx); /* context checks could be a poll() */ me = BKE_mesh_from_object(ob); @@ -3264,7 +3284,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f /* Create projection handle */ if (vpd->is_texbrush) { ob->sculpt->building_vp_handle = true; - vpd->vp_handle = ED_vpaint_proj_handle_create(scene, ob, &vpd->vertexcosnos); + vpd->vp_handle = ED_vpaint_proj_handle_create(&eval_ctx, scene, ob, &vpd->vertexcosnos); ob->sculpt->building_vp_handle = false; } @@ -3274,7 +3294,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f copy_m3_m4(vpd->vpimat, imat); /* If not previously created, create vertex/weight paint mode session data */ - vertex_paint_init_session(scene, ob); + vertex_paint_init_session(&eval_ctx, scene, ob); vwpaint_update_cache_invariants(C, vp, ss, op, mouse); vertex_paint_init_session_data(ts, ob); @@ -3818,6 +3838,8 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P swap_m4m4(vc->rv3d->persmat, mat); + BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_ALL); + /* calculate pivot for rotation around seletion if needed */ /* also needed for "View Selected" on last stroke */ paint_last_stroke_update(scene, vc->ar, mval); @@ -3933,8 +3955,10 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op) Object *armob = modifiers_isDeformedByArmature(ob); Mesh *me = ob->data; int type = RNA_enum_get(op->ptr, "type"); + EvaluationContext eval_ctx; - create_vgroups_from_armature(op->reports, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); + CTX_data_eval_ctx(C, &eval_ctx); + create_vgroups_from_armature(op->reports, &eval_ctx, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); DEG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); @@ -4152,6 +4176,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) struct ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); + EvaluationContext eval_ctx; Mesh *me = ob->data; int x_start = RNA_int_get(op->ptr, "xstart"); int y_start = RNA_int_get(op->ptr, "ystart"); @@ -4160,7 +4185,11 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) float sco_start[2] = {x_start, y_start}; float sco_end[2] = {x_end, y_end}; const bool is_interactive = (gesture != NULL); - DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask); + DerivedMesh *dm; + + CTX_data_eval_ctx(C, &eval_ctx); + + dm = mesh_get_derived_final(&eval_ctx, scene, ob, scene->customdata_mask); DMGradient_userData data = {NULL}; diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c index c9915a294ad..999c9dc7880 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c @@ -100,16 +100,14 @@ static void vpaint_proj_dm_map_cosnos_init__map_cb(void *userData, int index, co } } -static void vpaint_proj_dm_map_cosnos_init(const bContext *C, Scene *scene, Object *ob, - struct VertProjHandle *vp_handle) +static void vpaint_proj_dm_map_cosnos_init( + const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, + struct VertProjHandle *vp_handle) { - EvaluationContext eval_ctx; Mesh *me = ob->data; DerivedMesh *dm; - CTX_data_eval_ctx(C, &eval_ctx); - - dm = mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); + dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); if (dm->foreachMappedVert) { memset(vp_handle->vcosnos, 0, sizeof(DMCoNo) * me->totvert); @@ -174,14 +172,12 @@ static void vpaint_proj_dm_map_cosnos_update__map_cb(void *userData, int index, } } -static void vpaint_proj_dm_map_cosnos_update(const bContext *C, struct VertProjHandle *vp_handle, - ARegion *ar, const float mval_fl[2]) +static void vpaint_proj_dm_map_cosnos_update( + const struct EvaluationContext *eval_ctx, struct VertProjHandle *vp_handle, + ARegion *ar, const float mval_fl[2]) { - EvaluationContext eval_ctx; struct VertProjUpdate vp_update = {vp_handle, ar, mval_fl}; - CTX_data_eval_ctx(C, &eval_ctx); - Scene *scene = vp_handle->scene; Object *ob = vp_handle->ob; Mesh *me = ob->data; @@ -190,7 +186,7 @@ static void vpaint_proj_dm_map_cosnos_update(const bContext *C, struct VertProjH /* quick sanity check - we shouldn't have to run this if there are no modifiers */ BLI_assert(BLI_listbase_is_empty(&ob->modifiers) == false); - dm = mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); + dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); /* highly unlikely this will become unavailable once painting starts (perhaps with animated modifiers) */ if (LIKELY(dm->foreachMappedVert)) { @@ -206,8 +202,9 @@ static void vpaint_proj_dm_map_cosnos_update(const bContext *C, struct VertProjH /* -------------------------------------------------------------------- */ /* Public Functions */ -struct VertProjHandle *ED_vpaint_proj_handle_create(const bContext *C, Scene *scene, Object *ob, - DMCoNo **r_vcosnos) +struct VertProjHandle *ED_vpaint_proj_handle_create( + const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, + DMCoNo **r_vcosnos) { struct VertProjHandle *vp_handle = MEM_mallocN(sizeof(struct VertProjHandle), __func__); Mesh *me = ob->data; @@ -217,7 +214,7 @@ struct VertProjHandle *ED_vpaint_proj_handle_create(const bContext *C, Scene *sc vp_handle->use_update = false; /* sets 'use_update' if needed */ - vpaint_proj_dm_map_cosnos_init(C, scene, ob, vp_handle); + vpaint_proj_dm_map_cosnos_init(eval_ctx, scene, ob, vp_handle); if (vp_handle->use_update) { vp_handle->dists_sq = MEM_mallocN(sizeof(float) * me->totvert, __func__); @@ -236,11 +233,12 @@ struct VertProjHandle *ED_vpaint_proj_handle_create(const bContext *C, Scene *sc return vp_handle; } -void ED_vpaint_proj_handle_update(const bContext *C, struct VertProjHandle *vp_handle, - ARegion *ar, const float mval_fl[2]) +void ED_vpaint_proj_handle_update( + const struct EvaluationContext *eval_ctx, struct VertProjHandle *vp_handle, + ARegion *ar, const float mval_fl[2]) { if (vp_handle->use_update) { - vpaint_proj_dm_map_cosnos_update(C, vp_handle, ar, mval_fl); + vpaint_proj_dm_map_cosnos_update(eval_ctx, vp_handle, ar, mval_fl); } } |