X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmodel%2Fanimation.cxx;h=8a1c73e2281ef3bb5701cdc727f25969bf626b84;hb=b199f733f7a71218a20c3408af570aa1edf92642;hp=68cd908f888852dcc112fc9c3f91bbf886168d54;hpb=bda112297f2d81bd752b758bbb42485ccbf6a89e;p=simgear.git diff --git a/simgear/scene/model/animation.cxx b/simgear/scene/model/animation.cxx index 68cd908f..8a1c73e2 100644 --- a/simgear/scene/model/animation.cxx +++ b/simgear/scene/model/animation.cxx @@ -182,6 +182,11 @@ SGAnimation::SGAnimation (SGPropertyNode_ptr props, ssgBranch * branch) : _branch(branch) { _branch->setName(props->getStringValue("name", 0)); + if ( props->getBoolValue( "enable-hot", true ) ) { + _branch->setTraversalMaskBits( SSGTRAV_HOT ); + } else { + _branch->clrTraversalMaskBits( SSGTRAV_HOT ); + } } SGAnimation::~SGAnimation () @@ -441,21 +446,35 @@ SGTimedAnimation::SGTimedAnimation (SGPropertyNode_ptr props) rNode->getDoubleValue( "max", 1.0 ) ); } } +} + +SGTimedAnimation::~SGTimedAnimation () +{ +} + +void +SGTimedAnimation::init() +{ if ( !_use_personality ) { - for ( size_t i = 0; i < _branch_duration_specs.size(); i++ ) { - DurationSpec &sp = _branch_duration_specs[ i ]; - double v = sp._min + sg_random() * ( sp._max - sp._min ); + for ( size_t i = 0; i < getBranch()->getNumKids(); i++ ) { + double v; + if ( i < _branch_duration_specs.size() ) { + DurationSpec &sp = _branch_duration_specs[ i ]; + v = sp._min + sg_random() * ( sp._max - sp._min ); + } else { + v = _duration_sec; + } _branch_duration_sec.push_back( v ); _total_duration_sec += v; } + // Sanity check : total duration shouldn't equal zero + if ( _total_duration_sec < 0.01 ) { + _total_duration_sec = 0.01; + } } ((ssgSelector *)getBranch())->selectStep(_step); } -SGTimedAnimation::~SGTimedAnimation () -{ -} - int SGTimedAnimation::update() { @@ -472,6 +491,10 @@ SGTimedAnimation::update() offset = v; total += v; } + // Sanity check : total duration shouldn't equal zero + if ( total < 0.01 ) { + total = 0.01; + } offset *= sg_random(); key->setDoubleValue( sim_time_sec - offset, this, LAST_TIME_SEC ); key->setDoubleValue( total, this, TOTAL_DURATION_SEC );