mirror of
https://github.com/projectPiki/pikmin2.git
synced 2024-11-27 15:20:37 +00:00
Triangle::intersect Match
This commit is contained in:
parent
b15bd6554c
commit
53e18f3fbc
@ -809,7 +809,7 @@ bool Triangle::intersect(Edge& edge, f32 cutoff, Vector3f& intersectionPoint)
|
|||||||
f32 scalarProj = triPlaneNormal.dot(edgeVec);
|
f32 scalarProj = triPlaneNormal.dot(edgeVec);
|
||||||
|
|
||||||
// if edge has no length, cannot intersect
|
// if edge has no length, cannot intersect
|
||||||
if (0.0f == edgeLen) {
|
if (edgeLen == 0.0f) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,13 +823,12 @@ bool Triangle::intersect(Edge& edge, f32 cutoff, Vector3f& intersectionPoint)
|
|||||||
// check each edge plane of triangle
|
// check each edge plane of triangle
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
// project normal onto edge
|
// project normal onto edge
|
||||||
Vector3f edgePlaneNormal(mEdgePlanes[i].mNormal);
|
f32 edgePlaneProj = mEdgePlanes[i].mNormal.dot(edgeVec);
|
||||||
f32 edgePlaneProj = edgePlaneNormal.dot(edgeVec);
|
|
||||||
|
|
||||||
// check that projection isn't vanishingly small
|
// check that projection isn't vanishingly small
|
||||||
if (FABS(edgePlaneProj) > 0.01f) {
|
if (FABS(edgePlaneProj) > 0.01f) {
|
||||||
// check we have an intersection point
|
// check we have an intersection point
|
||||||
f32 edgePlaneRatio = (mEdgePlanes[i].mOffset - edgePlaneNormal.dot(edge.mStartPos)) / edgePlaneProj;
|
f32 edgePlaneRatio = (mEdgePlanes[i].mOffset - mEdgePlanes[i].mNormal.dot(edge.mStartPos)) / edgePlaneProj;
|
||||||
if ((edgePlaneRatio > -ratio) && (edgePlaneRatio < (1 + ratio))) {
|
if ((edgePlaneRatio > -ratio) && (edgePlaneRatio < (1 + ratio))) {
|
||||||
// get intersection point
|
// get intersection point
|
||||||
Vector3f projVec = edgeVec * edgePlaneRatio;
|
Vector3f projVec = edgeVec * edgePlaneRatio;
|
||||||
|
Loading…
Reference in New Issue
Block a user