Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung
talit:fluid_simulation [2025-11-16 15:37] scatalit:fluid_simulation [2025-11-16 19:27] (aktuell) sca
Zeile 668: Zeile 668:
  
     // get all particles in same and eight neighboring cells     // get all particles in same and eight neighboring cells
 +    // two options: same method once as IEnumerable and once returning a list. Same performance.
     IEnumerable<ParticleModel> GetNeighbors(Vector2 position)     IEnumerable<ParticleModel> GetNeighbors(Vector2 position)
     {     {
Zeile 689: Zeile 690:
     }     }
  
 +    List<ParticleModel> GetNeighborsList(Vector2 position)
 +    {
 +        List<ParticleModel> neigbours = new List<ParticleModel>();
 +        int xCell = GetGridCellCoord(position.x);
 +        int yCell = GetGridCellCoord(position.y);
 +        for (int dx = -1; dx <= 1; dx++)
 +        {
 +            int x = xCell + dx;
 +            for (int dy = -1; dy <= 1; dy++)
 +            {
 +                int y = yCell + dy;
 +                int hash = CalculateCellHash(x, y);
 +                if (!particleModelDict.ContainsKey(hash)) continue;
 +                foreach (var particle in particleModelDict[hash])
 +                {
 +                    neigbours.Add(particle);
 +                }
 +            }
 +
 +        }
 +        return neigbours;
 +    }
 +    
     void Step()     void Step()
     {     {
  • talit/fluid_simulation.1763307477.txt.gz
  • Zuletzt geändert: 2025-11-16 15:37
  • von sca