Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Quadtree-like structure for dynamic / moving Game Objects  (Read 2687 times)
0 Members and 1 Guest are viewing this topic.
Offline matheus23

JGO Wizard


Medals: 72
Projects: 3


You think about my Avatar right now!


« Reply #30 - Posted 2012-11-23 15:42:41 »

Yes, you have a grid, but not a grid-like datastructure. Remember that a HashMap is 'just' an array of linkedlists. And everybody knows linkedlists are a bad fit for, well, everything.

But since almost every Vec2i gives me different Hashcodes, I won't have hash collisions, which means I don't need to fill those linkedlists more than one or two objects.

After some little time the HashMap has built up it's size, and then it's not even necessary to delete or put in entries, so I guess it's not too bad.

And I diagree that LinkedLists are bad for everything Wink It's true that they're bad for storing entities (they're really bad there), but they're not bad for everything.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline krasse
« Reply #31 - Posted 2012-11-23 15:51:36 »


It's a grid... actually...
but how exactly would I go about making the grid aware of fast objects to avid tunneling?

Small and fast objects like bullets that travel far every tick can be assumed to travel along a line that is used for the collision testing. So basically you just create the line from the previous tick to the current and check against your grid/accelerator. For large and fast objects you probably need to do something more fancy like sweep areas... brrrr

Offline Roquen

JGO Ninja


Medals: 66



« Reply #32 - Posted 2012-11-23 16:33:16 »

And everybody knows linkedlists are a bad fit for, well, everything.
I...err..nevermind.

Roquen wanders off humming about traffic jams
Games published by our own members! Check 'em out!
Try the Free Demo of Titan Attacks
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 438
Projects: 4


Hand over your head.


« Reply #33 - Posted 2012-11-23 16:33:51 »

But since almost every Vec2i gives me different Hashcodes, I won't have hash collisions
That is not how hash maps work. Different hashcodes will cause hash collisions, unless your backing array has 4.2 billion entries.


And I diagree that LinkedLists are bad for everything
They are bad for everything. But let's not go there, as other threads have done so before.


Why don't you just use a List[w][h] ? It's so much better in every possible way. But it seems you have made up your mind, too bad, as the disadvantages have been explained already in this thread, and you just said 'no'. Oh well, in the end, it's about what works, not how it's done. So good luck with your game - if there's one in the making.



And as for tunneling / swept shapes: it's normally good enough to make your entities queries so fast, that you can simply iterate the movement of the shape within a single game tick. In games you don't need perfect solutions, so just moving a bullet with 100 positional updates (and querying for collisions) per tick will simply be enough. Another approach is to query series of overlapping bounding rectangles / circles along the movement vector and do a broad scan of potential colliders.

Nobody in their right minds will simulate more than 1 high speed colliding object, so don't even bother solving that problem. Complexity increases so rapidly that you can just as well write a scientific simulator, and ditch any plans for your game.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Offline delt0r

JGO Coder


Medals: 18


Computers can do that?


« Reply #34 - Posted 2012-11-25 15:36:14 »

The grid vers Quad tree performance depends on some details. If "things" are similar sizes and you have fairly well bounded space so that you don't need too many grid cells, grids are pretty fast. Since these 2 things are typically true in games then the generalization that grids are faster easier than quad trees is not a bad approximation.

However with very large spaces, with very uneven distribution of "things" and/or things have quite a  wide range of sizes. Then quad trees are faster and have smaller memory footprints.

I have no special talents. I am only passionately curious.--Albert Einstein
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 438
Projects: 4


Hand over your head.


« Reply #35 - Posted 2012-11-25 17:01:27 »

Quadtrees are also faster for frustum culling.

Just don't insert/update/remove items through the quadtree.
Just query them, and for large, odd shapes only.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Pages: 1 [2]
  ignore  |  Print  
 
 

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (76 views)
2013-05-17 21:29:12

alaslipknot (87 views)
2013-05-16 21:24:48

gouessej (117 views)
2013-05-16 00:53:38

gouessej (112 views)
2013-05-16 00:17:58

theagentd (122 views)
2013-05-15 15:01:13

theagentd (112 views)
2013-05-15 15:00:54

StreetDoggy (156 views)
2013-05-14 15:56:26

kutucuk (178 views)
2013-05-12 17:10:36

kutucuk (177 views)
2013-05-12 15:36:09

UnluckyDevil (185 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.109 seconds with 21 queries.