From 2753959ed7165a2e5b9bb5421fd6b3b744817402 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Apr 2019 14:39:31 +1000 Subject: Cleanup: sort CMake include paths --- source/blender/modifiers/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 691a0e369e6..5116fefde94 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -21,17 +21,17 @@ set(INC . intern + ../blenfont ../blenkernel ../blenlib - ../blenfont + ../bmesh ../depsgraph ../makesdna ../makesrna - ../bmesh ../render/extern/include ../../../intern/elbeem/extern - ../../../intern/guardedalloc ../../../intern/eigen + ../../../intern/guardedalloc ) set(INC_SYS -- cgit v1.2.3 From 047081841113da73d7a13886218f5a56cfc62de6 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Wed, 24 Apr 2019 16:24:53 +0300 Subject: Fix T59848: precisely represent the dependencies of Armature modifier. When the modifier uses vertex groups, the set of the bones it actually needs is precisely defined by the set of the group names. If envelopes are enabled, this refinement is not available, because any bone can potentially be used. This can be used in the dependency graph construction to allow objects deformed by a part of the armature to be used in constraints on other bones, e.g. for placing cartoon-style face elements on top of the body mesh via Shrinkwrap constraints. Since the list of vertex group names is now used as an input by the dependency graph, adding/removing/renaming groups should now be triggering a graph rebuild. Differential Revision: https://developer.blender.org/D4715 --- source/blender/modifiers/intern/MOD_armature.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 6a01b01c0d9..31a1f5207c6 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -24,11 +24,13 @@ #include #include "BLI_utildefines.h" +#include "BLI_listbase.h" #include "DNA_armature_types.h" #include "DNA_object_types.h" #include "DNA_mesh_types.h" +#include "BKE_action.h" #include "BKE_editmesh.h" #include "BKE_lattice.h" #include "BKE_library.h" @@ -91,7 +93,26 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte { ArmatureModifierData *amd = (ArmatureModifierData *)md; if (amd->object != NULL) { - DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_EVAL_POSE, "Armature Modifier"); + /* If not using envelopes, create relations to individual bones for more rigging flexibility. */ + if ((amd->deformflag & ARM_DEF_ENVELOPE) == 0 && (amd->object->pose != NULL) && + ELEM(ctx->object->type, OB_MESH, OB_LATTICE, OB_GPENCIL)) { + /* If neither vertex groups nor envelopes are used, the modifier has no bone dependencies. */ + if ((amd->deformflag & ARM_DEF_VGROUP) != 0) { + /* Enumerate groups that match existing bones. */ + LISTBASE_FOREACH (bDeformGroup *, dg, &ctx->object->defbase) { + if (BKE_pose_channel_find_name(amd->object->pose, dg->name) != NULL) { + /* Can't check BONE_NO_DEFORM because it can be animated. */ + DEG_add_bone_relation( + ctx->node, amd->object, dg->name, DEG_OB_COMP_BONE, "Armature Modifier"); + } + } + } + } + /* Otherwise require the whole pose to be complete. */ + else { + DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_EVAL_POSE, "Armature Modifier"); + } + DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_TRANSFORM, "Armature Modifier"); } DEG_add_modifier_to_transform_relation(ctx->node, "Armature Modifier"); -- cgit v1.2.3 From 5ca8ac51d04c6feb9d29d75fb2525168d30fbe74 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 May 2019 07:34:41 +1000 Subject: Cleanup: indentation from braces in '#if 0' --- .../blender/modifiers/intern/MOD_weighted_normal.c | 173 +++++++++++---------- 1 file changed, 87 insertions(+), 86 deletions(-) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c index 210f67ef07a..8f464be8e06 100644 --- a/source/blender/modifiers/intern/MOD_weighted_normal.c +++ b/source/blender/modifiers/intern/MOD_weighted_normal.c @@ -544,114 +544,115 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes * Once we fully switch to Mesh evaluation of modifiers, we can expect to get that flag from the COW copy. * But for now, it is lost in the DM intermediate step, so we need to directly check orig object's data. */ #if 0 - if (!(mesh->flag & ME_AUTOSMOOTH)) { + if (!(mesh->flag & ME_AUTOSMOOTH)) #else - if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH)) { + if (!(((Mesh *)ob->data)->flag & ME_AUTOSMOOTH)) #endif - modifier_setError((ModifierData *)wnmd, "Enable 'Auto Smooth' option in mesh settings"); - return mesh; -} + { + modifier_setError((ModifierData *)wnmd, "Enable 'Auto Smooth' option in mesh settings"); + return mesh; + } -Mesh *result; -BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE); + Mesh *result; + BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE); -const int numVerts = result->totvert; -const int numEdges = result->totedge; -const int numLoops = result->totloop; -const int numPolys = result->totpoly; + const int numVerts = result->totvert; + const int numEdges = result->totedge; + const int numLoops = result->totloop; + const int numPolys = result->totpoly; -MEdge *medge = result->medge; -MPoly *mpoly = result->mpoly; -MVert *mvert = result->mvert; -MLoop *mloop = result->mloop; + MEdge *medge = result->medge; + MPoly *mpoly = result->mpoly; + MVert *mvert = result->mvert; + MLoop *mloop = result->mloop; -/* Right now: + /* Right now: * If weight = 50 then all faces are given equal weight. * If weight > 50 then more weight given to faces with larger vals (face area / corner angle). * If weight < 50 then more weight given to faces with lesser vals. However current calculation * does not converge to min/max. */ -float weight = ((float)wnmd->weight) / 50.0f; -if (wnmd->weight == 100) { - weight = (float)SHRT_MAX; -} -else if (wnmd->weight == 1) { - weight = 1 / (float)SHRT_MAX; -} -else if ((weight - 1) * 25 > 1) { - weight = (weight - 1) * 25; -} + float weight = ((float)wnmd->weight) / 50.0f; + if (wnmd->weight == 100) { + weight = (float)SHRT_MAX; + } + else if (wnmd->weight == 1) { + weight = 1 / (float)SHRT_MAX; + } + else if ((weight - 1) * 25 > 1) { + weight = (weight - 1) * 25; + } -CustomData *pdata = &result->pdata; -float (*polynors)[3] = CustomData_get_layer(pdata, CD_NORMAL); -if (!polynors) { - polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, numPolys); - CustomData_set_layer_flag(pdata, CD_NORMAL, CD_FLAG_TEMPORARY); -} -BKE_mesh_calc_normals_poly( - mvert, NULL, numVerts, mloop, mpoly, numLoops, numPolys, polynors, false); - -const float split_angle = mesh->smoothresh; -short (*clnors)[2]; -CustomData *ldata = &result->ldata; -clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL); - -/* Keep info whether we had clnors, it helps when generating clnor spaces and default normals. */ -const bool has_clnors = clnors != NULL; -if (!clnors) { - clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops); -} + CustomData *pdata = &result->pdata; + float(*polynors)[3] = CustomData_get_layer(pdata, CD_NORMAL); + if (!polynors) { + polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, numPolys); + CustomData_set_layer_flag(pdata, CD_NORMAL, CD_FLAG_TEMPORARY); + } + BKE_mesh_calc_normals_poly( + mvert, NULL, numVerts, mloop, mpoly, numLoops, numPolys, polynors, false); + + const float split_angle = mesh->smoothresh; + short(*clnors)[2]; + CustomData *ldata = &result->ldata; + clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL); + + /* Keep info whether we had clnors, it helps when generating clnor spaces and default normals. */ + const bool has_clnors = clnors != NULL; + if (!clnors) { + clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops); + } -MDeformVert *dvert; -int defgrp_index; -MOD_get_vgroup(ctx->object, mesh, wnmd->defgrp_name, &dvert, &defgrp_index); + MDeformVert *dvert; + int defgrp_index; + MOD_get_vgroup(ctx->object, mesh, wnmd->defgrp_name, &dvert, &defgrp_index); -WeightedNormalData wn_data = { - .numVerts = numVerts, - .numEdges = numEdges, - .numLoops = numLoops, - .numPolys = numPolys, + WeightedNormalData wn_data = { + .numVerts = numVerts, + .numEdges = numEdges, + .numLoops = numLoops, + .numPolys = numPolys, - .mvert = mvert, - .medge = medge, + .mvert = mvert, + .medge = medge, - .mloop = mloop, - .clnors = clnors, - .has_clnors = has_clnors, - .split_angle = split_angle, + .mloop = mloop, + .clnors = clnors, + .has_clnors = has_clnors, + .split_angle = split_angle, - .mpoly = mpoly, - .polynors = polynors, - .poly_strength = CustomData_get_layer_named( - &result->pdata, CD_PROP_INT, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID), + .mpoly = mpoly, + .polynors = polynors, + .poly_strength = CustomData_get_layer_named( + &result->pdata, CD_PROP_INT, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID), - .dvert = dvert, - .defgrp_index = defgrp_index, - .use_invert_vgroup = (wnmd->flag & MOD_WEIGHTEDNORMAL_INVERT_VGROUP) != 0, + .dvert = dvert, + .defgrp_index = defgrp_index, + .use_invert_vgroup = (wnmd->flag & MOD_WEIGHTEDNORMAL_INVERT_VGROUP) != 0, - .weight = weight, - .mode = wnmd->mode, -}; + .weight = weight, + .mode = wnmd->mode, + }; -switch (wnmd->mode) { - case MOD_WEIGHTEDNORMAL_MODE_FACE: - wn_face_area(wnmd, &wn_data); - break; - case MOD_WEIGHTEDNORMAL_MODE_ANGLE: - wn_corner_angle(wnmd, &wn_data); - break; - case MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE: - wn_face_with_angle(wnmd, &wn_data); - break; -} + switch (wnmd->mode) { + case MOD_WEIGHTEDNORMAL_MODE_FACE: + wn_face_area(wnmd, &wn_data); + break; + case MOD_WEIGHTEDNORMAL_MODE_ANGLE: + wn_corner_angle(wnmd, &wn_data); + break; + case MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE: + wn_face_with_angle(wnmd, &wn_data); + break; + } -MEM_SAFE_FREE(wn_data.loop_to_poly); -MEM_SAFE_FREE(wn_data.mode_pair); -MEM_SAFE_FREE(wn_data.items_data); + MEM_SAFE_FREE(wn_data.loop_to_poly); + MEM_SAFE_FREE(wn_data.mode_pair); + MEM_SAFE_FREE(wn_data.items_data); -/* Currently Modifier stack assumes there is no poly normal data passed around... */ -CustomData_free_layers(pdata, CD_NORMAL, numPolys); -return result; + /* Currently Modifier stack assumes there is no poly normal data passed around... */ + CustomData_free_layers(pdata, CD_NORMAL, numPolys); + return result; } static void initData(ModifierData *md) -- cgit v1.2.3 From 910b88674763899c189b694aa306e03055fe33bf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 May 2019 07:40:07 +1000 Subject: Cleanup: comments (long lines) in modifiers Also remove duplicate comments in headers. --- source/blender/modifiers/intern/MOD_armature.c | 3 +- source/blender/modifiers/intern/MOD_array.c | 17 +++++--- source/blender/modifiers/intern/MOD_bevel.c | 26 ++++++------ .../modifiers/intern/MOD_correctivesmooth.c | 3 +- source/blender/modifiers/intern/MOD_datatransfer.c | 4 +- source/blender/modifiers/intern/MOD_dynamicpaint.c | 5 ++- source/blender/modifiers/intern/MOD_explode.c | 4 +- .../blender/modifiers/intern/MOD_fluidsim_util.c | 6 ++- .../blender/modifiers/intern/MOD_laplaciandeform.c | 18 ++++---- source/blender/modifiers/intern/MOD_mask.c | 17 ++++---- source/blender/modifiers/intern/MOD_normal_edit.c | 20 +++++---- source/blender/modifiers/intern/MOD_ocean.c | 3 +- source/blender/modifiers/intern/MOD_screw.c | 10 +++-- source/blender/modifiers/intern/MOD_skin.c | 2 +- source/blender/modifiers/intern/MOD_solidify.c | 3 +- .../blender/modifiers/intern/MOD_surfacedeform.c | 6 ++- source/blender/modifiers/intern/MOD_triangulate.c | 2 +- source/blender/modifiers/intern/MOD_util.c | 6 ++- .../blender/modifiers/intern/MOD_weighted_normal.c | 49 +++++++++++++--------- .../blender/modifiers/intern/MOD_weightvg_util.c | 11 ++--- .../blender/modifiers/intern/MOD_weightvg_util.h | 16 ------- .../modifiers/intern/MOD_weightvgproximity.c | 7 ++-- 22 files changed, 133 insertions(+), 105 deletions(-) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 31a1f5207c6..72215659915 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -93,7 +93,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte { ArmatureModifierData *amd = (ArmatureModifierData *)md; if (amd->object != NULL) { - /* If not using envelopes, create relations to individual bones for more rigging flexibility. */ + /* If not using envelopes, + * create relations to individual bones for more rigging flexibility. */ if ((amd->deformflag & ARM_DEF_ENVELOPE) == 0 && (amd->object->pose != NULL) && ELEM(ctx->object->type, OB_MESH, OB_LATTICE, OB_GPENCIL)) { /* If neither vertex groups nor envelopes are used, the modifier has no bone dependencies. */ diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 3443d275c81..fd6f58a21d4 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -148,7 +148,8 @@ static void svert_from_mvert(SortVertsElem *sv, /** * Take as inputs two sets of verts, to be processed for detection of doubles and mapping. * Each set of verts is defined by its start within mverts array and its num_verts; - * It builds a mapping for all vertices within source, to vertices within target, or -1 if no double found + * It builds a mapping for all vertices within source, + * to vertices within target, or -1 if no double found. * The int doubles_map[num_verts_source] array must have been allocated by caller. */ static void dm_mvert_map_doubles(int *doubles_map, @@ -220,11 +221,13 @@ static void dm_mvert_map_doubles(int *doubles_map, target_scan_completed = true; continue; } - /* Test target candidates starting at the low bound of possible doubles, ordered in terms of sumco */ + /* Test target candidates starting at the low bound of possible doubles, + * ordered in terms of sumco. */ i_target = i_target_low_bound; sve_target = sve_target_low_bound; - /* i_target will scan vertices in the [v_source_sumco - dist3; v_source_sumco + dist3] range */ + /* i_target will scan vertices in the + * [v_source_sumco - dist3; v_source_sumco + dist3] range */ while ((i_target < target_num_verts) && (sve_target->sum_co <= sve_source_sumco + dist3)) { /* Testing distance for candidate double in target */ @@ -237,8 +240,9 @@ static void dm_mvert_map_doubles(int *doubles_map, /* If target is already mapped, we only follow that mapping if final target remains * close enough from current vert (otherwise no mapping at all). - * Note that if we later find another target closer than this one, then we check it. But if other - * potential targets are farther, then there will be no mapping at all for this source. */ + * Note that if we later find another target closer than this one, then we check it. + * But if other potential targets are farther, + * then there will be no mapping at all for this source. */ while (best_target_vertex != -1 && !ELEM(doubles_map[best_target_vertex], -1, best_target_vertex)) { if (compare_len_v3v3(mverts[sve_source->vertex_num].co, @@ -720,7 +724,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, for (i = 0; i < result_nverts; i++) { int new_i = full_doubles_map[i]; if (new_i != -1) { - /* We have to follow chains of doubles (merge start/end especially is likely to create some), + /* We have to follow chains of doubles + * (merge start/end especially is likely to create some), * those are not supported at all by BKE_mesh_merge_verts! */ while (!ELEM(full_doubles_map[new_i], -1, new_i)) { new_i = full_doubles_map[new_i]; diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 02d3bd305be..26b45bbef0d 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -110,19 +110,19 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes const int miter_inner = bmd->miter_inner; const float spread = bmd->spread; - bm = BKE_mesh_to_bmesh_ex( - mesh, - &(struct BMeshCreateParams){0}, - &(struct BMeshFromMeshParams){ - .calc_face_normal = true, - .add_key_index = false, - .use_shapekey = false, - .active_shapekey = 0, - /* XXX We probably can use CD_MASK_BAREMESH_ORIGDINDEX here instead (also for other modifiers cases)? */ - .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, - .emask = CD_MASK_ORIGINDEX, - .pmask = CD_MASK_ORIGINDEX}, - }); + bm = BKE_mesh_to_bmesh_ex(mesh, + &(struct BMeshCreateParams){0}, + &(struct BMeshFromMeshParams){ + .calc_face_normal = true, + .add_key_index = false, + .use_shapekey = false, + .active_shapekey = 0, + /* XXX We probably can use CD_MASK_BAREMESH_ORIGDINDEX here instead + * (also for other modifiers cases)? */ + .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, + .emask = CD_MASK_ORIGINDEX, + .pmask = CD_MASK_ORIGINDEX}, + }); if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0]) { MOD_get_vgroup(ctx->object, mesh, bmd->defgrp_name, &dvert, &vgroup); diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c index 2a332bc9709..705ffb266c5 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.c +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c @@ -307,7 +307,8 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd, /* fast-path */ for (i = 0; i < numVerts; i++) { struct SmoothingData_Weighted *sd = &smooth_data[i]; - /* divide by sum of all neighbour distances (weighted) and amount of neighbors, (mean average) */ + /* Divide by sum of all neighbour distances (weighted) and amount of neighbors, + * (mean average). */ const float div = sd->edge_length_sum * vertex_edge_count[i]; if (div > eps) { #if 0 diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c index 4de99ea6fe6..3235d64cbbb 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.c +++ b/source/blender/modifiers/intern/MOD_datatransfer.c @@ -179,8 +179,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes if (((result == me) || (me->mvert == result->mvert) || (me->medge == result->medge)) && (dtmd->data_types & DT_TYPES_AFFECT_MESH)) { - /* We need to duplicate data here, otherwise setting custom normals, edges' shaprness, etc., could - * modify org mesh, see T43671. */ + /* We need to duplicate data here, otherwise setting custom normals, edges' shaprness, etc., + * could modify org mesh, see T43671. */ BKE_id_copy_ex(NULL, &me_mod->id, (ID **)&result, LIB_ID_COPY_LOCALIZE); } diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index ccd71455b21..ce488a224aa 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -129,7 +129,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte ctx->node, ctx->object, surface->effector_weights, true, 0, "Dynamic Paint Field"); } - /* Actual code uses custom loop over group/scene without layer checks in dynamicPaint_doStep */ + /* Actual code uses custom loop over group/scene + * without layer checks in dynamicPaint_doStep. */ DEG_add_collision_relations(ctx->node, ctx->object, surface->brush_group, @@ -167,7 +168,7 @@ static void foreachTexLink(ModifierData *UNUSED(md), TexWalkFunc UNUSED(walk), void *UNUSED(userData)) { - //walk(userData, ob, md, ""); /* re-enable when possible */ + // walk(userData, ob, md, ""); /* re-enable when possible */ } ModifierTypeInfo modifierType_DynamicPaint = { diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 7d87ba240d5..4ed787810a8 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -743,7 +743,7 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh) * have to stop using tessface - campbell */ facepa = MEM_calloc_arrayN((totface + (totfsplit * 2)), sizeof(int), "explode_facepa"); - //memcpy(facepa, emd->facepa, totface*sizeof(int)); + // memcpy(facepa, emd->facepa, totface*sizeof(int)); emd->facepa = facepa; /* create new verts */ @@ -766,7 +766,7 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh) /* create new faces */ curdupface = 0; //=totface; - //curdupin=totesplit; + // curdupin=totesplit; for (i = 0, fs = facesplit; i < totface; i++, fs++) { mf = &mesh->mface[i]; diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 3744c527983..0776806f541 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -435,8 +435,10 @@ static Mesh *fluidsim_read_cache( Object *ob, Mesh *orgmesh, FluidsimModifierData *fluidmd, int framenr, int useRenderParams) { int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */ - /* why start with 0 as start frame?? Animations + time are frozen for frame 0 anyway. (See physics_fluid.c for that. - DG */ - /* If we start with frame 0, we need to remap all animation channels, too, because they will all be 1 frame late if using frame-1! - DG */ + /* why start with 0 as start frame?? Animations + time are frozen for frame 0 anyway. + * (See physics_fluid.c for that. - DG) */ + /* If we start with frame 0, we need to remap all animation channels, too, + * because they will all be 1 frame late if using frame-1! - DG */ char targetFile[FILE_MAX]; FluidsimSettings *fss = fluidmd->fss; diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c index 71636463f70..e27d2786751 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.c +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c @@ -214,7 +214,8 @@ static void createVertRingMap(const int mvert_tot, } /** - * This method computes the Laplacian Matrix and Differential Coordinates for all vertex in the mesh. + * This method computes the Laplacian Matrix and Differential Coordinates + * for all vertex in the mesh.. * The Linear system is LV = d * Where L is Laplacian Matrix, V as the vertices in Mesh, d is the differential coordinates * The Laplacian Matrix is computes as a @@ -227,18 +228,21 @@ static void createVertRingMap(const int mvert_tot, * Where : * di is the Differential Coordinate i * sum (Wij) is the sum of all weights between vertex Vi and its vertices neighbors (Vj) - * sum (Wij * Vj) is the sum of the product between vertex neighbor Vj and weight Wij for all neighborhood. + * sum (Wij * Vj) is the sum of the product between vertex neighbor Vj and weight Wij + * for all neighborhood. * * This Laplacian Matrix is described in the paper: - * Desbrun M. et.al, Implicit fairing of irregular meshes using diffusion and curvature flow, SIGGRAPH '99, pag 317-324, - * New York, USA + * Desbrun M. et.al, Implicit fairing of irregular meshes using diffusion and curvature flow, + * SIGGRAPH '99, pag 317-324, New York, USA * - * The computation of Laplace Beltrami operator on Hybrid Triangle/Quad Meshes is described in the paper: - * Pinzon A., Romero E., Shape Inflation With an Adapted Laplacian Operator For Hybrid Quad/Triangle Meshes, + * The computation of Laplace Beltrami operator on Hybrid Triangle/Quad Meshes is described in the + * paper: Pinzon A., Romero E., Shape Inflation With an Adapted Laplacian Operator For + * Hybrid Quad/Triangle Meshes, * Conference on Graphics Patterns and Images, SIBGRAPI, 2013 * * The computation of Differential Coordinates is described in the paper: - * Sorkine, O. Laplacian Surface Editing. Proceedings of the EUROGRAPHICS/ACM SIGGRAPH Symposium on Geometry Processing, + * Sorkine, O. Laplacian Surface Editing. + * Proceedings of the EUROGRAPHICS/ACM SIGGRAPH Symposium on Geometry Processing, * 2004. p. 179-188. */ static void initLaplacianMatrix(LaplacianSystem *sys) diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index a13e75c76de..3417aaeeb5c 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -105,9 +105,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } /* Overview of Method: - * 1. Get the vertices that are in the vertexgroup of interest - * 2. Filter out unwanted geometry (i.e. not in vertexgroup), by populating mappings with new vs old indices - * 3. Make a new mesh containing only the mapping data + * 1. Get the vertices that are in the vertexgroup of interest. + * 2. Filter out unwanted geometry (i.e. not in vertexgroup), + * by populating mappings with new vs old indices. + * 3. Make a new mesh containing only the mapping data. */ /* get original number of verts, edges, and faces */ @@ -137,9 +138,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes return mesh; } - /* determine whether each vertexgroup is associated with a selected bone or not - * - each cell is a boolean saying whether bone corresponding to the ith group is selected - * - groups that don't match a bone are treated as not existing (along with the corresponding ungrouped verts) + /* Determine whether each vertexgroup is associated with a selected bone or not: + * - Each cell is a boolean saying whether bone corresponding to the ith group is selected. + * - Groups that don't match a bone are treated as not existing + * (along with the corresponding ungrouped verts). */ bone_select_array = MEM_malloc_arrayN((size_t)defbase_tot, sizeof(char), "mask array"); @@ -154,7 +156,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } } - /* verthash gives mapping from original vertex indices to the new indices (including selected matches only) + /* verthash gives mapping from original vertex indices to the new indices + * (including selected matches only): * key = oldindex, value = newindex */ vertHash = BLI_ghash_int_new_ex("mask vert gh", (unsigned int)maxVerts); diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c index 5c1f0435270..10852ed6148 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.c +++ b/source/blender/modifiers/intern/MOD_normal_edit.c @@ -62,13 +62,15 @@ static void generate_vert_coordinates(Mesh *mesh, } } - /* Get size (i.e. deformation of the spheroid generating normals), either from target object, or own geometry. */ + /* Get size (i.e. deformation of the spheroid generating normals), + * either from target object, or own geometry. */ if (r_size != NULL) { if (ob_center != NULL) { /* Using 'scale' as 'size' here. The input object is typically an empty * who's scale is used to define an ellipsoid instead of a simple sphere. */ - /* Not we are not interested in signs here - they are even troublesome actually, due to security clamping! */ + /* Not we are not interested in signs here - they are even troublesome actually, + * due to security clamping! */ abs_v3_v3(r_size, ob_center->scale); } else { @@ -247,7 +249,8 @@ static void normalEditModifier_do_radial(NormalEditModifierData *enmd, * Then, we want to find out for each vert its (a, b, c) triple (proportional to (A, B, C) one). * * Ellipsoid basic equation: ``(x^2/a^2) + (y^2/b^2) + (z^2/c^2) = 1.`` - * Since we want to find (a, b, c) matching this equation and proportional to (A, B, C), we can do: + * Since we want to find (a, b, c) matching this equation and proportional to (A, B, C), + * we can do: *
    *     m = B / A
    *     n = C / A
@@ -480,9 +483,11 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
     return mesh;
   }
 
-  /* XXX TODO ARG GRRR XYQWNMPRXTYY
-   * Once we fully switch to Mesh evaluation of modifiers, we can expect to get that flag from the COW copy.
-   * But for now, it is lost in the DM intermediate step, so we need to directly check orig object's data. */
+  /* XXX TODO(Rohan Rathi):
+   * Once we fully switch to Mesh evaluation of modifiers,
+   * we can expect to get that flag from the COW copy.
+   * But for now, it is lost in the DM intermediate step,
+   * so we need to directly check orig object's data. */
 #if 0
   if (!(mesh->flag & ME_AUTOSMOOTH))
 #else
@@ -495,7 +500,8 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
 
   Mesh *result;
   if (mesh->medge == ((Mesh *)ob->data)->medge) {
-    /* We need to duplicate data here, otherwise setting custom normals (which may also affect sharp edges) could
+    /* We need to duplicate data here, otherwise setting custom normals
+     * (which may also affect sharp edges) could
      * modify org mesh, see T43671. */
     BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
   }
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 1ca25cbb068..cd0046b8a31 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -434,7 +434,8 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
 
   /* displace the geometry */
 
-  /* Note: tried to parallelized that one and previous foam loop, but gives 20% slower results... odd. */
+  /* Note: tried to parallelized that one and previous foam loop,
+   * but gives 20% slower results... odd. */
   {
     const int num_verts = result->totvert;
 
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index bfd1858df09..dd894e86dcc 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -345,8 +345,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
   /* multiplying the steps is a bit tricky, this works best */
   step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1);
 
-  /* will the screw be closed?
-   * Note! smaller then FLT_EPSILON * 100 gives problems with float precision so its never closed. */
+  /* Will the screw be closed?
+   * Note! smaller then `FLT_EPSILON * 100`
+   * gives problems with float precision so its never closed. */
   if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) &&
       fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON * 100.0f)) {
     close = 1;
@@ -493,7 +494,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
      */
 
     vert_connect = MEM_malloc_arrayN(totvert, sizeof(ScrewVertConnect), "ScrewVertConnect");
-    //vert_connect = (ScrewVertConnect *) &medge_new[totvert];  /* skip the first slice of verts */
+    /* skip the first slice of verts. */
+    // vert_connect = (ScrewVertConnect *) &medge_new[totvert];
     vc = vert_connect;
 
     /* Copy Vert Locations */
@@ -605,7 +607,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
               /*printf("\t\tVERT: %i\n", lt_iter.v);*/
               if (lt_iter.v_poin->flag) {
                 /*printf("\t\t\tBreaking Found end\n");*/
-                //endpoints[0] = endpoints[1] = SV_UNUSED;
+                // endpoints[0] = endpoints[1] = SV_UNUSED;
                 ed_loop_closed = 1; /* circle */
                 break;
               }
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 7ddde7236c0..a344141bf4a 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -1216,7 +1216,7 @@ static BMFace *skin_hole_target_face(BMesh *bm, Frame *frame)
   }
 
   /* This case is unlikely now, but could still happen. Should look
-     * into splitting edges to make new faces. */
+   * into splitting edges to make new faces. */
 #if PRINT_HOLE_INFO
   if (!f) {
     printf("no good face found\n");
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 78006147ab5..88135b8790b 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -380,7 +380,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
     /* DO NOT copy here the 'copied' part of loop data, we want to reverse loops
      * (so that winding of copied face get reversed, so that normals get reversed
      * and point in expected direction...).
-     * If we also copy data here, then this data get overwritten (and allocated memory becomes memleak). */
+     * If we also copy data here, then this data get overwritten
+     * (and allocated memory becomes memleak). */
 
     CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)numPolys);
     CustomData_copy_data(&mesh->pdata, &result->pdata, 0, (int)numPolys, (int)numPolys);
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 2a9fff47e5d..47c0114f02f 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -441,7 +441,8 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
 
   bwdata->bind_polys = bpoly;
 
-  /* Loop over all adjacent edges, and build the SDefBindPoly data for each poly adjacent to those */
+  /* Loop over all adjacent edges,
+   * and build the SDefBindPoly data for each poly adjacent to those. */
   for (vedge = vert_edges; vedge; vedge = vedge->next) {
     unsigned int edge_ind = vedge->index;
 
@@ -860,7 +861,8 @@ static void bindVert(void *__restrict userdata,
         interp_weights_poly_v2(
             sdbind->vert_weights, bpoly->coords_v2, bpoly->numverts, bpoly->point_v2);
 
-        /* Reproject vert based on weights and original poly verts, to reintroduce poly non-planarity */
+        /* Reproject vert based on weights and original poly verts,
+         * to reintroduce poly non-planarity */
         zero_v3(point_co_proj);
         for (int j = 0; j < bpoly->numverts; j++, loop++) {
           madd_v3_v3fl(point_co_proj, bpoly->coords[j], sdbind->vert_weights[j]);
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index 7d890b29365..1582c27960e 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -133,7 +133,7 @@ ModifierTypeInfo modifierType_Triangulate = {
     /* applyModifier */ applyModifier,
 
     /* initData */ initData,
-    /* requiredDataMask */ NULL,  //requiredDataMask,
+    /* requiredDataMask */ NULL,  // requiredDataMask,
     /* freeData */ NULL,
     /* isDisabled */ NULL,
     /* updateDepsgraph */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 69cf8a651eb..1efc1aefae4 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -208,11 +208,13 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob,
     }
   }
   else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
-    /* TODO(sybren): get evaluated mesh from depsgraph once that's properly generated for curves. */
+    /* TODO(sybren): get evaluated mesh from depsgraph once
+     * that's properly generated for curves. */
     mesh = BKE_mesh_new_nomain_from_curve(ob);
 
     /* Currently, that may not be the case everytime
-     * (texts e.g. tend to give issues, also when deforming curve points instead of generated curve geometry... ). */
+     * (texts e.g. tend to give issues,
+     * also when deforming curve points instead of generated curve geometry... ). */
     if (mesh != NULL && mesh->totvert != num_verts) {
       BKE_id_free(NULL, mesh);
       mesh = NULL;
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 8f464be8e06..7fbaa24b579 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -51,7 +51,8 @@ static int modepair_cmp_by_val_inverse(const void *p1, const void *p2)
   return (r1->val < r2->val) ? 1 : ((r1->val > r2->val) ? -1 : 0);
 }
 
-/* There will be one of those per vertex (simple case, computing one normal per vertex), or per smooth fan. */
+/* There will be one of those per vertex
+ * (simple case, computing one normal per vertex), or per smooth fan. */
 typedef struct WeightedNormalDataAggregateItem {
   float normal[3];
 
@@ -97,8 +98,10 @@ typedef struct WeightedNormalData {
   int *loop_to_poly;
 } WeightedNormalData;
 
-/* Check strength of given poly compared to those found so far for that given item (vertex or smooth fan),
- * and reset matching item_data in case we get a stronger new strength. */
+/**
+ * Check strength of given poly compared to those found so far for that given item
+ * (vertex or smooth fan), and reset matching item_data in case we get a stronger new strength.
+ */
 static bool check_item_poly_strength(WeightedNormalData *wn_data,
                                      WeightedNormalDataAggregateItem *item_data,
                                      const int mp_index)
@@ -158,7 +161,8 @@ static void aggregate_item_normal(WeightedNormalModifierData *wnmd,
     item_data->curr_val = curr_val;
   }
 
-  /* Exponentially divided weight for each normal (since a few values will be used by most cases, we cache those). */
+  /* Exponentially divided weight for each normal
+   * (since a few values will be used by most cases, we cache those). */
   const int num_loops = item_data->num_loops;
   if (num_loops < NUM_CACHED_INVERSE_POWERS_OF_WEIGHT &&
       cached_inverse_powers_of_weight[num_loops] == 0.0f) {
@@ -211,7 +215,8 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
   if (keep_sharp) {
     BLI_bitmap *done_loops = BLI_BITMAP_NEW(numLoops, __func__);
 
-    /* This will give us loop normal spaces, we do not actually care about computed loop_normals for now... */
+    /* This will give us loop normal spaces,
+     * we do not actually care about computed loop_normals for now... */
     loop_normals = MEM_calloc_arrayN((size_t)numLoops, sizeof(*loop_normals), __func__);
     BKE_mesh_normals_loop_split(mvert,
                                 numVerts,
@@ -329,8 +334,9 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
 
   if (keep_sharp) {
     /* Set loop normals for normal computed for each lnor space (smooth fan).
-     * Note that loop_normals is already populated with clnors (before this modifier is applied, at start of
-     * this function), so no need to recompute them here. */
+     * Note that loop_normals is already populated with clnors
+     * (before this modifier is applied, at start of this function),
+     * so no need to recompute them here. */
     for (int ml_index = 0; ml_index < numLoops; ml_index++) {
       WeightedNormalDataAggregateItem *item_data = lnors_spacearr.lspacearr[ml_index]->user_data;
       if (!is_zero_v3(item_data->normal)) {
@@ -351,12 +357,14 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
                                      clnors);
   }
   else {
-    /* TODO: Ideally, we could add an option to BKE_mesh_normals_loop_custom_[from_vertices_]set() to keep current
-     * clnors instead of resetting them to default autocomputed ones, when given new custom normal is zero-vec.
+    /* TODO: Ideally, we could add an option to BKE_mesh_normals_loop_custom_[from_vertices_]set()
+     * to keep current clnors instead of resetting them to default autocomputed ones,
+     * when given new custom normal is zero-vec.
      * But this is not exactly trivial change, better to keep this optimization for later...
      */
     if (!has_vgroup) {
-      /* Note: in theory, we could avoid this extra allocation & copying... But think we can live with it for now,
+      /* Note: in theory, we could avoid this extra allocation & copying...
+       * But think we can live with it for now,
        * and it makes code simpler & cleaner. */
       float(*vert_normals)[3] = MEM_calloc_arrayN(
           (size_t)numVerts, sizeof(*loop_normals), __func__);
@@ -540,9 +548,11 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
   WeightedNormalModifierData *wnmd = (WeightedNormalModifierData *)md;
   Object *ob = ctx->object;
 
-  /* XXX TODO ARG GRRR XYQWNMPRXTYY
-   * Once we fully switch to Mesh evaluation of modifiers, we can expect to get that flag from the COW copy.
-   * But for now, it is lost in the DM intermediate step, so we need to directly check orig object's data. */
+  /* XXX TODO(Rohan Rathi):
+   * Once we fully switch to Mesh evaluation of modifiers,
+   * we can expect to get that flag from the COW copy.
+   * But for now, it is lost in the DM intermediate step,
+   * so we need to directly check orig object's data. */
 #if 0
   if (!(mesh->flag & ME_AUTOSMOOTH))
 #else
@@ -567,11 +577,11 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
   MLoop *mloop = result->mloop;
 
   /* Right now:
- * If weight = 50 then all faces are given equal weight.
- * If weight > 50 then more weight given to faces with larger vals (face area / corner angle).
- * If weight < 50 then more weight given to faces with lesser vals. However current calculation
- * does not converge to min/max.
- */
+   * If weight = 50 then all faces are given equal weight.
+   * If weight > 50 then more weight given to faces with larger vals (face area / corner angle).
+   * If weight < 50 then more weight given to faces with lesser vals. However current calculation
+   * does not converge to min/max.
+   */
   float weight = ((float)wnmd->weight) / 50.0f;
   if (wnmd->weight == 100) {
     weight = (float)SHRT_MAX;
@@ -597,7 +607,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
   CustomData *ldata = &result->ldata;
   clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL);
 
-  /* Keep info  whether we had clnors, it helps when generating clnor spaces and default normals. */
+  /* Keep info  whether we had clnors,
+   * it helps when generating clnor spaces and default normals. */
   const bool has_clnors = clnors != NULL;
   if (!clnors) {
     clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops);
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 871da8dfba9..61872cbe464 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -50,8 +50,8 @@
 
 /* Maps new_w weights in place, using either one of the predefined functions, or a custom curve.
  * Return values are in new_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
+ * If indices is not NULL, it must be a table of same length as org_w and new_w,
+ * mapping to the real vertex index (in case the weight tables do not cover the whole vertices...).
  * cmap might be NULL, in which case curve mapping mode will return unmodified data.
  */
 void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cmap, RNG *rng)
@@ -111,9 +111,10 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm
 
 /* Applies new_w weights to org_w ones, using either a texture, vgroup or constant value as factor.
  * Return values are in org_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
- * XXX The standard "factor" value is assumed in [0.0, 1.0] range. Else, weird results might appear.
+ * If indices is not NULL, it must be a table of same length as org_w and new_w,
+ * mapping to the real vertex index (in case the weight tables do not cover the whole vertices...).
+ * XXX The standard "factor" value is assumed in [0.0, 1.0] range.
+ * Else, weird results might appear.
  */
 void weightvg_do_mask(const ModifierEvalContext *ctx,
                       const int num,
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h
index d73cca935d7..08967b7400d 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.h
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.h
@@ -52,21 +52,9 @@ struct Tex;
  */
 #define MOD_WVG_ZEROFLOOR 1.0e-32f
 
-/* Maps new_w weights in place, using either one of the predefined functions, or a custom curve.
- * Return values are in new_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
- * cmap might be NULL, in which case curve mapping mode will return unmodified data.
- */
 void weightvg_do_map(
     int num, float *new_w, short mode, struct CurveMapping *cmap, struct RNG *rng);
 
-/* Applies new_w weights to org_w ones, using either a texture, vgroup or constant value as factor.
- * Return values are in org_w.
- * If indices is not NULL, it must be a table of same length as org_w and new_w, mapping to the real
- * vertex index (in case the weight tables do not cover the whole vertices...).
- * XXX The standard "factor" value is assumed in [0.0, 1.0] range. Else, weird results might appear.
- */
 void weightvg_do_mask(const ModifierEvalContext *ctx,
                       const int num,
                       const int *indices,
@@ -83,10 +71,6 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
                       Object *tex_map_object,
                       const char *tex_uvlayer_name);
 
-/* Applies weights to given vgroup (defgroup), and optionally add/remove vertices from the group.
- * If indices is not NULL, it must be a table of same length as weights, mapping to the real
- * vertex index (in case the weight table does not cover the whole vertices...).
- */
 void weightvg_update_vg(struct MDeformVert *dvert,
                         int defgrp_idx,
                         struct MDeformWeight **dws,
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 9699b5f15dd..9b3bc4678a1 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -79,7 +79,8 @@ typedef struct Vert2GeomData {
   float *dist[3];
 } Vert2GeomData;
 
-/* Data which is localized to each computed chunk (i.e. thread-safe, and with continuous subset of index range). */
+/** Data which is localized to each computed chunk
+ * (i.e. thread-safe, and with continuous subset of index range). */
 typedef struct Vert2GeomDataChunk {
   /* Read-only data */
   float last_hit_co[3][3];
@@ -110,8 +111,8 @@ static void vert2geom_task_cb_ex(void *__restrict userdata,
       /* Note that we use local proximity heuristics (to reduce the nearest search).
        *
        * If we already had an hit before in same chunk of tasks (i.e. previous vertex by index),
-       * we assume this vertex is going to have a close hit to that other vertex, so we can initiate
-       * the "nearest.dist" with the expected value to that last hit.
+       * we assume this vertex is going to have a close hit to that other vertex,
+       * so we can initiate the "nearest.dist" with the expected value to that last hit.
        * This will lead in pruning of the search tree.
        */
       nearest.dist_sq = data_chunk->is_init[i] ?
-- 
cgit v1.2.3


From 89826e0a0d8ac55881569e021c487ac5541c6612 Mon Sep 17 00:00:00 2001
From: Brecht Van Lommel 
Date: Thu, 4 Apr 2019 15:07:37 +0200
Subject: Alembic: integrate cache file into the dependency graph

* The cache file datablock is now evaluated as part of the dependency graph,
  creating/freeing the Alembic file handle matching the current frame.
  Modifiers and constraints depend on this evaluation.
* Cache file handles and readers now only exist on COW datablocks, never the
  original ones.
* Object data paths are flushed back to the original for the user interface.
* The cache file keeps a list of all readers associated with its handle, and
  automatically frees them when the handle is freed. This kind of sharing of
  data across datablocks is weak but we have no better mechanism for it.

Fix T62720: Alembic sequences not working and crashing

Differential Revision: https://developer.blender.org/D4774
---
 .../modifiers/intern/MOD_meshsequencecache.c       | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)

(limited to 'source/blender/modifiers')

diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index 7710082150b..760830ffb24 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -18,6 +18,11 @@
  * \ingroup modifiers
  */
 
+#include 
+
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
+
 #include "DNA_cachefile_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
@@ -47,6 +52,9 @@ static void initData(ModifierData *md)
   mcmd->cache_file = NULL;
   mcmd->object_path[0] = '\0';
   mcmd->read_flag = MOD_MESHSEQ_READ_ALL;
+
+  mcmd->reader = NULL;
+  mcmd->reader_object_path[0] = '\0';
 }
 
 static void copyData(const ModifierData *md, ModifierData *target, const int flag)
@@ -59,6 +67,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
   modifier_copyData_generic(md, target, flag);
 
   tmcmd->reader = NULL;
+  tmcmd->reader_object_path[0] = '\0';
 }
 
 static void freeData(ModifierData *md)
@@ -66,10 +75,8 @@ static void freeData(ModifierData *md)
   MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
 
   if (mcmd->reader) {
-#ifdef WITH_ALEMBIC
-    CacheReader_free(mcmd->reader);
-#endif
-    mcmd->reader = NULL;
+    mcmd->reader_object_path[0] = '\0';
+    BKE_cachefile_reader_free(mcmd->cache_file, &mcmd->reader);
   }
 }
 
@@ -93,17 +100,14 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
   Mesh *org_mesh = mesh;
 
   Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
+  CacheFile *cache_file = mcmd->cache_file;
   const float frame = DEG_get_ctime(ctx->depsgraph);
-  const float time = BKE_cachefile_time_offset(mcmd->cache_file, frame, FPS);
+  const float time = BKE_cachefile_time_offset(cache_file, frame, FPS);
   const char *err_str = NULL;
 
-  CacheFile *cache_file = (CacheFile *)DEG_get_original_id(&mcmd->cache_file->id);
-
-  BKE_cachefile_ensure_handle(G.main, cache_file);
-
-  if (!mcmd->reader) {
-    mcmd->reader = CacheReader_open_alembic_object(
-        cache_file->handle, NULL, ctx->object, mcmd->object_path);
+  if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) {
+    STRNCPY(mcmd->reader_object_path, mcmd->object_path);
+    BKE_cachefile_reader_open(cache_file, &mcmd->reader, ctx->object, mcmd->object_path);
     if (!mcmd->reader) {
       modifier_setError(md, "Could not create Alembic reader for file %s", cache_file->filepath);
       return mesh;
-- 
cgit v1.2.3