Merge pull request 'Fix weather FPS (and warning)' (#2341) from fix_weather_fps into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2341
Reviewed-by: MysticTempest <mystictempest@noreply.git.minetest.land>
This commit is contained in:
cora 2022-06-20 11:38:15 +00:00
commit 64b8f15f47
4 changed files with 31 additions and 18 deletions

@ -1,8 +1,10 @@
mcl_weather.nether_dust = {} mcl_weather.nether_dust = {}
mcl_weather.nether_dust.particlespawners = {} mcl_weather.nether_dust.particlespawners = {}
local PARTICLES_COUNT_NETHER_DUST = tonumber(minetest.settings:get("mcl_weather_rain_particles")) or 150
local psdef= { local psdef= {
amount = 150, amount = PARTICLES_COUNT_NETHER_DUST,
time = 0, time = 0,
minpos = vector.new(-15,-15,-15), minpos = vector.new(-15,-15,-15),
maxpos =vector.new(15,15,15), maxpos =vector.new(15,15,15),

@ -1,5 +1,5 @@
local PARTICLES_COUNT_RAIN = 800 local PARTICLES_COUNT_RAIN = tonumber(minetest.settings:get("mcl_weather_rain_particles")) or 500
local PARTICLES_COUNT_THUNDER = 1200 local PARTICLES_COUNT_THUNDER = tonumber(minetest.settings:get("mcl_weather_thunder_particles")) or 900
local get_connected_players = minetest.get_connected_players local get_connected_players = minetest.get_connected_players
@ -20,22 +20,20 @@ mcl_weather.rain = {
init_done = false, init_done = false,
} }
local update_sound={} local update_sound={}
local vel=math.random(0,3)
local falling_speed=math.random(10,15)
local size = math.random(1,3)
local psdef= { local psdef= {
amount = mcl_weather.rain.particles_count, amount = mcl_weather.rain.particles_count,
time=0, time=0,
minpos = vector.new(-15,20,-15), minpos = vector.new(-15,20,-15),
maxpos = vector.new(15,25,15), maxpos = vector.new(15,25,15),
minvel = vector.new(-2,-falling_speed-2,-2), minvel = vector.new(-2,-17,-2),
maxvel = vector.new(2,-falling_speed+2,2), maxvel = vector.new(2,-8,2),
minacc = vector.new(0,0,0), minacc = vector.new(0,0,0),
maxacc = vector.new(0,-0.5,0), maxacc = vector.new(0,-0.5,0),
minexptime = 15, minexptime = 1,
maxexptime = 30, maxexptime = 4,
minsize = size, minsize = 4,
maxsize= size*2, maxsize= 8,
collisiondetection = true, collisiondetection = true,
collision_removal = true, collision_removal = true,
vertical = true, vertical = true,
@ -70,9 +68,10 @@ end
-- no no no NO NO f*.. no. no manual particle creatin' PLS!! this sends EVERY particle over the net. -- no no no NO NO f*.. no. no manual particle creatin' PLS!! this sends EVERY particle over the net.
function mcl_weather.rain.add_rain_particles(player) function mcl_weather.rain.add_rain_particles(player)
mcl_weather.rain.last_rp_count = mcl_weather.rain.particles_count mcl_weather.rain.last_rp_count = mcl_weather.rain.particles_count
local l = false
for k,v in pairs(textures) do for k,v in pairs(textures) do
psdef.texture=v psdef.texture=v
mcl_weather.add_spawner_player(player,"rain"..k,psdef) l = l or mcl_weather.add_spawner_player(player,"rain"..k,psdef)
end end
if l then if l then
update_sound[player:get_player_name()]=true update_sound[player:get_player_name()]=true

@ -2,11 +2,11 @@ local get_connected_players = minetest.get_connected_players
mcl_weather.snow = {} mcl_weather.snow = {}
mcl_weather.snow.particles_count = 15 local PARTICLES_COUNT_SNOW = tonumber(minetest.settings:get("mcl_weather_snow_particles")) or 99
mcl_weather.snow.init_done = false mcl_weather.snow.init_done = false
local psdef= { local psdef= {
amount = 99, amount = PARTICLES_COUNT_SNOW,
time = 0, --stay on til we turn it off time = 0, --stay on til we turn it off
minpos = vector.new(-25,20,-25), minpos = vector.new(-25,20,-25),
maxpos =vector.new(25,25,25), maxpos =vector.new(25,25,25),
@ -14,9 +14,9 @@ local psdef= {
maxvel = vector.new(0.2,-4,0.2), maxvel = vector.new(0.2,-4,0.2),
minacc = vector.new(0,-1,0), minacc = vector.new(0,-1,0),
maxacc = vector.new(0,-4,0), maxacc = vector.new(0,-4,0),
minexptime = 15, minexptime = 3,
maxexptime = 30, maxexptime = 5,
minsize = 0.5, minsize = 2,
maxsize = 5, maxsize = 5,
collisiondetection = true, collisiondetection = true,
collision_removal = true, collision_removal = true,

@ -20,6 +20,18 @@ enable_fire (Destructive and spreading fire) bool true
# If enabled, the weather will change naturally over time. # If enabled, the weather will change naturally over time.
mcl_doWeatherCycle (Change weather) bool true mcl_doWeatherCycle (Change weather) bool true
# Amount of rain particles. You can reduce this to get better FPS (default: 500)
mcl_weather_rain_particles (Rain particles) int 500 0
# Amount of thunderstorm rain particles. You can reduce this to get better FPS (default: 900)
mcl_weather_thunder_particles (Thunderstorm rain particles) int 900 0
# Amount of snow particles. You can reduce this to get better FPS (default: 100)
mcl_weather_snow_particles (Snow particles) int 100 0
# Amount of nether dust particles. You can reduce this to get better FPS (default: 150)
mcl_weather_snow_particles (Nether dust particles) int 150 0
# If enabled, breaking blocks will cause them to drop as item. # If enabled, breaking blocks will cause them to drop as item.
# Note that blocks never have drops when in Creative Mode. # Note that blocks never have drops when in Creative Mode.
mcl_doTileDrops (Blocks have drops) bool true mcl_doTileDrops (Blocks have drops) bool true