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  check_sorted();
46  nassertr(n < _sorted_on_lights.size(), NodePath::fail());
47  return _sorted_on_lights[n];
48 }
49 
50 /**
51  * Returns true if the indicated light is turned on by the attrib, false
52  * otherwise.
53  */
54 INLINE bool LightAttrib::
55 has_on_light(const NodePath &light) const {
56  return _on_lights.find(light) != _on_lights.end();
57 }
58 
59 /**
60  * Returns true if any light is turned on by the attrib, false otherwise.
61  */
62 INLINE bool LightAttrib::
63 has_any_on_light() const {
64  return !_on_lights.empty();
65 }
66 
67 /**
68  * Returns the number of lights that are turned off by the attribute.
69  */
70 INLINE size_t LightAttrib::
71 get_num_off_lights() const {
72  return _off_lights.size();
73 }
74 
75 /**
76  * Returns the nth light turned off by the attribute, sorted in arbitrary
77  * (pointer) order.
78  */
80 get_off_light(size_t n) const {
81  nassertr(n < _off_lights.size(), NodePath::fail());
82  return _off_lights[n];
83 }
84 
85 /**
86  * Returns true if the indicated light is turned off by the attrib, false
87  * otherwise.
88  */
89 INLINE bool LightAttrib::
90 has_off_light(const NodePath &light) const {
91  return _off_lights.find(light) != _off_lights.end() ||
92  (_off_all_lights && !has_on_light(light));
93 }
94 
95 /**
96  * Returns true if this attrib turns off all lights (although it may also turn
97  * some on).
98  */
99 INLINE bool LightAttrib::
100 has_all_off() const {
101  return _off_all_lights;
102 }
103 
104 /**
105  * Returns true if this is an identity attrib: it does not change the set of
106  * lights in use.
107  */
108 INLINE bool LightAttrib::
109 is_identity() const {
110  return _on_lights.empty() && _off_lights.empty() && !_off_all_lights;
111 }
112 
113 /**
114  * Makes sure that the on lights are still sorted by priority. It may become
115  * invalid if someone calls Light::set_priority().
116  */
117 INLINE void LightAttrib::
118 check_sorted() const {
119  if (_sort_seq != Light::get_sort_seq()) {
120  ((LightAttrib *)this)->sort_on_lights();
121  }
122 }
Indicates which set of lights should be considered "on" to illuminate geometry at this level and belo...
Definition: lightAttrib.h:30
get_off_light
Returns the nth light turned off by the attribute, sorted in arbitrary (pointer) order.
Definition: lightAttrib.h:80
bool has_all_off() const
Returns true if this attrib turns off all lights (although it may also turn some on).
Definition: lightAttrib.I:100
get_num_off_lights
Returns the number of lights that are turned off by the attribute.
Definition: lightAttrib.h:80
get_num_on_lights
Returns the number of lights that are turned on by the attribute.
Definition: lightAttrib.h:74
bool has_any_on_light() const
Returns true if any light is turned on by the attrib, false otherwise.
Definition: lightAttrib.I:63
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:90
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:55
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:109
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
get_on_light
Returns the nth light turned on by the attribute, sorted in render order.
Definition: lightAttrib.h:74
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
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:159
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
Definition: nodePath.I:149
size_type_0 size() const
Returns the number of elements in the ordered vector.
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.