Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung | |||
| talit:fluid_simulation [2025-11-16 15:37] – sca | talit: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< | IEnumerable< | ||
| { | { | ||
| Zeile 689: | Zeile 690: | ||
| } | } | ||
| + | List< | ||
| + | { | ||
| + | List< | ||
| + | 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, | ||
| + | if (!particleModelDict.ContainsKey(hash)) continue; | ||
| + | foreach (var particle in particleModelDict[hash]) | ||
| + | { | ||
| + | neigbours.Add(particle); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | } | ||
| + | return neigbours; | ||
| + | } | ||
| + | | ||
| void Step() | void Step() | ||
| { | { | ||