diff options
Diffstat (limited to 'source/blender/render/intern/source/envmap.c')
-rw-r--r-- | source/blender/render/intern/source/envmap.c | 91 |
1 files changed, 52 insertions, 39 deletions
diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 55f7433da96..1e40ab886ae 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -25,6 +25,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/render/intern/source/envmap.c + * \ingroup render + */ + + #include <math.h> #include <string.h> @@ -70,47 +75,54 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf) { int dx, part; - BKE_free_envmapdata(env); - - dx= ibuf->y; - dx/= 2; - if (3*dx == ibuf->x) { - env->type = ENV_CUBE; - } else if (ibuf->x == ibuf->y) { - env->type = ENV_PLANE; - } else { - printf("Incorrect envmap size\n"); - env->ok= 0; - env->ima->ok= 0; - return; - } - - if (env->type == ENV_CUBE) { - for(part=0; part<6; part++) { - env->cube[part]= IMB_allocImBuf(dx, dx, 24, IB_rect|IB_rectfloat); + /* after lock we test cube[1], if set the other thread has done it fine */ + BLI_lock_thread(LOCK_IMAGE); + if(env->cube[1]==NULL) { + + BKE_free_envmapdata(env); + + dx= ibuf->y; + dx/= 2; + if (3*dx == ibuf->x) { + env->type = ENV_CUBE; + env->ok= ENV_OSA; + } else if (ibuf->x == ibuf->y) { + env->type = ENV_PLANE; + env->ok= ENV_OSA; + } else { + printf("Incorrect envmap size\n"); + env->ok= 0; + env->ima->ok= 0; } - IMB_float_from_rect(ibuf); - - IMB_rectcpy(env->cube[0], ibuf, - 0, 0, 0, 0, dx, dx); - IMB_rectcpy(env->cube[1], ibuf, - 0, 0, dx, 0, dx, dx); - IMB_rectcpy(env->cube[2], ibuf, - 0, 0, 2*dx, 0, dx, dx); - IMB_rectcpy(env->cube[3], ibuf, - 0, 0, 0, dx, dx, dx); - IMB_rectcpy(env->cube[4], ibuf, - 0, 0, dx, dx, dx, dx); - IMB_rectcpy(env->cube[5], ibuf, - 0, 0, 2*dx, dx, dx, dx); - env->ok= ENV_OSA; - } - else { /* ENV_PLANE */ - env->cube[1]= IMB_dupImBuf(ibuf); - IMB_float_from_rect(env->cube[1]); - env->ok= ENV_OSA; - } + if(env->ok) { + if (env->type == ENV_CUBE) { + for(part=0; part<6; part++) { + env->cube[part]= IMB_allocImBuf(dx, dx, 24, IB_rect|IB_rectfloat); + } + IMB_float_from_rect(ibuf); + + IMB_rectcpy(env->cube[0], ibuf, + 0, 0, 0, 0, dx, dx); + IMB_rectcpy(env->cube[1], ibuf, + 0, 0, dx, 0, dx, dx); + IMB_rectcpy(env->cube[2], ibuf, + 0, 0, 2*dx, 0, dx, dx); + IMB_rectcpy(env->cube[3], ibuf, + 0, 0, 0, dx, dx, dx); + IMB_rectcpy(env->cube[4], ibuf, + 0, 0, dx, dx, dx, dx); + IMB_rectcpy(env->cube[5], ibuf, + 0, 0, 2*dx, dx, dx, dx); + + } + else { /* ENV_PLANE */ + env->cube[1]= IMB_dupImBuf(ibuf); + IMB_float_from_rect(env->cube[1]); + } + } + } + BLI_unlock_thread(LOCK_IMAGE); } /* ------------------------------------------------------------------------- */ @@ -718,6 +730,7 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe TexResult texr1, texr2; texr1.nor= texr2.nor= NULL; + texr1.talpha= texr2.talpha= texres->talpha; /* boxclip expects this initialized */ add_v3_v3(vec, dxt); face1= envcube_isect(env, vec, sco); |