Game Development Reference
In-Depth Information
if (!qptmp) return FALSE;
qpMax *= 2;
memcpy(qptmp, qp,
sizeof(QUADRICPAIR)*qpTotal);
delete [] qp;
qp = qptmp;
}
}
}
}
qutmp = new QUADRICPAIR[qpTotal];
memcpy(qptmp, qp, sizeof(QUADRICPAIR)*qpTotal);
delete [] qp;
return qptmp;
}
When creating the contraction target we attempt to invert the matrix
created from the sum of the end vertex quadrics. Matrices are not always
invertible; it depends on the determinant of the matrix not being zero. If
the current matrix is not invertible, then we use the vertex that gives the
least error from the end-points and the mid-point as the contraction
target.
BOOL CQuadric::CalculateVDash(QUADRICPAIR &qp, CQuadric *q)
{
CQuadric vq, vqInv;
VECTOR v;
double err[3];
vq = q[qp.v1] + q[qp.v2];
if (vq.Invert()){
qp.v.x = vq.q14;
qp.v.y = vq.q24;
qp.v.z = vq.q34;
qp.error = vq.QEM(qp.v);
}else{
//vq is not invertable so select v dash as lowest error
//from the mid point and endpoints
v.x = (q[qp.v1].v.x + q[qp.v2].v.x)/2.0;
v.y = (q[qp.v1].v.y + q[qp.v2].v.y)/2.0;
v.z = (q[qp.v1].v.z + q[qp.v2].v.z)/2.0;
Search Nedrilad ::




Custom Search