Following on from my previous post here: http://forum.dyn4j.org/viewtopic.php?f=1&t=186, I am posting the completed version of my raycast test program. This casts 10000 rays in a World with 100 objects, which should be comparable with the box2d stress test with 10000 rays posted on youtube here: https://youtu.be/C-ScURIRTGA. The box2d stress tests has approximately 100 objects on screen from what I can see.
My version has mixed results depending on where on the screen the ray source is positioned. Given that the rays have a finite length I'm guessing that this has to do with how many objects are in range, but I'm not sure if that's correct. It's just a guess! Anyway, at worst the dyn4j is achieving 0.0101 ms per raycast and at best it is achieving 0.0022 ms per raycast (note that my version calculates the average time per raycast for each loop and also the average time per raycast over a rolling 5 second period to introduce some more stability into the calculation.) This is in comparison to the box2d video, which shows raycast times of between 0.003 and 0.004 ms per raycast. This suggests that dyn4 isn't performing as well as box2d, but I'm happy to accept that that might be down to my code rather than dynj!
I have attached the source code for the completed application. This uses dyn4j 3.1.11 and Slick2D build 237 with lwjgl 2.9.0 (dated 3 June 2013). Thanks to both William and zoom for suggestions and help to get this working correctly. I have also included a couple of screen shots of the best and worst cases below.
The first one (titled "Worst performance") shows the ray source in the top-left corner of the screen interacting with a large number of bodies.
The second (titled "Best performance") shows the ray source in the bottom right corner of the screen where there is relatively little to interact with).
Posts that don't fit into other categories.
1 post • Page 1 of 1
- Source code for dyn4j raycast stress test
- (48.37 KiB) Downloaded 146 times
Who is online
Users browsing this forum: No registered users and 1 guest