Renamed osg::Matric::makeIdent() to osg::Matrix::makeIdentity() to make
it consistent with the rest of the osg::Matrix naming. Updated OSG distribution to account for new name. Added support for the STATIC/DYNAMIC osg::Transform::Type to the .osg ASCII reader/writer plugin and the flt reader plugin. Removed the non cost version of osg::Transform::getMatrix() as this could by pass the dirty mechinism.
This commit is contained in:
@@ -42,7 +42,7 @@ class CameraPacket {
|
||||
|
||||
osg::Vec3 lv = _center-_eye;
|
||||
osg::Matrix matrix;
|
||||
matrix.makeIdent();
|
||||
matrix.makeIdentity();
|
||||
matrix.makeRotate(angle_offset,_up.x(),_up.y(),_up.z());
|
||||
lv = lv*matrix;
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ using namespace osg;
|
||||
|
||||
OrientationConverter::OrientationConverter( void )
|
||||
{
|
||||
R.makeIdent();
|
||||
T.makeIdent();
|
||||
R.makeIdentity();
|
||||
T.makeIdentity();
|
||||
_trans_set = false;
|
||||
S.makeIdent();
|
||||
S.makeIdentity();
|
||||
}
|
||||
|
||||
void OrientationConverter::setRotation( const Vec3 &from, const Vec3 &to )
|
||||
|
||||
@@ -82,7 +82,7 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix
|
||||
float ev_length = ev.length();
|
||||
if (ev_length>0.0f)
|
||||
{
|
||||
mat.makeIdent();
|
||||
mat.makeIdentity();
|
||||
//float rotation_zrotation_z = atan2f(ev.x(),ev.y());
|
||||
//mat.makeRotate(inRadians(rotation_z),0.0f,0.0f,1.0f);
|
||||
float inv = 1.0f/ev_length;
|
||||
@@ -134,7 +134,7 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix
|
||||
void Billboard::calcTransform(const Vec3& eye_local, const Vec3& pos_local,Matrix& mat) const
|
||||
{
|
||||
// mat.makeTranslate(pos_local[0],pos_local[1],pos_local[2]);
|
||||
// mat.makeIdent();
|
||||
// mat.makeIdentity();
|
||||
calcRotation(eye_local,pos_local,mat);
|
||||
|
||||
// mat.postTrans(pos_local[0],pos_local[1],pos_local[2]);
|
||||
|
||||
@@ -657,7 +657,7 @@ void Camera::calculateMatricesAndClippingVolume() const
|
||||
else
|
||||
{
|
||||
_modelViewMatrix = new Matrix;
|
||||
_modelViewMatrix->makeIdent();
|
||||
_modelViewMatrix->makeIdentity();
|
||||
}
|
||||
break;
|
||||
case(USE_EYE_AND_QUATERNION): // not implemented yet, default to eye,center,up.
|
||||
|
||||
@@ -95,7 +95,7 @@ void Matrix::setTrans( const Vec3& v )
|
||||
_mat[3][2] = v[2];
|
||||
}
|
||||
|
||||
void Matrix::makeIdent()
|
||||
void Matrix::makeIdentity()
|
||||
{
|
||||
SET_ROW(0, 1, 0, 0, 0 )
|
||||
SET_ROW(1, 0, 1, 0, 0 )
|
||||
|
||||
@@ -6,7 +6,7 @@ Transform::Transform()
|
||||
{
|
||||
_type = DYNAMIC;
|
||||
_matrix = new osg::Matrix();
|
||||
_matrix->makeIdent();
|
||||
_matrix->makeIdentity();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -113,8 +113,8 @@ bool FltFile::readFile(const std::string& fileName)
|
||||
// havn't found file, look in OSGFILEPATH
|
||||
char* newFileName = osgDB::findFile(fileName.c_str());
|
||||
|
||||
if (!newFileName) return NULL;
|
||||
if (!fin.open(newFileName)) return NULL;
|
||||
if (!newFileName) return false;
|
||||
if (!fin.open(newFileName)) return false;
|
||||
}
|
||||
|
||||
osg::notify(osg::INFO) << "Loading " << fileName << " ... " << std::endl;
|
||||
|
||||
@@ -551,6 +551,7 @@ osg::Node* ConvertFromFLT::visitDOF(osg::Group* osgParent, DofRecord* rec)
|
||||
|
||||
visitPrimaryNode(transform, (PrimNodeRecord*)rec);
|
||||
transform->setName(rec->getData()->szIdent);
|
||||
transform->setType(osg::Transform::DYNAMIC);
|
||||
|
||||
// note for Judd (and others) shouldn't there be code in here to set up the transform matrix?
|
||||
// as a transform with an identity matrix is effectively only a
|
||||
@@ -1088,8 +1089,8 @@ osg::Node* ConvertFromFLT::visitMatrix(osg::Group* osgParent, MatrixRecord* rec)
|
||||
{
|
||||
SMatrix* pSMatrix = (SMatrix*)rec->getData();
|
||||
|
||||
osg::Transform* dcs = new osg::Transform;
|
||||
if (dcs)
|
||||
osg::Transform* transform = new osg::Transform;
|
||||
if (transform)
|
||||
{
|
||||
osg::Matrix m;
|
||||
for(int i=0;i<4;++i)
|
||||
@@ -1107,9 +1108,11 @@ osg::Node* ConvertFromFLT::visitMatrix(osg::Group* osgParent, MatrixRecord* rec)
|
||||
pos *= (float)_unitScale;
|
||||
m *= osg::Matrix::translate(pos);
|
||||
|
||||
dcs->setMatrix(m);
|
||||
osgParent->addChild(dcs);
|
||||
return (osg::Node*)dcs;
|
||||
transform->setType(osg::Transform::STATIC);
|
||||
transform->setMatrix(m);
|
||||
|
||||
osgParent->addChild(transform);
|
||||
return (osg::Node*)transform;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -39,6 +39,22 @@ bool Transform_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
Transform& transform = static_cast<Transform&>(obj);
|
||||
|
||||
|
||||
if (fr[0].matchWord("Type"))
|
||||
{
|
||||
if (fr[1].matchWord("DYNAMIC"))
|
||||
{
|
||||
transform.setType(osg::Transform::DYNAMIC);
|
||||
fr +=2 ;
|
||||
}
|
||||
else if (fr[1].matchWord("STATIC"))
|
||||
{
|
||||
transform.setType(osg::Transform::STATIC);
|
||||
fr +=2 ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static Matrix s_matrix;
|
||||
|
||||
if (Matrix* tmpMatrix = static_cast<Matrix*>(fr.readObjectOfType(s_matrix)))
|
||||
@@ -59,6 +75,12 @@ bool Transform_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const Transform& transform = static_cast<const Transform&>(obj);
|
||||
|
||||
switch(transform.getType())
|
||||
{
|
||||
case(osg::Transform::STATIC): fw.indent() << "Type STATIC" << std::endl;
|
||||
default: fw.indent() << "Type DYNAMIC" << std::endl;
|
||||
}
|
||||
|
||||
fw.writeObject(transform.getMatrix());
|
||||
|
||||
return true;
|
||||
|
||||
@@ -367,7 +367,7 @@ void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Transform& transform)
|
||||
_transformList.insert(&transform);
|
||||
|
||||
// reset the matrix to identity.
|
||||
transform.getMatrix().makeIdent();
|
||||
transform.setMatrix(osg::Matrix::identity());
|
||||
|
||||
transform.dirtyBound();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user