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