Skip to content

Commit

Permalink
bugfix: integers used in vector operations causing errors, now fixed,…
Browse files Browse the repository at this point in the history
… set to float32
  • Loading branch information
eliasnijs committed May 25, 2024
1 parent c6f3aca commit 1cd8e46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/boids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ update_boid(BoidsApplication *app, Boid *b) {
b->vel.x = Clamp(-p->max_vel, b->vel.x, p->max_vel);
b->vel.y = Clamp(-p->max_vel, b->vel.y, p->max_vel);


b->pos = vec2_add(b->pos, b->vel);

if (b->pos.x < 0) {
Expand All @@ -125,6 +126,7 @@ update_boid(BoidsApplication *app, Boid *b) {
} else if (b->pos.y > window_height) {
b->vel.y = -Abs(b->vel.y);
}

}

internal void
Expand Down
4 changes: 2 additions & 2 deletions src/math/vectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ vec2_sub(vec2 a, vec2 b) {
}

internal vec2
vec2_div(vec2 a, int s) {
vec2_div(vec2 a, float32 s) {
return (vec2){ a.x / s, a.y / s };
}

internal vec2
vec2_mul(vec2 a, int s) {
vec2_mul(vec2 a, float32 s) {
return (vec2){ a.x * s, a.y * s };
}

Expand Down

0 comments on commit 1cd8e46

Please sign in to comment.