diff --git a/code/cgame/FxPrimitives.cpp b/code/cgame/FxPrimitives.cpp index 74dc874a88..acff2c09c5 100644 --- a/code/cgame/FxPrimitives.cpp +++ b/code/cgame/FxPrimitives.cpp @@ -762,6 +762,30 @@ bool COrientedParticle::Update() // //---------------------------- +//---------------------------- +bool CLine::Cull( void ) +{ + vec3_t dir; + + VectorSubtract( mOrigin1, cg.refdef.vieworg, dir ); + + //Check if it's in front of the viewer + if ( (DotProduct( cg.refdef.viewaxis[0], dir )) >= 0 ) + { + return false; //don't cull + } + + VectorSubtract( mOrigin2, cg.refdef.vieworg, dir ); + + //Check if it's in front of the viewer + if ( (DotProduct( cg.refdef.viewaxis[0], dir )) >= 0 ) + { + return false; + } + + return true; //all points behind viewer +} + //---------------------------- void CLine::Draw() { diff --git a/code/cgame/FxPrimitives.h b/code/cgame/FxPrimitives.h index d84185dabc..b19065662e 100644 --- a/code/cgame/FxPrimitives.h +++ b/code/cgame/FxPrimitives.h @@ -360,6 +360,7 @@ class CLine : public CParticle virtual ~CLine() {} virtual void Die() {} virtual bool Update(); + virtual bool Cull(); inline void SetOrigin2( const vec3_t org2 ) { VectorCopy( org2, mOrigin2 ); } diff --git a/codeJK2/cgame/FxPrimitives.cpp b/codeJK2/cgame/FxPrimitives.cpp index 9cda3a5991..0b83bc19b9 100644 --- a/codeJK2/cgame/FxPrimitives.cpp +++ b/codeJK2/cgame/FxPrimitives.cpp @@ -667,6 +667,29 @@ bool COrientedParticle::Update() // //---------------------------- +bool CLine::Cull( void ) +{ + vec3_t dir; + + VectorSubtract( mOrigin1, cg.refdef.vieworg, dir ); + + //Check if it's in front of the viewer + if ( (DotProduct( cg.refdef.viewaxis[0], dir )) >= 0 ) + { + return false; //don't cull + } + + VectorSubtract( mOrigin2, cg.refdef.vieworg, dir ); + + //Check if it's in front of the viewer + if ( (DotProduct( cg.refdef.viewaxis[0], dir )) >= 0 ) + { + return false; + } + + return true; //all points behind viewer +} + //---------------------------- void CLine::Draw() { diff --git a/codeJK2/cgame/FxPrimitives.h b/codeJK2/cgame/FxPrimitives.h index 14db076df9..11738428c7 100644 --- a/codeJK2/cgame/FxPrimitives.h +++ b/codeJK2/cgame/FxPrimitives.h @@ -348,6 +348,7 @@ class CLine : public CParticle virtual ~CLine() {} virtual void Die() {} virtual bool Update(); + virtual bool Cull(); inline void SetOrigin2( const vec3_t org2 ) { VectorCopy( org2, mOrigin2 ); } diff --git a/codemp/client/FxPrimitives.cpp b/codemp/client/FxPrimitives.cpp index 1497924f6a..61ba18aeae 100644 --- a/codemp/client/FxPrimitives.cpp +++ b/codemp/client/FxPrimitives.cpp @@ -750,6 +750,30 @@ CLine::CLine(void) mRefEnt.reType = RT_LINE; } +//---------------------------- +bool CLine::Cull( void ) +{ + vec3_t dir; + + VectorSubtract( mOrigin1, theFxHelper.refdef->vieworg, dir ); + + //Check if it's in front of the viewer + if ( (DotProduct( theFxHelper.refdef->viewaxis[0], dir )) >= 0 ) + { + return false; //don't cull + } + + VectorSubtract( mOrigin2, theFxHelper.refdef->vieworg, dir ); + + //Check if it's in front of the viewer + if ( (DotProduct( theFxHelper.refdef->viewaxis[0], dir )) >= 0 ) + { + return false; + } + + return true; //all points behind viewer +} + //---------------------------- void CLine::Draw(void) { diff --git a/codemp/client/FxPrimitives.h b/codemp/client/FxPrimitives.h index b04ccf5a59..7d39c52856 100644 --- a/codemp/client/FxPrimitives.h +++ b/codemp/client/FxPrimitives.h @@ -401,6 +401,7 @@ class CLine : public CParticle virtual void Die() {} virtual bool Update(); + virtual bool Cull(); inline void SetOrigin2( vec3_t org2 ) { VectorCopy( org2, mOrigin2 ); } };