Panda3D
transformTable.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 transformTable.h
10  * @author drose
11  * @date 2005-03-23
12  */
13 
14 #ifndef TRANSFORMTABLE_H
15 #define TRANSFORMTABLE_H
16 
17 #include "pandabase.h"
18 #include "vertexTransform.h"
20 #include "pointerTo.h"
21 #include "luse.h"
22 #include "pvector.h"
23 #include "cycleData.h"
24 #include "cycleDataReader.h"
25 #include "cycleDataWriter.h"
26 #include "pipelineCycler.h"
27 
28 class FactoryParams;
29 
30 /**
31  * Stores the total set of VertexTransforms that the vertices in a particular
32  * GeomVertexData object might depend on.
33  *
34  * This structure is used for a GeomVertexData set up to compute its dynamic
35  * vertices on the graphics card. See TransformBlendTable for one set up to
36  * compute its dynamic vertices on the CPU.
37  */
38 class EXPCL_PANDA_GOBJ TransformTable : public TypedWritableReferenceCount {
39 PUBLISHED:
41  TransformTable(const TransformTable &copy);
42  void operator = (const TransformTable &copy);
43  virtual ~TransformTable();
44 
45  INLINE bool is_registered() const;
46  INLINE static CPT(TransformTable) register_table(const TransformTable *table);
47 
48  INLINE size_t get_num_transforms() const;
49  INLINE const VertexTransform *get_transform(size_t n) const;
50  MAKE_SEQ(get_transforms, get_num_transforms, get_transform);
51  INLINE UpdateSeq get_modified(Thread *current_thread = Thread::get_current_thread()) const;
52 
53  void set_transform(size_t n, const VertexTransform *transform);
54  void insert_transform(size_t n, const VertexTransform *transform);
55  void remove_transform(size_t n);
56  size_t add_transform(const VertexTransform *transform);
57 
58  void write(std::ostream &out) const;
59 
60  MAKE_PROPERTY(registered, is_registered);
61  MAKE_PROPERTY(modified, get_modified);
62  MAKE_SEQ_PROPERTY(transforms, get_num_transforms, get_transform, set_transform,
63  remove_transform, insert_transform);
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  typedef pvector< CPT(VertexTransform) > Transforms;
74  Transforms _transforms;
75 
76  // This is the data that must be cycled between pipeline stages.
77  class EXPCL_PANDA_GOBJ CData : public CycleData {
78  public:
79  INLINE CData();
80  INLINE CData(const CData &copy);
81  virtual CycleData *make_copy() const;
82  virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
83  virtual void fillin(DatagramIterator &scan, BamReader *manager);
84  virtual TypeHandle get_parent_type() const {
85  return TransformTable::get_class_type();
86  }
87 
88  UpdateSeq _modified;
89  };
90 
91  PipelineCycler<CData> _cycler;
92  typedef CycleDataReader<CData> CDReader;
93  typedef CycleDataWriter<CData> CDWriter;
94 
95 public:
96  static void register_with_read_factory();
97  virtual void write_datagram(BamWriter *manager, Datagram &dg);
98  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
99 
100 protected:
101  static TypedWritable *make_from_bam(const FactoryParams &params);
102  void fillin(DatagramIterator &scan, BamReader *manager);
103 
104 public:
105  static TypeHandle get_class_type() {
106  return _type_handle;
107  }
108  static void init_type() {
109  TypedWritableReferenceCount::init_type();
110  register_type(_type_handle, "TransformTable",
111  TypedWritableReferenceCount::get_class_type());
112  }
113  virtual TypeHandle get_type() const {
114  return get_class_type();
115  }
116  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
117 
118 private:
119  static TypeHandle _type_handle;
120 
121  friend class VertexTransform;
122 };
123 
124 INLINE std::ostream &operator << (std::ostream &out, const TransformTable &obj);
125 
126 #include "transformTable.I"
127 
128 #endif
UpdateSeq
This is a sequence number that increments monotonically.
Definition: updateSeq.h:37
CycleData
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:47
pvector
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
CycleData::get_parent_type
virtual TypeHandle get_parent_type() const
Returns the type of the container that owns the CycleData.
Definition: cycleData.cxx:76
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
TransformTable
Stores the total set of VertexTransforms that the vertices in a particular GeomVertexData object migh...
Definition: transformTable.h:38
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
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
typedWritableReferenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
CycleData::write_datagram
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: cycleData.cxx:32
transformTable.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
CycleDataWriter
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
Definition: cycleDataWriter.h:34
cycleData.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CycleDataReader
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
Definition: cycleDataReader.h:35
cycleDataReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
vertexTransform.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CycleData::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: cycleData.cxx:58
plist
This is our own Panda specialization on the default STL list.
Definition: plist.h:35
pipelineCycler.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypedWritableReferenceCount
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Definition: typedWritableReferenceCount.h:31
cycleDataWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Thread
A thread; that is, a lightweight process.
Definition: thread.h:46
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CycleData::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: cycleData.cxx:48
VertexTransform
This is an abstract base class that holds a pointer to some transform, computed in some arbitrary way...
Definition: vertexTransform.h:35
PipelineCycler< CData >