summaryrefslogtreecommitdiff
path: root/src/particles.cpp
diff options
context:
space:
mode:
authorParamat <paramat@users.noreply.github.com>2018-09-08 00:38:35 +0100
committerGitHub <noreply@github.com>2018-09-08 00:38:35 +0100
commit766fb7b46edab47f96b8b940e390daf5319261b7 (patch)
tree59a3bb890cbf8922bd82e4e2fffdda42717c71ea /src/particles.cpp
parent6ed9c6fb3a80bf18b3f9f74e39704558371e8b41 (diff)
downloadminetest-766fb7b46edab47f96b8b940e390daf5319261b7.tar.gz
minetest-766fb7b46edab47f96b8b940e390daf5319261b7.tar.bz2
minetest-766fb7b46edab47f96b8b940e390daf5319261b7.zip
Particles: Make collision with objects optional (#7682)
Also set it to false for node dig particles, as they are often created and high in number. Improve particle documentation.
Diffstat (limited to 'src/particles.cpp')
-rw-r--r--src/particles.cpp40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/particles.cpp b/src/particles.cpp
index e98068f53..923c3ad01 100644
--- a/src/particles.cpp
+++ b/src/particles.cpp
@@ -54,6 +54,7 @@ Particle::Particle(
float size,
bool collisiondetection,
bool collision_removal,
+ bool object_collision,
bool vertical,
video::ITexture *texture,
v2f texpos,
@@ -93,6 +94,7 @@ Particle::Particle(
m_size = size;
m_collisiondetection = collisiondetection;
m_collision_removal = collision_removal;
+ m_object_collision = object_collision;
m_vertical = vertical;
m_glow = glow;
@@ -135,9 +137,9 @@ void Particle::step(float dtime)
aabb3f box = m_collisionbox;
v3f p_pos = m_pos * BS;
v3f p_velocity = m_velocity * BS;
- collisionMoveResult r = collisionMoveSimple(m_env,
- m_gamedef, BS * 0.5, box, 0, dtime, &p_pos,
- &p_velocity, m_acceleration * BS);
+ collisionMoveResult r = collisionMoveSimple(m_env, m_gamedef, BS * 0.5f,
+ box, 0.0f, dtime, &p_pos, &p_velocity, m_acceleration * BS, nullptr,
+ m_object_collision);
if (m_collision_removal && r.collides) {
// force expiration of the particle
m_expiration = -1.0;
@@ -243,14 +245,27 @@ void Particle::updateVertices()
ParticleSpawner
*/
-ParticleSpawner::ParticleSpawner(IGameDef *gamedef, LocalPlayer *player,
- u16 amount, float time,
- v3f minpos, v3f maxpos, v3f minvel, v3f maxvel, v3f minacc, v3f maxacc,
- float minexptime, float maxexptime, float minsize, float maxsize,
- bool collisiondetection, bool collision_removal, u16 attached_id, bool vertical,
- video::ITexture *texture, u32 id, const struct TileAnimationParams &anim,
+ParticleSpawner::ParticleSpawner(
+ IGameDef *gamedef,
+ LocalPlayer *player,
+ u16 amount,
+ float time,
+ v3f minpos, v3f maxpos,
+ v3f minvel, v3f maxvel,
+ v3f minacc, v3f maxacc,
+ float minexptime, float maxexptime,
+ float minsize, float maxsize,
+ bool collisiondetection,
+ bool collision_removal,
+ bool object_collision,
+ u16 attached_id,
+ bool vertical,
+ video::ITexture *texture,
+ u32 id,
+ const struct TileAnimationParams &anim,
u8 glow,
- ParticleManager *p_manager) :
+ ParticleManager *p_manager
+):
m_particlemanager(p_manager)
{
m_gamedef = gamedef;
@@ -269,6 +284,7 @@ ParticleSpawner::ParticleSpawner(IGameDef *gamedef, LocalPlayer *player,
m_maxsize = maxsize;
m_collisiondetection = collisiondetection;
m_collision_removal = collision_removal;
+ m_object_collision = object_collision;
m_attached_id = attached_id;
m_vertical = vertical;
m_texture = texture;
@@ -326,6 +342,7 @@ void ParticleSpawner::spawnParticle(ClientEnvironment *env, float radius,
size,
m_collisiondetection,
m_collision_removal,
+ m_object_collision,
m_vertical,
m_texture,
v2f(0.0, 0.0),
@@ -507,6 +524,7 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, Client *client,
event->add_particlespawner.maxsize,
event->add_particlespawner.collisiondetection,
event->add_particlespawner.collision_removal,
+ event->add_particlespawner.object_collision,
event->add_particlespawner.attached_id,
event->add_particlespawner.vertical,
texture,
@@ -545,6 +563,7 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, Client *client,
event->spawn_particle.size,
event->spawn_particle.collisiondetection,
event->spawn_particle.collision_removal,
+ event->spawn_particle.object_collision,
event->spawn_particle.vertical,
texture,
v2f(0.0, 0.0),
@@ -637,6 +656,7 @@ void ParticleManager::addNodeParticle(IGameDef* gamedef,
true,
false,
false,
+ false,
texture,
texpos,
texsize,