Ejemplo n.º 1
0
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;
	}
}
Ejemplo n.º 2
0
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;
}