Remove unused pos_max_d

This commit is contained in:
sfan5 2024-11-11 19:46:02 +01:00
parent 9a44d835d6
commit c00129360e
11 changed files with 29 additions and 79 deletions

@ -96,7 +96,6 @@ void ClientEnvironment::step(float dtime)
/*
Maximum position increment
*/
//f32 position_max_increment = 0.05*BS;
f32 position_max_increment = 0.1*BS;
// Maximum time increment (for collision detection etc)
@ -176,12 +175,11 @@ void ClientEnvironment::step(float dtime)
}
/*
Move the lplayer.
Move the local player.
This also does collision detection.
*/
lplayer->move(dtime_part, this, position_max_increment,
&player_collisions);
lplayer->move(dtime_part, this, &player_collisions);
}
bool player_immortal = false;

@ -1143,11 +1143,10 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
box.MinEdge *= BS;
box.MaxEdge *= BS;
collisionMoveResult moveresult;
f32 pos_max_d = BS*0.125; // Distance per iteration
v3f p_pos = m_position;
v3f p_velocity = m_velocity;
moveresult = collisionMoveSimple(env,env->getGameDef(),
pos_max_d, box, m_prop.stepheight, dtime,
box, m_prop.stepheight, dtime,
&p_pos, &p_velocity, m_acceleration,
this, m_prop.collideWithObjects);
// Apply results

@ -209,7 +209,7 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position,
return true;
}
void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
void LocalPlayer::move(f32 dtime, Environment *env,
std::vector<CollisionInfo> *collision_info)
{
// Node at feet position, update each ClientEnvironment::step()
@ -218,7 +218,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
// Temporary option for old move code
if (!physics_override.new_move) {
old_move(dtime, env, pos_max_d, collision_info);
old_move(dtime, env, collision_info);
return;
}
@ -320,17 +320,6 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
nodemgr->get(node2.getContent()).climbable) && !free_move;
}
/*
Collision uncertainty radius
Make it a bit larger than the maximum distance of movement
*/
//f32 d = pos_max_d * 1.1;
// A fairly large value in here makes moving smoother
f32 d = 0.15f * BS;
// This should always apply, otherwise there are glitches
sanity_check(d > pos_max_d);
// Player object property step height is multiplied by BS in
// /src/script/common/c_content.cpp and /src/content_sao.cpp
float player_stepheight = (m_cao == nullptr) ? 0.0f :
@ -341,7 +330,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
const v3f initial_speed = m_speed;
collisionMoveResult result = collisionMoveSimple(env, m_client,
pos_max_d, m_collisionbox, player_stepheight, dtime,
m_collisionbox, player_stepheight, dtime,
&position, &m_speed, accel_f, m_cao);
bool could_sneak = control.sneak && !free_move && !in_liquid &&
@ -528,12 +517,12 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
m_can_jump = m_can_jump && jumpspeed != 0.0f;
// Autojump
handleAutojump(dtime, env, result, initial_position, initial_speed, pos_max_d);
handleAutojump(dtime, env, result, initial_position, initial_speed);
}
void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d)
void LocalPlayer::move(f32 dtime, Environment *env)
{
move(dtime, env, pos_max_d, NULL);
move(dtime, env, nullptr);
}
void LocalPlayer::applyControl(float dtime, Environment *env)
@ -827,7 +816,7 @@ void LocalPlayer::accelerate(const v3f &target_speed, const f32 max_increase_H,
}
// Temporary option for old move code
void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
void LocalPlayer::old_move(f32 dtime, Environment *env,
std::vector<CollisionInfo> *collision_info)
{
Map *map = &env->getMap();
@ -924,15 +913,6 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
is_climbing = (nodemgr->get(node.getContent()).climbable ||
nodemgr->get(node2.getContent()).climbable) && !free_move;
/*
Collision uncertainty radius
Make it a bit larger than the maximum distance of movement
*/
//f32 d = pos_max_d * 1.1;
// A fairly large value in here makes moving smoother
f32 d = 0.15f * BS;
// This should always apply, otherwise there are glitches
sanity_check(d > pos_max_d);
// Maximum distance over border for sneaking
f32 sneak_max = BS * 0.4f;
@ -971,7 +951,7 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
const v3f initial_speed = m_speed;
collisionMoveResult result = collisionMoveSimple(env, m_client,
pos_max_d, m_collisionbox, player_stepheight, dtime,
m_collisionbox, player_stepheight, dtime,
&position, &m_speed, accel_f, m_cao);
// Position was slightly changed; update standing node pos
@ -1155,7 +1135,7 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
}
// Autojump
handleAutojump(dtime, env, result, initial_position, initial_speed, pos_max_d);
handleAutojump(dtime, env, result, initial_position, initial_speed);
}
float LocalPlayer::getSlipFactor(Environment *env, const v3f &speedH)
@ -1178,8 +1158,7 @@ float LocalPlayer::getSlipFactor(Environment *env, const v3f &speedH)
}
void LocalPlayer::handleAutojump(f32 dtime, Environment *env,
const collisionMoveResult &result, const v3f &initial_position,
const v3f &initial_speed, f32 pos_max_d)
const collisionMoveResult &result, v3f initial_position, v3f initial_speed)
{
PlayerSettings &player_settings = getPlayerSettings();
if (!player_settings.autojump)
@ -1235,7 +1214,7 @@ void LocalPlayer::handleAutojump(f32 dtime, Environment *env,
v3f jump_speed = initial_speed;
// try at peak of jump, zero step height
collisionMoveResult jump_result = collisionMoveSimple(env, m_client, pos_max_d,
collisionMoveResult jump_result = collisionMoveSimple(env, m_client,
m_collisionbox, 0.0f, dtime, &jump_pos, &jump_speed, v3f(0.0f), m_cao);
// see if we can get a little bit farther horizontally if we had

@ -16,6 +16,7 @@ class GenericCAO;
class ClientActiveObject;
class ClientEnvironment;
class IGameDef;
struct CollisionInfo;
struct collisionMoveResult;
enum class LocalPlayerAnimation
@ -68,11 +69,8 @@ public:
f32 gravity = 0; // total downwards acceleration
void move(f32 dtime, Environment *env, f32 pos_max_d);
void move(f32 dtime, Environment *env, f32 pos_max_d,
std::vector<CollisionInfo> *collision_info);
// Temporary option for old move code
void old_move(f32 dtime, Environment *env, f32 pos_max_d,
void move(f32 dtime, Environment *env);
void move(f32 dtime, Environment *env,
std::vector<CollisionInfo> *collision_info);
void applyControl(float dtime, Environment *env);
@ -174,10 +172,11 @@ private:
const f32 max_increase_V, const bool use_pitch);
bool updateSneakNode(Map *map, const v3f &position, const v3f &sneak_max);
float getSlipFactor(Environment *env, const v3f &speedH);
void old_move(f32 dtime, Environment *env,
std::vector<CollisionInfo> *collision_info);
void handleAutojump(f32 dtime, Environment *env,
const collisionMoveResult &result,
const v3f &position_before_move, const v3f &speed_before_move,
f32 pos_max_d);
v3f position_before_move, v3f speed_before_move);
v3f m_position;
v3s16 m_standing_node;

@ -89,7 +89,7 @@ void Particle::step(float dtime, ClientEnvironment *env)
aabb3f box(v3f(-m_p.size / 2.0f), v3f(m_p.size / 2.0f));
v3f p_pos = m_pos * BS;
v3f p_velocity = m_velocity * BS;
collisionMoveResult r = collisionMoveSimple(env, env->getGameDef(), BS * 0.5f,
collisionMoveResult r = collisionMoveSimple(env, env->getGameDef(),
box, 0.0f, dtime, &p_pos, &p_velocity, m_acceleration * BS, nullptr,
m_p.object_collision);

@ -323,7 +323,7 @@ static void add_object_boxes(Environment *env,
#define PROFILER_NAME(text) (dynamic_cast<ServerEnvironment*>(env) ? ("Server: " text) : ("Client: " text))
collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
f32 pos_max_d, const aabb3f &box_0,
const aabb3f &box_0,
f32 stepheight, f32 dtime,
v3f *pos_f, v3f *speed_f,
v3f accel_f, ActiveObject *self,

@ -53,10 +53,9 @@ struct collisionMoveResult
/// @warning For unit test use only.
extern bool g_collision_problems_encountered;
/// @brief Moves using a single iteration; speed should not exceed pos_max_d/dtime
/// @param self (optional) ActiveObject to ignore in the collision detection.
collisionMoveResult collisionMoveSimple(Environment *env,IGameDef *gamedef,
f32 pos_max_d, const aabb3f &box_0,
collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
const aabb3f &box_0,
f32 stepheight, f32 dtime,
v3f *pos_f, v3f *speed_f,
v3f accel_f, ActiveObject *self=NULL,

@ -127,7 +127,6 @@ struct PlayerPhysicsOverride
};
class Map;
struct CollisionInfo;
struct HudElement;
class Environment;
@ -140,12 +139,6 @@ public:
DISABLE_CLASS_COPY(Player);
virtual void move(f32 dtime, Environment *env, f32 pos_max_d)
{}
virtual void move(f32 dtime, Environment *env, f32 pos_max_d,
std::vector<CollisionInfo> *collision_info)
{}
// in BS-space
inline void setSpeed(v3f speed)
{

@ -155,12 +155,11 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
aabb3f box = m_prop.collisionbox;
box.MinEdge *= BS;
box.MaxEdge *= BS;
f32 pos_max_d = BS*0.25; // Distance per iteration
v3f p_pos = m_base_position;
v3f p_velocity = m_velocity;
v3f p_acceleration = m_acceleration;
moveresult = collisionMoveSimple(m_env, m_env->getGameDef(),
pos_max_d, box, m_prop.stepheight, dtime,
box, m_prop.stepheight, dtime,
&p_pos, &p_velocity, p_acceleration,
this, m_prop.collideWithObjects);
moveresult_p = &moveresult;

@ -1404,21 +1404,6 @@ void ServerEnvironment::step(float dtime)
m_game_time_fraction_counter -= (float)inc_i;
}
/*
Handle players
*/
{
ScopeProfiler sp(g_profiler, "ServerEnv: move players", SPT_AVG);
for (RemotePlayer *player : m_players) {
// Ignore disconnected players
if (player->getPeerId() == PEER_ID_INEXISTENT)
continue;
// Move
player->move(dtime, this, 100 * BS);
}
}
/*
Manage active block list
*/

@ -213,7 +213,6 @@ void TestCollision::testCollisionMoveSimple(IGameDef *gamedef)
for (s16 z = 0; z < MAP_BLOCKSIZE; z++)
env->getMap().setNode({x, 0, z}, MapNode(t_CONTENT_STONE));
const f32 pos_max_d = 0.25f * BS; // ?
v3f pos, speed, accel;
const aabb3f box(fpos(-0.1f, 0, -0.1f), fpos(0.1f, 1.4f, 0.1f));
collisionMoveResult res;
@ -222,7 +221,7 @@ void TestCollision::testCollisionMoveSimple(IGameDef *gamedef)
pos = fpos(4, 1, 4);
speed = fpos(0, 0, 0);
accel = fpos(0, 1, 0);
res = collisionMoveSimple(env.get(), gamedef, pos_max_d, box, 0.0f, 1.0f,
res = collisionMoveSimple(env.get(), gamedef, box, 0.0f, 1.0f,
&pos, &speed, accel);
UASSERT(!res.touching_ground || !res.collides || !res.standing_on_object);
@ -236,7 +235,7 @@ void TestCollision::testCollisionMoveSimple(IGameDef *gamedef)
pos = fpos(0, 0.5f, 0);
speed = fpos(0, 0, 0);
accel = fpos(0, -9.81f, 0);
res = collisionMoveSimple(env.get(), gamedef, pos_max_d, box, 0.0f, 0.04f,
res = collisionMoveSimple(env.get(), gamedef, box, 0.0f, 0.04f,
&pos, &speed, accel);
UASSERT(res.collides);
@ -256,7 +255,7 @@ void TestCollision::testCollisionMoveSimple(IGameDef *gamedef)
pos = fpos(0, -100, 0);
speed = fpos(0, 0, 0);
accel = fpos(0, 0, 0);
res = collisionMoveSimple(env.get(), gamedef, pos_max_d, box, 0.0f, 1/60.0f,
res = collisionMoveSimple(env.get(), gamedef, box, 0.0f, 1/60.0f,
&pos, &speed, accel);
UASSERT(!res.collides);
@ -264,7 +263,7 @@ void TestCollision::testCollisionMoveSimple(IGameDef *gamedef)
pos = fpos(0, -100, 0);
speed = fpos(5, 0, 0);
accel = fpos(0, 0, 0);
res = collisionMoveSimple(env.get(), gamedef, pos_max_d, box, 0.0f, 1/60.0f,
res = collisionMoveSimple(env.get(), gamedef, box, 0.0f, 1/60.0f,
&pos, &speed, accel);
UASSERTEQ_V3F(speed, fpos(0, 0, 0));
UASSERT(!res.collides); // FIXME this is actually inconsistent