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"
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 */
37class EXPCL_PANDA_GOBJ SliderTable : public TypedWritableReferenceCount {
38PUBLISHED:
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
65private:
66 void do_register();
67 void do_unregister();
68 INLINE void update_modified(UpdateSeq modified, Thread *current_thread);
69
70private:
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
106public:
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
111protected:
112 static TypedWritable *make_from_bam(const FactoryParams &params);
113 void fillin(DatagramIterator &scan, BamReader *manager);
114
115public:
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
129private:
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
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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
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
get_current_thread
Returns a pointer to the currently-executing Thread object.
Definition thread.h:109
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Base class for objects that can be written to and read from Bam files.
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...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
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().
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...
This is our own Panda specialization on the default STL list.
Definition plist.h:35
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.