Changes between Version 1 and Version 2 of Ticket #4338


Ignore:
Timestamp:
Sep 10, 2017, 9:57:54 PM (7 years ago)
Author:
temple
Comment:

There's a big bug in placer.js. It stores the previous coordinates like this:

resultObjs.push(new Entity(this.type, player, x, z, angle));

In entity.js these are converted to meters rather than tiles:

this.position = {
	x: x * CELL_SIZE,
	y: 0,
	z: z * CELL_SIZE
};

But then in player.js when testing for avoidSelf it mixes the two instead of dividing the position by CELL_SIZE:

var dx = x - resultObjs[i].position.x;
var dy = z - resultObjs[i].position.z;

So, for example:

x = 60.534041579297785, z = 104.47036333882323
resultObjs pos x = 243.887196250026, z = 425.05100603813344
dx = -183.3531546707282, dy = -320.5806426993102

The avoidSelf check literally never fails.

if (dx*dx + dy*dy < 1)
	fail = true;

So we see berry bushes overlapping even though they have an avoidSelf check. (There probably should be a max radius involved here instead of always checking < 1 tile.)

For big and small stones, each SimpleObject in the SimpleGroup is checked against itself rather than also against previous things, so even if the avoidSelf check had been working we would still have this problem. And again, even if that too had been working it only checks within one tile, and large stones have a 20m = 5 tile diameter and small stones a 10m = 2.5 tile diameter, so they could still overlap. (Their obstructions are squares with sides 13m and 7m.)

[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],

This stuff needs a little help. :)

Legend:

Unmodified
Added
Removed
Modified