mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Particles: Add option to remove particles on collision
Adds the particle option `collision_removal = bool` Some particles are hard to use right now since they either go through solid blocks (without collision detection), and with collision detection enabled they (e.g. raindrops) would just stop dead on the floor and sit there until they expire, or worse, scrape along a wall or ceiling. We can solve the problem by adding a boolean flag that tells the particle to be removed if it ever collides with something. This will make it easier to add rain that doesn't fall through your roof or stick on the top of it. Or clouds and smoke that don't go through trees. Particles that collide with this flag are marked expired unconditionally, causing them to be treated like normal expired particles and cleaned up normally. Documentation is adjusted accordingly. An added bonus of this patch is that particles can potentially collide many times with nodes, and this reduces the amount of collisions to 1 (max), which may end up reducing particle load on the client.
This commit is contained in:
parent
62d15ac7c1
commit
d499ec4838
9 changed files with 84 additions and 32 deletions
|
@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
struct ClientEvent;
|
||||
class ParticleManager;
|
||||
class ClientEnvironment;
|
||||
|
||||
class Particle : public scene::ISceneNode
|
||||
{
|
||||
|
@ -45,6 +46,7 @@ class Particle : public scene::ISceneNode
|
|||
float expirationtime,
|
||||
float size,
|
||||
bool collisiondetection,
|
||||
bool collision_removal,
|
||||
bool vertical,
|
||||
video::ITexture *texture,
|
||||
v2f texpos,
|
||||
|
@ -97,6 +99,7 @@ private:
|
|||
float m_size;
|
||||
u8 m_light;
|
||||
bool m_collisiondetection;
|
||||
bool m_collision_removal;
|
||||
bool m_vertical;
|
||||
v3s16 m_camera_offset;
|
||||
};
|
||||
|
@ -115,6 +118,7 @@ class ParticleSpawner
|
|||
float minexptime, float maxexptime,
|
||||
float minsize, float maxsize,
|
||||
bool collisiondetection,
|
||||
bool collision_removal,
|
||||
bool vertical,
|
||||
video::ITexture *texture,
|
||||
u32 id,
|
||||
|
@ -148,6 +152,7 @@ class ParticleSpawner
|
|||
video::ITexture *m_texture;
|
||||
std::vector<float> m_spawntimes;
|
||||
bool m_collisiondetection;
|
||||
bool m_collision_removal;
|
||||
bool m_vertical;
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue