Panda3D
|
00001 // Filename: deferredNodeProperty.cxx 00002 // Created by: drose (20Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "deferredNodeProperty.h" 00016 00017 #include "collisionNode.h" 00018 #include "pandaNode.h" 00019 #include "dcast.h" 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // Function: DeferredNodeProperty::Constructor 00023 // Access: Public 00024 // Description: 00025 //////////////////////////////////////////////////////////////////// 00026 DeferredNodeProperty:: 00027 DeferredNodeProperty() { 00028 _flags = 0; 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: DeferredNodeProperty::Copy Constructor 00033 // Access: Public 00034 // Description: 00035 //////////////////////////////////////////////////////////////////// 00036 DeferredNodeProperty:: 00037 DeferredNodeProperty(const DeferredNodeProperty ©) : 00038 _flags(copy._flags), 00039 _from_collide_mask(copy._from_collide_mask), 00040 _into_collide_mask(copy._into_collide_mask) 00041 { 00042 } 00043 00044 //////////////////////////////////////////////////////////////////// 00045 // Function: DeferredNodeProperty::Copy Assignment 00046 // Access: Public 00047 // Description: 00048 //////////////////////////////////////////////////////////////////// 00049 void DeferredNodeProperty:: 00050 operator = (const DeferredNodeProperty ©) { 00051 _flags = copy._flags; 00052 _from_collide_mask = copy._from_collide_mask; 00053 _into_collide_mask = copy._into_collide_mask; 00054 } 00055 00056 //////////////////////////////////////////////////////////////////// 00057 // Function: DeferredNodeProperty::compose 00058 // Access: Public 00059 // Description: Composes this state with the next one encountered on 00060 // a lower node during the apply traversal. 00061 //////////////////////////////////////////////////////////////////// 00062 void DeferredNodeProperty:: 00063 compose(const DeferredNodeProperty &other) { 00064 _flags |= other._flags; 00065 00066 if ((other._flags & F_has_from_collide_mask) != 0) { 00067 _from_collide_mask = other._from_collide_mask; 00068 } 00069 00070 if ((other._flags & F_has_into_collide_mask) != 0) { 00071 _into_collide_mask = other._into_collide_mask; 00072 } 00073 } 00074 00075 //////////////////////////////////////////////////////////////////// 00076 // Function: DeferredNodeProperty::apply_to_node 00077 // Access: Public 00078 // Description: Applies whatever state is appropriate to the node. 00079 //////////////////////////////////////////////////////////////////// 00080 void DeferredNodeProperty:: 00081 apply_to_node(PandaNode *node) { 00082 if (node->is_of_type(CollisionNode::get_class_type())) { 00083 CollisionNode *cnode = DCAST(CollisionNode, node); 00084 if ((_flags & F_has_from_collide_mask) != 0) { 00085 cnode->set_from_collide_mask(_from_collide_mask); 00086 } 00087 if ((_flags & F_has_into_collide_mask) != 0) { 00088 cnode->set_into_collide_mask(_into_collide_mask); 00089 } 00090 } 00091 } 00092