Make use of optimized matrix multiplication routines in osg.
Modified Files: simgear/scene/model/SGTranslateTransform.cxx
This commit is contained in:
@@ -29,16 +29,6 @@
|
|||||||
|
|
||||||
#include "SGTranslateTransform.hxx"
|
#include "SGTranslateTransform.hxx"
|
||||||
|
|
||||||
static inline void
|
|
||||||
set_translation (osg::Matrix &matrix, double position_m, const SGVec3d &axis)
|
|
||||||
{
|
|
||||||
SGVec3d xyz = axis * position_m;
|
|
||||||
matrix.makeIdentity();
|
|
||||||
matrix(3, 0) = xyz[0];
|
|
||||||
matrix(3, 1) = xyz[1];
|
|
||||||
matrix(3, 2) = xyz[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
SGTranslateTransform::SGTranslateTransform() :
|
SGTranslateTransform::SGTranslateTransform() :
|
||||||
_axis(0, 0, 0),
|
_axis(0, 0, 0),
|
||||||
_value(0)
|
_value(0)
|
||||||
@@ -59,13 +49,9 @@ SGTranslateTransform::computeLocalToWorldMatrix(osg::Matrix& matrix,
|
|||||||
osg::NodeVisitor* nv) const
|
osg::NodeVisitor* nv) const
|
||||||
{
|
{
|
||||||
if (_referenceFrame == RELATIVE_RF) {
|
if (_referenceFrame == RELATIVE_RF) {
|
||||||
osg::Matrix tmp;
|
matrix.preMultTranslate((_value*_axis).osg());
|
||||||
set_translation(tmp, _value, _axis);
|
|
||||||
matrix.preMult(tmp);
|
|
||||||
} else {
|
} else {
|
||||||
osg::Matrix tmp;
|
matrix.setTrans((_value*_axis).osg());
|
||||||
set_translation(tmp, _value, _axis);
|
|
||||||
matrix = tmp;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -75,13 +61,9 @@ SGTranslateTransform::computeWorldToLocalMatrix(osg::Matrix& matrix,
|
|||||||
osg::NodeVisitor* nv) const
|
osg::NodeVisitor* nv) const
|
||||||
{
|
{
|
||||||
if (_referenceFrame == RELATIVE_RF) {
|
if (_referenceFrame == RELATIVE_RF) {
|
||||||
osg::Matrix tmp;
|
matrix.postMultTranslate((-_value*_axis).osg());
|
||||||
set_translation(tmp, -_value, _axis);
|
|
||||||
matrix.postMult(tmp);
|
|
||||||
} else {
|
} else {
|
||||||
osg::Matrix tmp;
|
matrix.setTrans((-_value*_axis).osg());
|
||||||
set_translation(tmp, -_value, _axis);
|
|
||||||
matrix = tmp;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user