hlsdk-xash3d/dlls/plane.cpp

60 lines
1.5 KiB
C++
Raw Permalink Normal View History

2016-06-04 15:24:23 +02:00
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
2016-06-04 15:24:23 +02:00
#include "extdll.h"
#include "plane.h"
//=========================================================
// Plane
//=========================================================
2016-07-31 15:48:50 +02:00
CPlane::CPlane( void )
2016-06-04 15:24:23 +02:00
{
m_fInitialized = FALSE;
}
//=========================================================
// InitializePlane - Takes a normal for the plane and a
// point on the plane and
//=========================================================
2016-07-31 15:48:50 +02:00
void CPlane::InitializePlane( const Vector &vecNormal, const Vector &vecPoint )
2016-06-04 15:24:23 +02:00
{
m_vecNormal = vecNormal;
2016-07-31 15:48:50 +02:00
m_flDist = DotProduct( m_vecNormal, vecPoint );
2016-06-04 15:24:23 +02:00
m_fInitialized = TRUE;
}
//=========================================================
// PointInFront - determines whether the given vector is
// in front of the plane.
//=========================================================
2016-07-31 15:48:50 +02:00
BOOL CPlane::PointInFront( const Vector &vecPoint )
2016-06-04 15:24:23 +02:00
{
float flFace;
2016-07-31 15:48:50 +02:00
if( !m_fInitialized )
2016-06-04 15:24:23 +02:00
{
return FALSE;
}
2016-07-31 15:48:50 +02:00
flFace = DotProduct( m_vecNormal, vecPoint ) - m_flDist;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if( flFace >= 0 )
2016-06-04 15:24:23 +02:00
{
return TRUE;
}
return FALSE;
}