Small fixups to new code.
This commit is contained in:
parent
a5e58add12
commit
884ad51aa4
3 changed files with 18 additions and 16 deletions
|
|
@ -28,7 +28,7 @@ extend Class SWWMHandler
|
|||
transient ui Vector3 tpos[MAX_CROSSHAIRS]; // current trace positions in world space
|
||||
transient ui Color tcol[MAX_CROSSHAIRS]; // current crosshair colors
|
||||
transient ui SWWMProjectionData tprojdata; // cached Fast projection data
|
||||
transient ui Vector2 lagvpos[MAX_CROSSHAIRS]; // "lagged" clip pos for crosshairs
|
||||
transient ui Vector3 lagndc[MAX_CROSSHAIRS]; // "lagged" clip pos for crosshairs
|
||||
transient ui bool tactive[MAX_CROSSHAIRS]; // denotes that the crosshair is "active" for drawing
|
||||
transient ui double prevframe; // previous frame timestamp
|
||||
|
||||
|
|
@ -128,8 +128,7 @@ extend Class SWWMHandler
|
|||
if ( int(ts.x)%2 ) oddfix.x = -floor(sz/2.)+1.;
|
||||
if ( int(ts.y)%2 ) oddfix.y = -floor(sz/2.)+1.;
|
||||
SWWMUtility.PrepareProjData(tprojdata,e.ViewPos,e.ViewAngle,e.ViewPitch,e.ViewRoll,players[consoleplayer].fov);
|
||||
int cliptop = tprojdata.viewy, clipbottom = tprojdata.viewy+tprojdata.viewh,
|
||||
clipleft = tprojdata.viewx, clipright = tprojdata.viewx+tprojdata.vieww;
|
||||
Screen.SetClipRect(tprojdata.viewx,tprojdata.viewy,tprojdata.vieww,tprojdata.viewh);
|
||||
Vector2 actpos[MAX_CROSSHAIRS];
|
||||
for ( int i=0; i<MAX_CROSSHAIRS; i++ )
|
||||
{
|
||||
|
|
@ -142,26 +141,29 @@ extend Class SWWMHandler
|
|||
// invalid or behind view, skip
|
||||
if ( ndc.z <= 0. ) continue;
|
||||
Vector2 vpos = SWWMUtility.NDCToViewport(tprojdata,ndc);
|
||||
if ( !prevframe ) lagvpos[i] = vpos;
|
||||
Vector2 oldvpos = lagvpos[i];
|
||||
lagvpos[i] = SWWMUtility.LerpVector2(lagvpos[i],vpos,theta);
|
||||
if ( !prevframe ) lagndc[i] = ndc;
|
||||
Vector2 oldvpos = SWWMUtility.NDCToViewport(tprojdata,lagndc[i]);
|
||||
lagndc[i] = SWWMUtility.LerpVector3(lagndc[i],ndc,theta);
|
||||
if ( lagndc[i].z <= 0. ) continue;
|
||||
Vector2 lagvpos = SWWMUtility.NDCToViewport(tprojdata,lagndc[i]);
|
||||
if ( !tactive[i] ) continue;
|
||||
// draw
|
||||
int streak = int(max(abs(oldvpos.x-lagvpos[i].x),abs(oldvpos.y-lagvpos[i].y)));
|
||||
int streak = int(max(abs(oldvpos.x-lagvpos.x),abs(oldvpos.y-lagvpos.y)));
|
||||
double alph = 1.;
|
||||
if ( i < numcrosshairs ) actpos[i] = lagvpos[i];
|
||||
if ( i < numcrosshairs ) actpos[i] = lagvpos;
|
||||
else
|
||||
{
|
||||
// unused crosshairs must "linger" until they merge with the ones that are drawn
|
||||
int j = (i-numcrosshairs)%numcrosshairs;
|
||||
double dist = (lagvpos[i]-actpos[j]).length();
|
||||
double dist = (lagvpos-actpos[j]).length();
|
||||
if ( (streak <= 0) && (dist < 1.) )
|
||||
tactive[i] = false;
|
||||
alph = clamp(dist/max(2,streak+2),0.,1.); // this should make the merge less jarring
|
||||
}
|
||||
for ( int j=0; j<streak; j++ ) Screen.DrawTexture(ctex,false,int(SWWMUtility.lerp(oldvpos.x,lagvpos[i].x,j/double(streak)))+oddfix.x,int(SWWMUtility.lerp(oldvpos.y,lagvpos[i].y,j/double(streak)))+oddfix.y,DTA_DestWidthF,ts.x*sz,DTA_DestHeightF,ts.y*sz,DTA_AlphaChannel,true,DTA_FillColor,ccol,DTA_Alpha,((j*.5)/streak)*alph,DTA_ClipTop,cliptop,DTA_ClipBottom,clipbottom,DTA_ClipLeft,clipleft,DTA_ClipRight,clipright);
|
||||
Screen.DrawTexture(ctex,false,int(lagvpos[i].x)+oddfix.x,int(lagvpos[i].y)+oddfix.y,DTA_DestWidthF,ts.x*sz,DTA_DestHeightF,ts.y*sz,DTA_AlphaChannel,true,DTA_FillColor,ccol,DTA_Alpha,alph,DTA_ClipTop,cliptop,DTA_ClipBottom,clipbottom,DTA_ClipLeft,clipleft,DTA_ClipRight,clipright);
|
||||
for ( int j=0; j<streak; j++ ) Screen.DrawTexture(ctex,false,int(SWWMUtility.lerp(oldvpos.x,lagvpos.x,j/double(streak)))+oddfix.x,int(SWWMUtility.lerp(oldvpos.y,lagvpos.y,j/double(streak)))+oddfix.y,DTA_DestWidthF,ts.x*sz,DTA_DestHeightF,ts.y*sz,DTA_AlphaChannel,true,DTA_FillColor,ccol,DTA_Alpha,((j*.5)/streak)*alph);
|
||||
Screen.DrawTexture(ctex,false,int(lagvpos.x)+oddfix.x,int(lagvpos.y)+oddfix.y,DTA_DestWidthF,ts.x*sz,DTA_DestHeightF,ts.y*sz,DTA_AlphaChannel,true,DTA_FillColor,ccol,DTA_Alpha,alph);
|
||||
}
|
||||
Screen.ClearClipRect();
|
||||
prevframe = curframe;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@ Class Hellblazer : SWWMWeapon
|
|||
Super.RenderUnderlay(e);
|
||||
if ( !LockIcon ) LockIcon = TexMan.CheckForTexture("graphics/HUD/HellblazerMissileLock.png");
|
||||
SWWMUtility.PrepareProjData(projdata,e.ViewPos,e.ViewAngle,e.ViewPitch,e.ViewRoll,players[consoleplayer].fov);
|
||||
int cliptop = projdata.viewy, clipbottom = projdata.viewy+projdata.viewh,
|
||||
clipleft = projdata.viewx, clipright = projdata.viewx+projdata.vieww;
|
||||
Screen.SetClipRect(projdata.viewx,projdata.viewy,projdata.vieww,projdata.viewh);
|
||||
double hs = max(min(floor(Screen.GetWidth()/640.),floor(Screen.GetHeight()/360.)),1.);
|
||||
Vector2 ss = (Screen.GetWidth()/hs,Screen.GetHeight()/hs);
|
||||
for ( int i=0; i<3; i++ )
|
||||
|
|
@ -47,8 +46,9 @@ Class Hellblazer : SWWMWeapon
|
|||
Vector3 ndc = SWWMUtility.ProjectPoint(projdata,e.viewpos+level.Vec3Diff(e.viewpos,tpos+(0,0,seektarget[i].Height/2)));
|
||||
if ( ndc.z <= 0. ) continue;
|
||||
Vector2 vpos = SWWMUtility.NDCToViewport(projdata,ndc);
|
||||
Screen.DrawTexture(LockIcon,false,vpos.x/hs,vpos.y/hs,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_CenterOffset,true,DTA_ClipTop,cliptop,DTA_ClipBottom,clipbottom,DTA_ClipLeft,clipleft,DTA_ClipRight,clipright);
|
||||
Screen.DrawTexture(LockIcon,false,vpos.x/hs,vpos.y/hs,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_CenterOffset,true);
|
||||
}
|
||||
Screen.ClearClipRect();
|
||||
}
|
||||
|
||||
override Vector3 GetTraceOffset( int index )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue