The line proposed by Tom should work. However you shouldn't be storing this pointer in CustomDataLayer*, you should do something like this instead:
MTFace *mtface = CustomData_get_layer(&me->fdata, CD_MTFACE); MTFace *mtf = &mtface[i]; On Sun, Jan 5, 2014 at 9:36 PM, Tom Edwards <cont...@steamreview.org> wrote: > Built your patch and realised that cdl isn't MTFace**, which is what the > fix I suggested is for. This is what you actually need: > > MTFace *mtface = &((MTFace *) cdl)[i]; > > The original code was creating a ref to CustomDataLayer*, indexing into > it, and only casting to MTFace* as the last step. The structs are > different sizes so things ended up out of alignment. > > I had to fix a heap corruption bug to get that far BTW...full patch at > <http://pastebin.com/RR4GPQJN>. :-) > > On 05/01/2014 6:25 PM, Dalai Felinto wrote: >> Hi, >> >>> This should fix it: >>> &(cdl[1]) >> Sorry, but where would that be? Because If I do: >> (1) MTFace *mtface = (MTFace *)&cdl[i]; >> >> As it is now, or if I do: >> (2) MTFace *mtface = (MTFace *)&(cdl[i]); >> >> They all produce the same result >> >> I just committed (bc3d601 in the branch) a temporary printf code to >> illustrate better how I'm getting the values: >> https://github.com/dfelinto/blender-git/blob/bake-cycles/source/blender/render/intern/source/bake_new.c#L142 >> >> It produces this output: >> face: 0 >> vec[0]: 0.50, 1.00 >> vec[1]: 0.00, 0.00 >> vec[2]: 1.00, 0.00 >> vec[3]: 0.00, 0.00 >> >> face: 1 >> vec[0]: 0.00, 0.00 >> vec[1]: 0.50, 1.00 >> vec[2]: 0.00, 0.00 >> vec[3]: 0.00, 0.00 >> >> face: 2 >> vec[0]: 78719930099698347488497473945600.00, 0.00 >> vec[1]: 0.00, 261866902067410370560.00 >> vec[2]: 261048548756996227072.00, 2959217080378280902656.00 >> vec[3]: 69779857993988661313536.00, 4668088091354259464912896.00 >> >> Thanks, >> Dalai >> _______________________________________________ >> Bf-committers mailing list >> Bf-committers@blender.org >> http://lists.blender.org/mailman/listinfo/bf-committers >> > > _______________________________________________ > Bf-committers mailing list > Bf-committers@blender.org > http://lists.blender.org/mailman/listinfo/bf-committers _______________________________________________ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers