Panda3D
Loading...
Searching...
No Matches
nodePathComponent.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file nodePathComponent.h
10 * @author drose
11 * @date 2002-02-25
12 */
13
14#ifndef NODEPATHCOMPONENT_H
15#define NODEPATHCOMPONENT_H
16
17#include "pandabase.h"
18
19#include "pandaNode.h"
20#include "pointerTo.h"
21#include "referenceCount.h"
22#include "cycleData.h"
23#include "cycleDataReader.h"
24#include "cycleDataWriter.h"
28#include "lightMutex.h"
29#include "deletedChain.h"
30
31/**
32 * This is one component of a NodePath. These are stored on each PandaNode,
33 * as many as one for each of the possible instances of the node (but they
34 * only exist when they are requested, to minimize memory waste). A NodePath
35 * represents a singly-linked list of these from an arbitrary component in the
36 * graph to the root.
37 *
38 * This whole NodePath system is used to disambiguate instances in the scene
39 * graph, and the NodePathComponents are stored in the nodes themselves to
40 * allow the nodes to keep these up to date as the scene graph is manipulated.
41 */
42class EXPCL_PANDA_PGRAPH NodePathComponent final : public ReferenceCount {
43private:
45 int pipeline_stage, Thread *current_thread);
46
47public:
48 NodePathComponent(const NodePathComponent &copy) = delete;
49 INLINE ~NodePathComponent();
50
51 ALLOC_DELETED_CHAIN(NodePathComponent);
52
53 NodePathComponent &operator = (const NodePathComponent &copy) = delete;
54
55 INLINE PandaNode *get_node() const;
56 INLINE bool has_key() const;
57 int get_key() const;
58 bool is_top_node(int pipeline_stage, Thread *current_thread) const;
59
60 INLINE NodePathComponent *get_next(int pipeline_stage, Thread *current_thread) const;
61 int get_length(int pipeline_stage, Thread *current_thread) const;
62
63 bool fix_length(int pipeline_stage, Thread *current_thread);
64
65 void output(std::ostream &out) const;
66
67private:
68 void set_next(NodePathComponent *next, int pipeline_stage, Thread *current_thread);
69 void set_top_node(int pipeline_stage, Thread *current_thread);
70
71 // We don't have to cycle the _node and _key elements, since these are
72 // permanent properties of this object. (Well, the _key is semi-permanent:
73 // it becomes permanent after it has been set the first time.)
74 PT(PandaNode) _node;
75 int _key;
76
77 // This is the data that must be cycled between pipeline stages.
78 class EXPCL_PANDA_PGRAPH CData : public CycleData {
79 public:
80 INLINE CData();
81 CData(const CData &copy);
82 ALLOC_DELETED_CHAIN(CData);
83 virtual CycleData *make_copy() const;
84 virtual TypeHandle get_parent_type() const {
85 return NodePathComponent::get_class_type();
86 }
87
88 PT(NodePathComponent) _next;
89 int _length;
90
91 public:
92 static TypeHandle get_class_type() {
93 return _type_handle;
94 }
95 static void init_type() {
96 register_type(_type_handle, "NodePathComponent::CData");
97 }
98
99 private:
100 static TypeHandle _type_handle;
101 };
102
103 PipelineCycler<CData> _cycler;
109
110 static int _next_key;
111 static LightMutex _key_lock;
112
113public:
114 static TypeHandle get_class_type() {
115 return _type_handle;
116 }
117 static void init_type() {
118 ReferenceCount::init_type();
119 register_type(_type_handle, "NodePathComponent",
120 ReferenceCount::get_class_type());
121 CData::init_type();
122 }
123
124private:
125 static TypeHandle _type_handle;
126 friend class PandaNode;
127 friend class NodePath;
128};
129
130// We can safely redefine this as a no-op.
131template<>
133
134INLINE std::ostream &operator << (std::ostream &out, const NodePathComponent &comp);
135
136#include "nodePathComponent.I"
137
138#endif
This class is similar to CycleDataLockedReader, except it allows reading from a particular stage of t...
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This class is similar to CycleDataReader, except it allows reading from a particular stage of the pip...
This class is similar to CycleDataWriter, except it allows writing to a particular stage of the pipel...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A single page of data maintained by a PipelineCycler.
Definition cycleData.h:50
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition lightMutex.h:41
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
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
This is the base class for PointerTo and ConstPointerTo.
A base class for all things that want to be reference-counted.
A thread; that is, a lightweight process.
Definition thread.h:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...