Fix floating point syntax (#91)

* plane.c fix floating point syntax

* Update quaternion.c

* Update matrix.c

* Update collision_scene.c
This commit is contained in:
Haydn Trigg 2024-10-31 11:44:48 +10:30 committed by GitHub
parent 11a81e100f
commit d16bf1ac01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 10 deletions

View File

@ -36,7 +36,7 @@ float matrixNormalizedZValue(float depth, float near, float far) {
return 1.0f;
}
return (far * (depth + near) + 2.0 * far * near) / (depth * (far - near));
return (far * (depth + near) + 2.0f * far * near) / (depth * (far - near));
}
void matrixVec3Mul(float matrix[4][4], struct Vector3* input, struct Vector4* output) {

View File

@ -65,7 +65,7 @@ void calculateBarycentricCoords(struct Vector3* a, struct Vector3* b, struct Vec
if (d00 > d11) {
// b is other point
output->y = calculateLerp(a, b, point);
output->x = 1.0 - output->y;
output->x = 1.0f - output->y;
output->z = 0.0f;
} else {

View File

@ -210,31 +210,31 @@ void quatLook(struct Vector3* lookDir, struct Vector3* up, struct Quaternion* ou
if (trace > 0) {
float sqrtResult = sqrtf(trace+1.0f) * 2.0f;
float invSqrtResult = 1.0f / sqrtResult;
out->w = 0.25 * sqrtResult;
out->w = 0.25f * sqrtResult;
out->x = (yDir.z - zDir.y) * invSqrtResult;
out->y = (zDir.x - xDir.z) * invSqrtResult;
out->z = (xDir.y - yDir.x) * invSqrtResult;
} else if ((xDir.x > yDir.y) && (xDir.x > zDir.z)) {
float sqrtResult = sqrtf(1.0 + xDir.x - yDir.y - zDir.z) * 2.0f;
float sqrtResult = sqrtf(1.0f + xDir.x - yDir.y - zDir.z) * 2.0f;
float invSqrtResult = 1.0f / sqrtResult;
out->w = (yDir.z - zDir.y) * invSqrtResult;
out->x = 0.25 * sqrtResult;
out->x = 0.25f * sqrtResult;
out->y = (yDir.x + xDir.y) * invSqrtResult;
out->z = (zDir.x + xDir.z) * invSqrtResult;
} else if (yDir.y > zDir.z) {
float sqrtResult = sqrtf(1.0 + yDir.y - xDir.x - zDir.z) * 2.0f;
float sqrtResult = sqrtf(1.0f + yDir.y - xDir.x - zDir.z) * 2.0f;
float invSqrtResult = 1.0f / sqrtResult;
out->w = (zDir.x - xDir.z) * invSqrtResult;
out->x = (yDir.x + xDir.y) * invSqrtResult;
out->y = 0.25 * sqrtResult;
out->y = 0.25f * sqrtResult;
out->z = (zDir.y + yDir.z) * invSqrtResult;
} else {
float sqrtResult = sqrtf(1.0 + zDir.z - xDir.x - yDir.y) * 2.0f;
float sqrtResult = sqrtf(1.0f + zDir.z - xDir.x - yDir.y) * 2.0f;
float invSqrtResult = 1.0f / sqrtResult;
out->w = (xDir.y - yDir.x) * invSqrtResult;
out->x = (zDir.x + xDir.z) * invSqrtResult;
out->y = (zDir.y + yDir.z) * invSqrtResult;
out->z = 0.25 * sqrtResult;
out->z = 0.25f * sqrtResult;
}
}

View File

@ -286,7 +286,7 @@ void collisionScenePushObjectsOutOfPortal(int portalIndex) {
}
// Add a little extra to push it beyond the edge
depth += 0.5 * signf(depth);
depth += 0.5f * signf(depth);
vector3AddScaled(&object->body->transform.position, &reversePortalNormal, depth, &object->body->transform.position);
}