diff --git a/panda/src/mathutil/boundingBox.I b/panda/src/mathutil/boundingBox.I index 2b595b5794..9887d75860 100644 --- a/panda/src/mathutil/boundingBox.I +++ b/panda/src/mathutil/boundingBox.I @@ -114,3 +114,17 @@ get_plane(int n) const { get_point(plane_def[n][1]), get_point(plane_def[n][2])); } + +//////////////////////////////////////////////////////////////////// +// Function: BoundingBox::set_min_max +// Access: Published +// Description: Sets the min and max point of the rectangular solid. +//////////////////////////////////////////////////////////////////// +INLINE_MATHUTIL void BoundingBox:: +set_min_max(const LPoint3 &min, const LPoint3 &max) { + nassertv(!min.is_nan() && !max.is_nan()); + nassertv(_min[0] <= _max[0] && _min[1] <= _max[1] && _min[2] <= _max[2]); + _min = min; + _max = max; + _flags = 0; +} diff --git a/panda/src/mathutil/boundingBox.h b/panda/src/mathutil/boundingBox.h index d816e69a58..8d76955e8e 100644 --- a/panda/src/mathutil/boundingBox.h +++ b/panda/src/mathutil/boundingBox.h @@ -46,6 +46,7 @@ public: virtual void output(ostream &out) const; + PUBLISHED: INLINE_MATHUTIL int get_num_points() const; INLINE_MATHUTIL LPoint3 get_point(int n) const; @@ -54,6 +55,8 @@ PUBLISHED: INLINE_MATHUTIL LPlane get_plane(int n) const; MAKE_SEQ(get_planes, get_num_planes, get_plane); + INLINE_MATHUTIL void set_min_max(const LPoint3 &min, const LPoint3 &max); + public: // Inline accessors for speed. INLINE_MATHUTIL const LPoint3 &get_minq() const; diff --git a/panda/src/mathutil/boundingSphere.I b/panda/src/mathutil/boundingSphere.I index c42c7a40e4..708753ec3d 100644 --- a/panda/src/mathutil/boundingSphere.I +++ b/panda/src/mathutil/boundingSphere.I @@ -19,7 +19,7 @@ // Description: Constructs an empty sphere. //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL BoundingSphere:: -BoundingSphere() { +BoundingSphere() : _center(0) { } //////////////////////////////////////////////////////////////////// @@ -44,7 +44,6 @@ BoundingSphere(const LPoint3 ¢er, PN_stdfloat radius) : //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL LPoint3 BoundingSphere:: get_center() const { - nassertr(!is_empty(), LPoint3::zero()); nassertr(!is_infinite(), LPoint3::zero()); return _center; } @@ -61,3 +60,25 @@ get_radius() const { return _radius; } +//////////////////////////////////////////////////////////////////// +// Function: BoundingSphere::set_center +// Access: Published +// Description: Sets the center point of the sphere. +//////////////////////////////////////////////////////////////////// +INLINE_MATHUTIL void BoundingSphere:: +set_center(const LPoint3 ¢er) { + nassertv(!center.is_nan()); + _center = center; +} + +//////////////////////////////////////////////////////////////////// +// Function: BoundingSphere::set_radius +// Access: Published +// Description: Sets the radius of the sphere. +//////////////////////////////////////////////////////////////////// +INLINE_MATHUTIL void BoundingSphere:: +set_radius(PN_stdfloat radius) { + nassertv(!cnan(radius)); + _radius = radius; + _flags = 0; +} diff --git a/panda/src/mathutil/boundingSphere.h b/panda/src/mathutil/boundingSphere.h index d5b8854763..26e78209cb 100644 --- a/panda/src/mathutil/boundingSphere.h +++ b/panda/src/mathutil/boundingSphere.h @@ -47,6 +47,10 @@ PUBLISHED: INLINE_MATHUTIL LPoint3 get_center() const; INLINE_MATHUTIL PN_stdfloat get_radius() const; + INLINE_MATHUTIL void set_center(const LPoint3 ¢er); + INLINE_MATHUTIL void set_radius(PN_stdfloat radius); + + public: virtual const BoundingSphere *as_bounding_sphere() const;