Hi Jan,

It may be technically doable to implement the OSG Vec/Matrix API via the Eigen 
library along these lines:

Code:

namespace osg {

template< typename T > class Vec3t : public Eigen::Matrix< T, 3, 1 > 
{
public:
    Vec3t() : Eigen::Matrix< T, 3, 1 >(0, 0, 0) {} // Eigen not zero by default
    Vec3t(T x, T y, T z) : Eigen::Matrix< T, 3, 1 >(x, y, z) {}
    Vec3t(const Eigen::Matrix< T, 3, 1 >& copy) : Eigen::Matrix< T, 3, 1 
>(copy) {}
    // ...
};

template< typename T > inline 
auto operator ^ (const Vec3t< T >& t1, const Vec3t< T >& t2) -> 
decltype(t1.cross(t2))
{
    return t1.cross(t2);
}

template< typename T > inline 
auto operator * (const Vec3t< T >& t1, const Vec3t< T >& t2) -> 
decltype(t1.dot(t2))
{
   return t1.dot(t2);
}

typedef Vec3t< double > Vec3d;
}



However:* #include Eigen/Core, etc slows down compilation brutaly
* Requires c++11 (however this compiles with VC2010)
* 3D vectors will not be vectorized and thus not optimized with SSE.
* Copying to/from wrapper classes slows down, but optimizing compilers may/will 
eliminate that.


Cheers,
Tyge[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63689#63689





_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to