From 88e8477cbfd32078efed8588912e69227d3b65a9 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 17 Apr 2005 10:41:23 +0000 Subject: [PATCH] Moved istream/ostream includes out of Vec3f, and reimpleted osg::Matrix*::compare. --- include/osg/Matrixd | 2 +- include/osg/Matrixf | 2 +- include/osg/Vec3f | 3 --- src/osg/Matrix_implementation.cpp | 12 ++++++++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/osg/Matrixd b/include/osg/Matrixd index c478fa979..a2e132ccb 100644 --- a/include/osg/Matrixd +++ b/include/osg/Matrixd @@ -43,7 +43,7 @@ class OSG_EXPORT Matrixd ~Matrixd() {} - int compare(const Matrixd& m) const { return memcmp(_mat,m._mat,sizeof(_mat)); } + int compare(const Matrixd& m) const; bool operator < (const Matrixd& m) const { return compare(m)<0; } bool operator == (const Matrixd& m) const { return compare(m)==0; } diff --git a/include/osg/Matrixf b/include/osg/Matrixf index cfd9e5231..78ecd3159 100644 --- a/include/osg/Matrixf +++ b/include/osg/Matrixf @@ -43,7 +43,7 @@ class OSG_EXPORT Matrixf ~Matrixf() {} - int compare(const Matrixf& m) const { return memcmp(_mat,m._mat,sizeof(_mat)); } + int compare(const Matrixf& m) const; bool operator < (const Matrixf& m) const { return compare(m)<0; } bool operator == (const Matrixf& m) const { return compare(m)==0; } diff --git a/include/osg/Vec3f b/include/osg/Vec3f index 73972e35b..3dd03ac5a 100644 --- a/include/osg/Vec3f +++ b/include/osg/Vec3f @@ -14,9 +14,6 @@ #ifndef OSG_VEC3F #define OSG_VEC3F 1 -#include -#include - #include #include diff --git a/src/osg/Matrix_implementation.cpp b/src/osg/Matrix_implementation.cpp index e91be8433..127a3df98 100644 --- a/src/osg/Matrix_implementation.cpp +++ b/src/osg/Matrix_implementation.cpp @@ -174,6 +174,18 @@ void Matrix_implementation::get( Quat& q ) const } } +int Matrix_implementation::compare(const Matrix_implementation& m) const +{ + const Matrix_implementation::value_type* lhs = reinterpret_cast(_mat); + const Matrix_implementation::value_type* end_lhs = lhs+16; + const Matrix_implementation::value_type* rhs = reinterpret_cast(m._mat); + for(;lhs!=end_lhs;++lhs,++rhs) + { + if (*lhs < *rhs) return -1; + if (*rhs < *lhs) return 1; + } + return 0; +} void Matrix_implementation::setTrans( value_type tx, value_type ty, value_type tz ) {