Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  get position of particles
#7
(19-02-2021, 04:11 PM)josemendez Wrote: I don’t think you can reliably use list intersection() or contains() operations when the contents are floating point data. These use the type’s default comparer. This won’t work unless you provide a custom comparer that uses an epsilon to tell if two Vector3 are close enough to each other. Unless the particle positions are *exactly* the same, a direct comparison between floating point values is very likely to fail.

See: https://docs.unity3d.com/ScriptReference...ately.html
Hello and thanks for the reccomendation!

Using what you said and adding some checkings i managed to achieve what i wanted
Code:
for (int i = 0; i < 289; i++)
        {
            for (int j = 0; j < 289; j++)
            {
                if (Mathf.Approximately(clothParticles1[i].y, clothParticles2[j].y))
                {
                    if (Mathf.Approximately(clothParticles1[i].x,clothParticles2[j].x))
                    {
                        stitcher.AddStitch(i, j);
                    }
                }               
            }
        }
The above code succesfully stitches the 2 flags only on the overlaping positions.
Reply


Messages In This Thread
get position of particles - by orestissar - 19-02-2021, 10:44 AM
RE: get position of particles - by josemendez - 19-02-2021, 11:08 AM
RE: get position of particles - by orestissar - 19-02-2021, 02:49 PM
RE: get position of particles - by josemendez - 19-02-2021, 03:22 PM
RE: get position of particles - by orestissar - 19-02-2021, 03:52 PM
RE: get position of particles - by josemendez - 19-02-2021, 04:11 PM
RE: get position of particles - by orestissar - 22-02-2021, 02:59 PM