Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bevy Tweening
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Forks
Bevy Tweening
Commits
971edb62
Commit
971edb62
authored
2 years ago
by
Jerome Humbert
Browse files
Options
Downloads
Patches
Plain Diff
Revert "Carry time delta between tweens in a Sequence (#39)"
This reverts commit
77b56f44
.
parent
f7647405
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tweenable.rs
+15
-52
15 additions, 52 deletions
src/tweenable.rs
with
15 additions
and
52 deletions
src/tweenable.rs
+
15
−
52
View file @
971edb62
...
...
@@ -650,26 +650,28 @@ impl<T> Tweenable<T> for Sequence<T> {
fn
tick
(
&
mut
self
,
mut
delta
:
Duration
,
delta
:
Duration
,
target
:
&
mut
T
,
entity
:
Entity
,
event_writer
:
&
mut
EventWriter
<
TweenCompleted
>
,
)
->
TweenState
{
self
.time
=
(
self
.time
+
delta
)
.min
(
self
.duration
);
while
self
.index
<
self
.tweens
.len
()
{
if
self
.index
<
self
.tweens
.len
()
{
let
mut
state
=
TweenState
::
Active
;
self
.time
=
(
self
.time
+
delta
)
.min
(
self
.duration
);
let
tween
=
&
mut
self
.tweens
[
self
.index
];
let
tween_remaining
=
tween
.duration
()
.mul_f32
(
1.0
-
tween
.progress
());
if
let
TweenState
::
Active
=
tween
.tick
(
delta
,
target
,
entity
,
event_writer
)
{
return
TweenState
::
Active
;
let
tween_state
=
tween
.tick
(
delta
,
target
,
entity
,
event_writer
);
if
tween_state
==
TweenState
::
Completed
{
tween
.rewind
();
self
.index
+=
1
;
if
self
.index
>=
self
.tweens
.len
()
{
state
=
TweenState
::
Completed
;
self
.times_completed
=
1
;
}
}
tween
.rewind
();
delta
-=
tween_remaining
;
self
.index
+=
1
;
state
}
else
{
TweenState
::
Completed
}
self
.times_completed
=
1
;
TweenState
::
Completed
}
fn
times_completed
(
&
self
)
->
u32
{
...
...
@@ -1263,45 +1265,6 @@ mod tests {
}
}
/// Test crossing tween boundaries in one tick.
#[test]
fn
seq_tick_boundaries
()
{
let
mut
seq
=
Sequence
::
new
((
0
..
3
)
.map
(|
i
|
{
Tween
::
new
(
EaseMethod
::
Linear
,
TweeningType
::
Once
,
Duration
::
from_secs
(
1
),
TransformPositionLens
{
start
:
Vec3
::
splat
(
i
as
f32
),
end
:
Vec3
::
splat
((
i
+
1
)
as
f32
),
},
)
}));
let
mut
transform
=
Transform
::
default
();
// Dummy world and event writer
let
mut
world
=
World
::
new
();
world
.insert_resource
(
Events
::
<
TweenCompleted
>
::
default
());
let
mut
system_state
:
SystemState
<
EventWriter
<
TweenCompleted
>>
=
SystemState
::
new
(
&
mut
world
);
let
mut
event_writer
=
system_state
.get_mut
(
&
mut
world
);
// Tick halfway through the first tween, then in one tick:
// - Finish the first tween
// - Start and finish the second tween
// - Start the third tween
for
delta
in
[
0.5
,
2.0
]
{
seq
.tick
(
Duration
::
from_secs_f32
(
delta
),
&
mut
transform
,
Entity
::
from_raw
(
0
),
&
mut
event_writer
,
);
}
assert_eq!
(
seq
.index
(),
2
);
assert!
(
transform
.translation
.abs_diff_eq
(
Vec3
::
splat
(
2.5
),
1e-5
));
}
/// Sequence::new() and various Sequence-specific methods
#[test]
fn
seq_iter
()
{
...
...
This diff is collapsed.
Click to expand it.
Louis
@louis
mentioned in commit
e59ac355
·
2 years ago
mentioned in commit
e59ac355
mentioned in commit e59ac355bebfa51685cb22a74d56e41cda56cf9c
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment