2
0
David Rose 20 жил өмнө
parent
commit
dd28bafc68

+ 2 - 2
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)

+ 2 - 1
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"

+ 39 - 6
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;
+}

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