#include "particles.h"
#include "constants.h"
#include "debug.h"
-#include "main.h" // For g_profiler and g_settings
#include "settings.h"
-#include "tile.h"
+#include "client/tile.h"
#include "gamedef.h"
#include "collision.h"
#include <stdlib.h>
m_vertical = vertical;
// Irrlicht stuff
- m_collisionbox = core::aabbox3d<f32>
+ m_collisionbox = aabb3f
(-size/2,-size/2,-size/2,size/2,size/2,size/2);
this->setAutomaticCulling(scene::EAC_OFF);
void Particle::OnRegisterSceneNode()
{
if (IsVisible)
- {
- SceneManager->registerNodeForRendering
- (this, scene::ESNRP_TRANSPARENT);
- SceneManager->registerNodeForRendering
- (this, scene::ESNRP_SOLID);
- }
+ SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT_EFFECT);
ISceneNode::OnRegisterSceneNode();
}
void Particle::render()
{
- // TODO: Render particles in front of water and the selectionbox
-
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(m_material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
m_time += dtime;
if (m_collisiondetection)
{
- core::aabbox3d<f32> box = m_collisionbox;
+ aabb3f box = m_collisionbox;
v3f p_pos = m_pos*BS;
v3f p_velocity = m_velocity*BS;
- v3f p_acceleration = m_acceleration*BS;
collisionMoveSimple(m_env, m_gamedef,
BS*0.5, box,
0, dtime,
- p_pos, p_velocity, p_acceleration);
+ &p_pos, &p_velocity, m_acceleration * BS);
m_pos = p_pos/BS;
m_velocity = p_velocity/BS;
- m_acceleration = p_acceleration/BS;
}
else
{
}
else
{
- i++;
+ ++i;
}
}
}
*(m_maxsize-m_minsize)
+m_minsize;
- new Particle(
+ Particle* toadd = new Particle(
m_gamedef,
m_smgr,
m_player,
m_texture,
v2f(0.0, 0.0),
v2f(1.0, 1.0));
+ m_particlemanager->addParticle(toadd);
}
}
}
void ParticleManager::stepSpawners (float dtime)
{
- JMutexAutoLock lock(m_spawner_list_lock);
+ MutexAutoLock lock(m_spawner_list_lock);
for(std::map<u32, ParticleSpawner*>::iterator i =
m_particle_spawners.begin();
i != m_particle_spawners.end();)
else
{
i->second->step(dtime, m_env);
- i++;
+ ++i;
}
}
}
void ParticleManager::stepParticles (float dtime)
{
- JMutexAutoLock lock(m_particle_list_lock);
+ MutexAutoLock lock(m_particle_list_lock);
for(std::vector<Particle*>::iterator i = m_particles.begin();
i != m_particles.end();)
{
else
{
(*i)->step(dtime);
- i++;
+ ++i;
}
}
}
void ParticleManager::clearAll ()
{
- JMutexAutoLock lock(m_spawner_list_lock);
- JMutexAutoLock lock2(m_particle_list_lock);
+ MutexAutoLock lock(m_spawner_list_lock);
+ MutexAutoLock lock2(m_particle_list_lock);
for(std::map<u32, ParticleSpawner*>::iterator i =
m_particle_spawners.begin();
i != m_particle_spawners.end();)
scene::ISceneManager* smgr, LocalPlayer *player)
{
if (event->type == CE_DELETE_PARTICLESPAWNER) {
- JMutexAutoLock lock(m_spawner_list_lock);
+ MutexAutoLock lock(m_spawner_list_lock);
if (m_particle_spawners.find(event->delete_particlespawner.id) !=
m_particle_spawners.end())
{
if (event->type == CE_ADD_PARTICLESPAWNER) {
{
- JMutexAutoLock lock(m_spawner_list_lock);
+ MutexAutoLock lock(m_spawner_list_lock);
if (m_particle_spawners.find(event->add_particlespawner.id) !=
m_particle_spawners.end())
{
}
}
video::ITexture *texture =
- gamedef->tsrc()->getTexture(*(event->add_particlespawner.texture));
+ gamedef->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture));
ParticleSpawner* toadd = new ParticleSpawner(gamedef, smgr, player,
event->add_particlespawner.amount,
delete event->add_particlespawner.maxacc;
{
- JMutexAutoLock lock(m_spawner_list_lock);
+ MutexAutoLock lock(m_spawner_list_lock);
m_particle_spawners.insert(
std::pair<u32, ParticleSpawner*>(
event->add_particlespawner.id,
if (event->type == CE_SPAWN_PARTICLE) {
video::ITexture *texture =
- gamedef->tsrc()->getTexture(*(event->spawn_particle.texture));
+ gamedef->tsrc()->getTextureForMesh(*(event->spawn_particle.texture));
Particle* toadd = new Particle(gamedef, smgr, player, m_env,
*event->spawn_particle.pos,
void ParticleManager::addParticle(Particle* toadd)
{
- JMutexAutoLock lock(m_particle_list_lock);
+ MutexAutoLock lock(m_particle_list_lock);
m_particles.push_back(toadd);
}