2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
// world.c -- world query functions
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
#include "quakedef.h"
|
|
|
|
#include "pr_common.h"
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-11-17 00:15:44 +00:00
|
|
|
#if defined(CSQC_DAT) || !defined(CLIENTONLY)
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
entities never clip against themselves, or their owner
|
|
|
|
|
|
|
|
line of sight checks trace->crosscontent, but bullets don't
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2007-10-05 18:08:47 +00:00
|
|
|
extern cvar_t sv_compatiblehulls;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
vec3_t boxmins, boxmaxs;// enclose the test object along entire move
|
|
|
|
float *mins, *maxs; // size of the moving object
|
|
|
|
vec3_t mins2, maxs2; // size when clipping against mosnters
|
|
|
|
float *start, *end;
|
|
|
|
trace_t trace;
|
|
|
|
int type;
|
2012-01-17 07:57:46 +00:00
|
|
|
int hitcontentsmask;
|
2009-11-04 21:16:50 +00:00
|
|
|
wedict_t *passedict;
|
2004-08-23 00:15:46 +00:00
|
|
|
#ifdef Q2SERVER
|
|
|
|
q2edict_t *q2passedict;
|
|
|
|
#endif
|
|
|
|
int hullnum;
|
|
|
|
} moveclip_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
HULL BOXES
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static hull_t box_hull;
|
2011-06-29 18:39:11 +00:00
|
|
|
static mclipnode_t box_clipnodes[6];
|
2004-08-23 00:15:46 +00:00
|
|
|
static mplane_t box_planes[6];
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
SV_InitBoxHull
|
|
|
|
|
|
|
|
Set up the planes and clipnodes so that the six floats of a bounding box
|
|
|
|
can just be stored out and get a proper hull_t structure.
|
|
|
|
===================
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
static void World_InitBoxHull (void)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int side;
|
|
|
|
|
|
|
|
box_hull.clipnodes = box_clipnodes;
|
|
|
|
box_hull.planes = box_planes;
|
|
|
|
box_hull.firstclipnode = 0;
|
|
|
|
box_hull.lastclipnode = 5;
|
|
|
|
|
|
|
|
for (i=0 ; i<6 ; i++)
|
|
|
|
{
|
|
|
|
box_clipnodes[i].planenum = i;
|
|
|
|
|
|
|
|
side = i&1;
|
|
|
|
|
|
|
|
box_clipnodes[i].children[side] = Q1CONTENTS_EMPTY;
|
|
|
|
if (i != 5)
|
|
|
|
box_clipnodes[i].children[side^1] = i + 1;
|
|
|
|
else
|
|
|
|
box_clipnodes[i].children[side^1] = Q1CONTENTS_SOLID;
|
|
|
|
|
|
|
|
box_planes[i].type = i>>1;
|
|
|
|
box_planes[i].normal[i>>1] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
SV_HullForBox
|
|
|
|
|
|
|
|
To keep everything totally uniform, bounding boxes are turned into small
|
|
|
|
BSP trees instead of being compared directly.
|
|
|
|
===================
|
|
|
|
*/
|
2012-07-05 19:42:36 +00:00
|
|
|
hull_t *World_HullForBox (vec3_t mins, vec3_t maxs)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
box_planes[0].dist = maxs[0];
|
|
|
|
box_planes[1].dist = mins[0];
|
|
|
|
box_planes[2].dist = maxs[1];
|
|
|
|
box_planes[3].dist = mins[1];
|
|
|
|
box_planes[4].dist = maxs[2];
|
|
|
|
box_planes[5].dist = mins[2];
|
|
|
|
|
|
|
|
return &box_hull;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
ENTITY AREA CHECKING
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
SV_CreateAreaNode
|
|
|
|
|
|
|
|
===============
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
static areanode_t *World_CreateAreaNode (world_t *w, int depth, vec3_t mins, vec3_t maxs)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
areanode_t *anode;
|
|
|
|
vec3_t size;
|
|
|
|
vec3_t mins1, maxs1, mins2, maxs2;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
anode = &w->areanodes[w->numareanodes];
|
|
|
|
w->numareanodes++;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2011-06-29 18:39:11 +00:00
|
|
|
ClearLink (&anode->edicts);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (depth == AREA_DEPTH)
|
|
|
|
{
|
|
|
|
anode->axis = -1;
|
|
|
|
anode->children[0] = anode->children[1] = NULL;
|
|
|
|
return anode;
|
|
|
|
}
|
|
|
|
|
|
|
|
VectorSubtract (maxs, mins, size);
|
|
|
|
if (size[0] > size[1])
|
|
|
|
anode->axis = 0;
|
|
|
|
else
|
|
|
|
anode->axis = 1;
|
|
|
|
|
|
|
|
anode->dist = 0.5 * (maxs[anode->axis] + mins[anode->axis]);
|
|
|
|
VectorCopy (mins, mins1);
|
|
|
|
VectorCopy (mins, mins2);
|
|
|
|
VectorCopy (maxs, maxs1);
|
|
|
|
VectorCopy (maxs, maxs2);
|
|
|
|
|
|
|
|
maxs1[anode->axis] = mins2[anode->axis] = anode->dist;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
anode->children[0] = World_CreateAreaNode (w, depth+1, mins2, maxs2);
|
|
|
|
anode->children[1] = World_CreateAreaNode (w, depth+1, mins1, maxs1);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
return anode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
SV_ClearWorld
|
|
|
|
|
|
|
|
===============
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
void World_ClearWorld (world_t *w)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
World_InitBoxHull ();
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
memset (w->areanodes, 0, sizeof(w->areanodes));
|
|
|
|
w->numareanodes = 0;
|
2009-11-07 13:29:15 +00:00
|
|
|
if (!w->worldmodel)
|
|
|
|
{
|
|
|
|
vec3_t mins, maxs;
|
|
|
|
VectorSet(mins, -4096, -4096, -4096);
|
|
|
|
VectorSet(maxs, 4096, 4096, 4096);
|
|
|
|
World_CreateAreaNode (w, 0, mins, maxs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
World_CreateAreaNode (w, 0, w->worldmodel->mins, w->worldmodel->maxs);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
SV_UnlinkEdict
|
|
|
|
|
|
|
|
===============
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
void World_UnlinkEdict (wedict_t *ent)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
if (!ent->area.prev)
|
|
|
|
return; // not linked in anywhere
|
|
|
|
RemoveLink (&ent->area);
|
|
|
|
ent->area.prev = ent->area.next = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
SV_TouchLinks
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
#define MAX_NODELINKS 256 //all this means is that any more than this will not touch.
|
2009-11-04 21:16:50 +00:00
|
|
|
static wedict_t *nodelinks[MAX_NODELINKS];
|
|
|
|
void World_TouchLinks (world_t *w, wedict_t *ent, areanode_t *node)
|
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
link_t *l, *next;
|
2009-11-04 21:16:50 +00:00
|
|
|
wedict_t *touch;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
int linkcount = 0, ln;
|
|
|
|
|
|
|
|
//work out who they are first.
|
2011-06-29 18:39:11 +00:00
|
|
|
for (l = node->edicts.next ; l != &node->edicts ; l = next)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2005-05-26 12:55:34 +00:00
|
|
|
if (linkcount == MAX_NODELINKS)
|
|
|
|
break;
|
2004-08-23 00:15:46 +00:00
|
|
|
next = l->next;
|
|
|
|
touch = EDICT_FROM_AREA(l);
|
|
|
|
if (touch == ent)
|
|
|
|
continue;
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
if (!touch->v->touch || touch->v->solid != SOLID_TRIGGER)
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
if (ent->v->absmin[0] > touch->v->absmax[0]
|
|
|
|
|| ent->v->absmin[1] > touch->v->absmax[1]
|
|
|
|
|| ent->v->absmin[2] > touch->v->absmax[2]
|
|
|
|
|| ent->v->absmax[0] < touch->v->absmin[0]
|
|
|
|
|| ent->v->absmax[1] < touch->v->absmin[1]
|
|
|
|
|| ent->v->absmax[2] < touch->v->absmin[2] )
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
|
|
|
|
2007-09-02 19:55:17 +00:00
|
|
|
if (!((int)ent->xv->dimension_solid & (int)touch->xv->dimension_hit))
|
2004-08-31 23:58:18 +00:00
|
|
|
continue;
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
nodelinks[linkcount++] = touch;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (ln = 0; ln < linkcount; ln++)
|
|
|
|
{
|
|
|
|
touch = nodelinks[ln];
|
|
|
|
|
|
|
|
//make sure nothing moved it away
|
|
|
|
if (touch->isfree)
|
|
|
|
continue;
|
2005-03-28 00:11:59 +00:00
|
|
|
if (!touch->v->touch || touch->v->solid != SOLID_TRIGGER)
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
2009-11-04 21:16:50 +00:00
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
if (ent->v->absmin[0] > touch->v->absmax[0]
|
|
|
|
|| ent->v->absmin[1] > touch->v->absmax[1]
|
|
|
|
|| ent->v->absmin[2] > touch->v->absmax[2]
|
|
|
|
|| ent->v->absmax[0] < touch->v->absmin[0]
|
|
|
|
|| ent->v->absmax[1] < touch->v->absmin[1]
|
|
|
|
|| ent->v->absmax[2] < touch->v->absmin[2] )
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
|
|
|
|
2007-09-02 19:55:17 +00:00
|
|
|
if (!((int)ent->xv->dimension_solid & (int)touch->xv->dimension_hit)) //didn't change did it?...
|
2004-08-31 23:58:18 +00:00
|
|
|
continue;
|
|
|
|
|
2009-11-07 13:29:15 +00:00
|
|
|
w->Event_Touch(w, touch, ent);
|
2004-09-04 17:51:20 +00:00
|
|
|
|
|
|
|
if (ent->isfree)
|
|
|
|
break;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// recurse down both sides
|
2004-09-04 17:51:20 +00:00
|
|
|
if (node->axis == -1 || ent->isfree)
|
2004-08-23 00:15:46 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (ent->v->absmax[node->axis] > node->dist)
|
|
|
|
World_TouchLinks (w, ent, node->children[0]);
|
|
|
|
if (ent->v->absmin[node->axis] < node->dist)
|
|
|
|
World_TouchLinks (w, ent, node->children[1]);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef Q2BSPS
|
2010-07-11 02:22:39 +00:00
|
|
|
void Q2BSP_FindTouchedLeafs(model_t *model, struct pvscache_s *ent, float *mins, float *maxs)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
#define MAX_TOTAL_ENT_LEAFS 128
|
|
|
|
int leafs[MAX_TOTAL_ENT_LEAFS];
|
|
|
|
int clusters[MAX_TOTAL_ENT_LEAFS];
|
|
|
|
int num_leafs;
|
|
|
|
int topnode;
|
|
|
|
int i, j;
|
|
|
|
int area;
|
|
|
|
|
|
|
|
//ent->num_leafs == q2's ent->num_clusters
|
|
|
|
ent->num_leafs = 0;
|
|
|
|
ent->areanum = 0;
|
|
|
|
ent->areanum2 = 0;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (!mins || !maxs)
|
|
|
|
return;
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
//get all leafs, including solids
|
2009-03-03 01:52:30 +00:00
|
|
|
num_leafs = CM_BoxLeafnums (model, mins, maxs,
|
2004-08-23 00:15:46 +00:00
|
|
|
leafs, MAX_TOTAL_ENT_LEAFS, &topnode);
|
|
|
|
|
|
|
|
// set areas
|
|
|
|
for (i=0 ; i<num_leafs ; i++)
|
|
|
|
{
|
2005-08-26 22:56:51 +00:00
|
|
|
clusters[i] = CM_LeafCluster (model, leafs[i]);
|
|
|
|
area = CM_LeafArea (model, leafs[i]);
|
2004-08-23 00:15:46 +00:00
|
|
|
if (area)
|
|
|
|
{ // doors may legally straggle two areas,
|
2009-11-04 21:16:50 +00:00
|
|
|
// but nothing should ever need more than that
|
2004-08-23 00:15:46 +00:00
|
|
|
if (ent->areanum && ent->areanum != area)
|
|
|
|
ent->areanum2 = area;
|
|
|
|
else
|
|
|
|
ent->areanum = area;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_leafs >= MAX_TOTAL_ENT_LEAFS)
|
|
|
|
{ // assume we missed some leafs, and mark by headnode
|
|
|
|
ent->num_leafs = -1;
|
|
|
|
ent->headnode = topnode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ent->num_leafs = 0;
|
|
|
|
for (i=0 ; i<num_leafs ; i++)
|
|
|
|
{
|
|
|
|
if (clusters[i] == -1)
|
|
|
|
continue; // not a visible leaf
|
|
|
|
for (j=0 ; j<i ; j++)
|
|
|
|
if (clusters[j] == clusters[i])
|
|
|
|
break;
|
|
|
|
if (j == i)
|
|
|
|
{
|
|
|
|
if (ent->num_leafs == MAX_ENT_LEAFS)
|
|
|
|
{ // assume we missed some leafs, and mark by headnode
|
|
|
|
ent->num_leafs = -1;
|
|
|
|
ent->headnode = topnode;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->leafnums[ent->num_leafs++] = clusters[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
SV_LinkEdict
|
|
|
|
|
|
|
|
===============
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
void World_LinkEdict (world_t *w, wedict_t *ent, qboolean touch_triggers)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
areanode_t *node;
|
|
|
|
|
|
|
|
if (ent->area.prev)
|
2009-11-04 21:16:50 +00:00
|
|
|
World_UnlinkEdict (ent); // unlink from old position
|
2011-12-05 15:23:40 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (ent == w->edicts)
|
2004-08-23 00:15:46 +00:00
|
|
|
return; // don't add the world
|
|
|
|
|
|
|
|
if (ent->isfree)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// set the abs box
|
2005-03-28 00:11:59 +00:00
|
|
|
if (ent->v->solid == SOLID_BSP &&
|
|
|
|
(ent->v->angles[0] || ent->v->angles[1] || ent->v->angles[2]) )
|
2004-08-23 00:15:46 +00:00
|
|
|
{ // expand for rotation
|
2006-03-23 19:22:12 +00:00
|
|
|
|
|
|
|
#if 1
|
|
|
|
int i;
|
|
|
|
float v;
|
2006-04-02 03:47:06 +00:00
|
|
|
float max;
|
2006-03-23 19:22:12 +00:00
|
|
|
//q2 method
|
|
|
|
max = 0;
|
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
v =fabs( ent->v->mins[i]);
|
|
|
|
if (v > max)
|
|
|
|
max = v;
|
|
|
|
v =fabs( ent->v->maxs[i]);
|
|
|
|
if (v > max)
|
|
|
|
max = v;
|
|
|
|
}
|
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
ent->v->absmin[i] = ent->v->origin[i] - max;
|
|
|
|
ent->v->absmax[i] = ent->v->origin[i] + max;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
int i;
|
|
|
|
|
2004-10-18 10:46:06 +00:00
|
|
|
vec3_t f, r, u;
|
|
|
|
vec3_t mn, mx;
|
2006-03-23 19:22:12 +00:00
|
|
|
|
2004-10-18 10:46:06 +00:00
|
|
|
//we need to link to the correct leaves
|
|
|
|
|
2006-03-23 19:22:12 +00:00
|
|
|
AngleVectors(ent->v->angles, f,r,u);
|
2004-10-18 10:46:06 +00:00
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
mn[0] = DotProduct(ent->v->mins, f);
|
|
|
|
mn[1] = -DotProduct(ent->v->mins, r);
|
|
|
|
mn[2] = DotProduct(ent->v->mins, u);
|
2006-03-23 19:22:12 +00:00
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
mx[0] = DotProduct(ent->v->maxs, f);
|
|
|
|
mx[1] = -DotProduct(ent->v->maxs, r);
|
|
|
|
mx[2] = DotProduct(ent->v->maxs, u);
|
2004-10-18 10:46:06 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2004-10-18 10:46:06 +00:00
|
|
|
if (mn[i] < mx[i])
|
|
|
|
{
|
2005-03-28 00:11:59 +00:00
|
|
|
ent->v->absmin[i] = ent->v->origin[i]+mn[i]-0.1;
|
|
|
|
ent->v->absmax[i] = ent->v->origin[i]+mx[i]+0.1;
|
2004-10-18 10:46:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ //box went inside out
|
2005-03-28 00:11:59 +00:00
|
|
|
ent->v->absmin[i] = ent->v->origin[i]+mx[i]-0.1;
|
|
|
|
ent->v->absmax[i] = ent->v->origin[i]+mn[i]+0.1;
|
2004-10-18 10:46:06 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2006-03-23 19:22:12 +00:00
|
|
|
#endif
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2004-11-17 17:40:05 +00:00
|
|
|
else
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2005-03-28 00:11:59 +00:00
|
|
|
VectorAdd (ent->v->origin, ent->v->mins, ent->v->absmin);
|
|
|
|
VectorAdd (ent->v->origin, ent->v->maxs, ent->v->absmax);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// to make items easier to pick up and allow them to be grabbed off
|
|
|
|
// of shelves, the abs sizes are expanded
|
|
|
|
//
|
2005-03-28 00:11:59 +00:00
|
|
|
if ((int)ent->v->flags & FL_ITEM)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2005-03-28 00:11:59 +00:00
|
|
|
ent->v->absmin[0] -= 15;
|
|
|
|
ent->v->absmin[1] -= 15;
|
2009-03-03 01:52:30 +00:00
|
|
|
ent->v->absmin[2] -= 1;
|
2005-03-28 00:11:59 +00:00
|
|
|
ent->v->absmax[0] += 15;
|
|
|
|
ent->v->absmax[1] += 15;
|
2009-03-03 01:52:30 +00:00
|
|
|
ent->v->absmax[2] += 1;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // because movement is clipped an epsilon away from an actual edge,
|
|
|
|
// we must fully check even when bounding boxes don't quite touch
|
2005-03-28 00:11:59 +00:00
|
|
|
ent->v->absmin[0] -= 1;
|
|
|
|
ent->v->absmin[1] -= 1;
|
|
|
|
ent->v->absmin[2] -= 1;
|
|
|
|
ent->v->absmax[0] += 1;
|
|
|
|
ent->v->absmax[1] += 1;
|
|
|
|
ent->v->absmax[2] += 1;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// link to PVS leafs
|
2013-06-26 00:39:13 +00:00
|
|
|
if (w->worldmodel && !w->worldmodel->needload)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2011-09-03 03:49:43 +00:00
|
|
|
w->worldmodel->funcs.FindTouchedLeafs(w->worldmodel, &ent->pvsinfo, ent->v->absmin, ent->v->absmax);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// find the first node that the ent's box crosses
|
2009-11-04 21:16:50 +00:00
|
|
|
node = w->areanodes;
|
2004-08-23 00:15:46 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (node->axis == -1)
|
|
|
|
break;
|
2005-03-28 00:11:59 +00:00
|
|
|
if (ent->v->absmin[node->axis] > node->dist)
|
2004-08-23 00:15:46 +00:00
|
|
|
node = node->children[0];
|
2005-03-28 00:11:59 +00:00
|
|
|
else if (ent->v->absmax[node->axis] < node->dist)
|
2004-08-23 00:15:46 +00:00
|
|
|
node = node->children[1];
|
|
|
|
else
|
|
|
|
break; // crosses the node
|
|
|
|
}
|
|
|
|
|
|
|
|
// link it in
|
|
|
|
|
2011-06-29 18:39:11 +00:00
|
|
|
InsertLinkBefore (&ent->area, &node->edicts);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// if touch_triggers, touch all entities at this node and decend for more
|
2014-01-17 23:28:48 +00:00
|
|
|
if (touch_triggers && ent->v->solid != SOLID_NOT)
|
2009-11-04 21:16:50 +00:00
|
|
|
World_TouchLinks (w, ent, w->areanodes);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q2SERVER
|
2009-11-04 21:16:50 +00:00
|
|
|
void VARGS WorldQ2_UnlinkEdict(world_t *w, q2edict_t *ent)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
if (!ent->area.prev)
|
|
|
|
return; // not linked in anywhere
|
|
|
|
RemoveLink (&ent->area);
|
|
|
|
ent->area.prev = ent->area.next = NULL;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
void VARGS WorldQ2_LinkEdict(world_t *w, q2edict_t *ent)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
areanode_t *node;
|
|
|
|
int leafs[MAX_TOTAL_ENT_LEAFS];
|
|
|
|
int clusters[MAX_TOTAL_ENT_LEAFS];
|
|
|
|
int num_leafs;
|
|
|
|
int i, j, k;
|
|
|
|
int area;
|
|
|
|
int topnode;
|
|
|
|
|
|
|
|
if (ent->area.prev)
|
2009-11-04 21:16:50 +00:00
|
|
|
WorldQ2_UnlinkEdict (w, ent); // unlink from old position
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (ent == ge->edicts)
|
|
|
|
return; // don't add the world
|
|
|
|
|
|
|
|
if (!ent->inuse)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// set the size
|
|
|
|
VectorSubtract (ent->maxs, ent->mins, ent->size);
|
|
|
|
|
|
|
|
// encode the size into the entity_state for client prediction
|
|
|
|
if (ent->solid == Q2SOLID_BBOX && !(ent->svflags & SVF_DEADMONSTER))
|
|
|
|
{ // assume that x/y are equal and symetric
|
|
|
|
i = ent->maxs[0]/8;
|
|
|
|
if (i<1)
|
|
|
|
i = 1;
|
|
|
|
if (i>31)
|
|
|
|
i = 31;
|
|
|
|
|
|
|
|
// z is not symetric
|
|
|
|
j = (-ent->mins[2])/8;
|
|
|
|
if (j<1)
|
|
|
|
j = 1;
|
|
|
|
if (j>31)
|
|
|
|
j = 31;
|
|
|
|
|
|
|
|
// and z maxs can be negative...
|
|
|
|
k = (ent->maxs[2]+32)/8;
|
|
|
|
if (k<1)
|
|
|
|
k = 1;
|
|
|
|
if (k>63)
|
|
|
|
k = 63;
|
|
|
|
|
|
|
|
ent->s.solid = (k<<10) | (j<<5) | i;
|
|
|
|
}
|
|
|
|
else if (ent->solid == Q2SOLID_BSP)
|
|
|
|
{
|
|
|
|
ent->s.solid = 31; // a solid_bbox will never create this value
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ent->s.solid = 0;
|
|
|
|
|
|
|
|
// set the abs box
|
|
|
|
if (ent->solid == Q2SOLID_BSP &&
|
|
|
|
(ent->s.angles[0] || ent->s.angles[1] || ent->s.angles[2]) )
|
|
|
|
{ // expand for rotation
|
|
|
|
float max, v;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
max = 0;
|
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
v =fabs( ent->mins[i]);
|
|
|
|
if (v > max)
|
|
|
|
max = v;
|
|
|
|
v =fabs( ent->maxs[i]);
|
|
|
|
if (v > max)
|
|
|
|
max = v;
|
|
|
|
}
|
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
ent->absmin[i] = ent->s.origin[i] - max;
|
|
|
|
ent->absmax[i] = ent->s.origin[i] + max;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // normal
|
|
|
|
VectorAdd (ent->s.origin, ent->mins, ent->absmin);
|
|
|
|
VectorAdd (ent->s.origin, ent->maxs, ent->absmax);
|
|
|
|
}
|
|
|
|
|
|
|
|
// because movement is clipped an epsilon away from an actual edge,
|
|
|
|
// we must fully check even when bounding boxes don't quite touch
|
|
|
|
ent->absmin[0] -= 1;
|
|
|
|
ent->absmin[1] -= 1;
|
|
|
|
ent->absmin[2] -= 1;
|
|
|
|
ent->absmax[0] += 1;
|
|
|
|
ent->absmax[1] += 1;
|
|
|
|
ent->absmax[2] += 1;
|
|
|
|
|
|
|
|
// link to PVS leafs
|
|
|
|
ent->num_clusters = 0;
|
|
|
|
ent->areanum = 0;
|
|
|
|
ent->areanum2 = 0;
|
|
|
|
|
|
|
|
//get all leafs, including solids
|
2009-11-04 21:16:50 +00:00
|
|
|
num_leafs = CM_BoxLeafnums (w->worldmodel, ent->absmin, ent->absmax,
|
2004-08-23 00:15:46 +00:00
|
|
|
leafs, MAX_TOTAL_ENT_LEAFS, &topnode);
|
|
|
|
|
|
|
|
// set areas
|
|
|
|
for (i=0 ; i<num_leafs ; i++)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
clusters[i] = CM_LeafCluster (w->worldmodel, leafs[i]);
|
|
|
|
area = CM_LeafArea (w->worldmodel, leafs[i]);
|
2004-08-23 00:15:46 +00:00
|
|
|
if (area)
|
|
|
|
{ // doors may legally straggle two areas,
|
|
|
|
// but nothing should evern need more than that
|
|
|
|
if (ent->areanum && ent->areanum != area)
|
|
|
|
ent->areanum2 = area;
|
|
|
|
else
|
|
|
|
ent->areanum = area;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_leafs >= MAX_TOTAL_ENT_LEAFS)
|
|
|
|
{ // assume we missed some leafs, and mark by headnode
|
|
|
|
ent->num_clusters = -1;
|
|
|
|
ent->headnode = topnode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ent->num_clusters = 0;
|
|
|
|
for (i=0 ; i<num_leafs ; i++)
|
|
|
|
{
|
|
|
|
if (clusters[i] == -1)
|
|
|
|
continue; // not a visible leaf
|
|
|
|
for (j=0 ; j<i ; j++)
|
|
|
|
if (clusters[j] == clusters[i])
|
|
|
|
break;
|
|
|
|
if (j == i)
|
|
|
|
{
|
|
|
|
if (ent->num_clusters == MAX_ENT_CLUSTERS)
|
|
|
|
{ // assume we missed some leafs, and mark by headnode
|
|
|
|
ent->num_clusters = -1;
|
|
|
|
ent->headnode = topnode;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->clusternums[ent->num_clusters++] = clusters[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if first time, make sure old_origin is valid
|
|
|
|
if (!ent->linkcount)
|
|
|
|
{
|
|
|
|
VectorCopy (ent->s.origin, ent->s.old_origin);
|
|
|
|
}
|
|
|
|
ent->linkcount++;
|
|
|
|
|
|
|
|
if (ent->solid == Q2SOLID_NOT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// find the first node that the ent's box crosses
|
2009-11-04 21:16:50 +00:00
|
|
|
node = w->areanodes;
|
2004-08-23 00:15:46 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (node->axis == -1)
|
|
|
|
break;
|
|
|
|
if (ent->absmin[node->axis] > node->dist)
|
|
|
|
node = node->children[0];
|
|
|
|
else if (ent->absmax[node->axis] < node->dist)
|
|
|
|
node = node->children[1];
|
|
|
|
else
|
|
|
|
break; // crosses the node
|
|
|
|
}
|
|
|
|
|
|
|
|
// link it in
|
2011-06-29 18:39:11 +00:00
|
|
|
InsertLinkBefore (&ent->area, &node->edicts);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
void WorldQ2_Q1BSP_LinkEdict(world_t *w, q2edict_t *ent)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
areanode_t *node;
|
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
if (ent->area.prev)
|
2009-11-04 21:16:50 +00:00
|
|
|
WorldQ2_UnlinkEdict (w, ent); // unlink from old position
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (ent == ge->edicts)
|
|
|
|
return; // don't add the world
|
|
|
|
|
|
|
|
if (!ent->inuse)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// set the size
|
|
|
|
VectorSubtract (ent->maxs, ent->mins, ent->size);
|
|
|
|
|
|
|
|
// encode the size into the entity_state for client prediction
|
|
|
|
if (ent->solid == Q2SOLID_BBOX && !(ent->svflags & SVF_DEADMONSTER))
|
|
|
|
{ // assume that x/y are equal and symetric
|
|
|
|
i = ent->maxs[0]/8;
|
|
|
|
if (i<1)
|
|
|
|
i = 1;
|
|
|
|
if (i>31)
|
|
|
|
i = 31;
|
|
|
|
|
|
|
|
// z is not symetric
|
|
|
|
j = (-ent->mins[2])/8;
|
|
|
|
if (j<1)
|
|
|
|
j = 1;
|
|
|
|
if (j>31)
|
|
|
|
j = 31;
|
|
|
|
|
|
|
|
// and z maxs can be negative...
|
|
|
|
k = (ent->maxs[2]+32)/8;
|
|
|
|
if (k<1)
|
|
|
|
k = 1;
|
|
|
|
if (k>63)
|
|
|
|
k = 63;
|
|
|
|
|
|
|
|
ent->s.solid = (k<<10) | (j<<5) | i;
|
|
|
|
}
|
|
|
|
else if (ent->solid == Q2SOLID_BSP)
|
|
|
|
{
|
|
|
|
ent->s.solid = 31; // a solid_bbox will never create this value
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ent->s.solid = 0;
|
|
|
|
|
|
|
|
// set the abs box
|
|
|
|
if (ent->solid == Q2SOLID_BSP &&
|
|
|
|
(ent->s.angles[0] || ent->s.angles[1] || ent->s.angles[2]) )
|
|
|
|
{ // expand for rotation
|
|
|
|
float max, v;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
max = 0;
|
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
v =fabs( ent->mins[i]);
|
|
|
|
if (v > max)
|
|
|
|
max = v;
|
|
|
|
v =fabs( ent->maxs[i]);
|
|
|
|
if (v > max)
|
|
|
|
max = v;
|
|
|
|
}
|
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
ent->absmin[i] = ent->s.origin[i] - max;
|
|
|
|
ent->absmax[i] = ent->s.origin[i] + max;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // normal
|
|
|
|
VectorAdd (ent->s.origin, ent->mins, ent->absmin);
|
|
|
|
VectorAdd (ent->s.origin, ent->maxs, ent->absmax);
|
|
|
|
}
|
|
|
|
|
|
|
|
// because movement is clipped an epsilon away from an actual edge,
|
|
|
|
// we must fully check even when bounding boxes don't quite touch
|
|
|
|
ent->absmin[0] -= 1;
|
|
|
|
ent->absmin[1] -= 1;
|
|
|
|
ent->absmin[2] -= 1;
|
|
|
|
ent->absmax[0] += 1;
|
|
|
|
ent->absmax[1] += 1;
|
|
|
|
ent->absmax[2] += 1;
|
|
|
|
|
|
|
|
// link to PVS leafs
|
|
|
|
ent->num_clusters = 0;
|
|
|
|
ent->areanum = 0;
|
|
|
|
ent->areanum2 = 0;
|
|
|
|
|
|
|
|
|
|
|
|
ent->areanum = 1;
|
|
|
|
/*
|
|
|
|
//get all leafs, including solids
|
|
|
|
num_leafs = CM_BoxLeafnums (ent->absmin, ent->absmax,
|
|
|
|
leafs, MAX_TOTAL_ENT_LEAFS, &topnode);
|
|
|
|
|
|
|
|
// set areas
|
|
|
|
for (i=0 ; i<num_leafs ; i++)
|
|
|
|
{
|
|
|
|
clusters[i] = CM_LeafCluster (leafs[i]);
|
|
|
|
area = CM_LeafArea (leafs[i]);
|
|
|
|
if (area)
|
|
|
|
{ // doors may legally straggle two areas,
|
|
|
|
// but nothing should evern need more than that
|
|
|
|
if (ent->areanum && ent->areanum != area)
|
|
|
|
{
|
|
|
|
ent->areanum2 = area;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ent->areanum = area;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_leafs >= MAX_TOTAL_ENT_LEAFS)
|
|
|
|
{ // assume we missed some leafs, and mark by headnode
|
|
|
|
ent->num_clusters = -1;
|
|
|
|
ent->headnode = topnode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ent->num_clusters = 0;
|
|
|
|
for (i=0 ; i<num_leafs ; i++)
|
|
|
|
{
|
|
|
|
if (clusters[i] == -1)
|
|
|
|
continue; // not a visible leaf
|
|
|
|
for (j=0 ; j<i ; j++)
|
|
|
|
if (clusters[j] == clusters[i])
|
|
|
|
break;
|
|
|
|
if (j == i)
|
|
|
|
{
|
|
|
|
if (ent->num_clusters == MAX_ENT_CLUSTERS)
|
|
|
|
{ // assume we missed some leafs, and mark by headnode
|
|
|
|
ent->num_clusters = -1;
|
|
|
|
ent->headnode = topnode;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->clusternums[ent->num_clusters++] = clusters[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
// if first time, make sure old_origin is valid
|
|
|
|
if (!ent->linkcount)
|
|
|
|
{
|
|
|
|
VectorCopy (ent->s.origin, ent->s.old_origin);
|
|
|
|
}
|
|
|
|
ent->linkcount++;
|
|
|
|
|
|
|
|
if (ent->solid == Q2SOLID_NOT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// find the first node that the ent's box crosses
|
2009-11-04 21:16:50 +00:00
|
|
|
node = w->areanodes;
|
2004-08-23 00:15:46 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (node->axis == -1)
|
|
|
|
break;
|
|
|
|
if (ent->absmin[node->axis] > node->dist)
|
|
|
|
node = node->children[0];
|
|
|
|
else if (ent->absmax[node->axis] < node->dist)
|
|
|
|
node = node->children[1];
|
|
|
|
else
|
|
|
|
break; // crosses the node
|
|
|
|
}
|
|
|
|
|
2011-06-29 18:39:11 +00:00
|
|
|
// link it in
|
|
|
|
InsertLinkBefore (&ent->area, &node->edicts);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
POINT TESTING IN HULLS
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SV_PointContents
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
int World_PointContents (world_t *w, vec3_t p)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-08-28 17:14:38 +00:00
|
|
|
return w->worldmodel->funcs.PointContents(w->worldmodel, NULL, p);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
SV_TestEntityPosition
|
|
|
|
|
|
|
|
A small wrapper around SV_BoxInSolidEntity that never clips against the
|
|
|
|
supplied entity.
|
|
|
|
============
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
wedict_t *World_TestEntityPosition (world_t *w, wedict_t *ent)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
trace_t trace;
|
|
|
|
|
2010-07-11 12:13:40 +00:00
|
|
|
trace = World_Move (w, ent->v->origin, ent->v->mins, ent->v->maxs, ent->v->origin, ((ent->v->solid == SOLID_NOT || ent->v->solid == SOLID_TRIGGER)?MOVE_NOMONSTERS:0), ent);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (trace.startsolid)
|
2009-11-04 21:16:50 +00:00
|
|
|
return w->edicts;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-07-16 00:53:08 +00:00
|
|
|
qboolean Q1BSP_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace);
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
//wrapper function. Rotates the start and end positions around the angles if needed.
|
2005-07-16 00:53:08 +00:00
|
|
|
//qboolean TransformedHullCheck (hull_t *hull, vec3_t start, vec3_t end, trace_t *trace, vec3_t angles)
|
2012-01-17 07:57:46 +00:00
|
|
|
qboolean TransformedTrace (struct model_s *model, int hulloverride, int frame, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, struct trace_s *trace, vec3_t origin, vec3_t angles, unsigned int hitcontentsmask)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
vec3_t start_l, end_l;
|
2010-08-28 17:14:38 +00:00
|
|
|
vec3_t axis[3];
|
2004-08-23 00:15:46 +00:00
|
|
|
qboolean result;
|
|
|
|
|
2005-07-16 00:53:08 +00:00
|
|
|
memset (trace, 0, sizeof(trace_t));
|
|
|
|
trace->fraction = 1;
|
|
|
|
trace->allsolid = false;
|
|
|
|
trace->startsolid = false;
|
|
|
|
trace->inopen = true; //probably wrong...
|
|
|
|
VectorCopy (end, trace->endpos);
|
|
|
|
|
2011-05-20 04:10:46 +00:00
|
|
|
if (IS_NAN(end[0]) || IS_NAN(end[1]) || IS_NAN(end[2]))
|
|
|
|
{
|
|
|
|
Con_DPrintf("Nan in traceline\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
// don't rotate non bsp ents. Too small to bother.
|
2012-11-27 03:23:19 +00:00
|
|
|
if (model && !model->needload)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-08-28 17:14:38 +00:00
|
|
|
VectorSubtract (start, origin, start_l);
|
|
|
|
VectorSubtract (end, origin, end_l);
|
2005-07-16 00:53:08 +00:00
|
|
|
|
2010-08-28 17:14:38 +00:00
|
|
|
if (angles[0] || angles[1] || angles[2])
|
|
|
|
{
|
|
|
|
AngleVectors (angles, axis[0], axis[1], axis[2]);
|
|
|
|
VectorNegate(axis[1], axis[1]);
|
2012-01-17 07:57:46 +00:00
|
|
|
result = model->funcs.NativeTrace (model, hulloverride, frame, axis, start_l, end_l, mins, maxs, hitcontentsmask, trace);
|
2005-07-16 00:53:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-17 07:57:46 +00:00
|
|
|
result = model->funcs.NativeTrace (model, hulloverride, frame, NULL, start_l, end_l, mins, maxs, hitcontentsmask, trace);
|
2005-07-16 00:53:08 +00:00
|
|
|
}
|
|
|
|
|
2010-08-28 17:14:38 +00:00
|
|
|
VectorAdd (trace->endpos, origin, trace->endpos);
|
2006-03-06 01:41:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hull_t *hull = &box_hull;
|
|
|
|
|
|
|
|
memset (trace, 0, sizeof(trace_t));
|
|
|
|
trace->fraction = 1;
|
|
|
|
trace->allsolid = true;
|
|
|
|
|
|
|
|
VectorSubtract (start, origin, start_l);
|
|
|
|
VectorSubtract (end, origin, end_l);
|
|
|
|
VectorCopy (end_l, trace->endpos);
|
|
|
|
result = Q1BSP_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l, trace);
|
|
|
|
VectorAdd (trace->endpos, origin, trace->endpos);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean TransformedNativeTrace (struct model_s *model, int hulloverride, int frame, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, unsigned int against, struct trace_s *trace, vec3_t origin, vec3_t angles)
|
|
|
|
{
|
|
|
|
vec3_t start_l, end_l;
|
2010-08-28 17:14:38 +00:00
|
|
|
vec3_t axis[3];
|
2006-03-06 01:41:09 +00:00
|
|
|
qboolean result;
|
|
|
|
|
|
|
|
memset (trace, 0, sizeof(trace_t));
|
|
|
|
trace->fraction = 1;
|
|
|
|
trace->allsolid = false;
|
|
|
|
trace->startsolid = false;
|
|
|
|
trace->inopen = true; //probably wrong...
|
|
|
|
VectorCopy (end, trace->endpos);
|
|
|
|
|
|
|
|
// don't rotate non bsp ents. Too small to bother.
|
|
|
|
if (model)
|
|
|
|
{
|
2010-08-28 17:14:38 +00:00
|
|
|
VectorSubtract (start, origin, start_l);
|
|
|
|
VectorSubtract (end, origin, end_l);
|
|
|
|
if (angles[0] || angles[1] || angles[2])
|
2006-03-06 01:41:09 +00:00
|
|
|
{
|
2010-08-28 17:14:38 +00:00
|
|
|
AngleVectors (angles, axis[0], axis[1], axis[2]);
|
|
|
|
VectorNegate(axis[1], axis[1]);
|
|
|
|
result = model->funcs.NativeTrace (model, hulloverride, frame, axis, start_l, end_l, mins, maxs, against, trace);
|
2006-03-06 01:41:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-28 17:14:38 +00:00
|
|
|
result = model->funcs.NativeTrace (model, hulloverride, frame, NULL, start_l, end_l, mins, maxs, against, trace);
|
2005-07-16 00:53:08 +00:00
|
|
|
}
|
|
|
|
VectorAdd (trace->endpos, origin, trace->endpos);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
else
|
2005-07-16 00:53:08 +00:00
|
|
|
{
|
|
|
|
hull_t *hull = &box_hull;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2005-07-16 00:53:08 +00:00
|
|
|
memset (trace, 0, sizeof(trace_t));
|
|
|
|
trace->fraction = 1;
|
|
|
|
trace->allsolid = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2005-07-16 00:53:08 +00:00
|
|
|
VectorSubtract (start, origin, start_l);
|
|
|
|
VectorSubtract (end, origin, end_l);
|
2005-08-26 22:56:51 +00:00
|
|
|
VectorCopy (end_l, trace->endpos);
|
2005-07-16 00:53:08 +00:00
|
|
|
result = Q1BSP_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l, trace);
|
|
|
|
VectorAdd (trace->endpos, origin, trace->endpos);
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2005-07-16 00:53:08 +00:00
|
|
|
return result;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SV_ClipMoveToEntity
|
|
|
|
|
|
|
|
Handles selection or creation of a clipping hull, and offseting (and
|
|
|
|
eventually rotation) of the end points
|
|
|
|
==================
|
|
|
|
*/
|
2012-01-17 07:57:46 +00:00
|
|
|
static trace_t World_ClipMoveToEntity (world_t *w, wedict_t *ent, vec3_t eorg, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int hullnum, qboolean hitmodel, unsigned int hitcontentsmask) //hullnum overrides min/max for q1 style bsps
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
trace_t trace;
|
2005-07-16 00:53:08 +00:00
|
|
|
model_t *model;
|
2012-02-15 13:53:30 +00:00
|
|
|
int mdlidx = ent->v->modelindex;
|
2004-11-19 17:42:54 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
// get the clipping hull
|
2013-12-29 22:48:28 +00:00
|
|
|
if ((ent->v->solid == SOLID_BSP || ent->v->solid == SOLID_PORTAL) && mdlidx)
|
2005-07-16 00:53:08 +00:00
|
|
|
{
|
2012-02-15 13:53:30 +00:00
|
|
|
model = w->Get_CModel(w, mdlidx);
|
2005-08-26 22:56:51 +00:00
|
|
|
if (!model || (model->type != mod_brush && model->type != mod_heightmap))
|
2013-03-12 23:24:15 +00:00
|
|
|
{
|
|
|
|
// Host_Error("SOLID_BSP with non bsp model (classname: %s)", PR_GetString(w->progs, ent->v->classname));
|
|
|
|
model = NULL;
|
|
|
|
}
|
2005-07-16 00:53:08 +00:00
|
|
|
}
|
|
|
|
else
|
2013-03-12 23:24:15 +00:00
|
|
|
model = NULL;
|
|
|
|
|
2013-04-04 02:42:29 +00:00
|
|
|
if (!model)
|
2005-07-16 00:53:08 +00:00
|
|
|
{
|
|
|
|
vec3_t boxmins, boxmaxs;
|
|
|
|
VectorSubtract (ent->v->mins, maxs, boxmins);
|
|
|
|
VectorSubtract (ent->v->maxs, mins, boxmaxs);
|
2009-11-04 21:16:50 +00:00
|
|
|
World_HullForBox(boxmins, boxmaxs);
|
2005-07-16 00:53:08 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// trace a line through the apropriate clipping hull
|
2013-12-29 22:48:28 +00:00
|
|
|
if (ent->v->solid == SOLID_PORTAL)
|
|
|
|
{
|
|
|
|
//solid_portal cares only about origins and as such has no mins/max
|
|
|
|
TransformedTrace(model, 0, ent->v->frame, start, end, vec3_origin, vec3_origin, &trace, eorg, ent->v->angles, hitcontentsmask);
|
|
|
|
hitmodel = false;
|
|
|
|
}
|
|
|
|
else if (ent->v->solid != SOLID_BSP)
|
2004-11-17 17:40:05 +00:00
|
|
|
{
|
2006-03-23 19:22:12 +00:00
|
|
|
ent->v->angles[0]*=-1; //carmack made bsp models rotate wrongly.
|
2012-01-17 07:57:46 +00:00
|
|
|
TransformedTrace(model, hullnum, ent->v->frame, start, end, mins, maxs, &trace, eorg, ent->v->angles, hitcontentsmask);
|
2005-03-28 00:11:59 +00:00
|
|
|
ent->v->angles[0]*=-1;
|
2004-11-17 17:40:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-17 07:57:46 +00:00
|
|
|
TransformedTrace(model, hullnum, ent->v->frame, start, end, mins, maxs, &trace, eorg, ent->v->angles, hitcontentsmask);
|
2004-11-17 17:40:05 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2012-01-17 07:57:46 +00:00
|
|
|
// if using hitmodel, we know it hit the bounding box, so try a proper trace now.
|
2012-02-15 13:53:30 +00:00
|
|
|
if (hitmodel && trace.fraction != 1 && ent->v->solid != SOLID_BSP && mdlidx != 0)
|
2005-07-16 00:53:08 +00:00
|
|
|
{
|
2012-01-17 07:57:46 +00:00
|
|
|
//okay, we hit the bbox
|
2012-02-15 13:53:30 +00:00
|
|
|
model = w->Get_CModel(w, mdlidx);
|
2005-07-16 00:53:08 +00:00
|
|
|
|
2012-01-17 07:57:46 +00:00
|
|
|
if (model && model->funcs.NativeTrace)
|
|
|
|
{
|
|
|
|
//do the second trace
|
|
|
|
TransformedTrace(model, hullnum, ent->v->frame, start, end, mins, maxs, &trace, eorg, ent->v->angles, hitcontentsmask);
|
2005-07-16 00:53:08 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// did we clip the move?
|
2012-01-17 07:57:46 +00:00
|
|
|
if (trace.fraction < 1 || trace.startsolid)
|
2004-08-23 00:15:46 +00:00
|
|
|
trace.ent = ent;
|
|
|
|
|
|
|
|
return trace;
|
|
|
|
}
|
|
|
|
#ifdef Q2SERVER
|
2012-01-17 07:57:46 +00:00
|
|
|
static trace_t WorldQ2_ClipMoveToEntity (world_t *w, q2edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, unsigned int hitcontentsmask)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
trace_t trace;
|
2005-08-03 23:14:59 +00:00
|
|
|
model_t *model;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// get the clipping hull
|
2005-08-03 23:14:59 +00:00
|
|
|
if (ent->s.solid == Q2SOLID_BSP)
|
|
|
|
{
|
2011-10-27 16:16:29 +00:00
|
|
|
model = w->Get_CModel(w, ent->s.modelindex);
|
2005-08-03 23:14:59 +00:00
|
|
|
if (!model || model->type != mod_brush)
|
|
|
|
SV_Error("SOLID_BSP with non bsp model");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vec3_t boxmins, boxmaxs;
|
|
|
|
VectorSubtract (ent->mins, maxs, boxmins);
|
|
|
|
VectorSubtract (ent->maxs, mins, boxmaxs);
|
2009-11-04 21:16:50 +00:00
|
|
|
World_HullForBox(boxmins, boxmaxs);
|
2005-08-03 23:14:59 +00:00
|
|
|
model = NULL;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// trace a line through the apropriate clipping hull
|
2012-01-17 07:57:46 +00:00
|
|
|
TransformedTrace(model, 0, 0, start, end, mins, maxs, &trace, ent->s.origin, ent->s.angles, hitcontentsmask);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// did we clip the move?
|
|
|
|
if (trace.fraction < 1 || trace.startsolid )
|
|
|
|
trace.ent = (edict_t *)ent;
|
2005-08-03 23:14:59 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
return trace;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef Q2BSPS
|
|
|
|
float *area_mins, *area_maxs;
|
2009-11-04 21:16:50 +00:00
|
|
|
wedict_t **area_list;
|
2004-08-23 00:15:46 +00:00
|
|
|
#ifdef Q2SERVER
|
|
|
|
q2edict_t **area_q2list;
|
|
|
|
#endif
|
|
|
|
int area_count, area_maxcount;
|
|
|
|
int area_type;
|
|
|
|
#define AREA_SOLID 1
|
2011-06-29 18:39:11 +00:00
|
|
|
#define AREA_TRIGGER 2
|
2009-11-04 21:16:50 +00:00
|
|
|
static void World_AreaEdicts_r (areanode_t *node)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
link_t *l, *next, *start;
|
2009-11-04 21:16:50 +00:00
|
|
|
wedict_t *check;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// touch linked edicts
|
2011-06-29 18:39:11 +00:00
|
|
|
start = &node->edicts;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
for (l=start->next ; l != start ; l = next)
|
|
|
|
{
|
|
|
|
next = l->next;
|
|
|
|
check = EDICT_FROM_AREA(l);
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
if (check->v->solid == SOLID_NOT)
|
2004-08-23 00:15:46 +00:00
|
|
|
continue; // deactivated
|
2011-06-29 18:39:11 +00:00
|
|
|
|
|
|
|
/*q2 still has solid/trigger lists, emulate that here*/
|
|
|
|
if ((check->v->solid == SOLID_TRIGGER) != (area_type == AREA_TRIGGER))
|
|
|
|
continue;
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
if (check->v->absmin[0] > area_maxs[0]
|
|
|
|
|| check->v->absmin[1] > area_maxs[1]
|
|
|
|
|| check->v->absmin[2] > area_maxs[2]
|
|
|
|
|| check->v->absmax[0] < area_mins[0]
|
|
|
|
|| check->v->absmax[1] < area_mins[1]
|
|
|
|
|| check->v->absmax[2] < area_mins[2])
|
2004-08-23 00:15:46 +00:00
|
|
|
continue; // not touching
|
|
|
|
|
|
|
|
if (area_count == area_maxcount)
|
|
|
|
{
|
|
|
|
Con_Printf ("SV_AreaEdicts: MAXCOUNT\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
area_list[area_count] = check;
|
|
|
|
area_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node->axis == -1)
|
|
|
|
return; // terminal node
|
|
|
|
|
|
|
|
// recurse down both sides
|
|
|
|
if ( area_maxs[node->axis] > node->dist )
|
2009-11-04 21:16:50 +00:00
|
|
|
World_AreaEdicts_r ( node->children[0] );
|
2004-08-23 00:15:46 +00:00
|
|
|
if ( area_mins[node->axis] < node->dist )
|
2009-11-04 21:16:50 +00:00
|
|
|
World_AreaEdicts_r ( node->children[1] );
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SV_AreaEdicts
|
|
|
|
================
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
int World_AreaEdicts (world_t *w, vec3_t mins, vec3_t maxs, wedict_t **list,
|
2004-08-23 00:15:46 +00:00
|
|
|
int maxcount, int areatype)
|
|
|
|
{
|
|
|
|
area_mins = mins;
|
|
|
|
area_maxs = maxs;
|
|
|
|
area_list = list;
|
|
|
|
area_count = 0;
|
|
|
|
area_maxcount = maxcount;
|
|
|
|
area_type = areatype;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
World_AreaEdicts_r (w->areanodes);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
return area_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef Q2SERVER
|
2009-11-04 21:16:50 +00:00
|
|
|
static void WorldQ2_AreaEdicts_r (areanode_t *node)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
link_t *l, *next, *start;
|
|
|
|
q2edict_t *check;
|
|
|
|
|
|
|
|
// touch linked edicts
|
2011-06-29 18:39:11 +00:00
|
|
|
start = &node->edicts;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
for (l=start->next ; l != start ; l = next)
|
|
|
|
{
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
int i;
|
2009-11-04 21:16:50 +00:00
|
|
|
World_ClearWorld(&sv.world);
|
2004-08-23 00:15:46 +00:00
|
|
|
check = ge->edicts;
|
2004-09-15 03:06:20 +00:00
|
|
|
for (i = 0; i < ge->num_edicts; i++, check = (q2edict_t *)((char *)check + ge->edict_size))
|
2004-08-23 00:15:46 +00:00
|
|
|
memset(&check->area, 0, sizeof(check->area));
|
|
|
|
Con_Printf ("SV_AreaEdicts: Bad links\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
next = l->next;
|
|
|
|
check = Q2EDICT_FROM_AREA(l);
|
|
|
|
|
|
|
|
if (check->solid == Q2SOLID_NOT)
|
|
|
|
continue; // deactivated
|
2011-06-29 18:39:11 +00:00
|
|
|
|
|
|
|
/*q2 still has solid/trigger lists, emulate that here*/
|
|
|
|
if ((check->solid == Q2SOLID_TRIGGER) != (area_type == AREA_TRIGGER))
|
|
|
|
continue;
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (check->absmin[0] > area_maxs[0]
|
|
|
|
|| check->absmin[1] > area_maxs[1]
|
|
|
|
|| check->absmin[2] > area_maxs[2]
|
|
|
|
|| check->absmax[0] < area_mins[0]
|
|
|
|
|| check->absmax[1] < area_mins[1]
|
|
|
|
|| check->absmax[2] < area_mins[2])
|
|
|
|
continue; // not touching
|
|
|
|
|
|
|
|
if (area_count == area_maxcount)
|
|
|
|
{
|
|
|
|
Con_Printf ("SV_AreaEdicts: MAXCOUNT\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
area_q2list[area_count] = check;
|
|
|
|
area_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node->axis == -1)
|
|
|
|
return; // terminal node
|
|
|
|
|
|
|
|
// recurse down both sides
|
|
|
|
if ( area_maxs[node->axis] > node->dist )
|
2009-11-04 21:16:50 +00:00
|
|
|
WorldQ2_AreaEdicts_r ( node->children[0] );
|
2004-08-23 00:15:46 +00:00
|
|
|
if ( area_mins[node->axis] < node->dist )
|
2009-11-04 21:16:50 +00:00
|
|
|
WorldQ2_AreaEdicts_r ( node->children[1] );
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
int VARGS WorldQ2_AreaEdicts (world_t *w, vec3_t mins, vec3_t maxs, q2edict_t **list,
|
2004-08-23 00:15:46 +00:00
|
|
|
int maxcount, int areatype)
|
|
|
|
{
|
|
|
|
area_mins = mins;
|
|
|
|
area_maxs = maxs;
|
|
|
|
area_q2list = list;
|
|
|
|
area_count = 0;
|
|
|
|
area_maxcount = maxcount;
|
|
|
|
area_type = areatype;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
WorldQ2_AreaEdicts_r (w->areanodes);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
return area_count;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SV_HeadnodeForEntity
|
|
|
|
|
|
|
|
Returns a headnode that can be used for testing or clipping an
|
|
|
|
object of mins/maxs size.
|
|
|
|
Offset is filled in to contain the adjustment that must be added to the
|
|
|
|
testing object's origin to get a point to use with the returned hull.
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef Q2SERVER
|
2009-11-04 21:16:50 +00:00
|
|
|
static model_t *WorldQ2_ModelForEntity (world_t *w, q2edict_t *ent)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
model_t *model;
|
|
|
|
|
|
|
|
// decide which clipping hull to use, based on the size
|
|
|
|
if (ent->solid == Q2SOLID_BSP)
|
|
|
|
{ // explicit hulls in the BSP model
|
2011-10-27 16:16:29 +00:00
|
|
|
model = w->Get_CModel(w, ent->s.modelindex);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (!model)
|
|
|
|
SV_Error ("Q2SOLID_BSP with a non bsp model");
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
return model;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// create a temp hull from bounding box sizes
|
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
return CM_TempBoxModel (ent->mins, ent->maxs);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef Q2SERVER
|
2012-01-17 07:57:46 +00:00
|
|
|
void WorldQ2_ClipMoveToEntities (world_t *w, moveclip_t *clip )
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int i, num;
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
q2edict_t *touchlist[MAX_Q2EDICTS], *touch;
|
2004-08-23 00:15:46 +00:00
|
|
|
trace_t trace;
|
2005-08-26 22:56:51 +00:00
|
|
|
model_t *model;
|
2004-08-23 00:15:46 +00:00
|
|
|
float *angles;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
num = WorldQ2_AreaEdicts (w, clip->boxmins, clip->boxmaxs, touchlist
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
, MAX_Q2EDICTS, AREA_SOLID);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// be careful, it is possible to have an entity in this
|
|
|
|
// list removed before we get to it (killtriggered)
|
|
|
|
for (i=0 ; i<num ; i++)
|
|
|
|
{
|
|
|
|
touch = touchlist[i];
|
|
|
|
if (touch->solid == Q2SOLID_NOT)
|
|
|
|
continue;
|
|
|
|
if (touch == clip->q2passedict)
|
|
|
|
continue;
|
|
|
|
if (clip->trace.allsolid)
|
|
|
|
return;
|
|
|
|
if (clip->q2passedict)
|
|
|
|
{
|
|
|
|
if (touch->owner == clip->q2passedict)
|
|
|
|
continue; // don't clip against own missiles
|
|
|
|
if (clip->q2passedict->owner == touch)
|
|
|
|
continue; // don't clip against owner
|
|
|
|
}
|
|
|
|
|
|
|
|
if (touch->svflags & SVF_DEADMONSTER)
|
2012-01-17 07:57:46 +00:00
|
|
|
if ( !(clip->hitcontentsmask & Q2CONTENTS_DEADMONSTER))
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// might intersect, so do an exact clip
|
2009-11-04 21:16:50 +00:00
|
|
|
model = WorldQ2_ModelForEntity (w, touch);
|
2004-08-23 00:15:46 +00:00
|
|
|
angles = touch->s.angles;
|
|
|
|
if (touch->solid != Q2SOLID_BSP)
|
|
|
|
angles = vec3_origin; // boxes don't rotate
|
|
|
|
|
|
|
|
if (touch->svflags & SVF_MONSTER)
|
2005-08-26 22:56:51 +00:00
|
|
|
trace = CM_TransformedBoxTrace (model, clip->start, clip->end,
|
2012-01-17 07:57:46 +00:00
|
|
|
clip->mins2, clip->maxs2, clip->hitcontentsmask,
|
2004-08-23 00:15:46 +00:00
|
|
|
touch->s.origin, angles);
|
|
|
|
else
|
2005-08-26 22:56:51 +00:00
|
|
|
trace = CM_TransformedBoxTrace (model, clip->start, clip->end,
|
2012-01-17 07:57:46 +00:00
|
|
|
clip->mins, clip->maxs, clip->hitcontentsmask,
|
2004-08-23 00:15:46 +00:00
|
|
|
touch->s.origin, angles);
|
|
|
|
|
|
|
|
if (trace.allsolid || trace.startsolid ||
|
|
|
|
trace.fraction < clip->trace.fraction)
|
|
|
|
{
|
|
|
|
trace.ent = (edict_t *)touch;
|
|
|
|
if (clip->trace.startsolid)
|
|
|
|
{
|
|
|
|
clip->trace = trace;
|
|
|
|
clip->trace.startsolid = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
clip->trace = trace;
|
|
|
|
}
|
|
|
|
else if (trace.startsolid)
|
|
|
|
clip->trace.startsolid = true;
|
|
|
|
}
|
|
|
|
#undef ped
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
//===========================================================================
|
|
|
|
|
2005-10-01 03:09:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
SV_ClipToEverything
|
|
|
|
|
|
|
|
like SV_ClipToLinks, but doesn't use the links part. This can be used for checking triggers, solid entities, not-solid entities.
|
|
|
|
Sounds pointless, I know.
|
|
|
|
====================
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
static void World_ClipToEverything (world_t *w, moveclip_t *clip)
|
2005-10-01 03:09:17 +00:00
|
|
|
{
|
|
|
|
int e;
|
|
|
|
trace_t trace;
|
2009-11-04 21:16:50 +00:00
|
|
|
wedict_t *touch;
|
|
|
|
for (e=1 ; e<w->num_edicts ; e++)
|
2005-10-01 03:09:17 +00:00
|
|
|
{
|
2009-11-17 00:15:44 +00:00
|
|
|
touch = (wedict_t*)EDICT_NUM(w->progs, e);
|
2005-10-01 03:09:17 +00:00
|
|
|
|
|
|
|
if (touch->isfree)
|
|
|
|
continue;
|
|
|
|
if (touch->v->solid == SOLID_NOT && !((int)touch->v->flags & FL_FINDABLE_NONSOLID))
|
|
|
|
continue;
|
|
|
|
if (touch->v->solid == SOLID_TRIGGER && !((int)touch->v->flags & FL_FINDABLE_NONSOLID))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (touch == clip->passedict)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (clip->type & MOVE_NOMONSTERS && touch->v->solid != SOLID_BSP)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (clip->passedict)
|
|
|
|
{
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
if (w->usesolidcorpse)
|
|
|
|
{
|
|
|
|
// don't clip corpse against character
|
|
|
|
if (clip->passedict->v->solid == SOLID_CORPSE && (touch->v->solid == SOLID_SLIDEBOX || touch->v->solid == SOLID_CORPSE))
|
|
|
|
continue;
|
|
|
|
// don't clip character against corpse
|
|
|
|
if (clip->passedict->v->solid == SOLID_SLIDEBOX && touch->v->solid == SOLID_CORPSE)
|
|
|
|
continue;
|
|
|
|
}
|
2007-09-02 19:55:17 +00:00
|
|
|
if (!((int)clip->passedict->xv->dimension_hit & (int)touch->xv->dimension_solid))
|
2005-10-01 03:09:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clip->boxmins[0] > touch->v->absmax[0]
|
|
|
|
|| clip->boxmins[1] > touch->v->absmax[1]
|
|
|
|
|| clip->boxmins[2] > touch->v->absmax[2]
|
|
|
|
|| clip->boxmaxs[0] < touch->v->absmin[0]
|
|
|
|
|| clip->boxmaxs[1] < touch->v->absmin[1]
|
|
|
|
|| clip->boxmaxs[2] < touch->v->absmin[2] )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (clip->passedict && clip->passedict->v->size[0] && !touch->v->size[0])
|
|
|
|
continue; // points never interact
|
|
|
|
|
|
|
|
// might intersect, so do an exact clip
|
|
|
|
if (clip->trace.allsolid)
|
|
|
|
return;
|
|
|
|
if (clip->passedict)
|
|
|
|
{
|
2009-11-17 00:15:44 +00:00
|
|
|
if ((wedict_t*)PROG_TO_EDICT(w->progs, touch->v->owner) == clip->passedict)
|
2005-10-01 03:09:17 +00:00
|
|
|
continue; // don't clip against own missiles
|
2009-11-17 00:15:44 +00:00
|
|
|
if ((wedict_t*)PROG_TO_EDICT(w->progs, clip->passedict->v->owner) == touch)
|
2005-10-01 03:09:17 +00:00
|
|
|
continue; // don't clip against owner
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((int)touch->v->flags & FL_MONSTER)
|
2012-01-17 07:57:46 +00:00
|
|
|
trace = World_ClipMoveToEntity (w, touch, touch->v->origin, clip->start, clip->mins2, clip->maxs2, clip->end, clip->hullnum, clip->type & MOVE_HITMODEL, clip->hitcontentsmask);
|
2005-10-01 03:09:17 +00:00
|
|
|
else
|
2012-01-17 07:57:46 +00:00
|
|
|
trace = World_ClipMoveToEntity (w, touch, touch->v->origin, clip->start, clip->mins, clip->maxs, clip->end, clip->hullnum, clip->type & MOVE_HITMODEL, clip->hitcontentsmask);
|
2005-10-01 03:09:17 +00:00
|
|
|
if (trace.allsolid || trace.startsolid ||
|
|
|
|
trace.fraction < clip->trace.fraction)
|
|
|
|
{
|
2011-09-03 03:49:43 +00:00
|
|
|
if (clip->type & MOVE_ENTCHAIN)
|
|
|
|
{
|
|
|
|
touch->v->chain = EDICT_TO_PROG(w->progs, clip->trace.ent?clip->trace.ent:w->edicts);
|
|
|
|
clip->trace.ent = touch;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trace.ent = touch;
|
|
|
|
clip->trace = trace;
|
|
|
|
}
|
2005-10-01 03:09:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
====================
|
|
|
|
SV_ClipToLinks
|
|
|
|
|
|
|
|
Mins and maxs enclose the entire area swept by the move
|
|
|
|
====================
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
static void World_ClipToLinks (world_t *w, areanode_t *node, moveclip_t *clip)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
link_t *l, *next;
|
2009-11-04 21:16:50 +00:00
|
|
|
wedict_t *touch;
|
2004-08-23 00:15:46 +00:00
|
|
|
trace_t trace;
|
|
|
|
|
|
|
|
// touch linked edicts
|
2011-06-29 18:39:11 +00:00
|
|
|
for (l = node->edicts.next ; l != &node->edicts ; l = next)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
next = l->next;
|
|
|
|
touch = EDICT_FROM_AREA(l);
|
2005-03-28 00:11:59 +00:00
|
|
|
if (touch->v->solid == SOLID_NOT)
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
|
|
|
if (touch == clip->passedict)
|
|
|
|
continue;
|
2011-06-29 18:39:11 +00:00
|
|
|
|
|
|
|
/*if its a trigger, we only clip against it if the flags are aligned*/
|
2005-03-28 00:11:59 +00:00
|
|
|
if (touch->v->solid == SOLID_TRIGGER || touch->v->solid == SOLID_LADDER)
|
2010-07-11 02:22:39 +00:00
|
|
|
{
|
2011-06-29 18:39:11 +00:00
|
|
|
if (!(clip->type & MOVE_TRIGGERS))
|
|
|
|
continue;
|
|
|
|
if (!((int)touch->v->flags & FL_FINDABLE_NONSOLID))
|
|
|
|
continue;
|
2010-07-11 02:22:39 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (clip->type & MOVE_LAGGED)
|
|
|
|
{
|
|
|
|
//can't touch lagged ents - we do an explicit test for them later.
|
|
|
|
if (touch->entnum-1 < w->maxlagents)
|
|
|
|
if (w->lagents[touch->entnum-1].present)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-01-13 02:42:25 +00:00
|
|
|
if ((clip->type & MOVE_NOMONSTERS) && (touch->v->solid != SOLID_BSP && touch->v->solid != SOLID_PORTAL))
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
|
|
|
|
2005-07-01 19:23:00 +00:00
|
|
|
if (clip->passedict)
|
|
|
|
{
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
if (w->usesolidcorpse)
|
|
|
|
{
|
|
|
|
// don't clip corpse against character
|
|
|
|
if (clip->passedict->v->solid == SOLID_CORPSE && (touch->v->solid == SOLID_SLIDEBOX || touch->v->solid == SOLID_CORPSE))
|
|
|
|
continue;
|
|
|
|
// don't clip character against corpse
|
|
|
|
if (clip->passedict->v->solid == SOLID_SLIDEBOX && touch->v->solid == SOLID_CORPSE)
|
|
|
|
continue;
|
|
|
|
}
|
2007-09-02 19:55:17 +00:00
|
|
|
if (!((int)clip->passedict->xv->dimension_hit & (int)touch->xv->dimension_solid))
|
2005-07-01 19:23:00 +00:00
|
|
|
continue;
|
|
|
|
}
|
2004-11-23 15:13:32 +00:00
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
if (clip->boxmins[0] > touch->v->absmax[0]
|
|
|
|
|| clip->boxmins[1] > touch->v->absmax[1]
|
|
|
|
|| clip->boxmins[2] > touch->v->absmax[2]
|
|
|
|
|| clip->boxmaxs[0] < touch->v->absmin[0]
|
|
|
|
|| clip->boxmaxs[1] < touch->v->absmin[1]
|
|
|
|
|| clip->boxmaxs[2] < touch->v->absmin[2] )
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
if (clip->passedict && clip->passedict->v->size[0] && !touch->v->size[0])
|
2004-08-23 00:15:46 +00:00
|
|
|
continue; // points never interact
|
|
|
|
|
|
|
|
// might intersect, so do an exact clip
|
2013-10-08 14:28:11 +00:00
|
|
|
// if (clip->trace.allsolid)
|
|
|
|
// return;
|
2004-08-23 00:15:46 +00:00
|
|
|
if (clip->passedict)
|
|
|
|
{
|
2009-11-17 00:15:44 +00:00
|
|
|
if ((wedict_t*)PROG_TO_EDICT(w->progs, touch->v->owner) == clip->passedict)
|
2004-08-23 00:15:46 +00:00
|
|
|
continue; // don't clip against own missiles
|
2009-11-17 00:15:44 +00:00
|
|
|
if ((wedict_t*)PROG_TO_EDICT(w->progs, clip->passedict->v->owner) == touch)
|
2004-08-23 00:15:46 +00:00
|
|
|
continue; // don't clip against owner
|
|
|
|
}
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
if ((int)touch->v->flags & FL_MONSTER)
|
2012-01-17 07:57:46 +00:00
|
|
|
trace = World_ClipMoveToEntity (w, touch, touch->v->origin, clip->start, clip->mins2, clip->maxs2, clip->end, clip->hullnum, clip->type & MOVE_HITMODEL, clip->hitcontentsmask);
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2012-01-17 07:57:46 +00:00
|
|
|
trace = World_ClipMoveToEntity (w, touch, touch->v->origin, clip->start, clip->mins, clip->maxs, clip->end, clip->hullnum, clip->type & MOVE_HITMODEL, clip->hitcontentsmask);
|
2011-09-03 03:49:43 +00:00
|
|
|
|
2013-12-29 22:48:28 +00:00
|
|
|
if (trace.startsolid && touch->v->solid == SOLID_PORTAL)
|
|
|
|
continue;
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (trace.allsolid || trace.startsolid ||
|
|
|
|
trace.fraction < clip->trace.fraction)
|
|
|
|
{
|
2011-09-03 03:49:43 +00:00
|
|
|
if (clip->type & MOVE_ENTCHAIN)
|
|
|
|
{
|
|
|
|
touch->v->chain = EDICT_TO_PROG(w->progs, clip->trace.ent?clip->trace.ent:w->edicts);
|
|
|
|
clip->trace.ent = touch;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trace.ent = touch;
|
|
|
|
clip->trace = trace;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// recurse down both sides
|
|
|
|
if (node->axis == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( clip->boxmaxs[node->axis] > node->dist )
|
2009-11-04 21:16:50 +00:00
|
|
|
World_ClipToLinks (w, node->children[0], clip );
|
2004-08-23 00:15:46 +00:00
|
|
|
if ( clip->boxmins[node->axis] < node->dist )
|
2009-11-04 21:16:50 +00:00
|
|
|
World_ClipToLinks (w, node->children[1], clip );
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
#ifdef Q2SERVER
|
2009-11-04 21:16:50 +00:00
|
|
|
static void WorldQ2_ClipToLinks (world_t *w, areanode_t *node, moveclip_t *clip)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
link_t *l, *next;
|
|
|
|
q2edict_t *touch;
|
|
|
|
trace_t trace;
|
|
|
|
|
|
|
|
// touch linked edicts
|
2011-06-29 18:39:11 +00:00
|
|
|
for (l = node->edicts.next ; l != &node->edicts ; l = next)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
next = l->next;
|
|
|
|
touch = Q2EDICT_FROM_AREA(l);
|
|
|
|
if (touch->s.solid == Q2SOLID_NOT)
|
|
|
|
continue;
|
|
|
|
if (touch == clip->q2passedict)
|
|
|
|
continue;
|
|
|
|
if (touch->s.solid == Q2SOLID_TRIGGER)
|
|
|
|
SV_Error ("Trigger in clipping list");
|
|
|
|
|
|
|
|
if (clip->type & MOVE_NOMONSTERS && touch->s.solid != Q2SOLID_BSP)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (clip->boxmins[0] > touch->absmax[0]
|
|
|
|
|| clip->boxmins[1] > touch->absmax[1]
|
|
|
|
|| clip->boxmins[2] > touch->absmax[2]
|
|
|
|
|| clip->boxmaxs[0] < touch->absmin[0]
|
|
|
|
|| clip->boxmaxs[1] < touch->absmin[1]
|
|
|
|
|| clip->boxmaxs[2] < touch->absmin[2] )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (clip->q2passedict && clip->q2passedict->size[0] && !touch->size[0])
|
|
|
|
continue; // points never interact
|
|
|
|
|
|
|
|
// might intersect, so do an exact clip
|
|
|
|
if (clip->trace.allsolid)
|
|
|
|
return;
|
|
|
|
if (clip->passedict)
|
|
|
|
{
|
|
|
|
if (touch->owner == clip->q2passedict)
|
|
|
|
continue; // don't clip against own missiles
|
|
|
|
if (clip->q2passedict->owner == touch)
|
|
|
|
continue; // don't clip against owner
|
|
|
|
}
|
|
|
|
|
2012-01-17 07:57:46 +00:00
|
|
|
trace = WorldQ2_ClipMoveToEntity (w, touch, clip->start, clip->mins, clip->maxs, clip->end, clip->hitcontentsmask);
|
2005-07-16 00:53:08 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (trace.allsolid || trace.startsolid ||
|
|
|
|
trace.fraction < clip->trace.fraction)
|
|
|
|
{
|
|
|
|
trace.ent = (edict_t *)touch;
|
2005-07-16 00:53:08 +00:00
|
|
|
clip->trace = trace;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// recurse down both sides
|
|
|
|
if (node->axis == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( clip->boxmaxs[node->axis] > node->dist )
|
2009-11-04 21:16:50 +00:00
|
|
|
World_ClipToLinks (w, node->children[0], clip );
|
2004-08-23 00:15:46 +00:00
|
|
|
if ( clip->boxmins[node->axis] < node->dist )
|
2009-11-04 21:16:50 +00:00
|
|
|
World_ClipToLinks (w, node->children[1], clip );
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SV_MoveBounds
|
|
|
|
==================
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
static void World_MoveBounds (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, vec3_t boxmins, vec3_t boxmaxs)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
// debug to test against everything
|
|
|
|
boxmins[0] = boxmins[1] = boxmins[2] = -9999;
|
|
|
|
boxmaxs[0] = boxmaxs[1] = boxmaxs[2] = 9999;
|
|
|
|
#else
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
if (end[i] > start[i])
|
|
|
|
{
|
|
|
|
boxmins[i] = start[i] + mins[i] - 1;
|
|
|
|
boxmaxs[i] = end[i] + maxs[i] + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
boxmins[i] = end[i] + mins[i] - 1;
|
|
|
|
boxmaxs[i] = start[i] + maxs[i] + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SV_Move
|
|
|
|
==================
|
|
|
|
*/
|
2009-11-04 21:16:50 +00:00
|
|
|
trace_t World_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, wedict_t *passedict)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
moveclip_t clip;
|
|
|
|
int i;
|
|
|
|
int hullnum;
|
|
|
|
|
|
|
|
memset ( &clip, 0, sizeof ( moveclip_t ) );
|
|
|
|
|
2007-09-02 19:55:17 +00:00
|
|
|
if (passedict && passedict->xv->hull)
|
|
|
|
hullnum = passedict->xv->hull;
|
2009-11-17 00:15:44 +00:00
|
|
|
#ifdef CLIENTONLY
|
|
|
|
else
|
|
|
|
hullnum = 0;
|
|
|
|
#else
|
2007-10-05 18:08:47 +00:00
|
|
|
else if (sv_compatiblehulls.value)
|
2004-08-23 00:15:46 +00:00
|
|
|
hullnum = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int diff;
|
|
|
|
int best;
|
|
|
|
hullnum = 0;
|
|
|
|
best = 8192;
|
|
|
|
//x/y pos/neg are assumed to be the same magnitute.
|
2004-11-19 17:42:54 +00:00
|
|
|
//z pos/height are assumed to be different from all the others.
|
2004-08-23 00:15:46 +00:00
|
|
|
for (i = 0; i < MAX_MAP_HULLSM; i++)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if (!w->worldmodel->hulls[i].available)
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
|
|
|
#define sq(x) ((x)*(x))
|
2009-11-04 21:16:50 +00:00
|
|
|
diff = sq(w->worldmodel->hulls[i].clip_maxs[2] - maxs[2]) +
|
|
|
|
sq(w->worldmodel->hulls[i].clip_mins[2] - mins[2]) +
|
|
|
|
sq(w->worldmodel->hulls[i].clip_maxs[1] - maxs[1]) +
|
|
|
|
sq(w->worldmodel->hulls[i].clip_mins[0] - mins[0]);
|
2004-08-23 00:15:46 +00:00
|
|
|
if (diff < best)
|
|
|
|
{
|
|
|
|
best = diff;
|
|
|
|
hullnum=i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
hullnum++;
|
|
|
|
}
|
2009-11-17 00:15:44 +00:00
|
|
|
#endif
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2012-07-05 19:42:36 +00:00
|
|
|
if (passedict->xv->hitcontentsmask)
|
|
|
|
clip.hitcontentsmask = passedict->xv->hitcontentsmask;
|
|
|
|
else if (type & MOVE_NOMONSTERS)
|
2012-01-17 07:57:46 +00:00
|
|
|
clip.hitcontentsmask = MASK_WORLDSOLID; /*solid only to world*/
|
|
|
|
else if (maxs[0] - mins[0])
|
|
|
|
clip.hitcontentsmask = MASK_BOXSOLID; /*impacts playerclip*/
|
|
|
|
else
|
|
|
|
clip.hitcontentsmask = MASK_POINTSOLID; /*ignores playerclip but hits everything else*/
|
|
|
|
|
2013-12-08 20:06:55 +00:00
|
|
|
if (type & MOVE_ONLYENT)
|
|
|
|
{
|
|
|
|
if (!passedict)
|
|
|
|
passedict = w->edicts;
|
|
|
|
return World_ClipMoveToEntity (w, passedict, passedict->v->origin, start, mins, maxs, end, hullnum, clip.type & MOVE_HITMODEL, clip.hitcontentsmask);
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
// clip to world
|
2012-01-17 07:57:46 +00:00
|
|
|
clip.trace = World_ClipMoveToEntity (w, w->edicts, w->edicts->v->origin, start, mins, maxs, end, hullnum, false, clip.hitcontentsmask);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
clip.start = start;
|
|
|
|
clip.end = end;
|
|
|
|
clip.mins = mins;
|
|
|
|
clip.maxs = maxs;
|
2005-07-16 17:04:36 +00:00
|
|
|
clip.type = type;
|
2004-08-23 00:15:46 +00:00
|
|
|
clip.passedict = passedict;
|
|
|
|
clip.hullnum = hullnum;
|
|
|
|
#ifdef Q2SERVER
|
|
|
|
clip.q2passedict = NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (type & MOVE_MISSILE)
|
|
|
|
{
|
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
clip.mins2[i] = -15;
|
|
|
|
clip.maxs2[i] = 15;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
VectorCopy (mins, clip.mins2);
|
|
|
|
VectorCopy (maxs, clip.maxs2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// create the bounding box of the entire move
|
2009-11-04 21:16:50 +00:00
|
|
|
World_MoveBounds (start, clip.mins2, clip.maxs2, end, clip.boxmins, clip.boxmaxs );
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// clip to entities
|
2005-10-01 03:09:17 +00:00
|
|
|
if (clip.type & MOVE_EVERYTHING)
|
2009-11-04 21:16:50 +00:00
|
|
|
World_ClipToEverything (w, &clip);
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
|
|
|
if (clip.type & MOVE_LAGGED)
|
|
|
|
{
|
|
|
|
clip.type &= ~MOVE_LAGGED;
|
2009-11-17 00:15:44 +00:00
|
|
|
#ifndef CLIENTONLY
|
|
|
|
if (w == &sv.world)
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
2011-04-25 03:25:22 +00:00
|
|
|
if (passedict->entnum && passedict->entnum <= sv.allocated_client_slots)
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
|
|
|
clip.type |= MOVE_LAGGED;
|
2009-11-17 00:15:44 +00:00
|
|
|
w->lagents = svs.clients[passedict->entnum-1].laggedents;
|
|
|
|
w->maxlagents = svs.clients[passedict->entnum-1].laggedents_count;
|
|
|
|
w->lagentsfrac = svs.clients[passedict->entnum-1].laggedents_frac;
|
|
|
|
}
|
|
|
|
else if (passedict->v->owner)
|
|
|
|
{
|
2011-04-25 03:25:22 +00:00
|
|
|
if (passedict->v->owner && passedict->v->owner <= sv.allocated_client_slots)
|
2009-11-17 00:15:44 +00:00
|
|
|
{
|
|
|
|
clip.type |= MOVE_LAGGED;
|
|
|
|
w->lagents = svs.clients[passedict->v->owner-1].laggedents;
|
|
|
|
w->maxlagents = svs.clients[passedict->v->owner-1].laggedents_count;
|
|
|
|
w->lagentsfrac = svs.clients[passedict->v->owner-1].laggedents_frac;
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-17 00:15:44 +00:00
|
|
|
#endif
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
if (clip.type & MOVE_LAGGED)
|
|
|
|
{
|
|
|
|
trace_t trace;
|
|
|
|
wedict_t *touch;
|
2009-11-13 16:54:21 +00:00
|
|
|
vec3_t lp;
|
2009-11-04 21:16:50 +00:00
|
|
|
|
|
|
|
World_ClipToLinks (w, w->areanodes, &clip );
|
|
|
|
|
|
|
|
for (i = 0; i < w->maxlagents; i++)
|
|
|
|
{
|
|
|
|
if (!w->lagents[i].present)
|
|
|
|
continue;
|
|
|
|
if (clip.trace.allsolid)
|
|
|
|
break;
|
|
|
|
|
|
|
|
touch = (wedict_t*)EDICT_NUM(w->progs, i+1);
|
|
|
|
if (touch->v->solid == SOLID_NOT)
|
|
|
|
continue;
|
|
|
|
if (touch == clip.passedict)
|
|
|
|
continue;
|
|
|
|
if (touch->v->solid == SOLID_TRIGGER || touch->v->solid == SOLID_LADDER)
|
2009-11-17 00:15:44 +00:00
|
|
|
Host_Error ("Trigger (%s) in clipping list", PR_GetString(w->progs, touch->v->classname));
|
2009-11-04 21:16:50 +00:00
|
|
|
|
|
|
|
if (clip.type & MOVE_NOMONSTERS && touch->v->solid != SOLID_BSP)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (clip.passedict)
|
|
|
|
{
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
if (w->usesolidcorpse)
|
|
|
|
{
|
|
|
|
// don't clip corpse against character
|
|
|
|
if (clip.passedict->v->solid == SOLID_CORPSE && (touch->v->solid == SOLID_SLIDEBOX || touch->v->solid == SOLID_CORPSE))
|
|
|
|
continue;
|
|
|
|
// don't clip character against corpse
|
|
|
|
if (clip.passedict->v->solid == SOLID_SLIDEBOX && touch->v->solid == SOLID_CORPSE)
|
|
|
|
continue;
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
if (!((int)clip.passedict->xv->dimension_hit & (int)touch->xv->dimension_solid))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-11-13 16:54:21 +00:00
|
|
|
VectorInterpolate(touch->v->origin, w->lagentsfrac, w->lagents[i].laggedpos, lp);
|
|
|
|
|
|
|
|
if (clip.boxmins[0] > lp[0]+touch->v->maxs[0]
|
|
|
|
|| clip.boxmins[1] > lp[1]+touch->v->maxs[1]
|
|
|
|
|| clip.boxmins[2] > lp[2]+touch->v->maxs[2]
|
|
|
|
|| clip.boxmaxs[0] < lp[0]+touch->v->mins[0]
|
|
|
|
|| clip.boxmaxs[1] < lp[1]+touch->v->mins[1]
|
|
|
|
|| clip.boxmaxs[2] < lp[2]+touch->v->mins[2] )
|
2009-11-04 21:16:50 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (clip.passedict && clip.passedict->v->size[0] && !touch->v->size[0])
|
|
|
|
continue; // points never interact
|
|
|
|
|
|
|
|
if (clip.passedict)
|
|
|
|
{
|
2009-11-17 00:15:44 +00:00
|
|
|
if ((wedict_t*)PROG_TO_EDICT(w->progs, touch->v->owner) == clip.passedict)
|
2009-11-04 21:16:50 +00:00
|
|
|
continue; // don't clip against own missiles
|
2009-11-17 00:15:44 +00:00
|
|
|
if ((wedict_t*)PROG_TO_EDICT(w->progs, clip.passedict->v->owner) == touch)
|
2009-11-04 21:16:50 +00:00
|
|
|
continue; // don't clip against owner
|
|
|
|
}
|
|
|
|
|
2012-01-17 07:57:46 +00:00
|
|
|
trace = World_ClipMoveToEntity (w, touch, lp, clip.start, clip.mins, clip.maxs, clip.end, clip.hullnum, clip.type & MOVE_HITMODEL, clip.hitcontentsmask);
|
2009-11-04 21:16:50 +00:00
|
|
|
|
|
|
|
if (trace.allsolid || trace.startsolid || trace.fraction < clip.trace.fraction)
|
|
|
|
{
|
2011-09-03 03:49:43 +00:00
|
|
|
if (clip.type & MOVE_ENTCHAIN)
|
|
|
|
{
|
|
|
|
touch->v->chain = EDICT_TO_PROG(w->progs, clip.trace.ent?clip.trace.ent:w->edicts);
|
|
|
|
clip.trace.ent = touch;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trace.ent = touch;
|
|
|
|
clip.trace = trace;
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
World_ClipToLinks (w, w->areanodes, &clip );
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-08-18 22:56:33 +00:00
|
|
|
// if (clip.trace.startsolid)
|
|
|
|
// clip.trace.fraction = 0;
|
2004-12-08 04:14:52 +00:00
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
if (!clip.trace.ent)
|
|
|
|
return clip.trace;
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
return clip.trace;
|
|
|
|
}
|
|
|
|
#ifdef Q2SERVER
|
2012-01-17 07:57:46 +00:00
|
|
|
trace_t WorldQ2_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int hitcontentsmask, q2edict_t *passedict)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
moveclip_t clip;
|
|
|
|
|
|
|
|
memset ( &clip, 0, sizeof ( moveclip_t ) );
|
|
|
|
|
|
|
|
// clip to world
|
2012-02-27 12:23:15 +00:00
|
|
|
w->worldmodel->funcs.NativeTrace(w->worldmodel, 0, 0, NULL, start, end, mins, maxs, hitcontentsmask, &clip.trace);
|
|
|
|
// clip.trace = CM_BoxTrace(w->worldmodel, start, end, mins, maxs, hitcontentsmask);//SVQ2_ClipMoveToEntity ( ge->edicts, start, mins, maxs, end );
|
2009-11-04 21:16:50 +00:00
|
|
|
clip.trace.ent = ge->edicts;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (clip.trace.fraction == 0)
|
|
|
|
return clip.trace;
|
|
|
|
|
|
|
|
clip.start = start;
|
|
|
|
clip.end = end;
|
|
|
|
clip.mins = mins;
|
|
|
|
clip.maxs = maxs;
|
2012-01-17 07:57:46 +00:00
|
|
|
clip.type = MOVE_NORMAL;
|
|
|
|
clip.hitcontentsmask = hitcontentsmask;
|
2004-08-23 00:15:46 +00:00
|
|
|
clip.passedict = NULL;
|
|
|
|
clip.q2passedict = passedict;
|
|
|
|
|
|
|
|
VectorCopy (mins, clip.mins2);
|
|
|
|
VectorCopy (maxs, clip.maxs2);
|
|
|
|
|
|
|
|
// create the bounding box of the entire move
|
2009-11-04 21:16:50 +00:00
|
|
|
World_MoveBounds ( start, clip.mins2, clip.maxs2, end, clip.boxmins, clip.boxmaxs );
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// clip to entities
|
|
|
|
#ifdef Q2BSPS
|
2009-11-04 21:16:50 +00:00
|
|
|
if (w->worldmodel->fromgame == fg_quake2 || w->worldmodel->fromgame == fg_quake3)
|
2012-01-17 07:57:46 +00:00
|
|
|
WorldQ2_ClipMoveToEntities(w, &clip);
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
|
|
|
#endif
|
2009-11-04 21:16:50 +00:00
|
|
|
WorldQ2_ClipToLinks (w, w->areanodes, &clip );
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
return clip.trace;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-11-29 01:21:00 +00:00
|
|
|
#endif
|