本文整理汇总了C++中Curve::GetOwner方法的典型用法代码示例。如果您正苦于以下问题:C++ Curve::GetOwner方法的具体用法?C++ Curve::GetOwner怎么用?C++ Curve::GetOwner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curve
的用法示例。
在下文中一共展示了Curve::GetOwner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MouseDown
bool CurveEditTool::MouseDown( const MouseButtonInput& e )
{
bool success = true;
if ( GetEditMode() == CurveEditModes::Modify )
{
success = m_ControlPointManipulator->MouseDown( e );
}
else
{
Curve* curve = NULL;
{
FrustumLinePickVisitor pick (m_Scene->GetViewport()->GetCamera(), e.GetPosition().x, e.GetPosition().y);
m_Scene->Pick( &pick );
V_PickHitSmartPtr sorted;
PickHit::Sort(m_Scene->GetViewport()->GetCamera(), pick.GetHits(), sorted, PickSortTypes::Intersection);
for ( V_PickHitSmartPtr::const_iterator itr = sorted.begin(), end = sorted.end(); itr != end; ++itr )
{
if ( curve = Reflect::SafeCast<Curve>( (*itr)->GetHitObject() ) )
{
break;
}
}
}
if ( !curve || !m_Scene->IsEditable() )
{
return false;
}
LinePickVisitor pick (m_Scene->GetViewport()->GetCamera(), e.GetPosition().x, e.GetPosition().y);
switch ( GetEditMode() )
{
case CurveEditModes::Insert:
{
std::pair<uint32_t, uint32_t> points;
if ( !curve->ClosestControlPoints( &pick, points ) )
{
return false;
}
CurveControlPoint* p0 = curve->GetControlPointByIndex( points.first );
CurveControlPoint* p1 = curve->GetControlPointByIndex( points.second );
Vector3 a( p0->GetPosition() );
Vector3 b( p1->GetPosition() );
Vector3 p;
if ( curve->GetCurveType() == CurveType::Linear )
{
float mu;
if ( !pick.GetPickSpaceLine().IntersectsSegment( a, b, -1.0f, &mu ) )
{
return false;
}
p = a * ( 1.0f - mu ) + b * mu;
}
else
{
p = ( a + b ) * 0.5f;
}
uint32_t index = points.first > points.second ? points.first : points.second;
CurveControlPointPtr point = new CurveControlPoint();
point->SetOwner( curve->GetOwner() );
point->Initialize();
curve->GetOwner()->Push( curve->InsertControlPointAtIndex( index, point ) );
break;
}
case CurveEditModes::Remove:
{
int32_t index = curve->ClosestControlPoint( &pick );
if ( index < 0 )
{
return false;
}
curve->GetOwner()->Push( curve->RemoveControlPointAtIndex( index ) );
break;
}
}
curve->Dirty();
m_Scene->Execute( false );
}
return success || Base::MouseDown( e );
}