Y loops optimisation

Apr 11, 2011 at 4:48 AM
Edited Apr 11, 2011 at 4:50 AM

In my last commit & push, I updated the optimization of the Y loop on chunks with chunk.lowestNoneBlock and chunk.highestSolidBlock.

Now buildVertexList takes 2.1 ms on average, and this version of the project has trees , previous one was more flat ! 

Profile often, profile early, cause at first i was mistakenly looping between chunk.highestSolidBlock and chunk.lowestSOLIDBlock and getting ... 18 ms !

So if i summarize the evolution of this optimisation :

looping always from 0 to max : 18 ms

looping from lowest empty to max : 4.6 ms ( not so bad)

looping from lowest solid to highest solid: 18 ms => very bad regression !

looping from lowest empty to highest solid: 2.1 ms


Next step on the same subject would be to avoid building vertice for inaccessible caves, with some sort of pathfinding through empty blocks.

This may not be worth the milisecond and may adversely impact the terrain gen ( cause all those optimizations are done while generating the blocks).


Another optimization would be trying to do all vector operations with xna vector3,  because it s able to use SSE ( = operating on x, y and z at the same time ) , maybe even rewriting the perlin noise class to use vector3 or finding another impl that already uses that.  

(I use eqatec profiler in release mode, very easy to use )

Apr 11, 2011 at 6:15 AM

This is looking great!

I will have to look into eqatec and maybe the vector3 conversion, can't be that hard... right? :) .

nProf didn't seem to want to play nice (read somewhere that it could have been due to threads not exiting properly)