18 #include "pandabase.h" 20 #include "cycleData.h" 21 #include "cycleDataReader.h" 22 #include "cycleDataWriter.h" 23 #include "cycleDataLockedStageReader.h" 24 #include "cycleDataStageReader.h" 25 #include "cycleDataStageWriter.h" 26 #include "pipelineCycler.h" 27 #include "renderState.h" 28 #include "renderEffects.h" 29 #include "transformState.h" 31 #include "typedWritable.h" 32 #include "collideMask.h" 34 #include "referenceCount.h" 36 #include "ordered_vector.h" 37 #include "pointerTo.h" 38 #include "nodePointerTo.h" 39 #include "pointerToArray.h" 41 #include "updateSeq.h" 42 #include "deletedChain.h" 43 #include "pandaNodeChain.h" 44 #include "pStatCollector.h" 45 #include "copyOnWriteObject.h" 46 #include "copyOnWritePointer.h" 47 #include "lightReMutex.h" 48 #include "extension.h" 52 #undef _POSIX_C_SOURCE 75 PandaNode(
const string &name);
78 virtual PandaNode *combine_with(PandaNode *other);
81 PandaNode(
const PandaNode ©);
83 void operator = (
const PandaNode ©);
86 virtual PandaNode *dupe_for_flatten()
const;
88 virtual bool safe_to_flatten()
const;
89 virtual bool safe_to_transform()
const;
90 virtual bool safe_to_modify_transform()
const;
91 virtual bool safe_to_combine()
const;
92 virtual bool safe_to_combine_children()
const;
93 virtual bool safe_to_flatten_below()
const;
94 virtual bool preserve_name()
const;
95 virtual int get_unsafe_to_apply_attribs()
const;
99 virtual void xform(
const LMatrix4 &mat);
101 virtual CPT(TransformState)
104 const TransformState *transform,
108 virtual bool has_selective_visibility()
const;
109 virtual int get_first_visible_child()
const;
110 virtual int get_next_visible_child(
int n)
const;
111 virtual bool has_single_child_visibility()
const;
112 virtual int get_visible_child()
const;
113 virtual bool is_renderable()
const;
117 virtual PandaNode *make_copy()
const;
120 EXTENSION(PT(PandaNode) __copy__()
const);
121 EXTENSION(PyObject *__deepcopy__(PyObject *
self, PyObject *memo)
const);
126 MAKE_SEQ(get_parents, get_num_parents, get_parent);
132 MAKE_SEQ(get_children, get_num_children, get_child);
134 int count_num_descendants()
const;
136 void add_child(PandaNode *child_node,
int sort = 0,
140 bool replace_child(PandaNode *orig_child, PandaNode *new_child,
143 INLINE
bool stash_child(PandaNode *child_node,
145 void stash_child(
int child_index,
147 INLINE
bool unstash_child(PandaNode *child_node,
149 void unstash_child(
int stashed_index,
156 MAKE_SEQ(get_stashed, get_num_stashed, get_stashed);
165 void set_attrib(
const RenderAttrib *attrib,
int override = 0);
168 INLINE
bool has_attrib(
TypeHandle type)
const;
169 INLINE
bool has_attrib(
int slot)
const;
171 void clear_attrib(
int slot);
175 INLINE
bool has_effect(
TypeHandle type)
const;
193 INLINE
bool has_dirty_prev_transform()
const;
196 void set_tag(
const string &key,
const string &value,
198 INLINE
string get_tag(
const string &key,
200 INLINE
bool has_tag(
const string &key,
202 void clear_tag(
const string &key,
204 void get_tag_keys(vector_string &keys)
const;
206 EXTENSION(PyObject *get_tag_keys()
const);
208 EXTENSION(
void set_python_tag(
const string &key, PyObject *value));
209 EXTENSION(PyObject *get_python_tag(
const string &key)
const);
210 EXTENSION(
bool has_python_tag(
const string &key)
const);
211 EXTENSION(
void clear_python_tag(
const string &key));
212 EXTENSION(
void get_python_tag_keys(vector_string &keys)
const);
213 EXTENSION(PyObject *get_python_tag_keys()
const);
215 INLINE
bool has_tags()
const;
216 void copy_tags(PandaNode *other);
217 void list_tags(ostream &out,
const string &separator =
"\n")
const;
219 int compare_tags(
const PandaNode *other)
const;
221 void copy_all_properties(PandaNode *other);
222 void replace_node(PandaNode *other);
224 enum UnexpectedChange {
227 UC_transform = 0x004,
229 UC_draw_mask = 0x010,
231 void set_unexpected_change(
unsigned int flags);
232 unsigned int get_unexpected_change(
unsigned int flags)
const;
233 void clear_unexpected_change(
unsigned int flags);
235 INLINE
static DrawMask get_overall_bit();
236 INLINE
static DrawMask get_all_camera_mask();
237 INLINE
bool is_overall_hidden()
const;
238 INLINE
void set_overall_hidden(
bool overall_hidden);
240 void adjust_draw_mask(
DrawMask show_mask,
243 INLINE
DrawMask get_draw_control_mask()
const;
244 INLINE
DrawMask get_draw_show_mask()
const;
246 DrawMask get_net_draw_control_mask()
const;
247 DrawMask get_net_draw_show_mask()
const;
251 virtual CollideMask get_legal_collide_mask()
const;
258 bool is_scene_root()
const;
259 bool is_under_scene_root()
const;
261 virtual void output(ostream &out)
const;
262 virtual void write(ostream &out,
int indent_level)
const;
264 INLINE
void ls(ostream &out,
int indent_level)
const;
277 void set_bounds_type(BoundingVolume::BoundsType bounds_type);
278 BoundingVolume::BoundsType get_bounds_type()
const;
282 INLINE
void clear_bounds();
291 INLINE
bool is_bounds_stale()
const;
293 INLINE
void set_final(
bool flag);
296 virtual bool is_geom_node()
const;
297 virtual bool is_lod_node()
const;
298 virtual bool is_collision_node()
const;
299 virtual Light *as_light();
300 virtual bool is_ambient_light()
const;
303 FB_transform = 0x0001,
307 FB_draw_mask = 0x0020,
308 FB_cull_callback = 0x0040,
314 static PT(PandaNode) decode_from_bam_stream(
const string &data,
BamReader *reader = NULL);
321 int get_internal_vertices(
int pipeline_stage,
Thread *current_thread)
const;
324 INLINE
void mark_bounds_stale(
int pipeline_stage,
Thread *current_thread)
const;
326 void force_bounds_stale(
int pipeline_stage,
Thread *current_thread);
327 INLINE
void mark_internal_bounds_stale(
int pipeline_stage,
Thread *current_thread);
329 virtual void r_mark_geom_bounds_stale(
Thread *current_thread);
331 virtual void compute_internal_bounds(CPT(
BoundingVolume) &internal_bounds,
332 int &internal_vertices,
334 Thread *current_thread)
const;
335 virtual void parents_changed();
336 virtual void children_changed();
337 virtual void transform_changed();
338 virtual void state_changed();
339 virtual void draw_mask_changed();
342 virtual PT(PandaNode) r_copy_subgraph(InstanceMap &inst_map,
343 Thread *current_thread)
const;
344 virtual void r_copy_children(
const PandaNode *from, InstanceMap &inst_map,
347 void set_cull_callback();
348 void disable_cull_callback();
359 class EXPCL_PANDA_PGRAPH BoundsData :
public CycleData {
362 INLINE BoundsData(
const BoundsData ©);
363 INLINE
void copy_bounds(
const BoundsData ©);
371 int _internal_vertices;
379 INLINE
int do_find_parent(PandaNode *node,
const CData *cdata)
const;
380 bool stage_remove_child(PandaNode *child_node,
int pipeline_stage,
382 bool stage_replace_child(PandaNode *orig_child, PandaNode *new_child,
383 int pipeline_stage,
Thread *current_thread);
385 void quick_add_new_child(PandaNode *child_node,
int sort,
388 INLINE
bool verify_child_no_cycles(PandaNode *child_node);
389 void report_cycle(PandaNode *node);
390 bool find_node_above(PandaNode *node);
395 PandaNode *child,
int sort,
396 int pipeline_stage,
Thread *current_thread);
401 int pipeline_stage,
Thread *current_thread);
404 bool as_stashed,
int pipeline_stage,
Thread *current_thread);
407 int pipeline_stage,
Thread *current_thread);
409 int pipeline_stage,
Thread *current_thread);
411 int pipeline_stage,
Thread *current_thread);
413 bool &ambiguity_detected,
414 int pipeline_stage,
Thread *current_thread);
416 static void sever_connection(PandaNode *parent_node, PandaNode *child_node,
417 int pipeline_stage,
Thread *current_thread);
418 static void new_connection(PandaNode *parent_node, PandaNode *child_node,
419 int pipeline_stage,
Thread *current_thread);
420 void fix_path_lengths(
int pipeline_stage,
Thread *current_thread);
421 void r_list_descendants(ostream &out,
int indent_level)
const;
423 INLINE
void do_set_dirty_prev_transform();
424 INLINE
void do_clear_dirty_prev_transform();
432 INLINE
bool operator < (
const DownConnection &other)
const;
433 INLINE PandaNode *get_child()
const;
434 INLINE
void set_child(PandaNode *child);
435 INLINE
int get_sort()
const;
441 PT(PandaNode) _child;
452 INLINE BamReaderAuxDataDown();
456 return get_class_type();
458 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
464 static void init_type() {
465 BamReaderAuxData::init_type();
466 register_type(_type_handle,
"BamReaderAuxDataDown",
467 BamReaderAuxData::get_class_type());
474 class EXPCL_PANDA_PGRAPH UpConnection {
476 INLINE UpConnection(PandaNode *child);
477 INLINE
bool operator < (
const UpConnection &other)
const;
478 INLINE PandaNode *get_parent()
const;
493 typedef phash_set<NodePathComponent *, pointer_hash> Paths;
501 bool _dirty_prev_transform;
506 typedef phash_map<string, string, string_hash> TagData;
508 typedef phash_map<string, PyObject *, string_hash> PythonTagData;
509 #endif // HAVE_PYTHON 512 unsigned int _unexpected_change_flags;
517 class EXPCL_PANDA_PGRAPH CData :
public BoundsData {
520 CData(
const CData ©);
522 ALLOC_DELETED_CHAIN(CData);
526 void update_bam_nested(
BamWriter *manager)
const;
530 return PandaNode::get_class_type();
538 NCPT(TransformState) _transform;
539 NCPT(TransformState) _prev_transform;
545 INLINE
void set_fancy_bit(
int bits,
bool value);
556 PythonTagData _python_tag_data;
557 #endif // HAVE_PYTHON 561 DrawMask _draw_control_mask, _draw_show_mask;
570 BoundingVolume::BoundsType _bounds_type;
598 DrawMask _net_draw_control_mask, _net_draw_show_mask;
607 int _nested_vertices;
626 void write_up_list(
const Up &up_list,
628 void write_down_list(
const Down &down_list,
630 void update_up_list(
const Up &up_list,
BamWriter *manager)
const;
631 void update_down_list(
const Down &down_list,
BamWriter *manager)
const;
632 int complete_up_list(Up &up_list,
const string &tag,
634 int complete_down_list(Down &down_list,
const string &tag,
636 void fillin_up_list(Up &up_list,
const string &tag,
638 void fillin_down_list(Down &down_list,
const string &tag,
641 INLINE CPT(Down) get_down()
const;
642 INLINE PT(Down) modify_down();
643 INLINE CPT(Down) get_stashed()
const;
644 INLINE PT(Down) modify_stashed();
645 INLINE CPT(Up) get_up()
const;
646 INLINE PT(Up) modify_up();
652 COWPT(Down) _stashed;
659 static void init_type() {
660 register_type(_type_handle,
"PandaNode::CData");
674 int do_find_child(PandaNode *node,
const Down *down)
const;
675 CDStageWriter update_cached(
bool update_bounds,
int pipeline_stage,
676 CDLockedStageReader &cdata);
694 INLINE Children(
const CData *cdata);
695 INLINE Children(
const Children ©);
696 INLINE
void operator = (
const Children ©);
698 #ifdef USE_MOVE_SEMANTICS 699 INLINE Children(Children &&from) NOEXCEPT;
700 INLINE
void operator = (Children &&from) NOEXCEPT;
703 INLINE
int get_num_children()
const;
704 INLINE PandaNode *get_child(
int n)
const;
705 INLINE
int get_child_sort(
int n)
const;
715 INLINE Stashed(
const CData *cdata);
716 INLINE Stashed(
const Stashed ©);
717 INLINE
void operator = (
const Stashed ©);
719 #ifdef USE_MOVE_SEMANTICS 720 INLINE Stashed(Stashed &&from) NOEXCEPT;
721 INLINE
void operator = (Stashed &&from) NOEXCEPT;
724 INLINE
int get_num_stashed()
const;
725 INLINE PandaNode *get_stashed(
int n)
const;
726 INLINE
int get_stashed_sort(
int n)
const;
736 INLINE Parents(
const CData *cdata);
737 INLINE Parents(
const Parents ©);
738 INLINE
void operator = (
const Parents ©);
740 #ifdef USE_MOVE_SEMANTICS 741 INLINE Parents(Parents &&from) NOEXCEPT;
742 INLINE
void operator = (Parents &&from) NOEXCEPT;
745 INLINE
int get_num_parents()
const;
746 INLINE PandaNode *get_parent(
int n)
const;
756 typedef bool SceneRootFunc(
const PandaNode *);
757 static void set_scene_root_func(SceneRootFunc *func);
760 static SceneRootFunc *_scene_root_func;
763 static void register_with_read_factory();
765 virtual void update_bam_nested(
BamWriter *manager);
777 static void init_type() {
778 TypedWritable::init_type();
779 ReferenceCount::init_type();
780 Namable::init_type();
781 register_type(_type_handle,
"PandaNode",
782 TypedWritable::get_class_type(),
783 ReferenceCount::get_class_type(),
784 Namable::get_class_type());
788 BamReaderAuxDataDown::init_type();
791 return get_class_type();
793 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
798 #ifndef DO_PIPELINING 818 INLINE PandaNodePipelineReader(
const PandaNodePipelineReader ©);
819 INLINE
void operator = (
const PandaNodePipelineReader ©);
822 INLINE ~PandaNodePipelineReader();
823 ALLOC_DELETED_CHAIN(PandaNodePipelineReader);
825 INLINE
const PandaNode *get_node()
const;
826 INLINE
Thread *get_current_thread()
const;
828 INLINE
void release();
830 void check_cached(
bool update_bounds)
const;
832 INLINE
void compose_draw_mask(
DrawMask &running_draw_mask)
const;
833 INLINE
bool compare_draw_mask(
DrawMask running_draw_mask,
836 INLINE
int get_num_parents()
const;
837 INLINE PandaNode *get_parent(
int n)
const;
838 INLINE
int find_parent(PandaNode *node)
const;
840 INLINE
int get_num_children()
const;
841 INLINE PandaNode *get_child(
int n)
const;
842 INLINE
int get_child_sort(
int n)
const;
843 INLINE
int find_child(PandaNode *node)
const;
845 INLINE
int get_num_stashed()
const;
846 INLINE PandaNode *get_stashed(
int n)
const;
847 INLINE
int get_stashed_sort(
int n)
const;
848 INLINE
int find_stashed(PandaNode *node)
const;
852 INLINE
const TransformState *get_transform()
const;
853 INLINE
const TransformState *get_prev_transform()
const;
855 INLINE
string get_tag(
const string &key)
const;
856 INLINE
bool has_tag(
const string &key)
const;
861 INLINE
int get_nested_vertices()
const;
862 INLINE
bool is_final()
const;
863 INLINE
int get_fancy_bits()
const;
870 const PandaNode *_node;
873 const PandaNode::CData *_cdata;
879 static void init_type() {
880 register_type(_type_handle,
"PandaNodePipelineReader");
888 INLINE ostream &operator << (ostream &out,
const PandaNode &node) {
893 #include "pandaNode.I" The abstract interface to all kinds of lights.
This is our own Panda specialization on the default STL map.
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Stores auxiliary data that may be piggybacked on the BamReader during each object's read pass...
void output(ostream &out) const
Outputs the Namable.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
A single page of data maintained by a PipelineCycler.
Base class for objects that can be written to and read from Bam files.
A lightweight reentrant mutex.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is the base class for a number of special render effects that may be set on scene graph nodes to...
This is our own Panda specialization on the default STL list.
This is a class designed to support low-overhead traversals of the complete scene graph...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
This just stores the pointers to implement a doubly-linked list of some kind of object.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A lightweight class that represents a single element that may be timed and/or counted via stats...
A base class for all things which can have a name.
This class is used by the SceneGraphReducer to maintain and accumulate the set of attributes we have ...
This is a 4-by-4 transform matrix.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
A specialization of ordered_vector that emulates a standard STL set: many copies of each element are ...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
The default class template does not define any methods.
This class is similar to CycleDataLockedReader, except it allows reading from a particular stage of t...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A thread; that is, a lightweight process.
Encapsulates the data from a PandaNode, pre-fetched for one stage of the pipeline.
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
This represents a unique collection of RenderEffect objects that correspond to a particular renderabl...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
This class maintains a linked list of PandaNodes.
Converts an egg data structure, possibly read from an egg file but not necessarily, into a scene graph suitable for rendering.
This is one component of a NodePath.