mirror of
https://github.com/luanti-org/luanti.git
synced 2025-12-14 19:18:29 +01:00
Add spatial index for objects (#14631)
This commit is contained in:
@@ -70,11 +70,10 @@ std::string PlayerSAO::getDescription()
|
||||
void PlayerSAO::addedToEnvironment(u32 dtime_s)
|
||||
{
|
||||
ServerActiveObject::addedToEnvironment(dtime_s);
|
||||
ServerActiveObject::setBasePosition(m_base_position);
|
||||
m_player->setPlayerSAO(this);
|
||||
m_player->setPeerId(m_peer_id_initial);
|
||||
m_peer_id_initial = PEER_ID_INEXISTENT; // don't try to use it again.
|
||||
m_last_good_position = m_base_position;
|
||||
m_last_good_position = getBasePosition();
|
||||
}
|
||||
|
||||
// Called before removing from environment
|
||||
@@ -100,7 +99,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
|
||||
os << serializeString16(m_player->getName()); // name
|
||||
writeU8(os, 1); // is_player
|
||||
writeS16(os, getId()); // id
|
||||
writeV3F32(os, m_base_position);
|
||||
writeV3F32(os, getBasePosition());
|
||||
writeV3F32(os, m_rotation);
|
||||
writeU16(os, getHP());
|
||||
|
||||
@@ -184,7 +183,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
|
||||
// Sequence of damage points, starting 0.1 above feet and progressing
|
||||
// upwards in 1 node intervals, stopping below top damage point.
|
||||
for (float dam_height = 0.1f; dam_height < dam_top; dam_height++) {
|
||||
v3s16 p = floatToInt(m_base_position +
|
||||
v3s16 p = floatToInt(getBasePosition() +
|
||||
v3f(0.0f, dam_height * BS, 0.0f), BS);
|
||||
MapNode n = m_env->getMap().getNode(p);
|
||||
const ContentFeatures &c = m_env->getGameDef()->ndef()->get(n);
|
||||
@@ -196,7 +195,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
|
||||
}
|
||||
|
||||
// Top damage point
|
||||
v3s16 ptop = floatToInt(m_base_position +
|
||||
v3s16 ptop = floatToInt(getBasePosition() +
|
||||
v3f(0.0f, dam_top * BS, 0.0f), BS);
|
||||
MapNode ntop = m_env->getMap().getNode(ptop);
|
||||
const ContentFeatures &c = m_env->getGameDef()->ndef()->get(ntop);
|
||||
@@ -273,7 +272,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
|
||||
if (isAttached())
|
||||
pos = m_last_good_position;
|
||||
else
|
||||
pos = m_base_position;
|
||||
pos = getBasePosition();
|
||||
|
||||
std::string str = generateUpdatePositionCommand(
|
||||
pos,
|
||||
@@ -332,7 +331,7 @@ std::string PlayerSAO::generateUpdatePhysicsOverrideCommand() const
|
||||
|
||||
void PlayerSAO::setBasePosition(v3f position)
|
||||
{
|
||||
if (m_player && position != m_base_position)
|
||||
if (m_player && position != getBasePosition())
|
||||
m_player->setDirty(true);
|
||||
|
||||
// This needs to be ran for attachments too
|
||||
@@ -636,7 +635,7 @@ bool PlayerSAO::checkMovementCheat()
|
||||
if (m_is_singleplayer ||
|
||||
isAttached() ||
|
||||
!(anticheat_flags & AC_MOVEMENT)) {
|
||||
m_last_good_position = m_base_position;
|
||||
m_last_good_position = getBasePosition();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -701,7 +700,7 @@ bool PlayerSAO::checkMovementCheat()
|
||||
if (player_max_jump < 0.0001f)
|
||||
player_max_jump = 0.0001f;
|
||||
|
||||
v3f diff = (m_base_position - m_last_good_position);
|
||||
v3f diff = (getBasePosition() - m_last_good_position);
|
||||
float d_vert = diff.Y;
|
||||
diff.Y = 0;
|
||||
float d_horiz = diff.getLength();
|
||||
@@ -722,7 +721,7 @@ bool PlayerSAO::checkMovementCheat()
|
||||
required_time /= anticheat_movement_tolerance;
|
||||
|
||||
if (m_move_pool.grab(required_time)) {
|
||||
m_last_good_position = m_base_position;
|
||||
m_last_good_position = getBasePosition();
|
||||
} else {
|
||||
const float LAG_POOL_MIN = 5.0;
|
||||
float lag_pool_max = m_env->getMaxLagEstimate() * 2.0;
|
||||
@@ -744,8 +743,8 @@ bool PlayerSAO::getCollisionBox(aabb3f *toset) const
|
||||
toset->MinEdge = m_prop.collisionbox.MinEdge * BS;
|
||||
toset->MaxEdge = m_prop.collisionbox.MaxEdge * BS;
|
||||
|
||||
toset->MinEdge += m_base_position;
|
||||
toset->MaxEdge += m_base_position;
|
||||
toset->MinEdge += getBasePosition();
|
||||
toset->MaxEdge += getBasePosition();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user