From 32f7b4a3588f108c7ab4ec733ad4d97738017658 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Jul 2015 04:57:58 +1000 Subject: Avoid getting the original index if its not needed --- source/blender/blenkernel/intern/cdderivedmesh.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 8d91fe8d559..9307abc8a08 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -636,7 +636,7 @@ static void cdDM_drawMappedFaces( const MPoly *mpoly = cddm->mpoly; const MLoopCol *mloopcol = NULL; int colType, useColors = flag & DM_DRAW_USE_COLORS, useHide = flag & DM_DRAW_SKIP_HIDDEN; - int i, j, orig; + int i, j; int start_element = 0, tot_element, tot_drawn; int totpoly; int tottri; @@ -662,7 +662,7 @@ static void cdDM_drawMappedFaces( if (fi_map) { for (i = 0; i < totpoly; i++, mpoly++) { int selcol = 0xFFFFFFFF; - orig = (index_mp_to_orig) ? index_mp_to_orig[i] : i; + const int orig = (index_mp_to_orig) ? index_mp_to_orig[i] : i; if ((orig != ORIGINDEX_NONE) && (!useHide || !(me->mpoly[orig].flag & ME_HIDE))) { WM_framebuffer_index_get(orig + 1, &selcol); @@ -739,10 +739,13 @@ static void cdDM_drawMappedFaces( if (i != totpoly - 1) next_actualFace = bufmat->polys[i + 1]; - orig = (index_mp_to_orig) ? index_mp_to_orig[actualFace] : actualFace; + if (setDrawOptions) { + const int orig = (index_mp_to_orig) ? index_mp_to_orig[actualFace] : actualFace; - if (setDrawOptions != NULL && (orig != ORIGINDEX_NONE)) - draw_option = setDrawOptions(userData, orig); + if (orig != ORIGINDEX_NONE) { + draw_option = setDrawOptions(userData, orig); + } + } if (draw_option == DM_DRAW_OPTION_STIPPLE) { glEnable(GL_POLYGON_STIPPLE); -- cgit v1.2.3