SHARE
TWEET

Clipping test - Viewport::inView()

ulfben Feb 14th, 2017 (edited) 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
Want to get better at Java?
Learn to code Java in 2017
Top