Remove comments from ray files
All checks were successful
CI / build-and-analyze (push) Successful in 38s

This commit is contained in:
2026-07-04 09:16:23 +03:00
parent 3dd61dbbf2
commit ba1ef9a88e
2 changed files with 0 additions and 25 deletions

10
Ray2f.c
View File

@@ -1,5 +1,4 @@
#include "CgeMath.h"
#include <string.h>
#include <math.h>
#define EPSILON 0.00001f
@@ -10,15 +9,12 @@ int CgeRay2fIntersectLine(const float start[2], const float direction[2],
float tmp1[2];
float denom, time;
/* Calculate intersection time */
denom = CgeVec2fDot(direction, line);
time = (line[2] - CgeVec2fDot(line, start)) / denom;
/* Check for ray/plane parallel to each other or point is behing the ray. */
if (fabsf(denom) < EPSILON || time < 0.0f)
return 0;
/* Compute intersection point */
CgeVec2fScale(direction, time, tmp1);
CgeVec2fAdd(start, tmp1, out);
*t = time;
@@ -31,7 +27,6 @@ int CgeRay2fIntersectTime(const float aStart[2], const float aDirection[2],
float tmp1[2], tmp2[2], tmp3[2];
float denom;
/* Rotate directions by 90 degrees and caluclate denom */
tmp1[0] = -aDirection[1]; tmp1[1] = aDirection[0];
tmp2[0] = -bDirection[1]; tmp2[1] = bDirection[0];
denom = CgeVec2fDot(tmp1, bDirection);
@@ -39,7 +34,6 @@ int CgeRay2fIntersectTime(const float aStart[2], const float aDirection[2],
if (fabsf(denom) < EPSILON)
return 0;
/* Calculate segments offset and intersection times */
CgeVec2fSub(aStart, bStart, tmp3);
*time1 = CgeVec2fDot(tmp3, tmp2) / denom;
*time2 = CgeVec2fDot(tmp3, tmp1) / denom;
@@ -89,16 +83,13 @@ int CgeSegment2fIntersectLine(const float start[2], const float end[2],
float tmp[2];
float denom, time;
/* Calculate intersection time */
CgeVec2fSub(end, start, tmp);
denom = CgeVec2fDot(tmp, line);
time = (line[2] - CgeVec2fDot(line, start)) / denom;
/* Check for ray/plane parallel to each other or point is behing the ray. */
if (fabsf(denom) < EPSILON || time < 0.0f || time > 1.0f)
return 0;
/* Compute intersection point */
CgeVec2fScale(tmp, time, tmp);
CgeVec2fAdd(start, tmp, out);
*t = time;
@@ -134,7 +125,6 @@ int CgeRay2fIntersectBox2f(const float aStart[2], const float aDirection[2],
timeNear = -1.0f / 0.0f;
timeFar = 1.0f / 0.0f;
/* Check each axis for the minimal and maximum intersection time */
for (i = 0; i < 2; i++) {
if (fabsf(aDirection[i]) < EPSILON) {
if (aStart[i] < bMin[i] || aStart[i] > bMax[i])

15
Ray3f.c
View File

@@ -10,15 +10,12 @@ int CgeRay3fIntersectPlane(const float start[3], const float direction[3],
float tmp1[3];
float denom, time;
/* Calculate intersection time */
denom = CgeVec3fDot(direction, plane);
time = (plane[3] - CgeVec3fDot(plane, start)) / denom;
/* Check for ray/plane parallel to each other or point is behing the ray. */
if (fabsf(denom) < EPSILON || time < 0.0f)
return 0;
/* Compute intersection point */
CgeVec3fScale(direction, time, tmp1);
CgeVec3fAdd(start, tmp1, out);
*t = time;
@@ -32,15 +29,12 @@ int CgeRay3fIntersectTriangle(const float start[3], const float direction[3],
float tmp1[3], tmp2[3], tmp3[3];
float time;
/* Compute plane */
if (!CgePlaneFromPoints(a, b, c, plane))
return 0;
/* Compute intersection point in ray against plane */
if (!CgeRay3fIntersectPlane(start, direction, plane, &time, tmp3))
return 0;
/* Check if point inside rectangle */
CgeVec3fSub(b, a, tmp1);
CgeVec3fSub(tmp3, a, tmp2);
CgeVec3fCross(tmp2, tmp1, tmp1);
@@ -59,7 +53,6 @@ int CgeRay3fIntersectTriangle(const float start[3], const float direction[3],
if (CgeVec3fDot(tmp1, plane) < 0.0f)
return 0;
/* Copy intersection point */
memcpy(out, tmp3, sizeof(tmp3));
*t = time;
return 1;
@@ -70,16 +63,13 @@ int CgeSegment3fIntersectPlane(const float start[3], const float end[3],
float tmp[3];
float denom, time;
/* Calculate intersection time */
CgeVec3fSub(end, start, tmp);
denom = CgeVec3fDot(tmp, plane);
time = (plane[3] - CgeVec3fDot(plane, start)) / denom;
/* Check for ray/plane parallel to each other or point is behing the ray. */
if (fabsf(denom) < EPSILON || time < 0.0f || time > 1.0f)
return 0;
/* Compute intersection point */
CgeVec3fScale(tmp, time, tmp);
CgeVec3fAdd(start, tmp, out);
*t = time;
@@ -93,15 +83,12 @@ int CgeSegment3fIntersectTriangle(const float start[3], const float end[3],
float tmp1[3], tmp2[3], tmp3[3];
float time;
/* Compute plane */
if (!CgePlaneFromPoints(a, b, c, plane))
return 0;
/* Compute intersection point in ray against plane */
if (!CgeSegment3fIntersectPlane(start, end, plane, &time, tmp3))
return 0;
/* Check if point inside rectangle */
CgeVec3fSub(b, a, tmp1);
CgeVec3fSub(tmp3, a, tmp2);
CgeVec3fCross(tmp2, tmp1, tmp1);
@@ -120,7 +107,6 @@ int CgeSegment3fIntersectTriangle(const float start[3], const float end[3],
if (CgeVec3fDot(tmp1, plane) < 0.0f)
return 0;
/* Copy intersection point */
memcpy(out, tmp3, sizeof(tmp3));
*t = time;
return 1;
@@ -135,7 +121,6 @@ int CgeRay3fIntersectBox3f(const float aStart[3], const float aDirection[3],
timeNear = -1.0f / 0.0f;
timeFar = 1.0f / 0.0f;
/* Check each axis for the minimal and maximum intersection time */
for (i = 0; i < 3; i++) {
if (fabsf(aDirection[i]) < EPSILON) {
if (aStart[i] < bMin[i] || aStart[i] > bMax[i])