34 if (p.x > rd) faces |= CUBE_FACE_RIGHT;
35 if (p.x < -rd) faces |= CUBE_FACE_LEFT;
36 if (p.y > rd) faces |= CUBE_FACE_TOP;
37 if (p.y < -rd) faces |= CUBE_FACE_BOTTOM;
38 if (p.z > rd) faces |= CUBE_FACE_FRONT;
39 if (p.z < -rd) faces |= CUBE_FACE_BACK;
47 if ( p.x + p.y > r2) bevels |= 0x001;
48 if ( p.x - p.y > r2) bevels |= 0x002;
49 if (-p.x + p.y > r2) bevels |= 0x004;
50 if (-p.x - p.y > r2) bevels |= 0x008;
51 if ( p.x + p.z > r2) bevels |= 0x010;
52 if ( p.x - p.z > r2) bevels |= 0x020;
53 if (-p.x + p.z > r2) bevels |= 0x040;
54 if (-p.x - p.z > r2) bevels |= 0x080;
55 if ( p.y + p.z > r2) bevels |= 0x100;
56 if ( p.y - p.z > r2) bevels |= 0x200;
57 if (-p.y + p.z > r2) bevels |= 0x400;
58 if (-p.y - p.z > r2) bevels |= 0x800;
66 if (( p.x + p.y + p.z) > r3) corners |= 0x01;
67 if (( p.x + p.y - p.z) > r3) corners |= 0x02;
68 if (( p.x - p.y + p.z) > r3) corners |= 0x04;
69 if (( p.x - p.y - p.z) > r3) corners |= 0x08;
70 if ((-p.x + p.y + p.z) > r3) corners |= 0x10;
71 if ((-p.x + p.y - p.z) > r3) corners |= 0x20;
72 if ((-p.x - p.y + p.z) > r3) corners |= 0x40;
73 if ((-p.x - p.y - p.z) > r3) corners |= 0x80;
79 if (CUBE_FACE_RIGHT & mask)
80 return make_vector( rd,
81 p1.y + (p2.y - p1.y) * (rd - p1.x) / (p2.x - p1.x),
82 p1.z + (p2.z - p1.z) * (rd - p1.x) / (p2.x - p1.x));
84 if (CUBE_FACE_LEFT & mask)
85 return make_vector( -rd,
86 p1.y + (p2.y - p1.y) * (-rd - p1.x) / (p2.x - p1.x),
87 p1.z + (p2.z - p1.z) * (-rd - p1.x) / (p2.x - p1.x));
89 if (CUBE_FACE_TOP & mask)
90 return make_vector( p1.x + (p2.x - p1.x) * (rd - p1.y) / (p2.y - p1.y),
92 p1.z + (p2.z - p1.z) * (rd - p1.y) / (p2.y - p1.y));
94 if (CUBE_FACE_BOTTOM & mask)
95 return make_vector( p1.x + (p2.x - p1.x) * (-rd - p1.y) / (p2.y - p1.y),
97 p1.z + (p2.z - p1.z) * (-rd - p1.y) / (p2.y - p1.y));
99 if (CUBE_FACE_FRONT & mask)
100 return make_vector( p1.x + (p2.x - p1.x) * (rd - p1.z) / (p2.z - p1.z),
101 p1.y + (p2.y - p1.y) * (rd - p1.z) / (p2.z - p1.z),
104 if (CUBE_FACE_BACK & mask)
105 return make_vector( p1.x + (p2.x - p1.x) * (-rd - p1.z) / (p2.z - p1.z),
106 p1.y + (p2.y - p1.y) * (-rd - p1.z) / (p2.z - p1.z),
111int checkPoint(Vector p1, Vector p2, GLfloat alpha,
long mask, GLfloat rd)
114 pp.x = p1.x + alpha * (p2.x - p1.x);
115 pp.y = p1.y + alpha * (p2.y - p1.y);
116 pp.z = p1.z + alpha * (p2.z - p1.z);
120int checkLine(Vector p1, Vector p2,
int mask, GLfloat rd)
123 if ((CUBE_FACE_RIGHT & mask) && (p1.x > p2.x) && (
checkPoint( p1, p2, (rd-p1.x)/(p2.x-p1.x), 0x3f - CUBE_FACE_RIGHT, rd) == 0))
124 result |= CUBE_FACE_RIGHT;
125 if ((CUBE_FACE_LEFT & mask) && (p1.x < p2.x) && (
checkPoint( p1, p2, (-rd-p1.x)/(p2.x-p1.x), 0x3f - CUBE_FACE_LEFT, rd) == 0))
126 result |= CUBE_FACE_LEFT;
127 if ((CUBE_FACE_TOP & mask) && (p1.y > p2.y) && (
checkPoint( p1, p2, (rd-p1.y)/(p2.y-p1.y), 0x3f - CUBE_FACE_TOP, rd) == 0))
128 result |= CUBE_FACE_TOP;
129 if ((CUBE_FACE_BOTTOM & mask) && (p1.y < p2.y) && (
checkPoint( p1, p2, (-rd-p1.y)/(p2.y-p1.y), 0x3f - CUBE_FACE_BOTTOM, rd) == 0))
130 result |= CUBE_FACE_BOTTOM;
131 if ((CUBE_FACE_FRONT & mask) && (p1.z > p2.z) && (
checkPoint( p1, p2, (rd-p1.z)/(p2.z-p1.z), 0x3f - CUBE_FACE_FRONT, rd) == 0))
132 result |= CUBE_FACE_FRONT;
133 if ((CUBE_FACE_BACK & mask) && (p1.z < p2.z) && (
checkPoint( p1, p2, (-rd-p1.z)/(p2.z-p1.z), 0x3f - CUBE_FACE_BACK, rd) == 0))
134 result |= CUBE_FACE_BACK;
142 int v0_test, v1_test;
153 if ((v0_test & v1_test) != 0)
160 if ((v0_test & v1_test) != 0)
167 if ((v0_test & v1_test) != 0)
172 return checkLine( v0, v1, v0_test | v1_test, rd);