diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-05 19:04:10 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-05 19:04:10 +0400 |
commit | dfdfa06c27c6dc44cb3f05e0355279d9e16eab93 (patch) | |
tree | 5875875e50e6071ea9138fd8f65f85a8e475d9c9 /source/blender | |
parent | 0a35e050f3139a55e98f17c88875d76f433e371a (diff) |
code cleanup: minor edit - replace memset() with zero initialization, remove unneeded NULL check in ibuf_sample()
Diffstat (limited to 'source/blender')
4 files changed, 18 insertions, 38 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 3f9e0051d2e..99bc192042c 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. @@ -177,15 +177,10 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3], float paint_get_tex_pixel(Brush *br, float u, float v) { - TexResult texres; - float co[3]; + TexResult texres = {0}; + float co[3] = {u, v, 0.0f}; int hasrgb; - co[0] = u; - co[1] = v; - co[2] = 0; - - memset(&texres, 0, sizeof(TexResult)); hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 0, &texres); if (hasrgb & TEX_RGB) diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h index 9d7393f9414..604cd940fab 100644 --- a/source/blender/render/extern/include/RE_render_ext.h +++ b/source/blender/render/extern/include/RE_render_ext.h @@ -58,7 +58,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa float texture_value_blend(float tex, float out, float fact, float facg, int blendtype); /* node_composite.c */ -void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, float *result); +void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, float result[4]); void antialias_tagbuf(int xsize, int ysize, char *rectmove); /* dynamicpaint.c */ diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h index 1c8a2552482..e8f171fe383 100644 --- a/source/blender/render/intern/include/texture.h +++ b/source/blender/render/intern/include/texture.h @@ -78,7 +78,7 @@ void render_realtime_texture(struct ShadeInput *shi, struct Image *ima); int imagewraposa(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], const float dxt[3], const float dyt[3], struct TexResult *texres); int imagewrap(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], struct TexResult *texres); -void image_sample(struct Image *ima, float fx, float fy, float dx, float dy, float *result); +void image_sample(struct Image *ima, float fx, float fy, float dx, float dy, float result[4]); #endif /* __TEXTURE_H__ */ diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index c4c89bd06a6..0a90a55b3bc 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -1779,11 +1779,8 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const } /* de-premul, this is being premulled in shade_input_do_shade() */ - if (texres->ta!=1.0f && texres->ta>1e-4f) { - fx= 1.0f/texres->ta; - texres->tr*= fx; - texres->tg*= fx; - texres->tb*= fx; + if (texres->ta != 1.0f && texres->ta > 1e-4f) { + mul_v3_fl(&texres->tr, 1.0f / texres->ta); } BRICONTRGB; @@ -1791,25 +1788,22 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const return retval; } -void image_sample(Image *ima, float fx, float fy, float dx, float dy, float *result) +void image_sample(Image *ima, float fx, float fy, float dx, float dy, float result[4]) { TexResult texres; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if (ibuf==NULL) { - result[0]= result[1]= result[2]= result[3]= 0.0f; + if (UNLIKELY(ibuf == NULL)) { + zero_v4(result); return; } if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) ibuf->rect+= (ibuf->x*ibuf->y); - texres.talpha= 1; /* boxsample expects to be initialized */ - boxsample(ibuf, fx, fy, fx+dx, fy+dy, &texres, 0, 1); - result[0]= texres.tr; - result[1]= texres.tg; - result[2]= texres.tb; - result[3]= texres.ta; + texres.talpha = TRUE; /* boxsample expects to be initialized */ + boxsample(ibuf, fx, fy, fx + dx, fy + dy, &texres, 0, 1); + copy_v4_v4(result, &texres.tr); if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) ibuf->rect-= (ibuf->x*ibuf->y); @@ -1817,15 +1811,11 @@ void image_sample(Image *ima, float fx, float fy, float dx, float dy, float *res ima->flag|= IMA_USED_FOR_RENDER; } -void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float *result) +void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float result[4]) { - TexResult texres; + TexResult texres = {0}; afdata_t AFD; - - if (ibuf==NULL) { - return; - } - + AFD.dxt[0] = dx; AFD.dxt[1] = dx; AFD.dyt[0] = dy; AFD.dyt[1] = dy; //copy_v2_v2(AFD.dxt, dx); @@ -1833,13 +1823,8 @@ void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float *res AFD.intpol = 1; AFD.extflag = TXC_EXTD; - - memset(&texres, 0, sizeof(texres)); + ewa_eval(&texres, ibuf, fx, fy, &AFD); - - result[0]= texres.tr; - result[1]= texres.tg; - result[2]= texres.tb; - result[3]= texres.ta; + copy_v4_v4(result, &texres.tr); } |