Panda3D

clipPlaneAttrib.I

00001 // Filename: clipPlaneAttrib.I
00002 // Created by:  drose (11Jul02)
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 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: ClipPlaneAttrib::Constructor
00018 //       Access: Protected
00019 //  Description: Use ClipPlaneAttrib::make() to construct a new
00020 //               ClipPlaneAttrib object.
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE ClipPlaneAttrib::
00023 ClipPlaneAttrib() {
00024   _off_all_planes = false;
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: ClipPlaneAttrib::Copy Constructor
00029 //       Access: Protected
00030 //  Description: Use ClipPlaneAttrib::make() to construct a new
00031 //               ClipPlaneAttrib object.  The copy constructor is only
00032 //               defined to facilitate methods like add_on_plane().
00033 ////////////////////////////////////////////////////////////////////
00034 INLINE ClipPlaneAttrib::
00035 ClipPlaneAttrib(const ClipPlaneAttrib &copy) :
00036   _on_planes(copy._on_planes),
00037   _off_planes(copy._off_planes),
00038   _off_all_planes(copy._off_all_planes)
00039 {
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: ClipPlaneAttrib::get_num_on_planes
00044 //       Access: Published
00045 //  Description: Returns the number of planes that are enabled by
00046 //               the attribute.
00047 ////////////////////////////////////////////////////////////////////
00048 INLINE int ClipPlaneAttrib::
00049 get_num_on_planes() const {
00050   return _on_planes.size();
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: ClipPlaneAttrib::get_on_plane
00055 //       Access: Published
00056 //  Description: Returns the nth plane enabled by the attribute,
00057 //               sorted in render order.
00058 ////////////////////////////////////////////////////////////////////
00059 INLINE NodePath ClipPlaneAttrib::
00060 get_on_plane(int n) const {
00061   nassertr(n >= 0 && n < (int)_on_planes.size(), NodePath::fail());
00062   return _on_planes[n];
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: ClipPlaneAttrib::has_on_plane
00067 //       Access: Published
00068 //  Description: Returns true if the indicated plane is enabled by
00069 //               the attrib, false otherwise.
00070 ////////////////////////////////////////////////////////////////////
00071 INLINE bool ClipPlaneAttrib::
00072 has_on_plane(const NodePath &plane) const {
00073   return _on_planes.find(plane) != _on_planes.end();
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: ClipPlaneAttrib::get_num_off_planes
00078 //       Access: Published
00079 //  Description: Returns the number of planes that are disabled by
00080 //               the attribute.
00081 ////////////////////////////////////////////////////////////////////
00082 INLINE int ClipPlaneAttrib::
00083 get_num_off_planes() const {
00084   return _off_planes.size();
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: ClipPlaneAttrib::get_off_plane
00089 //       Access: Published
00090 //  Description: Returns the nth plane disabled by the attribute,
00091 //               sorted in arbitrary (pointer) order.
00092 ////////////////////////////////////////////////////////////////////
00093 INLINE NodePath ClipPlaneAttrib::
00094 get_off_plane(int n) const {
00095   nassertr(n >= 0 && n < (int)_off_planes.size(), NodePath::fail());
00096   return _off_planes[n];
00097 }
00098 
00099 ////////////////////////////////////////////////////////////////////
00100 //     Function: ClipPlaneAttrib::has_off_plane
00101 //       Access: Published
00102 //  Description: Returns true if the indicated plane is disabled by
00103 //               the attrib, false otherwise.
00104 ////////////////////////////////////////////////////////////////////
00105 INLINE bool ClipPlaneAttrib::
00106 has_off_plane(const NodePath &plane) const {
00107   return _off_planes.find(plane) != _off_planes.end() ||
00108     (_off_all_planes && !has_on_plane(plane));
00109 }
00110 
00111 ////////////////////////////////////////////////////////////////////
00112 //     Function: ClipPlaneAttrib::has_all_off
00113 //       Access: Published
00114 //  Description: Returns true if this attrib disables all planes
00115 //               (although it may also enable some).
00116 ////////////////////////////////////////////////////////////////////
00117 INLINE bool ClipPlaneAttrib::
00118 has_all_off() const {
00119   return _off_all_planes;
00120 }
00121 
00122 ////////////////////////////////////////////////////////////////////
00123 //     Function: ClipPlaneAttrib::is_identity
00124 //       Access: Published
00125 //  Description: Returns true if this is an identity attrib: it does
00126 //               not change the set of planes in use.
00127 ////////////////////////////////////////////////////////////////////
00128 INLINE bool ClipPlaneAttrib::
00129 is_identity() const {
00130   return _on_planes.empty() && _off_planes.empty() && !_off_all_planes;
00131 }
00132 
00133 ////////////////////////////////////////////////////////////////////
00134 //     Function: ClipPlaneAttrib::check_filtered
00135 //       Access: Private
00136 //  Description: Confirms whether the _filtered table is still valid.
00137 //               It may become invalid if someone calls
00138 //               PlaneNode::set_priority().
00139 //
00140 //               If the table is invalid, transparently empties it
00141 //               before returning.
00142 ////////////////////////////////////////////////////////////////////
00143 INLINE void ClipPlaneAttrib::
00144 check_filtered() const {
00145   if (_sort_seq != PlaneNode::get_sort_seq()) {
00146     ((ClipPlaneAttrib *)this)->sort_on_planes();
00147   }
00148 }
 All Classes Functions Variables Enumerations