Game Development Community


#1
11/15/2007 (2:40 pm)
You should post this on the TGB private forums since it deals with the C++ source code.
#2
11/15/2007 (2:50 pm)
Quote:
inline t2dVector& operator /= (const F32 s) { mX /= s; mY /= s; return *this; };

Does anyone see the point of returning *this? It creates a new t2DVector for every operation and then never uses it. Tons of cycles wasted on vector operations everywhere throughout the engine!
It is not creating a new t2dVector, it is returning a reference to itself so that you can do things like this:
if( ( someVec /= 4.0f ).isLenZero() )
// do stuff
#3
11/15/2007 (4:02 pm)
Re checking for 0 and other special angles,
i would be inclined to not do these checks because:
* the code becomes harder to trust & maintain, in exchange for not much optimization.
* the underlying libraries and/or FPU should already be doing this, possibly more efficiently.
* branch statements (conditionals) make it difficult for the modern CPU to pipeline efficiently, and so executing a simple if() statement may in fact mean greater overall cost than simply going ahead and performing the seemingly more expensive operation every time. - i'm not sure that's necessarily the case here, but it's something to bear in mind when optimizing at this level.