From c65c1958bde6425cedb810590d64252adc2e56c3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Jan 2013 05:54:17 +0000 Subject: code cleanup: minor edits to mesh-cache formatting. --- source/blender/modifiers/intern/MOD_meshcache.c | 73 ++++++++++++------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c index 1dd41c349d9..b111381eb9c 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.c +++ b/source/blender/modifiers/intern/MOD_meshcache.c @@ -236,49 +236,46 @@ static void meshcache_do( /* tricky shape key integration (slow!) */ if (mcmd->deform_mode == MOD_MESHCACHE_DEFORM_INTEGRATE) { + Mesh *me = ob->data; + /* we could support any object type */ - if (ob->type != OB_MESH) { + if (UNLIKELY(ob->type != OB_MESH)) { modifier_setError(&mcmd->modifier, "'Integrate' only valid for Mesh objects"); } + else if (UNLIKELY(me->totvert != numVerts)) { + modifier_setError(&mcmd->modifier, "'Integrate' original mesh vertex mismatch"); + } + else if (UNLIKELY(me->totpoly == 0)) { + modifier_setError(&mcmd->modifier, "'Integrate' requires faces"); + } else { - Mesh *me = ob->data; - if (me->totvert != numVerts) { - modifier_setError(&mcmd->modifier, "'Integrate' original mesh vertex mismatch"); - } - else { - if (me->totpoly == 0) { - modifier_setError(&mcmd->modifier, "'Integrate' requires faces"); - } - else { - /* the moons align! */ - int i; - - float (*vertexCos_Source)[3] = MEM_mallocN(sizeof(*vertexCos_Source) * numVerts, __func__); - float (*vertexCos_New)[3] = MEM_mallocN(sizeof(*vertexCos_New) * numVerts, __func__); - MVert *mv = me->mvert; - - for (i = 0; i < numVerts; i++, mv++) { - copy_v3_v3(vertexCos_Source[i], mv->co); - } - - BKE_mesh_calc_relative_deform( - me->mpoly, me->totpoly, - me->mloop, me->totvert, - - (const float (*)[3])vertexCos_Source, /* from the original Mesh*/ - (const float (*)[3])vertexCos_Real, /* the input we've been given (shape keys!) */ - - (const float (*)[3])vertexCos, /* the result of this modifier */ - vertexCos_New /* the result of this function */ - ); - - /* write the corrected locations back into the result */ - memcpy(use_factor ? vertexCos : vertexCos_Real, vertexCos_New, sizeof(*vertexCos) * numVerts); - - MEM_freeN(vertexCos_Source); - MEM_freeN(vertexCos_New); - } + /* the moons align! */ + int i; + + float (*vertexCos_Source)[3] = MEM_mallocN(sizeof(*vertexCos_Source) * numVerts, __func__); + float (*vertexCos_New)[3] = MEM_mallocN(sizeof(*vertexCos_New) * numVerts, __func__); + MVert *mv = me->mvert; + + for (i = 0; i < numVerts; i++, mv++) { + copy_v3_v3(vertexCos_Source[i], mv->co); } + + BKE_mesh_calc_relative_deform( + me->mpoly, me->totpoly, + me->mloop, me->totvert, + + (const float (*)[3])vertexCos_Source, /* from the original Mesh*/ + (const float (*)[3])vertexCos_Real, /* the input we've been given (shape keys!) */ + + (const float (*)[3])vertexCos, /* the result of this modifier */ + vertexCos_New /* the result of this function */ + ); + + /* write the corrected locations back into the result */ + memcpy(use_factor ? vertexCos : vertexCos_Real, vertexCos_New, sizeof(*vertexCos) * numVerts); + + MEM_freeN(vertexCos_Source); + MEM_freeN(vertexCos_New); } } -- cgit v1.2.3