Planet: Send blocks across wraparound map edges and fix collission de…

…tection at edges
master
Evert 2018-03-20 19:32:23 +02:00
parent ca7807995f
commit 9fa00af9b4
No known key found for this signature in database
GPG Key ID: 1688DA83D222D0B5
2 changed files with 20 additions and 1 deletions

View File

@ -237,6 +237,17 @@ void RemoteClient::GetNextBlocks (
for (li = list.begin(); li != list.end(); ++li) {
v3s16 p = *li + center;
/*
Planet: Map wraps around, so if block outside of the
map would be theoretically selected, send block on
the opposite side of the map instead
*/
int planet_circumference_blocks = ceil(g_settings->getU16("planet_radius") * M_PI) * 2;
if (p.X >= planet_circumference_blocks / 2) p.X -= planet_circumference_blocks;
if (p.Z >= planet_circumference_blocks / 2) p.Z -= planet_circumference_blocks;
if (p.X < -planet_circumference_blocks / 2) p.X += planet_circumference_blocks;
if (p.Z < -planet_circumference_blocks / 2) p.Z += planet_circumference_blocks;
/*
Send throttling
- Don't allow too many simultaneous transfers
@ -284,7 +295,7 @@ void RemoteClient::GetNextBlocks (
d_blocks_in_sight, &dist) ||
(playerspeed.getLength() > 1.0f * BS &&
isBlockInSight(p, camera_pos, playerspeeddir, 0.1f,
d_blocks_in_sight)))) {
d_blocks_in_sight))) && !g_settings->getBool("planet_enable")) {
continue;
}

View File

@ -276,6 +276,14 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
for (p.X = min.X; p.X <= max.X; p.X++)
for (p.Y = min.Y; p.Y <= max.Y; p.Y++)
for (p.Z = min.Z; p.Z <= max.Z; p.Z++) {
if (g_settings->getBool("planet_enable")) {
int planet_circumference = ceil(g_settings->getU16("planet_radius") * M_PI) * 2 * MAP_BLOCKSIZE;
if (p.X >= planet_circumference / 2) p.X -= planet_circumference;
if (p.Z >= planet_circumference / 2) p.Z -= planet_circumference;
if (p.X < -planet_circumference / 2) p.X += planet_circumference;
if (p.Z < -planet_circumference / 2) p.Z += planet_circumference;
}
bool is_position_valid;
MapNode n = map->getNodeNoEx(p, &is_position_valid);