1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-11-21 20:39:57 +01:00

Fix zero division

This commit is contained in:
Miloslav Číž 2019-05-12 15:07:18 +02:00
parent f7a8cc8f63
commit 8aa3bbe29e

6
s3l.h
View file

@ -1355,8 +1355,10 @@ void S3L_makeCameraMatrix(S3L_Transform3D cameraTransform, S3L_Mat4 *m)
static inline void S3L_perspectiveDivide(S3L_Vec4 *vector,
S3L_Unit focalLength)
{
vector->x = (vector->x * focalLength) / vector->z;
vector->y = (vector->y * focalLength) / vector->z;
S3L_Unit divisor = S3L_nonZero(vector->z);
vector->x = (vector->x * focalLength) / divisor;
vector->y = (vector->y * focalLength) / divisor;
}
void S3L_drawModelIndexed(