Panda3D
clipPlaneAttrib.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file clipPlaneAttrib.I
10  * @author drose
11  * @date 2002-07-11
12  */
13 
14 /**
15  * Use ClipPlaneAttrib::make() to construct a new ClipPlaneAttrib object.
16  */
17 INLINE ClipPlaneAttrib::
18 ClipPlaneAttrib() {
19  _off_all_planes = false;
20 }
21 
22 /**
23  * Use ClipPlaneAttrib::make() to construct a new ClipPlaneAttrib object. The
24  * copy constructor is only defined to facilitate methods like add_on_plane().
25  */
26 INLINE ClipPlaneAttrib::
27 ClipPlaneAttrib(const ClipPlaneAttrib &copy) :
28  _on_planes(copy._on_planes),
29  _off_planes(copy._off_planes),
30  _off_all_planes(copy._off_all_planes)
31 {
32 }
33 
34 /**
35  * Returns the number of planes that are enabled by the attribute.
36  */
37 INLINE int ClipPlaneAttrib::
38 get_num_on_planes() const {
39  return _on_planes.size();
40 }
41 
42 /**
43  * Returns the nth plane enabled by the attribute, sorted in render order.
44  */
46 get_on_plane(int n) const {
47  nassertr(n >= 0 && n < (int)_on_planes.size(), NodePath::fail());
48  return _on_planes[n];
49 }
50 
51 /**
52  * Returns true if the indicated plane is enabled by the attrib, false
53  * otherwise.
54  */
55 INLINE bool ClipPlaneAttrib::
56 has_on_plane(const NodePath &plane) const {
57  return _on_planes.find(plane) != _on_planes.end();
58 }
59 
60 /**
61  * Returns the number of planes that are disabled by the attribute.
62  */
63 INLINE int ClipPlaneAttrib::
64 get_num_off_planes() const {
65  return _off_planes.size();
66 }
67 
68 /**
69  * Returns the nth plane disabled by the attribute, sorted in arbitrary
70  * (pointer) order.
71  */
73 get_off_plane(int n) const {
74  nassertr(n >= 0 && n < (int)_off_planes.size(), NodePath::fail());
75  return _off_planes[n];
76 }
77 
78 /**
79  * Returns true if the indicated plane is disabled by the attrib, false
80  * otherwise.
81  */
82 INLINE bool ClipPlaneAttrib::
83 has_off_plane(const NodePath &plane) const {
84  return _off_planes.find(plane) != _off_planes.end() ||
85  (_off_all_planes && !has_on_plane(plane));
86 }
87 
88 /**
89  * Returns true if this attrib disables all planes (although it may also
90  * enable some).
91  */
92 INLINE bool ClipPlaneAttrib::
93 has_all_off() const {
94  return _off_all_planes;
95 }
96 
97 /**
98  * Returns true if this is an identity attrib: it does not change the set of
99  * planes in use.
100  */
101 INLINE bool ClipPlaneAttrib::
102 is_identity() const {
103  return _on_planes.empty() && _off_planes.empty() && !_off_all_planes;
104 }
105 
106 /**
107  * Confirms whether the _filtered table is still valid. It may become invalid
108  * if someone calls PlaneNode::set_priority().
109  *
110  * If the table is invalid, transparently empties it before returning.
111  */
112 INLINE void ClipPlaneAttrib::
113 check_filtered() const {
114  if (_sort_seq != PlaneNode::get_sort_seq()) {
115  ((ClipPlaneAttrib *)this)->sort_on_planes();
116  }
117 }
bool has_off_plane(const NodePath &plane) const
Returns true if the indicated plane is disabled by the attrib, false otherwise.
size_type_0 size() const
Returns the number of elements in the ordered vector.
bool is_identity() const
Returns true if this is an identity attrib: it does not change the set of planes in use.
bool has_all_off() const
Returns true if this attrib disables all planes (although it may also enable some).
This functions similarly to a LightAttrib.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
get_off_plane
Returns the nth plane disabled by the attribute, sorted in arbitrary (pointer) order.
static UpdateSeq get_sort_seq()
Returns a global sequence number that is incremented any time any PlaneNode in the world changes sort...
Definition: planeNode.I:138
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
Definition: nodePath.I:149
bool has_on_plane(const NodePath &plane) const
Returns true if the indicated plane is enabled by the attrib, false otherwise.
get_on_plane
Returns the nth plane enabled by the attribute, sorted in render order.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161