Bug 774 : Incorrect tesselation in 3D space, not in 2D space (concave geometry)
Last modified: 2008-05-30 10:43




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P3
Severity:
normal

 

Reporter:
georgebrower
Assigned To:
fry

Attachment Type Created Size Actions
Code application/octet-stream 2008-05-27 11:45 1012 bytes
Shows change when removing last bezierVertex application/octet-stream 2008-05-28 11:30 2.08 KB

Description:   Opened: 2008-05-27 11:42
The following shape is filled incorrectly when using P3D or OPENGL, but
gets filled fine when I turn off either mode (this is bad because I need to
view the shape in 3D space).

Proper Tesselation:

[code]
void setup() {
size(400, 400);
}

void draw() {
background(255);
translate(500, 200);
noStroke();
fill(0);
beginShape();
vertex(-236.06598,17.797005);
bezierVertex(-240.068,17.797005,-244.21799,16.019005,-248.21997,12.016006);
bezierVertex(-256.373,3.864006,-260.52496,-13.333992,-260.52496,-34.975998);
bezierVertex(-260.52496,-49.354996,-259.04297,-66.105995,-249.99997,-75.0);
bezierVertex(-246.44296,-78.558,-242.58896,-80.187996,-238.73398,-80.187996);
bezierVertex(-236.00497,-80.187996,-233.34299,-79.40399,-230.91199,-77.95);
vertex(-230.91199,-85.646996);
bezierVertex(-233.008,-86.24899,-235.22299,-86.562,-237.54898,-86.562);
bezierVertex(-256.524,-86.562,-268.236,-65.659996,-268.236,-31.120995);
bezierVertex(-268.236,1.640007,-257.858,24.02501,-236.957,24.02501);
bezierVertex(-234.858,24.02501,-232.845,23.743011,-230.914,23.206009);
vertex(-230.914,16.827011);
bezierVertex(-232.555,17.450005,-234.27899,17.797005,-236.06598,17.797005);
endShape();
}
[/code]

Buggy Tesselation:

[code]
void setup() {
size(400, 400, P3D);
}

void draw() {
background(255);
translate(500, 200);
noStroke();
fill(0);
beginShape();
vertex(-236.06598,17.797005);
bezierVertex(-240.068,17.797005,-244.21799,16.019005,-248.21997,12.016006);
bezierVertex(-256.373,3.864006,-260.52496,-13.333992,-260.52496,-34.975998);
bezierVertex(-260.52496,-49.354996,-259.04297,-66.105995,-249.99997,-75.0);
bezierVertex(-246.44296,-78.558,-242.58896,-80.187996,-238.73398,-80.187996);
bezierVertex(-236.00497,-80.187996,-233.34299,-79.40399,-230.91199,-77.95);
vertex(-230.91199,-85.646996);
bezierVertex(-233.008,-86.24899,-235.22299,-86.562,-237.54898,-86.562);
bezierVertex(-256.524,-86.562,-268.236,-65.659996,-268.236,-31.120995);
bezierVertex(-268.236,1.640007,-257.858,24.02501,-236.957,24.02501);
bezierVertex(-234.858,24.02501,-232.845,23.743011,-230.914,23.206009);
vertex(-230.914,16.827011);
bezierVertex(-232.555,17.450005,-234.27899,17.797005,-236.06598,17.797005);
endShape();
}
[/code]
Additional Comment #1 From georgebrower 2008-05-27 11:45
edit]
Code
Additional Comment #2 From fry 2008-05-28 10:53
the problem is in that last bezierVertex() call.. what does it do? removing
it and using endShape(CLOSE) it works fine. tesselator problems happen when
points are doubled up or hit themselves.
Additional Comment #3 From georgebrower 2008-05-28 11:29
Well, it's subtle, but removing the last bezierVertex() call and using
endShape(CLOSE) makes the last line drawn totally straight.

The shape needs to end with a curved line ... I'll attach a small bit of
code that shows the difference.

Thanks a lot for your help!

(In reply to comment #2)
>
>
>
> Additional Comment #2 From
> fry
> 2008-05-28 10:53
>
> <!--
> addReplyLink(2); //-->[reply]
>
>
>
>
> the problem is in that last bezierVertex() call.. what does it do?
removing
> it and using endShape(CLOSE) it works fine. tesselator problems happen when
> points are doubled up or hit themselves.
>
>
Additional Comment #4 From georgebrower 2008-05-28 11:30
edit]
Shows change when removing last bezierVertex
Additional Comment #5 From georgebrower 2008-05-30 00:48
not sure if this could have anything to do with bug 547, though it is
marked as fixed

(In reply to comment #4)
>
>
>
> Additional Comment #4 From
>
> georgebrower
> 2008-05-28 11:30
>
> <!--
> addReplyLink(4); //-->[reply]
>
>
>
>
> Created an edit] [edit]
> Shows change when removing last bezierVertex
>
>
>

Additional Comment #6 From fry 2008-05-30 07:10
nah, that was different; this is a tessellation problem with points getting
doubled. i haven't had a chance to look into it more closely.. my guess is
that that final curve is so small, that when it tries to create 20 bezier
segments out of it for rasterization, something is getting doubled up,
which confuses the tessellator. i just need to verify that the tessellator
is properly dropping sequential points, since it looks like it's not.
Additional Comment #7 From georgebrower 2008-05-30 09:22
Ah, okay ... So it is (supposed to be) okay when you start and end on the
same point, right? Seems like you have to if you ever want to end on a curve.

(In reply to comment #6)
>
>
>
> Additional Comment #6 From
> fry
> 2008-05-30 07:10
>
> <!--
> addReplyLink(6); //-->[reply]
>
>
>
>
> nah, that was different; this is a tessellation problem with points
getting
> doubled. i haven't had a chance to look into it more closely.. my guess is
> that that final curve is so small, that when it tries to create 20 bezier
> segments out of it for rasterization, something is getting doubled up,
> which confuses the tessellator. i just need to verify that the tessellator
> is properly dropping sequential points, since it looks like it's not.
>
>
Additional Comment #8 From fry 2008-05-30 10:43
k, got a fix in for 0138.