Panda3D
deferredNodeProperty.cxx
1 // Filename: deferredNodeProperty.cxx
2 // Created by: drose (20Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "deferredNodeProperty.h"
16 
17 #include "collisionNode.h"
18 #include "pandaNode.h"
19 #include "dcast.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: DeferredNodeProperty::Constructor
23 // Access: Public
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 DeferredNodeProperty::
27 DeferredNodeProperty() {
28  _flags = 0;
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: DeferredNodeProperty::Copy Constructor
33 // Access: Public
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 DeferredNodeProperty::
37 DeferredNodeProperty(const DeferredNodeProperty &copy) :
38  _flags(copy._flags),
39  _from_collide_mask(copy._from_collide_mask),
40  _into_collide_mask(copy._into_collide_mask)
41 {
42 }
43 
44 ////////////////////////////////////////////////////////////////////
45 // Function: DeferredNodeProperty::Copy Assignment
46 // Access: Public
47 // Description:
48 ////////////////////////////////////////////////////////////////////
49 void DeferredNodeProperty::
50 operator = (const DeferredNodeProperty &copy) {
51  _flags = copy._flags;
52  _from_collide_mask = copy._from_collide_mask;
53  _into_collide_mask = copy._into_collide_mask;
54 }
55 
56 ////////////////////////////////////////////////////////////////////
57 // Function: DeferredNodeProperty::compose
58 // Access: Public
59 // Description: Composes this state with the next one encountered on
60 // a lower node during the apply traversal.
61 ////////////////////////////////////////////////////////////////////
64  _flags |= other._flags;
65 
66  if ((other._flags & F_has_from_collide_mask) != 0) {
67  _from_collide_mask = other._from_collide_mask;
68  }
69 
70  if ((other._flags & F_has_into_collide_mask) != 0) {
71  _into_collide_mask = other._into_collide_mask;
72  }
73 }
74 
75 ////////////////////////////////////////////////////////////////////
76 // Function: DeferredNodeProperty::apply_to_node
77 // Access: Public
78 // Description: Applies whatever state is appropriate to the node.
79 ////////////////////////////////////////////////////////////////////
82  if (node->is_of_type(CollisionNode::get_class_type())) {
83  CollisionNode *cnode = DCAST(CollisionNode, node);
84  if ((_flags & F_has_from_collide_mask) != 0) {
85  cnode->set_from_collide_mask(_from_collide_mask);
86  }
87  if ((_flags & F_has_into_collide_mask) != 0) {
88  cnode->set_into_collide_mask(_into_collide_mask);
89  }
90  }
91 }
92 
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This class keeps track of all the state we must make note of during the graph traversal, but cannot apply immediately.
void apply_to_node(PandaNode *node)
Applies whatever state is appropriate to the node.
void compose(const DeferredNodeProperty &other)
Composes this state with the next one encountered on a lower node during the apply traversal...
void set_into_collide_mask(CollideMask mask)
Sets the "into" CollideMask.
Definition: collisionNode.I:38
A node in the scene graph that can hold any number of CollisionSolids.
Definition: collisionNode.h:33
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition: typedObject.I:63
void set_from_collide_mask(CollideMask mask)
Sets the "from" CollideMask.