コード例 #1
0
ファイル: Animation.cpp プロジェクト: ImageEngine/gaffer
void Animation::Key::setTime( float time )
{
	if( time == m_time )
	{
		return;
	}

	if( m_parent )
	{
		if( KeyPtr existingKey = m_parent->getKey( time ) )
		{
			m_parent->removeKey( existingKey );
		}

		const float previousTime = m_time;
		CurvePlug *curve = m_parent;
		Action::enact(
			m_parent,
			// Do
			[ curve, previousTime, time ] {
				curve->m_keys.modify(
					curve->m_keys.find( previousTime ),
					[ time ] ( KeyPtr &key ) {
						key->m_time = time;
					}
				);
				curve->propagateDirtiness( curve->outPlug() );
			},
			// Undo
			[ curve, previousTime, time ] {
				curve->m_keys.modify(
					curve->m_keys.find( time ),
					[ previousTime ] ( KeyPtr &key ) {
						key->m_time = previousTime;
					}
				);
				curve->propagateDirtiness( curve->outPlug() );
			}
		);
	}
	else
	{
		m_time = time;
	}
}
コード例 #2
0
ファイル: Animation.cpp プロジェクト: espennordahl/gaffer
Animation::CurvePlug *Animation::inputCurve( ValuePlug *plug )
{
	ValuePlug *source = plug->source<ValuePlug>();
	if( source == plug ) // no input
	{
		return NULL;
	}

	CurvePlug *curve = source->parent<CurvePlug>();
	if( !curve )
	{
		return NULL;
	}

	if( source == curve->outPlug() )
	{
		return curve;
	}

	return NULL;
}