Skip to content

Commit

Permalink
refactor: remove obsolete logic
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Feb 11, 2024
1 parent af99387 commit 35ba4bd
Showing 1 changed file with 6 additions and 32 deletions.
38 changes: 6 additions & 32 deletions src/renderer/extract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
font::VelloFont, theme::Theme, CoordinateSpace, PlaybackAlphaOverride, PlaybackSettings,
Playhead, VelloAsset, VelloText,
font::VelloFont, theme::Theme, CoordinateSpace, PlaybackAlphaOverride, Playhead, VelloAsset,
VelloText,
};
use bevy::{
prelude::*,
Expand All @@ -27,7 +27,6 @@ pub fn vector_instances(
&CoordinateSpace,
&GlobalTransform,
Option<&Playhead>,
Option<&PlaybackSettings>,
Option<&Theme>,
Option<&PlaybackAlphaOverride>,
Option<&Node>,
Expand All @@ -36,14 +35,12 @@ pub fn vector_instances(
)>,
>,
assets: Extract<Res<Assets<VelloAsset>>>,
time: Res<Time>,
) {
for (
vello_vector_handle,
render_mode,
transform,
playhead,
playback_settings,
theme,
alpha,
ui_node,
Expand All @@ -53,33 +50,10 @@ pub fn vector_instances(
{
if let Some(asset) = assets.get(vello_vector_handle) {
if view_visibility.get() && inherited_visibility.get() {
let playhead = playhead
.map(|p| p.frame())
.or_else(|| {
playback_settings.and_then(|playback_settings| match &asset.data {
crate::VectorFile::Svg { original: _ } => None,
crate::VectorFile::Lottie { composition } => {
let start_frame = playback_settings
.segments
.start
.max(composition.frames.start);
if !playback_settings.autoplay {
Some(start_frame)
} else {
let end_frame =
playback_settings.segments.end.min(composition.frames.end);
let length = end_frame - start_frame;
let frame =
(time.elapsed_seconds() * playback_settings.speed) % length;
Some(match playback_settings.direction {
crate::PlaybackDirection::Normal => start_frame + frame,
crate::PlaybackDirection::Reverse => end_frame - frame,
})
}
}
})
})
.unwrap_or(time.elapsed_seconds());
let playhead = match asset.data {
crate::VectorFile::Svg { .. } => 0.0,
crate::VectorFile::Lottie { .. } => playhead.unwrap().frame(),
};
commands.spawn(ExtractedRenderVector {
asset: asset.to_owned(),
transform: *transform,
Expand Down

0 comments on commit 35ba4bd

Please sign in to comment.