MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / UpdateBounds

Method UpdateBounds

Source/Engine/Particles/ParticleEffect.cpp:334–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334void 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
378void ParticleEffect::Sync()
379{

Callers 1

JobMethod · 0.45

Calls 8

ComputeBoundsMethod · 0.80
UpdateActorMethod · 0.80
TransformClass · 0.50
MergeFunction · 0.50
BoundingBoxClass · 0.50
GetMethod · 0.45
CountMethod · 0.45
IsNanOrInfinityMethod · 0.45

Tested by

no test coverage detected