Updated osgunittests with a matrix invert unit test, and added a conditional
calling of invert_4x4 or invert_4x3 depending on the the right hand column of the matrix. Updated wrappers
This commit is contained in:
@@ -524,45 +524,6 @@ void Matrix_implementation::orthoNormalize(const Matrix_implementation& rhs)
|
||||
|
||||
}
|
||||
|
||||
bool Matrix_implementation::invert( const Matrix_implementation& rhs)
|
||||
{
|
||||
#if 1
|
||||
return invert_4x4_new(rhs);
|
||||
#else
|
||||
static const osg::Timer& timer = *Timer::instance();
|
||||
|
||||
Matrix_implementation a;
|
||||
Matrix_implementation b;
|
||||
|
||||
Timer_t t1 = timer.tick();
|
||||
|
||||
a.invert_4x4_new(rhs);
|
||||
|
||||
Timer_t t2 = timer.tick();
|
||||
|
||||
b.invert_4x4_orig(rhs);
|
||||
|
||||
Timer_t t3 = timer.tick();
|
||||
|
||||
static double new_time = 0.0;
|
||||
static double orig_time = 0.0;
|
||||
static double count = 0.0;
|
||||
|
||||
new_time += timer.delta_u(t1,t2);
|
||||
orig_time += timer.delta_u(t2,t3);
|
||||
++count;
|
||||
|
||||
std::cout<<"Average new="<<new_time/count<<" orig = "<<orig_time/count<<std::endl;
|
||||
|
||||
std::cout<<"new matrix invert time="<<timer.delta_u(t1,t2)<<" "<<a<<std::endl;
|
||||
std::cout<<"orig matrix invert time="<<timer.delta_u(t2,t3)<<" "<<b<<std::endl;
|
||||
|
||||
set(b);
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************
|
||||
Matrix inversion technique:
|
||||
Given a matrix mat, we want to invert it.
|
||||
@@ -589,12 +550,12 @@ So the inverse is mat' = (trans * corr)' * rot', where rot' must be computed the
|
||||
This problem is simplified if [px py pz s] = [0 0 0 1], which will happen if mat was composed only of rotations, scales, and translations (which is common). In this case, we can ignore corr entirely which saves on a lot of computations.
|
||||
******************************************/
|
||||
|
||||
bool Matrix_implementation::invert_4x4_new( const Matrix_implementation& mat )
|
||||
bool Matrix_implementation::invert_4x3( const Matrix_implementation& mat )
|
||||
{
|
||||
if (&mat==this)
|
||||
{
|
||||
Matrix_implementation tm(mat);
|
||||
return invert_4x4_new(tm);
|
||||
return invert_4x3(tm);
|
||||
}
|
||||
|
||||
register value_type r00, r01, r02,
|
||||
@@ -719,11 +680,11 @@ inline T SGL_ABS(T a)
|
||||
#define SGL_SWAP(a,b,temp) ((temp)=(a),(a)=(b),(b)=(temp))
|
||||
#endif
|
||||
|
||||
bool Matrix_implementation::invert_4x4_orig( const Matrix_implementation& mat )
|
||||
bool Matrix_implementation::invert_4x4( const Matrix_implementation& mat )
|
||||
{
|
||||
if (&mat==this) {
|
||||
Matrix_implementation tm(mat);
|
||||
return invert_4x4_orig(tm);
|
||||
return invert_4x4(tm);
|
||||
}
|
||||
|
||||
unsigned int indxc[4], indxr[4], ipiv[4];
|
||||
|
||||
@@ -75,8 +75,8 @@ BEGIN_VALUE_REFLECTOR(osg::Matrixd)
|
||||
I_MethodWithDefaults4(void, getLookAt, IN, osg::Vec3f &, eye, , IN, osg::Vec3f &, center, , IN, osg::Vec3f &, up, , IN, osg::Matrixd::value_type, lookDistance, 1.0f);
|
||||
I_MethodWithDefaults4(void, getLookAt, IN, osg::Vec3d &, eye, , IN, osg::Vec3d &, center, , IN, osg::Vec3d &, up, , IN, osg::Matrixd::value_type, lookDistance, 1.0f);
|
||||
I_Method1(bool, invert, IN, const osg::Matrixd &, rhs);
|
||||
I_Method1(bool, invert_4x4_orig, IN, const osg::Matrixd &, x);
|
||||
I_Method1(bool, invert_4x4_new, IN, const osg::Matrixd &, x);
|
||||
I_Method1(bool, invert_4x3, IN, const osg::Matrixd &, rhs);
|
||||
I_Method1(bool, invert_4x4, IN, const osg::Matrixd &, rhs);
|
||||
I_Method1(void, orthoNormalize, IN, const osg::Matrixd &, rhs);
|
||||
I_Method1(osg::Vec3f, preMult, IN, const osg::Vec3f &, v);
|
||||
I_Method1(osg::Vec3d, preMult, IN, const osg::Vec3d &, v);
|
||||
|
||||
@@ -75,8 +75,8 @@ BEGIN_VALUE_REFLECTOR(osg::Matrixf)
|
||||
I_MethodWithDefaults4(void, getLookAt, IN, osg::Vec3f &, eye, , IN, osg::Vec3f &, center, , IN, osg::Vec3f &, up, , IN, osg::Matrixf::value_type, lookDistance, 1.0f);
|
||||
I_MethodWithDefaults4(void, getLookAt, IN, osg::Vec3d &, eye, , IN, osg::Vec3d &, center, , IN, osg::Vec3d &, up, , IN, osg::Matrixf::value_type, lookDistance, 1.0f);
|
||||
I_Method1(bool, invert, IN, const osg::Matrixf &, rhs);
|
||||
I_Method1(bool, invert_4x4_orig, IN, const osg::Matrixf &, x);
|
||||
I_Method1(bool, invert_4x4_new, IN, const osg::Matrixf &, x);
|
||||
I_Method1(bool, invert_4x3, IN, const osg::Matrixf &, rhs);
|
||||
I_Method1(bool, invert_4x4, IN, const osg::Matrixf &, rhs);
|
||||
I_Method1(void, orthoNormalize, IN, const osg::Matrixf &, rhs);
|
||||
I_Method1(osg::Vec3f, preMult, IN, const osg::Vec3f &, v);
|
||||
I_Method1(osg::Vec3d, preMult, IN, const osg::Vec3d &, v);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
TYPE_NAME_ALIAS(std::list< osg::ref_ptr< osg::Texture::TextureObject > >, osg::Texture::TextureObjectList);
|
||||
|
||||
TYPE_NAME_ALIAS(std::map< unsigned int COMMA osg::Texture::TextureObjectList >, osg::Texture::TextureObjectListMap);
|
||||
TYPE_NAME_ALIAS(osg::buffered_object< osg::Texture::TextureObjectList >, osg::Texture::TextureObjectListMap);
|
||||
|
||||
BEGIN_ENUM_REFLECTOR(osg::Texture::WrapParameter)
|
||||
I_EnumLabel(osg::Texture::WRAP_S);
|
||||
@@ -235,6 +235,16 @@ BEGIN_OBJECT_REFLECTOR(osg::Texture::TextureObject)
|
||||
I_WriteOnlyProperty(bool, Allocated);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_VALUE_REFLECTOR(osg::buffered_object< osg::Texture::TextureObjectList >)
|
||||
I_Constructor0();
|
||||
I_Constructor1(IN, unsigned int, size);
|
||||
I_Method1(void, setAllElementsTo, IN, const osg::Texture::TextureObjectList &, t);
|
||||
I_Method0(void, clear);
|
||||
I_Method0(bool, empty);
|
||||
I_Method0(unsigned int, size);
|
||||
I_WriteOnlyProperty(const osg::Texture::TextureObjectList &, AllElementsTo);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osg::Texture::TextureObject >)
|
||||
I_Constructor0();
|
||||
I_Constructor1(IN, osg::Texture::TextureObject *, ptr);
|
||||
@@ -248,5 +258,3 @@ END_REFLECTOR
|
||||
|
||||
STD_LIST_REFLECTOR(std::list< osg::ref_ptr< osg::Texture::TextureObject > >);
|
||||
|
||||
STD_MAP_REFLECTOR(std::map< unsigned int COMMA osg::Texture::TextureObjectList >);
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ BEGIN_OBJECT_REFLECTOR(osgGA::EventQueue)
|
||||
I_Method2(void, mouseWarp, IN, float, x, IN, float, y);
|
||||
I_Method2(void, mouseMotion, IN, float, x, IN, float, y);
|
||||
I_Method3(void, mouseButtonPress, IN, float, x, IN, float, y, IN, unsigned int, button);
|
||||
I_Method3(void, mouseDoubleButtonPress, IN, float, x, IN, float, y, IN, unsigned int, button);
|
||||
I_Method3(void, mouseButtonRelease, IN, float, x, IN, float, y, IN, unsigned int, button);
|
||||
I_Method1(void, keyPress, IN, osgGA::GUIEventAdapter::KeySymbol, key);
|
||||
I_Method1(void, keyRelease, IN, osgGA::GUIEventAdapter::KeySymbol, key);
|
||||
|
||||
Reference in New Issue
Block a user