additional way of clipping areas: tagclips

In addition to the existing clip- and plclip-entities, this patch provides
a new approach to provide the same: clip areas by tagging cubes.
Each cube of a map has a parameter "tag". All tags in all existing ac maps
are currently zero. It is a leftover from cube 1. This patch uses the tag value
to determine, if a cube (from floor to ceiling) should be forbidden for
players (tag 0x80) or every moving object (tag 0x40). Tagclips have several
advantages over classic clip entities: they are fast to establish (mark
area, then /edittag 0x80) and are "cheap" for the engine. Tagclips do not
increase the number of entities. As tagclips are always floor to ceiling,
they can't be used to build stairs or platforms. Tagclips should be
preferred over clip entities, but can coexist without problems.

Technically, setting the tag value to 0x40 or 0x80 causes the physics
engine to handle the cube like a "solid".
This commit is contained in:
ac-stef
2014-01-28 01:12:52 +01:00
parent c3d4713904
commit 3865affb0b
2 changed files with 9 additions and 0 deletions
+2
View File
@@ -178,11 +178,13 @@ bool collide(physent *d, bool spawn, float drop, float rise, int level) // level
float hi = 127, lo = -128;
const float eyeheight = d->eyeheight;
const float playerheight = eyeheight + d->aboveeye;
const int applyclip = d->type == ENT_PLAYER ? TAGCLIP|TAGPLCLIP : TAGCLIP;
if(level&1) for(int y = y1; y<=y2; y++) for(int x = x1; x<=x2; x++) // collide with map
{
if(OUTBORD(x,y)) return true;
sqr *s = S(x,y);
if(s->tag & applyclip) return true; // tagged clips feel like solids
float ceil = s->ceil;
float floor = s->floor;
switch(s->type)
+7
View File
@@ -32,6 +32,13 @@ enum // hardcoded texture numbers
DEFAULT_CEIL
};
enum // stuff encoded in sqr.tag
{
TAGTRIGGERMASK = 0x3F, // room for old fashioned cube 1 triggers
TAGCLIP = 0x40, // clips all objects
TAGPLCLIP = 0x80 // clips only players
};
#define MAXMAPVERSION 10 // defines the highest readable format
#define MAPVERSION 9 // default map format version to be written (bump if map format changes, see worldio.cpp)