From e686a9a4a50713acbfc68d2b7270dba2724f77a5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 3 Oct 2006 09:39:03 +0000 Subject: [PATCH] From Brede Johansen, "I think some nitpicking is required. The loop duration was added in OpenFlight version 15.8. With the attached changes the flasher unit on the spinnercar and the character_anim model from the Creator gallery behaves." --- src/osgPlugins/OpenFlight/PrimaryRecords.cpp | 33 ++++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/osgPlugins/OpenFlight/PrimaryRecords.cpp b/src/osgPlugins/OpenFlight/PrimaryRecords.cpp index eefe2a4b2..c77cd7abb 100644 --- a/src/osgPlugins/OpenFlight/PrimaryRecords.cpp +++ b/src/osgPlugins/OpenFlight/PrimaryRecords.cpp @@ -158,23 +158,6 @@ public: protected: - virtual ~Group() - { - if (!_group.valid()) - return; - - if ( (_group->getNumChildren() > 0) && - (_forwardAnim || _backwardAnim) ) - { - // Now that we know the number of children, set the loop duration - // to the best of our ability (currently, osg::Sequence doesn't - // support the OpenFlight last frame duration concept). - osg::Sequence* sequence = dynamic_cast( _group.get() ); - assert( sequence != NULL ); - sequence->setDuration( _loopDuration / (float)(_group->getNumChildren()) ); - } - } - void readRecord(RecordInputStream& in, Document& document) { std::string id = in.readString(8); @@ -188,6 +171,7 @@ protected: /*uint16 significance =*/ in.readUInt16(); /*int8 layer =*/ in.readInt8(); in.forward(5); + // version >= VERSION_15_8 /*uint32 loopCount =*/ in.readUInt32(); _loopDuration = in.readFloat32(); /*float32 lastFrameDuration =*/ in.readFloat32(); @@ -237,6 +221,21 @@ protected: _parent->addChild(*_group); } + virtual void popLevel(Document& document) + { + // Set loop duration? + if (document.version() >= VERSION_15_8) + { + // Now that we know the number of children, set the loop duration + // to the best of our ability (currently, osg::Sequence doesn't + // support the OpenFlight last frame duration concept). + osg::Sequence* sequence = dynamic_cast(_group.get()); + if (sequence && sequence->getNumChildren()>0) + { + sequence->setDuration( _loopDuration / (float)(_group->getNumChildren()) ); + } + } + } }; RegisterRecordProxy g_Group(GROUP_OP);