Panda3D
nodePath.I
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 nodePath.I
10  * @author drose
11  * @date 2002-02-25
12  */
13 
14 /**
15  * This constructs an empty NodePath with no nodes.
16  */
17 INLINE NodePath::
18 NodePath() :
19  _error_type(ET_ok),
20  _backup_key(0)
21 {
22 }
23 
24 /**
25  * This constructs a new NodePath with a single node. An ordinary, unattached
26  * PandaNode is created with the indicated name.
27  */
28 INLINE NodePath::
29 NodePath(const std::string &top_node_name, Thread *current_thread) :
30  _error_type(ET_ok)
31 {
32  PandaNode *top_node = new PandaNode(top_node_name);
33  int pipeline_stage = current_thread->get_pipeline_stage();
34  _head = top_node->get_generic_component(false, pipeline_stage, current_thread);
35  _backup_key = 0;
36 }
37 
38 /**
39  * This constructs a NodePath for the indicated node. If the node does not
40  * have any parents, this creates a singleton NodePath; otherwise, it
41  * automatically finds the path from the node to the root. If the node has
42  * multiple paths to the root, one path is chosen arbitrarily and a warning
43  * message is printed (but see also NodePath::any_path(), below).
44  */
45 INLINE NodePath::
46 NodePath(PandaNode *node, Thread *current_thread) :
47  _error_type(ET_ok)
48 {
49  if (node != nullptr) {
50  int pipeline_stage = current_thread->get_pipeline_stage();
51  _head = node->get_generic_component(false, pipeline_stage, current_thread);
52  }
53  _backup_key = 0;
54 }
55 
56 /**
57  * Returns a new NodePath that represents any arbitrary path from the root to
58  * the indicated node. This is the same thing that would be returned by
59  * NodePath(node), except that no warning is issued if the path is ambiguous.
60  */
62 any_path(PandaNode *node, Thread *current_thread) {
63  NodePath result;
64  if (node != nullptr) {
65  int pipeline_stage = current_thread->get_pipeline_stage();
66  result._head = node->get_generic_component(true, pipeline_stage,
67  current_thread);
68  }
69  return result;
70 }
71 
72 /**
73  *
74  */
75 INLINE NodePath::
76 NodePath(const NodePath &copy) :
77  _head(copy._head),
78  _backup_key(copy._backup_key),
79  _error_type(copy._error_type)
80 {
81 }
82 
83 /**
84  *
85  */
86 INLINE void NodePath::
87 operator = (const NodePath &copy) {
88  _head = copy._head;
89  _backup_key = copy._backup_key;
90  _error_type = copy._error_type;
91 }
92 
93 /**
94  *
95  */
96 INLINE NodePath::
97 NodePath(NodePath &&from) noexcept :
98  _head(std::move(from._head)),
99  _backup_key(from._backup_key),
100  _error_type(from._error_type)
101 {
102 }
103 
104 /**
105  *
106  */
107 INLINE void NodePath::
108 operator = (NodePath &&from) noexcept {
109  _head = std::move(from._head);
110  _backup_key = from._backup_key;
111  _error_type = from._error_type;
112 }
113 
114 /**
115  * Sets this NodePath to the empty NodePath. It will no longer point to any
116  * node.
117  */
118 INLINE void NodePath::
119 clear() {
120  _head.clear();
121  _backup_key = 0;
122  _error_type = ET_ok;
123 }
124 
125 /**
126  * Creates a NodePath with the ET_not_found error type set.
127  */
129 not_found() {
130  NodePath result;
131  result._error_type = ET_not_found;
132  return result;
133 }
134 
135 /**
136  * Creates a NodePath with the ET_removed error type set.
137  */
139 removed() {
140  NodePath result;
141  result._error_type = ET_removed;
142  return result;
143 }
144 
145 /**
146  * Creates a NodePath with the ET_fail error type set.
147  */
149 fail() {
150  NodePath result;
151  result._error_type = ET_fail;
152  return result;
153 }
154 
155 /**
156  * Certain operations, such as find() or find_all_matches(), require a
157  * traversal of the scene graph to search for the target node or nodes. This
158  * traversal does not attempt to detect cycles, so an arbitrary cap is set on
159  * the depth of the traversal as a poor man's cycle detection, in the event
160  * that a cycle has inadvertently been introduced into the scene graph.
161  *
162  * There may be other reasons you'd want to truncate a search before the
163  * bottom of the scene graph has been reached. In any event, this function
164  * sets the limit on the number of levels that a traversal will continue, and
165  * hence the maximum length of a path that may be returned by a traversal.
166  *
167  * This is a static method, and so changing this parameter affects all of the
168  * NodePaths in the universe.
169  */
170 INLINE void NodePath::
171 set_max_search_depth(int max_search_depth) {
172  _max_search_depth = max_search_depth;
173 }
174 
175 /**
176  * Returns the current setting of the search depth limit. See
177  * set_max_search_depth.
178  */
179 INLINE int NodePath::
181  return _max_search_depth;
182 }
183 
184 /**
185  * Returns true if the NodePath contains no nodes.
186  */
187 INLINE bool NodePath::
188 is_empty() const {
189  return (_head == nullptr);
190 }
191 
192 /**
193  * Returns true if the NodePath contains exactly one node.
194  */
195 INLINE bool NodePath::
196 is_singleton(Thread *current_thread) const {
197  int pipeline_stage = current_thread->get_pipeline_stage();
198  return (_head != nullptr && _head->is_top_node(pipeline_stage, current_thread));
199 }
200 
201 /**
202  * If is_empty() is true, this returns a code that represents the reason why
203  * the NodePath is empty.
204  */
205 INLINE NodePath::ErrorType NodePath::
206 get_error_type() const {
207  return _error_type;
208 }
209 
210 /**
211  * Returns the top node of the path, or NULL if the path is empty. This
212  * requires iterating through the path.
213  */
215 get_top_node(Thread *current_thread) const {
216  if (is_empty()) {
217  return nullptr;
218  }
219 
220  return get_top(current_thread).node();
221 }
222 
223 /**
224  * Returns the referenced node of the path.
225  */
227 node() const {
228  nassertr_always(!is_empty(), nullptr);
229  return _head->get_node();
230 }
231 
232 /**
233  * Returns an integer that is guaranteed to be the same for all NodePaths that
234  * represent the same node instance, and different for all NodePaths that
235  * represent a different node instance.
236  *
237  * The same key will be returned for a particular instance as long as at least
238  * one NodePath exists that represents that instance; if all NodePaths for a
239  * particular instance destruct and a new one is later created, it may have a
240  * different index. However, a given key will never be reused for a different
241  * instance (unless the app has been running long enough that we overflow the
242  * integer key value).
243  */
244 INLINE int NodePath::
245 get_key() const {
246  if (is_empty()) {
247  return _backup_key;
248  }
249  return _head->get_key();
250 }
251 
252 /**
253  * Adds the NodePath into the running hash. This is intended to be used by
254  * lower-level code that computes a hash for each NodePath. It modifies the
255  * hash value passed in by a unique adjustment for each NodePath, and returns
256  * the modified hash.
257  *
258  * This is similar to the unique integer returned by get_key(), but it is not
259  * guaranteed to remain unique beyond the lifetime of this particular
260  * NodePath. Once this NodePath destructs, a different NodePath may be
261  * created which shares the same hash value.
262  */
263 INLINE size_t NodePath::
264 add_hash(size_t hash) const {
265  return pointer_hash::add_hash(hash, _head);
266 }
267 
268 /**
269  * Returns true if the node represented by this NodePath is parented within
270  * the same graph as that of the other NodePath. This is essentially the same
271  * thing as asking whether get_top() of both NodePaths is the same (e.g., both
272  * "render").
273  */
274 INLINE bool NodePath::
275 is_same_graph(const NodePath &other, Thread *current_thread) const {
276  // Actually, it's possible for the top nodes to be the same, but the
277  // NodePaths still to be considered in different graphs. But even in this
278  // case, get_top() will be different for each one. (They'll be different
279  // singleton NodePaths that happen to reference the same node).
280 
281  // This will happen if one of the top nodes is considered a different
282  // instance--for instance, render.instance_to(NodePath()) returns a
283  // different instance of render that appears to have the same top node. But
284  // this is a very rare thing to do.
285  int a_count, b_count;
286  return (find_common_ancestor(*this, other, a_count, b_count, current_thread) != nullptr);
287 }
288 
289 /**
290  * Returns true if the node represented by this NodePath is a parent or other
291  * ancestor of the other NodePath, or false if it is not.
292  */
293 INLINE bool NodePath::
294 is_ancestor_of(const NodePath &other, Thread *current_thread) const {
295  int a_count, b_count;
296  if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == nullptr) {
297  // Not related.
298  return false;
299  }
300 
301  // They are related; now b is descended from a only if a is the common
302  // ancestor (which is to say, a_count == 0).
303  return (a_count == 0);
304 }
305 
306 /**
307  * Returns the lowest NodePath that both of these two NodePaths have in
308  * common: the first ancestor that both of them share. If the two NodePaths
309  * are unrelated, returns NodePath::not_found().
310  */
312 get_common_ancestor(const NodePath &other, Thread *current_thread) const {
313  int a_count, b_count;
314  NodePathComponent *common = find_common_ancestor(*this, other, a_count, b_count, current_thread);
315  if (common == nullptr) {
316  return NodePath::not_found();
317  }
318 
319  NodePath result;
320  result._head = common;
321  return result;
322 }
323 
324 /**
325  * Returns the number of children of the referenced node.
326  */
327 INLINE int NodePath::
328 get_num_children(Thread *current_thread) const {
329  nassertr_always(!is_empty(), 0);
330  return _head->get_node()->get_num_children(current_thread);
331 }
332 
333 /**
334  * Returns a NodePath representing the nth child of the referenced node.
335  */
337 get_child(int n, Thread *current_thread) const {
338  nassertr_always(n >= 0 && n < get_num_children(current_thread), NodePath());
339  NodePath child;
340  int pipeline_stage = current_thread->get_pipeline_stage();
341  child._head = PandaNode::get_component(_head, _head->get_node()->get_child(n, current_thread),
342  pipeline_stage, current_thread);
343  return child;
344 }
345 
346 /**
347  * Returns the number of nodes at and below this level.
348  */
349 INLINE int NodePath::
350 count_num_descendants() const {
351  if (is_empty()) {
352  return 0;
353  }
354  return _head->get_node()->count_num_descendants();
355 }
356 
357 /**
358  * Returns true if the referenced node has a parent; i.e. the NodePath chain
359  * contains at least two nodes.
360  */
361 INLINE bool NodePath::
362 has_parent(Thread *current_thread) const {
363  return !is_empty() && !is_singleton(current_thread);
364 }
365 
366 /**
367  * Returns the NodePath to the parent of the referenced node: that is, this
368  * NodePath, shortened by one node. The parent of a singleton NodePath is
369  * defined to be the empty NodePath.
370  */
371 INLINE NodePath NodePath::
372 get_parent(Thread *current_thread) const {
373  if (!has_parent(current_thread)) {
374  return NodePath();
375  }
376 
377  int pipeline_stage = current_thread->get_pipeline_stage();
378 
379  NodePath parent;
380  parent._head = _head->get_next(pipeline_stage, current_thread);
381  return parent;
382 }
383 
384 /**
385  * Creates an ordinary PandaNode and attaches it below the current NodePath,
386  * returning a new NodePath that references it.
387  */
389 attach_new_node(const std::string &name, int sort, Thread *current_thread) const {
390  nassertr(verify_complete(current_thread), NodePath::fail());
391 
392  return attach_new_node(new PandaNode(name), sort, current_thread);
393 }
394 
395 /**
396  * Lists the hierarchy at and below the referenced node.
397  */
398 INLINE void NodePath::
399 ls() const {
400  ls(nout);
401 }
402 
403 /**
404  * Lists the hierarchy at and below the referenced node.
405  */
406 INLINE void NodePath::
407 ls(std::ostream &out, int indent_level) const {
408  if (is_empty()) {
409  out << "(empty)\n";
410  } else {
411  node()->ls(out, indent_level);
412  }
413 }
414 
415 /**
416  * Lists the hierarchy at and above the referenced node.
417  */
418 INLINE void NodePath::
419 reverse_ls() const {
420  reverse_ls(nout);
421 }
422 
423 /**
424  * Changes the complete state object on this node.
425  */
426 INLINE void NodePath::
427 set_state(const RenderState *state, Thread *current_thread) {
428  nassertv_always(!is_empty());
429  node()->set_state(state, current_thread);
430 }
431 
432 /**
433  * Returns the net state on this node from the root.
434  */
435 INLINE CPT(RenderState) NodePath::
436 get_net_state(Thread *current_thread) const {
437  nassertr(_error_type == ET_ok, RenderState::make_empty());
438  return r_get_net_state(_head, current_thread);
439 }
440 
441 /**
442  * Adds the indicated render attribute to the scene graph on this node. This
443  * attribute will now apply to this node and everything below. If there was
444  * already an attribute of the same type, it is replaced.
445  */
446 INLINE void NodePath::
447 set_attrib(const RenderAttrib *attrib, int priority) {
448  nassertv_always(!is_empty());
449  node()->set_attrib(attrib, priority);
450 }
451 
452 /**
453  * Returns the render attribute of the indicated type, if it is defined on the
454  * node, or NULL if it is not. This checks only what is set on this
455  * particular node level, and has nothing to do with what render attributes
456  * may be inherited from parent nodes.
457  */
459 get_attrib(TypeHandle type) const {
460  nassertr_always(!is_empty(), nullptr);
461  return node()->get_attrib(type);
462 }
463 
464 /**
465  * Returns true if there is a render attribute of the indicated type defined
466  * on this node, or false if there is not.
467  */
468 INLINE bool NodePath::
469 has_attrib(TypeHandle type) const {
470  nassertr_always(!is_empty(), false);
471  return node()->has_attrib(type);
472 }
473 
474 /**
475  * Removes the render attribute of the given type from this node. This node,
476  * and the subgraph below, will now inherit the indicated render attribute
477  * from the nodes above this one.
478  */
479 INLINE void NodePath::
480 clear_attrib(TypeHandle type) {
481  nassertv_always(!is_empty());
482  node()->clear_attrib(type);
483 }
484 
485 /**
486  * Adds the indicated render effect to the scene graph on this node. If there
487  * was already an effect of the same type, it is replaced.
488  */
489 INLINE void NodePath::
490 set_effect(const RenderEffect *effect) {
491  nassertv_always(!is_empty());
492  node()->set_effect(effect);
493 }
494 
495 /**
496  * Returns the render effect of the indicated type, if it is defined on the
497  * node, or NULL if it is not.
498  */
500 get_effect(TypeHandle type) const {
501  nassertr_always(!is_empty(), nullptr);
502  return node()->get_effect(type);
503 }
504 
505 /**
506  * Returns true if there is a render effect of the indicated type defined on
507  * this node, or false if there is not.
508  */
509 INLINE bool NodePath::
510 has_effect(TypeHandle type) const {
511  nassertr_always(!is_empty(), false);
512  return node()->has_effect(type);
513 }
514 
515 /**
516  * Removes the render effect of the given type from this node.
517  */
518 INLINE void NodePath::
519 clear_effect(TypeHandle type) {
520  nassertv_always(!is_empty());
521  node()->clear_effect(type);
522 }
523 
524 /**
525  * Sets the complete RenderEffects that will be applied this node. This
526  * completely replaces whatever has been set on this node via repeated calls
527  * to set_attrib().
528  */
529 INLINE void NodePath::
530 set_effects(const RenderEffects *effects) {
531  nassertv_always(!is_empty());
532  node()->set_effects(effects);
533 }
534 
535 /**
536  * Returns the complete RenderEffects that will be applied to this node.
537  */
539 get_effects() const {
540  nassertr_always(!is_empty(), RenderEffects::make_empty());
541  return node()->get_effects();
542 }
543 
544 /**
545  * Resets this node to have no render effects.
546  */
547 INLINE void NodePath::
548 clear_effects() {
549  nassertv_always(!is_empty());
550  node()->clear_effects();
551 }
552 
553 /**
554  * Sets the transform object on this node to identity.
555  */
556 INLINE void NodePath::
557 clear_transform(Thread *current_thread) {
558  set_transform(TransformState::make_identity(), current_thread);
559 }
560 
561 /**
562  * Changes the complete transform object on this node.
563  */
564 INLINE void NodePath::
565 set_transform(const TransformState *transform, Thread *current_thread) {
566  nassertv_always(!is_empty());
567  node()->set_transform(transform, current_thread);
568 }
569 
570 /**
571  * Sets the transform object on this node to identity, relative to the other
572  * node. This effectively places this node at the same position as the other
573  * node.
574  */
575 INLINE void NodePath::
576 clear_transform(const NodePath &other, Thread *current_thread) {
577  set_transform(other, TransformState::make_identity(), current_thread);
578 }
579 
580 /**
581  * Returns the net transform on this node from the root.
582  */
583 INLINE CPT(TransformState) NodePath::
584 get_net_transform(Thread *current_thread) const {
585  nassertr(_error_type == ET_ok, TransformState::make_identity());
586  return r_get_net_transform(_head, current_thread);
587 }
588 
589 /**
590  * Sets the transform that represents this node's "previous" position, one
591  * frame ago, for the purposes of detecting motion for accurate collision
592  * calculations.
593  */
594 INLINE void NodePath::
595 set_prev_transform(const TransformState *transform, Thread *current_thread) {
596  nassertv_always(!is_empty());
597  node()->set_prev_transform(transform, current_thread);
598 }
599 
600 /**
601  * Returns the net "previous" transform on this node from the root. See
602  * set_prev_transform().
603  */
604 INLINE CPT(TransformState) NodePath::
605 get_net_prev_transform(Thread *current_thread) const {
606  nassertr(_error_type == ET_ok, TransformState::make_identity());
607  return r_get_net_prev_transform(_head, current_thread);
608 }
609 
610 /**
611  * Sets the translation component of the transform, leaving rotation and scale
612  * untouched. This also resets the node's "previous" position, so that the
613  * collision system will see the node as having suddenly appeared in the new
614  * position, without passing any points in between.
615  */
616 INLINE void NodePath::
617 set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
618  set_pos(LPoint3(x, y, z));
619 }
620 
621 /**
622  * Sets the translation component, without changing the "previous" position,
623  * so that the collision system will see the node as moving fluidly from its
624  * previous position to its new position.
625  */
626 INLINE void NodePath::
627 set_fluid_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
628  set_fluid_pos(LPoint3(x, y, z));
629 }
630 
631 INLINE PN_stdfloat NodePath::
632 get_x() const {
633  return get_pos()[0];
634 }
635 
636 INLINE PN_stdfloat NodePath::
637 get_y() const {
638  return get_pos()[1];
639 }
640 
641 INLINE PN_stdfloat NodePath::
642 get_z() const {
643  return get_pos()[2];
644 }
645 
646 /**
647  * Sets the rotation component of the transform, leaving translation and scale
648  * untouched.
649  */
650 INLINE void NodePath::
651 set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
652  set_hpr(LVecBase3(h, p, r));
653 }
654 
655 INLINE PN_stdfloat NodePath::
656 get_h() const {
657  return get_hpr()[0];
658 }
659 
660 INLINE PN_stdfloat NodePath::
661 get_p() const {
662  return get_hpr()[1];
663 }
664 
665 INLINE PN_stdfloat NodePath::
666 get_r() const {
667  return get_hpr()[2];
668 }
669 
670 /**
671  * Sets the scale component of the transform, leaving translation and rotation
672  * untouched.
673  */
674 INLINE void NodePath::
675 set_scale(PN_stdfloat scale) {
676  set_scale(LVecBase3(scale, scale, scale));
677 }
678 
679 INLINE void NodePath::
680 set_scale(PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) {
681  set_scale(LVecBase3(sx, sy, sz));
682 }
683 
684 INLINE PN_stdfloat NodePath::
685 get_sx() const {
686  return get_scale()[0];
687 }
688 
689 INLINE PN_stdfloat NodePath::
690 get_sy() const {
691  return get_scale()[1];
692 }
693 
694 INLINE PN_stdfloat NodePath::
695 get_sz() const {
696  return get_scale()[2];
697 }
698 
699 /**
700  * Sets the shear component of the transform, leaving translation, rotation,
701  * and scale untouched.
702  */
703 INLINE void NodePath::
704 set_shear(PN_stdfloat shxy, PN_stdfloat shxz, PN_stdfloat shyz) {
705  set_shear(LVecBase3(shxy, shxz, shyz));
706 }
707 
708 INLINE PN_stdfloat NodePath::
709 get_shxy() const {
710  return get_shear()[0];
711 }
712 
713 INLINE PN_stdfloat NodePath::
714 get_shxz() const {
715  return get_shear()[1];
716 }
717 
718 INLINE PN_stdfloat NodePath::
719 get_shyz() const {
720  return get_shear()[2];
721 }
722 
723 /**
724  * Sets the translation and rotation component of the transform, leaving scale
725  * untouched.
726  */
727 INLINE void NodePath::
728 set_pos_hpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
729  set_pos_hpr(LVecBase3(x, y, z), LVecBase3(h, p, r));
730 }
731 
732 /**
733  * Sets the rotation and scale components of the transform, leaving
734  * translation untouched.
735  */
736 INLINE void NodePath::
737 set_hpr_scale(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) {
738  set_hpr_scale(LVecBase3(h, p, r), LVecBase3(sx, sy, sz));
739 }
740 
741 /**
742  * Completely replaces the transform with new translation, rotation, and scale
743  * components.
744  */
745 INLINE void NodePath::
746 set_pos_hpr_scale(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r,
747  PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) {
748  set_pos_hpr_scale(LVecBase3(x, y, z), LVecBase3(h, p, r),
749  LVecBase3(sx, sy, sz));
750 }
751 
752 /**
753  * Completely removes any transform from the referenced node.
754  */
755 INLINE void NodePath::
756 clear_mat() {
757  nassertv_always(!is_empty());
758  node()->clear_transform();
759 }
760 
761 /**
762  * Returns true if a non-identity transform matrix has been applied to the
763  * referenced node, false otherwise.
764  */
765 INLINE bool NodePath::
766 has_mat() const {
767  nassertr_always(!is_empty(), false);
768  return !node()->get_transform()->is_identity();
769 }
770 
771 /**
772  * Returns the transform matrix that has been applied to the referenced node,
773  * or the identity matrix if no matrix has been applied.
774  */
775 INLINE const LMatrix4 &NodePath::
776 get_mat() const {
777  nassertr_always(!is_empty(), LMatrix4::ident_mat());
778 
779  return node()->get_transform()->get_mat();
780 }
781 
782 
783 /**
784  * Sets the transform on this NodePath so that it rotates to face the
785  * indicated point in space. This will overwrite any previously existing
786  * scale on the node, although it will preserve any translation.
787  */
788 INLINE void NodePath::
789 look_at(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
790  look_at(LPoint3(x, y, z));
791 }
792 
793 /**
794  * Behaves like look_at(), but with a strong preference to keeping the up
795  * vector oriented in the indicated "up" direction.
796  */
797 INLINE void NodePath::
798 heads_up(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
799  heads_up(LPoint3(x, y, z));
800 }
801 
802 /**
803  * Sets the translation component of the transform, relative to the other
804  * node.
805  */
806 INLINE void NodePath::
807 set_pos(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
808  set_pos(other, LPoint3(x, y, z));
809 }
810 
811 /**
812  * Sets the translation component, without changing the "previous" position,
813  * so that the collision system will see the node as moving fluidly from its
814  * previous position to its new position.
815  */
816 INLINE void NodePath::
817 set_fluid_pos(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
818  set_fluid_pos(other, LPoint3(x, y, z));
819 }
820 
821 INLINE PN_stdfloat NodePath::
822 get_x(const NodePath &other) const {
823  return get_pos(other)[0];
824 }
825 
826 INLINE PN_stdfloat NodePath::
827 get_y(const NodePath &other) const {
828  return get_pos(other)[1];
829 }
830 
831 INLINE PN_stdfloat NodePath::
832 get_z(const NodePath &other) const {
833  return get_pos(other)[2];
834 }
835 
836 /**
837  * Sets the rotation component of the transform, relative to the other node.
838  */
839 INLINE void NodePath::
840 set_hpr(const NodePath &other, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
841  set_hpr(other, LPoint3(h, p, r));
842 }
843 
844 INLINE PN_stdfloat NodePath::
845 get_h(const NodePath &other) const {
846  return get_hpr(other)[0];
847 }
848 
849 INLINE PN_stdfloat NodePath::
850 get_p(const NodePath &other) const {
851  return get_hpr(other)[1];
852 }
853 
854 INLINE PN_stdfloat NodePath::
855 get_r(const NodePath &other) const {
856  return get_hpr(other)[2];
857 }
858 
859 /**
860  * Sets the scale component of the transform, relative to the other node.
861  */
862 INLINE void NodePath::
863 set_scale(const NodePath &other, PN_stdfloat scale) {
864  set_scale(other, LPoint3(scale, scale, scale));
865 }
866 
867 /**
868  * Sets the scale component of the transform, relative to the other node.
869  */
870 INLINE void NodePath::
871 set_scale(const NodePath &other, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) {
872  set_scale(other, LPoint3(sx, sy, sz));
873 }
874 
875 /**
876  * Returns the relative scale of the referenced node as seen from the other
877  * node.
878  */
879 INLINE PN_stdfloat NodePath::
880 get_sx(const NodePath &other) const {
881  return get_scale(other)[0];
882 }
883 
884 INLINE PN_stdfloat NodePath::
885 get_sy(const NodePath &other) const {
886  return get_scale(other)[1];
887 }
888 
889 INLINE PN_stdfloat NodePath::
890 get_sz(const NodePath &other) const {
891  return get_scale(other)[2];
892 }
893 
894 /**
895  * Sets the shear component of the transform, relative to the other node.
896  */
897 INLINE void NodePath::
898 set_shear(const NodePath &other, PN_stdfloat shxy, PN_stdfloat shxz, PN_stdfloat shyz) {
899  set_shear(other, LPoint3(shxy, shxz, shyz));
900 }
901 
902 /**
903  * Returns the relative shear of the referenced node as seen from the other
904  * node.
905  */
906 INLINE PN_stdfloat NodePath::
907 get_shxy(const NodePath &other) const {
908  return get_shear(other)[0];
909 }
910 
911 INLINE PN_stdfloat NodePath::
912 get_shxz(const NodePath &other) const {
913  return get_shear(other)[1];
914 }
915 
916 INLINE PN_stdfloat NodePath::
917 get_shyz(const NodePath &other) const {
918  return get_shear(other)[2];
919 }
920 
921 /**
922  * Sets the translation and rotation component of the transform, relative to
923  * the other node.
924  */
925 INLINE void NodePath::
926 set_pos_hpr(const NodePath &other,
927  PN_stdfloat x, PN_stdfloat y, PN_stdfloat z,
928  PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
929  set_pos_hpr(other, LVecBase3(x, y, z), LVecBase3(h, p, r));
930 }
931 
932 /**
933  * Sets the rotation and scale components of the transform, leaving
934  * translation untouched. This, or set_pos_hpr_scale, is the preferred way to
935  * update a transform when both hpr and scale are to be changed.
936  */
937 INLINE void NodePath::
938 set_hpr_scale(const NodePath &other,
939  PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) {
940  set_hpr_scale(other, LVecBase3(h, p, r), LVecBase3(sx, sy, sz));
941 }
942 
943 /**
944  * Completely replaces the transform with new translation, rotation, and scale
945  * components, relative to the other node.
946  */
947 INLINE void NodePath::
948 set_pos_hpr_scale(const NodePath &other,
949  PN_stdfloat x, PN_stdfloat y, PN_stdfloat z,
950  PN_stdfloat h, PN_stdfloat p, PN_stdfloat r,
951  PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) {
952  set_pos_hpr_scale(other, LVecBase3(x, y, z), LVecBase3(h, p, r),
953  LVecBase3(sx, sy, sz));
954 }
955 
956 /**
957  * Sets the hpr on this NodePath so that it rotates to face the indicated
958  * point in space, which is relative to the other NodePath.
959  */
960 INLINE void NodePath::
961 look_at(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
962  look_at(other, LPoint3(x, y, z));
963 }
964 
965 /**
966  * Behaves like look_at(), but with a strong preference to keeping the up
967  * vector oriented in the indicated "up" direction.
968  */
969 INLINE void NodePath::
970 heads_up(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
971  heads_up(other, LPoint3(x, y, z));
972 }
973 
974 /**
975  * Returns the straight-line distance between this referenced node's
976  * coordinate frame's origin, and that of the other node's origin.
977  */
978 INLINE PN_stdfloat NodePath::
979 get_distance(const NodePath &other) const {
980  LPoint3 pos = get_pos(other);
981  return length(LVector3(pos));
982 }
983 
984 /**
985  * Sets the color scale component of the transform
986  */
987 INLINE void NodePath::
988 set_color_scale(PN_stdfloat sr, PN_stdfloat sg, PN_stdfloat sb, PN_stdfloat sa, int priority) {
989  set_color_scale(LVecBase4(sr, sg, sb, sa), priority);
990 }
991 
992 /**
993  * Sets the color scale component of the transform
994  */
995 INLINE void NodePath::
996 compose_color_scale(PN_stdfloat sr, PN_stdfloat sg, PN_stdfloat sb, PN_stdfloat sa, int priority) {
997  compose_color_scale(LVecBase4(sr, sg, sb, sa), priority);
998 }
999 
1000 /**
1001  * Sets the red component of the color scale.
1002  * @see set_color_scale()
1003  */
1004 INLINE void NodePath::
1005 set_sr(PN_stdfloat sr) {
1006  LVecBase4 new_scale = get_color_scale();
1007  new_scale[0] = sr;
1008 
1009  set_color_scale(new_scale);
1010 }
1011 
1012 /**
1013  * Sets the green component of the color scale.
1014  * @see set_color_scale()
1015  */
1016 INLINE void NodePath::
1017 set_sg(PN_stdfloat sg) {
1018  LVecBase4 new_scale = get_color_scale();
1019  new_scale[1] = sg;
1020 
1021  set_color_scale(new_scale);
1022 }
1023 
1024 /**
1025  * Sets the blue component of the color scale.
1026  * @see set_color_scale()
1027  */
1028 INLINE void NodePath::
1029 set_sb(PN_stdfloat sb) {
1030  LVecBase4 new_scale = get_color_scale();
1031  new_scale[2] = sb;
1032 
1033  set_color_scale(new_scale);
1034 }
1035 
1036 /**
1037  * Sets the alpha component of the color scale.
1038  * @see set_color_scale()
1039  */
1040 INLINE void NodePath::
1041 set_sa(PN_stdfloat sa) {
1042  LVecBase4 new_scale = get_color_scale();
1043  new_scale[3] = sa;
1044 
1045  set_color_scale(new_scale);
1046 }
1047 
1048 /**
1049  * Gets the red component of the color scale.
1050  * @see get_color_scale()
1051  */
1052 INLINE PN_stdfloat NodePath::
1053 get_sr() const {
1054  return get_color_scale()[0];
1055 }
1056 
1057 /**
1058  * Gets the green component of the color scale.
1059  * @see get_color_scale()
1060  */
1061 INLINE PN_stdfloat NodePath::
1062 get_sg() const {
1063  return get_color_scale()[1];
1064 }
1065 
1066 /**
1067  * Gets the blue component of the color scale.
1068  * @see get_color_scale()
1069  */
1070 INLINE PN_stdfloat NodePath::
1071 get_sb() const {
1072  return get_color_scale()[2];
1073 }
1074 
1075 /**
1076  * Gets the alpha component of the color scale.
1077  * @see get_color_scale()
1078  */
1079 INLINE PN_stdfloat NodePath::
1080 get_sa() const {
1081  return get_color_scale()[3];
1082 }
1083 
1084 /**
1085  *
1086  */
1087 INLINE void NodePath::
1088 set_shader_input(CPT_InternalName id, const PTA_float &v, int priority) {
1089  set_shader_input(ShaderInput(std::move(id), v, priority));
1090 }
1091 
1092 /**
1093  *
1094  */
1095 INLINE void NodePath::
1096 set_shader_input(CPT_InternalName id, const PTA_double &v, int priority) {
1097  set_shader_input(ShaderInput(std::move(id), v, priority));
1098 }
1099 
1100 /**
1101  *
1102  */
1103 INLINE void NodePath::
1104 set_shader_input(CPT_InternalName id, const PTA_int &v, int priority) {
1105  set_shader_input(ShaderInput(std::move(id), v, priority));
1106 }
1107 
1108 /**
1109  *
1110  */
1111 INLINE void NodePath::
1112 set_shader_input(CPT_InternalName id, const PTA_LVecBase4 &v, int priority) {
1113  set_shader_input(ShaderInput(std::move(id), v, priority));
1114 }
1115 
1116 /**
1117  *
1118  */
1119 INLINE void NodePath::
1120 set_shader_input(CPT_InternalName id, const PTA_LVecBase3 &v, int priority) {
1121  set_shader_input(ShaderInput(std::move(id), v, priority));
1122 }
1123 
1124 
1125 /**
1126  *
1127  */
1128 INLINE void NodePath::
1129 set_shader_input(CPT_InternalName id, const PTA_LVecBase2 &v, int priority) {
1130  set_shader_input(ShaderInput(std::move(id), v, priority));
1131 }
1132 
1133 /**
1134  *
1135  */
1136 INLINE void NodePath::
1137 set_shader_input(CPT_InternalName id, const LVecBase4 &v, int priority) {
1138  set_shader_input(ShaderInput(std::move(id), v, priority));
1139 }
1140 
1141 /**
1142  *
1143  */
1144 INLINE void NodePath::
1145 set_shader_input(CPT_InternalName id, const LVecBase3 &v, int priority) {
1146  set_shader_input(ShaderInput(std::move(id), v, priority));
1147 }
1148 
1149 /**
1150  *
1151  */
1152 INLINE void NodePath::
1153 set_shader_input(CPT_InternalName id, const LVecBase2 &v, int priority) {
1154  set_shader_input(ShaderInput(std::move(id), v, priority));
1155 }
1156 
1157 /**
1158  *
1159  */
1160 INLINE void NodePath::
1161 set_shader_input(CPT_InternalName id, const PTA_LVecBase4i &v, int priority) {
1162  set_shader_input(ShaderInput(std::move(id), v, priority));
1163 }
1164 
1165 /**
1166  *
1167  */
1168 INLINE void NodePath::
1169 set_shader_input(CPT_InternalName id, const PTA_LVecBase3i &v, int priority) {
1170  set_shader_input(ShaderInput(std::move(id), v, priority));
1171 }
1172 
1173 
1174 /**
1175  *
1176  */
1177 INLINE void NodePath::
1178 set_shader_input(CPT_InternalName id, const PTA_LVecBase2i &v, int priority) {
1179  set_shader_input(ShaderInput(std::move(id), v, priority));
1180 }
1181 
1182 /**
1183  *
1184  */
1185 INLINE void NodePath::
1186 set_shader_input(CPT_InternalName id, const LVecBase4i &v, int priority) {
1187  set_shader_input(ShaderInput(std::move(id), v, priority));
1188 }
1189 
1190 /**
1191  *
1192  */
1193 INLINE void NodePath::
1194 set_shader_input(CPT_InternalName id, const LVecBase3i &v, int priority) {
1195  set_shader_input(ShaderInput(std::move(id), v, priority));
1196 }
1197 
1198 /**
1199  *
1200  */
1201 INLINE void NodePath::
1202 set_shader_input(CPT_InternalName id, const LVecBase2i &v, int priority) {
1203  set_shader_input(ShaderInput(std::move(id), v, priority));
1204 }
1205 
1206 /**
1207  *
1208  */
1209 INLINE void NodePath::
1210 set_shader_input(CPT_InternalName id, const PTA_LMatrix4 &v, int priority) {
1211  set_shader_input(ShaderInput(std::move(id), v, priority));
1212 }
1213 
1214 /**
1215  *
1216  */
1217 INLINE void NodePath::
1218 set_shader_input(CPT_InternalName id, const PTA_LMatrix3 &v, int priority) {
1219  set_shader_input(ShaderInput(std::move(id), v, priority));
1220 }
1221 
1222 /**
1223  *
1224  */
1225 INLINE void NodePath::
1226 set_shader_input(CPT_InternalName id, const LMatrix4 &v, int priority) {
1227  set_shader_input(ShaderInput(std::move(id), v, priority));
1228 }
1229 
1230 /**
1231  *
1232  */
1233 INLINE void NodePath::
1234 set_shader_input(CPT_InternalName id, const LMatrix3 &v, int priority) {
1235  set_shader_input(ShaderInput(std::move(id), v, priority));
1236 }
1237 
1238 /**
1239  *
1240  */
1241 INLINE void NodePath::
1242 set_shader_input(CPT_InternalName id, Texture *tex, int priority) {
1243  set_shader_input(ShaderInput(std::move(id), tex, priority));
1244 }
1245 
1246 /**
1247  *
1248  */
1249 INLINE void NodePath::
1250 set_shader_input(CPT_InternalName id, Texture *tex, const SamplerState &sampler, int priority) {
1251  set_shader_input(ShaderInput(std::move(id), tex, sampler, priority));
1252 }
1253 
1254 /**
1255  *
1256  */
1257 INLINE void NodePath::
1258 set_shader_input(CPT_InternalName id, Texture *tex, bool read, bool write, int z, int n, int priority) {
1259  set_shader_input(ShaderInput(std::move(id), tex, read, write, z, n, priority));
1260 }
1261 
1262 /**
1263  *
1264  */
1265 INLINE void NodePath::
1266 set_shader_input(CPT_InternalName id, ShaderBuffer *buf, int priority) {
1267  set_shader_input(ShaderInput(std::move(id), buf, priority));
1268 }
1269 
1270 /**
1271  *
1272  */
1273 INLINE void NodePath::
1274 set_shader_input(CPT_InternalName id, const NodePath &np, int priority) {
1275  set_shader_input(ShaderInput(std::move(id), np, priority));
1276 }
1277 
1278 /**
1279  *
1280  */
1281 INLINE void NodePath::
1282 set_shader_input(CPT_InternalName id, int n1, int n2, int n3, int n4, int priority) {
1283  set_shader_input(ShaderInput(std::move(id), LVecBase4i(n1, n2, n3, n4), priority));
1284 }
1285 
1286 /**
1287  *
1288  */
1289 INLINE void NodePath::
1290 set_shader_input(CPT_InternalName id, PN_stdfloat n1, PN_stdfloat n2, PN_stdfloat n3, PN_stdfloat n4, int priority) {
1291  set_shader_input(ShaderInput(std::move(id), LVecBase4(n1, n2, n3, n4), priority));
1292 }
1293 
1294 /**
1295  * Sets a texture matrix on the current node to apply the indicated offset to
1296  * UV's for the given stage.
1297  *
1298  * This call is appropriate for ordinary 2-d texture coordinates.
1299  */
1300 INLINE void NodePath::
1301 set_tex_offset(TextureStage *stage, PN_stdfloat u, PN_stdfloat v) {
1302  set_tex_offset(stage, LVecBase2(u, v));
1303 }
1304 
1305 /**
1306  * Sets a texture matrix on the current node to apply the indicated offset to
1307  * UV's for the given stage.
1308  *
1309  * This call is appropriate for ordinary 2-d texture coordinates.
1310  */
1311 INLINE void NodePath::
1312 set_tex_offset(TextureStage *stage, const LVecBase2 &uv) {
1313  nassertv_always(!is_empty());
1314  set_tex_transform(stage,
1315  get_tex_transform(stage)->set_pos2d(uv));
1316 }
1317 
1318 /**
1319  * Sets a texture matrix on the current node to apply the indicated rotation,
1320  * clockwise in degrees, to UV's for the given stage.
1321  *
1322  * This call is appropriate for ordinary 2-d texture coordinates.
1323  */
1324 INLINE void NodePath::
1325 set_tex_rotate(TextureStage *stage, PN_stdfloat r) {
1326  nassertv_always(!is_empty());
1327  set_tex_transform(stage,
1328  get_tex_transform(stage)->set_rotate2d(r));
1329 }
1330 
1331 /**
1332  * Sets a texture matrix on the current node to apply the indicated scale to
1333  * UVW's for the given stage.
1334  *
1335  * This call is appropriate for 2-d or 3-d texture coordinates.
1336  */
1337 INLINE void NodePath::
1338 set_tex_scale(TextureStage *stage, PN_stdfloat scale) {
1339  nassertv_always(!is_empty());
1340  set_tex_transform(stage,
1341  get_tex_transform(stage)->set_scale(scale));
1342 }
1343 
1344 /**
1345  * Sets a texture matrix on the current node to apply the indicated scale to
1346  * UV's for the given stage.
1347  *
1348  * This call is appropriate for ordinary 2-d texture coordinates.
1349  */
1350 INLINE void NodePath::
1351 set_tex_scale(TextureStage *stage, PN_stdfloat su, PN_stdfloat sv) {
1352  set_tex_scale(stage, LVecBase2(su, sv));
1353 }
1354 
1355 /**
1356  * Sets a texture matrix on the current node to apply the indicated scale to
1357  * UV's for the given stage.
1358  *
1359  * This call is appropriate for ordinary 2-d texture coordinates.
1360  */
1361 INLINE void NodePath::
1362 set_tex_scale(TextureStage *stage, const LVecBase2 &scale) {
1363  nassertv_always(!is_empty());
1364  set_tex_transform(stage,
1365  get_tex_transform(stage)->set_scale2d(scale));
1366 }
1367 
1368 /**
1369  * Returns the offset set for the UV's for the given stage on the current
1370  * node.
1371  *
1372  * This call is appropriate for ordinary 2-d texture coordinates.
1373  */
1374 INLINE LVecBase2 NodePath::
1375 get_tex_offset(TextureStage *stage) const {
1376  nassertr_always(!is_empty(), LVecBase2::zero());
1377  return get_tex_transform(stage)->get_pos2d();
1378 }
1379 
1380 /**
1381  * Returns the rotation set for the UV's for the given stage on the current
1382  * node.
1383  *
1384  * This call is appropriate for ordinary 2-d texture coordinates.
1385  */
1386 INLINE PN_stdfloat NodePath::
1387 get_tex_rotate(TextureStage *stage) const {
1388  nassertr_always(!is_empty(), 0.0f);
1389  return get_tex_transform(stage)->get_rotate2d();
1390 }
1391 
1392 /**
1393  * Returns the scale set for the UV's for the given stage on the current node.
1394  *
1395  * This call is appropriate for ordinary 2-d texture coordinates.
1396  */
1397 INLINE LVecBase2 NodePath::
1398 get_tex_scale(TextureStage *stage) const {
1399  nassertr_always(!is_empty(), LVecBase2(1.0f, 1.0f));
1400  return get_tex_transform(stage)->get_scale2d();
1401 }
1402 
1403 /**
1404  * Sets a texture matrix on the current node to apply the indicated offset to
1405  * UVW's for the given stage.
1406  *
1407  * This call is appropriate for 3-d texture coordinates.
1408  */
1409 INLINE void NodePath::
1410 set_tex_pos(TextureStage *stage, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) {
1411  set_tex_pos(stage, LVecBase3(u, v, w));
1412 }
1413 
1414 /**
1415  * Sets a texture matrix on the current node to apply the indicated offset to
1416  * UVW's for the given stage.
1417  *
1418  * This call is appropriate for 3-d texture coordinates.
1419  */
1420 INLINE void NodePath::
1421 set_tex_pos(TextureStage *stage, const LVecBase3 &uvw) {
1422  nassertv_always(!is_empty());
1423  set_tex_transform(stage,
1424  get_tex_transform(stage)->set_pos(uvw));
1425 }
1426 
1427 /**
1428  * Sets a texture matrix on the current node to apply the indicated rotation,
1429  * as a 3-D HPR, to UVW's for the given stage.
1430  *
1431  * This call is appropriate for 3-d texture coordinates.
1432  */
1433 INLINE void NodePath::
1434 set_tex_hpr(TextureStage *stage, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
1435  set_tex_hpr(stage, LVecBase3(h, p, r));
1436 }
1437 
1438 /**
1439  * Sets a texture matrix on the current node to apply the indicated rotation,
1440  * as a 3-D HPR, to UVW's for the given stage.
1441  *
1442  * This call is appropriate for 3-d texture coordinates.
1443  */
1444 INLINE void NodePath::
1445 set_tex_hpr(TextureStage *stage, const LVecBase3 &hpr) {
1446  nassertv_always(!is_empty());
1447  set_tex_transform(stage,
1448  get_tex_transform(stage)->set_hpr(hpr));
1449 }
1450 
1451 /**
1452  * Sets a texture matrix on the current node to apply the indicated scale to
1453  * UVW's for the given stage.
1454  *
1455  * This call is appropriate for 3-d texture coordinates.
1456  */
1457 INLINE void NodePath::
1458 set_tex_scale(TextureStage *stage, PN_stdfloat su, PN_stdfloat sv, PN_stdfloat sw) {
1459  set_tex_scale(stage, LVecBase3(su, sv, sw));
1460 }
1461 
1462 /**
1463  * Sets a texture matrix on the current node to apply the indicated scale to
1464  * UVW's for the given stage.
1465  *
1466  * This call is appropriate for 3-d texture coordinates.
1467  */
1468 INLINE void NodePath::
1469 set_tex_scale(TextureStage *stage, const LVecBase3 &scale) {
1470  nassertv_always(!is_empty());
1471  set_tex_transform(stage,
1472  get_tex_transform(stage)->set_scale(scale));
1473 }
1474 
1475 /**
1476  * Returns the offset set for the UVW's for the given stage on the current
1477  * node.
1478  *
1479  * This call is appropriate for 3-d texture coordinates.
1480  */
1481 INLINE LVecBase3 NodePath::
1482 get_tex_pos(TextureStage *stage) const {
1483  nassertr_always(!is_empty(), LVecBase3::zero());
1484  return get_tex_transform(stage)->get_pos();
1485 }
1486 
1487 /**
1488  * Returns the 3-D HPR set for the UVW's for the given stage on the current
1489  * node.
1490  *
1491  * This call is appropriate for 3-d texture coordinates.
1492  */
1493 INLINE LVecBase3 NodePath::
1494 get_tex_hpr(TextureStage *stage) const {
1495  nassertr_always(!is_empty(), LVecBase3::zero());
1496  return get_tex_transform(stage)->get_hpr();
1497 }
1498 
1499 /**
1500  * Returns the scale set for the UVW's for the given stage on the current
1501  * node.
1502  *
1503  * This call is appropriate for 3-d texture coordinates.
1504  */
1505 INLINE LVecBase3 NodePath::
1506 get_tex_scale_3d(TextureStage *stage) const {
1507  nassertr_always(!is_empty(), LVecBase3(1.0f, 1.0f, 1.0f));
1508  return get_tex_transform(stage)->get_scale();
1509 }
1510 
1511 /**
1512  * Sets a texture matrix on the current node to apply the indicated offset to
1513  * UV's for the given stage.
1514  *
1515  * This call is appropriate for ordinary 2-d texture coordinates.
1516  */
1517 INLINE void NodePath::
1518 set_tex_offset(const NodePath &other, TextureStage *stage, PN_stdfloat u, PN_stdfloat v) {
1519  set_tex_offset(other, stage, LVecBase2(u, v));
1520 }
1521 
1522 /**
1523  * Sets a texture matrix on the current node to apply the indicated offset to
1524  * UV's for the given stage.
1525  *
1526  * This call is appropriate for ordinary 2-d texture coordinates.
1527  */
1528 INLINE void NodePath::
1529 set_tex_offset(const NodePath &other, TextureStage *stage, const LVecBase2 &uv) {
1530  nassertv_always(!is_empty());
1531  set_tex_transform(other, stage,
1532  get_tex_transform(other, stage)->set_pos2d(uv));
1533 }
1534 
1535 /**
1536  * Sets a texture matrix on the current node to apply the indicated rotation,
1537  * clockwise in degrees, to UV's for the given stage.
1538  *
1539  * This call is appropriate for ordinary 2-d texture coordinates.
1540  */
1541 INLINE void NodePath::
1542 set_tex_rotate(const NodePath &other, TextureStage *stage, PN_stdfloat r) {
1543  nassertv_always(!is_empty());
1544  set_tex_transform(other, stage,
1545  get_tex_transform(other, stage)->set_rotate2d(r));
1546 }
1547 
1548 /**
1549  * Sets a texture matrix on the current node to apply the indicated scale to
1550  * UV's for the given stage.
1551  *
1552  * This call is appropriate for 2-d or 3-d texture coordinates.
1553  */
1554 INLINE void NodePath::
1555 set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat scale) {
1556  nassertv_always(!is_empty());
1557  set_tex_transform(other, stage,
1558  get_tex_transform(stage)->set_scale(scale));
1559 }
1560 
1561 /**
1562  * Sets a texture matrix on the current node to apply the indicated scale to
1563  * UV's for the given stage.
1564  *
1565  * This call is appropriate for ordinary 2-d texture coordinates.
1566  */
1567 INLINE void NodePath::
1568 set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat su, PN_stdfloat sv) {
1569  set_tex_scale(other, stage, LVecBase2(su, sv));
1570 }
1571 
1572 /**
1573  * Sets a texture matrix on the current node to apply the indicated scale to
1574  * UV's for the given stage.
1575  *
1576  * This call is appropriate for ordinary 2-d texture coordinates.
1577  */
1578 INLINE void NodePath::
1579 set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase2 &scale) {
1580  nassertv_always(!is_empty());
1581  set_tex_transform(other, stage,
1582  get_tex_transform(stage)->set_scale2d(scale));
1583 }
1584 
1585 /**
1586  * Returns the offset set for the UV's for the given stage on the current
1587  * node.
1588  *
1589  * This call is appropriate for ordinary 2-d texture coordinates.
1590  */
1591 INLINE LVecBase2 NodePath::
1592 get_tex_offset(const NodePath &other, TextureStage *stage) const {
1593  nassertr_always(!is_empty(), LVecBase2::zero());
1594  return get_tex_transform(other, stage)->get_pos2d();
1595 }
1596 
1597 /**
1598  * Returns the rotation set for the UV's for the given stage on the current
1599  * node.
1600  *
1601  * This call is appropriate for ordinary 2-d texture coordinates.
1602  */
1603 INLINE PN_stdfloat NodePath::
1604 get_tex_rotate(const NodePath &other, TextureStage *stage) const {
1605  nassertr_always(!is_empty(), 0.0f);
1606  return get_tex_transform(other, stage)->get_rotate2d();
1607 }
1608 
1609 /**
1610  * Returns the scale set for the UV's for the given stage on the current node.
1611  *
1612  * This call is appropriate for ordinary 2-d texture coordinates.
1613  */
1614 INLINE LVecBase2 NodePath::
1615 get_tex_scale(const NodePath &other, TextureStage *stage) const {
1616  nassertr_always(!is_empty(), LVecBase2(1.0f, 1.0f));
1617  return get_tex_transform(other, stage)->get_scale2d();
1618 }
1619 
1620 /**
1621  * Sets a texture matrix on the current node to apply the indicated offset to
1622  * UVW's for the given stage.
1623  *
1624  * This call is appropriate for 3-d texture coordinates.
1625  */
1626 INLINE void NodePath::
1627 set_tex_pos(const NodePath &other, TextureStage *stage, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) {
1628  set_tex_pos(other, stage, LVecBase3(u, v, w));
1629 }
1630 
1631 /**
1632  * Sets a texture matrix on the current node to apply the indicated offset to
1633  * UVW's for the given stage.
1634  *
1635  * This call is appropriate for 3-d texture coordinates.
1636  */
1637 INLINE void NodePath::
1638 set_tex_pos(const NodePath &other, TextureStage *stage, const LVecBase3 &uvw) {
1639  nassertv_always(!is_empty());
1640  set_tex_transform(other, stage,
1641  get_tex_transform(stage)->set_pos(uvw));
1642 }
1643 
1644 /**
1645  * Sets a texture matrix on the current node to apply the indicated rotation,
1646  * as a 3-D HPR, to UVW's for the given stage.
1647  *
1648  * This call is appropriate for 3-d texture coordinates.
1649  */
1650 INLINE void NodePath::
1651 set_tex_hpr(const NodePath &other, TextureStage *stage, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) {
1652  set_tex_hpr(other, stage, LVecBase3(h, p, r));
1653 }
1654 
1655 /**
1656  * Sets a texture matrix on the current node to apply the indicated rotation,
1657  * as a 3-D HPR, to UVW's for the given stage.
1658  *
1659  * This call is appropriate for 3-d texture coordinates.
1660  */
1661 INLINE void NodePath::
1662 set_tex_hpr(const NodePath &other, TextureStage *stage, const LVecBase3 &hpr) {
1663  nassertv_always(!is_empty());
1664  set_tex_transform(other, stage,
1665  get_tex_transform(stage)->set_hpr(hpr));
1666 }
1667 
1668 /**
1669  * Sets a texture matrix on the current node to apply the indicated scale to
1670  * UVW's for the given stage.
1671  *
1672  * This call is appropriate for 3-d texture coordinates.
1673  */
1674 INLINE void NodePath::
1675 set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat su, PN_stdfloat sv, PN_stdfloat sw) {
1676  set_tex_scale(other, stage, LVecBase3(su, sv, sw));
1677 }
1678 
1679 /**
1680  * Sets a texture matrix on the current node to apply the indicated scale to
1681  * UVW's for the given stage.
1682  *
1683  * This call is appropriate for 3-d texture coordinates.
1684  */
1685 INLINE void NodePath::
1686 set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase3 &scale) {
1687  nassertv_always(!is_empty());
1688  set_tex_transform(other, stage,
1689  get_tex_transform(stage)->set_scale(scale));
1690 }
1691 
1692 /**
1693  * Returns the offset set for the UVW's for the given stage on the current
1694  * node.
1695  *
1696  * This call is appropriate for 3-d texture coordinates.
1697  */
1698 INLINE LVecBase3 NodePath::
1699 get_tex_pos(const NodePath &other, TextureStage *stage) const {
1700  nassertr_always(!is_empty(), LVecBase3::zero());
1701  return get_tex_transform(stage)->get_pos();
1702 }
1703 
1704 /**
1705  * Returns the 3-D HPR set for the UVW's for the given stage on the current
1706  * node.
1707  *
1708  * This call is appropriate for 3-d texture coordinates.
1709  */
1710 INLINE LVecBase3 NodePath::
1711 get_tex_hpr(const NodePath &other, TextureStage *stage) const {
1712  nassertr_always(!is_empty(), LVecBase3::zero());
1713  return get_tex_transform(stage)->get_hpr();
1714 }
1715 
1716 /**
1717  * Returns the scale set for the UVW's for the given stage on the current
1718  * node.
1719  *
1720  * This call is appropriate for 3-d texture coordinates.
1721  */
1722 INLINE LVecBase3 NodePath::
1723 get_tex_scale_3d(const NodePath &other, TextureStage *stage) const {
1724  nassertr_always(!is_empty(), LVecBase3(1.0f, 1.0f, 1.0f));
1725  return get_tex_transform(stage)->get_scale();
1726 }
1727 
1728 /**
1729  * Undoes the effect of project_texture().
1730  */
1731 INLINE void NodePath::
1733  clear_texture(stage);
1734  clear_tex_gen(stage);
1735  clear_tex_projector(stage);
1736 }
1737 
1738 /**
1739  * Returns true if there are at least some vertices at this node and below
1740  * that use the named texture coordinate set, false otherwise. Pass the empty
1741  * string for the default texture coordinate set.
1742  */
1743 INLINE bool NodePath::
1744 has_texcoord(const std::string &texcoord_name) const {
1745  return has_vertex_column(InternalName::get_texcoord_name(texcoord_name));
1746 }
1747 
1748 /**
1749  * Puts a billboard transition on the node such that it will rotate in two
1750  * dimensions around the up axis.
1751  */
1752 INLINE void NodePath::
1753 set_billboard_axis(PN_stdfloat offset) {
1754  set_billboard_axis(NodePath(), offset);
1755 }
1756 
1757 /**
1758  * Puts a billboard transition on the node such that it will rotate in three
1759  * dimensions about the origin, keeping its up vector oriented to the top of
1760  * the camera.
1761  */
1762 INLINE void NodePath::
1763 set_billboard_point_eye(PN_stdfloat offset, bool fixed_depth) {
1764  set_billboard_point_eye(NodePath(), offset, fixed_depth);
1765 }
1766 
1767 /**
1768  * Puts a billboard transition on the node such that it will rotate in three
1769  * dimensions about the origin, keeping its up vector oriented to the sky.
1770  */
1771 INLINE void NodePath::
1772 set_billboard_point_world(PN_stdfloat offset) {
1774 }
1775 
1776 /**
1777  * Adds the indicated adjustment amount (which may be negative) to the
1778  * priority for all transitions on the referenced node, and for all nodes in
1779  * the subgraph below. This can be used to force these nodes not to be
1780  * overridden by a high-level state change above. If the priority would drop
1781  * below zero, it is set to zero.
1782  */
1783 INLINE void NodePath::
1784 adjust_all_priorities(int adjustment) {
1785  nassertv_always(!is_empty());
1786  r_adjust_all_priorities(node(), adjustment);
1787 }
1788 
1789 /**
1790  * Undoes the effect of a previous hide() on this node: makes the referenced
1791  * node (and the entire subgraph below this node) visible to all cameras.
1792  *
1793  * This will not reveal the node if a parent node has been hidden.
1794  */
1795 INLINE void NodePath::
1796 show() {
1797  nassertv_always(!is_empty());
1798  node()->adjust_draw_mask(DrawMask::all_off(), DrawMask::all_off(), PandaNode::get_overall_bit());
1799 }
1800 
1801 /**
1802  * Makes the referenced node visible just to the cameras whose camera_mask
1803  * shares the indicated bits.
1804  *
1805  * This undoes the effect of a previous hide() call. It will not reveal the
1806  * node if a parent node has been hidden. However, see show_through().
1807  */
1808 INLINE void NodePath::
1809 show(DrawMask camera_mask) {
1810  nassertv_always(!is_empty());
1811  camera_mask &= ~PandaNode::get_overall_bit();
1813 }
1814 
1815 /**
1816  * Makes the referenced node visible just to the cameras whose camera_mask
1817  * shares the indicated bits.
1818  *
1819  * Unlike show(), this will reveal the node even if a parent node has been
1820  * hidden, thus "showing through" a parent's hide().
1821  */
1822 INLINE void NodePath::
1823 show_through() {
1824  nassertv_always(!is_empty());
1825  node()->adjust_draw_mask(PandaNode::get_overall_bit(), DrawMask::all_off(), DrawMask::all_off());
1826 }
1827 
1828 /**
1829  * Makes the referenced node visible just to the cameras whose camera_mask
1830  * shares the indicated bits.
1831  *
1832  * Unlike show(), this will reveal the node even if a parent node has been
1833  * hidden via the one-parameter hide() method, thus "showing through" a
1834  * parent's hide(). (However, it will not show through a parent's hide() call
1835  * if the no-parameter form of hide() was used.)
1836  */
1837 INLINE void NodePath::
1838 show_through(DrawMask camera_mask) {
1839  nassertv_always(!is_empty());
1840  camera_mask &= ~PandaNode::get_overall_bit();
1842 }
1843 
1844 /**
1845  * Makes the referenced node (and the entire subgraph below this node)
1846  * invisible to all cameras. It remains part of the scene graph, its bounding
1847  * volume still contributes to its parent's bounding volume, and it will still
1848  * be involved in collision tests.
1849  *
1850  * To undo this, call show().
1851  */
1852 INLINE void NodePath::
1853 hide() {
1854  nassertv_always(!is_empty());
1855  node()->adjust_draw_mask(DrawMask::all_off(), PandaNode::get_overall_bit(), DrawMask::all_off());
1856 }
1857 
1858 /**
1859  * Makes the referenced node invisible just to the cameras whose camera_mask
1860  * shares the indicated bits.
1861  *
1862  * This will also hide any nodes below this node in the scene graph, including
1863  * those nodes for which show() has been called, but it will not hide
1864  * descendent nodes for which show_through() has been called.
1865  */
1866 INLINE void NodePath::
1867 hide(DrawMask camera_mask) {
1868  nassertv_always(!is_empty());
1869  camera_mask &= ~PandaNode::get_overall_bit();
1871 }
1872 
1873 /**
1874  * Returns true if the referenced node is hidden from the indicated camera(s)
1875  * either directly, or because some ancestor is hidden.
1876  */
1877 INLINE bool NodePath::
1878 is_hidden(DrawMask camera_mask) const {
1879  return !get_hidden_ancestor(camera_mask).is_empty();
1880 }
1881 
1882 /**
1883  * Returns true if the referenced node is stashed either directly, or because
1884  * some ancestor is stashed.
1885  */
1886 INLINE bool NodePath::
1887 is_stashed() const {
1888  return !get_stashed_ancestor().is_empty();
1889 }
1890 
1891 /**
1892  * Returns the union of all of the into_collide_masks for nodes at this level
1893  * and below. This is the same thing as node()->get_net_collide_mask().
1894  *
1895  * If you want to return what the into_collide_mask of this node itself is,
1896  * without regard to its children, use node()->get_into_collide_mask().
1897  */
1899 get_collide_mask() const {
1900  nassertr_always(!is_empty(), CollideMask::all_off());
1901  return node()->get_net_collide_mask();
1902 }
1903 
1904 /**
1905  * Recursively applies the indicated CollideMask to the into_collide_masks for
1906  * all nodes at this level and below. If node_type is not TypeHandle::none(),
1907  * then only nodes matching (or inheriting from) the indicated PandaNode
1908  * subclass are modified.
1909  *
1910  * The default is to change all bits, but if bits_to_change is not all bits
1911  * on, then only the bits that are set in bits_to_change are modified,
1912  * allowing this call to change only a subset of the bits in the subgraph.
1913  */
1914 INLINE void NodePath::
1915 set_collide_mask(CollideMask new_mask, CollideMask bits_to_change,
1916  TypeHandle node_type) {
1917  nassertv_always(!is_empty());
1918  if (node_type == TypeHandle::none()) {
1919  node_type = PandaNode::get_class_type();
1920  }
1921 
1922  r_set_collide_mask(node(), ~bits_to_change, new_mask & bits_to_change,
1923  node_type);
1924 }
1925 
1926 /**
1927  * Returns true if the two paths are equivalent; that is, if they contain the
1928  * same list of nodes in the same order.
1929  */
1930 INLINE bool NodePath::
1931 operator == (const NodePath &other) const {
1932  return _head == other._head;
1933 }
1934 
1935 /**
1936  * Returns true if the two paths are not equivalent.
1937  */
1938 INLINE bool NodePath::
1939 operator != (const NodePath &other) const {
1940  return _head != other._head;
1941 }
1942 
1943 /**
1944  * Returns true if this NodePath sorts before the other one, false otherwise.
1945  * The sorting order of two nonequivalent NodePaths is consistent but
1946  * undefined, and is useful only for storing NodePaths in a sorted container
1947  * like an STL set.
1948  */
1949 INLINE bool NodePath::
1950 operator < (const NodePath &other) const {
1951  return _head < other._head;
1952 }
1953 
1954 /**
1955  * Returns a number less than zero if this NodePath sorts before the other
1956  * one, greater than zero if it sorts after, or zero if they are equivalent.
1957  *
1958  * Two NodePaths are considered equivalent if they consist of exactly the same
1959  * list of nodes in the same order. Otherwise, they are different; different
1960  * NodePaths will be ranked in a consistent but undefined ordering; the
1961  * ordering is useful only for placing the NodePaths in a sorted container
1962  * like an STL set.
1963  */
1964 INLINE int NodePath::
1965 compare_to(const NodePath &other) const {
1966  // Nowadays, the NodePathComponents at the head are pointerwise equivalent
1967  // if and only if the NodePaths are equivalent. So we only have to compare
1968  // pointers.
1969  if (_head != other._head) {
1970  return _head < other._head ? -1 : 1;
1971  }
1972  return 0;
1973 }
1974 
1975 /**
1976  * Recursively walks through the scene graph at this level and below, looking
1977  * for ModelNodes, and calls model_node->set_preserve_transform(PT_drop_node)
1978  * on each one. This allows a subsequent call to flatten_strong() to
1979  * eliminate all of the ModelNodes.
1980  *
1981  * Returns the number of ModelNodes found.
1982  */
1983 INLINE int NodePath::
1985  nassertr_always(!is_empty(), 0);
1986  return r_clear_model_nodes(node());
1987 }
1988 
1989 /**
1990  * Associates a user-defined value with a user-defined key which is stored on
1991  * the node. This value has no meaning to Panda; but it is stored
1992  * indefinitely on the node until it is requested again.
1993  *
1994  * Each unique key stores a different string value. There is no effective
1995  * limit on the number of different keys that may be stored or on the length
1996  * of any one key's value.
1997  */
1998 INLINE void NodePath::
1999 set_tag(const std::string &key, const std::string &value) {
2000  nassertv_always(!is_empty());
2001  node()->set_tag(key, value);
2002 }
2003 
2004 /**
2005  * Retrieves the user-defined value that was previously set on this node for
2006  * the particular key, if any. If no value has been previously set, returns
2007  * the empty string. See also get_net_tag().
2008  */
2009 INLINE std::string NodePath::
2010 get_tag(const std::string &key) const {
2011  // An empty NodePath quietly returns no tags. This makes get_net_tag()
2012  // easier to implement.
2013  if (is_empty()) {
2014  return std::string();
2015  }
2016  return node()->get_tag(key);
2017 }
2018 
2019 /**
2020  * Fills the given vector up with the list of tags on this PandaNode.
2021  *
2022  * It is the user's responsibility to ensure that the keys vector is empty
2023  * before making this call; otherwise, the new files will be appended to it.
2024  */
2025 INLINE void NodePath::
2026 get_tag_keys(vector_string &keys) const {
2027  nassertv_always(!is_empty());
2028  node()->get_tag_keys(keys);
2029 }
2030 
2031 /**
2032  * Returns true if a value has been defined on this node for the particular
2033  * key (even if that value is the empty string), or false if no value has been
2034  * set. See also has_net_tag().
2035  */
2036 INLINE bool NodePath::
2037 has_tag(const std::string &key) const {
2038  // An empty NodePath quietly has no tags. This makes has_net_tag() easier
2039  // to implement.
2040  if (is_empty()) {
2041  return false;
2042  }
2043  return node()->has_tag(key);
2044 }
2045 
2046 /**
2047  * Removes the value defined for this key on this particular node. After a
2048  * call to clear_tag(), has_tag() will return false for the indicated key.
2049  */
2050 INLINE void NodePath::
2051 clear_tag(const std::string &key) {
2052  nassertv_always(!is_empty());
2053  node()->clear_tag(key);
2054 }
2055 
2056 /**
2057  * Returns the tag value that has been defined on this node, or the nearest
2058  * ancestor node, for the indicated key. If no value has been defined for the
2059  * indicated key on any ancestor node, returns the empty string. See also
2060  * get_tag().
2061  */
2062 INLINE std::string NodePath::
2063 get_net_tag(const std::string &key) const {
2064  return find_net_tag(key).get_tag(key);
2065 }
2066 
2067 /**
2068  * Returns true if the indicated tag value has been defined on this node or on
2069  * any ancestor node, or false otherwise. See also has_tag().
2070  */
2071 INLINE bool NodePath::
2072 has_net_tag(const std::string &key) const {
2073  return !find_net_tag(key).is_empty();
2074 }
2075 
2076 /**
2077  * Lists the tags to the nout stream, one per line. See
2078  * PandaNode::list_tags() for a variant that allows you to specify the output
2079  * stream.
2080  */
2081 INLINE void NodePath::
2082 list_tags() const {
2083  nassertv_always(!is_empty());
2084  node()->list_tags(nout);
2085  nout << "\n";
2086 }
2087 
2088 /**
2089  * Changes the name of the referenced node.
2090  */
2091 INLINE void NodePath::
2092 set_name(const std::string &name) {
2093  nassertv_always(!is_empty());
2094  node()->set_name(name);
2095 }
2096 
2097 /**
2098  * Returns the name of the referenced node.
2099  */
2100 INLINE std::string NodePath::
2101 get_name() const {
2102  nassertr_always(!is_empty(), std::string());
2103  return node()->get_name();
2104 }
2105 
2106 /**
2107  * Converts the NodePath object into a single stream of data using a
2108  * BamWriter, and returns that data as a string string. Returns empty string
2109  * on failure. This is similar to write_bam_stream().
2110  *
2111  * This method is used by __reduce__ to handle streaming of NodePaths to a
2112  * pickle file.
2113  */
2114 INLINE vector_uchar NodePath::
2115 encode_to_bam_stream() const {
2116  vector_uchar data;
2117  if (!encode_to_bam_stream(data)) {
2118  data.clear();
2119  }
2120  return data;
2121 }
2122 
2123 
2124 INLINE std::ostream &operator << (std::ostream &out, const NodePath &node_path) {
2125  node_path.output(out);
2126  return out;
2127 }
static BitMask< uint32_t, nbits > all_off()
Returns a BitMask whose bits are all off.
Definition: bitMask.I:43
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
Definition: internalName.h:193
This is one component of a NodePath.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:159
void set_tex_hpr(TextureStage *stage, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r)
Sets a texture matrix on the current node to apply the indicated rotation, as a 3-D HPR,...
Definition: nodePath.I:1434
void set_sa(PN_stdfloat sa)
Sets the alpha component of the color scale.
Definition: nodePath.I:1041
void set_hpr_scale(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz)
Sets the rotation and scale components of the transform, leaving translation untouched.
Definition: nodePath.I:737
static void set_max_search_depth(int max_search_depth)
Certain operations, such as find() or find_all_matches(), require a traversal of the scene graph to s...
Definition: nodePath.I:171
static NodePath any_path(PandaNode *node, Thread *current_thread=Thread::get_current_thread())
Returns a new NodePath that represents any arbitrary path from the root to the indicated node.
Definition: nodePath.I:62
void compose_color_scale(const LVecBase4 &scale, int priority=0)
multiplies the color scale component of the transform, with previous color scale leaving translation ...
Definition: nodePath.cxx:2117
void set_sb(PN_stdfloat sb)
Sets the blue component of the color scale.
Definition: nodePath.I:1029
void get_tag_keys(vector_string &keys) const
Fills the given vector up with the list of tags on this PandaNode.
Definition: nodePath.I:2026
void list_tags() const
Lists the tags to the nout stream, one per line.
Definition: nodePath.I:2082
void clear_transform(Thread *current_thread=Thread::get_current_thread())
Sets the transform object on this node to identity.
Definition: nodePath.I:557
bool is_same_graph(const NodePath &other, Thread *current_thread=Thread::get_current_thread()) const
Returns true if the node represented by this NodePath is parented within the same graph as that of th...
Definition: nodePath.I:275
int get_num_children(Thread *current_thread=Thread::get_current_thread()) const
Returns the number of children of the referenced node.
Definition: nodePath.I:328
int count_num_descendants() const
Returns the number of nodes at and below this level.
Definition: nodePath.I:350
void clear_mat()
Completely removes any transform from the referenced node.
Definition: nodePath.I:756
bool verify_complete(Thread *current_thread=Thread::get_current_thread()) const
Returns true if all of the nodes described in the NodePath are connected, or false otherwise.
Definition: nodePath.cxx:5331
void set_billboard_point_eye(PN_stdfloat offset=0.0, bool fixed_depth=false)
Puts a billboard transition on the node such that it will rotate in three dimensions about the origin...
Definition: nodePath.I:1763
bool operator<(const NodePath &other) const
Returns true if this NodePath sorts before the other one, false otherwise.
Definition: nodePath.I:1950
bool has_vertex_column(const InternalName *name) const
Returns true if there are at least some vertices at this node and below that contain a reference to t...
Definition: nodePath.cxx:3871
static NodePath not_found()
Creates a NodePath with the ET_not_found error type set.
Definition: nodePath.I:129
static int get_max_search_depth()
Returns the current setting of the search depth limit.
Definition: nodePath.I:180
void clear_tex_gen()
Removes the texture coordinate generation mode from all texture stages on this node.
Definition: nodePath.cxx:3667
void show()
Undoes the effect of a previous hide() on this node: makes the referenced node (and the entire subgra...
Definition: nodePath.I:1796
size_t add_hash(size_t hash) const
Adds the NodePath into the running hash.
Definition: nodePath.I:264
void set_sr(PN_stdfloat sr)
Sets the red component of the color scale.
Definition: nodePath.I:1005
void clear_effects()
Resets this node to have no render effects.
Definition: nodePath.I:548
LVecBase3 get_hpr() const
Retrieves the rotation component of the transform.
Definition: nodePath.cxx:1110
PandaNode * get_top_node(Thread *current_thread=Thread::get_current_thread()) const
Returns the top node of the path, or NULL if the path is empty.
Definition: nodePath.I:215
void output(std::ostream &out) const
Writes a sensible description of the NodePath to the indicated output stream.
Definition: nodePath.cxx:697
LPoint3 get_pos() const
Retrieves the translation component of the transform.
Definition: nodePath.cxx:1044
void look_at(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the transform on this NodePath so that it rotates to face the indicated point in space.
Definition: nodePath.I:789
void hide()
Makes the referenced node (and the entire subgraph below this node) invisible to all cameras.
Definition: nodePath.I:1853
const RenderEffect * get_effect(TypeHandle type) const
Returns the render effect of the indicated type, if it is defined on the node, or NULL if it is not.
Definition: nodePath.I:500
LVecBase3 get_shear() const
Retrieves the shear component of the transform.
Definition: nodePath.cxx:1243
set_name
Changes the name of the referenced node.
Definition: nodePath.h:945
LVecBase3 get_scale() const
Retrieves the scale component of the transform.
Definition: nodePath.cxx:1195
bool has_effect(TypeHandle type) const
Returns true if there is a render effect of the indicated type defined on this node,...
Definition: nodePath.I:510
get_net_tag
Returns the tag value that has been defined on this node, or the nearest ancestor node,...
Definition: nodePath.h:922
NodePath get_common_ancestor(const NodePath &other, Thread *current_thread=Thread::get_current_thread()) const
Returns the lowest NodePath that both of these two NodePaths have in common: the first ancestor that ...
Definition: nodePath.I:312
void adjust_all_priorities(int adjustment)
Adds the indicated adjustment amount (which may be negative) to the priority for all transitions on t...
Definition: nodePath.I:1784
void set_tex_transform(TextureStage *stage, const TransformState *transform)
Sets the texture matrix on the current node to the indicated transform for the given stage.
Definition: nodePath.cxx:3469
void set_sg(PN_stdfloat sg)
Sets the green component of the color scale.
Definition: nodePath.I:1017
void set_pos_hpr_scale(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz)
Completely replaces the transform with new translation, rotation, and scale components.
Definition: nodePath.I:746
PN_stdfloat get_sb() const
Gets the blue component of the color scale.
Definition: nodePath.I:1071
bool operator!=(const NodePath &other) const
Returns true if the two paths are not equivalent.
Definition: nodePath.I:1939
bool is_empty() const
Returns true if the NodePath contains no nodes.
Definition: nodePath.I:188
void clear_tag(const std::string &key)
Removes the value defined for this key on this particular node.
Definition: nodePath.I:2051
PN_stdfloat get_tex_rotate(TextureStage *stage) const
Returns the rotation set for the UV's for the given stage on the current node.
Definition: nodePath.I:1387
LVecBase3 get_tex_pos(TextureStage *stage) const
Returns the offset set for the UVW's for the given stage on the current node.
Definition: nodePath.I:1482
void reverse_ls() const
Lists the hierarchy at and above the referenced node.
Definition: nodePath.I:419
LVecBase2 get_tex_scale(TextureStage *stage) const
Returns the scale set for the UV's for the given stage on the current node.
Definition: nodePath.I:1398
get_error_type
If is_empty() is true, this returns a code that represents the reason why the NodePath is empty.
Definition: nodePath.h:211
void set_fluid_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the translation component, without changing the "previous" position, so that the collision syste...
Definition: nodePath.I:627
const LMatrix4 & get_mat() const
Returns the transform matrix that has been applied to the referenced node, or the identity matrix if ...
Definition: nodePath.I:776
int clear_model_nodes()
Recursively walks through the scene graph at this level and below, looking for ModelNodes,...
Definition: nodePath.I:1984
void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change=CollideMask::all_on(), TypeHandle node_type=TypeHandle::none())
Recursively applies the indicated CollideMask to the into_collide_masks for all nodes at this level a...
Definition: nodePath.I:1915
bool is_stashed() const
Returns true if the referenced node is stashed either directly, or because some ancestor is stashed.
Definition: nodePath.I:1887
bool is_ancestor_of(const NodePath &other, Thread *current_thread=Thread::get_current_thread()) const
Returns true if the node represented by this NodePath is a parent or other ancestor of the other Node...
Definition: nodePath.I:294
PandaNode * node() const
Returns the referenced node of the path.
Definition: nodePath.I:227
void clear_texture()
Completely removes any texture adjustment that may have been set via set_texture() or set_texture_off...
Definition: nodePath.cxx:3069
const LVecBase4 & get_color_scale() const
Returns the complete color scale vector that has been applied to this node via a previous call to set...
Definition: nodePath.cxx:2241
LVecBase2 get_tex_offset(TextureStage *stage) const
Returns the offset set for the UV's for the given stage on the current node.
Definition: nodePath.I:1375
NodePath()
This constructs an empty NodePath with no nodes.
Definition: nodePath.I:18
PN_stdfloat get_distance(const NodePath &other) const
Returns the straight-line distance between this referenced node's coordinate frame's origin,...
Definition: nodePath.I:979
void set_effect(const RenderEffect *effect)
Adds the indicated render effect to the scene graph on this node.
Definition: nodePath.I:490
CollideMask get_collide_mask() const
Returns the union of all of the into_collide_masks for nodes at this level and below.
Definition: nodePath.I:1899
void clear_attrib(TypeHandle type)
Removes the render attribute of the given type from this node.
Definition: nodePath.I:480
void ls() const
Lists the hierarchy at and below the referenced node.
Definition: nodePath.I:399
bool has_mat() const
Returns true if a non-identity transform matrix has been applied to the referenced node,...
Definition: nodePath.I:766
int compare_to(const NodePath &other) const
Returns a number less than zero if this NodePath sorts before the other one, greater than zero if it ...
Definition: nodePath.I:1965
vector_uchar encode_to_bam_stream() const
Converts the NodePath object into a single stream of data using a BamWriter, and returns that data as...
Definition: nodePath.I:2115
NodePath get_child(int n, Thread *current_thread=Thread::get_current_thread()) const
Returns a NodePath representing the nth child of the referenced node.
Definition: nodePath.I:337
NodePath find_net_tag(const std::string &key) const
Returns the lowest ancestor of this node that contains a tag definition with the indicated key,...
Definition: nodePath.cxx:5677
bool operator==(const NodePath &other) const
Returns true if the two paths are equivalent; that is, if they contain the same list of nodes in the ...
Definition: nodePath.I:1931
void set_state(const RenderState *state, Thread *current_thread=Thread::get_current_thread())
Changes the complete state object on this node.
Definition: nodePath.I:427
bool is_singleton(Thread *current_thread=Thread::get_current_thread()) const
Returns true if the NodePath contains exactly one node.
Definition: nodePath.I:196
PN_stdfloat get_sr() const
Gets the red component of the color scale.
Definition: nodePath.I:1053
void heads_up(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Behaves like look_at(), but with a strong preference to keeping the up vector oriented in the indicat...
Definition: nodePath.I:798
bool is_hidden(DrawMask camera_mask=PandaNode::get_overall_bit()) const
Returns true if the referenced node is hidden from the indicated camera(s) either directly,...
Definition: nodePath.I:1878
void set_shear(PN_stdfloat shxy, PN_stdfloat shxz, PN_stdfloat shyz)
Sets the shear component of the transform, leaving translation, rotation, and scale untouched.
Definition: nodePath.I:704
const RenderAttrib * get_attrib(TypeHandle type) const
Returns the render attribute of the indicated type, if it is defined on the node, or NULL if it is no...
Definition: nodePath.I:459
NodePath get_top(Thread *current_thread=Thread::get_current_thread()) const
Returns a singleton NodePath that represents the top of the path, or empty NodePath if this path is e...
Definition: nodePath.cxx:209
bool has_texcoord(const std::string &texcoord_name) const
Returns true if there are at least some vertices at this node and below that use the named texture co...
Definition: nodePath.I:1744
NodePath attach_new_node(PandaNode *node, int sort=0, Thread *current_thread=Thread::get_current_thread()) const
Attaches a new node, with or without existing parents, to the scene graph below the referenced node o...
Definition: nodePath.cxx:600
has_parent
Returns true if the referenced node has a parent; i.e.
Definition: nodePath.h:242
void set_billboard_axis(PN_stdfloat offset=0.0)
Puts a billboard transition on the node such that it will rotate in two dimensions around the up axis...
Definition: nodePath.I:1753
get_parent
Returns the NodePath to the parent of the referenced node: that is, this NodePath,...
Definition: nodePath.h:242
void set_pos_hpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r)
Sets the translation and rotation component of the transform, leaving scale untouched.
Definition: nodePath.I:728
LVecBase3 get_tex_hpr(TextureStage *stage) const
Returns the 3-D HPR set for the UVW's for the given stage on the current node.
Definition: nodePath.I:1494
void set_tex_pos(TextureStage *stage, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w)
Sets a texture matrix on the current node to apply the indicated offset to UVW's for the given stage.
Definition: nodePath.I:1410
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
Definition: nodePath.I:149
void set_tex_offset(TextureStage *stage, PN_stdfloat u, PN_stdfloat v)
Sets a texture matrix on the current node to apply the indicated offset to UV's for the given stage.
Definition: nodePath.I:1301
PN_stdfloat get_sg() const
Gets the green component of the color scale.
Definition: nodePath.I:1062
void set_scale(PN_stdfloat scale)
Sets the scale component of the transform, leaving translation and rotation untouched.
Definition: nodePath.I:675
static NodePath removed()
Creates a NodePath with the ET_removed error type set.
Definition: nodePath.I:139
void clear_project_texture(TextureStage *stage)
Undoes the effect of project_texture().
Definition: nodePath.I:1732
void clear_tex_projector()
Removes the TexProjectorEffect for all stages from this node.
Definition: nodePath.cxx:3788
get_name
Returns the name of the referenced node.
Definition: nodePath.h:945
void set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r)
Sets the rotation component of the transform, leaving translation and scale untouched.
Definition: nodePath.I:651
bool has_tag(const std::string &key) const
Returns true if a value has been defined on this node for the particular key (even if that value is t...
Definition: nodePath.I:2037
void set_billboard_point_world(PN_stdfloat offset=0.0)
Puts a billboard transition on the node such that it will rotate in three dimensions about the origin...
Definition: nodePath.I:1772
LVecBase3 get_tex_scale_3d(TextureStage *stage) const
Returns the scale set for the UVW's for the given stage on the current node.
Definition: nodePath.I:1506
void set_tex_scale(TextureStage *stage, PN_stdfloat scale)
Sets a texture matrix on the current node to apply the indicated scale to UVW's for the given stage.
Definition: nodePath.I:1338
const RenderEffects * get_effects() const
Returns the complete RenderEffects that will be applied to this node.
Definition: nodePath.I:539
has_net_tag
Returns true if the indicated tag value has been defined on this node or on any ancestor node,...
Definition: nodePath.h:922
bool has_attrib(TypeHandle type) const
Returns true if there is a render attribute of the indicated type defined on this node,...
Definition: nodePath.I:469
int get_key() const
Returns an integer that is guaranteed to be the same for all NodePaths that represent the same node i...
Definition: nodePath.I:245
void clear_effect(TypeHandle type)
Removes the render effect of the given type from this node.
Definition: nodePath.I:519
void clear()
Sets this NodePath to the empty NodePath.
Definition: nodePath.I:119
void set_tex_rotate(TextureStage *stage, PN_stdfloat r)
Sets a texture matrix on the current node to apply the indicated rotation, clockwise in degrees,...
Definition: nodePath.I:1325
void set_color_scale(const LVecBase4 &scale, int priority=0)
Sets the color scale component of the transform, leaving translation and rotation untouched.
Definition: nodePath.cxx:2147
void set_effects(const RenderEffects *effects)
Sets the complete RenderEffects that will be applied this node.
Definition: nodePath.I:530
PN_stdfloat get_sa() const
Gets the alpha component of the color scale.
Definition: nodePath.I:1080
NodePath get_stashed_ancestor(Thread *current_thread=Thread::get_current_thread()) const
Returns the NodePath at or above the referenced node that is stashed, or an empty NodePath if no ance...
Definition: nodePath.cxx:5259
NodePath get_hidden_ancestor(DrawMask camera_mask=PandaNode::get_overall_bit(), Thread *current_thread=Thread::get_current_thread()) const
Returns the NodePath at or above the referenced node that is hidden to the indicated camera(s),...
Definition: nodePath.cxx:5185
void set_tag(const std::string &key, const std::string &value)
Associates a user-defined value with a user-defined key which is stored on the node.
Definition: nodePath.I:1999
void set_transform(const TransformState *transform, Thread *current_thread=Thread::get_current_thread())
Changes the complete transform object on this node.
Definition: nodePath.I:565
void show_through()
Makes the referenced node visible just to the cameras whose camera_mask shares the indicated bits.
Definition: nodePath.I:1823
std::string get_tag(const std::string &key) const
Retrieves the user-defined value that was previously set on this node for the particular key,...
Definition: nodePath.I:2010
A basic node of the scene graph or data graph.
Definition: pandaNode.h:65
void get_tag_keys(vector_string &keys) const
Fills the given vector up with the list of tags on this PandaNode.
Definition: pandaNode.cxx:1298
set_tag
Associates a user-defined value with a user-defined key which is stored on the node.
Definition: pandaNode.h:207
void clear_effect(TypeHandle type)
Removes the render effect of the given type from this node.
Definition: pandaNode.cxx:1016
CollideMask get_net_collide_mask(Thread *current_thread=Thread::get_current_thread()) const
Returns the union of all into_collide_mask() values set at CollisionNodes at this level and below.
Definition: pandaNode.cxx:1715
set_effects
Sets the complete RenderEffects that will be applied this node.
Definition: pandaNode.h:178
void adjust_draw_mask(DrawMask show_mask, DrawMask hide_mask, DrawMask clear_mask)
Adjusts the hide/show bits of this particular node.
Definition: pandaNode.cxx:1585
set_state
Sets the complete RenderState that will be applied to all nodes at this level and below.
Definition: pandaNode.h:173
set_transform
Sets the transform that will be applied to this node and below.
Definition: pandaNode.h:183
void set_effect(const RenderEffect *effect)
Adds the indicated render effect to the scene graph on this node.
Definition: pandaNode.cxx:999
void list_tags(std::ostream &out, const std::string &separator="\n") const
Writes a list of all the tag keys assigned to the node to the indicated stream.
Definition: pandaNode.cxx:1277
clear_tag
Removes the value defined for this key on this particular node.
Definition: pandaNode.h:207
void set_prev_transform(const TransformState *transform, Thread *current_thread=Thread::get_current_thread())
Sets the transform that represents this node's "previous" position, one frame ago,...
Definition: pandaNode.cxx:1118
void set_attrib(const RenderAttrib *attrib, int override=0)
Adds the indicated render attribute to the scene graph on this node.
Definition: pandaNode.cxx:938
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:51
This is the base class for a number of special render effects that may be set on scene graph nodes to...
Definition: renderEffect.h:48
This represents a unique collection of RenderEffect objects that correspond to a particular renderabl...
Definition: renderEffects.h:41
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
Represents a set of settings that indicate how a texture is sampled.
Definition: samplerState.h:36
This is a generic buffer object that lives in graphics memory.
Definition: shaderBuffer.h:33
This is a small container class that can hold any one of the value types that can be passed as input ...
Definition: shaderInput.h:40
Defines the properties of a named stage of the multitexture pipeline.
Definition: textureStage.h:35
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
A thread; that is, a lightweight process.
Definition: thread.h:46
get_pipeline_stage
Returns the Pipeline stage number associated with this thread.
Definition: thread.h:105
Indicates a coordinate-system transform on vertices.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
static size_t add_hash(size_t start, const void *key)
Adds the indicated key into a running hash.
Definition: stl_compares.I:110
CPT(RenderState) NodePath
Returns the net state on this node from the root.
Definition: nodePath.I:435