1

Topic: First patches. Solve #230 and fast vector normalization.

Hey,
I decided to give a shot the nasty bug in here -> http://ix.teewars.com/trac/ticket/230
First problem was the bug in vector normalization function. It didn't handle small values resulting in dividing by zero which resulted in nan. Got that fixed. Next thing was adding a special case for the cursor position (0,0). I defaulted the shooting and hook direction to vector (1,0) as it would be expected from the tee's barrel position.
Here's the patch. I think that it should be abstracted to "get_direction" method somewhere, but I leave it to you
http://eros.vlo.gda.pl/~rush/teewars-0.3.0-fix230.patch

The second patch depends on the first one and it adds a fast normalization method which could speed the things up on slower machines. Dunno if it's worth it. Possibly it is hardware dependant because of the IEEE-32 operations. Also, your templates are a bit decieving. wink They all take T as an argument, but obviously most of them operates only on floats. I followed this weird style. :> And the last thing .. I assume that such small math code is in public domain but I can't be 100% sure, there is a reference in the comment from where it was taken ...
Here is the second patch:
http://eros.vlo.gda.pl/~rush/teewars-0. … norm.patch

Cheers,
Ergo

The proxy of death / noWai!

2

Re: First patches. Solve #230 and fast vector normalization.

I will look into this more deeply in the morning when I sober up form the party I just came from.

The 0,0 bug I was aware of but I never put it down as a ticket so I forgot it. My idea how to solve it is the same as yours. Force direction (0,0) to something valid like (0,-1).

Regardning the second patch. The code is taken from Quake 3 Arena that is licensensed under GPL which isn't compatible. When it come to optimizatings I have a pretty good idea where to start and it's not in that end.

3 (edited by void 2007-12-16 11:36:59)

Re: First patches. Solve #230 and fast vector normalization.

matricks wrote:

Regardning the second patch. The code is taken from Quake 3 Arena that is licensensed under GPL which isn't compatible. When it come to optimizatings I have a pretty good idea where to start and it's not in that end.

It was included in q3, thats different. The code was originally public domain from some researchers or articles IIRC. Will look into it.

EDIT:
http://www.beyond3d.com/content/articles/8/ Looks like it was 3dfx.

Anyway: we can't just take random code and use it in teewars.

Languages shapes the way we think, or don't.