ulfben

Clipping test - Viewport::inView()

Feb 14th, 2017
137
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×