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