Skip to content
Browse files

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".
  • Loading branch information...
ac-stef committed Jan 28, 2014
1 parent c3d4713 commit 3865affb0b2d288befa2f6a121afbb98517d772e
Showing with 9 additions and 0 deletions.
  1. +2 −0 source/src/physics.cpp
  2. +7 −0 source/src/world.h
@@ -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;
@@ -32,6 +32,13 @@ enum // hardcoded texture numbers

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)

0 comments on commit 3865aff

Please sign in to comment.
You can’t perform that action at this time.