1

I'm creating a level modifying slightly the destructible terrain class from here:

http://napephys.com/samples.html#swf-DestructibleTerrain

Instead of using PerlinNoise to create a random map, I input my own bitmapdata. When the size of the terrain is the size of the stage, the performance is just fine, however when I put there a 4096x4096 custom bitmap, I get less than 25 fps, which is expected since it has a lot more of area to calculate.

I assume this has a workaround/best practice, like putting to sleep the area of the level you don't see, maybe passing a AABB region of the space that shouldn't count towards calculation for example, but no idea, I'm guesstimating.

If anyone knows what would be a good approach, let me know, thanks.

Artemix
  • 8,497
  • 14
  • 48
  • 75
  • Putting areas "to sleep" will depend a lot on NAPE, since this isn't a native AS3 feature in that sense. I would expect a good physics engine to already optimize static bodies. If you turn off areas of NAPE that are off screen, you have to be *sure* that nothing is going to actually happen off-screen. It's also possible that your bottleneck is the display, not the physics engine. There are certainly techniques to optimize display rendering by only rendering what is on-screen. – Aaron Beall Mar 28 '16 at 14:12
  • Actually no, the bottleneck is Nape, and they are already sleeping, since the map is completely static except my character, so they are sleeping. The only way I found to regain my old performance was to remove the off-screen bodies from the Space. But I'm not very experienced with Nape, might be other way to do it. – Artemix Mar 28 '16 at 18:58

0 Answers0