mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-24 21:09:57 +01:00
Fix zero division
This commit is contained in:
parent
f7a8cc8f63
commit
8aa3bbe29e
1 changed files with 4 additions and 2 deletions
6
s3l.h
6
s3l.h
|
@ -1355,8 +1355,10 @@ void S3L_makeCameraMatrix(S3L_Transform3D cameraTransform, S3L_Mat4 *m)
|
||||||
static inline void S3L_perspectiveDivide(S3L_Vec4 *vector,
|
static inline void S3L_perspectiveDivide(S3L_Vec4 *vector,
|
||||||
S3L_Unit focalLength)
|
S3L_Unit focalLength)
|
||||||
{
|
{
|
||||||
vector->x = (vector->x * focalLength) / vector->z;
|
S3L_Unit divisor = S3L_nonZero(vector->z);
|
||||||
vector->y = (vector->y * focalLength) / vector->z;
|
|
||||||
|
vector->x = (vector->x * focalLength) / divisor;
|
||||||
|
vector->y = (vector->y * focalLength) / divisor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void S3L_drawModelIndexed(
|
void S3L_drawModelIndexed(
|
||||||
|
|
Loading…
Reference in a new issue