Panda3D
lightAttrib.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 lightAttrib.I
10  * @author drose
11  * @date 2002-03-26
12  */
13 
14 /**
15  * Use LightAttrib::make() to construct a new LightAttrib object.
16  */
17 INLINE LightAttrib::
18 LightAttrib() : _off_all_lights(false), _num_non_ambient_lights(0) {
19 }
20 
21 /**
22  * Returns the number of lights that are turned on by the attribute.
23  */
24 INLINE size_t LightAttrib::
25 get_num_on_lights() const {
26  check_sorted();
27  return _sorted_on_lights.size();
28 }
29 
30 /**
31  * Returns the number of non-ambient lights that are turned on by this
32  * attribute.
33  */
34 INLINE size_t LightAttrib::
36  check_sorted();
37  return _num_non_ambient_lights;
38 }
39 
40 /**
41  * Returns the nth light turned on by the attribute, sorted in render order.
42  */
44 get_on_light(size_t n) const {
45  nassertr(n < _sorted_on_lights.size(), NodePath::fail());
46  return _sorted_on_lights[n];
47 }
48 
49 /**
50  * Returns true if the indicated light is turned on by the attrib, false
51  * otherwise.
52  */
53 INLINE bool LightAttrib::
54 has_on_light(const NodePath &light) const {
55  return _on_lights.find(light) != _on_lights.end();
56 }
57 
58 /**
59  * Returns true if any light is turned on by the attrib, false otherwise.
60  */
61 INLINE bool LightAttrib::
63  return !_on_lights.empty();
64 }
65 
66 /**
67  * Returns the number of lights that are turned off by the attribute.
68  */
69 INLINE size_t LightAttrib::
70 get_num_off_lights() const {
71  return _off_lights.size();
72 }
73 
74 /**
75  * Returns the nth light turned off by the attribute, sorted in arbitrary
76  * (pointer) order.
77  */
79 get_off_light(size_t n) const {
80  nassertr(n < _off_lights.size(), NodePath::fail());
81  return _off_lights[n];
82 }
83 
84 /**
85  * Returns true if the indicated light is turned off by the attrib, false
86  * otherwise.
87  */
88 INLINE bool LightAttrib::
89 has_off_light(const NodePath &light) const {
90  return _off_lights.find(light) != _off_lights.end() ||
91  (_off_all_lights && !has_on_light(light));
92 }
93 
94 /**
95  * Returns true if this attrib turns off all lights (although it may also turn
96  * some on).
97  */
98 INLINE bool LightAttrib::
99 has_all_off() const {
100  return _off_all_lights;
101 }
102 
103 /**
104  * Returns true if this is an identity attrib: it does not change the set of
105  * lights in use.
106  */
107 INLINE bool LightAttrib::
108 is_identity() const {
109  return _on_lights.empty() && _off_lights.empty() && !_off_all_lights;
110 }
111 
112 /**
113  * Makes sure that the on lights are still sorted by priority. It may become
114  * invalid if someone calls Light::set_priority().
115  */
116 INLINE void LightAttrib::
117 check_sorted() const {
118  if (_sort_seq != Light::get_sort_seq()) {
119  ((LightAttrib *)this)->sort_on_lights();
120  }
121 }
size_type_0 size() const
Returns the number of elements in the ordered vector.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
get_off_light
Returns the nth light turned off by the attribute, sorted in arbitrary (pointer) order.
Definition: lightAttrib.h:80
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
bool is_identity() const
Returns true if this is an identity attrib: it does not change the set of lights in use.
Definition: lightAttrib.I:108
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
Definition: nodePath.I:149
get_on_light
Returns the nth light turned on by the attribute, sorted in render order.
Definition: lightAttrib.h:74
bool has_on_light(const NodePath &light) const
Returns true if the indicated light is turned on by the attrib, false otherwise.
Definition: lightAttrib.I:54
size_t get_num_non_ambient_lights() const
Returns the number of non-ambient lights that are turned on by this attribute.
Definition: lightAttrib.I:35
static UpdateSeq get_sort_seq()
Returns a global sequence number that is incremented any time any Light in the world changes sort or ...
Definition: light.I:134
bool has_all_off() const
Returns true if this attrib turns off all lights (although it may also turn some on).
Definition: lightAttrib.I:99
bool has_off_light(const NodePath &light) const
Returns true if the indicated light is turned off by the attrib, false otherwise.
Definition: lightAttrib.I:89
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161
bool has_any_on_light() const
Returns true if any light is turned on by the attrib, false otherwise.
Definition: lightAttrib.I:62
Indicates which set of lights should be considered "on" to illuminate geometry at this level and belo...
Definition: lightAttrib.h:30