Collision Trees algorithms - Binary Tree Quad Tree

What collision tree structure (Quad Tree, Binary Tree) does Cocos2d-x use , if any ?

Also what tree would you advise if I were doing my own kind of collision testing. What classes are available for these types of things ?

Thanks

Do you mean you are writing your own physics engine? Or you are not using a physics engine and are going to write your own collision logic?

I’m not entirely sure as of yet.

I am building my 4th year project solo.

I am trying to contribute to the Cocos Community.

My focus is providing strategy game classes/functions and framework.

I want to create a object layer where everything avoids one another, avoids collisions. I will use Box2D, in case collisions happen anyways (And they will, and should).

I will build a World class, then World Layer class(Air, Ground, HUD), which has Groups/Flocks of Game Objects. We can send flocks/groups around in various formations such as line, square, circle, flock(like Birds). When flocks collider or pass through each other ill have to make some ninja code. Image two formations of horses going through each other(Complex I think, Ill figure out(Use Box2D also, but idea is not to reply on box2D but have them all dynamically avoid each other in clever way))…

I feel ill need narrow other checking at some stage as not to be checking every object against every object( Log N * N).

If I used a Quad Tree or Binary tree I can reduce checking I am thinking, so I am wondering what may be good approach, what functions or classes can help me ?

Thanks Jedi Slack

1 Like

For a start figuring out flocking, look into “boids”.

As you are using Box2D for collision detection, collision response, and dynamics, why not try and use it’s broadphase data or callbacks for your proximity checks? (I suspect avoidance can be thought of as a larger collision shape and custom collision response)

I suspect it’s a pretty good start, and if you latter feel you need to try writing an alternative you’ll have more familiarity with the engine and perhaps might try and get it to your your custom broadphase implementation rather than duplicate work with it’s own spatial structure.

If you have a really high number of entities, and feel like it, perhaps also dig into Google’s LiquidFun code base?

1 Like

Thanks very much man for the advice. I will take it on board fully

One of my assignment study options is flocking algorithm, apart from its critical to my project anyways. Ill do exactly this as you said, get flocking working well, research boids and get a working implementation. From there ill start to tweet it to make different formations

I think using Box2D will be a smart move as its awesome library. I may just rest my work over this library

Does Liquid fun provide some clever algorithm , better than Box2D broad phase ?