Improved the handling of matrices in serialization so that it's more reliable,
change was to use doubles for reading and writing matrices regardless of type of Matrix being serialized. Change does break backwards compatibility though, so code path supporting original format has been left in for the time being. However, this code is not reliable enough and is over complicated compared to the simplified handling. Once the new code has been bedded down for a while I'll remove this code block.
This commit is contained in:
@@ -84,8 +84,9 @@ struct ObjectGLenum
|
||||
#define GLENUM(value) osgDB::ObjectGLenum(value)
|
||||
#define DEF_GLENUM(var) osgDB::ObjectGLenum var;
|
||||
|
||||
struct ObjectProperty
|
||||
class ObjectProperty
|
||||
{
|
||||
public:
|
||||
ObjectProperty( const char* name, int value=0, bool useMap=false )
|
||||
: _name(name), _value(value), _mapProperty(useMap) {}
|
||||
|
||||
@@ -101,6 +102,9 @@ struct ObjectProperty
|
||||
std::string _name;
|
||||
int _value;
|
||||
bool _mapProperty;
|
||||
|
||||
protected:
|
||||
ObjectProperty():_value(0),_mapProperty(false) {}
|
||||
};
|
||||
static ObjectProperty defaultProp("");
|
||||
|
||||
@@ -109,8 +113,9 @@ static ObjectProperty defaultProp("");
|
||||
#define DEF_PROPERTY(name, var) osgDB::ObjectProperty var(name);
|
||||
#define DEF_MAPPEE(pairName, var) osgDB::ObjectProperty var(#pairName, 0, true);
|
||||
|
||||
struct ObjectMark
|
||||
class ObjectMark
|
||||
{
|
||||
public:
|
||||
ObjectMark( const char* name, int delta=0 )
|
||||
: _name(name), _indentDelta(delta) {}
|
||||
|
||||
@@ -119,6 +124,9 @@ struct ObjectMark
|
||||
|
||||
std::string _name;
|
||||
int _indentDelta;
|
||||
|
||||
protected:
|
||||
ObjectMark():_indentDelta(0) {}
|
||||
};
|
||||
static ObjectMark BEGIN_BRACKET("{", +INDENT_VALUE);
|
||||
static ObjectMark END_BRACKET ("}", -INDENT_VALUE);
|
||||
|
||||
@@ -69,7 +69,6 @@ public:
|
||||
virtual ~InputStream();
|
||||
|
||||
bool isBinary() const { return _in->isBinary(); }
|
||||
bool getUseFloatMatrix() const { return _useFloatMatrix; }
|
||||
const osgDB::Options* getOptions() const { return _options.get(); }
|
||||
|
||||
// Serialization related functions
|
||||
@@ -161,7 +160,6 @@ protected:
|
||||
IdentifierMap _identifierMap;
|
||||
|
||||
int _byteSwap;
|
||||
bool _useFloatMatrix;
|
||||
bool _useSchemaData;
|
||||
bool _forceReadingImage;
|
||||
std::vector<std::string> _fields;
|
||||
|
||||
@@ -336,14 +336,17 @@ public:
|
||||
|
||||
virtual bool write( OutputStream& os, const osg::Object& obj )
|
||||
{
|
||||
|
||||
const C& object = OBJECT_CAST<const C&>(obj);
|
||||
const osg::Matrix& value = (object.*_getter)();
|
||||
if ( os.isBinary() )
|
||||
{
|
||||
OSG_NOTICE<<"MatrixSerializer::write() binary"<<std::endl;
|
||||
os << value;
|
||||
}
|
||||
else if ( ParentType::_defaultValue!=value )
|
||||
{
|
||||
OSG_NOTICE<<"MatrixSerializer::write() ascii, ParentType::_name="<<ParentType::_name<<std::endl;
|
||||
os << PROPERTY((ParentType::_name).c_str()) << value << std::endl;
|
||||
}
|
||||
return true;
|
||||
@@ -352,6 +355,9 @@ public:
|
||||
protected:
|
||||
void readMatrixImplementation( InputStream& is, osg::Matrix& matrix )
|
||||
{
|
||||
#if 1
|
||||
is >> matrix;
|
||||
#else
|
||||
if ( is.getUseFloatMatrix() )
|
||||
{
|
||||
osg::Matrixf realValue; is >> realValue;
|
||||
@@ -362,6 +368,7 @@ protected:
|
||||
osg::Matrixd realValue; is >> realValue;
|
||||
matrix = realValue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user