diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/cmodel.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'public/cmodel.h')
| -rw-r--r-- | public/cmodel.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/public/cmodel.h b/public/cmodel.h new file mode 100644 index 0000000..b8b7444 --- /dev/null +++ b/public/cmodel.h @@ -0,0 +1,127 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// $NoKeywords: $ +//=============================================================================// + +#ifndef CMODEL_H +#define CMODEL_H +#ifdef _WIN32 +#pragma once +#endif + +#include "trace.h" +#include "tier0/dbg.h" +#include "basehandle.h" + +struct edict_t; +struct model_t; + +/* +============================================================== + +COLLISION DETECTION + +============================================================== +*/ + +#include "bspflags.h" +//#include "mathlib/vector.h" + +// gi.BoxEdicts() can return a list of either solid or trigger entities +// FIXME: eliminate AREA_ distinction? +#define AREA_SOLID 1 +#define AREA_TRIGGERS 2 + +#include "vcollide.h" + +struct cmodel_t +{ + Vector mins, maxs; + Vector origin; // for sounds or lights + int headnode; + + vcollide_t vcollisionData; +}; + +struct csurface_t +{ + const char *name; + short surfaceProps; + unsigned short flags; // BUGBUG: These are declared per surface, not per material, but this database is per-material now +}; + +//----------------------------------------------------------------------------- +// A ray... +//----------------------------------------------------------------------------- + +struct Ray_t +{ + VectorAligned m_Start; // starting point, centered within the extents + VectorAligned m_Delta; // direction + length of the ray + VectorAligned m_StartOffset; // Add this to m_Start to get the actual ray start + VectorAligned m_Extents; // Describes an axis aligned box extruded along a ray + bool m_IsRay; // are the extents zero? + bool m_IsSwept; // is delta != 0? + + void Init( Vector const& start, Vector const& end ) + { + VectorSubtract( end, start, m_Delta ); + + m_IsSwept = (m_Delta.LengthSqr() != 0); + + VectorClear( m_Extents ); + m_IsRay = true; + + // Offset m_Start to be in the center of the box... + VectorClear( m_StartOffset ); + VectorCopy( start, m_Start ); + } + + void Init( Vector const& start, Vector const& end, Vector const& mins, Vector const& maxs ) + { + VectorSubtract( end, start, m_Delta ); + + m_IsSwept = (m_Delta.LengthSqr() != 0); + + VectorSubtract( maxs, mins, m_Extents ); + m_Extents *= 0.5f; + m_IsRay = (m_Extents.LengthSqr() < 1e-6); + + // Offset m_Start to be in the center of the box... + VectorAdd( mins, maxs, m_StartOffset ); + m_StartOffset *= 0.5f; + VectorAdd( start, m_StartOffset, m_Start ); + m_StartOffset *= -1.0f; + } + + // compute inverse delta + Vector InvDelta() const + { + Vector vecInvDelta; + for ( int iAxis = 0; iAxis < 3; ++iAxis ) + { + if ( m_Delta[iAxis] != 0.0f ) + { + vecInvDelta[iAxis] = 1.0f / m_Delta[iAxis]; + } + else + { + vecInvDelta[iAxis] = FLT_MAX; + } + } + return vecInvDelta; + } + +private: +}; + + +#endif // CMODEL_H + + +#include "gametrace.h" + |