From f79856f9fb12d47d08e14a1e0edaee9e638362c0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 12 Jun 2020 14:29:59 +1000 Subject: Cleanup: minor changes to deform functions - Use 'float (*)[3]' to avoid casts. - Remove unnecessary float[3] copy in gpencil_deform_verts. - Use MEM_SAFE_FREE - Use const arguments. --- source/blender/modifiers/intern/MOD_armature.c | 16 +++++----------- source/blender/modifiers/intern/MOD_util.c | 8 ++++---- source/blender/modifiers/intern/MOD_util.h | 4 ++-- 3 files changed, 11 insertions(+), 17 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 214c6dbe9dc..800de546a5a 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -74,7 +74,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla ArmatureModifierData *tamd = (ArmatureModifierData *)target; BKE_modifier_copydata_generic(md, target, flag); - tamd->prevCos = NULL; + tamd->vert_coords_prev = NULL; } static void requiredDataMask(Object *UNUSED(ob), @@ -152,15 +152,12 @@ static void deformVerts(ModifierData *md, NULL, numVerts, amd->deformflag, - (float(*)[3])amd->prevCos, + amd->vert_coords_prev, amd->defgrp_name, mesh); /* free cache */ - if (amd->prevCos) { - MEM_freeN(amd->prevCos); - amd->prevCos = NULL; - } + MEM_SAFE_FREE(amd->vert_coords_prev); } static void deformVertsEM(ModifierData *md, @@ -186,15 +183,12 @@ static void deformVertsEM(ModifierData *md, NULL, numVerts, amd->deformflag, - (float(*)[3])amd->prevCos, + amd->vert_coords_prev, amd->defgrp_name, mesh_src); /* free cache */ - if (amd->prevCos) { - MEM_freeN(amd->prevCos); - amd->prevCos = NULL; - } + MEM_SAFE_FREE(amd->vert_coords_prev); if (mesh_src != mesh) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 1aee545aa43..c6dff375109 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -169,12 +169,12 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd, } } -void MOD_previous_vcos_store(ModifierData *md, float (*vertexCos)[3]) +void MOD_previous_vcos_store(ModifierData *md, const float (*vert_coords)[3]) { while ((md = md->next) && md->type == eModifierType_Armature) { ArmatureModifierData *amd = (ArmatureModifierData *)md; - if (amd->multi && amd->prevCos == NULL) { - amd->prevCos = MEM_dupallocN(vertexCos); + if (amd->multi && amd->vert_coords_prev == NULL) { + amd->vert_coords_prev = MEM_dupallocN(vert_coords); } else { break; @@ -187,7 +187,7 @@ void MOD_previous_vcos_store(ModifierData *md, float (*vertexCos)[3]) Mesh *MOD_deform_mesh_eval_get(Object *ob, struct BMEditMesh *em, Mesh *mesh, - float (*vertexCos)[3], + const float (*vertexCos)[3], const int num_verts, const bool use_normals, const bool use_orco) diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h index 38e2083082d..a05e25d204c 100644 --- a/source/blender/modifiers/intern/MOD_util.h +++ b/source/blender/modifiers/intern/MOD_util.h @@ -40,12 +40,12 @@ void MOD_get_texture_coords(struct MappingInfoModifierData *dmd, float (*cos)[3], float (*r_texco)[3]); -void MOD_previous_vcos_store(struct ModifierData *md, float (*vertexCos)[3]); +void MOD_previous_vcos_store(struct ModifierData *md, const float (*vertexCos)[3]); struct Mesh *MOD_deform_mesh_eval_get(struct Object *ob, struct BMEditMesh *em, struct Mesh *mesh, - float (*vertexCos)[3], + const float (*vertexCos)[3], const int num_verts, const bool use_normals, const bool use_orco); -- cgit v1.2.3