Comments (2)
Hello! Thank you for using the library.
The collision space is restricted by a rectangle with width
and height
passed as arguments in the NewSpace
function.
subdivisionFactor
is the max depth of the underlying quadtree minus 1, so it's the max level of the node in the quadtree (levels are in the range of [0; subdivisionFactor]).
shapesInArea
is the max number of shapes a single quadtree node can take.
So initially there's a quadtree with only one root node which has level 0. When its shape count reaches the number of shapesInArea
, the next insertion will make the node split into 4 subnodes and redistribute all the shapes into them. These subnodes are all of level 1, because the parent was 0. If the limit of one of these subnodes is exceeded, it splits into 4 subnodes of level 2, and so on, that's how quadtrees work.
If the node reaches the level of subdivisionFactor
, it cannot split anymore and will accept shapes regardless of its shape count and shapesInArea
limit.
So what does this mean for the user of the library? Well, he should pick the values that will be efficient for his current situation. You can take a look at the examples
folder with some demos with prepared values for subdivisionFactor
and shapesInArea
.
And please be careful, the work on the project is still in progress, the API might change anytime, and I still haven't yet fixed the normals for rectangle-rectangle
and rectangle-line
cases.
from cirno.
No worries. I am just playing with it and creating simple game for learning purposes only.
Thanks! I think I have to dive deep into quadtree to understand it better.
from cirno.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cirno.