Pie menus were looking up settings each frame...

How am I the first to notice this.
Also, while we're here, let's clean up duplicate code and make some constexprs
This commit is contained in:
Lirusaito
2019-04-19 02:29:12 -04:00
parent 1244d5df03
commit 308a249891

View File

@@ -5264,30 +5264,30 @@ void LLPieMenu::draw()
mHoverIndex = -1; mHoverIndex = -1;
} }
F32 width = (F32) getRect().getWidth(); const auto& rect = getRect();
F32 height = (F32) getRect().getHeight(); // correct for non-square pixels
mCurRadius = PIE_SCALE_FACTOR * llmax( width/2, height/2 ); F32 center_x = ((F32) rect.getWidth())/2;
F32 center_y = ((F32) rect.getHeight())/2;
constexpr S32 steps = 100;
mCurRadius = PIE_SCALE_FACTOR * llmax(center_x, center_y);
mOuterRingAlpha = mUseInfiniteRadius ? 0.f : 1.f; mOuterRingAlpha = mUseInfiniteRadius ? 0.f : 1.f;
if (mShrinkBorderTimer.getStarted()) if (mShrinkBorderTimer.getStarted())
{ {
mOuterRingAlpha = clamp_rescale(mShrinkBorderTimer.getElapsedTimeF32(), 0.f, PIE_SHRINK_TIME, 0.f, 1.f); const auto& elapsed = mShrinkBorderTimer.getElapsedTimeF32();
mCurRadius *= clamp_rescale(mShrinkBorderTimer.getElapsedTimeF32(), 0.f, PIE_SHRINK_TIME, 1.f, 1.f / PIE_SCALE_FACTOR); mOuterRingAlpha = clamp_rescale(elapsed, 0.f, PIE_SHRINK_TIME, 0.f, 1.f);
mCurRadius *= clamp_rescale(elapsed, 0.f, PIE_SHRINK_TIME, 1.f, 1.f / PIE_SCALE_FACTOR);
} }
// correct for non-square pixels
F32 center_x = width/2;
F32 center_y = height/2;
S32 steps = 100;
gGL.pushUIMatrix(); gGL.pushUIMatrix();
{ {
gGL.translateUI(center_x, center_y, 0.f); gGL.translateUI(center_x, center_y, 0.f);
F32 line_width = LLUI::sConfigGroup->getF32("PieMenuLineWidth"); static const LLUICachedControl<F32> line_width("PieMenuLineWidth");
LLColor4 line_color = LLUI::sColorsGroup->getColor("PieMenuLineColor"); static const LLCachedControl<LLColor4> line_color(*LLUI::sColorsGroup, "PieMenuLineColor");
LLColor4 bg_color = LLUI::sColorsGroup->getColor("PieMenuBgColor"); static const LLCachedControl<LLColor4> bg_color(*LLUI::sColorsGroup, "PieMenuBgColor");
LLColor4 selected_color = LLUI::sColorsGroup->getColor("PieMenuSelectedColor"); static const LLCachedControl<LLColor4> selected_color(*LLUI::sColorsGroup, "PieMenuSelectedColor");
// main body // main body
LLColor4 outer_color = bg_color; LLColor4 outer_color = bg_color;
@@ -5297,7 +5297,7 @@ void LLPieMenu::draw()
// selected wedge // selected wedge
if (mHoverItem) if (mHoverItem)
{ {
F32 arc_size = F_PI * 0.25f; constexpr F32 arc_size = F_PI * 0.25f;
F32 start_radians = (mHoverIndex * arc_size) - (arc_size * 0.5f); F32 start_radians = (mHoverIndex * arc_size) - (arc_size * 0.5f);
F32 end_radians = start_radians + arc_size; F32 end_radians = start_radians + arc_size;
@@ -5315,7 +5315,7 @@ void LLPieMenu::draw()
gl_washer_spokes_2d( mCurRadius, (F32)PIE_CENTER_SIZE, 8, line_color, outer_color ); gl_washer_spokes_2d( mCurRadius, (F32)PIE_CENTER_SIZE, 8, line_color, outer_color );
// inner circle // inner circle
gGL.color4fv( line_color.mV ); gGL.color4fv( line_color().mV );
gl_circle_2d( 0, 0, (F32)PIE_CENTER_SIZE, steps, FALSE ); gl_circle_2d( 0, 0, (F32)PIE_CENTER_SIZE, steps, FALSE );
// outer circle // outer circle