PDA

View Full Version : Azone utility bug: Faces that intersect a node but have no vertices in that node


Derision
12-12-2007, 11:02 PM
I've run across a couple of small bugs in the azone utility which
means that some faces which intersect a node, but don't have any
vertices in that node, will not be included in the facelist for
that node.

E.g. in the case shown in this picture:

http://www.rama.demon.co.uk/nodeface.png

The first bug is in one of the GPoint constructors:

azone.cpp, Line 1155:

Change:

GPoint::GPoint(float x, float y, float z) {
x = x;
y = y;
z = z;
}


to

GPoint::GPoint(float nx, float ny, float nz) {
x = nx;
y = ny;
z = nz;
}


The second bug is in the edges_cross function. Take the following
example of two lines which intersect.

http://www.rama.demon.co.uk/lines_cross.png

The following code illustrates the bug, it returns FALSE:


GPoint p1(100,100,0), p2(100,300,0);
VERTEX p3, p4;
p3.x=300;p3.y=200;p3.z=0;
p4.x=50;p4.y=200;p4.z=0;
printf("edges_cross returns %d\n", edges_cross(&p1,&p2,&p3,&p4));


The fix is to change:

azone.cpp, Line 868:

from
#define CoordOnLine(p1, p2, coord, dim) \
(p1->dim > p2->dim? (coord > p2->dim && coord < p1->dim) : (coord > p1->dim && coord < p2->dim))


to


#define CoordOnLine(p1, p2, coord, dim) \
(p1->dim > p2->dim? (coord >= p2->dim && coord <= p1->dim) : (coord >= p1->dim && coord <= p2->dim))