aboutsummaryrefslogtreecommitdiff
path: root/mp/src/utils/common/scratchpad_helpers.cpp
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
committerJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
commit39ed87570bdb2f86969d4be821c94b722dc71179 (patch)
treeabc53757f75f40c80278e87650ea92808274aa59 /mp/src/utils/common/scratchpad_helpers.cpp
downloadsource-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz
source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/utils/common/scratchpad_helpers.cpp')
-rw-r--r--mp/src/utils/common/scratchpad_helpers.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/mp/src/utils/common/scratchpad_helpers.cpp b/mp/src/utils/common/scratchpad_helpers.cpp
new file mode 100644
index 00000000..9a3c2d74
--- /dev/null
+++ b/mp/src/utils/common/scratchpad_helpers.cpp
@@ -0,0 +1,103 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================//
+
+#include "scratchpad_helpers.h"
+#include "bspfile.h"
+#include "bsplib.h"
+
+
+void ScratchPad_DrawWinding(
+ IScratchPad3D *pPad,
+ int nPoints,
+ Vector *pPoints,
+ Vector vColor,
+ Vector vOffset )
+{
+ for ( int i=0; i < nPoints; i++ )
+ {
+ pPad->DrawLine( CSPVert( pPoints[i]+vOffset, vColor ), CSPVert( pPoints[(i+1)%nPoints]+vOffset, vColor ) );
+ }
+}
+
+
+void ScratchPad_DrawFace( IScratchPad3D *pPad, dface_t *f, int iFaceNumber, const CSPColor &faceColor, const Vector &vOffset )
+{
+ // Draw the face's outline, then put text for its face index on it too.
+ CUtlVector<Vector> points;
+ for ( int iEdge = 0; iEdge < f->numedges; iEdge++ )
+ {
+ int v;
+ int se = dsurfedges[f->firstedge + iEdge];
+ if ( se < 0 )
+ v = dedges[-se].v[1];
+ else
+ v = dedges[se].v[0];
+
+ dvertex_t *dv = &dvertexes[v];
+ points.AddToTail( dv->point );
+ }
+
+ // Draw the outline.
+ Vector vCenter( 0, 0, 0 );
+ for ( int iEdge=0; iEdge < points.Count(); iEdge++ )
+ {
+ pPad->DrawLine( CSPVert( points[iEdge]+vOffset, faceColor ), CSPVert( points[(iEdge+1)%points.Count()]+vOffset, faceColor ) );
+ vCenter += points[iEdge];
+ }
+ vCenter /= points.Count();
+ vCenter += vOffset;
+
+ // Draw the text.
+ if ( iFaceNumber != -1 )
+ {
+ char str[64];
+ Q_snprintf( str, sizeof( str ), "%d", iFaceNumber );
+
+ CTextParams params;
+
+ params.m_bCentered = true;
+ params.m_bOutline = true;
+ params.m_flLetterWidth = 2;
+ params.m_vColor.Init( 1, 0, 0 );
+
+ VectorAngles( dplanes[f->planenum].normal, params.m_vAngles );
+ params.m_bTwoSided = true;
+
+ params.m_vPos = vCenter;
+
+ pPad->DrawText( str, params );
+ }
+}
+
+
+void ScratchPad_DrawWorld( IScratchPad3D *pPad, bool bDrawFaceNumbers, const CSPColor &faceColor )
+{
+ bool bAutoFlush = pPad->GetAutoFlush();
+ pPad->SetAutoFlush( false );
+
+ for ( int i=0; i < numleafs; i++ )
+ {
+ dleaf_t *l = &dleafs[i];
+ if ( l->contents & CONTENTS_DETAIL )
+ continue;
+
+ for ( int z=0; z < l->numleaffaces; z++ )
+ {
+ int iFace = dleaffaces[l->firstleafface+z];
+ dface_t *f = &dfaces[iFace];
+ ScratchPad_DrawFace( pPad, f, bDrawFaceNumbers ? i : -1 );
+ }
+ }
+
+ pPad->SetAutoFlush( bAutoFlush );
+}
+
+
+void ScratchPad_DrawWorld( bool bDrawFaceNumbers, const CSPColor &faceColor )
+{
+ IScratchPad3D *pPad = ScratchPad3D_Create();
+ ScratchPad_DrawWorld( pPad, bDrawFaceNumbers );
+}