Skip to content

Commit

Permalink
fix: tac-map projection and player facing pip on map.
Browse files Browse the repository at this point in the history
  • Loading branch information
Subject9x committed Oct 29, 2024
1 parent 0b63a43 commit b87f7d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
4 changes: 1 addition & 3 deletions client/ui/hud/hud_tacmap.qc
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ void() hud_render_tactical_map={
}

//render player pointer
//arrow = gui_angleToArrow(input_angles_y - 90);
arrowAng = anglemod( 90 - view_angles_y);
makevectors(view_angles);
arrowAng = anglemod( view_angles_y + 270);
playerMapOrg = gui_mapCoordToImgCoord(mapMins, map_size, CLIENT_vis_org, mapOrg, mapImgSize);
drawrotpic(playerMapOrg, "gfx/hud/map_up.png", '12 12', '6 6', arrowAng, '0.25 1 2', 1, 0);
};
Expand Down
19 changes: 10 additions & 9 deletions common/ui/gui_api.qc
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ vector(vector startSize, vector targsize) gui_newAspectRatio={
};

float(float pct, float ox, float mx) gui_percentCustom={
pct = pct / ox;
pct = pct * mx;
pct = (pct / ox) * mx;
return pct;
};

Expand Down Expand Up @@ -342,17 +341,19 @@ void( vector org, vector siz, vector fontSize, vector colr, float alpha, float d
drawpic(vOrg + [i * celSize, 0], TEXT64_RT, [celSize,celSize], colr, alpha, drawFlag);
};

/*
Projects 3D engine coords to a 2D map space, attempting to correct for abnormal map sizes.
*/
vector(vector areaMins, vector areaMinAndMax, vector objectCoords, vector uiOffsetStart, vector uiAreaSize) gui_mapCoordToImgCoord={
local vector mapCenter, objectTransform, objectPercent, objectUIOrg;

mapCenter_x = ((areaMins_x*-1)/areaMinAndMax_x) * areaMinAndMax_x;
mapCenter_x = areaMinAndMax_x - mapCenter_x;

mapCenter_y = ((areaMins_y*-1)/areaMinAndMax_y) * areaMinAndMax_y;
mapCenter_y = areaMinAndMax_y - mapCenter_y;

objectTransform = mapCenter - objectCoords;
mapCenter_x = ((areaMins_x * -1) / areaMinAndMax_x) * areaMinAndMax_x;

mapCenter_y = ((areaMins_y * -1) / areaMinAndMax_y) * areaMinAndMax_y;

objectTransform = objectCoords + mapCenter;
objectTransform_y = areaMinAndMax_y + (objectTransform_y * -1);
objectTransform_z = 0;

objectPercent = gui_percentCustomVec(objectTransform, areaMinAndMax, uiAreaSize);
Expand Down

0 comments on commit b87f7d0

Please sign in to comment.