15 #include "transformBlendTable.h"
17 #include "bamReader.h"
18 #include "bamWriter.h"
38 TransformBlendTable() {
48 _blends(copy._blends),
58 void TransformBlendTable::
60 _blends = copy._blends;
71 ~TransformBlendTable() {
82 nassertv(n >= 0 && n < (
int)_blends.size());
93 nassertv(n >= 0 && n < (
int)_blends.size());
94 _blends.erase(_blends.begin() + n);
106 consider_rebuild_index();
108 BlendIndex::iterator bi;
109 bi = _blend_index.find(&blend);
110 if (bi != _blend_index.end()) {
115 bool needs_realloc = (_blends.size() >= _blends.capacity());
116 int new_position = (int)_blends.size();
117 _blends.push_back(blend);
128 _blend_index[&added_blend] = new_position;
129 _max_simultaneous_transforms = max(_max_simultaneous_transforms,
134 _num_transforms = -1;
145 void TransformBlendTable::
146 write(ostream &out,
int indent_level)
const {
147 for (
int i = 0; i < (int)_blends.size(); i++) {
148 indent(out, indent_level)
149 << i <<
". " << _blends[i] <<
"\n";
159 void TransformBlendTable::
161 _blend_index.clear();
171 void TransformBlendTable::
173 _blend_index.clear();
178 _max_simultaneous_transforms = 0;
182 for (
int i = 0; i < (int)_blends.size(); ++i) {
184 _blend_index[&blend] = i;
189 _max_simultaneous_transforms = max(_max_simultaneous_transforms,
193 _num_transforms = transforms.size();
202 void TransformBlendTable::
203 recompute_modified(TransformBlendTable::CData *cdata,
Thread *current_thread) {
210 Blends::const_iterator bi;
211 for (bi = _blends.begin(); bi != _blends.end(); ++bi) {
212 seq = max(seq, (*bi).get_modified(current_thread));
215 cdata->_modified = seq;
224 void TransformBlendTable::
225 clear_modified(
Thread *current_thread) {
226 CDWriter cdata(_cycler,
true, current_thread);
253 Blends::const_iterator bi;
254 for (bi = _blends.begin(); bi != _blends.end(); ++bi) {
255 (*bi).write_datagram(manager, dg);
275 for (bi = _blends.begin(); bi != _blends.end(); ++bi) {
276 pi += (*bi).complete_pointers(p_list + pi, manager);
296 parse_params(params, scan, manager);
297 object->fillin(scan, manager);
309 void TransformBlendTable::
314 _blends.reserve(num_blends);
316 for (i = 0; i < num_blends; ++i) {
318 blend.
fillin(scan, manager);
319 _blends.push_back(blend);
340 return new CData(*
this);
349 void TransformBlendTable::CData::
360 void TransformBlendTable::CData::
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler)
Reads in the indicated CycleData object.
A single page of data maintained by a PipelineCycler.
Base class for objects that can be written to and read from Bam files.
void write_cdata(Datagram &packet, const PipelineCyclerBase &cycler)
Writes out the indicated CycleData object.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
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...
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
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()...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
This base class provides basic reference counting, but also can be used with a CopyOnWritePointer to ...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
A thread; that is, a lightweight process.
void write_datagram(BamWriter *manager, Datagram &dg) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is our own Panda specialization on the default STL set.
A class to retrieve the individual data elements previously stored in a Datagram. ...
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void read_datagram(DatagramIterator &scan, BamReader *manager)
Reads the object that was previously written to a Bam file.