Chaos destruction Niagara data interface spawns some particles at the origin instead of the event position

Hello, I think I found a bug in UNiagaraDataInterfaceChaosDestruction. In UNiagaraDataInterfaceChaosDestruction::GetParticleIdsToSpawnAtTime():

OutMinValue.SetAndAdvance(LastSpawnedPointID + 1);

OutMaxValue.SetAndAdvance(LastSpawnedPointID + InstData->PositionArray.Num());

So we are mapping indices into InstData->PositionArray to ParticleIds by adding LastSpawnedPointID + 1. Then to get from ParticleIds back to indices, we need to subtract LastSpawnedPointID + 1. But UNiagaraDataInterfaceChaosDestruction::GetPosition() does:

const int32 ParticleID = ParticleIDParam.GetAndAdvance() - LastSpawnedPointID + 1;

const FVector3f Sample = InstData->PositionArray.IsValidIndex(ParticleID) ? (FVector3f)InstData->PositionArray[ParticleID] : FVector3f::Zero();

So that first line should rather be:

const int32 ParticleID = ParticleIDParam.GetAndAdvance() - LastSpawnedPointID - 1;

Because of this, two particles each frame spawn at the origin instead of where they should have. The same error is in GetNormal(), GetVelocity(), etc.

Best,

Max

Steps to Reproduce
Create a geometry collection from a cube and split it into three pieces. Place it in an empty map at (0, 0, 500). Enable Notify Break and Notify Trailing. In the level blueprint, Crumble Active Clusters the geometry collection on begin play.

Create a Niagara system using the Chaos Destruction Niagara Data Interface to spawn particles on trailing events.

[Image Removed]

Play the scene. Every couple of frames, two particles spawn at the origin and a third spawns with the geometry collection.

Hello [mention removed]​!

Thank you for reaching out and offering this solution.

I found a similar issue reported in the issue tracker here, but for some reason the fix was backlogged.

I’ll investigate/ask around and let you know.

All the best,

[mention removed]​

Hello [mention removed]​

I’ve confirmed this issue still reproduces in a /main Perforce 5.8 version of the engine.

I was expecting it to be fixed in the latest.

I asked Epic, hoping they could share their rationale regarding the Backlogging of this issue.

I’m waiting for their response.

Thank you for your patience.

All the best,

[mention removed]​

Hello [mention removed]​

I’ve been told they backlogged the issue because the proposed fix was incorrect.

It currently is:

const int32 ParticleID = ParticleIDParam.GetAndAdvance() - LastSpawnedPointID + 1;

The proposed fix was:

const int32 ParticleID = ParticleIDParam.GetAndAdvance() +LastSpawnedPointID + 1;

Looks like they forgot to enclose the last two terms:

const int32 ParticleID = ParticleIDParam.GetAndAdvance() - (LastSpawnedPointID + 1);

So your solution is also right:

const int32 ParticleID = ParticleIDParam.GetAndAdvance() - LastSpawnedPointID - 1;

Let me know if this is useful!

All the best,

[mention removed]​

Hello [mention removed]​

I’ve been informed that a CL is being reviewed for a fix here!

Just asking for context nudged the devs to act on it. :wink:

I’ll share once I have it.

All the best,

[mention removed]​

Hello [mention removed]​

I’m sorry for the delay.

I’ve just received the CL: 47674773.

I’ll go ahead and close the case!

All the best,

[mention removed]​