[STORM-1981] Change tracking beacons to extend to the ground and (optionally) vertically indicate direction

Jonathan Yap's beacon enhancements, with a Singular twist!
This commit is contained in:
Inusaito Sayori
2014-02-06 17:23:28 -05:00
parent eb4b0d630f
commit 29d5c951c5

View File

@@ -427,7 +427,7 @@ const std::string& LLTracker::getTrackedLocationName()
return instance()->mTrackedLocationName; return instance()->mTrackedLocationName;
} }
F32 pulse_func(F32 t, F32 z) F32 pulse_func(F32 t, F32 z, bool down)
{ {
if (!LLTracker::sCheesyBeacon) if (!LLTracker::sCheesyBeacon)
{ {
@@ -435,7 +435,14 @@ F32 pulse_func(F32 t, F32 z)
} }
t *= F_PI; t *= F_PI;
if (down)
{
z += t*64.f - 256.f;
}
else
{
z -= t*64.f - 256.f; z -= t*64.f - 256.f;
}
F32 a = cosf(z*F_PI/512.f)*10.0f; F32 a = cosf(z*F_PI/512.f)*10.0f;
a = llmax(a, 9.9f); a = llmax(a, 9.9f);
@@ -489,51 +496,27 @@ void draw_shockwave(F32 center_z, F32 t, S32 steps, LLColor4 color)
gGL.end(); gGL.end();
} }
void draw_beacon(LLVector3 pos_agent, bool down, LLColor4 fogged_color, F32 dist)
// static
void LLTracker::renderBeacon(LLVector3d pos_global,
const LLColor4& color,
LLHUDText* hud_textp,
const std::string& label )
{ {
sCheesyBeacon = gSavedSettings.getBOOL("CheesyBeacon"); const U32 BEACON_VERTS = 256;
LLVector3d to_vec = pos_global - gAgentCamera.getCameraPositionGlobal(); F32 step;
F32 dist = (F32)to_vec.magVec();
F32 color_frac = 1.f;
if (dist > 0.99f * LLViewerCamera::getInstance()->getFar())
{
color_frac = 0.4f;
// pos_global = gAgentCamera.getCameraPositionGlobal() + 0.99f*(LLViewerCamera::getInstance()->getFar()/dist)*to_vec;
}
else
{
color_frac = 1.f - 0.6f*(dist/LLViewerCamera::getInstance()->getFar());
}
LLColor4 fogged_color = color_frac * color + (1 - color_frac)*gSky.getFogColor();
F32 FADE_DIST = 3.f;
fogged_color.mV[3] = llmax(0.2f, llmin(0.5f,(dist-FADE_DIST)/FADE_DIST));
LLVector3 pos_agent = gAgent.getPosAgentFromGlobal(pos_global);
LLGLSTracker gls_tracker; // default+ CULL_FACE + LIGHTING + GL_BLEND + GL_ALPHA_TEST
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLGLDisable cull_face(GL_CULL_FACE);
LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.pushMatrix(); gGL.pushMatrix();
if (down)
{ {
gGL.translatef(pos_agent.mV[0], pos_agent.mV[1], pos_agent.mV[2]); gGL.translatef(pos_agent.mV[0], pos_agent.mV[1], pos_agent.mV[2]);
draw_shockwave(1024.f, gRenderStartTime.getElapsedTimeF32(), 32, fogged_color); draw_shockwave(1024.f, gRenderStartTime.getElapsedTimeF32(), 32, fogged_color);
step = (8192.0f - pos_agent.mV[2]) / BEACON_VERTS;
}
else
{
gGL.translatef(pos_agent.mV[0], pos_agent.mV[1], 0);
step = pos_agent[2] / BEACON_VERTS;
}
gGL.color4fv(fogged_color.mV); gGL.color4fv(fogged_color.mV);
const U32 BEACON_VERTS = 256;
const F32 step = 1024.0f/BEACON_VERTS;
LLVector3 x_axis = LLViewerCamera::getInstance()->getLeftAxis(); LLVector3 x_axis = LLViewerCamera::getInstance()->getLeftAxis();
F32 t = gRenderStartTime.getElapsedTimeF32(); F32 t = gRenderStartTime.getElapsedTimeF32();
@@ -547,8 +530,8 @@ void LLTracker::renderBeacon(LLVector3d pos_global,
F32 z = i * step; F32 z = i * step;
F32 z_next = (i+1)*step; F32 z_next = (i+1)*step;
F32 a = pulse_func(t, z); F32 a = pulse_func(t, z, down);
F32 an = pulse_func(t, z_next); F32 an = pulse_func(t, z_next, down);
LLColor4 c_col = fogged_color + LLColor4(a,a,a,a); LLColor4 c_col = fogged_color + LLColor4(a,a,a,a);
LLColor4 col_next = fogged_color + LLColor4(an,an,an,an); LLColor4 col_next = fogged_color + LLColor4(an,an,an,an);
@@ -579,8 +562,47 @@ void LLTracker::renderBeacon(LLVector3d pos_global,
gGL.end(); gGL.end();
} }
}
gGL.popMatrix(); gGL.popMatrix();
}
// static
void LLTracker::renderBeacon(LLVector3d pos_global,
const LLColor4& color,
LLHUDText* hud_textp,
const std::string& label )
{
const LLColor4& color_under(LLColor4::blue);
sCheesyBeacon = gSavedSettings.getBOOL("CheesyBeacon");
LLVector3d to_vec = pos_global - gAgentCamera.getCameraPositionGlobal();
F32 dist = (F32)to_vec.magVec();
F32 color_frac = 1.f;
if (dist > 0.99f * LLViewerCamera::getInstance()->getFar())
{
color_frac = 0.4f;
// pos_global = gAgentCamera.getCameraPositionGlobal() + 0.99f*(LLViewerCamera::getInstance()->getFar()/dist)*to_vec;
}
else
{
color_frac = 1.f - 0.6f*(dist/LLViewerCamera::getInstance()->getFar());
}
LLColor4 fogged_color = color_frac * color + (1 - color_frac)*gSky.getFogColor();
LLColor4 fogged_color_under = color_frac * color_under + (1 - color_frac) * gSky.getFogColor();
F32 FADE_DIST = 3.f;
fogged_color.mV[3] = llmax(0.2f, llmin(0.5f,(dist-FADE_DIST)/FADE_DIST));
fogged_color_under.mV[3] = llmax(0.2f, llmin(0.5f,(dist-FADE_DIST)/FADE_DIST));
LLVector3 pos_agent = gAgent.getPosAgentFromGlobal(pos_global);
LLGLSTracker gls_tracker; // default+ CULL_FACE + LIGHTING + GL_BLEND + GL_ALPHA_TEST
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLGLDisable cull_face(GL_CULL_FACE);
LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
draw_beacon(pos_agent, true, fogged_color, dist);
draw_beacon(pos_agent, false, fogged_color_under, dist);
std::string text; std::string text;
text = llformat( "%.0f m", to_vec.magVec()); text = llformat( "%.0f m", to_vec.magVec());