00001 // Filename: finiteBoundingVolume.cxx 00002 // Created by: drose (02Oct99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "finiteBoundingVolume.h" 00016 #include "boundingBox.h" 00017 00018 TypeHandle FiniteBoundingVolume::_type_handle; 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: FiniteBoundingVolume::get_volume 00022 // Access: Public, Virtual 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 PN_stdfloat FiniteBoundingVolume:: 00026 get_volume() const { 00027 nassertr(!is_infinite(), 0.0f); 00028 if (is_empty()) { 00029 return 0.0f; 00030 } 00031 00032 mathutil_cat.warning() 00033 << get_type() << "::get_volume() called\n"; 00034 00035 // We don't know how to compute the volume of this shape correctly; 00036 // just calculate the volume of its containing box. 00037 BoundingBox box(get_min(), get_max()); 00038 box.local_object(); 00039 return box.get_volume(); 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: FiniteBoundingVolume::as_finite_bounding_volume 00044 // Access: Public, Virtual 00045 // Description: Virtual downcast method. Returns this object as a 00046 // pointer of the indicated type, if it is in fact that 00047 // type. Returns NULL if it is not that type. 00048 //////////////////////////////////////////////////////////////////// 00049 const FiniteBoundingVolume *FiniteBoundingVolume:: 00050 as_finite_bounding_volume() const { 00051 return this; 00052 } 00053 00054 //////////////////////////////////////////////////////////////////// 00055 // Function: FiniteBoundingVolume::around_lines 00056 // Access: Protected, Virtual 00057 // Description: Double-dispatch support: called by around_other() 00058 // when the type of the first element in the list is 00059 // known to be a nonempty line. 00060 //////////////////////////////////////////////////////////////////// 00061 bool FiniteBoundingVolume:: 00062 around_lines(const BoundingVolume **, const BoundingVolume **) { 00063 _flags = F_infinite; 00064 00065 // Since it's a FiniteBoundingVolume, we can't do any better than 00066 // making it infinite. So we return true. 00067 return true; 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: FiniteBoundingVolume::around_planes 00072 // Access: Protected, Virtual 00073 // Description: Double-dispatch support: called by around_other() 00074 // when the type of the first element in the list is 00075 // known to be a nonempty plane. 00076 //////////////////////////////////////////////////////////////////// 00077 bool FiniteBoundingVolume:: 00078 around_planes(const BoundingVolume **, const BoundingVolume **) { 00079 _flags = F_infinite; 00080 00081 // Since it's a FiniteBoundingVolume, we can't do any better than 00082 // making it infinite. So we return true. 00083 return true; 00084 }