Skip to content

Commit

Permalink
Merge branch 'minetest32double' into minetest32net
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Dec 29, 2024
2 parents fe5bc4b + 2f40ee2 commit ec847f8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
18 changes: 9 additions & 9 deletions src/collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ CollisionAxis axisAlignedCollision(
{
//TimeTaker tt("axisAlignedCollision");

aabb3f relbox(
aabb3o relbox(
(movingbox.MaxEdge.X - movingbox.MinEdge.X) + (staticbox.MaxEdge.X - staticbox.MinEdge.X), // sum of the widths
(movingbox.MaxEdge.Y - movingbox.MinEdge.Y) + (staticbox.MaxEdge.Y - staticbox.MinEdge.Y),
(movingbox.MaxEdge.Z - movingbox.MinEdge.Z) + (staticbox.MaxEdge.Z - staticbox.MinEdge.Z),
Expand Down Expand Up @@ -240,7 +240,7 @@ static bool add_area_node_boxes(const v3pos_t min, const v3pos_t max, IGameDef *
// Calculate float position only once
auto posf = intToFloat(p, BS);
for (auto boxf : nodeboxes) {
aabb3o box {v3fToOpos(boxf.MinEdge), v3fToOpos(boxf.MaxEdge)};
aabb3o box = ToOpos(boxf);
box.MinEdge += posf;
box.MaxEdge += posf;
cinfo.emplace_back(false, n_bouncy_value, p, box);
Expand Down Expand Up @@ -373,18 +373,18 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
cinfo.clear();

{
v3f minpos_f(
v3opos_t minpos_f(
MYMIN(pos_f->X, newpos_f.X),
MYMIN(pos_f->Y, newpos_f.Y) + 0.01f * BS, // bias rounding, player often at +/-n.5
MYMIN(pos_f->Z, newpos_f.Z)
);
v3f maxpos_f(
v3opos_t maxpos_f(
MYMAX(pos_f->X, newpos_f.X),
MYMAX(pos_f->Y, newpos_f.Y),
MYMAX(pos_f->Z, newpos_f.Z)
);
v3pos_t min = floatToInt(minpos_f + box_0.MinEdge, BS) - v3pos_t(1, 1, 1);
v3pos_t max = floatToInt(maxpos_f + box_0.MaxEdge, BS) + v3pos_t(1, 1, 1);
v3pos_t min = floatToInt(minpos_f + v3fToOpos(box_0.MinEdge), BS) - v3pos_t(1, 1, 1);
v3pos_t max = floatToInt(maxpos_f + v3fToOpos(box_0.MaxEdge), BS) + v3pos_t(1, 1, 1);

bool any_position_valid = add_area_node_boxes(min, max, gamedef, env, cinfo);

Expand Down Expand Up @@ -421,7 +421,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
break;
}

aabb3o movingbox(v3fToOpos(box_0.MinEdge), v3fToOpos(box_0.MaxEdge));
aabb3o movingbox(ToOpos(box_0));
movingbox.MinEdge += *pos_f;
movingbox.MaxEdge += *pos_f;

Expand Down Expand Up @@ -548,7 +548,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
/*
Final touches: Check if standing on ground, step up stairs.
*/
aabb3o box(v3fToOpos(box_0.MinEdge), v3fToOpos(box_0.MaxEdge));
aabb3o box(ToOpos(box_0));
box.MinEdge += *pos_f;
box.MaxEdge += *pos_f;
for (const auto &box_info : cinfo) {
Expand All @@ -567,7 +567,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
cbox.MinEdge.Z + d < box.MaxEdge.Z) {
if (box_info.is_step_up) {
pos_f->Y += cbox.MaxEdge.Y - box.MinEdge.Y;
box = {(v3fToOpos(box_0.MinEdge), v3fToOpos(box_0.MaxEdge))};
box = ToOpos(box_0);
box.MinEdge += *pos_f;
box.MaxEdge += *pos_f;
}
Expand Down
1 change: 0 additions & 1 deletion src/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ void Environment::continueRaycast(RaycastState *state, PointedThing *result_p)
v3opos_t npf = intToFloat(np, BS);
v3opos_t rel_start = state->m_shootline.start - npf;
for (aabb3f &box : boxes) {
//aabb3o box(v3fToOpos(boxf.MinEdge), v3fToOpos(boxf.MaxEdge));
v3opos_t intersection_point;
v3f intersection_normal;
if (!boxLineCollision(box, rel_start,
Expand Down
2 changes: 1 addition & 1 deletion src/raycast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool boxLineCollision(const aabb3f &box, const v3opos_t start,
collision_normal->set(0, 0, 0);
return true;
}
float m = 0;
opos_t m = 0;

// Test X collision
if (dir.X != 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/server/player_sao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,9 @@ std::string PlayerSAO::getPropertyPacket()
void PlayerSAO::setMaxSpeedOverride(const v3f &vel)
{
if (m_max_speed_override_time == 0.0f)
m_max_speed_override = vel;
m_max_speed_override = v3fToOpos(vel);
else
m_max_speed_override += vel;
m_max_speed_override += v3fToOpos(vel);
if (m_player) {
float accel = MYMIN(m_player->movement_acceleration_default,
m_player->movement_acceleration_air);
Expand Down
2 changes: 1 addition & 1 deletion src/server/player_sao.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class PlayerSAO : public UnitSAO
v3pos_t m_nocheat_dig_pos = v3pos_t(32767, 32767, 32767);
float m_nocheat_dig_time = 0.0f;
float m_max_speed_override_time = 0.0f;
v3f m_max_speed_override = v3f(0.0f, 0.0f, 0.0f);
v3opos_t m_max_speed_override = v3opos_t(0.0f, 0.0f, 0.0f);

// Timers
IntervalLimiter m_breathing_interval;
Expand Down

0 comments on commit ec847f8

Please sign in to comment.