Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/physics/physicalNode.cxx

Go to the documentation of this file.
00001 // Filename: physicalNode.cxx
00002 // Created by:  charles (01Aug00)
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 "physicalNode.h"
00020 
00021 // static stuff.
00022 TypeHandle PhysicalNode::_type_handle;
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function : PhysicalNode
00026 //       Access : public
00027 //  Description : default constructor
00028 ////////////////////////////////////////////////////////////////////
00029 PhysicalNode::
00030 PhysicalNode(const string &name) :
00031   PandaNode(name) 
00032 {
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function : PhysicalNode
00037 //       Access : protected
00038 //  Description : copy constructor
00039 ////////////////////////////////////////////////////////////////////
00040 PhysicalNode::
00041 PhysicalNode(const PhysicalNode &copy) :
00042   PandaNode(copy), _physicals(copy._physicals) {
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function : ~PhysicalNode
00047 //       Access : protected, virtual
00048 //  Description : destructor
00049 ////////////////////////////////////////////////////////////////////
00050 PhysicalNode::
00051 ~PhysicalNode(void) {
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //     Function : make_copy
00056 //       Access : public, virtual
00057 //  Description : dynamic child copy
00058 ////////////////////////////////////////////////////////////////////
00059 PandaNode *PhysicalNode::
00060 make_copy(void) const {
00061   return new PhysicalNode(*this);
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function : add_physicals_from
00066 //       Access : public
00067 //  Description : append operation
00068 ////////////////////////////////////////////////////////////////////
00069 void PhysicalNode::
00070 add_physicals_from(const PhysicalNode &other) {
00071   pvector< PT(Physical) >::iterator last = _physicals.end() - 1;
00072 
00073   _physicals.insert(_physicals.end(),
00074                     other._physicals.begin(), other._physicals.end());
00075 
00076   for (; last != _physicals.end(); last++)
00077     (*last)->_physical_node = this;
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function : remove_physical
00082 //       Access : public
00083 //  Description : remove operation
00084 ////////////////////////////////////////////////////////////////////
00085 void PhysicalNode::
00086 remove_physical(Physical *physical) {
00087   pvector< PT(Physical) >::iterator found;
00088   PT(Physical) ptp = physical;
00089   found = find(_physicals.begin(), _physicals.end(), ptp);
00090   if (found == _physicals.end())
00091     return;
00092   _physicals.erase(found);
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function : remove_physical
00097 //       Access : public
00098 //  Description : remove operation
00099 ////////////////////////////////////////////////////////////////////
00100 void PhysicalNode::
00101 remove_physical(int index) {
00102   nassertv(index >= 0 && index <= (int)_physicals.size());
00103 
00104   pvector< PT(Physical) >::iterator remove;
00105   remove = _physicals.begin() + index;
00106   (*remove)->_physical_node = (PhysicalNode *) NULL;
00107 
00108   _physicals.erase(remove);
00109 }

Generated on Fri May 2 00:43:02 2003 for Panda by doxygen1.3