diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /sp/src/public/mathlib/polyhedron.h | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'sp/src/public/mathlib/polyhedron.h')
| -rw-r--r-- | sp/src/public/mathlib/polyhedron.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/sp/src/public/mathlib/polyhedron.h b/sp/src/public/mathlib/polyhedron.h new file mode 100644 index 00000000..6c51d432 --- /dev/null +++ b/sp/src/public/mathlib/polyhedron.h @@ -0,0 +1,73 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+
+#ifndef POLYHEDRON_H_
+#define POLYHEDRON_H_
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "mathlib/mathlib.h"
+
+
+
+struct Polyhedron_IndexedLine_t
+{
+ unsigned short iPointIndices[2];
+};
+
+struct Polyhedron_IndexedLineReference_t
+{
+ unsigned short iLineIndex;
+ unsigned char iEndPointIndex; //since two polygons reference any one line, one needs to traverse the line backwards, this flags that behavior
+};
+
+struct Polyhedron_IndexedPolygon_t
+{
+ unsigned short iFirstIndex;
+ unsigned short iIndexCount;
+ Vector polyNormal;
+};
+
+class CPolyhedron //made into a class because it's going virtual to support distinctions between temp and permanent versions
+{
+public:
+ Vector *pVertices;
+ Polyhedron_IndexedLine_t *pLines;
+ Polyhedron_IndexedLineReference_t *pIndices;
+ Polyhedron_IndexedPolygon_t *pPolygons;
+
+ unsigned short iVertexCount;
+ unsigned short iLineCount;
+ unsigned short iIndexCount;
+ unsigned short iPolygonCount;
+
+ virtual ~CPolyhedron( void ) {};
+ virtual void Release( void ) = 0;
+ Vector Center( void );
+};
+
+class CPolyhedron_AllocByNew : public CPolyhedron
+{
+public:
+ virtual void Release( void );
+ static CPolyhedron_AllocByNew *Allocate( unsigned short iVertices, unsigned short iLines, unsigned short iIndices, unsigned short iPolygons ); //creates the polyhedron along with enough memory to hold all it's data in a single allocation
+
+private:
+ CPolyhedron_AllocByNew( void ) { }; //CPolyhedron_AllocByNew::Allocate() is the only way to create one of these.
+};
+
+CPolyhedron *GeneratePolyhedronFromPlanes( const float *pOutwardFacingPlanes, int iPlaneCount, float fOnPlaneEpsilon, bool bUseTemporaryMemory = false ); //be sure to polyhedron->Release()
+CPolyhedron *ClipPolyhedron( const CPolyhedron *pExistingPolyhedron, const float *pOutwardFacingPlanes, int iPlaneCount, float fOnPlaneEpsilon, bool bUseTemporaryMemory = false ); //this does NOT modify/delete the existing polyhedron
+
+CPolyhedron *GetTempPolyhedron( unsigned short iVertices, unsigned short iLines, unsigned short iIndices, unsigned short iPolygons ); //grab the temporary polyhedron. Avoids new/delete for quick work. Can only be in use by one chunk of code at a time
+
+
+#endif //#ifndef POLYHEDRON_H_
+
|