Skip to content

Commit

Permalink
y axis inversion fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgates747 committed Aug 29, 2024
1 parent 017a91b commit 2ad7b10
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions video/pingo/render/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ int rendererSetCamera(Renderer * r, Vec4i rect) {
// SCRATCHPIXEL FUNCTIONS
static inline void persp_divide(struct Vec3f* p) {
if (p->z > -Z_THRESHOLD) {
p->z = -Z_THRESHOLD; // Prevent division by zero
p->z = -Z_THRESHOLD;
}
float inv_z = 1.0f / p->z; // Use the z value directly without flipping sign
p->x *= inv_z; // Normalize x by z
p->y *= inv_z; // Normalize y by z
float inv_z = -1.0f / p->z;
p->x *= inv_z;
p->y *= inv_z;
}

static inline void to_raster(const Vec2i size, struct Vec3f* const p) {
Expand Down

0 comments on commit 2ad7b10

Please sign in to comment.