Hi everyone. I find love2d really cool! I got interested in spatial indexing and decided to try my hand on quadtrees. I tried to base it on this link: http://www.kyleschouviller.com/wsuxna/q ... -included/
I've attached a demo showing what it looks like. You can left mouse click on a circle to retrieve it's collidable objects. The collidables are in green and the circle you clicked is in blue. Circle's that collide with each other turn red. Nodes with objects are also drawn. I think it's pretty cool.
Quadtree Spatial Indexing Demo
- dreadkillz
- Party member
- Posts: 223
- Joined: Sun Mar 04, 2012 2:04 pm
- Location: USA
Quadtree Spatial Indexing Demo
- Attachments
-
- quadtreeDemo.love
- (2.93 KiB) Downloaded 482 times
Re: Quadtree Spatial Indexing Demo
Neat. Out of curiosity, have you checked how fast memory grows with this? print the output of collectgarbage("count") to check this, though, remember that lua's strings grow memory usage as well so only check it like once a second so it doesn't make your memory usage explode out of control.
Re: Quadtree Spatial Indexing Demo
Clean and clear visualization. Well done. This would be a great addition to the wiki.
Re: Quadtree Spatial Indexing Demo
nice, I did something similar recently with spatial hashing but not quadtree:
Click to increase ball number, arrow keys up and down for grid density
Click to increase ball number, arrow keys up and down for grid density
- dreadkillz
- Party member
- Posts: 223
- Joined: Sun Mar 04, 2012 2:04 pm
- Location: USA
Re: Quadtree Spatial Indexing Demo
Very cool. My quadtree is not very optimized with large numbers of balls, but I just wanted to show it as a proof of concept in lua.kraftman wrote:nice, I did something similar recently with spatial hashing but not quadtree:
Click to increase ball number, arrow keys up and down for grid density
Re: Quadtree Spatial Indexing Demo
Thanks for the resources guys! I'm definitely going to try and add this to the game I'm working on right now!
Re: Quadtree Spatial Indexing Demo
I've always been interested in how well various quadtree methods and similar tricks would work within this engine. I've long dreamed of mkaing some sort of 2d space shooter with many ships flying around with shots and particles all over the place. I was never able to get framerates to acceptable levels during my stress tests.
This demo shows my FPS at 90ish
Attempting on LuaJIT build gives about 145.
I've worried about being able to keep 60fps with more drawings, particles effects, weapons, hitscans, etc.
Removed circle function, replaced with drawing an image instead:
Love 0.8: 6.7ish frame time = 150ish FPS
LuaJIT: 3.0ish frame time = 300ish FPS.
Sure shows LuaJit being quite a significant improvement. I can even do 1000 balls and get 40FPS with the JIT version. Still, I wonder how more "real world" tests would fare.
This demo shows my FPS at 90ish
Attempting on LuaJIT build gives about 145.
I've worried about being able to keep 60fps with more drawings, particles effects, weapons, hitscans, etc.
Removed circle function, replaced with drawing an image instead:
Love 0.8: 6.7ish frame time = 150ish FPS
LuaJIT: 3.0ish frame time = 300ish FPS.
Sure shows LuaJit being quite a significant improvement. I can even do 1000 balls and get 40FPS with the JIT version. Still, I wonder how more "real world" tests would fare.
- dreadkillz
- Party member
- Posts: 223
- Joined: Sun Mar 04, 2012 2:04 pm
- Location: USA
Re: Quadtree Spatial Indexing Demo
Well if its any consolation, the quadtree could be improved by a lot. The demo doesn't have the most efficient methods of moving objects in the tree or finding collidables. Basically, tree traversals optimization would help a lot. Compared to kraftman's grid, the quadtree is horribly slow at large numbers of balls.Lap wrote:I've always been interested in how well various quadtree methods and similar tricks would work within this engine. I've long dreamed of mkaing some sort of 2d space shooter with many ships flying around with shots and particles all over the place. I was never able to get framerates to acceptable levels during my stress tests.
This demo shows my FPS at 90ish
Attempting on LuaJIT build gives about 145.
I've worried about being able to keep 60fps with more drawings, particles effects, weapons, hitscans, etc.
Removed circle function, replaced with drawing an image instead:
Love 0.8: 6.7ish frame time = 150ish FPS
LuaJIT: 3.0ish frame time = 300ish FPS.
Sure shows LuaJit being quite a significant improvement. I can even do 1000 balls and get 40FPS with the JIT version. Still, I wonder how more "real world" tests would fare.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Quadtree Spatial Indexing Demo
I've seen luajit go 6x as fast as lua on particularly lua-heavy code (I think it was one of jasoco's 3d things) but also match the speed of lua on gpu-heavy code.
Re: Quadtree Spatial Indexing Demo
any lua codepath that happens to call a love c api function will never get compiled, so it's not too surprising that gpu-heavy code doesn't benefit (either because the gpu is the bottleneck or you're hammering love.graphics functions)bartbes wrote:I've seen luajit go 6x as fast as lua on particularly lua-heavy code (I think it was one of jasoco's 3d things) but also match the speed of lua on gpu-heavy code.
technically a proper luajit version of love would use the ffi for everything (or implement as much in lua as possible)
Who is online
Users browsing this forum: Google [Bot] and 3 guests