From 11a55ea6de20ea8e81cf13d71dd758ac2c1fca02 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 9 Jun 2015 16:49:20 +0000 Subject: [PATCH] Added supoort for osg::CullSettings/Camera::InheritanceMaskActionOnAttributeSetting and InheritanceMask properties. git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14904 16af8721-9629-0410-8352-f15c8da7e697 --- CMakeLists.txt | 2 +- include/osgDB/Serializer | 31 ++++++++++++++---- src/osgWrappers/serializers/osg/Camera.cpp | 37 ++++++++++++++++++++++ 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d198c2d4c..f7bb7fb5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ PROJECT(OpenSceneGraph) SET(OPENSCENEGRAPH_MAJOR_VERSION 3) SET(OPENSCENEGRAPH_MINOR_VERSION 3) SET(OPENSCENEGRAPH_PATCH_VERSION 8) -SET(OPENSCENEGRAPH_SOVERSION 122) +SET(OPENSCENEGRAPH_SOVERSION 123) # set to 0 when not a release candidate, non zero means that any generated # svn tags will be treated as release candidates of given number diff --git a/include/osgDB/Serializer b/include/osgDB/Serializer index 1ae562b52..74fb9922b 100644 --- a/include/osgDB/Serializer +++ b/include/osgDB/Serializer @@ -1452,9 +1452,12 @@ public: C& object = OBJECT_CAST(obj); if ( is.isBinary() ) { - bool ok = false; is >> ok; //code from user serialized ensuring backwards-compatibility - if ( !ok ) return true; - + if (is.getFileVersion()<123) + { + bool ok = false; is >> ok; //code from user serialized ensuring backwards-compatibility + if ( !ok ) return true; + } + P mask; is >> mask; (object.*_setter)( mask ); @@ -1482,9 +1485,12 @@ public: bool ok = ParentType::_defaultValue!=static_cast

(mask); if ( os.isBinary() ) { - os << ok; - if ( !ok ) - return true; + if (os.getFileVersion()<123) + { + os << ok; + if ( !ok ) + return true; + } os << (int)mask; //just write int value in binary case } else @@ -1838,12 +1844,23 @@ protected: #define END_ENUM_SERIALIZER() \ wrapper->addSerializer(serializer.get(), osgDB::BaseSerializer::RW_ENUM); } - + +/** defaults to uint bitfield type.*/ #define BEGIN_BITFLAGS_SERIALIZER(PROP, DEF) \ { typedef osgDB::BitFlagsSerializer MySerializer; \ osg::ref_ptr serializer = new MySerializer( \ #PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP) +#define BEGIN_UINT_BITFLAGS_SERIALIZER(PROP, DEF) \ + { typedef osgDB::BitFlagsSerializer MySerializer; \ + osg::ref_ptr serializer = new MySerializer( \ + #PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP) + +#define BEGIN_INT_BITFLAGS_SERIALIZER(PROP, DEF) \ + { typedef osgDB::BitFlagsSerializer MySerializer; \ + osg::ref_ptr serializer = new MySerializer( \ + #PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP) + #define ADD_BITFLAG_VALUE(VALUE_NAME, VALUE) \ serializer->add(#VALUE_NAME, VALUE) diff --git a/src/osgWrappers/serializers/osg/Camera.cpp b/src/osgWrappers/serializers/osg/Camera.cpp index c28cbe7b2..4d6ca4c3a 100644 --- a/src/osgWrappers/serializers/osg/Camera.cpp +++ b/src/osgWrappers/serializers/osg/Camera.cpp @@ -228,4 +228,41 @@ REGISTER_OBJECT_WRAPPER( Camera, ADD_OBJECT_SERIALIZER( PreDrawCallback, osg::Camera::DrawCallback, NULL ); // _preDrawCallback ADD_OBJECT_SERIALIZER( PostDrawCallback, osg::Camera::DrawCallback, NULL ); // _postDrawCallback ADD_OBJECT_SERIALIZER( FinalDrawCallback, osg::Camera::DrawCallback, NULL ); // _finalDrawCallback + + { + UPDATE_TO_VERSION_SCOPED( 123 ) + BEGIN_ENUM_SERIALIZER( InheritanceMaskActionOnAttributeSetting, DISABLE_ASSOCIATED_INHERITANCE_MASK_BIT ); + ADD_ENUM_VALUE( DISABLE_ASSOCIATED_INHERITANCE_MASK_BIT ); + ADD_ENUM_VALUE( DO_NOT_MODIFY_INHERITANCE_MASK ); + END_ENUM_SERIALIZER(); + + BEGIN_INT_BITFLAGS_SERIALIZER(InheritanceMask, osg::Camera::ALL_VARIABLES); + ADD_BITFLAG_VALUE(COMPUTE_NEAR_FAR_MODE, osg::Camera::COMPUTE_NEAR_FAR_MODE); + ADD_BITFLAG_VALUE(CULLING_MODE, osg::Camera::CULLING_MODE); + ADD_BITFLAG_VALUE(LOD_SCALE, osg::Camera::LOD_SCALE); + ADD_BITFLAG_VALUE(SMALL_FEATURE_CULLING_PIXEL_SIZE, osg::Camera::SMALL_FEATURE_CULLING_PIXEL_SIZE); + ADD_BITFLAG_VALUE(CLAMP_PROJECTION_MATRIX_CALLBACK, osg::Camera::CLAMP_PROJECTION_MATRIX_CALLBACK); + ADD_BITFLAG_VALUE(NEAR_FAR_RATIO, osg::Camera::NEAR_FAR_RATIO); + ADD_BITFLAG_VALUE(IMPOSTOR_ACTIVE, osg::Camera::IMPOSTOR_ACTIVE); + ADD_BITFLAG_VALUE(DEPTH_SORT_IMPOSTOR_SPRITES, osg::Camera::DEPTH_SORT_IMPOSTOR_SPRITES); + ADD_BITFLAG_VALUE(IMPOSTOR_PIXEL_ERROR_THRESHOLD, osg::Camera::IMPOSTOR_PIXEL_ERROR_THRESHOLD); + ADD_BITFLAG_VALUE(NUM_FRAMES_TO_KEEP_IMPOSTORS_SPRITES, osg::Camera::NUM_FRAMES_TO_KEEP_IMPOSTORS_SPRITES); + ADD_BITFLAG_VALUE(CULL_MASK, osg::Camera::CULL_MASK); + ADD_BITFLAG_VALUE(CULL_MASK_LEFT, osg::Camera::CULL_MASK_LEFT); + ADD_BITFLAG_VALUE(CULL_MASK_RIGHT, osg::Camera::CULL_MASK_RIGHT); + ADD_BITFLAG_VALUE(CLEAR_COLOR, osg::Camera::CLEAR_COLOR); + ADD_BITFLAG_VALUE(CLEAR_MASK, osg::Camera::CLEAR_MASK); + ADD_BITFLAG_VALUE(LIGHTING_MODE, osg::Camera::LIGHTING_MODE); + ADD_BITFLAG_VALUE(LIGHT, osg::Camera::LIGHT); + ADD_BITFLAG_VALUE(DRAW_BUFFER, osg::Camera::DRAW_BUFFER); + ADD_BITFLAG_VALUE(READ_BUFFER, osg::Camera::READ_BUFFER); + ADD_BITFLAG_VALUE(NO_VARIABLES, osg::Camera::NO_VARIABLES); + /** ADD_BITFLAG_VALUE(ALL_VARIABLES, osg::Camera::ALL_VARIABLES);*/ + END_BITFLAGS_SERIALIZER(); + + //ALL_VARIABLES + + } + + }