Prevent ants from picking up the surface they walk on

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.
This commit is contained in:
Jared Miller 2026-03-12 10:16:14 -04:00
parent 328f8a76e2
commit 5d25218433
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -337,20 +337,27 @@ void main() {
float aheadMatId = texture(tWorld, aheadUv).x; float aheadMatId = texture(tWorld, aheadUv).x;
int aheadMatInt = int(aheadMatId); int aheadMatInt = int(aheadMatId);
// food: pick up from any adjacent cell
if (aheadMatInt == MAT_FOOD) { if (aheadMatInt == MAT_FOOD) {
isCarrying = 1.; isCarrying = 1.;
cargoMaterialId = aheadMatId; cargoMaterialId = aheadMatId;
angle += PI; angle += PI;
storage = getMaxScentStorage(vUv); storage = getMaxScentStorage(vUv);
} else if (aheadMatInt != MAT_AIR && aheadMatInt != MAT_HOME) { } else if (aheadMatInt != MAT_AIR && aheadMatInt != MAT_HOME) {
vec4 props = texelFetch(uMaterialProps, ivec2(aheadMatInt, 0), 0); // powder: don't grab the surface we're walking on — only dig
float behavior = props.r; // when facing diagonally into material (DIG priority angles us there)
float hardness = props.b; vec2 belowCell = roundUvToCellCenter(pos - vec2(0., cellSize));
if (behavior == BEHAVIOR_POWDER && hardness <= ANT_CARRY_STRENGTH) { bool isWalkingSurface = all(equal(aheadUv, belowCell));
isCarrying = 1.; if (!isWalkingSurface) {
cargoMaterialId = aheadMatId; vec4 props = texelFetch(uMaterialProps, ivec2(aheadMatInt, 0), 0);
angle += PI; float behavior = props.r;
storage = getMaxScentStorage(vUv); float hardness = props.b;
if (behavior == BEHAVIOR_POWDER && hardness <= ANT_CARRY_STRENGTH) {
isCarrying = 1.;
cargoMaterialId = aheadMatId;
angle += PI;
storage = getMaxScentStorage(vUv);
}
} }
} }
} }