[Gtkradiant] small optimization

Rudolf Polzer divverent at googlemail.com
Wed Feb 22 07:52:22 EST 2012

On Sun, Feb 19, 2012 at 09:46:41PM -0800, James Canete wrote:
> So I was running q3map2 through a profiler when I noticed that a lot of
> time was being spent in VectorNormalize() in libs/mathlib/mathlib.c during
> the -light phase.  I figured this was due to the math accuracy fixes, but I
> also figured that there weren't really necessary during lighting, so I
> borrowed the fast VectorNormalize2() from ioquake3 and used it in a couple
> of key places during lighting.  I also went ahead and rewrote TraceLine_r()
> in light_trace.c to be iterative when possible, while I was at it.
> These two changes improved the light time on my test map by around 7% (or
> one second, if you prefer), and don't seem to have any bad side effects,
> though I haven't tried running the regression maps on it.
> I put the patch at http://pastebin.com/uUED7Kt8 since I'm still not sure
> where I should be submitting patches.

I put the patch in the NetRadiant git repository:


I will test it later and possibly merge it. In review it looked good.

BTW, regarding the accuracy fixes... I wonder if it'd gain even more speed to
do the inaccurate case using Carmack's invsqrt hack. But this is to be tested


Best regards,

Rudolf Polzer

More information about the Gtkradiant mailing list