Esempio n. 1
0
void WrapActorConstraint( Vector3& position, const PropertyInputContainer& inputs )
{
  bool wrap = inputs[5]->GetBoolean();

  if(wrap)
  {
    const Vector2& min = inputs[3]->GetVector2();
    const Vector2& max = inputs[4]->GetVector2();

    const Vector3& anchor = inputs[1]->GetVector3();
    const Vector3 scale = inputs[0]->GetVector3();
    const Vector3 size = inputs[2]->GetVector3();

    if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
    {
      // WRAP X (based on the position of the right side)
      float offsetX = (1.0f - anchor.x) * size.x * scale.x;
      position.x = WrapInDomain(position.x + offsetX, min.x, max.x) - offsetX;
    }

    if(fabsf(min.y - max.y) > Math::MACHINE_EPSILON_1)
    {
      // WRAP Y (based on the position of the bottom side)
      float offsetY = (1.0f - anchor.y) * size.y * scale.y;
      position.y = WrapInDomain(position.y + offsetY, min.y, max.y) - offsetY;
    }
  }
}
void WrapPositionWithinDomain( Vector3& position, const Vector3& pageSize, const Vector3& min, const Vector3& max )
{
  if( fabsf( min.x - max.x ) > Math::MACHINE_EPSILON_1 )
  {
    // WRAP X (based on the position of the right side)
    position.x = WrapInDomain( position.x + pageSize.width, min.x, max.x ) - pageSize.width;
  }

  if( fabsf( min.y - max.y ) > Math::MACHINE_EPSILON_1 )
  {
    // WRAP Y (based on the position of the bottom side)
    position.y = WrapInDomain( position.y + pageSize.height, min.y, max.y ) - pageSize.height;
  }
}
bool PanGestureDetector::CheckAngleAllowed( Radian angle ) const
{
  bool allowed( false );
  if ( mAngleContainer.empty() )
  {
    allowed = true;
  }
  else
  {
    for ( AngleContainer::const_iterator iter = mAngleContainer.begin(), endIter = mAngleContainer.end(); iter != endIter; ++iter )
    {
      float angleAllowed( iter->first );
      float threshold ( iter->second );

      DALI_LOG_INFO( gLogFilter, Debug::General,
                     "AngleToCheck: %.2f, CompareWith: %.2f, Threshold: %.2f\n",
                     Degree(angle), Degree(angleAllowed), Degree(threshold) );

      float relativeAngle( fabsf( WrapInDomain( angle - angleAllowed, -Math::PI, Math::PI ) ) );
      if ( relativeAngle <= threshold )
      {
        allowed = true;
        break;
      }
    }
  }

  return allowed;
}
void PanGestureDetector::RemoveAngle( Radian angle )
{
  angle = WrapInDomain( angle, -Math::PI, Math::PI );

  for (AngleContainer::iterator iter = mAngleContainer.begin(), endIter = mAngleContainer.end(); iter != endIter; ++iter )
  {
    if ( iter->first == angle )
    {
      mAngleContainer.erase( iter );
      break;
    }
  }
}
void PanGestureDetector::AddAngle( Radian angle, Radian threshold )
{
  threshold = fabsf( threshold ); // Ensure the threshold is positive.

  // If the threshold is greater than PI, then just use PI
  // This means that any panned angle will invoke the pan gesture. We should still add this angle as
  // an angle may have been added previously with a small threshold.
  if ( threshold > Math::PI )
  {
    threshold = Math::PI;
  }

  angle = WrapInDomain( angle, -Math::PI, Math::PI );

  DALI_LOG_INFO( gLogFilter, Debug::Concise, "Angle Added: %.2f, Threshold: %.2f\n", Degree(angle), Degree(threshold) );

  AngleThresholdPair pair( angle, threshold );
  mAngleContainer.push_back( pair );
}