Panda3D
Loading...
Searching...
No Matches
physicsObjectCollection.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file physicsObjectCollection.h
10 * @author joswilso
11 * @date 2006-07-12
12 */
13
14#ifndef PHYSICSOBJECTCOLLECTION_H
15#define PHYSICSOBJECTCOLLECTION_H
16
17#include "pandabase.h"
18#include "physicsObject.h"
19#include "pointerToArray.h"
20
21/**
22 * This is a set of zero or more PhysicsObjects. It's handy for returning
23 * from functions that need to return multiple PhysicsObjects.
24 */
25class EXPCL_PANDA_PHYSICS PhysicsObjectCollection {
26PUBLISHED:
27 PhysicsObjectCollection();
28 PhysicsObjectCollection(const PhysicsObjectCollection &copy);
29 void operator = (const PhysicsObjectCollection &copy);
30 INLINE ~PhysicsObjectCollection();
31
32 void add_physics_object(PT(PhysicsObject) physics_object);
33 bool remove_physics_object(PT(PhysicsObject) physics_object);
34 void add_physics_objects_from(const PhysicsObjectCollection &other);
35 void remove_physics_objects_from(const PhysicsObjectCollection &other);
37 bool has_physics_object(PT(PhysicsObject) physics_object) const;
38 void clear();
39
40 bool is_empty() const;
41 int get_num_physics_objects() const;
42 PT(PhysicsObject) get_physics_object(int index) const;
43 MAKE_SEQ(get_physics_objects, get_num_physics_objects, get_physics_object);
44 PT(PhysicsObject) operator [] (int index) const;
45 int size() const;
46 INLINE void operator += (const PhysicsObjectCollection &other);
47 INLINE PhysicsObjectCollection operator + (const PhysicsObjectCollection &other) const;
48
49 void output(std::ostream &out) const;
50 void write(std::ostream &out, int indent_level = 0) const;
51
52private:
53 typedef PTA(PT(PhysicsObject)) PhysicsObjects;
54 PhysicsObjects _physics_objects;
55};
56
57/*
58INLINE ostream &operator << (ostream &out, const PhysicsObjectCollection &col) {
59 col.output(out);
60 return out;
61}
62*/
64
65#endif
bool has_physics_object(PT(PhysicsObject) physics_object) const
Returns true if the indicated PhysicsObject appears in this collection, false otherwise.
void clear()
Removes all PhysicsObjects from the collection.
bool is_empty() const
Returns true if there are no PhysicsObjects in the collection, false otherwise.
void add_physics_object(PT(PhysicsObject) physics_object)
Adds a new PhysicsObject to the collection.
bool remove_physics_object(PT(PhysicsObject) physics_object)
Removes the indicated PhysicsObject from the collection.
get_num_physics_objects
Returns the number of PhysicsObjects in the collection.
void remove_physics_objects_from(const PhysicsObjectCollection &other)
Removes from this collection all of the PhysicsObjects listed in the other collection.
void remove_duplicate_physics_objects()
Removes any duplicate entries of the same PhysicsObjects on this collection.
void add_physics_objects_from(const PhysicsObjectCollection &other)
Adds all the PhysicsObjects indicated in the other collection to this collection.
A body on which physics will be applied.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.