Voxel scene with 1000 cubes. 30fps

Hi!

A little while back I was easing back into programming with making a voxel engine. It worked, but all the physics impostors really hit the fps hard. I tried a method where EVERY mesh in the scene was checked to see if was near the player, then added a physics impostor if so. That also hit the fps hard. My new solution: rays.
https://playground.babylonjs.com/frame#D1Z1VL#24

A ray is casted down. whatever mesh it hits, has a physics impostor. The hit mesh changed? dispose of the old impostor, and add the new one. Works at around 30fps, and now I just hafta optimize the rendering.

3 Likes

Good job!

1 Like

Thanks! I’m gonna add more rays so that the cubes in front, behind, to your left and right can have collision. I thought about using texture planes with billboarding for an optimized rendering, but I’m not sure how that would go. :laughing:

1 Like