[Quest-ed-checkins] CVS: quest-3b/src/quest trace.c,1.2,1.3
Brought to you by:
alexm
|
From: Alexander M. <al...@us...> - 2002-05-21 19:38:06
|
Update of /cvsroot/quest-ed/quest-3b/src/quest
In directory usw-pr-cvs1:/tmp/cvs-serv6996/src/quest
Modified Files:
trace.c
Log Message:
Trace() was ignoring the TRACE_ENTITY flag and only checking entities if TRACE_FLAG was on. Fixed.
Index: trace.c
===================================================================
RCS file: /cvsroot/quest-ed/quest-3b/src/quest/trace.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** trace.c 4 Feb 2002 20:43:58 -0000 1.2
--- trace.c 21 May 2002 19:03:32 -0000 1.3
***************
*** 18,86 ****
void Trace(vec3_t org,vec3_t dir,scalar_t len,int flags,
! void (*func)(scalar_t dist,int type,void *v,int face))
{
! vec3_t s,e;
! vec3_t d;
! vec3_t a;
! brush_t *b;
! int i,j;
entity_t *ent;
! scalar_t f,g,h;
! s=org;
! d=dir;
! e.x=s.x+d.x*len;
! e.y=s.y+d.y*len;
! e.z=s.z+d.z*len;
/* We trace from s to e, direction is d */
! if (flags&TRACE_FACE)
! {
! for (b=M.VBrushHead;b;b=b->VNext)
! {
/* TODO: handle curves */
! if (b->bt->type==BRUSH_NORMAL)
! {
! for (i=0;i<b->num_faces;i++)
! {
! f=DotProd(s,b->faces[i]->normal)-b->faces[i]->dist;
! g=DotProd(e,b->faces[i]->normal)-b->faces[i]->dist;
!
! if ((f<0 && g<0) || (f>0 && g>0))
! continue;
!
! g=DotProd(d,b->faces[i]->normal);
! if (fabs(g)<0.0001)
! continue;
!
! h=-f/g;
!
! a.x=s.x+d.x*h;
! a.y=s.y+d.y*h;
! a.z=s.z+d.z*h;
!
! /* now make sure a is actually in the face by checking it
! against the planes of the other faces in the brush */
! for (j=0;j<b->num_faces;j++)
! {
! if (i==j)
! continue;
!
! f=DotProd(a,b->faces[j]->normal)-b->faces[j]->dist;
! if (f>0) break;
! }
!
! if (j!=b->num_faces)
! continue;
!
! func(h,TRACE_FACE,b,i);
! }
! }
! }
for (ent=M.VEntityHead;ent;ent=ent->VNext)
{
--- 18,89 ----
void Trace(vec3_t org,vec3_t dir,scalar_t len,int flags,
! void (*func)(scalar_t dist,int type,void *v,int face))
{
! vec3_t s,e;
! vec3_t d;
! vec3_t a;
! brush_t *b;
! int i,j;
entity_t *ent;
! scalar_t f,g,h;
! s=org;
! d=dir;
! e.x=s.x+d.x*len;
! e.y=s.y+d.y*len;
! e.z=s.z+d.z*len;
/* We trace from s to e, direction is d */
! if (flags&TRACE_FACE)
! {
! for (b=M.VBrushHead;b;b=b->VNext)
! {
/* TODO: handle curves */
! if (b->bt->type==BRUSH_NORMAL)
! {
! for (i=0;i<b->num_faces;i++)
! {
! f=DotProd(s,b->faces[i]->normal)-b->faces[i]->dist;
! g=DotProd(e,b->faces[i]->normal)-b->faces[i]->dist;
!
! if ((f<0 && g<0) || (f>0 && g>0))
! continue;
!
! g=DotProd(d,b->faces[i]->normal);
! if (fabs(g)<0.0001)
! continue;
!
! h=-f/g;
!
! a.x=s.x+d.x*h;
! a.y=s.y+d.y*h;
! a.z=s.z+d.z*h;
!
! /* now make sure a is actually in the face by checking it
! against the planes of the other faces in the brush */
! for (j=0;j<b->num_faces;j++)
! {
! if (i==j)
! continue;
!
! f=DotProd(a,b->faces[j]->normal)-b->faces[j]->dist;
! if (f>0) break;
! }
!
! if (j!=b->num_faces)
! continue;
!
! func(h,TRACE_FACE,b,i);
! }
! }
! }
! }
! if (flags&TRACE_ENTITY)
! {
for (ent=M.VEntityHead;ent;ent=ent->VNext)
{
***************
*** 119,123 ****
func(h,TRACE_ENTITY,ent,-1);
}
! }
}
--- 122,126 ----
func(h,TRACE_ENTITY,ent,-1);
}
! }
}
|