Skip to content

Commit

Permalink
Merge pull request #1239 from JACoders/fix-line-fx
Browse files Browse the repository at this point in the history
Applied proper fix from jaMME for lines disappearing at certain angles
  • Loading branch information
SomaZ authored Oct 2, 2024
2 parents ad98f60 + 41af0cd commit cb52f9f
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
24 changes: 24 additions & 0 deletions code/cgame/FxPrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
1 change: 1 addition & 0 deletions code/cgame/FxPrimitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ); }
Expand Down
23 changes: 23 additions & 0 deletions codeJK2/cgame/FxPrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
1 change: 1 addition & 0 deletions codeJK2/cgame/FxPrimitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ); }
Expand Down
24 changes: 24 additions & 0 deletions codemp/client/FxPrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions codemp/client/FxPrimitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ); }
};
Expand Down

0 comments on commit cb52f9f

Please sign in to comment.