diff --git a/Ray2f.c b/Ray2f.c index a731c95..1edc295 100644 --- a/Ray2f.c +++ b/Ray2f.c @@ -53,7 +53,7 @@ int CgeRay2fIntersectRay(const float aStart[2], const float aDirection[2], float tmp[2]; float time1, time2; - if (CgeRay2fIntersectTime(aStart, aDirection, bStart, bDirection, &time1, &time2)) + if (!CgeRay2fIntersectTime(aStart, aDirection, bStart, bDirection, &time1, &time2)) return 0; if (time1 < 0.0f || time2 < 0.0f) @@ -72,7 +72,7 @@ int CgeRay2fIntersectSegment(const float aStart[2], const float aDirection[2], float time1, time2; CgeVec2fSub(bEnd, bStart, tmp); - if (CgeRay2fIntersectTime(aStart, aDirection, bStart, tmp, &time1, &time2)) + if (!CgeRay2fIntersectTime(aStart, aDirection, bStart, tmp, &time1, &time2)) return 0; if (time1 < 0.0f || time2 < 0.0f || time2 > 1.0f) @@ -113,7 +113,7 @@ int CgeSegment2fIntersectSegment(const float aStart[2], const float aEnd[2], CgeVec2fSub(aEnd, aStart, tmp1); CgeVec2fSub(bEnd, bStart, tmp2); - if (CgeRay2fIntersectTime(aStart, tmp1, bStart, tmp2, &time1, &time2)) + if (!CgeRay2fIntersectTime(aStart, tmp1, bStart, tmp2, &time1, &time2)) return 0; if (time1 < 0.0f || time1 > 1.0f || time2 < 0.0f || time2 > 1.0f) @@ -135,7 +135,7 @@ int CgeRay2fIntersectBox2f(const float aStart[2], const float aDirection[2], timeFar = 1.0f / 0.0f; /* Check if origin inside box */ - if (!CgeBox2fContains(bMin, bMax, aStart)) { + if (CgeBox2fContains(bMin, bMax, aStart)) { memcpy(out, aStart, sizeof(float) * 2); *t = 0.0f; return 1; @@ -182,7 +182,7 @@ int CgeSegment2fIntersectBox2f(const float aStart[2], const float aEnd[2], float time; CgeVec2fSub(aEnd, aStart, tmp); - if (CgeRay2fIntersectBox2f(aStart, tmp, bMin, bMax, &time, out)) + if (!CgeRay2fIntersectBox2f(aStart, tmp, bMin, bMax, &time, out)) return 0; if (time > 1.0f) diff --git a/Ray3f.c b/Ray3f.c index c683569..2279a43 100644 --- a/Ray3f.c +++ b/Ray3f.c @@ -33,11 +33,11 @@ int CgeRay3fIntersectTriangle(const float start[3], const float direction[3], float time; /* Compute plane */ - if (CgePlaneFromPoints(a, b, c, plane)) + if (!CgePlaneFromPoints(a, b, c, plane)) return 0; /* Compute intersection point in ray against plane */ - if (CgeRay3fIntersectPlane(start, direction, plane, &time, tmp3)) + if (!CgeRay3fIntersectPlane(start, direction, plane, &time, tmp3)) return 0; /* Check if point inside rectangle */ @@ -94,11 +94,11 @@ int CgeSegment3fIntersectTriangle(const float start[3], const float end[3], float time; /* Compute plane */ - if (CgePlaneFromPoints(a, b, c, plane)) + if (!CgePlaneFromPoints(a, b, c, plane)) return 0; /* Compute intersection point in ray against plane */ - if (CgeSegment3fIntersectPlane(start, end, plane, &time, tmp3)) + if (!CgeSegment3fIntersectPlane(start, end, plane, &time, tmp3)) return 0; /* Check if point inside rectangle */ @@ -136,7 +136,7 @@ int CgeRay3fIntersectBox3f(const float aStart[3], const float aDirection[3], timeFar = 1.0f / 0.0f; /* Check if origin inside box */ - if (!CgeBox3fContains(bMin, bMax, aStart)) { + if (CgeBox3fContains(bMin, bMax, aStart)) { memcpy(out, aStart, sizeof(float) * 3); *t = 0.0f; return 1; @@ -184,7 +184,7 @@ int CgeSegment3fIntersectBox3f(const float aStart[3], const float aEnd[3], float time; CgeVec3fSub(aEnd, aStart, tmp); - if (CgeRay3fIntersectBox3f(aStart, tmp, bMin, bMax, &time, out)) + if (!CgeRay3fIntersectBox3f(aStart, tmp, bMin, bMax, &time, out)) return 0; if (time > 1.0f)