// Filename: physxObjectCollection.I // Created by: enn0x (08Nov09) // //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE // Copyright (c) Carnegie Mellon University. All rights reserved. // // All use of this software is subject to the terms of the revised BSD // license. You should have received a copy of this license along // with this source code in a file named "LICENSE." // //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // Function: PhysxObjectCollection::size // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE unsigned int PhysxObjectCollection:: size() const { return _objects.size(); } //////////////////////////////////////////////////////////////////// // Function: PhysxObjectCollection::add // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE void PhysxObjectCollection:: add(PT(T) object) { _objects.push_back(object); } //////////////////////////////////////////////////////////////////// // Function: PhysxObjectCollection::remove // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE void PhysxObjectCollection:: remove(PT(T) object) { typename pvector::iterator it; it = find(_objects.begin(), _objects.end(), object); if (it != _objects.end()) { _objects.erase(it); } else { physx_cat.warning() << "object not found in collection" << endl; } } //////////////////////////////////////////////////////////////////// // Function: PhysxObjectCollection::get // Access: Public // Description: Returns the n-th PhysxObject in the collection. // The operator [] is maybe a more convenient way to // access objects from the collection. //////////////////////////////////////////////////////////////////// template INLINE T *PhysxObjectCollection:: get(unsigned int index) const { nassertr(index < _objects.size(), NULL); return _objects[index]; } //////////////////////////////////////////////////////////////////// // Function: PhysxObjectCollection::operator [] // Access: Public // Description: Returns the n-th PhysxObject in the collection. // This is the same as the get() method. //////////////////////////////////////////////////////////////////// template INLINE T *PhysxObjectCollection:: operator [] (unsigned int index) const { nassertr(index < _objects.size(), NULL); return _objects[index]; } //////////////////////////////////////////////////////////////////// // Function: PhysxObjectCollection::ls // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE void PhysxObjectCollection:: ls() const { ls(nout); } //////////////////////////////////////////////////////////////////// // Function: PhysxObjectCollection::ls // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE void PhysxObjectCollection:: ls(ostream &out, int indent_level) const { for (unsigned int i=0; i < size(); i++) { get(i)->ls(out, indent_level + 2); } }