Panda3D
Loading...
Searching...
No Matches
panda
src
physx
physxObjectCollection.I
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 physxObjectCollection.I
10
* @author enn0x
11
* @date 2009-11-08
12
*/
13
14
/**
15
*
16
*/
17
template
<
class
T>
18
INLINE
unsigned
int
PhysxObjectCollection<T>::
19
size
()
const
{
20
21
return
_objects.size();
22
}
23
24
/**
25
*
26
*/
27
template
<
class
T>
28
INLINE
void
PhysxObjectCollection<T>::
29
add
(PT(T)
object
) {
30
31
_objects.push_back(
object
);
32
}
33
34
/**
35
*
36
*/
37
template
<
class
T>
38
INLINE
void
PhysxObjectCollection<T>::
39
remove
(PT(T)
object
) {
40
41
typename
pvector
<PT(T)>::iterator it;
42
43
it = find(_objects.begin(), _objects.end(),
object
);
44
if
(it != _objects.end()) {
45
_objects.erase(it);
46
}
47
else
48
{
49
physx_cat.warning() <<
"object not found in collection"
<< std::endl;
50
}
51
}
52
53
/**
54
* Returns the n-th PhysxObject in the collection. The operator [] is maybe a
55
* more convenient way to access objects from the collection.
56
*/
57
template
<
class
T>
58
INLINE T *
PhysxObjectCollection<T>::
59
get
(
unsigned
int
index)
const
{
60
61
nassertr(index < _objects.size(),
nullptr
);
62
return
_objects[index];
63
}
64
65
/**
66
* Returns the n-th PhysxObject in the collection. This is the same as the
67
* get() method.
68
*/
69
template
<
class
T>
70
INLINE T *
PhysxObjectCollection<T>::
71
operator []
(
unsigned
int
index)
const
{
72
73
nassertr(index < _objects.size(),
nullptr
);
74
return
_objects[index];
75
}
76
77
/**
78
*
79
*/
80
template
<
class
T>
81
INLINE
void
PhysxObjectCollection<T>::
82
ls
()
const
{
83
84
ls(nout);
85
}
86
87
/**
88
*
89
*/
90
template
<
class
T>
91
INLINE
void
PhysxObjectCollection<T>::
92
ls
(std::ostream &out,
int
indent_level)
const
{
93
94
for
(
unsigned
int
i=0; i < size(); i++) {
95
get(i)->ls(out, indent_level + 2);
96
}
97
}
PhysxObjectCollection
Definition
physxObjectCollection.h:25
PhysxObjectCollection::operator[]
T * operator[](unsigned int index) const
Returns the n-th PhysxObject in the collection.
Definition
physxObjectCollection.I:71
PhysxObjectCollection::get
T * get(unsigned int index) const
Returns the n-th PhysxObject in the collection.
Definition
physxObjectCollection.I:59
pvector
This is our own Panda specialization on the default STL vector.
Definition
pvector.h:42
Generated on Mon Jan 8 2024 17:18:44 for Panda3D by
1.10.0