SebLague / Pathfinding

MIT License
668 stars 251 forks source link

swapping raw with columns #11

Closed ahmedsaid12345 closed 4 years ago

ahmedsaid12345 commented 4 years ago

i think in penalties horizontal u swap between raw and columns `

for (int y = 0; y < gridSizeY; y++) {
            for (int x = -kernelExtents; x <= kernelExtents; x++) {
                int sampleX = Mathf.Clamp (x, 0, kernelExtents);
                penaltiesHorizontalPass [0, y] += grid [sampleX, y].movementPenalty;
            }

            for (int x = 1; x < gridSizeX; x++) {
                int removeIndex = Mathf.Clamp(x - kernelExtents - 1, 0, gridSizeX);
                int addIndex = Mathf.Clamp(x + kernelExtents, 0, gridSizeX-1);

                penaltiesHorizontalPass [x, y] = penaltiesHorizontalPass [x - 1, y] - grid [removeIndex, y].movementPenalty + grid [addIndex, y].movementPenalty;
            }
        }

cause for this it should go vertically right not horizontal correct me if i'am wrong

ahmedsaid12345 commented 4 years ago

i'am sorry i was wrong cause i always think the rows should go vertically