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:
parent
328f8a76e2
commit
5d25218433
1 changed files with 15 additions and 8 deletions
|
|
@ -337,12 +337,18 @@ 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) {
|
||||
// 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;
|
||||
|
|
@ -354,6 +360,7 @@ void main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end !isFalling
|
||||
|
||||
FragColor = vec4(
|
||||
|
|
|
|||
Loading…
Reference in a new issue