Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ignore near_plane setting on non-Android platforms (#8749)
Camera's near-plane will be hard-coded to 0.1 on all non-Android platforms. The upper-bound of this setting has been reduced to 0.25, as 0.5 is just way too high.
  • Loading branch information
ClobberXD committed Mar 28, 2020
1 parent c6d6358 commit 13b2285
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 37 deletions.
6 changes: 3 additions & 3 deletions builtin/settingtypes.txt
Expand Up @@ -623,11 +623,11 @@ pause_on_lost_focus (Pause on lost window focus) bool false
# View distance in nodes.
viewing_range (Viewing range) int 100 20 4000

# Camera 'near clipping plane' distance in nodes, between 0 and 0.5.
# Most users will not need to change this.
# Camera 'near clipping plane' distance in nodes, between 0 and 0.25
# Only works on GLES platforms. Most users will not need to change this.
# Increasing can reduce artifacting on weaker GPUs.
# 0.1 = Default, 0.25 = Good value for weaker tablets.
near_plane (Near clipping plane) float 0.1 0 0.5
near_plane (Near plane) float 0.1 0 0.25

# Width component of the initial window size.
screen_w (Screen width) int 1024 1
Expand Down
61 changes: 30 additions & 31 deletions minetest.conf.example
Expand Up @@ -713,11 +713,11 @@
# type: int min: 20 max: 4000
# viewing_range = 100

# Camera 'near clipping plane' distance in nodes, between 0 and 0.5.
# Most users will not need to change this.
# Camera 'near clipping plane' distance in nodes, between 0 and 0.25
# Only works on GLES platforms. Most users will not need to change this.
# Increasing can reduce artifacting on weaker GPUs.
# 0.1 = Default, 0.25 = Good value for weaker tablets.
# type: float min: 0 max: 0.5
# type: float min: 0 max: 0.25
# near_plane = 0.1

# Width component of the initial window size.
Expand Down Expand Up @@ -1371,7 +1371,7 @@
# ask_reconnect_on_crash = false

# From how far clients know about objects, stated in mapblocks (16 nodes).
#
#
# Setting this larger than active_block_range will also cause the server
# to maintain active objects up to this distance in the direction the
# player is looking. (This can avoid mobs suddenly disappearing from view)
Expand Down Expand Up @@ -1920,7 +1920,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# Second of two 3D noises that together define tunnels.
Expand All @@ -1933,7 +1933,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# 3D noise defining giant caverns.
Expand All @@ -1946,7 +1946,7 @@
# octaves = 5,
# persistence = 0.63,
# lacunarity = 2.0,
# flags =
# flags =
# }

# 3D noise defining terrain.
Expand All @@ -1972,7 +1972,7 @@
# octaves = 2,
# persistence = 0.8,
# lacunarity = 2.0,
# flags =
# flags =
# }

## Mapgen V6
Expand Down Expand Up @@ -2312,7 +2312,7 @@
# octaves = 5,
# persistence = 0.63,
# lacunarity = 2.0,
# flags =
# flags =
# }

# 3D noise defining structure of river canyon walls.
Expand All @@ -2325,7 +2325,7 @@
# octaves = 4,
# persistence = 0.75,
# lacunarity = 2.0,
# flags =
# flags =
# }

# 3D noise defining giant caverns.
Expand All @@ -2338,7 +2338,7 @@
# octaves = 5,
# persistence = 0.63,
# lacunarity = 2.0,
# flags =
# flags =
# }

# First of two 3D noises that together define tunnels.
Expand All @@ -2351,7 +2351,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# Second of two 3D noises that together define tunnels.
Expand All @@ -2364,7 +2364,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# 3D noise that determines number of dungeons per mapchunk.
Expand All @@ -2377,7 +2377,7 @@
# octaves = 2,
# persistence = 0.8,
# lacunarity = 2.0,
# flags =
# flags =
# }

## Mapgen Carpathian
Expand Down Expand Up @@ -2620,7 +2620,7 @@
# octaves = 5,
# persistence = 0.55,
# lacunarity = 2.0,
# flags =
# flags =
# }

# First of two 3D noises that together define tunnels.
Expand All @@ -2633,7 +2633,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# Second of two 3D noises that together define tunnels.
Expand All @@ -2646,7 +2646,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# 3D noise defining giant caverns.
Expand All @@ -2659,7 +2659,7 @@
# octaves = 5,
# persistence = 0.63,
# lacunarity = 2.0,
# flags =
# flags =
# }

# 3D noise that determines number of dungeons per mapchunk.
Expand All @@ -2672,7 +2672,7 @@
# octaves = 2,
# persistence = 0.8,
# lacunarity = 2.0,
# flags =
# flags =
# }

## Mapgen Flat
Expand Down Expand Up @@ -2782,7 +2782,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# Second of two 3D noises that together define tunnels.
Expand All @@ -2795,7 +2795,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# 3D noise that determines number of dungeons per mapchunk.
Expand All @@ -2808,7 +2808,7 @@
# octaves = 2,
# persistence = 0.8,
# lacunarity = 2.0,
# flags =
# flags =
# }

## Mapgen Fractal
Expand Down Expand Up @@ -2982,7 +2982,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# Second of two 3D noises that together define tunnels.
Expand All @@ -2995,7 +2995,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# 3D noise that determines number of dungeons per mapchunk.
Expand All @@ -3008,7 +3008,7 @@
# octaves = 2,
# persistence = 0.8,
# lacunarity = 2.0,
# flags =
# flags =
# }

## Mapgen Valleys
Expand Down Expand Up @@ -3098,7 +3098,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# Second of two 3D noises that together define tunnels.
Expand All @@ -3111,7 +3111,7 @@
# octaves = 3,
# persistence = 0.5,
# lacunarity = 2.0,
# flags =
# flags =
# }

# The depth of dirt or other biome filler node.
Expand All @@ -3137,7 +3137,7 @@
# octaves = 6,
# persistence = 0.63,
# lacunarity = 2.0,
# flags =
# flags =
# }

# Defines large-scale river channel structure.
Expand Down Expand Up @@ -3189,7 +3189,7 @@
# octaves = 6,
# persistence = 0.8,
# lacunarity = 2.0,
# flags =
# flags =
# }

# Amplifies the valleys.
Expand Down Expand Up @@ -3228,7 +3228,7 @@
# octaves = 2,
# persistence = 0.8,
# lacunarity = 2.0,
# flags =
# flags =
# }

## Advanced
Expand Down Expand Up @@ -3292,4 +3292,3 @@
# so see a full list at https://content.minetest.net/help/content_flags/
# type: string
# contentdb_flag_blacklist = nonfree, desktop_default

13 changes: 10 additions & 3 deletions src/client/camera.cpp
Expand Up @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "camera.h"
#include "debug.h"
#include "client.h"
#include "config.h"
#include "map.h"
#include "clientmap.h" // MapDrawControl
#include "player.h"
Expand Down Expand Up @@ -569,10 +570,16 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r
void Camera::updateViewingRange()
{
f32 viewing_range = g_settings->getFloat("viewing_range");
f32 near_plane = g_settings->getFloat("near_plane");

// Ignore near_plane setting on all other platforms to prevent abuse
#if ENABLE_GLES
m_cameranode->setNearValue(rangelim(
g_settings->getFloat("near_plane"), 0.0f, 0.25f) * BS);
#else
m_cameranode->setNearValue(0.1f * BS);
#endif

m_draw_control.wanted_range = std::fmin(adjustDist(viewing_range, getFovMax()), 4000);
m_cameranode->setNearValue(rangelim(near_plane, 0.0f, 0.5f) * BS);
if (m_draw_control.range_all) {
m_cameranode->setFarValue(100000.0);
return;
Expand Down Expand Up @@ -600,7 +607,7 @@ void Camera::wield(const ItemStack &item)

void Camera::drawWieldedTool(irr::core::matrix4* translation)
{
// Clear Z buffer so that the wielded tool stay in front of world geometry
// Clear Z buffer so that the wielded tool stays in front of world geometry
m_wieldmgr->getVideoDriver()->clearZBuffer();

// Draw the wielded node (in a separate scene manager)
Expand Down
2 changes: 2 additions & 0 deletions src/defaultsettings.cpp
Expand Up @@ -165,7 +165,9 @@ void set_default_settings(Settings *settings)
settings->setDefault("fps_max", "60");
settings->setDefault("pause_fps_max", "20");
settings->setDefault("viewing_range", "100");
#if ENABLE_GLES
settings->setDefault("near_plane", "0.1");
#endif
settings->setDefault("screen_w", "1024");
settings->setDefault("screen_h", "600");
settings->setDefault("autosave_screensize", "true");
Expand Down

0 comments on commit 13b2285

Please sign in to comment.