particles.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 3.0 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #include "particles.h"
  17. #include "client.h"
  18. #include "collision.h"
  19. #include <stdlib.h>
  20. #include "util/numeric.h"
  21. #include "light.h"
  22. #include "environment.h"
  23. #include "clientmap.h"
  24. #include "mapnode.h"
  25. #include "client.h"
  26. #include "settings.h"
  27. /*
  28. Utility
  29. */
  30. v3f random_v3f(v3f min, v3f max)
  31. {
  32. return v3f( rand()/(float)RAND_MAX*(max.X-min.X)+min.X,
  33. rand()/(float)RAND_MAX*(max.Y-min.Y)+min.Y,
  34. rand()/(float)RAND_MAX*(max.Z-min.Z)+min.Z);
  35. }
  36. Particle::Particle(
  37. IGameDef *gamedef,
  38. scene::ISceneManager* smgr,
  39. LocalPlayer *player,
  40. ClientEnvironment *env,
  41. v3f pos,
  42. v3f velocity,
  43. v3f acceleration,
  44. float expirationtime,
  45. float size,
  46. bool collisiondetection,
  47. bool collision_removal,
  48. bool vertical,
  49. video::ITexture *texture,
  50. v2f texpos,
  51. v2f texsize,
  52. const struct TileAnimationParams &anim,
  53. u8 glow,
  54. video::SColor color
  55. ):
  56. scene::ISceneNode(smgr->getRootSceneNode(), smgr)
  57. {
  58. // Misc
  59. m_gamedef = gamedef;
  60. m_env = env;
  61. // Texture
  62. m_material.setFlag(video::EMF_LIGHTING, false);
  63. m_material.setFlag(video::EMF_BACK_FACE_CULLING, false);
  64. m_material.setFlag(video::EMF_BILINEAR_FILTER, false);
  65. m_material.setFlag(video::EMF_FOG_ENABLE, true);
  66. m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
  67. m_material.setTexture(0, texture);
  68. m_texpos = texpos;
  69. m_texsize = texsize;
  70. m_animation = anim;
  71. m_animation_frame = 0;
  72. m_animation_time = 0.0;
  73. // Color
  74. m_base_color = color;
  75. m_color = color;
  76. // Particle related
  77. m_pos = pos;
  78. m_velocity = velocity;
  79. m_acceleration = acceleration;
  80. m_expiration = expirationtime;
  81. m_time = 0;
  82. m_player = player;
  83. m_size = size;
  84. m_collisiondetection = collisiondetection;
  85. m_collision_removal = collision_removal;
  86. m_vertical = vertical;
  87. m_glow = glow;
  88. // Irrlicht stuff
  89. m_collisionbox = aabb3f
  90. (-size/2,-size/2,-size/2,size/2,size/2,size/2);
  91. this->setAutomaticCulling(scene::EAC_OFF);
  92. // Init lighting
  93. updateLight();
  94. // Init model
  95. updateVertices();
  96. }
  97. Particle::~Particle()
  98. {
  99. }
  100. void Particle::OnRegisterSceneNode()
  101. {
  102. if (IsVisible)
  103. SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT_EFFECT);
  104. ISceneNode::OnRegisterSceneNode();
  105. }
  106. void Particle::render()
  107. {
  108. video::IVideoDriver* driver = SceneManager->getVideoDriver();
  109. driver->setMaterial(m_material);
  110. driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
  111. u16 indices[] = {0,1,2, 2,3,0};
  112. driver->drawVertexPrimitiveList(m_vertices, 4,
  113. indices, 2, video::EVT_STANDARD,
  114. scene::EPT_TRIANGLES, video::EIT_16BIT);
  115. }
  116. void Particle::step(float dtime)
  117. {
  118. m_time += dtime;
  119. if (m_collisiondetection) {
  120. aabb3f box = m_collisionbox;
  121. v3f p_pos = m_pos * BS;
  122. v3f p_velocity = m_velocity * BS;
  123. collisionMoveResult r = collisionMoveSimple(m_env,
  124. m_gamedef, BS * 0.5, box, 0, dtime, &p_pos,
  125. &p_velocity, m_acceleration * BS);
  126. if (m_collision_removal && r.collides) {
  127. // force expiration of the particle
  128. m_expiration = -1.0;
  129. } else {
  130. m_pos = p_pos / BS;
  131. m_velocity = p_velocity / BS;
  132. }
  133. } else {
  134. m_velocity += m_acceleration * dtime;
  135. m_pos += m_velocity * dtime;
  136. }
  137. if (m_animation.type != TAT_NONE) {
  138. m_animation_time += dtime;
  139. int frame_length_i, frame_count;
  140. m_animation.determineParams(
  141. m_material.getTexture(0)->getSize(),
  142. &frame_count, &frame_length_i, NULL);
  143. float frame_length = frame_length_i / 1000.0;
  144. while (m_animation_time > frame_length) {
  145. m_animation_frame++;
  146. m_animation_time -= frame_length;
  147. }
  148. }
  149. // Update lighting
  150. updateLight();
  151. // Update model
  152. updateVertices();
  153. }
  154. void Particle::updateLight()
  155. {
  156. u8 light = 0;
  157. bool pos_ok;
  158. v3s16 p = v3s16(
  159. floor(m_pos.X+0.5),
  160. floor(m_pos.Y+0.5),
  161. floor(m_pos.Z+0.5)
  162. );
  163. MapNode n = m_env->getClientMap().getNodeNoEx(p, &pos_ok);
  164. if (pos_ok)
  165. light = n.getLightBlend(m_env->getDayNightRatio(), m_gamedef->ndef());
  166. else
  167. light = blend_light(m_env->getDayNightRatio(), LIGHT_SUN, 0);
  168. u8 m_light = decode_light(light + m_glow);
  169. m_color.set(255,
  170. m_light * m_base_color.getRed() / 255,
  171. m_light * m_base_color.getGreen() / 255,
  172. m_light * m_base_color.getBlue() / 255);
  173. }
  174. void Particle::updateVertices()
  175. {
  176. f32 tx0, tx1, ty0, ty1;
  177. if (m_animation.type != TAT_NONE) {
  178. const v2u32 texsize = m_material.getTexture(0)->getSize();
  179. v2f texcoord, framesize_f;
  180. v2u32 framesize;
  181. texcoord = m_animation.getTextureCoords(texsize, m_animation_frame);
  182. m_animation.determineParams(texsize, NULL, NULL, &framesize);
  183. framesize_f = v2f(framesize.X / (float) texsize.X, framesize.Y / (float) texsize.Y);
  184. tx0 = m_texpos.X + texcoord.X;
  185. tx1 = m_texpos.X + texcoord.X + framesize_f.X * m_texsize.X;
  186. ty0 = m_texpos.Y + texcoord.Y;
  187. ty1 = m_texpos.Y + texcoord.Y + framesize_f.Y * m_texsize.Y;
  188. } else {
  189. tx0 = m_texpos.X;
  190. tx1 = m_texpos.X + m_texsize.X;
  191. ty0 = m_texpos.Y;
  192. ty1 = m_texpos.Y + m_texsize.Y;
  193. }
  194. m_vertices[0] = video::S3DVertex(-m_size / 2, -m_size / 2,
  195. 0, 0, 0, 0, m_color, tx0, ty1);
  196. m_vertices[1] = video::S3DVertex(m_size / 2, -m_size / 2,
  197. 0, 0, 0, 0, m_color, tx1, ty1);
  198. m_vertices[2] = video::S3DVertex(m_size / 2, m_size / 2,
  199. 0, 0, 0, 0, m_color, tx1, ty0);
  200. m_vertices[3] = video::S3DVertex(-m_size / 2, m_size / 2,
  201. 0, 0, 0, 0, m_color, tx0, ty0);
  202. v3s16 camera_offset = m_env->getCameraOffset();
  203. for(u16 i=0; i<4; i++)
  204. {
  205. if (m_vertical) {
  206. v3f ppos = m_player->getPosition()/BS;
  207. m_vertices[i].Pos.rotateXZBy(atan2(ppos.Z-m_pos.Z, ppos.X-m_pos.X)/core::DEGTORAD+90);
  208. } else {
  209. m_vertices[i].Pos.rotateYZBy(m_player->getPitch());
  210. m_vertices[i].Pos.rotateXZBy(m_player->getYaw());
  211. }
  212. m_box.addInternalPoint(m_vertices[i].Pos);
  213. m_vertices[i].Pos += m_pos*BS - intToFloat(camera_offset, BS);
  214. }
  215. }
  216. /*
  217. ParticleSpawner
  218. */
  219. ParticleSpawner::ParticleSpawner(IGameDef* gamedef, scene::ISceneManager *smgr, LocalPlayer *player,
  220. u16 amount, float time,
  221. v3f minpos, v3f maxpos, v3f minvel, v3f maxvel, v3f minacc, v3f maxacc,
  222. float minexptime, float maxexptime, float minsize, float maxsize,
  223. bool collisiondetection, bool collision_removal, u16 attached_id, bool vertical,
  224. video::ITexture *texture, u32 id, const struct TileAnimationParams &anim,
  225. u8 glow,
  226. ParticleManager *p_manager) :
  227. m_particlemanager(p_manager)
  228. {
  229. m_gamedef = gamedef;
  230. m_smgr = smgr;
  231. m_player = player;
  232. m_amount = amount;
  233. m_spawntime = time;
  234. m_minpos = minpos;
  235. m_maxpos = maxpos;
  236. m_minvel = minvel;
  237. m_maxvel = maxvel;
  238. m_minacc = minacc;
  239. m_maxacc = maxacc;
  240. m_minexptime = minexptime;
  241. m_maxexptime = maxexptime;
  242. m_minsize = minsize;
  243. m_maxsize = maxsize;
  244. m_collisiondetection = collisiondetection;
  245. m_collision_removal = collision_removal;
  246. m_attached_id = attached_id;
  247. m_vertical = vertical;
  248. m_texture = texture;
  249. m_time = 0;
  250. m_animation = anim;
  251. m_glow = glow;
  252. for (u16 i = 0; i<=m_amount; i++)
  253. {
  254. float spawntime = (float)rand()/(float)RAND_MAX*m_spawntime;
  255. m_spawntimes.push_back(spawntime);
  256. }
  257. }
  258. ParticleSpawner::~ParticleSpawner() {}
  259. void ParticleSpawner::spawnParticle(ClientEnvironment *env, float radius,
  260. bool is_attached, const v3f &attached_pos, float attached_yaw)
  261. {
  262. v3f ppos = m_player->getPosition() / BS;
  263. v3f pos = random_v3f(m_minpos, m_maxpos);
  264. // Need to apply this first or the following check
  265. // will be wrong for attached spawners
  266. if (is_attached) {
  267. pos.rotateXZBy(attached_yaw);
  268. pos += attached_pos;
  269. }
  270. if (pos.getDistanceFrom(ppos) > radius)
  271. return;
  272. v3f vel = random_v3f(m_minvel, m_maxvel);
  273. v3f acc = random_v3f(m_minacc, m_maxacc);
  274. if (is_attached) {
  275. // Apply attachment yaw
  276. vel.rotateXZBy(attached_yaw);
  277. acc.rotateXZBy(attached_yaw);
  278. }
  279. float exptime = rand() / (float)RAND_MAX
  280. * (m_maxexptime - m_minexptime)
  281. + m_minexptime;
  282. float size = rand() / (float)RAND_MAX
  283. * (m_maxsize - m_minsize)
  284. + m_minsize;
  285. m_particlemanager->addParticle(new Particle(
  286. m_gamedef,
  287. m_smgr,
  288. m_player,
  289. env,
  290. pos,
  291. vel,
  292. acc,
  293. exptime,
  294. size,
  295. m_collisiondetection,
  296. m_collision_removal,
  297. m_vertical,
  298. m_texture,
  299. v2f(0.0, 0.0),
  300. v2f(1.0, 1.0),
  301. m_animation,
  302. m_glow
  303. ));
  304. }
  305. void ParticleSpawner::step(float dtime, ClientEnvironment* env)
  306. {
  307. m_time += dtime;
  308. static const float radius =
  309. g_settings->getS16("max_block_send_distance") * MAP_BLOCKSIZE;
  310. bool unloaded = false;
  311. bool is_attached = false;
  312. v3f attached_pos = v3f(0,0,0);
  313. float attached_yaw = 0;
  314. if (m_attached_id != 0) {
  315. if (ClientActiveObject *attached = env->getActiveObject(m_attached_id)) {
  316. attached_pos = attached->getPosition() / BS;
  317. attached_yaw = attached->getYaw();
  318. is_attached = true;
  319. } else {
  320. unloaded = true;
  321. }
  322. }
  323. if (m_spawntime != 0) {
  324. // Spawner exists for a predefined timespan
  325. for (std::vector<float>::iterator i = m_spawntimes.begin();
  326. i != m_spawntimes.end();) {
  327. if ((*i) <= m_time && m_amount > 0) {
  328. m_amount--;
  329. // Pretend to, but don't actually spawn a particle if it is
  330. // attached to an unloaded object or distant from player.
  331. if (!unloaded)
  332. spawnParticle(env, radius, is_attached, attached_pos, attached_yaw);
  333. i = m_spawntimes.erase(i);
  334. } else {
  335. ++i;
  336. }
  337. }
  338. } else {
  339. // Spawner exists for an infinity timespan, spawn on a per-second base
  340. // Skip this step if attached to an unloaded object
  341. if (unloaded)
  342. return;
  343. for (int i = 0; i <= m_amount; i++) {
  344. if (rand() / (float)RAND_MAX < dtime)
  345. spawnParticle(env, radius, is_attached, attached_pos, attached_yaw);
  346. }
  347. }
  348. }
  349. ParticleManager::ParticleManager(ClientEnvironment* env) :
  350. m_env(env)
  351. {}
  352. ParticleManager::~ParticleManager()
  353. {
  354. clearAll();
  355. }
  356. void ParticleManager::step(float dtime)
  357. {
  358. stepParticles (dtime);
  359. stepSpawners (dtime);
  360. }
  361. void ParticleManager::stepSpawners (float dtime)
  362. {
  363. MutexAutoLock lock(m_spawner_list_lock);
  364. for (std::map<u32, ParticleSpawner*>::iterator i =
  365. m_particle_spawners.begin();
  366. i != m_particle_spawners.end();)
  367. {
  368. if (i->second->get_expired())
  369. {
  370. delete i->second;
  371. m_particle_spawners.erase(i++);
  372. }
  373. else
  374. {
  375. i->second->step(dtime, m_env);
  376. ++i;
  377. }
  378. }
  379. }
  380. void ParticleManager::stepParticles (float dtime)
  381. {
  382. MutexAutoLock lock(m_particle_list_lock);
  383. for(std::vector<Particle*>::iterator i = m_particles.begin();
  384. i != m_particles.end();)
  385. {
  386. if ((*i)->get_expired())
  387. {
  388. (*i)->remove();
  389. delete *i;
  390. i = m_particles.erase(i);
  391. }
  392. else
  393. {
  394. (*i)->step(dtime);
  395. ++i;
  396. }
  397. }
  398. }
  399. void ParticleManager::clearAll ()
  400. {
  401. MutexAutoLock lock(m_spawner_list_lock);
  402. MutexAutoLock lock2(m_particle_list_lock);
  403. for(std::map<u32, ParticleSpawner*>::iterator i =
  404. m_particle_spawners.begin();
  405. i != m_particle_spawners.end();)
  406. {
  407. delete i->second;
  408. m_particle_spawners.erase(i++);
  409. }
  410. for(std::vector<Particle*>::iterator i =
  411. m_particles.begin();
  412. i != m_particles.end();)
  413. {
  414. (*i)->remove();
  415. delete *i;
  416. i = m_particles.erase(i);
  417. }
  418. }
  419. void ParticleManager::handleParticleEvent(ClientEvent *event, Client *client,
  420. scene::ISceneManager* smgr, LocalPlayer *player)
  421. {
  422. switch (event->type) {
  423. case CE_DELETE_PARTICLESPAWNER: {
  424. MutexAutoLock lock(m_spawner_list_lock);
  425. if (m_particle_spawners.find(event->delete_particlespawner.id) !=
  426. m_particle_spawners.end()) {
  427. delete m_particle_spawners.find(event->delete_particlespawner.id)->second;
  428. m_particle_spawners.erase(event->delete_particlespawner.id);
  429. }
  430. // no allocated memory in delete event
  431. break;
  432. }
  433. case CE_ADD_PARTICLESPAWNER: {
  434. {
  435. MutexAutoLock lock(m_spawner_list_lock);
  436. if (m_particle_spawners.find(event->add_particlespawner.id) !=
  437. m_particle_spawners.end()) {
  438. delete m_particle_spawners.find(event->add_particlespawner.id)->second;
  439. m_particle_spawners.erase(event->add_particlespawner.id);
  440. }
  441. }
  442. video::ITexture *texture =
  443. client->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture));
  444. ParticleSpawner* toadd = new ParticleSpawner(client, smgr, player,
  445. event->add_particlespawner.amount,
  446. event->add_particlespawner.spawntime,
  447. *event->add_particlespawner.minpos,
  448. *event->add_particlespawner.maxpos,
  449. *event->add_particlespawner.minvel,
  450. *event->add_particlespawner.maxvel,
  451. *event->add_particlespawner.minacc,
  452. *event->add_particlespawner.maxacc,
  453. event->add_particlespawner.minexptime,
  454. event->add_particlespawner.maxexptime,
  455. event->add_particlespawner.minsize,
  456. event->add_particlespawner.maxsize,
  457. event->add_particlespawner.collisiondetection,
  458. event->add_particlespawner.collision_removal,
  459. event->add_particlespawner.attached_id,
  460. event->add_particlespawner.vertical,
  461. texture,
  462. event->add_particlespawner.id,
  463. event->add_particlespawner.animation,
  464. event->add_particlespawner.glow,
  465. this);
  466. /* delete allocated content of event */
  467. delete event->add_particlespawner.minpos;
  468. delete event->add_particlespawner.maxpos;
  469. delete event->add_particlespawner.minvel;
  470. delete event->add_particlespawner.maxvel;
  471. delete event->add_particlespawner.minacc;
  472. delete event->add_particlespawner.texture;
  473. delete event->add_particlespawner.maxacc;
  474. {
  475. MutexAutoLock lock(m_spawner_list_lock);
  476. m_particle_spawners.insert(
  477. std::pair<u32, ParticleSpawner*>(
  478. event->add_particlespawner.id,
  479. toadd));
  480. }
  481. break;
  482. }
  483. case CE_SPAWN_PARTICLE: {
  484. video::ITexture *texture =
  485. client->tsrc()->getTextureForMesh(*(event->spawn_particle.texture));
  486. Particle* toadd = new Particle(client, smgr, player, m_env,
  487. *event->spawn_particle.pos,
  488. *event->spawn_particle.vel,
  489. *event->spawn_particle.acc,
  490. event->spawn_particle.expirationtime,
  491. event->spawn_particle.size,
  492. event->spawn_particle.collisiondetection,
  493. event->spawn_particle.collision_removal,
  494. event->spawn_particle.vertical,
  495. texture,
  496. v2f(0.0, 0.0),
  497. v2f(1.0, 1.0),
  498. event->spawn_particle.animation,
  499. event->spawn_particle.glow);
  500. addParticle(toadd);
  501. delete event->spawn_particle.pos;
  502. delete event->spawn_particle.vel;
  503. delete event->spawn_particle.acc;
  504. delete event->spawn_particle.texture;
  505. break;
  506. }
  507. default: break;
  508. }
  509. }
  510. void ParticleManager::addDiggingParticles(IGameDef* gamedef,
  511. scene::ISceneManager* smgr, LocalPlayer *player, v3s16 pos,
  512. const MapNode &n, const ContentFeatures &f)
  513. {
  514. for (u16 j = 0; j < 32; j++) // set the amount of particles here
  515. {
  516. addNodeParticle(gamedef, smgr, player, pos, n, f);
  517. }
  518. }
  519. void ParticleManager::addPunchingParticles(IGameDef* gamedef,
  520. scene::ISceneManager* smgr, LocalPlayer *player, v3s16 pos,
  521. const MapNode &n, const ContentFeatures &f)
  522. {
  523. addNodeParticle(gamedef, smgr, player, pos, n, f);
  524. }
  525. void ParticleManager::addNodeParticle(IGameDef* gamedef,
  526. scene::ISceneManager* smgr, LocalPlayer *player, v3s16 pos,
  527. const MapNode &n, const ContentFeatures &f)
  528. {
  529. // Texture
  530. u8 texid = myrand_range(0, 5);
  531. const TileLayer &tile = f.tiles[texid].layers[0];
  532. video::ITexture *texture;
  533. struct TileAnimationParams anim;
  534. anim.type = TAT_NONE;
  535. // Only use first frame of animated texture
  536. if (tile.material_flags & MATERIAL_FLAG_ANIMATION)
  537. texture = tile.frames[0].texture;
  538. else
  539. texture = tile.texture;
  540. float size = rand() % 64 / 256.;
  541. float visual_size = BS * size;
  542. v2f texsize(size * 2, size * 2);
  543. v2f texpos;
  544. texpos.X = ((rand() % 64) / 64. - texsize.X);
  545. texpos.Y = ((rand() % 64) / 64. - texsize.Y);
  546. // Physics
  547. v3f velocity((rand() % 100 / 50. - 1) / 1.5,
  548. rand() % 100 / 35.,
  549. (rand() % 100 / 50. - 1) / 1.5);
  550. v3f acceleration(0,-9,0);
  551. v3f particlepos = v3f(
  552. (f32) pos.X + rand() %100 /200. - 0.25,
  553. (f32) pos.Y + rand() %100 /200. - 0.25,
  554. (f32) pos.Z + rand() %100 /200. - 0.25
  555. );
  556. video::SColor color;
  557. if (tile.has_color)
  558. color = tile.color;
  559. else
  560. n.getColor(f, &color);
  561. Particle* toadd = new Particle(
  562. gamedef,
  563. smgr,
  564. player,
  565. m_env,
  566. particlepos,
  567. velocity,
  568. acceleration,
  569. rand() % 100 / 100., // expiration time
  570. visual_size,
  571. true,
  572. false,
  573. false,
  574. texture,
  575. texpos,
  576. texsize,
  577. anim,
  578. 0,
  579. color);
  580. addParticle(toadd);
  581. }
  582. void ParticleManager::addParticle(Particle* toadd)
  583. {
  584. MutexAutoLock lock(m_particle_list_lock);
  585. m_particles.push_back(toadd);
  586. }