detect-collisions icon indicating copy to clipboard operation
detect-collisions copied to clipboard

have you noticed its much faster to clear and rebuild the tree every tick?

Open manidkdontmatter opened this issue 7 months ago • 3 comments

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?

manidkdontmatter avatar May 29 '25 23:05 manidkdontmatter

I will double check, add benchmark for this + test, and then reply

thank you! @Gabriel-xyz

nenjack avatar Jun 04 '25 14:06 nenjack

if you're right this will be an awesome feature

nenjack avatar Jun 04 '25 14:06 nenjack

if you're right this will be an awesome feature

i don't know for sure but good luck

manidkdontmatter avatar Jun 06 '25 19:06 manidkdontmatter

@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

nenjack avatar Jul 27 '25 19:07 nenjack