I'm almost finished with the porting of the original Quake map compiling tools 
from 1996, written in C.

To be more precise, the tool that calculates the light for the map, nothing 
special, it a straight 1:1 port. After initial benchmarks i ran on various 
maps, it turned out that the Nim version is almost twice slower than the 
original C version.

I found the hotspot, its in the function called TestRay. Basicly it checks if a 
straith line could be drawn between light and a sample point on face from the 
map. To check if there is a blocking face between these two 3d points, the BSP 
tree is walked recursively until it comes to the leafs, or it hits some other 
condition for breaking. There are 10000 -20000 checks flips and flops only for 
one test, and there are 1296 sample points on a face, and tens of thousands 
faces on a map in average.

Same as in the C version, Im using ptrmath, the original code is 
[here](https://github.com/id-Software/Quake-Tools/blob/c0d1b91c74eb654365ac7755bc837e497caaca73/qutils/LIGHT/TRACE.C#L93)

, nim version is 
[here](https://bitbucket.org/DraganJanushevski/qutils-nim/src/master/LIGHT/TRACE.nim#lines-103)

Reply via email to