MCPcopy Create free account
hub / github.com/ddnet/ddnet / FindPointIndex

Method FindPointIndex

src/game/map/render_map.cpp:24–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22using namespace std::chrono_literals;
23
24int IEnvelopePointAccess::FindPointIndex(CFixedTime Time) const
25{
26 // binary search for the interval around Time
27 int Low = 0;
28 int High = NumPoints() - 2;
29 int FoundIndex = -1;
30
31 while(Low <= High)
32 {
33 int Mid = Low + (High - Low) / 2;
34 const CEnvPoint *pMid = GetPoint(Mid);
35 const CEnvPoint *pNext = GetPoint(Mid + 1);
36 if(Time >= pMid->m_Time && Time < pNext->m_Time)
37 {
38 FoundIndex = Mid;
39 break;
40 }
41 else if(Time < pMid->m_Time)
42 {
43 High = Mid - 1;
44 }
45 else
46 {
47 Low = Mid + 1;
48 }
49 }
50 return FoundIndex;
51}
52
53CMapBasedEnvelopePointAccess::CMapBasedEnvelopePointAccess(IMap *pMap)
54{

Callers 1

RenderEvalEnvelopeMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected