summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-11-02 21:39:49 -0400
committerSam Anthony <sam@samanthony.xyz>2024-11-02 21:39:49 -0400
commitb5c25416bc7df0e3134731d3337409e2447467d2 (patch)
tree69286b2460bd90d925201b7cbc3c0572ada9af8c
parentd08483a437bc44ddc7b65b140c9f173815e13a0f (diff)
downloadballs-b5c25416bc7df0e3134731d3337409e2447467d2.zip
correct units of measurement in move() kernel
-rw-r--r--balls.c2
-rw-r--r--balls.cl6
2 files changed, 4 insertions, 4 deletions
diff --git a/balls.c b/balls.c
index c66a362..dab8961 100644
--- a/balls.c
+++ b/balls.c
@@ -26,7 +26,7 @@
#define RMIN 0.05 /* Minimum radius. */
#define RMAX 0.10 /* Maximum radius. */
-#define VMAX_INIT 0.05 /* Maximum initial velocity. */
+#define VMAX_INIT 1.5 /* Maximum initial velocity. */
enum {
WIDTH = 640,
diff --git a/balls.cl b/balls.cl
index 3ca7de7..47bd7aa 100644
--- a/balls.cl
+++ b/balls.cl
@@ -1,6 +1,6 @@
#include "config.h"
-#define G (9.81f / FPS / FPS)
+#define G 9.81f
#define DENSITY 1500.0f
int isCollision(float2 p1, float r1, float2 p2, float r2);
@@ -17,8 +17,8 @@ move(__global float2 *positions, __global float2 *velocities) {
size_t id;
id = get_global_id(0);
- velocities[id].y -= G;
- positions[id] += velocities[id];
+ velocities[id].y -= G / FPS;
+ positions[id] += velocities[id] / FPS;
}
__kernel void