diff options
| author | Alan Edwardes <[email protected]> | 2013-12-03 10:47:30 +0000 |
|---|---|---|
| committer | Alan Edwardes <[email protected]> | 2013-12-03 10:47:30 +0000 |
| commit | 550992aebacbc7586553c15a3c2120f85a879126 (patch) | |
| tree | c814cf654018acd5d69bb6e4be5dc9900391fd37 /mp/src/raytrace/trace3.cpp | |
| parent | VBSP now checks all search paths for an FGD file. (diff) | |
| parent | Make .xcconfigs text files too. (diff) | |
| download | source-sdk-2013-550992aebacbc7586553c15a3c2120f85a879126.tar.xz source-sdk-2013-550992aebacbc7586553c15a3c2120f85a879126.zip | |
Merge remote-tracking branch 'upstream/master' into vbsp-fixes.
Diffstat (limited to 'mp/src/raytrace/trace3.cpp')
| -rw-r--r-- | mp/src/raytrace/trace3.cpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/mp/src/raytrace/trace3.cpp b/mp/src/raytrace/trace3.cpp new file mode 100644 index 00000000..b582347e --- /dev/null +++ b/mp/src/raytrace/trace3.cpp @@ -0,0 +1,127 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// + +#include "raytrace.h" +#include <bspfile.h> +#include "bsplib.h" + +static Vector VertCoord(dface_t const &f, int vnum) +{ + int eIndex = dsurfedges[f.firstedge+vnum]; + int point; + if( eIndex < 0 ) + { + point = dedges[-eIndex].v[1]; + } + else + { + point = dedges[eIndex].v[0]; + } + dvertex_t *v=dvertexes+point; + return Vector(v->point[0],v->point[1],v->point[2]); + +} + +Vector colors[]={ + Vector(0.5,0.5,1), + Vector(0.5,1,0.5), + Vector(0.5,1,1), + Vector(1,0.5,0.5), + Vector(1,0.5,1), + Vector(1,1,1)}; + +void RayTracingEnvironment::AddBSPFace(int id,dface_t const &face) +{ + if (face.dispinfo!=-1) // displacements must be dealt with elsewhere + return; + texinfo_t *tx =(face.texinfo>=0)?&(texinfo[face.texinfo]):0; +// if (tx && (tx->flags & (SURF_SKY|SURF_NODRAW))) +// return; + if (tx) + { + printf("id %d flags=%x\n",id,tx->flags); + } + printf("side: "); + for(int v=0;v<face.numedges;v++) + { + printf("(%f %f %f) ",XYZ(VertCoord(face,v))); + } + printf("\n"); + int ntris=face.numedges-2; + for(int tri=0;tri<ntris;tri++) + { + + AddTriangle(id,VertCoord(face,0),VertCoord(face,(tri+1)%face.numedges), + VertCoord(face,(tri+2)%face.numedges),Vector(1,1,1)); //colors[id % NELEMS(colors)]); + } +} + +void RayTracingEnvironment::InitializeFromLoadedBSP(void) +{ +// CUtlVector<uint8> PlanesToSkip; +// SidesToSkip.EnsureCapacity(numplanes); +// for(int s=0;s<numplanes;s++) +// SidesToSkip.AddToTail(0); +// for(int b=0;b<numbrushes;b++) +// if ((dbrushes[b].contents & MASK_OPAQUE)==0) +// { +// // transparent brush - mark all its sides as "do not process" +// for(int s=0;s<dbrushes[b].numsides;s++) +// { +// PlanesToSkip[s+dbrushes[b].firstside]=1; +// } + +// } +// // now, add all origfaces, omitting those whose sides are the ones we marked previously +// for(int c=0;c<numorigfaces;c++) +// { +// dface_t const &f=dorigfaces[c]; +// if (SidesToSkip[f.AddBSPFace(c,dorigfaces[c]); +// } + + + +// // ugly - I want to traverse all the faces. but there is no way to get from a face back to it's +// // original brush, and I need to get back to the face to the contents field of the brush. So I +// // will create a temporary mapping from a "side" to its brush. I can get from the face to it +// // side, which can get me back to its brush. + +// CUtlVector<uint8> OrigFaceVisited; +// OrigFaceVisited.EnsureCapacity(numorigfaces); +// int n_added=0; + +// for(int i=0;i<numorigfaces;i++) +// OrigFaceVisited.AddToTail(0); + +// for(int l=0;l<numleafs;l++) +// { +// dleaf_t const &lf=dleafs[l]; +// // if (lf.contents & MASK_OPAQUE) +// { +// for(int f=0;f<lf.numleaffaces;f++); +// { +// dface_t const &face=dfaces[f+lf.firstleafface]; +// if (OrigFaceVisited[face.origFace]==0) +// { +// dface_t const &oface=dorigfaces[face.origFace]; +// OrigFaceVisited[face.origFace]=1; +// n_added++; +// AddBSPFace(face.origFace,oface); +// } +// } +// } +// } +// printf("added %d of %d\n",n_added,numorigfaces); +// for(int c=0;c<numorigfaces;c++) +// { +// dface_t const &f=dorigfaces[c]; +// AddBSPFace(c,dorigfaces[c]); +// } + for(int c=0;c<numfaces;c++) + { +// dface_t const &f=dfaces[c]; + AddBSPFace(c,dorigfaces[c]); + } + +// AddTriangle(1234,Vector(51,145,-700),Vector(71,165,-700),Vector(51,165,-700),colors[5]); +} + |