From 3865affb0b2d288befa2f6a121afbb98517d772e Mon Sep 17 00:00:00 2001 From: ac-stef Date: Tue, 28 Jan 2014 01:12:52 +0100 Subject: [PATCH] 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". --- source/src/physics.cpp | 2 ++ source/src/world.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/source/src/physics.cpp b/source/src/physics.cpp index febd1955..06adff5e 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -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) diff --git a/source/src/world.h b/source/src/world.h index 361cc73e..24c75f4a 100644 --- a/source/src/world.h +++ b/source/src/world.h @@ -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)