MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / InterpolateRGB

Method InterpolateRGB

ogsr_engine/xr_3da/LightAnimLibrary.cpp:75–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75u32 CLAItem::InterpolateRGB(int frame)
76{
77 R_ASSERT(frame <= iFrameCount);
78
79 KeyPairIt A = Keys.find(frame);
80 KeyPairIt B;
81 if (A != Keys.end())
82 { // ключ - возвращаем цвет ключа
83 return A->second;
84 }
85 else
86 { // не ключ
87 B = Keys.upper_bound(frame); // ищем следующий ключ
88 if (B == Keys.end())
89 { // если его нет вернем цвет последнего ключа
90 --B;
91 return B->second;
92 }
93 A = B; // иначе в A занесем предыдущий ключ
94 --A;
95 }
96
97 R_ASSERT(Keys.size() > 1);
98 // интерполируем цвет
99 Fcolor c, c0, c1;
100 float a0 = (float)A->first;
101 float a1 = (float)B->first;
102 c0.set(A->second);
103 c1.set(B->second);
104 float t = float(frame - a0) / float(a1 - a0);
105 c.lerp(c0, c1, t);
106 return c.get();
107}
108
109u32 CLAItem::InterpolateBGR(int frame)
110{

Callers 1

UpdateMethod · 0.80

Calls 6

findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45
lerpMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected