[Bf-committers] Radio code!

Brecht Van Lommel brechtvanlommel at pandora.be
Sun Dec 10 23:58:34 CET 2006


Hey Ton,

Fully agree this is bad code. It uses the same ugly trick as before I 
made changes there though, stuffing vertex indices in the colors, I just 
didn't improve the situation. But will do that.

Brecht.

Ton Roosendaal wrote:
> Hi Brecht,
> 
> Someone pointed me at warnings in radpostprocess.c (gcc 3.3 doesnt here):
> 
> gcc error:
> "radpostprocess.c:760: warning: dereferencing type-punned pointer will 
> break strict-aliasing rules"
> 
> It is stuffed with lines like:
> 
> 
>     mcol[0]= *((unsigned int*)face->v1+3) | 0x1000000;
> 
>     *((unsigned int*)face->v1+3)= ~0;
> 
>     unsigned int *col= ((unsigned int**)&face->v1)[i] + 3;
> 
>     *vco= ((float**)&face->v1)[i];
> 
>     ((unsigned int*)&mf->v1)[i] = *col;
> 
>     subco= (me->mvert + ((unsigned int*)&mf->v1)[i])->co;
> 
> 
> Which might seem incredible smart (I am too stupid to grasp this code), 
> but it smells like very dangerous hacking, bypassing the meaning of 
> structs.
> 
> If you don't like MCol or MFace structures, then make own temporal 
> structs to store things in, with proper names and no casting. Or use 
> your custom data storage...
> 
> Or am I wrong? For me, this I can never fix or check if it's 64 bits 
> safe code for example...
> 
> -Ton-
> 
> --------------------------------------------------------------------------
> Ton Roosendaal  Blender Foundation ton at blender.org http://www.blender.org
> 
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-committers
> 
> 



More information about the Bf-committers mailing list