text
stringlengths 0
2.2M
|
---|
bmin[2] = pos[2] - radius;
|
bmax[0] = pos[0] + radius;
|
bmax[1] = pos[1] + height;
|
bmax[2] = pos[2] + radius;
|
const float r2 = dtSqr(radius/cs + 0.5f);
|
const int w = (int)layer.header->width;
|
const int h = (int)layer.header->height;
|
const float ics = 1.0f/cs;
|
const float ich = 1.0f/ch;
|
const float px = (pos[0]-orig[0])*ics;
|
const float pz = (pos[2]-orig[2])*ics;
|
int minx = (int)dtMathFloorf((bmin[0]-orig[0])*ics);
|
int miny = (int)dtMathFloorf((bmin[1]-orig[1])*ich);
|
int minz = (int)dtMathFloorf((bmin[2]-orig[2])*ics);
|
int maxx = (int)dtMathFloorf((bmax[0]-orig[0])*ics);
|
int maxy = (int)dtMathFloorf((bmax[1]-orig[1])*ich);
|
int maxz = (int)dtMathFloorf((bmax[2]-orig[2])*ics);
|
if (maxx < 0) return DT_SUCCESS;
|
if (minx >= w) return DT_SUCCESS;
|
if (maxz < 0) return DT_SUCCESS;
|
if (minz >= h) return DT_SUCCESS;
|
if (minx < 0) minx = 0;
|
if (maxx >= w) maxx = w-1;
|
if (minz < 0) minz = 0;
|
if (maxz >= h) maxz = h-1;
|
for (int z = minz; z <= maxz; ++z)
|
{
|
for (int x = minx; x <= maxx; ++x)
|
{
|
const float dx = (float)(x+0.5f) - px;
|
const float dz = (float)(z+0.5f) - pz;
|
if (dx*dx + dz*dz > r2)
|
continue;
|
const int y = layer.heights[x+z*w];
|
if (y < miny || y > maxy)
|
continue;
|
layer.areas[x+z*w] = areaId;
|
}
|
}
|
return DT_SUCCESS;
|
}
|
dtStatus dtMarkBoxArea(dtTileCacheLayer& layer, const float* orig, const float cs, const float ch,
|
const float* bmin, const float* bmax, const unsigned char areaId)
|
{
|
const int w = (int)layer.header->width;
|
const int h = (int)layer.header->height;
|
const float ics = 1.0f/cs;
|
const float ich = 1.0f/ch;
|
int minx = (int)floorf((bmin[0]-orig[0])*ics);
|
int miny = (int)floorf((bmin[1]-orig[1])*ich);
|
int minz = (int)floorf((bmin[2]-orig[2])*ics);
|
int maxx = (int)floorf((bmax[0]-orig[0])*ics);
|
int maxy = (int)floorf((bmax[1]-orig[1])*ich);
|
int maxz = (int)floorf((bmax[2]-orig[2])*ics);
|
if (maxx < 0) return DT_SUCCESS;
|
if (minx >= w) return DT_SUCCESS;
|
if (maxz < 0) return DT_SUCCESS;
|
if (minz >= h) return DT_SUCCESS;
|
if (minx < 0) minx = 0;
|
if (maxx >= w) maxx = w-1;
|
if (minz < 0) minz = 0;
|
if (maxz >= h) maxz = h-1;
|
for (int z = minz; z <= maxz; ++z)
|
{
|
for (int x = minx; x <= maxx; ++x)
|
{
|
const int y = layer.heights[x+z*w];
|
if (y < miny || y > maxy)
|
continue;
|
layer.areas[x+z*w] = areaId;
|
}
|
}
|
return DT_SUCCESS;
|
}
|
dtStatus dtMarkBoxArea(dtTileCacheLayer& layer, const float* orig, const float cs, const float ch,
|
const float* center, const float* halfExtents, const float* rotAux, const unsigned char areaId)
|
{
|
const int w = (int)layer.header->width;
|
const int h = (int)layer.header->height;
|
const float ics = 1.0f/cs;
|
const float ich = 1.0f/ch;
|
float cx = (center[0] - orig[0])*ics;
|
float cz = (center[2] - orig[2])*ics;
|
float maxr = 1.41f*dtMax(halfExtents[0], halfExtents[2]);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.