Skip to content

Commit 6e4fdf3

Browse files
sapiersapier
sapier
authored and
sapier
committedApr 9, 2013
fix objects colliding with its own collision boxes
1 parent 7d002b6 commit 6e4fdf3

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed
 

‎src/collision.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ bool wouldCollideWithCeiling(
192192
collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
193193
f32 pos_max_d, const aabb3f &box_0,
194194
f32 stepheight, f32 dtime,
195-
v3f &pos_f, v3f &speed_f, v3f &accel_f)
195+
v3f &pos_f, v3f &speed_f, v3f &accel_f,ActiveObject* self)
196196
{
197197
Map *map = &env->getMap();
198198
//TimeTaker tt("collisionMoveSimple");
@@ -300,7 +300,9 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
300300
c_env->getActiveObjects(pos_f,distance * 1.5,clientobjects);
301301
for (int i=0; i < clientobjects.size(); i++)
302302
{
303-
objects.push_back((ActiveObject*)clientobjects[i].obj);
303+
if ((self == 0) || (self != clientobjects[i].obj)) {
304+
objects.push_back((ActiveObject*)clientobjects[i].obj);
305+
}
304306
}
305307
}
306308
else
@@ -314,7 +316,9 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
314316
for (std::set<u16>::iterator iter = s_objects.begin(); iter != s_objects.end(); iter++)
315317
{
316318
ServerActiveObject *current = s_env->getActiveObject(*iter);
317-
objects.push_back((ActiveObject*)current);
319+
if ((self == 0) || (self != current)) {
320+
objects.push_back((ActiveObject*)current);
321+
}
318322
}
319323
}
320324
}
@@ -458,8 +462,9 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
458462
if (is_object[nearest_boxindex]) {
459463
info.type = COLLISION_OBJECT;
460464
}
461-
else
465+
else {
462466
info.type = COLLISION_NODE;
467+
}
463468
info.node_p = node_positions[nearest_boxindex];
464469
info.bouncy = bouncy;
465470
info.old_speed = speed_f;

‎src/collision.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2626
class Map;
2727
class IGameDef;
2828
class Environment;
29+
class ActiveObject;
2930

3031
enum CollisionType
3132
{
@@ -70,7 +71,7 @@ struct collisionMoveResult
7071
collisionMoveResult collisionMoveSimple(Environment *env,IGameDef *gamedef,
7172
f32 pos_max_d, const aabb3f &box_0,
7273
f32 stepheight, f32 dtime,
73-
v3f &pos_f, v3f &speed_f, v3f &accel_f);
74+
v3f &pos_f, v3f &speed_f, v3f &accel_f,ActiveObject* self=0);
7475

7576
#if 0
7677
// This doesn't seem to work and isn't used

‎src/content_cao.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ class GenericCAO : public ClientActiveObject
11521152
v3f p_acceleration = m_acceleration;
11531153
moveresult = collisionMoveSimple(env,env->getGameDef(),
11541154
pos_max_d, box, stepheight, dtime,
1155-
p_pos, p_velocity, p_acceleration);
1155+
p_pos, p_velocity, p_acceleration,this);
11561156
// Apply results
11571157
m_position = p_pos;
11581158
m_velocity = p_velocity;

‎src/content_sao.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
502502
v3f p_acceleration = m_acceleration;
503503
moveresult = collisionMoveSimple(m_env,m_env->getGameDef(),
504504
pos_max_d, box, stepheight, dtime,
505-
p_pos, p_velocity, p_acceleration);
505+
p_pos, p_velocity, p_acceleration,this);
506506
// Apply results
507507
m_base_position = p_pos;
508508
m_velocity = p_velocity;

0 commit comments

Comments
 (0)
Please sign in to comment.