Merge remote-tracking branch 'minetest/master'
This commit is contained in:
commit
2ce92e62ed
@ -511,6 +511,12 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
|
||||
|
||||
void Camera::updateViewingRange()
|
||||
{
|
||||
|
||||
const f32 viewing_range = g_settings->getFloat("viewing_range");
|
||||
/* mt static range:
|
||||
m_draw_control.wanted_range = viewing_range;
|
||||
*/
|
||||
|
||||
if (m_draw_control.range_all) {
|
||||
m_cameranode->setFarValue(100000.0);
|
||||
return;
|
||||
@ -537,7 +543,7 @@ void Camera::updateViewingRange()
|
||||
<<std::endl;*/
|
||||
|
||||
// Get current viewing range and FPS settings
|
||||
f32 viewing_range_min = g_settings->getFloat("viewing_range");
|
||||
f32 viewing_range_min = viewing_range;
|
||||
viewing_range_min = MYMAX(15.0, viewing_range_min);
|
||||
|
||||
f32 viewing_range_max = g_settings->getFloat("viewing_range_max");
|
||||
@ -710,12 +716,9 @@ void Camera::updateViewingRange()
|
||||
|
||||
g_profiler->add("CM: wanted_range", m_draw_control.wanted_range);
|
||||
|
||||
const auto viewing_range = m_draw_control.wanted_range;
|
||||
/* mt static range:
|
||||
f32 viewing_range = g_settings->getFloat("viewing_range");
|
||||
m_draw_control.wanted_range = viewing_range;
|
||||
*/
|
||||
m_cameranode->setFarValue((viewing_range < 2000) ? 2000 * BS : viewing_range * BS);
|
||||
const auto viewing_range_new = m_draw_control.wanted_range;
|
||||
|
||||
m_cameranode->setFarValue((viewing_range_new < 2000) ? 2000 * BS : viewing_range_new * BS);
|
||||
}
|
||||
|
||||
void Camera::setDigging(s32 button)
|
||||
|
@ -1015,13 +1015,16 @@ void Client::Send(NetworkPacket* pkt)
|
||||
#endif
|
||||
|
||||
// Will fill up 12 + 12 + 4 + 4 + 4 bytes
|
||||
void writePlayerPos(LocalPlayer *myplayer, NetworkPacket *pkt)
|
||||
void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket *pkt)
|
||||
{
|
||||
v3f pf = myplayer->getPosition() * 100;
|
||||
v3f sf = myplayer->getSpeed() * 100;
|
||||
s32 pitch = myplayer->getPitch() * 100;
|
||||
s32 yaw = myplayer->getYaw() * 100;
|
||||
u32 keyPressed = myplayer->keyPressed;
|
||||
v3f pf = myplayer->getPosition() * 100;
|
||||
v3f sf = myplayer->getSpeed() * 100;
|
||||
s32 pitch = myplayer->getPitch() * 100;
|
||||
s32 yaw = myplayer->getYaw() * 100;
|
||||
u32 keyPressed = myplayer->keyPressed;
|
||||
// scaled by 80, so that pi can fit into a u8
|
||||
u8 fov = clientMap->getCameraFov() * 80;
|
||||
u8 wanted_range = clientMap->getControl().wanted_range / MAP_BLOCKSIZE;
|
||||
|
||||
v3s32 position(pf.X, pf.Y, pf.Z);
|
||||
v3s32 speed(sf.X, sf.Y, sf.Z);
|
||||
@ -1033,9 +1036,11 @@ void writePlayerPos(LocalPlayer *myplayer, NetworkPacket *pkt)
|
||||
[12+12] s32 pitch*100
|
||||
[12+12+4] s32 yaw*100
|
||||
[12+12+4+4] u32 keyPressed
|
||||
[12+12+4+4+1] u8 fov*80
|
||||
[12+12+4+4+4+1] u8 wanted_range / MAP_BLOCKSIZE
|
||||
*/
|
||||
|
||||
*pkt << position << speed << pitch << yaw << keyPressed;
|
||||
*pkt << fov << wanted_range;
|
||||
}
|
||||
|
||||
#if MINETEST_PROTO
|
||||
@ -1079,7 +1084,7 @@ void Client::interact(u8 action, const PointedThing& pointed)
|
||||
|
||||
pkt.putLongString(tmp_os.str());
|
||||
|
||||
writePlayerPos(myplayer, &pkt);
|
||||
writePlayerPos(myplayer, &m_env.getClientMap(), &pkt);
|
||||
|
||||
Send(&pkt);
|
||||
}
|
||||
@ -1388,19 +1393,30 @@ void Client::sendPlayerPos()
|
||||
if(myplayer == NULL)
|
||||
return;
|
||||
|
||||
ClientMap &map = m_env.getClientMap();
|
||||
|
||||
u8 camera_fov = map.getCameraFov();
|
||||
u8 wanted_range = map.getControl().wanted_range;
|
||||
|
||||
// Save bandwidth by only updating position when something changed
|
||||
if(myplayer->last_position == myplayer->getPosition() &&
|
||||
myplayer->last_speed == myplayer->getSpeed() &&
|
||||
myplayer->last_pitch == myplayer->getPitch() &&
|
||||
myplayer->last_yaw == myplayer->getYaw() &&
|
||||
myplayer->last_keyPressed == myplayer->keyPressed)
|
||||
myplayer->last_speed == myplayer->getSpeed() &&
|
||||
myplayer->last_pitch == myplayer->getPitch() &&
|
||||
myplayer->last_yaw == myplayer->getYaw() &&
|
||||
myplayer->last_keyPressed == myplayer->keyPressed &&
|
||||
myplayer->last_camera_fov == camera_fov &&
|
||||
myplayer->last_wanted_range == wanted_range)
|
||||
return;
|
||||
|
||||
myplayer->last_position = myplayer->getPosition();
|
||||
myplayer->last_speed = myplayer->getSpeed();
|
||||
myplayer->last_pitch = myplayer->getPitch();
|
||||
myplayer->last_yaw = myplayer->getYaw();
|
||||
myplayer->last_keyPressed = myplayer->keyPressed;
|
||||
myplayer->last_position = myplayer->getPosition();
|
||||
myplayer->last_speed = myplayer->getSpeed();
|
||||
myplayer->last_pitch = myplayer->getPitch();
|
||||
myplayer->last_yaw = myplayer->getYaw();
|
||||
myplayer->last_keyPressed = myplayer->keyPressed;
|
||||
myplayer->last_camera_fov = camera_fov;
|
||||
myplayer->last_wanted_range = wanted_range;
|
||||
|
||||
//infostream << "Sending Player Position information" << std::endl;
|
||||
|
||||
u16 our_peer_id;
|
||||
{
|
||||
@ -1416,7 +1432,7 @@ void Client::sendPlayerPos()
|
||||
|
||||
NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4);
|
||||
|
||||
writePlayerPos(myplayer, &pkt);
|
||||
writePlayerPos(myplayer, &map, &pkt);
|
||||
|
||||
Send(&pkt);
|
||||
}
|
||||
|
@ -249,6 +249,16 @@ int RemoteClient::GetNextBlocks (
|
||||
*/
|
||||
s32 new_nearest_unsent_d = -1;
|
||||
|
||||
// get view range and camera fov from the client
|
||||
s16 wanted_range = sao->getWantedRange();
|
||||
float camera_fov = sao->getFov();
|
||||
// if FOV, wanted_range are not available (old client), fall back to old default
|
||||
/*
|
||||
if (wanted_range <= 0) wanted_range = 140;
|
||||
*/
|
||||
if (camera_fov <= 0) camera_fov = ((fov+5)*M_PI/180) * 4./3.;
|
||||
|
||||
|
||||
static const auto max_block_send_distance = g_settings->getS16("max_block_send_distance");
|
||||
s16 full_d_max = max_block_send_distance;
|
||||
if (wanted_range) {
|
||||
@ -256,14 +266,19 @@ int RemoteClient::GetNextBlocks (
|
||||
if (wanted_blocks < full_d_max)
|
||||
full_d_max = wanted_blocks;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
const s16 full_d_max = g_settings->getS16("max_block_send_distance");
|
||||
const s16 d_opt = g_settings->getS16("block_send_optimize_distance");
|
||||
const s16 full_d_max = MYMIN(g_settings->getS16("max_block_send_distance"), wanted_range);
|
||||
const s16 d_opt = MYMIN(g_settings->getS16("block_send_optimize_distance"), wanted_range);
|
||||
*/
|
||||
|
||||
const s16 d_blocks_in_sight = full_d_max * BS * MAP_BLOCKSIZE;
|
||||
//infostream << "Fov from client " << camera_fov << " full_d_max " << full_d_max << std::endl;
|
||||
|
||||
s16 d_max = full_d_max;
|
||||
static const s16 d_max_gen = g_settings->getS16("max_block_generate_distance");
|
||||
static const s16 d_max_gen_s = g_settings->getS16("max_block_generate_distance");
|
||||
s16 d_max_gen = MYMIN(d_max_gen_s, wanted_range);
|
||||
|
||||
// Don't loop very much at a time
|
||||
s16 max_d_increment_at_time = 10;
|
||||
@ -386,7 +401,6 @@ int RemoteClient::GetNextBlocks (
|
||||
FOV setting. The default of 72 degrees is fine.
|
||||
*/
|
||||
|
||||
float camera_fov = ((fov+5)*M_PI/180) * 4./3.;
|
||||
if(can_skip && isBlockInSight(p, camera_pos, camera_dir, camera_fov, d_blocks_in_sight) == false)
|
||||
{
|
||||
continue;
|
||||
|
@ -160,8 +160,16 @@ public:
|
||||
// For debug printing
|
||||
virtual void PrintInfo(std::ostream &out);
|
||||
|
||||
MapDrawControl & getControl() { return m_control; }
|
||||
/*
|
||||
// Check if sector was drawn on last render()
|
||||
bool sectorWasDrawn(v2s16 p)
|
||||
{
|
||||
return (m_last_drawn_sectors.find(p) != m_last_drawn_sectors.end());
|
||||
}
|
||||
*/
|
||||
|
||||
MapDrawControl & getControl() const { return m_control; }
|
||||
f32 getCameraFov() const { return m_camera_fov; }
|
||||
private:
|
||||
Client *m_client;
|
||||
|
||||
|
@ -804,6 +804,8 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, u16 peer_id_, bool is_singleplayer
|
||||
m_attachment_sent(false),
|
||||
m_breath(PLAYER_MAX_BREATH),
|
||||
m_pitch(0),
|
||||
m_fov(0),
|
||||
m_wanted_range(0),
|
||||
// public
|
||||
m_physics_override_speed(1),
|
||||
m_physics_override_jump(1),
|
||||
@ -1178,6 +1180,22 @@ void PlayerSAO::setYaw(const float yaw)
|
||||
UnitSAO::setYaw(yaw);
|
||||
}
|
||||
|
||||
void PlayerSAO::setFov(const float fov)
|
||||
{
|
||||
if (m_player && fov != m_fov)
|
||||
m_player->setDirty(true);
|
||||
|
||||
m_fov = fov;
|
||||
}
|
||||
|
||||
void PlayerSAO::setWantedRange(const s16 range)
|
||||
{
|
||||
if (m_player && range != m_wanted_range)
|
||||
m_player->setDirty(true);
|
||||
|
||||
m_wanted_range = range;
|
||||
}
|
||||
|
||||
void PlayerSAO::setYawAndSend(const float yaw)
|
||||
{
|
||||
setYaw(yaw);
|
||||
|
@ -222,6 +222,10 @@ public:
|
||||
f32 getRadPitch() const { return m_pitch * core::DEGTORAD; }
|
||||
// Deprecated
|
||||
f32 getRadPitchDep() const { return -1.0 * m_pitch * core::DEGTORAD; }
|
||||
void setFov(const float pitch);
|
||||
f32 getFov() const { return m_fov; }
|
||||
void setWantedRange(const s16 range);
|
||||
s16 getWantedRange() const { return m_wanted_range; }
|
||||
|
||||
/*
|
||||
Interaction interface
|
||||
@ -377,6 +381,8 @@ private:
|
||||
bool m_attachment_sent;
|
||||
u16 m_breath;
|
||||
f32 m_pitch;
|
||||
f32 m_fov;
|
||||
s16 m_wanted_range;
|
||||
public:
|
||||
float m_physics_override_speed;
|
||||
float m_physics_override_jump;
|
||||
|
@ -61,6 +61,8 @@ LocalPlayer::LocalPlayer(Client *gamedef, const char *name):
|
||||
last_pitch(0),
|
||||
last_yaw(0),
|
||||
last_keyPressed(0),
|
||||
last_camera_fov(0),
|
||||
last_wanted_range(0),
|
||||
camera_impact(0.f),
|
||||
last_animation(NO_ANIM),
|
||||
/*
|
||||
|
@ -81,6 +81,8 @@ public:
|
||||
float last_pitch;
|
||||
float last_yaw;
|
||||
unsigned int last_keyPressed;
|
||||
u8 last_camera_fov;
|
||||
u8 last_wanted_range;
|
||||
|
||||
float camera_impact;
|
||||
|
||||
|
@ -1482,13 +1482,14 @@ void Server::handleCommand_Drawcontrol(NetworkPacket* pkt) {
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
/*
|
||||
|
||||
auto playersao = player->getPlayerSAO();
|
||||
/*
|
||||
if (!playersao) {
|
||||
m_con.DisconnectPeer(pkt->getPeerId());
|
||||
return;
|
||||
}
|
||||
*/
|
||||
}*/
|
||||
|
||||
auto client = getClient(peer_id);
|
||||
auto lock = client->lock_unique_rec();
|
||||
client->wanted_range = packet[TOSERVER_DRAWCONTROL_WANTED_RANGE].as<u32>();
|
||||
@ -1496,4 +1497,10 @@ void Server::handleCommand_Drawcontrol(NetworkPacket* pkt) {
|
||||
client->farmesh = packet[TOSERVER_DRAWCONTROL_FARMESH].as<u8>();
|
||||
client->fov = packet[TOSERVER_DRAWCONTROL_FOV].as<f32>();
|
||||
//client->block_overflow = packet[TOSERVER_DRAWCONTROL_BLOCK_OVERFLOW].as<bool>();
|
||||
|
||||
// minetest compat, fmtodo: make one place
|
||||
if (playersao) {
|
||||
playersao->setFov(client->fov);
|
||||
playersao->setWantedRange(client->wanted_range);
|
||||
}
|
||||
}
|
||||
|
@ -948,6 +948,8 @@ enum {
|
||||
[2+12+12] s32 pitch*100
|
||||
[2+12+12+4] s32 yaw*100
|
||||
[2+12+12+4+4] u32 keyPressed
|
||||
[2+12+12+4+4+1] u8 fov*80
|
||||
[2+12+12+4+4+4+1] u8 wanted_range / MAP_BLOCKSIZE
|
||||
*/
|
||||
|
||||
#define TOSERVER_GOTBLOCKS 0x24 // mt compat only
|
||||
|
@ -793,6 +793,7 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
|
||||
|
||||
v3s32 ps, ss;
|
||||
s32 f32pitch, f32yaw;
|
||||
u8 f32fov;
|
||||
|
||||
*pkt >> ps;
|
||||
*pkt >> ss;
|
||||
@ -803,8 +804,18 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
|
||||
f32 yaw = (f32)f32yaw / 100.0;
|
||||
u32 keyPressed = 0;
|
||||
|
||||
// default behavior (in case an old client doesn't send these)
|
||||
f32 fov = (72.0*M_PI/180) * 4./3.;
|
||||
u8 wanted_range = 0;
|
||||
|
||||
if (pkt->getRemainingBytes() >= 4)
|
||||
*pkt >> keyPressed;
|
||||
if (pkt->getRemainingBytes() >= 1) {
|
||||
*pkt >> f32fov;
|
||||
fov = (f32)f32fov / 80.0;
|
||||
}
|
||||
if (pkt->getRemainingBytes() >= 1)
|
||||
*pkt >> wanted_range;
|
||||
|
||||
v3f position((f32)ps.X / 100.0, (f32)ps.Y / 100.0, (f32)ps.Z / 100.0);
|
||||
v3f speed((f32)ss.X / 100.0, (f32)ss.Y / 100.0, (f32)ss.Z / 100.0);
|
||||
@ -816,6 +827,8 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
|
||||
player->setSpeed(speed);
|
||||
playersao->setPitch(pitch);
|
||||
playersao->setYaw(yaw);
|
||||
playersao->setFov(fov);
|
||||
playersao->setWantedRange(wanted_range);
|
||||
player->keyPressed = keyPressed;
|
||||
|
||||
{
|
||||
|
@ -795,8 +795,6 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
|
||||
static const s16 radius =
|
||||
g_settings->getS16("active_object_send_range_blocks") * MAP_BLOCKSIZE;
|
||||
|
||||
static const s16 radius_deactivate = radius * 2;
|
||||
|
||||
// Radius inside which players are active
|
||||
static const bool is_transfer_limited =
|
||||
g_settings->exists("unlimited_player_transfer_distance") &&
|
||||
@ -826,11 +824,16 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
|
||||
if (playersao == NULL)
|
||||
continue;
|
||||
|
||||
s16 my_radius = MYMIN(radius, playersao->getWantedRange() * MAP_BLOCKSIZE);
|
||||
if (my_radius <= 0) my_radius = radius;
|
||||
my_radius *= 1.5;
|
||||
//infostream << "Server: Active Radius " << my_radius << std::endl;
|
||||
|
||||
std::queue<u16> removed_objects;
|
||||
std::queue<u16> added_objects;
|
||||
m_env->getRemovedActiveObjects(playersao, radius_deactivate, player_radius,
|
||||
m_env->getRemovedActiveObjects(playersao, my_radius, player_radius,
|
||||
client->m_known_objects, removed_objects);
|
||||
m_env->getAddedActiveObjects(playersao, radius, player_radius,
|
||||
m_env->getAddedActiveObjects(playersao, my_radius, player_radius,
|
||||
client->m_known_objects, added_objects);
|
||||
|
||||
// Ignore if nothing happened
|
||||
|
Loading…
x
Reference in New Issue
Block a user