mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-03-10 20:11:42 +00:00
Add proper collision support for angles on SOLID_BSP entities.
This commit is contained in:
parent
0d8c45168f
commit
9d15653e46
2 changed files with 56 additions and 6 deletions
|
@ -805,9 +805,14 @@ void R_ShowBoundingBoxes (void)
|
|||
else
|
||||
{
|
||||
//box entity
|
||||
VectorAdd (ed->v.mins, ed->v.origin, mins);
|
||||
VectorAdd (ed->v.maxs, ed->v.origin, maxs);
|
||||
R_EmitWireBox (mins, maxs);
|
||||
if (ed->v.solid == SOLID_BSP && (ed->v.angles[0]||ed->v.angles[1]||ed->v.angles[2]) && pr_checkextension.value)
|
||||
R_EmitWireBox (ed->v.absmin, ed->v.absmax);
|
||||
else
|
||||
{
|
||||
VectorAdd (ed->v.mins, ed->v.origin, mins);
|
||||
VectorAdd (ed->v.maxs, ed->v.origin, maxs);
|
||||
R_EmitWireBox (mins, maxs);
|
||||
}
|
||||
}
|
||||
}
|
||||
PR_SwitchQCVM(oldvm);
|
||||
|
|
|
@ -432,8 +432,30 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
|
|||
return;
|
||||
|
||||
// set the abs box
|
||||
VectorAdd (ent->v.origin, ent->v.mins, ent->v.absmin);
|
||||
VectorAdd (ent->v.origin, ent->v.maxs, ent->v.absmax);
|
||||
if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) && pr_checkextension.value)
|
||||
{ // expand for rotation the lame way. hopefully there's an origin brush in there.
|
||||
int i;
|
||||
float v1,v2;
|
||||
vec3_t max;
|
||||
//q2 method
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
v1 = fabs(ent->v.mins[i]);
|
||||
v2 = fabs(ent->v.maxs[i]);
|
||||
max[i] = q_max(v1,v2);
|
||||
}
|
||||
v1 = sqrt(DotProduct(max,max));
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
ent->v.absmin[i] = ent->v.origin[i] - v1;
|
||||
ent->v.absmax[i] = ent->v.origin[i] + v1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
VectorAdd (ent->v.origin, ent->v.mins, ent->v.absmin);
|
||||
VectorAdd (ent->v.origin, ent->v.maxs, ent->v.absmax);
|
||||
}
|
||||
|
||||
//
|
||||
// to make items easier to pick up and allow them to be grabbed off
|
||||
|
@ -808,7 +830,30 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max
|
|||
VectorSubtract (end, offset, end_l);
|
||||
|
||||
// trace a line through the apropriate clipping hull
|
||||
SV_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l, &trace);
|
||||
if (ent->v.solid == SOLID_BSP && (ent->v.angles[0]||ent->v.angles[1]||ent->v.angles[2]) && pr_checkextension.value)
|
||||
{
|
||||
#define DotProductTranspose(v,m,a) ((v)[0]*(m)[0][a] + (v)[1]*(m)[1][a] + (v)[2]*(m)[2][a])
|
||||
vec3_t axis[3], start_r, end_r, tmp;
|
||||
AngleVectors(ent->v.angles, axis[0], axis[1], axis[2]);
|
||||
VectorInverse(axis[1]);
|
||||
start_r[0] = DotProduct(start_l, axis[0]);
|
||||
start_r[1] = DotProduct(start_l, axis[1]);
|
||||
start_r[2] = DotProduct(start_l, axis[2]);
|
||||
end_r[0] = DotProduct(end_l, axis[0]);
|
||||
end_r[1] = DotProduct(end_l, axis[1]);
|
||||
end_r[2] = DotProduct(end_l, axis[2]);
|
||||
SV_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_r, end_r, &trace);
|
||||
VectorCopy(trace.endpos, tmp);
|
||||
trace.endpos[0] = DotProductTranspose(tmp,axis,0);
|
||||
trace.endpos[1] = DotProductTranspose(tmp,axis,1);
|
||||
trace.endpos[2] = DotProductTranspose(tmp,axis,2);
|
||||
VectorCopy(trace.plane.normal, tmp);
|
||||
trace.plane.normal[0] = DotProductTranspose(tmp,axis,0);
|
||||
trace.plane.normal[1] = DotProductTranspose(tmp,axis,1);
|
||||
trace.plane.normal[2] = DotProductTranspose(tmp,axis,2);
|
||||
}
|
||||
else
|
||||
SV_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l, &trace);
|
||||
|
||||
// fix trace up by the offset
|
||||
if (trace.fraction != 1)
|
||||
|
|
Loading…
Reference in a new issue