ParticleEmitter.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. //
  2. // Copyright (c) 2008-2013 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include "Precompiled.h"
  23. #include "Context.h"
  24. #include "Log.h"
  25. #include "Material.h"
  26. #include "MemoryBuffer.h"
  27. #include "ParticleEmitter.h"
  28. #include "Profiler.h"
  29. #include "ResourceCache.h"
  30. #include "Scene.h"
  31. #include "SceneEvents.h"
  32. #include "XMLFile.h"
  33. #include "DebugNew.h"
  34. namespace Urho3D
  35. {
  36. OBJECTTYPESTATIC(ParticleEmitter);
  37. ParticleEmitter::ParticleEmitter(Context* context) :
  38. BillboardSet(context),
  39. emitterType_(EMITTER_POINT),
  40. emitterSize_(Vector3::ZERO),
  41. directionMin_(Vector3(-1.0f, -1.0f, -1.0f)),
  42. directionMax_(Vector3(1.0f, 1.0f, 1.0f)),
  43. constanceForce_(Vector3::ZERO),
  44. sizeMin_(Vector2(0.1f, 0.1f)),
  45. sizeMax_(Vector2(0.1f, 0.1f)),
  46. dampingForce_(0.0f),
  47. emitterRadius_(0.0f),
  48. periodTimer_(0.0f),
  49. emissionTimer_(0.0f),
  50. activeTime_(0.0f),
  51. inactiveTime_(0.0f),
  52. intervalMin_(0.1f),
  53. intervalMax_(0.1f),
  54. timeToLiveMin_(1.0f),
  55. timeToLiveMax_(1.0f),
  56. velocityMin_(1.0f),
  57. velocityMax_(1.0f),
  58. rotationMin_(0.0f),
  59. rotationMax_(0.0f),
  60. rotationSpeedMin_(0.0f),
  61. rotationSpeedMax_(0.0f),
  62. sizeAdd_(0.0f),
  63. sizeMul_(1.0f),
  64. active_(true),
  65. updateInvisible_(false),
  66. lastTimeStep_(0.0f),
  67. lastUpdateFrameNumber_(M_MAX_UNSIGNED)
  68. {
  69. SetParticleColor(Color(1.0f, 1.0f, 1.0f));
  70. SetNumParticles(10);
  71. }
  72. ParticleEmitter::~ParticleEmitter()
  73. {
  74. }
  75. void ParticleEmitter::RegisterObject(Context* context)
  76. {
  77. context->RegisterFactory<ParticleEmitter>();
  78. ACCESSOR_ATTRIBUTE(ParticleEmitter, VAR_RESOURCEREF, "Parameter Source", GetParameterSourceAttr, SetParameterSourceAttr, ResourceRef, ResourceRef(XMLFile::GetTypeStatic()), AM_DEFAULT);
  79. ATTRIBUTE(ParticleEmitter, VAR_BOOL, "Is Active", active_, true, AM_DEFAULT);
  80. ATTRIBUTE(ParticleEmitter, VAR_BOOL, "Is Visible", visible_, true, AM_DEFAULT);
  81. ACCESSOR_ATTRIBUTE(ParticleEmitter, VAR_BOOL, "Can Be Occluded", IsOccludee, SetOccludee, bool, true, AM_DEFAULT);
  82. ATTRIBUTE(ParticleEmitter, VAR_BOOL, "Cast Shadows", castShadows_, false, AM_DEFAULT);
  83. ACCESSOR_ATTRIBUTE(ParticleEmitter, VAR_FLOAT, "Draw Distance", GetDrawDistance, SetDrawDistance, float, 0.0f, AM_DEFAULT);
  84. ACCESSOR_ATTRIBUTE(ParticleEmitter, VAR_FLOAT, "Shadow Distance", GetShadowDistance, SetShadowDistance, float, 0.0f, AM_DEFAULT);
  85. ACCESSOR_ATTRIBUTE(ParticleEmitter, VAR_FLOAT, "Animation LOD Bias", GetAnimationLodBias, SetAnimationLodBias, float, 1.0f, AM_DEFAULT);
  86. ATTRIBUTE(ParticleEmitter, VAR_FLOAT, "Period Timer", periodTimer_, 0.0f, AM_DEFAULT | AM_NOEDIT);
  87. ATTRIBUTE(ParticleEmitter, VAR_FLOAT, "Emission Timer", emissionTimer_, 0.0f, AM_DEFAULT | AM_NOEDIT);
  88. ACCESSOR_ATTRIBUTE(ParticleEmitter, VAR_VARIANTVECTOR, "Particles", GetParticlesAttr, SetParticlesAttr, VariantVector, VariantVector(), AM_FILE | AM_NOEDIT);
  89. ACCESSOR_ATTRIBUTE(ParticleEmitter, VAR_VARIANTVECTOR, "Billboards", GetBillboardsAttr, SetBillboardsAttr, VariantVector, VariantVector(), AM_FILE | AM_NOEDIT);
  90. }
  91. void ParticleEmitter::Update(const FrameInfo& frame)
  92. {
  93. // If there is an amount mismatch between particles and billboards, correct it
  94. if (particles_.Size() != billboards_.Size())
  95. SetNumBillboards(particles_.Size());
  96. bool needBillboardUpdate = false;
  97. // Check active/inactive period switching
  98. periodTimer_ += lastTimeStep_;
  99. if (active_)
  100. {
  101. if (activeTime_ && periodTimer_ >= activeTime_)
  102. {
  103. active_ = false;
  104. periodTimer_ -= activeTime_;
  105. }
  106. }
  107. else
  108. {
  109. if (inactiveTime_ && periodTimer_ >= inactiveTime_)
  110. {
  111. active_ = true;
  112. periodTimer_ -= inactiveTime_;
  113. }
  114. }
  115. // Check for emitting a new particle
  116. if (active_)
  117. {
  118. emissionTimer_ += lastTimeStep_;
  119. if (emissionTimer_ > 0.0f)
  120. {
  121. emissionTimer_ -= Lerp(intervalMin_, intervalMax_, Random(1.0f));
  122. if (EmitNewParticle())
  123. needBillboardUpdate = true;
  124. }
  125. }
  126. // Update existing particles
  127. Vector3 relativeConstantForce = node_->GetWorldRotation().Inverse() * constanceForce_;
  128. // If billboards are not relative, apply scaling to the position update
  129. Vector3 scaleVector = Vector3::ONE;
  130. if (scaled_ && !relative_)
  131. scaleVector = node_->GetWorldScale();
  132. for (unsigned i = 0; i < particles_.Size(); ++i)
  133. {
  134. Particle& particle = particles_[i];
  135. Billboard& billboard = billboards_[i];
  136. if (billboard.enabled_)
  137. {
  138. needBillboardUpdate = true;
  139. // Time to live
  140. if (particle.timer_ >= particle.timeToLive_)
  141. {
  142. billboard.enabled_ = false;
  143. continue;
  144. }
  145. particle.timer_ += lastTimeStep_;
  146. // Velocity & position
  147. if (constanceForce_ != Vector3::ZERO)
  148. {
  149. if (relative_)
  150. particle.velocity_ += lastTimeStep_ * relativeConstantForce;
  151. else
  152. particle.velocity_ += lastTimeStep_ * constanceForce_;
  153. }
  154. if (dampingForce_ != 0.0f)
  155. {
  156. Vector3 force = -dampingForce_ * particle.velocity_;
  157. particle.velocity_ += lastTimeStep_ * force;
  158. }
  159. billboard.position_ += lastTimeStep_ * particle.velocity_ * scaleVector;
  160. // Rotation
  161. billboard.rotation_ += lastTimeStep_ * particle.rotationSpeed_;
  162. // Scaling
  163. if (sizeAdd_ != 0.0f || sizeMul_ != 1.0f)
  164. {
  165. particle.scale_ += lastTimeStep_ * sizeAdd_;
  166. if (sizeMul_ != 1.0f)
  167. particle.scale_ *= (lastTimeStep_ * (sizeMul_ - 1.0f)) + 1.0f;
  168. billboard.size_ = particle.size_ * particle.scale_;
  169. }
  170. // Color interpolation
  171. unsigned& index = particle.colorIndex_;
  172. if (index < colors_.Size())
  173. {
  174. if (index < colors_.Size() - 1)
  175. {
  176. if (particle.timer_ >= colors_[index + 1].time_)
  177. ++index;
  178. }
  179. if (index < colors_.Size() - 1)
  180. billboard.color_ = colors_[index].interpolate(colors_[index + 1], particle.timer_);
  181. else
  182. billboard.color_ = colors_[index].color_;
  183. }
  184. // Texture animation
  185. unsigned& texIndex = particle.texIndex_;
  186. if (textureAnimation_.Size() && texIndex < textureAnimation_.Size() - 1)
  187. {
  188. if (particle.timer_ >= textureAnimation_[texIndex + 1].time_)
  189. {
  190. billboard.uv_ = textureAnimation_[texIndex + 1].uv_;
  191. ++texIndex;
  192. }
  193. }
  194. }
  195. }
  196. if (needBillboardUpdate)
  197. Updated();
  198. }
  199. bool ParticleEmitter::LoadParameters(XMLFile* file)
  200. {
  201. ResourceCache* cache = GetSubsystem<ResourceCache>();
  202. if (!file || !cache)
  203. return false;
  204. XMLElement rootElem = file->GetRoot();
  205. if (!rootElem)
  206. return false;
  207. parameterSource_ = file;
  208. if (rootElem.HasChild("material"))
  209. SetMaterial(cache->GetResource<Material>(rootElem.GetChild("material").GetAttribute("name")));
  210. if (rootElem.HasChild("numparticles"))
  211. SetNumParticles(rootElem.GetChild("numparticles").GetInt("value"));
  212. if (rootElem.HasChild("updateinvisible"))
  213. updateInvisible_ = rootElem.GetChild("updateinvisible").GetBool("enable");
  214. if (rootElem.HasChild("relative"))
  215. relative_ = rootElem.GetChild("relative").GetBool("enable");
  216. if (rootElem.HasChild("scaled"))
  217. scaled_ = rootElem.GetChild("scaled").GetBool("enable");
  218. if (rootElem.HasChild("sorted"))
  219. sorted_ = rootElem.GetChild("sorted").GetBool("enable");
  220. if (rootElem.HasChild("animlodbias"))
  221. SetAnimationLodBias(rootElem.GetChild("relative").GetFloat("value"));
  222. if (rootElem.HasChild("emittertype"))
  223. {
  224. String type = rootElem.GetChild("emittertype").GetAttributeLower("value");
  225. if (type == "point")
  226. emitterType_ = EMITTER_POINT;
  227. else if (type == "box")
  228. emitterType_ = EMITTER_BOX;
  229. else if (type == "sphere")
  230. emitterType_ = EMITTER_SPHERE;
  231. else
  232. LOGERROR("Unknown particle emitter type " + type);
  233. }
  234. if (rootElem.HasChild("emittersize"))
  235. emitterSize_ = rootElem.GetChild("emittersize").GetVector3("value");
  236. if (rootElem.HasChild("direction"))
  237. GetVector3MinMax(rootElem.GetChild("direction"), directionMin_, directionMax_);
  238. if (rootElem.HasChild("constantforce"))
  239. constanceForce_ = rootElem.GetChild("constantforce").GetVector3("value");
  240. if (rootElem.HasChild("dampingforce"))
  241. dampingForce_ = rootElem.GetChild("dampingforce").GetFloat("value");
  242. if (rootElem.HasChild("activetime"))
  243. activeTime_ = rootElem.GetChild("activetime").GetFloat("value");
  244. if (activeTime_ < 0.0f)
  245. activeTime_ = M_INFINITY;
  246. if (rootElem.HasChild("inactivetime"))
  247. inactiveTime_ = rootElem.GetChild("inactivetime").GetFloat("value");
  248. if (inactiveTime_ < 0.0f)
  249. inactiveTime_ = M_INFINITY;
  250. if (rootElem.HasChild("interval"))
  251. GetFloatMinMax(rootElem.GetChild("interval"), intervalMin_, intervalMax_);
  252. if (rootElem.HasChild("particlesize"))
  253. GetVector2MinMax(rootElem.GetChild("particlesize"), sizeMin_, sizeMax_);
  254. if (rootElem.HasChild("timetolive"))
  255. GetFloatMinMax(rootElem.GetChild("timetolive"), timeToLiveMin_, timeToLiveMax_);
  256. if (rootElem.HasChild("velocity"))
  257. GetFloatMinMax(rootElem.GetChild("velocity"), velocityMin_, velocityMax_);
  258. if (rootElem.HasChild("rotation"))
  259. GetFloatMinMax(rootElem.GetChild("rotation"), rotationMin_, rotationMax_);
  260. if (rootElem.HasChild("rotationspeed"))
  261. GetFloatMinMax(rootElem.GetChild("rotationspeed"), rotationSpeedMin_, rotationSpeedMax_);
  262. if (rootElem.HasChild("sizedelta"))
  263. {
  264. XMLElement deltaElem = rootElem.GetChild("sizedelta");
  265. if (deltaElem.HasAttribute("add"))
  266. sizeAdd_ = deltaElem.GetFloat("add");
  267. if (deltaElem.HasAttribute("mul"))
  268. sizeMul_ = deltaElem.GetFloat("mul");
  269. }
  270. if (rootElem.HasChild("color"))
  271. SetParticleColor(rootElem.GetChild("color").GetColor("value"));
  272. if (rootElem.HasChild("colorfade"))
  273. {
  274. Vector<ColorFade> fades;
  275. XMLElement colorFadeElem = rootElem.GetChild("colorfade");
  276. while (colorFadeElem)
  277. {
  278. fades.Push(ColorFade(colorFadeElem.GetColor("color"), colorFadeElem.GetFloat("time")));
  279. colorFadeElem = colorFadeElem.GetNext("colorfade");
  280. }
  281. SetParticleColors(fades);
  282. }
  283. if (rootElem.HasChild("texanim"))
  284. {
  285. Vector<TextureAnimation> animations;
  286. XMLElement animElem = rootElem.GetChild("texanim");
  287. while (animElem)
  288. {
  289. TextureAnimation animation;
  290. animation.uv_ = animElem.GetRect("uv");
  291. animation.time_ = animElem.GetFloat("time");
  292. animations.Push(animation);
  293. animElem = animElem.GetNext("texanim");
  294. }
  295. textureAnimation_ = animations;
  296. }
  297. MarkNetworkUpdate();
  298. return true;
  299. }
  300. void ParticleEmitter::SetActive(bool enable, bool resetPeriod)
  301. {
  302. if (enable != active_ || resetPeriod)
  303. {
  304. active_ = enable;
  305. periodTimer_ = 0.0f;
  306. MarkNetworkUpdate();
  307. }
  308. }
  309. void ParticleEmitter::SetParameterSourceAttr(ResourceRef value)
  310. {
  311. ResourceCache* cache = GetSubsystem<ResourceCache>();
  312. LoadParameters(cache->GetResource<XMLFile>(value.id_));
  313. }
  314. void ParticleEmitter::SetParticlesAttr(VariantVector value)
  315. {
  316. unsigned index = 0;
  317. SetNumParticles(value[index++].GetInt());
  318. for (PODVector<Particle>::Iterator i = particles_.Begin(); i != particles_.End() && index < value.Size(); ++i)
  319. {
  320. i->velocity_ = value[index++].GetVector3();
  321. i->size_ = value[index++].GetVector2();
  322. i->timer_ = value[index++].GetFloat();
  323. i->timeToLive_ = value[index++].GetFloat();
  324. i->scale_ = value[index++].GetFloat();
  325. i->rotationSpeed_ = value[index++].GetFloat();
  326. i->colorIndex_ = value[index++].GetInt();
  327. i->texIndex_ = value[index++].GetInt();
  328. }
  329. }
  330. ResourceRef ParticleEmitter::GetParameterSourceAttr() const
  331. {
  332. return GetResourceRef(parameterSource_, XMLFile::GetTypeStatic());
  333. }
  334. VariantVector ParticleEmitter::GetParticlesAttr() const
  335. {
  336. VariantVector ret;
  337. ret.Reserve(particles_.Size() * 8 + 1);
  338. ret.Push(particles_.Size());
  339. for (PODVector<Particle>::ConstIterator i = particles_.Begin(); i != particles_.End(); ++i)
  340. {
  341. ret.Push(i->velocity_);
  342. ret.Push(i->size_);
  343. ret.Push(i->timer_);
  344. ret.Push(i->timeToLive_);
  345. ret.Push(i->scale_);
  346. ret.Push(i->rotationSpeed_);
  347. ret.Push(i->colorIndex_);
  348. ret.Push(i->texIndex_);
  349. }
  350. return ret;
  351. }
  352. void ParticleEmitter::OnNodeSet(Node* node)
  353. {
  354. BillboardSet::OnNodeSet(node);
  355. if (node)
  356. {
  357. Scene* scene = GetScene();
  358. if (scene)
  359. SubscribeToEvent(scene, E_SCENEPOSTUPDATE, HANDLER(ParticleEmitter, HandleScenePostUpdate));
  360. }
  361. }
  362. void ParticleEmitter::SetNumParticles(int num)
  363. {
  364. num = Max(num, 0);
  365. particles_.Resize(num);
  366. SetNumBillboards(num);
  367. }
  368. void ParticleEmitter::SetParticleColor(const Color& color)
  369. {
  370. colors_.Clear();
  371. colors_.Push(ColorFade(color));
  372. }
  373. void ParticleEmitter::SetParticleColors(const Vector<ColorFade>& colors)
  374. {
  375. if (!colors.Size())
  376. return;
  377. colors_ = colors;
  378. }
  379. bool ParticleEmitter::EmitNewParticle()
  380. {
  381. unsigned index = GetFreeParticle();
  382. if (index == M_MAX_UNSIGNED)
  383. return false;
  384. assert(index < particles_.Size());
  385. Particle& particle = particles_[index];
  386. Billboard& billboard = billboards_[index];
  387. Vector3 startPos;
  388. Vector3 startDir;
  389. switch (emitterType_)
  390. {
  391. case EMITTER_POINT:
  392. startPos = Vector3::ZERO;
  393. break;
  394. case EMITTER_BOX:
  395. startPos = Vector3(
  396. Random(emitterSize_.x_) - emitterSize_.x_ * 0.5f,
  397. Random(emitterSize_.y_) - emitterSize_.y_ * 0.5f,
  398. Random(emitterSize_.z_) - emitterSize_.z_ * 0.5f
  399. );
  400. break;
  401. case EMITTER_SPHERE:
  402. {
  403. Vector3 dir(
  404. Random(2.0f) - 1.0f,
  405. Random(2.0f) - 1.0f,
  406. Random(2.0f) - 1.0f
  407. );
  408. dir.Normalize();
  409. startPos = Random(emitterRadius_) * dir;
  410. }
  411. break;
  412. }
  413. startDir = Vector3(
  414. Lerp(directionMin_.x_, directionMax_.x_, Random(1.0f)),
  415. Lerp(directionMin_.y_, directionMax_.y_, Random(1.0f)),
  416. Lerp(directionMin_.z_, directionMax_.z_, Random(1.0f))
  417. );
  418. startDir.Normalize();
  419. if (!relative_)
  420. {
  421. startPos = node_->GetWorldTransform() * startPos;
  422. startDir = node_->GetWorldRotation() * startDir;
  423. };
  424. particle.velocity_ = Lerp(velocityMin_, velocityMax_, Random(1.0f)) * startDir;
  425. particle.size_ = sizeMin_.Lerp(sizeMax_, Random(1.0f));
  426. particle.timer_ = 0.0f;
  427. particle.timeToLive_ = Lerp(timeToLiveMin_, timeToLiveMax_, Random(1.0f));
  428. particle.scale_ = 1.0f;
  429. particle.rotationSpeed_ = Lerp(rotationSpeedMin_, rotationSpeedMax_, Random(1.0f));
  430. particle.colorIndex_ = 0;
  431. particle.texIndex_ = 0;
  432. billboard.position_ = startPos;
  433. billboard.size_ = particles_[index].size_;
  434. billboard.uv_ = textureAnimation_.Size() ? textureAnimation_[0].uv_ : Rect::POSITIVE;
  435. billboard.rotation_ = Lerp(rotationMin_, rotationMax_, Random(1.0f));
  436. billboard.color_ = colors_[0].color_;
  437. billboard.enabled_ = true;
  438. return true;
  439. }
  440. unsigned ParticleEmitter::GetFreeParticle() const
  441. {
  442. for (unsigned i = 0; i < billboards_.Size(); ++i)
  443. {
  444. if (!billboards_[i].enabled_)
  445. return i;
  446. }
  447. return M_MAX_UNSIGNED;
  448. }
  449. void ParticleEmitter::GetFloatMinMax(const XMLElement& element, float& minValue, float& maxValue)
  450. {
  451. if (element.IsNull())
  452. return;
  453. if (element.HasAttribute("value"))
  454. minValue = maxValue = element.GetFloat("value");
  455. if (element.HasAttribute("min") && element.HasAttribute("max"))
  456. {
  457. minValue = element.GetFloat("min");
  458. maxValue = element.GetFloat("max");
  459. }
  460. }
  461. void ParticleEmitter::GetVector2MinMax(const XMLElement& element, Vector2& minValue, Vector2& maxValue)
  462. {
  463. if (element.IsNull())
  464. return;
  465. if (element.HasAttribute("value"))
  466. minValue = maxValue = element.GetVector2("value");
  467. if (element.HasAttribute("min") && element.HasAttribute("max"))
  468. {
  469. minValue = element.GetVector2("min");
  470. maxValue = element.GetVector2("max");
  471. }
  472. }
  473. void ParticleEmitter::GetVector3MinMax(const XMLElement& element, Vector3& minValue, Vector3& maxValue)
  474. {
  475. if (element.IsNull())
  476. return;
  477. if (element.HasAttribute("value"))
  478. minValue = maxValue = element.GetVector3("value");
  479. if (element.HasAttribute("min") && element.HasAttribute("max"))
  480. {
  481. minValue = element.GetVector3("min");
  482. maxValue = element.GetVector3("max");
  483. }
  484. }
  485. void ParticleEmitter::HandleScenePostUpdate(StringHash eventType, VariantMap& eventData)
  486. {
  487. // Store scene's timestep and use it instead of global timestep, as time scale may be other than 1
  488. using namespace ScenePostUpdate;
  489. lastTimeStep_ = eventData[P_TIMESTEP].GetFloat();
  490. // If no invisible update, check that the billboardset is in view (framenumber has changed)
  491. if (updateInvisible_ || viewFrameNumber_ != lastUpdateFrameNumber_)
  492. {
  493. lastUpdateFrameNumber_ = viewFrameNumber_;
  494. MarkForUpdate();
  495. }
  496. }
  497. }