Advertisement
ulfben

Clipping test - Viewport::inView()

Feb 14th, 2017
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. //the fixed clipping test. :)
  2. public boolean inView(final PointF worldPos, final float objectWidth, final float objectHeight) {
  3.     float maxX = (mCurrentViewportWorldCentre.x + mHalfDistX);
  4.     float minX = (mCurrentViewportWorldCentre.x - mHalfDistX)-objectWidth;
  5.     float maxY = (mCurrentViewportWorldCentre.y + mHalfDistY);
  6.     float minY  = (mCurrentViewportWorldCentre.y - mHalfDistY)-objectHeight;
  7.     if((worldPos.x > minX && worldPos.x < maxX)
  8.             && (worldPos.y > minY && worldPos.y < maxY)){
  9.         return true;
  10.     }
  11.     mClippedCount++; //for debugging
  12.     return false;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement