[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35672] trunk/blender/source/blender: Bugfix #26549

Dalai Felinto dfelinto at gmail.com
Tue Mar 22 00:59:26 CET 2011


Mitchell,
this is a safe fix. If you can commit it go for it.

Datablocks have ID as the first element of the struct so in the end a
pointer to the datablock and a pointer to the ID struct points to the same
address. So although the warning is valid, the code itself should be ok
(after silencing the warning for MSVC's sake).

Cheers,
Dalai

2011/3/21 Mitchell Stokes <mogurijin at gmail.com>

>  id_us_min(texn->env->ima) generates a warning and causes MSVC+CMake
> to not build since warnings are treated as errors.
> id_us_min((ID*)texn->env->ima) is fine though. If this is the right
> change, than I can go ahead and commit it.
>
> Cheers,
> Mitchell
>
> On Mon, Mar 21, 2011 at 10:10 AM, Ton Roosendaal <ton at blender.org> wrote:
> > Revision: 35672
> >
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35672
> > Author:   ton
> > Date:     2011-03-21 17:10:55 +0000 (Mon, 21 Mar 2011)
> > Log Message:
> > -----------
> > Bugfix #26549
> >
> > Using environment map type "load" increased user counter on each
> > preview render.
> >
> > Also noticed that this type of envmap use wasn't threadsafe, causing
> > imbufs being allocated for all threads. Also fixed that.
> >
> > Modified Paths:
> > --------------
> >    trunk/blender/source/blender/blenkernel/intern/texture.c
> >    trunk/blender/source/blender/render/intern/source/envmap.c
> >
> > Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
> > ===================================================================
> > --- trunk/blender/source/blender/blenkernel/intern/texture.c
>  2011-03-21 16:46:26 UTC (rev 35671)
> > +++ trunk/blender/source/blender/blenkernel/intern/texture.c
>  2011-03-21 17:10:55 UTC (rev 35672)
> > @@ -788,7 +788,10 @@
> >        }
> >
> >        if(texn->coba) texn->coba= MEM_dupallocN(texn->coba);
> > -       if(texn->env) texn->env= BKE_copy_envmap(texn->env);
> > +       if(texn->env) {
> > +               texn->env= BKE_copy_envmap(texn->env);
> > +               id_us_min(texn->env->ima);
> > +       }
> >        if(texn->pd) texn->pd= MEM_dupallocN(texn->pd);
> >        if(texn->vd) {
> >                texn->vd= MEM_dupallocN(texn->vd);
> >
> > Modified: trunk/blender/source/blender/render/intern/source/envmap.c
> > ===================================================================
> > --- trunk/blender/source/blender/render/intern/source/envmap.c
>  2011-03-21 16:46:26 UTC (rev 35671)
> > +++ trunk/blender/source/blender/render/intern/source/envmap.c
>  2011-03-21 17:10:55 UTC (rev 35672)
> > @@ -75,47 +75,54 @@
> >  {
> >        int dx, part;
> >
> > -       BKE_free_envmapdata(env);
> > +       /* 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;
> > -       } 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);
> > +               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);
> >  }
> >
> >  /*
> ------------------------------------------------------------------------- */
> >
> > _______________________________________________
> > Bf-blender-cvs mailing list
> > Bf-blender-cvs at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-blender-cvs
> >
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list