54class EXPCL_PANDA_PGRAPH TransformState final :
public NodeCachedReferenceCount {
60 virtual ~TransformState();
61 ALLOC_DELETED_CHAIN(TransformState);
63 TransformState &operator = (
const TransformState ©) =
delete;
66 INLINE
bool operator != (
const TransformState &other)
const;
67 INLINE
int compare_to(
const TransformState &other)
const;
68 int compare_to(
const TransformState &other,
bool uniquify_matrix)
const;
69 bool operator == (
const TransformState &other)
const;
72 static CPT(TransformState) make_identity();
73 static CPT(TransformState) make_invalid();
74 INLINE
static CPT(TransformState) make_pos(
const LVecBase3 &pos);
75 INLINE
static CPT(TransformState) make_hpr(
const LVecBase3 &hpr);
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);
79 INLINE
static CPT(TransformState) make_scale(PN_stdfloat scale);
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);
96 static CPT(TransformState) make_mat(
const LMatrix4 &mat);
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,
113 static CPT(TransformState) make_mat3(
const LMatrix3 &mat);
119 INLINE
bool is_2d()
const;
146 INLINE
const LPoint3 &
get_pos()
const;
147 INLINE
const LVecBase3 &
get_hpr()
const;
148 INLINE
const LQuaternion &
get_quat()
const;
150 INLINE
const LVecBase3 &
get_scale()
const;
152 INLINE
const LVecBase3 &
get_shear()
const;
153 INLINE
const LMatrix4 &
get_mat()
const;
170 CPT(TransformState) set_pos(
const LVecBase3 &pos)
const;
171 CPT(TransformState) set_hpr(
const LVecBase3 &hpr)
const;
172 CPT(TransformState) set_quat(
const LQuaternion &quat)
const;
173 CPT(TransformState) set_scale(
const LVecBase3 &scale)
const;
174 CPT(TransformState) set_shear(
const LVecBase3 &shear)
const;
176 CPT(TransformState) set_pos2d(
const LVecBase2 &pos)
const;
177 CPT(TransformState) set_rotate2d(PN_stdfloat rotate)
const;
178 CPT(TransformState) set_scale2d(
const LVecBase2 &scale)
const;
179 CPT(TransformState) set_shear2d(PN_stdfloat shear)
const;
181 CPT(TransformState) compose(
const TransformState *other)
const;
182 CPT(TransformState) invert_compose(
const TransformState *other)
const;
184 INLINE CPT(TransformState) get_inverse()
const;
185 INLINE CPT(TransformState) get_unique()
const;
187 INLINE
int get_geom_rendering(
int geom_rendering)
const;
189 virtual bool unref()
const;
196 INLINE
size_t get_composition_cache_num_entries()
const;
197 INLINE
size_t get_invert_composition_cache_num_entries()
const;
199 INLINE
size_t get_composition_cache_size()
const;
200 INLINE
const TransformState *get_composition_cache_source(
size_t n)
const;
201 INLINE
const TransformState *get_composition_cache_result(
size_t n)
const;
202 INLINE
size_t get_invert_composition_cache_size()
const;
203 INLINE
const TransformState *get_invert_composition_cache_source(
size_t n)
const;
204 INLINE
const TransformState *get_invert_composition_cache_result(
size_t n)
const;
206 EXTENSION(PyObject *get_composition_cache()
const);
207 EXTENSION(PyObject *get_invert_composition_cache()
const);
209 void output(std::ostream &out)
const;
210 void write(std::ostream &out,
int indent_level)
const;
220 EXTENSION(
static PyObject *get_states());
221 EXTENSION(
static PyObject *get_unused_states());
226 INLINE
static void flush_level();
231 INLINE
void cache_unref_only()
const;
234 INLINE
bool do_cache_unref()
const;
235 INLINE
bool do_node_unref()
const;
237 class CompositionCycleDescEntry {
239 INLINE CompositionCycleDescEntry(
const TransformState *obj,
240 const TransformState *result,
243 const TransformState *_obj;
244 const TransformState *_result;
247 typedef pvector<CompositionCycleDescEntry> CompositionCycleDesc;
254 void detect_and_break_cycles();
258 CompositionCycleDesc *cycle_desc);
259 static bool r_detect_reverse_cycles(
const TransformState *start_state,
262 CompositionCycleDesc *cycle_desc);
265 void remove_cache_pointers();
273 static States *_states;
294 INLINE Composition();
295 INLINE Composition(
const Composition ©);
302 typedef SimpleHashMap<const TransformState *, Composition, pointer_hash> CompositionCache;
303 mutable CompositionCache _composition_cache;
304 mutable CompositionCache _invert_composition_cache;
307 UpdateSeq _cycle_detect;
308 static UpdateSeq _last_cycle_detect;
312 static size_t _garbage_index;
314 static bool _uniquify_matrix;
316 static PStatCollector _cache_update_pcollector;
317 static PStatCollector _garbage_collect_pcollector;
318 static PStatCollector _transform_compose_pcollector;
319 static PStatCollector _transform_invert_pcollector;
320 static PStatCollector _transform_calc_pcollector;
321 static PStatCollector _transform_break_cycles_pcollector;
322 static PStatCollector _transform_new_pcollector;
323 static PStatCollector _transform_validate_pcollector;
324 static PStatCollector _transform_hash_pcollector;
326 static PStatCollector _node_counter;
327 static PStatCollector _cache_counter;
331 INLINE
void check_hash()
const;
332 INLINE
void check_singular()
const;
333 INLINE
void check_components()
const;
334 INLINE
void check_hpr()
const;
335 INLINE
void check_quat()
const;
336 INLINE
void check_norm_quat()
const;
337 INLINE
void check_mat()
const;
338 INLINE
void calc_hash();
340 void calc_singular();
341 INLINE
void calc_components();
342 void do_calc_components();
343 INLINE
void calc_hpr();
346 void calc_norm_quat();
347 INLINE
void calc_mat();
350 INLINE
void check_uniform_scale();
351 INLINE
void check_uniform_scale2d();
353 INLINE
void set_destructing();
354 INLINE
bool is_destructing()
const;
356 INLINE
void consider_update_pstats(
int old_referenced_bits)
const;
357 static void update_pstats(
int old_referenced_bits,
int new_referenced_bits);
360 F_is_identity = 0x00000001,
361 F_is_singular = 0x00000002,
362 F_singular_known = 0x00000004,
363 F_components_given = 0x00000008,
364 F_components_known = 0x00000010,
365 F_has_components = 0x00000020,
366 F_mat_known = 0x00000040,
367 F_is_invalid = 0x00000080,
368 F_quat_given = 0x00000100,
369 F_quat_known = 0x00000200,
370 F_hpr_given = 0x00000400,
371 F_hpr_known = 0x00000800,
372 F_uniform_scale = 0x00001000,
373 F_identity_scale = 0x00002000,
374 F_has_nonzero_shear = 0x00004000,
375 F_is_destructing = 0x00008000,
376 F_is_2d = 0x00010000,
377 F_hash_known = 0x00020000,
378 F_norm_quat_known = 0x00040000,
381 LVecBase3 _hpr, _scale, _shear;
382 LQuaternion _quat, _norm_quat;
392 static CacheStats _cache_stats;
395 static void register_with_read_factory();
397 static PT(TypedWritableReferenceCount) change_this(TypedWritableReferenceCount *old_ptr, BamReader *manager);
400 static TypedWritable *make_from_bam(
const FactoryParams ¶ms);
401 void fillin(DatagramIterator &scan, BamReader *manager);
404 static TypeHandle get_class_type() {
407 static void init_type() {
408 NodeCachedReferenceCount::init_type();
410 NodeCachedReferenceCount::get_class_type());
412 virtual TypeHandle get_type()
const {
413 return get_class_type();
415 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
418 static TypeHandle _type_handle;