Panda3D
Loading...
Searching...
No Matches
sliderTable.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 sliderTable.I
10 * @author drose
11 * @date 2005-03-28
12 */
13
14/**
15 * Returns true if this table has been registered. Once it has been
16 * registered, the set of sliders in a SliderTable may not be further
17 * modified; but it must be registered before it can be assigned to a Geom.
18 */
19INLINE bool SliderTable::
20is_registered() const {
21 return _is_registered;
22}
23
24/**
25 * Registers a SliderTable for use. This is similar to
26 * GeomVertexFormat::register_format(). Once registered, a SliderTable may no
27 * longer be modified (although the individual VertexSlider objects may modify
28 * their reported sliders).
29 *
30 * This must be called before a table may be used in a Geom. After this call,
31 * you should discard the original pointer you passed in (which may or may not
32 * now be invalid) and let its reference count decrement normally; you should
33 * use only the returned value from this point on.
34 */
35INLINE CPT(SliderTable) SliderTable::
36register_table(const SliderTable *table) {
37 // We don't actually bother adding the table object to a registry. This
38 // means there may be multiple copies of identical registered SliderTables.
39 // Big deal. We can always go back and make a registry later if we really
40 // need it.
41 if (table->is_registered()) {
42 return table;
43 }
44
45 ((SliderTable *)table)->do_register();
46 return table;
47}
48
49/**
50 * Returns the number of sliders in the table.
51 */
52INLINE size_t SliderTable::
53get_num_sliders() const {
54 return _sliders.size();
55}
56
57/**
58 * Returns the nth slider in the table.
59 */
60INLINE const VertexSlider *SliderTable::
61get_slider(size_t n) const {
62 nassertr(n < _sliders.size(), nullptr);
63 return _sliders[n]._slider;
64}
65
66/**
67 * Returns the set of rows (vertices) governed by the nth slider in the table.
68 */
70get_slider_rows(size_t n) const {
71 nassertr(n < _sliders.size(), _empty_array);
72 return _sliders[n]._rows;
73}
74
75/**
76 * Returns a list of slider indices that represent the list of sliders with
77 * the indicated name, or an empty SparseArray if no slider in the table has
78 * that name.
79 */
81find_sliders(const InternalName *name) const {
82 SlidersByName::const_iterator sni;
83 sni = _sliders_by_name.find(name);
84 if (sni != _sliders_by_name.end()) {
85 return (*sni).second;
86 }
87 return _empty_array;
88}
89
90/**
91 * Returns true if the table has at least one slider by the indicated name,
92 * false otherwise.
93 */
94INLINE bool SliderTable::
95has_slider(const InternalName *name) const {
96 return (!find_sliders(name).is_zero());
97}
98
99/**
100 * Returns true if the table has no sliders, false if it has at least one.
101 */
102INLINE bool SliderTable::
103is_empty() const {
104 return _sliders.empty();
105}
106
107/**
108 * Returns a sequence number that's guaranteed to change at least when any
109 * VertexSliders in the table change. (However, this is only true for a
110 * registered table. An unregistered table may or may not reflect an update
111 * here when a VertexSlider changes.)
112 */
114get_modified(Thread *current_thread) const {
115 CDReader cdata(_cycler, current_thread);
116 return cdata->_modified;
117}
118
119/**
120 * Called internally whenever a nested VertexSlider reports that it has been
121 * modified.
122 */
123INLINE void SliderTable::
124update_modified(UpdateSeq modified, Thread *current_thread) {
125 CDWriter cdata(_cycler, true, current_thread);
126 cdata->_modified = modified;
127}
128
129/**
130 *
131 */
132INLINE SliderTable::CData::
133CData() {
134}
135
136/**
137 *
138 */
139INLINE SliderTable::CData::
140CData(const SliderTable::CData &copy) :
141 _modified(copy._modified)
142{
143}
Encodes a string name in a hash table, mapping it to a pointer.
Stores the total set of VertexSliders that the vertices in a particular GeomVertexData object might d...
Definition sliderTable.h:37
bool is_registered() const
Returns true if this table has been registered.
Definition sliderTable.I:20
bool has_slider(const InternalName *name) const
Returns true if the table has at least one slider by the indicated name, false otherwise.
Definition sliderTable.I:95
get_slider
Returns the nth slider in the table.
Definition sliderTable.h:49
const SparseArray & find_sliders(const InternalName *name) const
Returns a list of slider indices that represent the list of sliders with the indicated name,...
Definition sliderTable.I:81
bool is_empty() const
Returns true if the table has no sliders, false if it has at least one.
get_num_sliders
Returns the number of sliders in the table.
Definition sliderTable.h:49
get_modified
Returns a sequence number that's guaranteed to change at least when any VertexSliders in the table ch...
Definition sliderTable.h:56
const SparseArray & get_slider_rows(size_t n) const
Returns the set of rows (vertices) governed by the nth slider in the table.
Definition sliderTable.I:70
This class records a set of integers, where each integer is either present or not present in the set.
Definition sparseArray.h:43
A thread; that is, a lightweight process.
Definition thread.h:46
This is a sequence number that increments monotonically.
Definition updateSeq.h:37
This is an abstract base class that retains some slider value, which is a linear value that typically...