summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-10-09 10:58:15 -0400
committerSam Anthony <sam@samanthony.xyz>2024-10-09 10:58:15 -0400
commita4deaae971f6e0869668561f251dd29ae23da189 (patch)
tree97e97fdce2b2ba9073f254fa6324c85b66474379
parentcb8489f4fc1f30a5eff65c0d66478689395811b9 (diff)
downloadballs-a4deaae971f6e0869668561f251dd29ae23da189.zip
parallelize ball-wall collisions
-rw-r--r--balls.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/balls.cpp b/balls.cpp
index dfcf8d8..b98b322 100644
--- a/balls.cpp
+++ b/balls.cpp
@@ -210,9 +210,9 @@ animate(int v) {
});
}
- /* TODO: parallel */
- for (Ball *ball : balls)
- collideWall(ball, bounds);
+ parallel_for(size_t(0), balls.size(), [] (size_t i) {
+ collideWall(balls[i], bounds);
+ });
display();
glutTimerFunc(FRAME_TIME_MS, animate, 0);