[Bf-committers] help with tessface, CustomData and MTFace

2014-01-05 Thread Dalai Felinto
Hi there,
Anyone  familiar with CustomData and tessface here?

I'm trying to figure out why this function is only working for the first face:
https://github.com/dfelinto/blender-git/blob/bake-cycles/source/blender/render/intern/source/bake_new.c#L104

I'm getting bad data when trying to read the MTFace for any face that
is not the first one:

((MTFace *)cdl[0])-uv
{0.50238, 1}, {0, 0}, {1, 0}, {0, 0}}

((MTFace *)cdl[1])-uv
{{0, 0}, {0.50238, 1}, {0, 0}, {0, 0}}

((MTFace *)cdl[2])-uv
{{7.87199301e+31, 1.17082983e-19}, {2.17010503e-18,
2.61866902e+20}, {2.61048549e+20, 2.95921708e+21}, {
  6.9779858e+22, 4.66808809e+24}}

As you can see the 2nd face is bad (2 verts are at 0, 0) and the 3rd
one is totally bogus. The mesh itself is very simple, if you want to
check out (it's the one in 3-Tris):
http://www.pasteall.org/blend/26092

While at there another question:
Is there any way to get the number of verts of a MTFace?

Thanks,
Dalai
--
blendernetwork.org/dalai-felinto
www.dalaifelinto.com
___
Bf-committers mailing list
Bf-committers@blender.org
http://lists.blender.org/mailman/listinfo/bf-committers


Re: [Bf-committers] help with tessface, CustomData and MTFace

2014-01-05 Thread Tom Edwards
This should fix it:

(cdl[1])

Currently you are indexing into your reference!

On 05/01/2014 5:28 PM, Dalai Felinto wrote:
 Hi there,
 Anyone  familiar with CustomData and tessface here?

 I'm trying to figure out why this function is only working for the first face:
 https://github.com/dfelinto/blender-git/blob/bake-cycles/source/blender/render/intern/source/bake_new.c#L104

 I'm getting bad data when trying to read the MTFace for any face that
 is not the first one:

 ((MTFace *)cdl[0])-uv
 {0.50238, 1}, {0, 0}, {1, 0}, {0, 0}}

 ((MTFace *)cdl[1])-uv
 {{0, 0}, {0.50238, 1}, {0, 0}, {0, 0}}

 ((MTFace *)cdl[2])-uv
 {{7.87199301e+31, 1.17082983e-19}, {2.17010503e-18,
 2.61866902e+20}, {2.61048549e+20, 2.95921708e+21}, {
6.9779858e+22, 4.66808809e+24}}

 As you can see the 2nd face is bad (2 verts are at 0, 0) and the 3rd
 one is totally bogus. The mesh itself is very simple, if you want to
 check out (it's the one in 3-Tris):
 http://www.pasteall.org/blend/26092

 While at there another question:
 Is there any way to get the number of verts of a MTFace?

 Thanks,
 Dalai
 --
 blendernetwork.org/dalai-felinto
 www.dalaifelinto.com
 ___
 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


Re: [Bf-committers] help with tessface, CustomData and MTFace

2014-01-05 Thread Dalai Felinto
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


Re: [Bf-committers] help with tessface, CustomData and MTFace

2014-01-05 Thread Tom Edwards
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


Re: [Bf-committers] help with tessface, CustomData and MTFace

2014-01-05 Thread Brecht Van Lommel
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


Re: [Bf-committers] help with tessface, CustomData and MTFace

2014-01-05 Thread Dalai Felinto
 However you shouldn't be storing this pointer in CustomDataLayer*, you should 
 do something like this instead: (...)

Ah, now I I understand the CustomData_get_* functions better. Way more
clear thanks a lot Brecht.

@Tom, many thanks, my system was crashing some times, but I haven't
stop to pinpoint the MEM_callocN issue ;), and thanks for the other
fix too.

Apparently the function is fully working now :) The only missing bit
is to get the number of verts of the MTFace to know when it's a quad
and when it is a triangle.

Kudos,
Dalai
--
blendernetwork.org/dalai-felinto
www.dalaifelinto.com
___
Bf-committers mailing list
Bf-committers@blender.org
http://lists.blender.org/mailman/listinfo/bf-committers