20-11-2023, 07:07 AM
(This post was last modified: 20-11-2023, 07:12 AM by josemendez.)
(19-11-2023, 06:37 AM)slimedev Wrote: Here's the important formula in the script below, where dataDelta is a float difference in Userdata PlayerInput between two particles.
It seems correct, but invovled guesswork and AI so who knows.
Code:float4 oneDeltaA2B = dataDelta * distA2B / math.length(distA2B);
All this formula does is normalize distA2B and multiply it by dataDelta. That is, get a vector in the direction of "distA2B" with "dataDelta" magnitude. However it will result in NaN values when distA2B is zero, which can happen when particles get close to each other.
A simpler and safer alternative:
Code:
float4 oneDeltaA2B = dataDelta * math.normalizesafe(distA2B);
(19-11-2023, 06:37 AM)slimedev Wrote: Maybe the problem is having one Burst Job use the same userdata for two purposes at once: Regular Diffusion of "Direction" as Userdata AND +/- "Direction" based on another?
I'm not too sure of what you're trying to do, to be honest. However you're seem to be writing userData's xyz values based on partial diffusion results of userdata.w (playerInputIndex.iInVec4?) which will yield undefined results.
You want to make sure the diffusion step has finished (which will only happen once all batches have finished UpdateDensitiesJob, so all particles have had a chance to gather/scatter userData values from/to their neighbors) and only then do some calculation based on the results.
kind regards,