| 332 | } |
| 333 | |
| 334 | void ParticleEffect::UpdateBounds() |
| 335 | { |
| 336 | BoundingBox bounds = BoundingBox::Empty; |
| 337 | const auto particleSystem = ParticleSystem.Get(); |
| 338 | if (particleSystem && Instance.LastUpdateTime >= 0) |
| 339 | { |
| 340 | for (int32 j = 0; j < particleSystem->Tracks.Count(); j++) |
| 341 | { |
| 342 | const auto& track = particleSystem->Tracks[j]; |
| 343 | if (track.Type != ParticleSystem::Track::Types::Emitter || track.Disabled) |
| 344 | continue; |
| 345 | const int32 emitterIndex = track.AsEmitter.Index; |
| 346 | ParticleEmitter* emitter = particleSystem->Emitters[emitterIndex].Get(); |
| 347 | if (!emitter || emitter->Capacity == 0 || emitter->Graph.Layout.Size == 0 || Instance.Emitters.Count() <= emitterIndex) |
| 348 | continue; |
| 349 | auto& data = Instance.Emitters[emitterIndex]; |
| 350 | |
| 351 | BoundingBox emitterBounds; |
| 352 | if (emitter->GraphExecutorCPU.ComputeBounds(emitter, this, data, emitterBounds)) |
| 353 | { |
| 354 | ASSERT(!emitterBounds.Minimum.IsNanOrInfinity() && !emitterBounds.Maximum.IsNanOrInfinity()); |
| 355 | |
| 356 | if (emitter->SimulationSpace == ParticlesSimulationSpace::Local) |
| 357 | { |
| 358 | BoundingBox::Transform(emitterBounds, _transform, emitterBounds); |
| 359 | } |
| 360 | |
| 361 | BoundingBox::Merge(emitterBounds, bounds, bounds); |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | // Empty bounds if there is no particle system to play or it has been never played |
| 367 | if (bounds == BoundingBox::Empty) |
| 368 | { |
| 369 | bounds = BoundingBox(_transform.Translation); |
| 370 | } |
| 371 | |
| 372 | _box = bounds; |
| 373 | BoundingSphere::FromBox(bounds, _sphere); |
| 374 | if (_sceneRenderingKey != -1) |
| 375 | GetSceneRendering()->UpdateActor(this, _sceneRenderingKey); |
| 376 | } |
| 377 | |
| 378 | void ParticleEffect::Sync() |
| 379 | { |
no test coverage detected