minetest / minetest

Minetest is an open source voxel game-creation platform with easy modding and game creation
https://www.minetest.net/
Other
10.59k stars 1.99k forks source link

Add a light test for particle spawning #12650

Open jeremyshannon opened 2 years ago

jeremyshannon commented 2 years ago

Problem

Exile's particle system is using the old add_particle system. I was going to update it to use spawners, but this will cause a regression in our weather. Currently every particle of rain/snow/dust storm that is going to be generated passes the node at its position through minetest.get_natural_light(pos, 0.5) as a crude "is it indoors" check, and only spawns if the light level at noon is high enough. In this way, snow storms don't generate whirling clouds of blowing snow inside your house.

While rain could be spawned above usual roof levels and allowed to stop when hitting something, there seems to be no good way to prevent our whirling blizzard and dust storm particles (which appear at all heights and can go straight sideways) from spawning indoors with the new particle spawner system.

Solutions

An optional "min_daylight = x" field in the particle spawner def would be sufficient for Exile's use case, though I can definitely see potential uses for other similar tests to e.g. cause a node to spawn particles in shadows but not in the sunlight, or only when artificial light is shone on something.

Additional context

OutdoorsVsIndoors As you can see here, snow particles appear and blow a short distance in most any direction, but they only start from nodes outside the house.

Edit: not deprecated, that was just me misreading lua_api

sfan5 commented 2 years ago

Since when is add_particle deprecated?

jeremyshannon commented 2 years ago

Huh. I thought it was listed as deprecated in lua_api, but no, I looked again, and add_particle with the various parameters instead of a definition is what's deprecated, one line below. My bad! I've been staring at code half the day, and all the lines are starting to blur together, and what's more I just found out I have to rework my rework of Exile's weather system to keep add_particle around after all, even though using the spawners would make things more elegant.