15 #include "nodePathCollection.h" 16 #include "findApproxPath.h" 17 #include "findApproxLevelEntry.h" 18 #include "textureAttrib.h" 19 #include "colorScaleAttrib.h" 20 #include "colorAttrib.h" 29 NodePathCollection() {
39 _node_paths(copy._node_paths)
48 void NodePathCollection::
50 _node_paths = copy._node_paths;
65 if (_node_paths.get_ref_count() > 1) {
66 NodePaths old_node_paths = _node_paths;
67 _node_paths = NodePaths::empty_array(0);
68 _node_paths.v() = old_node_paths.v();
71 _node_paths.push_back(node_path);
84 for (
int i = 0; path_index == -1 && i < (int)_node_paths.size(); i++) {
85 if (_node_paths[i] == node_path) {
90 if (path_index == -1) {
100 if (_node_paths.get_ref_count() > 1) {
101 NodePaths old_node_paths = _node_paths;
102 _node_paths = NodePaths::empty_array(0);
103 _node_paths.v() = old_node_paths.v();
106 _node_paths.erase(_node_paths.begin() + path_index);
121 for (
int i = 0; i < other_num_paths; i++) {
137 for (
int i = 0; i < num_paths; i++) {
140 new_paths.push_back(path);
143 _node_paths = new_paths;
159 for (
int i = 0; i < num_paths; i++) {
161 bool duplicated =
false;
163 for (
int j = 0; j < i && !duplicated; j++) {
168 new_paths.push_back(path);
172 _node_paths = new_paths;
210 _node_paths.reserve(num);
221 return _node_paths.empty();
231 return _node_paths.size();
241 nassertr(index >= 0 && index < (
int)_node_paths.size(),
NodePath());
243 return _node_paths[index];
255 nassertr(index >= 0 && index < (
int)_node_paths.size(),
NodePath());
257 return _node_paths[index];
268 return _node_paths.size();
278 ls(ostream &out,
int indent_level)
const {
281 indent(out, indent_level) << path <<
"\n";
282 path.
ls(out, indent_level + 2);
306 start->_next = level;
309 get_path(0).find_matches(result, level, -1);
458 bool have_bounds =
false;
474 min_point.set(min(min_point._v(0), tmp_min._v(0)),
475 min(min_point._v(1), tmp_min._v(1)),
476 min(min_point._v(2), tmp_min._v(2)));
477 max_point.set(max(max_point._v(0), tmp_max._v(0)),
478 max(max_point._v(1), tmp_max._v(1)),
479 max(max_point._v(2), tmp_max._v(2)));
520 NodePaths::iterator npi;
521 for (npi = _node_paths.begin(); npi != _node_paths.end(); ++npi) {
524 StateMap::iterator smi = state_map.find(orig_state);
525 if (smi != state_map.end()) {
550 set_attrib(TextureAttrib::make_all_off(), priority);
567 NodePaths::iterator npi;
568 for (npi = _node_paths.begin(); npi != _node_paths.end(); ++npi) {
571 StateMap::iterator smi = state_map.find(orig_state);
572 if (smi != state_map.end()) {
591 set_attrib(ColorAttrib::make_flat(color), priority);
604 NodePaths::iterator npi;
605 for (npi = _node_paths.begin(); npi != _node_paths.end(); ++npi) {
608 StateMap::iterator smi = state_map.find(orig_state);
609 if (smi != state_map.end()) {
632 NodePaths::iterator npi;
633 for (npi = _node_paths.begin(); npi != _node_paths.end(); ++npi) {
636 StateMap::iterator smi = state_map.find(orig_state);
637 if (smi != state_map.end()) {
662 NodePaths::iterator npi;
663 for (npi = _node_paths.begin(); npi != _node_paths.end(); ++npi) {
666 StateMap::iterator smi = state_map.find(orig_state);
667 if (smi != state_map.end()) {
673 np.set_attrib(attrib, priority);
701 write(ostream &out,
int indent_level)
const {
703 indent(out, indent_level) <<
get_path(i) <<
"\n";
void unstash(int sort=0, Thread *current_thread=Thread::get_current_thread())
Undoes the effect of a previous stash() on this node: makes the referenced node (and the entire subgr...
void ls() const
Lists all the nodes at and below each node in the collection hierarchically.
bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, Thread *current_thread=Thread::get_current_thread()) const
Calculates the minimum and maximum vertices of all Geoms at this NodePath's bottom node and below...
bool remove_path(const NodePath &node_path)
Removes the indicated NodePath from the collection.
This is our own Panda specialization on the default STL map.
void add_path(const NodePath &node_path)
Adds a new NodePath to the collection.
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...
This is the base class for a number of render attributes (other than transform) that may be set on sc...
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...
NodePathCollection find_all_matches(const string &path) const
Returns the complete set of all NodePaths that begin with any NodePath in this collection and can be ...
bool is_empty() const
Returns true if the NodePath contains no nodes.
This class is local to this package only; it doesn't get exported.
void unstash()
Unstashes all NodePaths in the collection.
void clear()
Removes all NodePaths from the collection.
bool is_empty() const
Returns true if there are no NodePaths in the collection, false otherwise.
void add_paths_from(const NodePathCollection &other)
Adds all the NodePaths indicated in the other collection to this path.
void remove_paths_from(const NodePathCollection &other)
Removes from this collection all of the NodePaths listed in the other collection. ...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
This class is local to this package only; it doesn't get exported.
void wrt_reparent_to(const NodePath &other)
Reparents all the NodePaths in the collection to the indicated node, adjusting each transform so as n...
void compose_color_scale(const LVecBase4 &scale, int priority=0)
multiplies the color scale component of the transform, with previous color scale leaving translation ...
void show()
Shows all NodePaths in the collection.
void write(ostream &out, int indent_level=0) const
Writes a complete multi-line description of the NodePathCollection to the indicated output stream...
void hide()
Hides all NodePaths in the collection.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
void show()
Undoes the effect of a previous hide() on this node: makes the referenced node (and the entire subgra...
void set_texture(Texture *tex, int priority=0)
Adds the indicated texture to the list of textures that will be rendered on the default texture stage...
void stash()
Stashes all NodePaths in the collection.
void compose_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a=1.0, int priority=0)
Applies color scales to all NodePaths in the collection.
void set_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a=1.0, int priority=0)
Applies color scales to all NodePaths in the collection.
CollideMask get_collide_mask() const
Returns the union of all of the into_collide_masks for nodes at this level and below.
void reparent_to(const NodePath &other, int sort=0, Thread *current_thread=Thread::get_current_thread())
Removes the referenced node of the NodePath from its current parent and attaches it to the referenced...
bool has_path(const NodePath &path) const
Returns true if the indicated NodePath appears in this collection, false otherwise.
void set_attrib(const RenderAttrib *attrib, int priority=0)
Applies the indicated RenderAttrib to all NodePaths in the collection.
void detach()
Detaches all NodePaths in the collection.
void output(ostream &out) const
Writes a brief one-line description of the NodePathCollection to the indicated output stream...
NodePath operator[](int index) const
Returns the nth NodePath in the collection.
NodePath get_path(int index) const
Returns the nth NodePath in the collection.
int get_num_paths() const
Returns the number of NodePaths in the collection.
void set_texture(Texture *tex, int priority=0)
Adds the indicated texture to the list of textures that will be rendered on the default texture stage...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
This is the base class for all three-component vectors and points.
void set_texture_off(int priority=0)
Sets the geometry at this level and below to render using no texture, on any stage.
void wrt_reparent_to(const NodePath &other, int sort=0, Thread *current_thread=Thread::get_current_thread())
This functions identically to reparent_to(), except the transform on this node is also adjusted so th...
void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a=1.0, int priority=0)
Colors all NodePaths in the collection.
void reserve(size_t num)
This is a hint to Panda to allocate enough memory to hold the given number of NodePaths, if you know ahead of time how many you will be adding.
bool add_string(const string &str_path)
Adds a sequence of components separated by slashes, followed optionally by a semicolon and a sequence...
int size() const
Returns the number of paths in the collection.
void stash(int sort=0, Thread *current_thread=Thread::get_current_thread())
Removes the referenced node (and the entire subgraph below this node) from the scene graph in any nor...
bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const
Calculates the minimum and maximum vertices of all Geoms at these NodePath's bottom nodes and below T...
TypeHandle is the identifier used to differentiate C++ class types.
static TextureStage * get_default()
Returns the default TextureStage that will be used for all texturing that does not name a particular ...
void hide()
Makes the referenced node (and the entire subgraph below this node) invisible to all cameras...
void set_texture_off(int priority=0)
Sets the geometry at this level and below to render using no texture, on any stage.
void ls() const
Lists the hierarchy at and below the referenced node.
Defines the properties of a named stage of the multitexture pipeline.
void remove_duplicate_paths()
Removes any duplicate entries of the same NodePaths on this collection.
void detach_node(Thread *current_thread=Thread::get_current_thread())
Disconnects the referenced node from its parent, but does not immediately delete it.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
void set_state(const RenderState *state, Thread *current_thread=Thread::get_current_thread())
Changes the complete state object on this node.
void set_color_scale(const LVecBase4 &scale, int priority=0)
Sets the color scale component of the transform, leaving translation and rotation untouched...
CollideMask get_collide_mask() const
Returns the union of all of the into_collide_masks for nodes at this level and below.
void reparent_to(const NodePath &other)
Reparents all the NodePaths in the collection to the indicated node.
const RenderState * get_state(Thread *current_thread=Thread::get_current_thread()) const
Returns the complete state object set on this node.
This is a set of zero or more NodePaths.