Browse Source

Unexpose BoundingVolume::around, add GraphicsOutput::get_fb_size

rdb 10 years ago
parent
commit
f1ea25bfb1

+ 48 - 0
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

+ 3 - 0
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;

+ 2 - 0
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 {

+ 2 - 0
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;