Skip to content

Commit 2d283ec

Browse files
committed
xrPhysics: use range-based for
1 parent ad8c0b0 commit 2d283ec

File tree

7 files changed

+171
-215
lines changed

7 files changed

+171
-215
lines changed

src/xrPhysics/BlockAllocator.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ class CBlockAllocator
3939
}
4040
IC void clear()
4141
{
42-
xr_vector<T *>::iterator i = blocks.begin(), e = blocks.end();
43-
for (; i != e; ++i)
44-
xr_free(*i);
42+
for (auto& it : blocks)
43+
xr_free(it);
4544
blocks.clear();
4645
init();
4746
}

src/xrPhysics/PHActivationShape.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,21 @@ static void ActivateTestDepthCallback(
119119

120120
void StaticEnvironment(bool& do_colide, bool bo1, dContact& c, SGameMtl* material_1, SGameMtl* material_2)
121121
{
122-
dJointID contact_joint = dJointCreateContact(0, ContactGroup, &c);
122+
dJointID contact_joint = dJointCreateContact(nullptr, ContactGroup, &c);
123123

124124
if (bo1)
125125
{
126126
((CPHActivationShape*)(retrieveGeomUserData(c.geom.g1)->callback_data))
127127
->DActiveIsland()
128128
->ConnectJoint(contact_joint);
129-
dJointAttach(contact_joint, dGeomGetBody(c.geom.g1), 0);
129+
dJointAttach(contact_joint, dGeomGetBody(c.geom.g1), nullptr);
130130
}
131131
else
132132
{
133133
((CPHActivationShape*)(retrieveGeomUserData(c.geom.g2)->callback_data))
134134
->DActiveIsland()
135135
->ConnectJoint(contact_joint);
136-
dJointAttach(contact_joint, 0, dGeomGetBody(c.geom.g2));
136+
dJointAttach(contact_joint, nullptr, dGeomGetBody(c.geom.g2));
137137
}
138138
do_colide = false;
139139
}
@@ -150,11 +150,10 @@ void GetMaxDepthCallback(bool& do_colide, bool bo1, dContact& c, SGameMtl* mater
150150

151151
void RestoreVelocityState(V_PH_WORLD_STATE& state)
152152
{
153-
V_PH_WORLD_STATE::iterator i = state.begin(), e = state.end();
154-
for (; e != i; ++i)
153+
for (auto& it : state)
155154
{
156-
CPHSynchronize& sync = *i->first;
157-
SPHNetState& old_s = i->second;
155+
CPHSynchronize& sync = *it.first;
156+
SPHNetState& old_s = it.second;
158157
SPHNetState new_s;
159158
sync.get_State(new_s);
160159
new_s.angular_vel.set(old_s.angular_vel);
@@ -166,10 +165,10 @@ void RestoreVelocityState(V_PH_WORLD_STATE& state)
166165

167166
CPHActivationShape::CPHActivationShape()
168167
{
169-
m_geom = NULL;
170-
m_body = NULL;
168+
m_geom = nullptr;
169+
m_body = nullptr;
171170
m_flags.zero();
172-
m_flags.set(flFixedRotation, TRUE);
171+
m_flags.set(flFixedRotation, true);
173172
}
174173
CPHActivationShape::~CPHActivationShape() { VERIFY(!m_body && !m_geom); }
175174
void CPHActivationShape::Create(
@@ -179,16 +178,16 @@ void CPHActivationShape::Create(
179178
R_ASSERT(_valid(start_pos));
180179
R_ASSERT(_valid(start_size));
181180

182-
m_body = dBodyCreate(0);
181+
m_body = dBodyCreate(nullptr);
183182
dMass m;
184183
dMassSetSphere(&m, 1.f, 100000.f);
185184
dMassAdjust(&m, 1.f);
186185
dBodySetMass(m_body, &m);
187186
switch (_type)
188187
{
189-
case etBox: m_geom = dCreateBox(0, start_size.x, start_size.y, start_size.z); break;
188+
case etBox: m_geom = dCreateBox(nullptr, start_size.x, start_size.y, start_size.z); break;
190189

191-
case etSphere: m_geom = dCreateSphere(0, start_size.x); break;
190+
case etSphere: m_geom = dCreateSphere(nullptr, start_size.x); break;
192191
};
193192

194193
dGeomCreateUserData(m_geom);
@@ -200,7 +199,7 @@ void CPHActivationShape::Create(
200199
dBodyEnable(m_body);
201200
m_safe_state.create(m_body);
202201
spatial_register();
203-
m_flags.set(flags, TRUE);
202+
m_flags.set(flags, true);
204203
}
205204
void CPHActivationShape::Destroy()
206205
{
@@ -209,9 +208,9 @@ void CPHActivationShape::Destroy()
209208
CPHObject::deactivate();
210209
dGeomDestroyUserData(m_geom);
211210
dGeomDestroy(m_geom);
212-
m_geom = NULL;
211+
m_geom = nullptr;
213212
dBodyDestroy(m_body);
214-
m_body = NULL;
213+
m_body = nullptr;
215214
}
216215
bool CPHActivationShape::Activate(
217216
const Fvector need_size, u16 steps, float max_displacement, float max_rotation, bool un_freeze_later /* =false*/)

src/xrPhysics/PHElement.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ void CPHElement::set_local_mass_center(const Fvector& mc)
151151
}
152152
dMass CPHElement::recursive_mass_summ(u16 start_geom, FRACTURE_I cur_fracture)
153153
{
154+
// XXX: Review
154155
dMass end_mass;
155156
dMassSetZero(&end_mass);
156157
GEOM_I i_geom = m_geoms.begin() + start_geom, e = m_geoms.begin() + cur_fracture->m_start_geom_num;

0 commit comments

Comments
 (0)