Skip to content

Commit cb52f9f

Browse files
authored
Merge pull request #1239 from JACoders/fix-line-fx
Applied proper fix from jaMME for lines disappearing at certain angles
2 parents ad98f60 + 41af0cd commit cb52f9f

File tree

6 files changed

+74
-0
lines changed

6 files changed

+74
-0
lines changed

code/cgame/FxPrimitives.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,30 @@ bool COrientedParticle::Update()
762762
//
763763
//----------------------------
764764

765+
//----------------------------
766+
bool CLine::Cull( void )
767+
{
768+
vec3_t dir;
769+
770+
VectorSubtract( mOrigin1, cg.refdef.vieworg, dir );
771+
772+
//Check if it's in front of the viewer
773+
if ( (DotProduct( cg.refdef.viewaxis[0], dir )) >= 0 )
774+
{
775+
return false; //don't cull
776+
}
777+
778+
VectorSubtract( mOrigin2, cg.refdef.vieworg, dir );
779+
780+
//Check if it's in front of the viewer
781+
if ( (DotProduct( cg.refdef.viewaxis[0], dir )) >= 0 )
782+
{
783+
return false;
784+
}
785+
786+
return true; //all points behind viewer
787+
}
788+
765789
//----------------------------
766790
void CLine::Draw()
767791
{

code/cgame/FxPrimitives.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ class CLine : public CParticle
360360
virtual ~CLine() {}
361361
virtual void Die() {}
362362
virtual bool Update();
363+
virtual bool Cull();
363364

364365

365366
inline void SetOrigin2( const vec3_t org2 ) { VectorCopy( org2, mOrigin2 ); }

codeJK2/cgame/FxPrimitives.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,29 @@ bool COrientedParticle::Update()
667667
//
668668
//----------------------------
669669

670+
bool CLine::Cull( void )
671+
{
672+
vec3_t dir;
673+
674+
VectorSubtract( mOrigin1, cg.refdef.vieworg, dir );
675+
676+
//Check if it's in front of the viewer
677+
if ( (DotProduct( cg.refdef.viewaxis[0], dir )) >= 0 )
678+
{
679+
return false; //don't cull
680+
}
681+
682+
VectorSubtract( mOrigin2, cg.refdef.vieworg, dir );
683+
684+
//Check if it's in front of the viewer
685+
if ( (DotProduct( cg.refdef.viewaxis[0], dir )) >= 0 )
686+
{
687+
return false;
688+
}
689+
690+
return true; //all points behind viewer
691+
}
692+
670693
//----------------------------
671694
void CLine::Draw()
672695
{

codeJK2/cgame/FxPrimitives.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ class CLine : public CParticle
348348
virtual ~CLine() {}
349349
virtual void Die() {}
350350
virtual bool Update();
351+
virtual bool Cull();
351352

352353

353354
inline void SetOrigin2( const vec3_t org2 ) { VectorCopy( org2, mOrigin2 ); }

codemp/client/FxPrimitives.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,30 @@ CLine::CLine(void)
750750
mRefEnt.reType = RT_LINE;
751751
}
752752

753+
//----------------------------
754+
bool CLine::Cull( void )
755+
{
756+
vec3_t dir;
757+
758+
VectorSubtract( mOrigin1, theFxHelper.refdef->vieworg, dir );
759+
760+
//Check if it's in front of the viewer
761+
if ( (DotProduct( theFxHelper.refdef->viewaxis[0], dir )) >= 0 )
762+
{
763+
return false; //don't cull
764+
}
765+
766+
VectorSubtract( mOrigin2, theFxHelper.refdef->vieworg, dir );
767+
768+
//Check if it's in front of the viewer
769+
if ( (DotProduct( theFxHelper.refdef->viewaxis[0], dir )) >= 0 )
770+
{
771+
return false;
772+
}
773+
774+
return true; //all points behind viewer
775+
}
776+
753777
//----------------------------
754778
void CLine::Draw(void)
755779
{

codemp/client/FxPrimitives.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ class CLine : public CParticle
401401
virtual void Die() {}
402402

403403
virtual bool Update();
404+
virtual bool Cull();
404405

405406
inline void SetOrigin2( vec3_t org2 ) { VectorCopy( org2, mOrigin2 ); }
406407
};

0 commit comments

Comments
 (0)