Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 73 additions & 37 deletions OverlayDDU.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ SOFTWARE.
#include "iracing.h"
#include "Config.h"
#include "OverlayDebug.h"

class OverlayDDU : public Overlay
{
public:
Expand Down Expand Up @@ -257,32 +256,59 @@ class OverlayDDU : public Overlay
const float rpmPct = (rpm-lo) / (hi-lo);

const float ww = 0.16f;
for( int i=0; i<8; ++i )
for (int i = 0; i < 8; ++i)
{
const float lightPct = i/8.0f;
const float lightRpm = lo + (hi-lo) * lightPct;
const float lightPct = i / 8.0f;
const float lightRpm = lo + (hi - lo) * lightPct;

D2D1_ELLIPSE e = { float2(r2ax(0.5f-ww/2+(i+0.5f)*ww/8),r2ay(0.065f)), r2ax(0.007f), r2ax(0.007f) };
D2D1_ELLIPSE e = { float2(r2ax(0.5f - ww / 2 + (i + 0.5f) * ww / 8),r2ay(0.065f)), r2ax(0.007f), r2ax(0.007f) };

if( rpmPct < lightPct ) {
m_brush->SetColor( outlineCol );
m_renderTarget->DrawEllipse( &e, m_brush.Get() );
if (rpmPct < lightPct) {
m_brush->SetColor(outlineCol);
m_renderTarget->DrawEllipse(&e, m_brush.Get());
}
else {
if( lightRpm < ir_session.rpmSLFirst )
m_brush->SetColor( float4(1,1,1,1) );
else if( lightRpm < ir_session.rpmSLLast )
m_brush->SetColor( warnCol );
if (lightRpm < ir_session.rpmSLFirst)
m_brush->SetColor(float4(1, 1, 1, 1));
else if (lightRpm < ir_session.rpmSLLast)
m_brush->SetColor(warnCol);
else
m_brush->SetColor( float4(1,0,0,1) );
m_renderTarget->FillEllipse( &e, m_brush.Get() );
m_brush->SetColor(float4(1, 0, 0, 1));
m_renderTarget->FillEllipse(&e, m_brush.Get());
}
}

if ((ir_EngineWarnings.getInt() & irsdk_pitSpeedLimiter))
{
int frames = 60;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if this was time-based rather than counting frames. I think there's some "blinking" logic in other places in the code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I will take a look

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only thing left to do for this implementation now. I am unsure where blinking has been used elsewhere? I'll take another skim through.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be misremembering about blinking used elsewhere. It was in there at some point for something, but I might have removed it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I have opted for using the current tick count to work out if the lights should be on or off. Only thing is that I had to use a magic number (16) because the tick count was jumping 16 for every render call, however on odd occasions it would jump 17. There's definitely better ways of doing it, but this illuminates the need for incrementing a variable every tick.

The main rpm lights are moved out of the pit limiter if statement scope now, so this shouldn't affect performance at all if not using the limiter. I have fully tested this now on a laptop with lowest possible graphics settings, if anything would have performance issues it is this laptop. Tested on both 30Hz and 60Hz. I believe this is ready for merge.

if (g_cfg.getBool("General", "performance_mode_30hz", false)) frames = 30;
if (((tickCount / 16) % (frames / 2)) <= frames / 4) m_brush->SetColor(warnCol);
else m_brush->SetColor(outlineCol);

for (int i = 0; i < 8; ++i)
{
D2D1_ELLIPSE e = { float2(r2ax(0.5f - ww / 2 + (i + 0.5f) * ww / 8),r2ay(0.065f)), r2ax(0.007f), r2ax(0.007f) };
m_renderTarget->DrawEllipse(&e, m_brush.Get());
}
}
}

// Gear & Speed
{
if( ir_RPM.getFloat() >= ir_session.rpmSLShift || ir_EngineWarnings.getInt() & irsdk_revLimiterActive )
//std::cout << tickCount / 16 << std::endl;
if ((ir_EngineWarnings.getInt() & irsdk_pitSpeedLimiter))
{
int frames = 60;
if (g_cfg.getBool("General", "performance_mode_30hz", false)) frames = 30;
//std::cout << (tickCount % frames) << std::endl;
if (((tickCount / 16) % (frames / 2)) <= frames / 4)
{
m_brush->SetColor(goodCol);
D2D1_RECT_F r = { m_boxGear.x0, m_boxGear.y0, m_boxGear.x1, m_boxGear.y1 };
m_renderTarget->FillRectangle(&r, m_brush.Get());
}
}
else if( ir_RPM.getFloat() >= ir_session.rpmSLShift )
{
m_brush->SetColor( warnCol );
D2D1_RECT_F r = { m_boxGear.x0, m_boxGear.y0, m_boxGear.x1, m_boxGear.y1 };
Expand Down Expand Up @@ -553,25 +579,32 @@ class OverlayDDU : public Overlay
const float rr = 100.0f * std::min(std::min( ir_RRwearL.getFloat(), ir_RRwearM.getFloat() ), ir_RRwearR.getFloat() );

// Left
if( ir_dpLTireChange.getFloat() )
m_brush->SetColor( serviceCol );
else
m_brush->SetColor( textCol );
swprintf( s, _countof(s), L"%d", (int)(lf+0.5f) );
m_text.render( m_renderTarget.Get(), s, m_textFormatSmall.Get(), m_boxTires.x0+20, m_boxTires.x0+m_boxTires.w/2, m_boxTires.y0+m_boxTires.h*1.0f/3.0f, m_brush.Get(), DWRITE_TEXT_ALIGNMENT_CENTER );
swprintf( s, _countof(s), L"%d", (int)(lr+0.5f) );
m_text.render( m_renderTarget.Get(), s, m_textFormatSmall.Get(), m_boxTires.x0+20, m_boxTires.x0+m_boxTires.w/2, m_boxTires.y0+m_boxTires.h*2.0f/3.0f, m_brush.Get(), DWRITE_TEXT_ALIGNMENT_CENTER );

// Right
if( ir_dpRTireChange.getFloat() )
m_brush->SetColor( serviceCol );
else
m_brush->SetColor( textCol );
swprintf( s, _countof(s), L"%d", (int)(rf+0.5f) );
m_text.render( m_renderTarget.Get(), s, m_textFormatSmall.Get(), m_boxTires.x0+m_boxTires.w/2, m_boxTires.x1-20, m_boxTires.y0+m_boxTires.h*1.0f/3.0f, m_brush.Get(), DWRITE_TEXT_ALIGNMENT_CENTER );
swprintf( s, _countof(s), L"%d", (int)(rr+0.5f) );
m_text.render( m_renderTarget.Get(), s, m_textFormatSmall.Get(), m_boxTires.x0+m_boxTires.w/2, m_boxTires.x1-20, m_boxTires.y0+m_boxTires.h*2.0f/3.0f, m_brush.Get(), DWRITE_TEXT_ALIGNMENT_CENTER );
m_brush->SetColor( textCol );
if (ir_dpLTireChange.isValid())
{
if (ir_dpLTireChange.getFloat())
m_brush->SetColor(serviceCol);
else
m_brush->SetColor(textCol);

swprintf(s, _countof(s), L"%d", (int)(lf + 0.5f));
m_text.render(m_renderTarget.Get(), s, m_textFormatSmall.Get(), m_boxTires.x0 + 20, m_boxTires.x0 + m_boxTires.w / 2, m_boxTires.y0 + m_boxTires.h * 1.0f / 3.0f, m_brush.Get(), DWRITE_TEXT_ALIGNMENT_CENTER);
swprintf(s, _countof(s), L"%d", (int)(lr + 0.5f));
m_text.render(m_renderTarget.Get(), s, m_textFormatSmall.Get(), m_boxTires.x0 + 20, m_boxTires.x0 + m_boxTires.w / 2, m_boxTires.y0 + m_boxTires.h * 2.0f / 3.0f, m_brush.Get(), DWRITE_TEXT_ALIGNMENT_CENTER);
}

if (ir_dpRTireChange.isValid())
{
// Right
if (ir_dpRTireChange.getFloat())
m_brush->SetColor(serviceCol);
else
m_brush->SetColor(textCol);
swprintf(s, _countof(s), L"%d", (int)(rf + 0.5f));
m_text.render(m_renderTarget.Get(), s, m_textFormatSmall.Get(), m_boxTires.x0 + m_boxTires.w / 2, m_boxTires.x1 - 20, m_boxTires.y0 + m_boxTires.h * 1.0f / 3.0f, m_brush.Get(), DWRITE_TEXT_ALIGNMENT_CENTER);
swprintf(s, _countof(s), L"%d", (int)(rr + 0.5f));
m_text.render(m_renderTarget.Get(), s, m_textFormatSmall.Get(), m_boxTires.x0 + m_boxTires.w / 2, m_boxTires.x1 - 20, m_boxTires.y0 + m_boxTires.h * 2.0f / 3.0f, m_brush.Get(), DWRITE_TEXT_ALIGNMENT_CENTER);
m_brush->SetColor(textCol);
}

/* TODO: why doesn't iracing report 255 here in an AI session where we DO have unlimited tire sets??

Expand Down Expand Up @@ -633,9 +666,12 @@ class OverlayDDU : public Overlay

// Brake bias
{
const float bias = ir_dcBrakeBias.getFloat();
swprintf( s, _countof(s), L"%+3.1f", bias );
m_text.render( m_renderTarget.Get(), s, m_textFormat.Get(), m_boxBias.x0, m_boxBias.x1, m_boxBias.y0+m_boxBias.h*0.5f, m_brush.Get(), DWRITE_TEXT_ALIGNMENT_CENTER );
if (ir_dcBrakeBias.isValid())
{
const float bias = ir_dcBrakeBias.getFloat();
swprintf(s, _countof(s), L"%+3.1f", bias);
m_text.render(m_renderTarget.Get(), s, m_textFormat.Get(), m_boxBias.x0, m_boxBias.x1, m_boxBias.y0 + m_boxBias.h * 0.5f, m_brush.Get(), DWRITE_TEXT_ALIGNMENT_CENTER);
}
}

// Oil temp
Expand Down