Implement more complex area modifications (#260)

This implements rcAreaModification which allows combining of area types when they overlap
and otherwise usage of the area type as a bit mask.
This commit is contained in:
Domenico Albani
2017-03-12 12:18:29 +01:00
committed by Jakob Botsch Nielsen
parent ef3ea40f7a
commit 433986a5a4
15 changed files with 200 additions and 134 deletions
+40 -12
View File
@@ -35,25 +35,53 @@
# define snprintf _snprintf
#endif
unsigned short sampleAreaToFlags(unsigned char area)
{
unsigned char areaType = (area & SAMPLE_POLYAREA_TYPE_MASK);
unsigned short flags = (unsigned short)((areaType == SAMPLE_POLYAREA_TYPE_WATER) ? SAMPLE_POLYFLAGS_SWIM : SAMPLE_POLYFLAGS_WALK);
if((areaType & SAMPLE_POLYAREA_FLAG_DOOR) != 0)
{
flags |= SAMPLE_POLYFLAGS_DOOR;
}
if((areaType & SAMPLE_POLYAREA_FLAG_JUMP) != 0)
{
flags |= SAMPLE_POLYFLAGS_JUMP;
}
return flags;
}
unsigned int SampleDebugDraw::areaToCol(unsigned int area)
{
switch(area)
unsigned int col;
unsigned char ceil = (area & SAMPLE_POLYAREA_TYPE_MASK);
switch(ceil)
{
// Ground (0) : light blue
case SAMPLE_POLYAREA_GROUND: return duRGBA(0, 192, 255, 255);
// Ground : light blue
case SAMPLE_POLYAREA_TYPE_GROUND: col = duRGBA(0, 192, 255, 255); break;
// Water : blue
case SAMPLE_POLYAREA_WATER: return duRGBA(0, 0, 255, 255);
case SAMPLE_POLYAREA_TYPE_WATER: col = duRGBA(0, 0, 255, 255); break;
// Road : brown
case SAMPLE_POLYAREA_ROAD: return duRGBA(50, 20, 12, 255);
// Door : cyan
case SAMPLE_POLYAREA_DOOR: return duRGBA(0, 255, 255, 255);
case SAMPLE_POLYAREA_TYPE_ROAD: col = duRGBA(50, 20, 12, 255); break;
// Grass : green
case SAMPLE_POLYAREA_GRASS: return duRGBA(0, 255, 0, 255);
// Jump : yellow
case SAMPLE_POLYAREA_JUMP: return duRGBA(255, 255, 0, 255);
// Unexpected : red
default: return duRGBA(255, 0, 0, 255);
case SAMPLE_POLYAREA_TYPE_GRASS: col = duRGBA(0, 255, 0, 255); break;
// Unexpected ceil : red
default: col = duRGBA(255, 0, 0, 255); break;
}
if(area & SAMPLE_POLYAREA_FLAG_DOOR)
{
// Door : cyan
col = duLerpCol(col, duRGBA(0, 255, 255, 255), 127);
}
if(area & SAMPLE_POLYAREA_FLAG_JUMP)
{
// Jump : yellow
col = duLerpCol(col, duRGBA(255, 255, 0, 255), 127);
}
return col;
}
Sample::Sample() :