Panda3D
planeNode.I
1 // Filename: planeNode.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: PlaneNode::CData::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE PlaneNode::CData::
22 CData() :
23  _viz_scale(100.0f)
24 {
25  // The default plane (perpendicular to the Z-axis) is used until
26  // another one is specified explicitly.
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: PlaneNode::CData::Copy Constructor
31 // Access: Public
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 INLINE PlaneNode::CData::
35 CData(const PlaneNode::CData &copy) :
36  _plane(copy._plane),
37  _front_viz(copy._front_viz),
38  _back_viz(copy._back_viz),
39  _viz_scale(copy._viz_scale)
40 {
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: PlaneNode::set_plane
45 // Access: Public
46 // Description: Sets the particular plane represented by the
47 // PlaneNode.
48 ////////////////////////////////////////////////////////////////////
49 INLINE void PlaneNode::
50 set_plane(const LPlane &plane) {
51  CDWriter cdata(_cycler);
52  if (cdata->_plane != plane) {
53  cdata->_plane = plane;
54  cdata->_front_viz = NULL;
55  cdata->_back_viz = NULL;
56  }
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: PlaneNode::get_plane
61 // Access: Public
62 // Description: Returns the plane represented by the PlaneNode.
63 ////////////////////////////////////////////////////////////////////
64 INLINE const LPlane &PlaneNode::
65 get_plane() const {
66  CDReader cdata(_cycler);
67  return cdata->_plane;
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function: PlaneNode::set_viz_scale
72 // Access: Public
73 // Description: Specifies the size of the visual representation of
74 // the plane that is drawn if the PlaneNode is shown.
75 ////////////////////////////////////////////////////////////////////
76 INLINE void PlaneNode::
77 set_viz_scale(PN_stdfloat viz_scale) {
78  CDWriter cdata(_cycler);
79  if (cdata->_viz_scale != viz_scale) {
80  cdata->_viz_scale = viz_scale;
81  cdata->_front_viz = NULL;
82  cdata->_back_viz = NULL;
83  }
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: PlaneNode::get_viz_scale
88 // Access: Public
89 // Description: Returns the size of the visual representation of
90 // the plane that is drawn if the PlaneNode is shown.
91 ////////////////////////////////////////////////////////////////////
92 INLINE PN_stdfloat PlaneNode::
93 get_viz_scale() const {
94  CDReader cdata(_cycler);
95  return cdata->_viz_scale;
96 }
97 
98 ////////////////////////////////////////////////////////////////////
99 // Function: PlaneNode::set_priority
100 // Access: Published
101 // Description: Changes the relative importance of this PlaneNode
102 // (when it is used as a clip plane) relative to the
103 // other clip planes that are applied simultaneously.
104 //
105 // The priority number is used to decide which of the
106 // requested clip planes are to be activated when more
107 // clip planes are requested than the hardware will
108 // support. The highest-priority n planes are selected
109 // for rendering.
110 //
111 // This is similar to TextureStage::set_priority().
112 ////////////////////////////////////////////////////////////////////
113 INLINE void PlaneNode::
114 set_priority(int priority) {
115  _priority = priority;
116 
117  // Update the global flag to indicate that all ClipPlaneAttribs in
118  // the world must now re-sort their lists.
119  _sort_seq++;
120 }
121 
122 ////////////////////////////////////////////////////////////////////
123 // Function: PlaneNode::get_priority
124 // Access: Published
125 // Description: Returns the priority associated with this clip
126 // plane. See set_priority().
127 ////////////////////////////////////////////////////////////////////
128 INLINE int PlaneNode::
129 get_priority() const {
130  return _priority;
131 }
132 
133 ////////////////////////////////////////////////////////////////////
134 // Function: PlaneNode::set_clip_effect
135 // Access: Published
136 // Description: Specifies the sort of things this plane will actually
137 // clip (when it is used as a clip plane). This is a
138 // bitmask union of ClipEffect values. If it includes
139 // CE_visible, then it will clip visible geometry; if it
140 // includes CE_collision, then it will clip collision
141 // polygons. If it includes neither bit, it will still
142 // affect culling, but objects will either be wholly
143 // behind the clipping plane, or wholly present.
144 ////////////////////////////////////////////////////////////////////
145 INLINE void PlaneNode::
146 set_clip_effect(int clip_effect) {
147  _clip_effect = clip_effect;
148 }
149 
150 ////////////////////////////////////////////////////////////////////
151 // Function: PlaneNode::get_clip_effect
152 // Access: Published
153 // Description: Returns the clip_effect bits for this clip plane.
154 // See set_clip_effect().
155 ////////////////////////////////////////////////////////////////////
156 INLINE int PlaneNode::
158  return _clip_effect;
159 }
160 
161 ////////////////////////////////////////////////////////////////////
162 // Function: PlaneNode::get_sort_seq
163 // Access: Public, Static
164 // Description: Returns a global sequence number that is incremented
165 // any time any PlaneNode in the world changes sort
166 // or priority. This is used by ClipPlaneAttrib to
167 // determine when it is necessary to re-sort its
168 // internal array of stages.
169 ////////////////////////////////////////////////////////////////////
170 INLINE UpdateSeq PlaneNode::
172  return _sort_seq;
173 }
174 
void set_plane(const LPlane &plane)
Sets the particular plane represented by the PlaneNode.
Definition: planeNode.I:50
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
void set_viz_scale(PN_stdfloat viz_scale)
Specifies the size of the visual representation of the plane that is drawn if the PlaneNode is shown...
Definition: planeNode.I:77
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
const LPlane & get_plane() const
Returns the plane represented by the PlaneNode.
Definition: planeNode.I:65
PN_stdfloat get_viz_scale() const
Returns the size of the visual representation of the plane that is drawn if the PlaneNode is shown...
Definition: planeNode.I:93
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
int get_priority() const
Returns the priority associated with this clip plane.
Definition: planeNode.I:129
void set_priority(int priority)
Changes the relative importance of this PlaneNode (when it is used as a clip plane) relative to the o...
Definition: planeNode.I:114
void set_clip_effect(int clip_effect)
Specifies the sort of things this plane will actually clip (when it is used as a clip plane)...
Definition: planeNode.I:146
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43
int get_clip_effect() const
Returns the clip_effect bits for this clip plane.
Definition: planeNode.I:157