-/*\r
-Copyright (c) 2001, Loki software, inc.\r
-All rights reserved.\r
-\r
-Redistribution and use in source and binary forms, with or without modification, \r
-are permitted provided that the following conditions are met:\r
-\r
-Redistributions of source code must retain the above copyright notice, this list \r
-of conditions and the following disclaimer.\r
-\r
-Redistributions in binary form must reproduce the above copyright notice, this\r
-list of conditions and the following disclaimer in the documentation and/or\r
-other materials provided with the distribution.\r
-\r
-Neither the name of Loki software nor the names of its contributors may be used \r
-to endorse or promote products derived from this software without specific prior \r
-written permission. \r
-\r
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' \r
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \r
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE \r
-DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY \r
-DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \r
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS \r
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
-*/\r
-\r
-#include "stdafx.h"\r
-\r
-bfilter_t *FilterAdd(bfilter_t *pFilter, int type, int bmask, char *str, int exclude)\r
-{\r
- bfilter_t *pNew = new bfilter_t;\r
- pNew->next = pFilter;\r
- pNew->attribute = type;\r
- if (type == 1 || type == 3) pNew->string = str;\r
- if (type == 2 || type == 4) pNew->mask = bmask;\r
- if (g_qeglobals.d_savedinfo.exclude & exclude)\r
- pNew->active = true;\r
- else\r
- pNew->active = false;\r
- return pNew;\r
-}\r
-\r
- // removes the filter list at *pFilter, returns NULL pointer\r
-bfilter_t *FilterListDelete(bfilter_t *pFilter)\r
-{\r
- if (pFilter != NULL)\r
- {\r
- FilterListDelete(pFilter->next);\r
- delete pFilter;\r
- }\r
- return NULL;\r
-}\r
-\r
-\r
- //spog - FilterUpdate is called each time the filters are changed by menu or shortcuts\r
-bfilter_t *FilterUpdate(bfilter_t *pFilter)\r
-{\r
- pFilter = FilterAdd(pFilter,1,0,"clip",EXCLUDE_CLIP);\r
- pFilter = FilterAdd(pFilter,1,0,"caulk",EXCLUDE_CAULK);\r
- pFilter = FilterAdd(pFilter,1,0,"liquids",EXCLUDE_LIQUIDS);\r
- pFilter = FilterAdd(pFilter,1,0,"hint",EXCLUDE_HINTSSKIPS);\r
- pFilter = FilterAdd(pFilter,1,0,"clusterportal",EXCLUDE_CLUSTERPORTALS);\r
- pFilter = FilterAdd(pFilter,1,0,"areaportal",EXCLUDE_AREAPORTALS);\r
- pFilter = FilterAdd(pFilter,2,QER_TRANS,NULL,EXCLUDE_TRANSLUCENT);\r
- pFilter = FilterAdd(pFilter,3,0,"trigger",EXCLUDE_TRIGGERS);\r
- pFilter = FilterAdd(pFilter,3,0,"misc_model",EXCLUDE_MODELS);\r
- pFilter = FilterAdd(pFilter,3,0,"misc_gamemodel",EXCLUDE_MODELS);\r
- pFilter = FilterAdd(pFilter,4,ECLASS_LIGHT,NULL,EXCLUDE_LIGHTS);\r
- pFilter = FilterAdd(pFilter,4,ECLASS_PATH,NULL,EXCLUDE_PATHS);\r
- pFilter = FilterAdd(pFilter,1,0,"lightgrid",EXCLUDE_LIGHTGRID);\r
- pFilter = FilterAdd(pFilter,1,0,"botclip",EXCLUDE_BOTCLIP);\r
- pFilter = FilterAdd(pFilter,1,0,"clipmonster",EXCLUDE_BOTCLIP);\r
- return pFilter;\r
-}\r
-\r
-/*\r
-==================\r
-FilterBrush\r
-==================\r
-*/\r
-\r
-bool FilterBrush(brush_t *pb)\r
-{\r
- \r
- if (!pb->owner)\r
- return FALSE; // during construction\r
- \r
- if (pb->hiddenBrush)\r
- return TRUE;\r
- \r
- if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD)\r
- {\r
- if (strcmp(pb->owner->eclass->name, "worldspawn") == 0 || !strcmp(pb->owner->eclass->name,"func_group")) // hack, treating func_group as world\r
- {\r
- return TRUE;\r
- }\r
- }\r
- \r
- if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT)\r
- {\r
- if (strcmp(pb->owner->eclass->name, "worldspawn") != 0 && strcmp(pb->owner->eclass->name,"func_group")) // hack, treating func_group as world\r
- {\r
- return TRUE;\r
- }\r
- }\r
- \r
- if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_CURVES )\r
- {\r
- if (pb->patchBrush)\r
- {\r
- return TRUE;\r
- }\r
- }\r
- \r
- \r
- if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_DETAILS )\r
- {\r
- if (!pb->patchBrush && pb->brush_faces->texdef.contents & CONTENTS_DETAIL )\r
- {\r
- return TRUE;\r
- }\r
- }\r
- if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_STRUCTURAL )\r
- {\r
- if (!pb->patchBrush && !( pb->brush_faces->texdef.contents & CONTENTS_DETAIL ))\r
- {\r
- return TRUE;\r
- }\r
- }\r
- \r
- // if brush belongs to world entity or a brushmodel entity and is not a patch\r
- if ( ( strcmp(pb->owner->eclass->name, "worldspawn") == 0\r
- || !strncmp( pb->owner->eclass->name, "func", 4)\r
- || !strncmp( pb->owner->eclass->name, "trigger", 7) ) && !pb->patchBrush )\r
- {\r
- bool filterbrush;\r
- for (face_t *f=pb->brush_faces;f!=NULL;f = f->next)\r
- {\r
- filterbrush=false;\r
- for (bfilter_t *filters = g_qeglobals.d_savedinfo.filters;\r
- filters != NULL;\r
- filters = filters->next)\r
- {\r
- // exclude by attribute 1 brush->face->pShader->getName()\r
- if (filters->active && filters->attribute == 1)\r
- {\r
- if (strstr(f->pShader->getName(),filters->string))\r
- {\r
- filterbrush=true;\r
- break;\r
- }\r
- }\r
- // exclude by attribute 2 brush->face->pShader->getFlags()\r
- else if (filters->active\r
- && filters->attribute == 2)\r
- {\r
- if (f->pShader->getFlags() & filters->mask)\r
- {\r
- filterbrush=true;\r
- break;\r
- }\r
- }\r
- }\r
- if (!filterbrush)\r
- break;\r
- }\r
- if (filterbrush)// if no face is found that should not be excluded\r
- return true; // exclude this brush\r
- }\r
-\r
- // if brush is a patch\r
- if ( pb->patchBrush )\r
- {\r
- bool drawpatch=true;\r
- for (bfilter_t *filters = g_qeglobals.d_savedinfo.filters;\r
- filters != NULL;\r
- filters = filters->next)\r
- {\r
- // exclude by attribute 1 (for patch) brush->pPatch->pShader->getName()\r
- if (filters->active\r
- && filters->attribute == 1)\r
- {\r
- if (strstr(pb->pPatch->pShader->getName(),filters->string))\r
- {\r
- drawpatch=false;\r
- break;\r
- }\r
- }\r
- \r
- // exclude by attribute 2 (for patch) brush->pPatch->pShader->getFlags()\r
- if (filters->active\r
- && filters->attribute == 2)\r
- {\r
- if (pb->pPatch->pShader->getFlags() & filters->mask)\r
- {\r
- drawpatch=false;\r
- break;\r
- }\r
- }\r
- }\r
- if (!drawpatch) // if a shader is found that should be excluded\r
- return TRUE; // exclude this patch\r
- }\r
- \r
- if (strcmp(pb->owner->eclass->name, "worldspawn") != 0) // if brush does not belong to world entity\r
- {\r
- bool drawentity=true;\r
- for (bfilter_t *filters = g_qeglobals.d_savedinfo.filters;\r
- filters != NULL;\r
- filters = filters->next)\r
- {\r
- // exclude by attribute 3 brush->owner->eclass->name\r
- if (filters->active\r
- && filters->attribute == 3)\r
- {\r
- if (strstr(pb->owner->eclass->name,filters->string))\r
- {\r
- drawentity=false;\r
- break;\r
- }\r
- }\r
- \r
- // exclude by attribute 4 brush->owner->eclass->nShowFlags\r
- else if (filters->active\r
- && filters->attribute == 4)\r
- {\r
- if ( pb->owner->eclass->nShowFlags & filters->mask )\r
- {\r
- drawentity=false;\r
- break;\r
- }\r
- }\r
- }\r
- if (!drawentity) // if an eclass property is found that should be excluded\r
- return TRUE; // exclude this brush\r
- }\r
- return FALSE;\r
-}\r
+/*
+Copyright (c) 2001, Loki software, inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list
+of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice, this
+list of conditions and the following disclaimer in the documentation and/or
+other materials provided with the distribution.
+
+Neither the name of Loki software nor the names of its contributors may be used
+to endorse or promote products derived from this software without specific prior
+written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "stdafx.h"
+
+bfilter_t *FilterAdd(bfilter_t *pFilter, int type, int bmask, char *str, int exclude)
+{
+ bfilter_t *pNew = new bfilter_t;
+ pNew->next = pFilter;
+ pNew->attribute = type;
+ if (type == 1 || type == 3) pNew->string = str;
+ if (type == 2 || type == 4) pNew->mask = bmask;
+ if (g_qeglobals.d_savedinfo.exclude & exclude)
+ pNew->active = true;
+ else
+ pNew->active = false;
+ return pNew;
+}
+
+ // removes the filter list at *pFilter, returns NULL pointer
+bfilter_t *FilterListDelete(bfilter_t *pFilter)
+{
+ if (pFilter != NULL)
+ {
+ FilterListDelete(pFilter->next);
+ delete pFilter;
+ }
+ return NULL;
+}
+
+
+ //spog - FilterUpdate is called each time the filters are changed by menu or shortcuts
+bfilter_t *FilterUpdate(bfilter_t *pFilter)
+{
+ pFilter = FilterAdd(pFilter,1,0,"clip",EXCLUDE_CLIP);
+ pFilter = FilterAdd(pFilter,1,0,"caulk",EXCLUDE_CAULK);
+ pFilter = FilterAdd(pFilter,1,0,"liquids",EXCLUDE_LIQUIDS);
+ pFilter = FilterAdd(pFilter,1,0,"hint",EXCLUDE_HINTSSKIPS);
+ pFilter = FilterAdd(pFilter,1,0,"clusterportal",EXCLUDE_CLUSTERPORTALS);
+ pFilter = FilterAdd(pFilter,1,0,"areaportal",EXCLUDE_AREAPORTALS);
+ pFilter = FilterAdd(pFilter,2,QER_TRANS,NULL,EXCLUDE_TRANSLUCENT);
+ pFilter = FilterAdd(pFilter,3,0,"trigger",EXCLUDE_TRIGGERS);
+ pFilter = FilterAdd(pFilter,3,0,"misc_model",EXCLUDE_MODELS);
+ pFilter = FilterAdd(pFilter,3,0,"misc_gamemodel",EXCLUDE_MODELS);
+ pFilter = FilterAdd(pFilter,4,ECLASS_LIGHT,NULL,EXCLUDE_LIGHTS);
+ pFilter = FilterAdd(pFilter,4,ECLASS_PATH,NULL,EXCLUDE_PATHS);
+ pFilter = FilterAdd(pFilter,1,0,"lightgrid",EXCLUDE_LIGHTGRID);
+ pFilter = FilterAdd(pFilter,1,0,"botclip",EXCLUDE_BOTCLIP);
+ pFilter = FilterAdd(pFilter,1,0,"clipmonster",EXCLUDE_BOTCLIP);
+ return pFilter;
+}
+
+/*
+==================
+FilterBrush
+==================
+*/
+
+bool FilterBrush(brush_t *pb)
+{
+
+ if (!pb->owner)
+ return FALSE; // during construction
+
+ if (pb->hiddenBrush)
+ return TRUE;
+
+ if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_WORLD)
+ {
+ if (strcmp(pb->owner->eclass->name, "worldspawn") == 0 || !strcmp(pb->owner->eclass->name,"func_group")) // hack, treating func_group as world
+ {
+ return TRUE;
+ }
+ }
+
+ if (g_qeglobals.d_savedinfo.exclude & EXCLUDE_ENT)
+ {
+ if (strcmp(pb->owner->eclass->name, "worldspawn") != 0 && strcmp(pb->owner->eclass->name,"func_group")) // hack, treating func_group as world
+ {
+ return TRUE;
+ }
+ }
+
+ if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_CURVES )
+ {
+ if (pb->patchBrush)
+ {
+ return TRUE;
+ }
+ }
+
+
+ if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_DETAILS )
+ {
+ if (!pb->patchBrush && pb->brush_faces->texdef.contents & CONTENTS_DETAIL )
+ {
+ return TRUE;
+ }
+ }
+ if ( g_qeglobals.d_savedinfo.exclude & EXCLUDE_STRUCTURAL )
+ {
+ if (!pb->patchBrush && !( pb->brush_faces->texdef.contents & CONTENTS_DETAIL ))
+ {
+ return TRUE;
+ }
+ }
+
+ // if brush belongs to world entity or a brushmodel entity and is not a patch
+ if ( ( strcmp(pb->owner->eclass->name, "worldspawn") == 0
+ || !strncmp( pb->owner->eclass->name, "func", 4)
+ || !strncmp( pb->owner->eclass->name, "trigger", 7) ) && !pb->patchBrush )
+ {
+ bool filterbrush;
+ for (face_t *f=pb->brush_faces;f!=NULL;f = f->next)
+ {
+ filterbrush=false;
+ for (bfilter_t *filters = g_qeglobals.d_savedinfo.filters;
+ filters != NULL;
+ filters = filters->next)
+ {
+ // exclude by attribute 1 brush->face->pShader->getName()
+ if (filters->active && filters->attribute == 1)
+ {
+ if (strstr(f->pShader->getName(),filters->string))
+ {
+ filterbrush=true;
+ break;
+ }
+ }
+ // exclude by attribute 2 brush->face->pShader->getFlags()
+ else if (filters->active
+ && filters->attribute == 2)
+ {
+ if (f->pShader->getFlags() & filters->mask)
+ {
+ filterbrush=true;
+ break;
+ }
+ }
+ }
+ if (!filterbrush)
+ break;
+ }
+ if (filterbrush)// if no face is found that should not be excluded
+ return true; // exclude this brush
+ }
+
+ // if brush is a patch
+ if ( pb->patchBrush )
+ {
+ bool drawpatch=true;
+ for (bfilter_t *filters = g_qeglobals.d_savedinfo.filters;
+ filters != NULL;
+ filters = filters->next)
+ {
+ // exclude by attribute 1 (for patch) brush->pPatch->pShader->getName()
+ if (filters->active
+ && filters->attribute == 1)
+ {
+ if (strstr(pb->pPatch->pShader->getName(),filters->string))
+ {
+ drawpatch=false;
+ break;
+ }
+ }
+
+ // exclude by attribute 2 (for patch) brush->pPatch->pShader->getFlags()
+ if (filters->active
+ && filters->attribute == 2)
+ {
+ if (pb->pPatch->pShader->getFlags() & filters->mask)
+ {
+ drawpatch=false;
+ break;
+ }
+ }
+ }
+ if (!drawpatch) // if a shader is found that should be excluded
+ return TRUE; // exclude this patch
+ }
+
+ if (strcmp(pb->owner->eclass->name, "worldspawn") != 0) // if brush does not belong to world entity
+ {
+ bool drawentity=true;
+ for (bfilter_t *filters = g_qeglobals.d_savedinfo.filters;
+ filters != NULL;
+ filters = filters->next)
+ {
+ // exclude by attribute 3 brush->owner->eclass->name
+ if (filters->active
+ && filters->attribute == 3)
+ {
+ if (strstr(pb->owner->eclass->name,filters->string))
+ {
+ drawentity=false;
+ break;
+ }
+ }
+
+ // exclude by attribute 4 brush->owner->eclass->nShowFlags
+ else if (filters->active
+ && filters->attribute == 4)
+ {
+ if ( pb->owner->eclass->nShowFlags & filters->mask )
+ {
+ drawentity=false;
+ break;
+ }
+ }
+ }
+ if (!drawentity) // if an eclass property is found that should be excluded
+ return TRUE; // exclude this brush
+ }
+ return FALSE;
+}