use breath first search when finding detail data so that we don't expand to wrong storey.

This commit is contained in:
Mikko Mononen 2010-05-28 06:31:43 +00:00
parent 2aa749c940
commit 4ac6b64050

View File

@ -845,18 +845,22 @@ static void getHeightData(const rcCompactHeightfield& chf,
hp.data[idx] = cs.y;
}
while (stack.size() > 0)
{
/* int cx = stack[0];
int cy = stack[1];
int ci = stack[2];
if (stack.size() >= 3)
memmove(&stack[0], &stack[3], sizeof(int)*(stack.size()-3));
stack.resize(stack.size()-3);*/
static const int RETRACT_SIZE = 256;
int head = 0;
int ci = stack.pop();
int cy = stack.pop();
int cx = stack.pop();
while (head*3 < stack.size())
{
int cx = stack[head*3+0];
int cy = stack[head*3+1];
int ci = stack[head*3+2];
head++;
if (head >= RETRACT_SIZE)
{
head = 0;
if (stack.size() > RETRACT_SIZE*3)
memmove(&stack[0], &stack[RETRACT_SIZE*3], sizeof(int)*(stack.size()-RETRACT_SIZE*3));
stack.resize(stack.size()-RETRACT_SIZE*3);
}
const rcCompactSpan& cs = chf.spans[ci];
for (int dir = 0; dir < 4; ++dir)