Panda3D

Loading...
Searching...
No Matches
sliderTable.h
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.h
10 * @author drose
11 * @date 2005-03-28
12 */
13
14#ifndef SLIDERTABLE_H
15#define SLIDERTABLE_H
16
17#include "pandabase.h"
18#include "vertexSlider.h"
19#include "typedWritableReferenceCount.h"
20#include "pointerTo.h"
21#include "pmap.h"
22#include "cycleData.h"
23#include "cycleDataReader.h"
24#include "cycleDataWriter.h"
25#include "pipelineCycler.h"
26#include "sparseArray.h"
27
28/**
29 * Stores the total set of VertexSliders that the vertices in a particular
30 * GeomVertexData object might depend on.
31 *
32 * This is similar to a TransformTable, but it stores VertexSliders instead of
33 * VertexTransforms, and it stores them by name instead of by index number.
34 * Also, it is only used when animating vertices on the CPU, since GPU's don't
35 * support morphs at this point in time.
36 */
37 class EXPCL_PANDA_GOBJ SliderTable : public TypedWritableReferenceCount {
38PUBLISHED:
39 SliderTable();
40 SliderTable(const SliderTable &copy);
41 void operator = (const SliderTable &copy);
42 virtual ~SliderTable();
43
44 INLINE bool is_registered() const;
45 INLINE static CPT(SliderTable) register_table(const SliderTable *table);
46
47 INLINE size_t get_num_sliders() const;
48 INLINE const VertexSlider *get_slider(size_t n) const;
49 MAKE_SEQ(get_sliders, get_num_sliders, get_slider);
50 INLINE const SparseArray &get_slider_rows(size_t n) const;
51
52 INLINE const SparseArray &find_sliders(const InternalName *name) const;
53 INLINE bool has_slider(const InternalName *name) const;
54 INLINE bool is_empty() const;
55 INLINE UpdateSeq get_modified(Thread *current_thread = Thread::get_current_thread()) const;
56 MAKE_PROPERTY(modified, get_modified);
57
58 void set_slider(size_t n, const VertexSlider *slider);
59 void set_slider_rows(size_t n, const SparseArray &rows);
60 void remove_slider(size_t n);
61 size_t add_slider(const VertexSlider *slider, const SparseArray &rows);
62
63 void write(std::ostream &out) const;
64
65 private:
66 void do_register();
67 void do_unregister();
68 INLINE void update_modified(UpdateSeq modified, Thread *current_thread);
69
70 private:
71 bool _is_registered;
72
73 class SliderDef {
74 public:
75 CPT(VertexSlider) _slider;
76 SparseArray _rows;
77 };
78
79 typedef pvector<SliderDef> Sliders;
80 Sliders _sliders;
81
82 typedef pmap< CPT(InternalName), SparseArray > SlidersByName;
83 SlidersByName _sliders_by_name;
84
85 static SparseArray _empty_array;
86
87 // This is the data that must be cycled between pipeline stages.
88 class EXPCL_PANDA_GOBJ CData : public CycleData {
89 public:
90 INLINE CData();
91 INLINE CData(const CData &copy);
92 virtual CycleData *make_copy() const;
93 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
94 virtual void fillin(DatagramIterator &scan, BamReader *manager);
95 virtual TypeHandle get_parent_type() const {
96 return SliderTable::get_class_type();
97 }
98
99 UpdateSeq _modified;
100 };
101
102 PipelineCycler<CData> _cycler;
103 typedef CycleDataReader<CData> CDReader;
104 typedef CycleDataWriter<CData> CDWriter;
105
106 public:
107 static void register_with_read_factory();
108 virtual void write_datagram(BamWriter *manager, Datagram &dg);
109 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
110
111 protected:
112 static TypedWritable *make_from_bam(const FactoryParams &params);
113 void fillin(DatagramIterator &scan, BamReader *manager);
114
115 public:
116 static TypeHandle get_class_type() {
117 return _type_handle;
118 }
119 static void init_type() {
120 TypedWritableReferenceCount::init_type();
121 register_type(_type_handle, "SliderTable",
122 TypedWritableReferenceCount::get_class_type());
123 }
124 virtual TypeHandle get_type() const {
125 return get_class_type();
126 }
127 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
128
129 private:
130 static TypeHandle _type_handle;
131
132 friend class VertexSlider;
133};
134
135INLINE std::ostream &operator << (std::ostream &out, const SliderTable &obj);
136
137#include "sliderTable.I"
138
139#endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
CycleData
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
InternalName
Encodes a string name in a hash table, mapping it to a pointer.
Definition internalName.h:38
SliderTable
Stores the total set of VertexSliders that the vertices in a particular GeomVertexData object might d...
Definition sliderTable.h:37
SliderTable::is_registered
bool is_registered() const
Returns true if this table has been registered.
Definition sliderTable.I:20
SliderTable::set_slider_rows
void set_slider_rows(size_t n, const SparseArray &rows)
Replaces the rows affected by the nth slider.
Definition sliderTable.cxx:83
SliderTable::has_slider
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
SliderTable::get_slider
get_slider
Returns the nth slider in the table.
Definition sliderTable.h:49
SliderTable::find_sliders
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
SliderTable::set_slider
void set_slider(size_t n, const VertexSlider *slider)
Replaces the nth slider.
Definition sliderTable.cxx:66
SliderTable::is_empty
bool is_empty() const
Returns true if the table has no sliders, false if it has at least one.
Definition sliderTable.I:103
SliderTable::get_num_sliders
get_num_sliders
Returns the number of sliders in the table.
Definition sliderTable.h:49
SliderTable::get_modified
get_modified
Returns a sequence number that's guaranteed to change at least when any VertexSliders in the table ch...
Definition sliderTable.h:56
SliderTable::add_slider
size_t add_slider(const VertexSlider *slider, const SparseArray &rows)
Adds a new slider to the table, and returns the index number of the new slider.
Definition sliderTable.cxx:109
SliderTable::remove_slider
void remove_slider(size_t n)
Removes the nth slider.
Definition sliderTable.cxx:96
SliderTable::get_slider_rows
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
SparseArray
This class records a set of integers, where each integer is either present or not present in the set.
Definition sparseArray.h:43
Thread
A thread; that is, a lightweight process.
Definition thread.h:46
Thread::get_current_thread
get_current_thread
Returns a pointer to the currently-executing Thread object.
Definition thread.h:109
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable::fillin
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
Definition typedWritable.cxx:103
TypedWritable::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition typedWritable.cxx:54
TypedWritable::complete_pointers
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Definition typedWritable.cxx:81
UpdateSeq
This is a sequence number that increments monotonically.
Definition updateSeq.h:37
cycleDataReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleDataWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cycleData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pipelineCycler.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22
sliderTable.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
sparseArray.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
typedWritableReferenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
vertexSlider.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.