Skip to content

Commit

Permalink
additional way of clipping areas: tagclips
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
ac-stef committed Jan 28, 2014
1 parent c3d4713 commit 3865aff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/src/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions source/src/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3865aff

Please sign in to comment.