Tested curves using dof:sharp-distance
(also fixed a bug)
This commit is contained in:
parent
663aff9ea1
commit
7e4a1736e8
3 changed files with 62 additions and 7 deletions
34
demo.cc
34
demo.cc
|
@ -25,11 +25,41 @@ bool T_Demo::initialise( )
|
|||
|
||||
Globals::Sync( ).clearInputs( );
|
||||
Globals::Sync( ).addInput( "dof:sharp-distance" , 15 );
|
||||
Globals::Sync( ).addInput( "dof:sharp-range" , 25 );
|
||||
Globals::Sync( ).addInput( "dof:falloff" , 100 );
|
||||
Globals::Sync( ).addInput( "dof:sharp-range" , 5 );
|
||||
Globals::Sync( ).addInput( "dof:falloff" , 10 );
|
||||
Globals::Sync( ).addInput( "dof:max-blur" , 16 );
|
||||
Globals::Sync( ).addInput( "dof:samples" , 16 );
|
||||
|
||||
// XXX test curve
|
||||
{
|
||||
T_SyncCurve curve;
|
||||
curve.name = "dof:sharp-distance";
|
||||
{
|
||||
T_SyncSegment seg;
|
||||
seg.nPoints = 4;
|
||||
seg.type = T_SyncSegment::SMOOTH;
|
||||
seg.durations.push_back( 300 );
|
||||
seg.durations.push_back( 300 );
|
||||
seg.durations.push_back( 300 );
|
||||
seg.values.push_back( 15 );
|
||||
seg.values.push_back( 30 );
|
||||
seg.values.push_back( 15 );
|
||||
seg.values.push_back( 15 );
|
||||
curve.segments.emplace_back( std::move( seg ) );
|
||||
}
|
||||
{
|
||||
T_SyncSegment seg;
|
||||
seg.nPoints = 2;
|
||||
seg.type = T_SyncSegment::LINEAR;
|
||||
seg.durations.push_back( 600 );
|
||||
seg.values.push_back( 100 );
|
||||
seg.values.push_back( 20 );
|
||||
curve.segments.emplace_back( std::move( seg ) );
|
||||
}
|
||||
Globals::Sync( ).setCurve( std::move( curve ) );
|
||||
}
|
||||
Globals::Sync( ).updateCurveCaches( );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
27
sync.cc
27
sync.cc
|
@ -22,15 +22,15 @@ void T_SyncCurves::clear( )
|
|||
positions.clear( );
|
||||
}
|
||||
|
||||
bool T_SyncCurves::addCurve( __rd__ T_SyncCurve curve )
|
||||
void T_SyncCurves::setCurve( __rd__ T_SyncCurve curve )
|
||||
{
|
||||
const auto p( positions.find( curve.name ) );
|
||||
if ( p == positions.end( ) ) {
|
||||
positions.emplace( curve.name , curves.size( ) );
|
||||
curves.emplace_back( std::move( curve ) );
|
||||
return true;
|
||||
} else {
|
||||
curves[ p->second ] = std::move( curve );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t T_SyncCurves::indexOf( __rd__ std::string const& name )
|
||||
|
@ -137,7 +137,7 @@ float T_SyncCurveCache::segmentValue(
|
|||
}
|
||||
|
||||
auto const& idxp( segRefs[ segIndex ] );
|
||||
auto const& seg( segments[ idxp.second ] );
|
||||
auto const& seg( segments[ idxp.first ] );
|
||||
|
||||
// Interpolation factor
|
||||
const float st( segStarts[ segIndex ] );
|
||||
|
@ -154,6 +154,10 @@ float T_SyncCurveCache::segmentValue(
|
|||
const auto pid( idxp.second );
|
||||
const float sv( seg.values[ pid ] );
|
||||
const float ev( seg.values[ pid + 1 ] );
|
||||
#if 0
|
||||
printf( "[%.2f] gidx %d - seg %d idx %d - %f\n" , time , segIndex ,
|
||||
idxp.first , idxp.second , v * ( ev - sv ) + sv );
|
||||
#endif
|
||||
return v * ( ev - sv ) + sv;
|
||||
}
|
||||
|
||||
|
@ -224,6 +228,21 @@ void T_SyncManager::setTime(
|
|||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
void T_SyncManager::clearCurves( )
|
||||
{
|
||||
curves_.clear( );
|
||||
updateCurveCaches( );
|
||||
}
|
||||
|
||||
void T_SyncManager::setCurve(
|
||||
__rd__ T_SyncCurve curve )
|
||||
{
|
||||
curves_.setCurve( curve );
|
||||
updateCurveCaches( );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
void T_SyncManager::updateCurveCaches( )
|
||||
{
|
||||
curveCaches_.clear( );
|
||||
|
|
8
sync.hh
8
sync.hh
|
@ -61,7 +61,7 @@ struct T_SyncCurves
|
|||
void clear( );
|
||||
|
||||
// Returns true on success, false on duplicate
|
||||
bool addCurve( __rd__ T_SyncCurve curve );
|
||||
void setCurve( __rd__ T_SyncCurve curve );
|
||||
|
||||
// Returns -1 on lookup failure
|
||||
int32_t indexOf( __rd__ std::string const& name );
|
||||
|
@ -171,6 +171,12 @@ struct T_SyncManager
|
|||
std::vector< float > const& inputs( ) const noexcept
|
||||
{ return values_.values; }
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Curves
|
||||
|
||||
void clearCurves( );
|
||||
void setCurve( __rd__ T_SyncCurve curve );
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void updateCurveCaches( );
|
||||
|
|
Loading…
Reference in a new issue