Unity-Technologies / EntityComponentSystemSamples

Other
7.21k stars 1.61k forks source link

Possible Error in BoidsSystem that surprisingly does not breake the simulation. #271

Open piotrrach opened 1 year ago

piotrrach commented 1 year ago

I've been analyzing BoidSystem and got to realization that there is a possible mistake in MergeCells job. In the ExecuteNext method to be precise. I suppose instead of this:

        public void ExecuteNext(int cellIndex, int index)
        {
            cellCount[cellIndex]      += 1;
            cellAlignment[cellIndex]  += cellAlignment[cellIndex];
            cellSeparation[cellIndex] += cellSeparation[cellIndex];
            cellIndices[index]        = cellIndex;
        }

should it be like this:

       public void ExecuteNext(int cellIndex, int index)
        {
            cellCount[cellIndex]      += 1;
            cellAlignment[cellIndex]  += cellAlignment[index];
            cellSeparation[cellIndex] += cellSeparation[index];
            cellIndices[index]        = cellIndex;
        }