Marcus Lindblom schrieb:

> Templates are ok. :) Did you know that you can put template code inside 
> a dll and export instances across dlls? As an example you could 
> explcitly instantiate OSG::TransformationMatrix for float and double in 
> a cpp file (with code for the big functions) and export those. We do 
> this for a lot of our own math and geom classes, and it really cuts down 
> on compile time & object size, as every file doesn't have to instantiate 
> a lot of template code.

Did you look at the generated assembly code? Because the trouble with 
templates is: The functions quite often don´t get inlined (at least not 
with MSVC8) which really slows you down a lot.
Especially using templates in basic math classes like Vec3f/Pnt3f and so 
on is probably the worst thing one can do since some functions in OpenSG 
(like operator+ for Pnt3f) don´t get inlined. Not to mention: you loose 
some chances for optimizations (SIMD for example could be pretty 
difficult to use in templates when you want to use the same code for 
Vec2f/Vec3f/Vec4f).

I finally got used to use my own math classes and do a simple 
reinterpret cast on values stored in multifields - got me quite some 
speedup since the compiler does correct inlining.

Michael

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to