detect-collisions
detect-collisions copied to clipboard
have you noticed its much faster to clear and rebuild the tree every tick?
kinda weird no? it's 2.5x faster. example:
// 44 fps
for (let i = 0; i < 2000; i++) {
var o = dynamicObjects[Math.floor(Math.random() * dynamicObjects.length)]
o.move(64 * dt, false)
}
system.update()
system.separate()
// 113 fps
system.clear() // if i could only clear and rebuild the dynamic branch of the rtree i bet this would be even faster. right now im having to clear the whole thing which means i have to load statics back in (see below) and dynamics instead of only dynamics
for (let i = 0; i < 2000; i++) {
var o = dynamicObjects[Math.floor(Math.random() * dynamicObjects.length)]
o.move(64 * dt, false)
}
system.load(staticObjects)
system.load(dynamicObjects)
system.separate()
would this influence your design decisions at all?
I will double check, add benchmark for this + test, and then reply
thank you! @Gabriel-xyz
if you're right this will be an awesome feature
if you're right this will be an awesome feature
i don't know for sure but good luck
@Gabriel-xyz I looked into it and it would work if
we didn't have scale, rotation, etc.
but it may be possible to base a
remove-all, add-all approach
with updated/upgraded/modified version of adding