mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
better NodePath interfaces for set_collide_mask()
This commit is contained in:
parent
0369f07074
commit
895b553cdb
@ -1475,7 +1475,7 @@ get_collide_mask() const {
|
|||||||
// Access: Published
|
// Access: Published
|
||||||
// Description: Recursively applies the indicated CollideMask to the
|
// Description: Recursively applies the indicated CollideMask to the
|
||||||
// into_collide_masks for all nodes at this level and
|
// into_collide_masks for all nodes at this level and
|
||||||
// below.
|
// below. Only nodes
|
||||||
//
|
//
|
||||||
// The default is to change all bits, but if
|
// The default is to change all bits, but if
|
||||||
// bits_to_change is not all bits on, then only the bits
|
// bits_to_change is not all bits on, then only the bits
|
||||||
@ -1484,9 +1484,15 @@ get_collide_mask() const {
|
|||||||
// subgraph.
|
// subgraph.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE void NodePath::
|
INLINE void NodePath::
|
||||||
set_collide_mask(CollideMask new_mask, CollideMask bits_to_change) {
|
set_collide_mask(CollideMask new_mask, CollideMask bits_to_change,
|
||||||
|
TypeHandle node_type) {
|
||||||
nassertv_always(!is_empty());
|
nassertv_always(!is_empty());
|
||||||
r_set_collide_mask(node(), ~bits_to_change, new_mask & bits_to_change);
|
if (node_type == TypeHandle::none()) {
|
||||||
|
node_type = PandaNode::get_class_type();
|
||||||
|
}
|
||||||
|
|
||||||
|
r_set_collide_mask(node(), ~bits_to_change, new_mask & bits_to_change,
|
||||||
|
node_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -4952,15 +4952,18 @@ r_force_recompute_bounds(PandaNode *node) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void NodePath::
|
void NodePath::
|
||||||
r_set_collide_mask(PandaNode *node,
|
r_set_collide_mask(PandaNode *node,
|
||||||
CollideMask and_mask, CollideMask or_mask) {
|
CollideMask and_mask, CollideMask or_mask,
|
||||||
|
TypeHandle node_type) {
|
||||||
|
if (node->is_of_type(node_type)) {
|
||||||
CollideMask into_collide_mask = node->get_into_collide_mask();
|
CollideMask into_collide_mask = node->get_into_collide_mask();
|
||||||
into_collide_mask = (into_collide_mask & and_mask) | or_mask;
|
into_collide_mask = (into_collide_mask & and_mask) | or_mask;
|
||||||
node->set_into_collide_mask(into_collide_mask);
|
node->set_into_collide_mask(into_collide_mask);
|
||||||
|
}
|
||||||
|
|
||||||
PandaNode::Children cr = node->get_children();
|
PandaNode::Children cr = node->get_children();
|
||||||
int num_children = cr.get_num_children();
|
int num_children = cr.get_num_children();
|
||||||
for (int i = 0; i < num_children; i++) {
|
for (int i = 0; i < num_children; i++) {
|
||||||
r_set_collide_mask(cr.get_child(i), and_mask, or_mask);
|
r_set_collide_mask(cr.get_child(i), and_mask, or_mask, node_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,7 +648,8 @@ PUBLISHED:
|
|||||||
NodePath get_stashed_ancestor() const;
|
NodePath get_stashed_ancestor() const;
|
||||||
|
|
||||||
INLINE CollideMask get_collide_mask() const;
|
INLINE CollideMask get_collide_mask() const;
|
||||||
INLINE void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change = CollideMask::all_on());
|
INLINE void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change = CollideMask::all_on(),
|
||||||
|
TypeHandle node_type = TypeHandle::none());
|
||||||
|
|
||||||
// Comparison methods
|
// Comparison methods
|
||||||
INLINE bool operator == (const NodePath &other) const;
|
INLINE bool operator == (const NodePath &other) const;
|
||||||
@ -712,7 +713,8 @@ private:
|
|||||||
void r_force_recompute_bounds(PandaNode *node);
|
void r_force_recompute_bounds(PandaNode *node);
|
||||||
|
|
||||||
void r_set_collide_mask(PandaNode *node,
|
void r_set_collide_mask(PandaNode *node,
|
||||||
CollideMask and_mask, CollideMask or_mask);
|
CollideMask and_mask, CollideMask or_mask,
|
||||||
|
TypeHandle node_type);
|
||||||
|
|
||||||
typedef pset<Texture *> Textures;
|
typedef pset<Texture *> Textures;
|
||||||
Texture *r_find_texture(PandaNode *node, const RenderState *state,
|
Texture *r_find_texture(PandaNode *node, const RenderState *state,
|
||||||
|
@ -380,6 +380,47 @@ detach() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePathCollection::get_collide_mask
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the union of all of the into_collide_masks
|
||||||
|
// for nodes at this level and below. This is the same
|
||||||
|
// thing as node()->get_net_collide_mask().
|
||||||
|
//
|
||||||
|
// If you want to return what the into_collide_mask of
|
||||||
|
// this node itself is, without regard to its children,
|
||||||
|
// use node()->get_into_collide_mask().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
CollideMask NodePathCollection::
|
||||||
|
get_collide_mask() const {
|
||||||
|
CollideMask collide_mask;
|
||||||
|
for (int i = 0; i < get_num_paths(); i++) {
|
||||||
|
collide_mask |= get_path(i).get_collide_mask();
|
||||||
|
}
|
||||||
|
return collide_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePathCollection::set_collide_mask
|
||||||
|
// Access: Published
|
||||||
|
// Description: Recursively applies the indicated CollideMask to the
|
||||||
|
// into_collide_masks for all nodes at this level and
|
||||||
|
// below. Only nodes
|
||||||
|
//
|
||||||
|
// The default is to change all bits, but if
|
||||||
|
// bits_to_change is not all bits on, then only the bits
|
||||||
|
// that are set in bits_to_change are modified, allowing
|
||||||
|
// this call to change only a subset of the bits in the
|
||||||
|
// subgraph.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void NodePathCollection::
|
||||||
|
set_collide_mask(CollideMask new_mask, CollideMask bits_to_change,
|
||||||
|
TypeHandle node_type) {
|
||||||
|
for (int i = 0; i < get_num_paths(); i++) {
|
||||||
|
get_path(i).set_collide_mask(new_mask, bits_to_change, node_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NodePathCollection::set_color
|
// Function: NodePathCollection::set_color
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -64,6 +64,10 @@ PUBLISHED:
|
|||||||
void unstash();
|
void unstash();
|
||||||
void detach();
|
void detach();
|
||||||
|
|
||||||
|
CollideMask get_collide_mask() const;
|
||||||
|
void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change = CollideMask::all_on(),
|
||||||
|
TypeHandle node_type = TypeHandle::none());
|
||||||
|
|
||||||
void set_color(float r, float g, float b, float a = 1.0,
|
void set_color(float r, float g, float b, float a = 1.0,
|
||||||
int priority = 0);
|
int priority = 0);
|
||||||
void set_color(const Colorf &color, int priority = 0);
|
void set_color(const Colorf &color, int priority = 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user