Skip to content

Commit a397205

Browse files
committed
Get rid of redundant geoms_ in world.hpp
1 parent fd1e309 commit a397205

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/multi_body.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ class MultiBody {
9191

9292
explicit MultiBody(bool isFloating = false) : is_floating_(isFloating) {}
9393

94+
virtual ~RigidBody() { clear(); }
95+
96+
void clear() {
97+
while (!collision_geometries_.empty()) {
98+
delete collision_geometries_.back(), collision_geometries_.pop_back();
99+
}
100+
94101
template <typename AlgebraTo = Algebra>
95102
MultiBody<AlgebraTo> clone() const {
96103
typedef Conversion<Algebra, AlgebraTo> C;

src/rigid_body.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class RigidBody {
5959
Algebra::set_zero(total_torque_);
6060
}
6161

62+
virtual ~RigidBody() { delete geometry_; }
63+
6264
template <typename AlgebraTo = Algebra>
6365
RigidBody<AlgebraTo> clone() const {
6466
typedef Conversion<Algebra, AlgebraTo> C;

src/world.hpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ class World {
4848
std::vector<MultiBody*> multi_bodies_;
4949

5050
Vector3 gravity_acceleration_;
51-
52-
std::vector<Geometry*> geoms_;
53-
54-
51+
5552

5653
CollisionDispatcher<Algebra> dispatcher_;
5754
RigidBodyConstraintSolver<Algebra>* rb_constraint_solver_{nullptr};
@@ -77,7 +74,6 @@ class World {
7774

7875
size_t num_rigid_bodies() const { return rigid_bodies_.size(); }
7976
size_t num_multi_bodies() const { return multi_bodies_.size(); }
80-
size_t num_geoms() const { return geoms_.size(); }
8177

8278
inline void submit_profile_timing(const char* name=0) const {
8379
if (profile_timing_func_) {
@@ -99,9 +95,6 @@ class World {
9995
}
10096

10197
void clear() {
102-
while (!geoms_.empty()) {
103-
delete geoms_.back(), geoms_.pop_back();
104-
}
10598
while (!rigid_bodies_.empty()) {
10699
delete rigid_bodies_.back(), rigid_bodies_.pop_back();
107100
}
@@ -122,25 +115,21 @@ class World {
122115

123116
Capsule* create_capsule(const Scalar& radius, const Scalar& length) {
124117
Capsule* capsule = new Capsule(radius, length);
125-
geoms_.push_back(capsule);
126118
return capsule;
127119
}
128120

129121
Plane* create_plane() {
130122
Plane* plane = new Plane();
131-
geoms_.push_back(plane);
132123
return plane;
133124
}
134125

135126
Sphere* create_sphere(const Scalar& radius) {
136127
Sphere* sphere = new Sphere(radius);
137-
geoms_.push_back(sphere);
138128
return sphere;
139129
}
140130

141131
Box* create_box (const Vector3& extents) {
142132
Box* box = new Box(extents);
143-
geoms_.push_back(box);
144133
return box;
145134
}
146135

0 commit comments

Comments
 (0)