Compare commits
No commits in common. "298012455a4a7b112d9f54e43430a062e18b1ae7" and "0f4aa5461219ffbd4b85250bf774acedd6d361ad" have entirely different histories.
298012455a
...
0f4aa54612
19
src/lib.rs
19
src/lib.rs
|
@ -130,7 +130,7 @@ pub struct Sound {
|
|||
pub paused: bool,
|
||||
pub restart: bool,
|
||||
#[reflect(ignore)]
|
||||
pub generator: Option<syz::Generator>,
|
||||
pub generator: Option<syz::BufferGenerator>,
|
||||
}
|
||||
|
||||
impl Default for Sound {
|
||||
|
@ -194,6 +194,7 @@ fn update_listener(
|
|||
fn add_source_handle(
|
||||
context: Res<syz::Context>,
|
||||
mut query: Query<(
|
||||
Entity,
|
||||
&mut Source,
|
||||
Option<&PannerStrategy>,
|
||||
Option<&GlobalTransform>,
|
||||
|
@ -201,7 +202,7 @@ fn add_source_handle(
|
|||
Option<&ScalarPan>,
|
||||
)>,
|
||||
) {
|
||||
for (mut source, panner_strategy, transform, angular_pan, scalar_pan) in &mut query {
|
||||
for (entity, mut source, panner_strategy, transform, angular_pan, scalar_pan) in &mut query {
|
||||
if source.handle.is_none() {
|
||||
let panner_strategy = panner_strategy.cloned().unwrap_or_default();
|
||||
let handle: syz::Source = if let Some(transform) = transform {
|
||||
|
@ -284,7 +285,7 @@ fn add_generator(
|
|||
handle
|
||||
.add_generator(&generator)
|
||||
.expect("Unable to add generator");
|
||||
sound.generator = Some(generator.into());
|
||||
sound.generator = Some(generator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -356,6 +357,7 @@ fn change_panner_strategy(
|
|||
fn update_source_properties(
|
||||
context: Res<syz::Context>,
|
||||
mut query: Query<(
|
||||
Entity,
|
||||
&mut Source,
|
||||
Option<&DistanceModel>,
|
||||
Option<&DistanceRef>,
|
||||
|
@ -369,6 +371,7 @@ fn update_source_properties(
|
|||
)>,
|
||||
) {
|
||||
for (
|
||||
entity,
|
||||
mut source,
|
||||
distance_model,
|
||||
distance_ref,
|
||||
|
@ -500,16 +503,11 @@ fn update_sound_properties(mut query: Query<&mut Sound>) {
|
|||
assert!(pitch > 0. && pitch <= 2.);
|
||||
if sound.restart {
|
||||
if let Some(generator) = sound.generator.as_mut() {
|
||||
if let Some(generator) = generator
|
||||
.cast_to::<syz::BufferGenerator>()
|
||||
.expect("Failed to cast")
|
||||
{
|
||||
generator
|
||||
.playback_position()
|
||||
.set(0.)
|
||||
.expect("Failed to restart");
|
||||
}
|
||||
}
|
||||
sound.restart = false;
|
||||
}
|
||||
if let Some(generator) = sound.generator.as_mut() {
|
||||
|
@ -518,10 +516,6 @@ fn update_sound_properties(mut query: Query<&mut Sound>) {
|
|||
.pitch_bend()
|
||||
.set(pitch)
|
||||
.expect("Failed to set pitch");
|
||||
if let Some(generator) = generator
|
||||
.cast_to::<syz::BufferGenerator>()
|
||||
.expect("Failed to cast")
|
||||
{
|
||||
generator
|
||||
.looping()
|
||||
.set(looping)
|
||||
|
@ -529,7 +523,6 @@ fn update_sound_properties(mut query: Query<&mut Sound>) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update_source_playback_state(query: Query<&Source>) {
|
||||
for source in &query {
|
||||
|
|
Loading…
Reference in New Issue
Block a user