From f1ea25bfb1cc32549f7ad502bee0ed07a10453fb Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 25 Apr 2015 17:13:35 +0200 Subject: [PATCH] Unexpose BoundingVolume::around, add GraphicsOutput::get_fb_size --- panda/src/display/graphicsOutput.I | 48 ++++++++++++++++++++ panda/src/display/graphicsOutput.h | 3 ++ panda/src/mathutil/boundingVolume.h | 2 + panda/src/mathutil/geometricBoundingVolume.h | 2 + 4 files changed, 55 insertions(+) diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index 2b746ff09d..b24390146b 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -207,6 +207,20 @@ get_y_size() const { return _size.get_y(); } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::get_fb_size +// Access: Published +// Description: Returns the internal size of the window or buffer. +// This is almost always the same as get_size(), +// except when a pixel_zoom is in effect--see +// set_pixel_zoom(). +//////////////////////////////////////////////////////////////////// +INLINE LVecBase2i GraphicsOutput:: +get_fb_size() const { + return LVecBase2i(max(int(_size.get_x() * get_pixel_factor()), 1), + max(int(_size.get_y() * get_pixel_factor()), 1)); +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::get_fb_x_size // Access: Published @@ -233,6 +247,23 @@ get_fb_y_size() const { return max(int(_size.get_y() * get_pixel_factor()), 1); } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::get_sbs_left_size +// Access: Published +// Description: If side-by-side stereo is enabled, this returns the +// pixel size of the left eye, based on scaling +// get_size() by get_sbs_left_dimensions(). If +// side-by-side stereo is not enabled, this returns the +// same as get_size(). +//////////////////////////////////////////////////////////////////// +INLINE LVecBase2i GraphicsOutput:: +get_sbs_left_size() const { + PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; + PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2]; + return LVecBase2i(max(int(_size.get_x() * left_w), 1), + max(int(_size.get_y() * left_h), 1)); +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::get_sbs_left_x_size // Access: Published @@ -263,6 +294,23 @@ get_sbs_left_y_size() const { return max(int(_size.get_y() * left_h), 1); } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::get_sbs_right_size +// Access: Published +// Description: If side-by-side stereo is enabled, this returns the +// pixel size of the right eye, based on scaling +// get_size() by get_sbs_right_dimensions(). If +// side-by-side stereo is not enabled, this returns the +// same as get_size(). +//////////////////////////////////////////////////////////////////// +INLINE LVecBase2i GraphicsOutput:: +get_sbs_right_size() const { + PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; + PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2]; + return LVecBase2i(max(int(_size.get_x() * right_w), 1), + max(int(_size.get_y() * right_h), 1)); +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::get_sbs_right_x_size // Access: Published diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index cbcd787d90..7c01cff360 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -135,10 +135,13 @@ PUBLISHED: INLINE const LVecBase2i &get_size() const; INLINE int get_x_size() const; INLINE int get_y_size() const; + INLINE LVecBase2i get_fb_size() const; INLINE int get_fb_x_size() const; INLINE int get_fb_y_size() const; + INLINE LVecBase2i get_sbs_left_size() const; INLINE int get_sbs_left_x_size() const; INLINE int get_sbs_left_y_size() const; + INLINE LVecBase2i get_sbs_right_size() const; INLINE int get_sbs_right_x_size() const; INLINE int get_sbs_right_y_size() const; INLINE bool has_size() const; diff --git a/panda/src/mathutil/boundingVolume.h b/panda/src/mathutil/boundingVolume.h index ef7663ad2f..3af3e7fa2d 100644 --- a/panda/src/mathutil/boundingVolume.h +++ b/panda/src/mathutil/boundingVolume.h @@ -56,12 +56,14 @@ PUBLISHED: INLINE_MATHUTIL bool extend_by(const BoundingVolume *vol); +public: // It might be nice to make these template member functions so we // could have true STL-style first/last iterators, but that's // impossible for virtual functions. bool around(const BoundingVolume **first, const BoundingVolume **last); +PUBLISHED: // The contains() functions return the union of one or more of these // bits. enum IntersectionFlags { diff --git a/panda/src/mathutil/geometricBoundingVolume.h b/panda/src/mathutil/geometricBoundingVolume.h index 768db6063d..4bd53591e3 100644 --- a/panda/src/mathutil/geometricBoundingVolume.h +++ b/panda/src/mathutil/geometricBoundingVolume.h @@ -36,6 +36,7 @@ PUBLISHED: INLINE_MATHUTIL bool extend_by(const GeometricBoundingVolume *vol); INLINE_MATHUTIL bool extend_by(const LPoint3 &point); +public: // It might be nice to make these template member functions so we // could have true STL-style first/last iterators, but that's // impossible for virtual functions. @@ -43,6 +44,7 @@ PUBLISHED: const GeometricBoundingVolume **last); INLINE_MATHUTIL bool around(const LPoint3 *first, const LPoint3 *last); +PUBLISHED: INLINE_MATHUTIL int contains(const GeometricBoundingVolume *vol) const; INLINE_MATHUTIL int contains(const LPoint3 &point) const; INLINE_MATHUTIL int contains(const LPoint3 &a, const LPoint3 &b) const;