ap
= ad
= bp
= bd
=
static Vector intersectLines(const Vector &ap, const Vector &ad,
const Vector &bp, const Vector &bd) {
// always returns a point on the (ap, ad) line
double a = ad.sqrnorm(), b = ad | bd, c = bd.sqrnorm();
double d = ad | (ap - bp), e = bd | (ap - bp);
if (a * c - b * b < 1.0e-7)
return ap;
double s = (b * e - c * d) / (a * c - b * b);
return ap + s * ad;
}
selected_object
beállításavoid Viewer::endSelection(const QPoint &) {
glFlush();
GLint nbHits = glRenderMode(GL_RENDER);
if (nbHits <= 0)
setSelectedName(-1);
else {
const GLuint *ptr = selectBuffer();
GLuint zMin = std::numeric_limits<GLuint>::max();
for (int i = 0; i < nbHits; ++i, ptr += 4) {
GLuint names = ptr[0];
if (ptr[1] < zMin) {
zMin = ptr[1];
if (names == 2) {
selected_object = ptr[3];
ptr++;
}
setSelectedName(ptr[3]);
} else if (names == 2)
ptr++;
}
}
}