Panda3D
 All Classes Functions Variables Enumerations
clipPlaneAttrib.I
1 // Filename: clipPlaneAttrib.I
2 // Created by: drose (11Jul02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: ClipPlaneAttrib::Constructor
18 // Access: Protected
19 // Description: Use ClipPlaneAttrib::make() to construct a new
20 // ClipPlaneAttrib object.
21 ////////////////////////////////////////////////////////////////////
22 INLINE ClipPlaneAttrib::
23 ClipPlaneAttrib() {
24  _off_all_planes = false;
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: ClipPlaneAttrib::Copy Constructor
29 // Access: Protected
30 // Description: Use ClipPlaneAttrib::make() to construct a new
31 // ClipPlaneAttrib object. The copy constructor is only
32 // defined to facilitate methods like add_on_plane().
33 ////////////////////////////////////////////////////////////////////
34 INLINE ClipPlaneAttrib::
35 ClipPlaneAttrib(const ClipPlaneAttrib &copy) :
36  _on_planes(copy._on_planes),
37  _off_planes(copy._off_planes),
38  _off_all_planes(copy._off_all_planes)
39 {
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: ClipPlaneAttrib::get_num_on_planes
44 // Access: Published
45 // Description: Returns the number of planes that are enabled by
46 // the attribute.
47 ////////////////////////////////////////////////////////////////////
48 INLINE int ClipPlaneAttrib::
50  return _on_planes.size();
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: ClipPlaneAttrib::get_on_plane
55 // Access: Published
56 // Description: Returns the nth plane enabled by the attribute,
57 // sorted in render order.
58 ////////////////////////////////////////////////////////////////////
60 get_on_plane(int n) const {
61  nassertr(n >= 0 && n < (int)_on_planes.size(), NodePath::fail());
62  return _on_planes[n];
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: ClipPlaneAttrib::has_on_plane
67 // Access: Published
68 // Description: Returns true if the indicated plane is enabled by
69 // the attrib, false otherwise.
70 ////////////////////////////////////////////////////////////////////
71 INLINE bool ClipPlaneAttrib::
72 has_on_plane(const NodePath &plane) const {
73  return _on_planes.find(plane) != _on_planes.end();
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: ClipPlaneAttrib::get_num_off_planes
78 // Access: Published
79 // Description: Returns the number of planes that are disabled by
80 // the attribute.
81 ////////////////////////////////////////////////////////////////////
82 INLINE int ClipPlaneAttrib::
84  return _off_planes.size();
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: ClipPlaneAttrib::get_off_plane
89 // Access: Published
90 // Description: Returns the nth plane disabled by the attribute,
91 // sorted in arbitrary (pointer) order.
92 ////////////////////////////////////////////////////////////////////
94 get_off_plane(int n) const {
95  nassertr(n >= 0 && n < (int)_off_planes.size(), NodePath::fail());
96  return _off_planes[n];
97 }
98 
99 ////////////////////////////////////////////////////////////////////
100 // Function: ClipPlaneAttrib::has_off_plane
101 // Access: Published
102 // Description: Returns true if the indicated plane is disabled by
103 // the attrib, false otherwise.
104 ////////////////////////////////////////////////////////////////////
105 INLINE bool ClipPlaneAttrib::
106 has_off_plane(const NodePath &plane) const {
107  return _off_planes.find(plane) != _off_planes.end() ||
108  (_off_all_planes && !has_on_plane(plane));
109 }
110 
111 ////////////////////////////////////////////////////////////////////
112 // Function: ClipPlaneAttrib::has_all_off
113 // Access: Published
114 // Description: Returns true if this attrib disables all planes
115 // (although it may also enable some).
116 ////////////////////////////////////////////////////////////////////
117 INLINE bool ClipPlaneAttrib::
118 has_all_off() const {
119  return _off_all_planes;
120 }
121 
122 ////////////////////////////////////////////////////////////////////
123 // Function: ClipPlaneAttrib::is_identity
124 // Access: Published
125 // Description: Returns true if this is an identity attrib: it does
126 // not change the set of planes in use.
127 ////////////////////////////////////////////////////////////////////
128 INLINE bool ClipPlaneAttrib::
129 is_identity() const {
130  return _on_planes.empty() && _off_planes.empty() && !_off_all_planes;
131 }
132 
133 ////////////////////////////////////////////////////////////////////
134 // Function: ClipPlaneAttrib::check_filtered
135 // Access: Private
136 // Description: Confirms whether the _filtered table is still valid.
137 // It may become invalid if someone calls
138 // PlaneNode::set_priority().
139 //
140 // If the table is invalid, transparently empties it
141 // before returning.
142 ////////////////////////////////////////////////////////////////////
143 INLINE void ClipPlaneAttrib::
144 check_filtered() const {
145  if (_sort_seq != PlaneNode::get_sort_seq()) {
146  ((ClipPlaneAttrib *)this)->sort_on_planes();
147  }
148 }
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
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 has_on_plane(const NodePath &plane) const
Returns true if the indicated plane is enabled by the attrib, false otherwise.
bool has_off_plane(const NodePath &plane) const
Returns true if the indicated plane is disabled by the attrib, false otherwise.
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:171
int get_num_off_planes() const
Returns the number of planes that are disabled by the attribute.
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
Definition: nodePath.I:185
bool is_identity() const
Returns true if this is an identity attrib: it does not change the set of planes in use...
NodePath get_off_plane(int n) const
Returns the nth plane disabled by the attribute, sorted in arbitrary (pointer) order.
NodePath get_on_plane(int n) const
Returns the nth plane enabled by the attribute, sorted in render order.
int get_num_on_planes() const
Returns the number of planes that are enabled by the attribute.
size_type_0 size() const
Returns the number of elements in the ordered vector.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165