X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=r_crosshairs.c;h=aeec2190f6a16199d0d420daaa006b2eca7193e3;hb=9c94125fe3b3877ebb6b0ec22db94a32df0cc7a5;hp=bf5018bb46cb7d35caa71d12a9282bd516f418b3;hpb=946b0f6826047585b551278c674053b2869b0dff;p=xonotic%2Fdarkplaces.git diff --git a/r_crosshairs.c b/r_crosshairs.c index bf5018bb..aeec2190 100644 --- a/r_crosshairs.c +++ b/r_crosshairs.c @@ -7,10 +7,10 @@ cvar_t crosshair_alpha = {CVAR_SAVE, "crosshair_alpha", "1"}; cvar_t crosshair_flashspeed = {CVAR_SAVE, "crosshair_flashspeed", "2"}; cvar_t crosshair_flashrange = {CVAR_SAVE, "crosshair_flashrange", "0.1"}; cvar_t crosshair_size = {CVAR_SAVE, "crosshair_size", "1"}; -cvar_t crosshair_static = {CVAR_SAVE, "crosshair_static", "0"}; +cvar_t crosshair_static = {CVAR_SAVE, "crosshair_static", "1"}; // must match NUMCROSSHAIRS in gl_draw.c -#define NUMCROSSHAIRS 5 +#define NUMCROSSHAIRS 6 void R_Crosshairs_Init(void) { @@ -25,7 +25,7 @@ void R_Crosshairs_Init(void) void R_GetCrosshairColor(float *out) { int i; - qbyte *color; + unsigned char *color; float scale, base; if (cl.viewentity >= 1 && cl.viewentity <= cl.maxclients) { @@ -37,7 +37,7 @@ void R_GetCrosshairColor(float *out) } else i = 15; - color = (qbyte *) &palette_complete[i]; + color = (unsigned char *) &palette_complete[i]; if (crosshair_flashspeed.value >= 0.01f) base = (sin(realtime * crosshair_flashspeed.value * (M_PI*2.0f)) * crosshair_flashrange.value); else @@ -62,6 +62,7 @@ void R_DrawWorldCrosshair(void) vec3_t v1, v2, spriteorigin; vec_t spritescale; vec4_t color; + trace_t trace; if (r_letterbox.value) return; if (crosshair_static.integer) @@ -71,23 +72,25 @@ void R_DrawWorldCrosshair(void) return; if (!cl.viewentity || !cl_entities[cl.viewentity].state_current.active) return; - pic = Draw_CachePic(va("gfx/crosshair%i.tga", num)); + pic = Draw_CachePic(va("gfx/crosshair%i", num), true); if (!pic) return; R_GetCrosshairColor(color); // trace the shot path up to a certain distance - VectorCopy(cl_entities[cl.viewentity].render.origin, v1); + Matrix4x4_OriginFromMatrix(&cl_entities[cl.viewentity].render.matrix, v1); v1[2] += 16; // HACK: this depends on the QC // get the forward vector for the gun (not the view) AngleVectors(cl.viewangles, v2, NULL, NULL); //VectorCopy(r_vieworigin, v1); VectorMA(v1, 8192, v2, v2); - spritescale = CL_TraceLine(v1, v2, spriteorigin, NULL, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY) * (8192.0f / 40.0f) * crosshair_size.value; + trace = CL_TraceBox(v1, vec3_origin, vec3_origin, v2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, false); + spritescale = trace.fraction * (8192.0f / 40.0f) * crosshair_size.value; + VectorCopy(trace.endpos, spriteorigin); // draw the sprite - R_DrawSprite(GL_SRC_ALPHA, GL_ONE, pic->tex, true, spriteorigin, r_viewright, r_viewup, spritescale, -spritescale, -spritescale, spritescale, color[0], color[1], color[2], color[3]); + R_DrawSprite(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, pic->tex, NULL, true, spriteorigin, r_viewright, r_viewup, spritescale, -spritescale, -spritescale, spritescale, color[0], color[1], color[2], color[3]); } void R_Draw2DCrosshair(void) @@ -104,11 +107,11 @@ void R_Draw2DCrosshair(void) return; if (!cl.viewentity || !cl_entities[cl.viewentity].state_current.active) return; - pic = Draw_CachePic(va("gfx/crosshair%i.tga", num)); + pic = Draw_CachePic(va("gfx/crosshair%i", num), true); if (pic) { R_GetCrosshairColor(color); - DrawQ_Pic((vid.conwidth - pic->width * crosshair_size.value) * 0.5f, (vid.conheight - pic->height * crosshair_size.value) * 0.5f, pic->name, pic->width * crosshair_size.value, pic->height * crosshair_size.value, color[0], color[1], color[2], color[3], 0); + DrawQ_Pic((vid_conwidth.integer - pic->width * crosshair_size.value) * 0.5f, (vid_conheight.integer - pic->height * crosshair_size.value) * 0.5f, pic->name, pic->width * crosshair_size.value, pic->height * crosshair_size.value, color[0], color[1], color[2], color[3], 0); } }