Panda3D
physicsObjectCollection.h
1 // Filename: physicsObjectCollection.h
2 // Created by: joswilso (12Jul06)
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 #ifndef PHYSICSOBJECTCOLLECTION_H
16 #define PHYSICSOBJECTCOLLECTION_H
17 
18 #include "pandabase.h"
19 #include "physicsObject.h"
20 #include "pointerToArray.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : PhysicsObjectCollection
24 // Description : This is a set of zero or more PhysicsObjects. It's handy
25 // for returning from functions that need to return
26 // multiple PhysicsObjects.
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_PANDAPHYSICS PhysicsObjectCollection {
29 PUBLISHED:
32  void operator = (const PhysicsObjectCollection &copy);
33  INLINE ~PhysicsObjectCollection();
34 
35  void add_physics_object(PT(PhysicsObject) physics_object);
36  bool remove_physics_object(PT(PhysicsObject) physics_object);
37  void add_physics_objects_from(const PhysicsObjectCollection &other);
38  void remove_physics_objects_from(const PhysicsObjectCollection &other);
39  void remove_duplicate_physics_objects();
40  bool has_physics_object(PT(PhysicsObject) physics_object) const;
41  void clear();
42 
43  bool is_empty() const;
44  int get_num_physics_objects() const;
45  PT(PhysicsObject) get_physics_object(int index) const;
46  MAKE_SEQ(get_physics_objects, get_num_physics_objects, get_physics_object);
47  PT(PhysicsObject) operator [] (int index) const;
48  int size() const;
49  INLINE void operator += (const PhysicsObjectCollection &other);
50  INLINE PhysicsObjectCollection operator + (const PhysicsObjectCollection &other) const;
51 
52  void output(ostream &out) const;
53  void write(ostream &out, int indent_level = 0) const;
54 
55 private:
56  typedef PTA(PT(PhysicsObject)) PhysicsObjects;
57  PhysicsObjects _physics_objects;
58 };
59 
60 /*
61 INLINE ostream &operator << (ostream &out, const PhysicsObjectCollection &col) {
62  col.output(out);
63  return out;
64 }
65 */
66 #include "physicsObjectCollection.I"
67 
68 #endif
69 
70 
A body on which physics will be applied.
Definition: physicsObject.h:29
This is a set of zero or more PhysicsObjects.