14 #ifndef TRANSFORMSTATE_H 15 #define TRANSFORMSTATE_H 70 INLINE
size_t get_hash()
const;
76 INLINE
static CPT(
TransformState) make_quat(
const LQuaternion &quat);
77 INLINE
static CPT(
TransformState) make_pos_hpr(
const LVecBase3 &pos,
78 const LVecBase3 &hpr);
80 INLINE
static CPT(
TransformState) make_scale(
const LVecBase3 &scale);
81 INLINE
static CPT(
TransformState) make_shear(
const LVecBase3 &shear);
82 INLINE
static CPT(
TransformState) make_pos_hpr_scale(
const LVecBase3 &pos,
84 const LVecBase3 &scale);
85 INLINE
static CPT(
TransformState) make_pos_quat_scale(
const LVecBase3 &pos,
86 const LQuaternion &quat,
87 const LVecBase3 &scale);
88 static CPT(
TransformState) make_pos_hpr_scale_shear(
const LVecBase3 &pos,
90 const LVecBase3 &scale,
91 const LVecBase3 &shear);
92 static CPT(
TransformState) make_pos_quat_scale_shear(
const LVecBase3 &pos,
93 const LQuaternion &quat,
94 const LVecBase3 &scale,
95 const LVecBase3 &shear);
99 INLINE
static CPT(
TransformState) make_pos2d(
const LVecBase2 &pos);
100 INLINE
static CPT(
TransformState) make_rotate2d(PN_stdfloat rotate);
101 INLINE
static CPT(
TransformState) make_pos_rotate2d(
const LVecBase2 &pos,
103 INLINE
static CPT(
TransformState) make_scale2d(PN_stdfloat scale);
104 INLINE
static CPT(
TransformState) make_scale2d(
const LVecBase2 &scale);
105 INLINE
static CPT(
TransformState) make_shear2d(PN_stdfloat shear);
106 INLINE
static CPT(
TransformState) make_pos_rotate_scale2d(
const LVecBase2 &pos,
108 const LVecBase2 &scale);
109 static CPT(
TransformState) make_pos_rotate_scale_shear2d(
const LVecBase2 &pos,
111 const LVecBase2 &scale,
116 INLINE
bool is_identity()
const;
117 INLINE
bool is_invalid()
const;
118 INLINE
bool is_singular()
const;
119 INLINE
bool is_2d()
const;
121 INLINE
bool has_components()
const;
122 INLINE
bool components_given()
const;
123 INLINE
bool hpr_given()
const;
124 INLINE
bool quat_given()
const;
125 INLINE
bool has_pos()
const;
126 INLINE
bool has_hpr()
const;
127 INLINE
bool has_quat()
const;
128 INLINE
bool has_scale()
const;
129 INLINE
bool has_identity_scale()
const;
130 INLINE
bool has_uniform_scale()
const;
131 INLINE
bool has_shear()
const;
132 INLINE
bool has_nonzero_shear()
const;
133 INLINE
bool has_mat()
const;
135 INLINE
const LPoint3 &get_pos()
const;
136 INLINE
const LVecBase3 &get_hpr()
const;
137 INLINE
const LQuaternion &get_quat()
const;
138 INLINE
const LQuaternion &get_norm_quat()
const;
139 INLINE
const LVecBase3 &get_scale()
const;
140 INLINE PN_stdfloat get_uniform_scale()
const;
141 INLINE
const LVecBase3 &get_shear()
const;
142 INLINE
const LMatrix4 &get_mat()
const;
144 INLINE LVecBase2 get_pos2d()
const;
145 INLINE PN_stdfloat get_rotate2d()
const;
146 INLINE LVecBase2 get_scale2d()
const;
147 INLINE PN_stdfloat get_shear2d()
const;
148 INLINE LMatrix3 get_mat3()
const;
150 MAKE_PROPERTY(pos, get_pos);
151 MAKE_PROPERTY(hpr, get_hpr);
152 MAKE_PROPERTY(quat, get_quat);
153 MAKE_PROPERTY(norm_quat, get_norm_quat);
154 MAKE_PROPERTY(scale, get_scale);
155 MAKE_PROPERTY(shear, get_shear);
156 MAKE_PROPERTY(mat, get_mat);
175 INLINE
int get_geom_rendering(
int geom_rendering)
const;
177 virtual bool unref()
const;
184 INLINE
size_t get_composition_cache_num_entries()
const;
185 INLINE
size_t get_invert_composition_cache_num_entries()
const;
187 INLINE
size_t get_composition_cache_size()
const;
188 INLINE
const TransformState *get_composition_cache_source(
size_t n)
const;
189 INLINE
const TransformState *get_composition_cache_result(
size_t n)
const;
190 INLINE
size_t get_invert_composition_cache_size()
const;
191 INLINE
const TransformState *get_invert_composition_cache_source(
size_t n)
const;
192 INLINE
const TransformState *get_invert_composition_cache_result(
size_t n)
const;
193 bool validate_composition_cache()
const;
194 EXTENSION(PyObject *get_composition_cache()
const);
195 EXTENSION(PyObject *get_invert_composition_cache()
const);
197 void output(std::ostream &out)
const;
198 void write(std::ostream &out,
int indent_level)
const;
199 void write_composition_cache(std::ostream &out,
int indent_level)
const;
201 static int get_num_states();
202 static int get_num_unused_states();
203 static int clear_cache();
204 static int garbage_collect();
205 static void list_cycles(std::ostream &out);
206 static void list_states(std::ostream &out);
207 static bool validate_states();
208 EXTENSION(
static PyObject *get_states());
209 EXTENSION(
static PyObject *get_unused_states());
212 static void init_states();
214 INLINE
static void flush_level();
217 INLINE
bool do_cache_unref()
const;
218 INLINE
bool do_node_unref()
const;
220 class CompositionCycleDescEntry {
237 void detect_and_break_cycles();
241 CompositionCycleDesc *cycle_desc);
242 static bool r_detect_reverse_cycles(
const TransformState *start_state,
245 CompositionCycleDesc *cycle_desc);
248 void remove_cache_pointers();
256 static States *_states;
277 INLINE Composition();
278 INLINE Composition(
const Composition ©);
286 mutable CompositionCache _composition_cache;
287 mutable CompositionCache _invert_composition_cache;
295 static size_t _garbage_index;
297 static bool _uniquify_matrix;
314 INLINE
void check_hash()
const;
315 INLINE
void check_singular()
const;
316 INLINE
void check_components()
const;
317 INLINE
void check_hpr()
const;
318 INLINE
void check_quat()
const;
319 INLINE
void check_norm_quat()
const;
320 INLINE
void check_mat()
const;
321 INLINE
void calc_hash();
323 void calc_singular();
324 INLINE
void calc_components();
325 void do_calc_components();
326 INLINE
void calc_hpr();
329 void calc_norm_quat();
330 INLINE
void calc_mat();
333 INLINE
void check_uniform_scale();
334 INLINE
void check_uniform_scale2d();
336 INLINE
void set_destructing();
337 INLINE
bool is_destructing()
const;
339 INLINE
void consider_update_pstats(
int old_referenced_bits)
const;
340 static void update_pstats(
int old_referenced_bits,
int new_referenced_bits);
343 F_is_identity = 0x00000001,
344 F_is_singular = 0x00000002,
345 F_singular_known = 0x00000004,
346 F_components_given = 0x00000008,
347 F_components_known = 0x00000010,
348 F_has_components = 0x00000020,
349 F_mat_known = 0x00000040,
350 F_is_invalid = 0x00000080,
351 F_quat_given = 0x00000100,
352 F_quat_known = 0x00000200,
353 F_hpr_given = 0x00000400,
354 F_hpr_known = 0x00000800,
355 F_uniform_scale = 0x00001000,
356 F_identity_scale = 0x00002000,
357 F_has_nonzero_shear = 0x00004000,
358 F_is_destructing = 0x00008000,
359 F_is_2d = 0x00010000,
360 F_hash_known = 0x00020000,
361 F_norm_quat_known = 0x00040000,
364 LVecBase3 _hpr, _scale, _shear;
365 LQuaternion _quat, _norm_quat;
378 static void register_with_read_factory();
390 static void init_type() {
391 NodeCachedReferenceCount::init_type();
393 NodeCachedReferenceCount::get_class_type());
396 return get_class_type();
398 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
410 INLINE std::ostream &operator << (std::ostream &out,
const TransformState &state) {
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class further specializes CachedTypedWritableReferenceCount to also add a node_ref_count,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class for PointerTo and ConstPointerTo.
Base class for objects that can be written to and read from Bam files.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight reentrant mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void node_ref() const
Explicitly increments the reference count.
This template class implements an unordered map of keys to data, implemented as a hashtable.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
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 vector.
A lightweight class that represents a single element that may be timed and/or counted via stats.
bool cache_unref() const
Explicitly decrements the cache reference count and the normal reference count simultaneously.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void cache_ref() const
Explicitly increments the cache reference count and the normal reference count simultaneously.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool node_unref() const
Explicitly decrements the node reference count and the normal reference count simultaneously.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
The default class template does not define any methods.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An STL function object class, this is intended to be used on any ordered collection of class objects ...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is used to track the utilization of the TransformState and RenderState caches,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
This is a standard, non-reentrant mutex, similar to the Mutex class.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
virtual bool unref() const
Explicitly decrements the reference count.