From 5d2521843386a962078ac52396c41eeafae899b4 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Thu, 12 Mar 2026 10:16:14 -0400 Subject: [PATCH] Prevent ants from picking up the surface they walk on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Angle noise (±12° from wander) caused the ahead-cell pickup check to sample into the sand cell directly below the ant. Ants were grabbing sand on their first frame of existence. Fix: skip powder pickup when the ahead cell equals the cell directly below (the walking surface). Food pickup is still allowed from any adjacent cell. Diagonal dig pickup still works since the DIG priority angles ants at ~40° which targets a diagonal neighbor, not directly below. --- src/shaders/antsCompute.frag | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/shaders/antsCompute.frag b/src/shaders/antsCompute.frag index 3a319b7..443392a 100644 --- a/src/shaders/antsCompute.frag +++ b/src/shaders/antsCompute.frag @@ -337,20 +337,27 @@ void main() { float aheadMatId = texture(tWorld, aheadUv).x; int aheadMatInt = int(aheadMatId); + // food: pick up from any adjacent cell if (aheadMatInt == MAT_FOOD) { isCarrying = 1.; cargoMaterialId = aheadMatId; angle += PI; storage = getMaxScentStorage(vUv); } else if (aheadMatInt != MAT_AIR && aheadMatInt != MAT_HOME) { - vec4 props = texelFetch(uMaterialProps, ivec2(aheadMatInt, 0), 0); - float behavior = props.r; - float hardness = props.b; - if (behavior == BEHAVIOR_POWDER && hardness <= ANT_CARRY_STRENGTH) { - isCarrying = 1.; - cargoMaterialId = aheadMatId; - angle += PI; - storage = getMaxScentStorage(vUv); + // powder: don't grab the surface we're walking on — only dig + // when facing diagonally into material (DIG priority angles us there) + vec2 belowCell = roundUvToCellCenter(pos - vec2(0., cellSize)); + bool isWalkingSurface = all(equal(aheadUv, belowCell)); + if (!isWalkingSurface) { + vec4 props = texelFetch(uMaterialProps, ivec2(aheadMatInt, 0), 0); + float behavior = props.r; + float hardness = props.b; + if (behavior == BEHAVIOR_POWDER && hardness <= ANT_CARRY_STRENGTH) { + isCarrying = 1.; + cargoMaterialId = aheadMatId; + angle += PI; + storage = getMaxScentStorage(vUv); + } } } }