mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-06-05 22:55:04 -06:00
overlays: fix indentation
This commit is contained in:
parent
24445123fc
commit
709305df0e
@ -5,143 +5,143 @@
|
|||||||
|
|
||||||
namespace rsx
|
namespace rsx
|
||||||
{
|
{
|
||||||
namespace overlays
|
namespace overlays
|
||||||
{
|
{
|
||||||
void animation_base::begin_animation(u64 frame)
|
void animation_base::begin_animation(u64 frame)
|
||||||
{
|
{
|
||||||
frame_start = frame;
|
frame_start = frame;
|
||||||
frame_end = u64(frame + duration * g_cfg.video.vblank_rate);
|
frame_end = u64(frame + duration * g_cfg.video.vblank_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 animation_base::get_progress_ratio(u64 frame) const
|
f32 animation_base::get_progress_ratio(u64 frame) const
|
||||||
{
|
{
|
||||||
if (!frame_start)
|
if (!frame_start)
|
||||||
{
|
{
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 t = f32(frame - frame_start) / (frame_end - frame_start);
|
f32 t = f32(frame - frame_start) / (frame_end - frame_start);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case animation_type::linear:
|
case animation_type::linear:
|
||||||
break;
|
break;
|
||||||
case animation_type::ease_in_quad:
|
case animation_type::ease_in_quad:
|
||||||
t = t * t;
|
t = t * t;
|
||||||
break;
|
break;
|
||||||
case animation_type::ease_out_quad:
|
case animation_type::ease_out_quad:
|
||||||
t = t * (2.0f - t);
|
t = t * (2.0f - t);
|
||||||
break;
|
break;
|
||||||
case animation_type::ease_in_out_cubic:
|
case animation_type::ease_in_out_cubic:
|
||||||
t = t > 0.5f ? 4.0f * std::pow((t - 1.0f), 3.0f) + 1.0f : 4.0f * std::pow(t, 3.0f);
|
t = t > 0.5f ? 4.0f * std::pow((t - 1.0f), 3.0f) + 1.0f : 4.0f * std::pow(t, 3.0f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void animation_translate::apply(compiled_resource& resource)
|
void animation_translate::apply(compiled_resource& resource)
|
||||||
{
|
{
|
||||||
if (!active)
|
if (!active)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const vertex delta = { current.x, current.y, current.z, 0.f };
|
const vertex delta = { current.x, current.y, current.z, 0.f };
|
||||||
for (auto& cmd : resource.draw_commands)
|
for (auto& cmd : resource.draw_commands)
|
||||||
{
|
{
|
||||||
for (auto& v : cmd.verts)
|
for (auto& v : cmd.verts)
|
||||||
{
|
{
|
||||||
v += delta;
|
v += delta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void animation_translate::update(u64 frame)
|
void animation_translate::update(u64 frame)
|
||||||
{
|
{
|
||||||
if (!active)
|
if (!active)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame_start == 0)
|
if (frame_start == 0)
|
||||||
{
|
{
|
||||||
start = current;
|
start = current;
|
||||||
begin_animation(frame);
|
begin_animation(frame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame >= frame_end)
|
if (frame >= frame_end)
|
||||||
{
|
{
|
||||||
// Exit condition
|
// Exit condition
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 t = get_progress_ratio(frame);
|
f32 t = get_progress_ratio(frame);
|
||||||
current = lerp(start, end, t);
|
current = lerp(start, end, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void animation_translate::finish()
|
void animation_translate::finish()
|
||||||
{
|
{
|
||||||
active = false;
|
active = false;
|
||||||
frame_start = 0;
|
frame_start = 0;
|
||||||
frame_end = 0;
|
frame_end = 0;
|
||||||
current = end; // Snap current to limit in case we went over
|
current = end; // Snap current to limit in case we went over
|
||||||
|
|
||||||
if (on_finish)
|
if (on_finish)
|
||||||
{
|
{
|
||||||
on_finish();
|
on_finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void animation_color_interpolate::apply(compiled_resource& data)
|
void animation_color_interpolate::apply(compiled_resource& data)
|
||||||
{
|
{
|
||||||
if (!active)
|
if (!active)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& cmd : data.draw_commands)
|
for (auto& cmd : data.draw_commands)
|
||||||
{
|
{
|
||||||
cmd.config.color *= current;
|
cmd.config.color *= current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void animation_color_interpolate::update(u64 frame)
|
void animation_color_interpolate::update(u64 frame)
|
||||||
{
|
{
|
||||||
if (!active)
|
if (!active)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame_start == 0)
|
if (frame_start == 0)
|
||||||
{
|
{
|
||||||
start = current;
|
start = current;
|
||||||
begin_animation(frame);
|
begin_animation(frame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame >= frame_end)
|
if (frame >= frame_end)
|
||||||
{
|
{
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 t = get_progress_ratio(frame);
|
f32 t = get_progress_ratio(frame);
|
||||||
current = lerp(start, end, t);
|
current = lerp(start, end, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void animation_color_interpolate::finish()
|
void animation_color_interpolate::finish()
|
||||||
{
|
{
|
||||||
active = false;
|
active = false;
|
||||||
frame_start = 0;
|
frame_start = 0;
|
||||||
frame_end = 0;
|
frame_end = 0;
|
||||||
current = end;
|
current = end;
|
||||||
|
|
||||||
if (on_finish)
|
if (on_finish)
|
||||||
{
|
{
|
||||||
on_finish();
|
on_finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,71 +8,71 @@
|
|||||||
|
|
||||||
namespace rsx
|
namespace rsx
|
||||||
{
|
{
|
||||||
namespace overlays
|
namespace overlays
|
||||||
{
|
{
|
||||||
struct compiled_resource;
|
struct compiled_resource;
|
||||||
|
|
||||||
enum class animation_type
|
enum class animation_type
|
||||||
{
|
{
|
||||||
linear,
|
linear,
|
||||||
ease_in_quad,
|
ease_in_quad,
|
||||||
ease_out_quad,
|
ease_out_quad,
|
||||||
ease_in_out_cubic,
|
ease_in_out_cubic,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct animation_base
|
struct animation_base
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
u64 frame_start = 0;
|
u64 frame_start = 0;
|
||||||
u64 frame_end = 0;
|
u64 frame_end = 0;
|
||||||
|
|
||||||
void begin_animation(u64 frame);
|
void begin_animation(u64 frame);
|
||||||
f32 get_progress_ratio(u64 frame) const;
|
f32 get_progress_ratio(u64 frame) const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T lerp(const T& a, const T& b, f32 t)
|
static T lerp(const T& a, const T& b, f32 t)
|
||||||
{
|
{
|
||||||
return (a * (1.f - t)) + (b * t);
|
return (a * (1.f - t)) + (b * t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool active = false;
|
bool active = false;
|
||||||
animation_type type { animation_type::linear };
|
animation_type type { animation_type::linear };
|
||||||
f32 duration = 1.f; // in seconds
|
f32 duration = 1.f; // in seconds
|
||||||
|
|
||||||
std::function<void()> on_finish;
|
std::function<void()> on_finish;
|
||||||
|
|
||||||
virtual void apply(compiled_resource&) = 0;
|
virtual void apply(compiled_resource&) = 0;
|
||||||
virtual void update(u64 frame) = 0;
|
virtual void update(u64 frame) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct animation_translate : animation_base
|
struct animation_translate : animation_base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
vector3f start{}; // Set `current` instead of this
|
vector3f start{}; // Set `current` instead of this
|
||||||
// NOTE: Necessary because update() is called after rendering,
|
// NOTE: Necessary because update() is called after rendering,
|
||||||
// resulting in one frame of incorrect translation
|
// resulting in one frame of incorrect translation
|
||||||
public:
|
public:
|
||||||
vector3f current{};
|
vector3f current{};
|
||||||
vector3f end{};
|
vector3f end{};
|
||||||
|
|
||||||
void apply(compiled_resource& data) override;
|
void apply(compiled_resource& data) override;
|
||||||
void update(u64 frame) override;
|
void update(u64 frame) override;
|
||||||
void finish();
|
void finish();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct animation_color_interpolate : animation_translate
|
struct animation_color_interpolate : animation_translate
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
color4f start{};
|
color4f start{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
color4f current{};
|
color4f current{};
|
||||||
color4f end{};
|
color4f end{};
|
||||||
|
|
||||||
void apply(compiled_resource& data) override;
|
void apply(compiled_resource& data) override;
|
||||||
void update(u64 frame) override;
|
void update(u64 frame) override;
|
||||||
void finish();
|
void finish();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user