From dd28bafc685be48cec7c8882220ee96f0e65bc8c Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 6 Sep 2005 18:18:56 +0000 Subject: [PATCH] build on linux --- panda/src/gobj/shader.cxx | 4 +-- panda/src/mathutil/boundingPlane.h | 3 +- panda/src/mathutil/boundingSphere.cxx | 45 +++++++++++++++++++++++---- panda/src/mathutil/boundingSphere.h | 1 + 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 6ea7f40a7f..72e7a992a0 100755 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -122,7 +122,7 @@ parse_rest(string &result) { //////////////////////////////////////////////////////////////////// bool Shader:: parse_eof(void) { - return _text.size() == _parse; + return (int)_text.size() == _parse; } //////////////////////////////////////////////////////////////////// @@ -131,7 +131,7 @@ parse_eof(void) { // Description: Allocates an integer index to the given // shader parameter name. //////////////////////////////////////////////////////////////////// -INLINE int Shader:: +int Shader:: arg_index(const string &id) { for (int i=0; i<(int)(_args.size()); i++) if (_args[i] == id) diff --git a/panda/src/mathutil/boundingPlane.h b/panda/src/mathutil/boundingPlane.h index f9590e4fca..67b48d8196 100644 --- a/panda/src/mathutil/boundingPlane.h +++ b/panda/src/mathutil/boundingPlane.h @@ -62,7 +62,6 @@ protected: private: Planef _plane; - public: static TypeHandle get_class_type() { return _type_handle; @@ -79,6 +78,8 @@ public: private: static TypeHandle _type_handle; + + friend class BoundingSphere; }; #include "boundingPlane.I" diff --git a/panda/src/mathutil/boundingSphere.cxx b/panda/src/mathutil/boundingSphere.cxx index 7d8f182980..e74e125846 100644 --- a/panda/src/mathutil/boundingSphere.cxx +++ b/panda/src/mathutil/boundingSphere.cxx @@ -63,7 +63,7 @@ xform(const LMatrix4f &mat) { if (!is_empty() && !is_infinite()) { // First, determine the longest axis of the matrix, in case it - // contains a non-proportionate scale. + // contains a non-uniform scale. /* LVector3f x,y,z; @@ -77,18 +77,18 @@ xform(const LMatrix4f &mat) { */ float xd,yd,zd,scale; - #define ROW_DOTTED(mat,ROWNUM) \ +#define ROW_DOTTED(mat,ROWNUM) \ (mat._m.m._##ROWNUM##0*mat._m.m._##ROWNUM##0 + \ mat._m.m._##ROWNUM##1*mat._m.m._##ROWNUM##1 + \ mat._m.m._##ROWNUM##2*mat._m.m._##ROWNUM##2) - + xd = ROW_DOTTED(mat,0); yd = ROW_DOTTED(mat,1); zd = ROW_DOTTED(mat,2); - scale = max(xd,yd); - scale = max(scale,zd); - scale = sqrtf(scale); + scale = max(xd,yd); + scale = max(scale,zd); + scale = sqrtf(scale); // Transform the radius _radius *= scale; @@ -439,6 +439,13 @@ contains_lineseg(const LPoint3f &a, const LPoint3f &b) const { } } +//////////////////////////////////////////////////////////////////// +// Function: BoundingSphere::contains_sphere +// Access: Protected, Virtual +// Description: Double-dispatch support: called by contains_other() +// when the type we're testing for intersection is known +// to be a sphere. +//////////////////////////////////////////////////////////////////// int BoundingSphere:: contains_sphere(const BoundingSphere *sphere) const { nassertr(!is_empty() && !is_infinite(), 0); @@ -462,12 +469,38 @@ contains_sphere(const BoundingSphere *sphere) const { } } +//////////////////////////////////////////////////////////////////// +// Function: BoundingSphere::contains_hexahedron +// Access: Protected, Virtual +// Description: Double-dispatch support: called by contains_other() +// when the type we're testing for intersection is known +// to be a hexahedron. +//////////////////////////////////////////////////////////////////// int BoundingSphere:: contains_hexahedron(const BoundingHexahedron *hexahedron) const { return hexahedron->contains_sphere(this) & ~IF_all; } +//////////////////////////////////////////////////////////////////// +// Function: BoundingSphere::contains_line +// Access: Protected, Virtual +// Description: Double-dispatch support: called by contains_other() +// when the type we're testing for intersection is known +// to be a line. +//////////////////////////////////////////////////////////////////// int BoundingSphere:: contains_line(const BoundingLine *line) const { return line->contains_sphere(this) & ~IF_all; } + +//////////////////////////////////////////////////////////////////// +// Function: BoundingSphere::contains_plane +// Access: Protected, Virtual +// Description: Double-dispatch support: called by contains_other() +// when the type we're testing for intersection is known +// to be a plane. +//////////////////////////////////////////////////////////////////// +int BoundingSphere:: +contains_plane(const BoundingPlane *plane) const { + return plane->contains_sphere(this) & ~IF_all; +} diff --git a/panda/src/mathutil/boundingSphere.h b/panda/src/mathutil/boundingSphere.h index 56ce32bd4b..a614eb8b21 100644 --- a/panda/src/mathutil/boundingSphere.h +++ b/panda/src/mathutil/boundingSphere.h @@ -76,6 +76,7 @@ protected: virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const; virtual int contains_sphere(const BoundingSphere *sphere) const; virtual int contains_line(const BoundingLine *line) const; + virtual int contains_plane(const BoundingPlane *plane) const; private: LPoint3f _center;