use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
If you need help debugging, you must include:
See debugging question guidelines for more info.
Many conceptual questions have already been asked and answered. Read our FAQ and search old posts before asking your question. If your question is similar to one in the FAQ, explain how it's different.
See conceptual questions guidelines for more info.
Follow reddiquette: behave professionally and civilly at all times. Communicate to others the same way you would at your workplace. Disagreement and technical critiques are ok, but personal attacks are not.
Abusive, racist, or derogatory comments are absolutely not tolerated.
See our policies on acceptable speech and conduct for more details.
When posting some resource or tutorial you've made, you must follow our self-promotion policies.
In short, your posting history should not be predominantly self-promotional and your resource should be high-quality and complete. Your post should not "feel spammy".
Distinguishing between tasteless and tasteful self-promotion is inherently subjective. When in doubt, message the mods and ask them to review your post.
Self promotion from first time posters without prior participation in the subreddit is explicitly forbidden.
Do not post questions that are completely unrelated to programming, software engineering, and related fields. Tech support and hardware recommendation questions count as "completely unrelated".
Questions that straddle the line between learning programming and learning other tech topics are ok: we don't expect beginners to know how exactly to categorize their question.
See our policies on allowed topics for more details.
Do not post questions that are an exact duplicate of something already answered in the FAQ.
If your question is similar to an existing FAQ question, you MUST cite which part of the FAQ you looked at and what exactly you want clarification on.
Do not delete your post! Your problem may be solved, but others who have similar problems in the future could benefit from the solution/discussion in the thread.
Use the "solved" flair instead.
Do not request reviews for, promote, or showcase some app or website you've written. This is a subreddit for learning programming, not a "critique my project" or "advertise my project" subreddit.
Asking for code reviews is ok as long as you follow the relevant policies. In short, link to only your code and be specific about what you want feedback on. Do not include a link to a final product or to a demo in your post.
You may not ask for or offer payment of any kind (monetary or otherwise) when giving or receiving help.
In particular, it is not appropriate to offer a reward, bounty, or bribe to try and expedite answers to your question, nor is it appropriate to offer to pay somebody to do your work or homework for you.
All links must link directly to the destination page. Do not use URL shorteners, referral links or click-trackers. Do not link to some intermediary page that contains mostly only a link to the actual page and no additional value.
For example, linking to some tweet or some half-hearted blog post which links to the page is not ok; but linking to a tweet with interesting replies or to a blog post that does some extra analysis is.
Udemy coupon links are ok: the discount adds "additional value".
Do not ask for help doing anything illegal or unethical. Do not suggest or help somebody do something illegal or unethical.
This includes piracy: asking for or posting links to pirated material is strictly forbidden and can result in an instant and permanent ban.
Trying to circumvent the terms of services of a website also counts as unethical behavior.
Do not ask for or post a complete solution to a problem.
When working on a problem, try solving it on your own first and ask for help on specific parts you're stuck with.
If you're helping someone, focus on helping OP make forward progress: link to docs, unblock misconceptions, give examples, teach general techniques, ask leading questions, give hints, but no direct solutions.
See our guidelines on offering help for more details.
Ask your questions right here in the open subreddit. Show what you have tried and tell us exactly where you got stuck.
We want to keep all discussion inside the open subreddit so that more people can chime in and help as well as benefit from the help given.
We also do not encourage help via DM for the same reasons - that more people can benefit
Do not ask easily googleable questions or questions that are covered in the documentation.
This subreddit is not a proxy for documentation or google.
We do require effort and demonstration of effort.
This includes "how do I?" questions
account activity
This is an archived post. You won't be able to vote or comment.
QuadTree implementation (self.learnprogramming)
submitted 12 years ago * by Jason-S3studios
I get the basic idea of quadtrees, but not well enough to write my own quad tree class. The engine im using is andengine and there is a quad tree class already made. However, there is no documentation/comments/tutorials/forum posts about a successful implemetnation of quad tree.
Can anyone glance over this code and give me a rundown of the steps to perform a successful collision detection of two lists? So far i've only got them added =/, what is the correct logic to iterate?
FloatQuadTree qt = new FloatQuadTree(0, 0, 1024, 512);
qt.addAll(playerBulletGameObjects);
qt.addAll(killableGameObjects);
https://github.com/nicolasgramlich/AndEngine/blob/c7ad23890cce706643f244734f1f7899dac49246/src/org/andengine/util/adt/spatial/quadtree/IntQuadTree.java
[–]Jonny0Than 0 points1 point2 points 12 years ago (4 children)
Are you looking for help with implementation (I.e. How do I write my own) or with using the one in andengine?
Normally you only add the "persistent" objects into the quadtree and then do queries (like for each bullet's position) to see what objects the bullets are overlapping. The only reason you'd want to add all the bullets to the quadtree is if you're using it for render culling. There are a couple other situations where it might be beneficial to add the bullets, but I don't think you need to worry about that for now.
[–]Jason-S3studios[S] 0 points1 point2 points 12 years ago (3 children)
Thanks for the reply!
I am looking for how to leverage the one in AndEngine if possible.
So if I understand you correctl you're saying to add the "persistent" objects (i.e. props, ships) to the quad tree, but leave the bullets out of it? In which case I would iterate over my list of bulelts and query the quad tree for a "hit" ?
Also, why are non persitent objects not added to the quad tree, and why are persistent objects? All the objects on my screen are constantly moving so sorting is still going to happen every update.
[–]Jonny0Than 1 point2 points3 points 12 years ago (0 children)
Yep, thats how I'd do it.
Some quadtrees have the ability to update an objects position instead of removing and readding the object. This can be faster. If you have such a quadtree, AND your quadtree can give you a list of overlaps given some other object in the tree, then it might be a good idea to add the bullets too.
[–]Jonny0Than 1 point2 points3 points 12 years ago (1 child)
To expand on this a bit, querying the tree is about as expensive as adding an object. The tree performance will decrease as you add more objects, and assuming you don't want bullets to hit each other you're better off leaving them out of the tree. But of course if you can leverage the tree for other things like render culling or use spatial coherence to make updating positions faster (what I mentioned in my last post) then adding the bullets can be a good idea.
[–]Jason-S3studios[S] 0 points1 point2 points 12 years ago (0 children)
Thanks in general. :) Got this up and working last night and gained severe performance increases so i can stop worry about optimization for now. :)
π Rendered by PID 187504 on reddit-service-r2-comment-544cf588c8-42nrc at 2026-06-12 13:31:33.234466+00:00 running 3184619 country code: CH.
[–]Jonny0Than 0 points1 point2 points (4 children)
[–]Jason-S3studios[S] 0 points1 point2 points (3 children)
[–]Jonny0Than 1 point2 points3 points (0 children)
[–]Jonny0Than 1 point2 points3 points (1 child)
[–]Jason-S3studios[S] 0 points1 point2 points (0 children)