Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/entries/2026-11-25_T12_27_00_ozette_colette_hair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
issues: []
prs: []

---

# Fixed
Colette’s hair hangs and sways as the wyvern carries her away in Ozette.
86 changes: 68 additions & 18 deletions crates/presentation/src/field_animation/prediction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub(crate) fn prepare(
Option<&crate::secondary_motion::Rig>,
)>,
helper: Helper,
attachments: crate::field_pose::AttachedActors,
) {
let _timer = crate::performance::smoothing_profile::Timer::start(1);
if prediction.field().is_none() || prediction.poses().is_some() {
Expand All @@ -92,24 +93,72 @@ pub(crate) fn prepare(
let result = prediction.scratch(|next, _| {
let mut output = Vec::new();
let world = &next.events.world;
for (root, part, rig, secondary) in &rigs {
let Some(current) = state.get().events.world.field_model_actor(part.actor) else {
continue;
};
let Some(actor) = world.field_model_actor(part.actor) else {
continue;
};
let current_world = &state.get().events.world;
let endpoints = |part: &ActorPart| {
let current = current_world.field_model_actor(part.actor)?;
let actor = world.field_model_actor(part.actor)?;
if !part.prepared || !crate::field_view::prediction::continuous_pose(current, actor) {
continue;
return None;
}
// Echo slots shift when an older echo expires. Keep this draw's
// snapshot while advancing its age; never morph it into its neighbor.
let echo = current.wings.as_ref().and_then(|w| {
w.layer(part.pass, state.get().events.world.effect_tick)
.echo
});
let target_root =
// Echo slots can shift when the oldest expires. Keep this draw's snapshot.
let echo = current
.wings
.as_ref()
.and_then(|w| w.layer(part.pass, current_world.effect_tick).echo);
let root =
crate::field_view::actor_transform(actor, part.actor, part.pass, world, echo);
Some((current, actor, echo, root))
};
let mut samples = BTreeMap::new();
let frames = if rigs.iter().any(|(_, part, _, secondary)| {
secondary.is_some()
&& world
.field_model_actor(part.actor)
.is_some_and(|a| a.attachment.is_some())
}) {
// The draw keeps its current attachment through a discontinuous handoff.
attachments.carrier_frames(
current_world,
|root, part| {
endpoints(part)
.map(|(_, _, _, t)| t.into())
.or_else(|| helper.local(root).ok())
},
|owner, bone, parents| {
let (_, part, rig, _) = rigs.get(owner).ok()?;
let Some((current, actor, echo, root)) = endpoints(part) else {
return helper.global_with(bone, parents, None).ok();
};
let placed = parents.get(&owner).copied().unwrap_or_else(|| root.into());
if let Some(rig) = rig.filter(|_| !current.animation_culled) {
let (locals, adjustments, _) = samples.entry(owner).or_insert_with(|| {
rig.next_pose(
part,
&art.models[&part.resource][part.part],
actor,
world,
echo,
camera,
)
});
locals.insert(owner, placed);
helper
.predicted_global(bone, locals, adjustments, &BTreeMap::new(), None)
.ok()
} else {
helper
.global_with(bone, &BTreeMap::from([(owner, placed)]), None)
.ok()
}
},
)
} else {
BTreeMap::new()
};
for (root, part, rig, secondary) in &rigs {
let Some((current, actor, echo, target_root)) = endpoints(part) else {
continue;
};
if let Ok(current_root) = helper.local(root) {
output.push(PoseEndpoint {
entity: root,
Expand All @@ -125,8 +174,9 @@ pub(crate) fn prepare(
if model.spec.outline_color.is_some() {
continue;
}
let (mut locals, adjustments, animated_roots) =
rig.next_pose(part, model, actor, world, echo, camera);
let (mut locals, adjustments, animated_roots) = samples
.remove(&root)
.unwrap_or_else(|| rig.next_pose(part, model, actor, world, echo, camera));
locals.insert(root, target_root.into());
let empty = BTreeMap::new();
let mut future_cache = bevy::ecs::entity::EntityHashMap::default();
Expand All @@ -136,8 +186,8 @@ pub(crate) fn prepare(
&& let Some(pose) = secondary.predict(
actor,
world,
world.tick,
target_root.scale,
frames.get(&root).copied(),
&animated_roots,
|entity| {
Some((
Expand Down
35 changes: 33 additions & 2 deletions crates/presentation/src/field_pose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,37 @@ impl AttachedActors<'_, '_> {
&self,
world: &resonance_events::GameWorld,
helper: &TransformHelper,
resolved: impl FnMut(Entity, &ActorPart, Option<(&resonance_events::Attachment, Transform)>),
) -> BTreeMap<Entity, Pose> {
self.roots_with(
world,
|root, _| helper.local(root).ok(),
|_, bone, parents| helper.global_with(bone, parents, None).ok(),
resolved,
)
}

/// Sample the same rigid sockets used to place the finished models.
pub(super) fn carrier_frames(
&self,
world: &resonance_events::GameWorld,
local: impl Fn(Entity, &ActorPart) -> Option<Pose>,
socket: impl FnMut(Entity, Entity, &BTreeMap<Entity, Pose>) -> Option<GlobalTransform>,
) -> BTreeMap<Entity, GlobalTransform> {
let mut frames = BTreeMap::new();
self.roots_with(world, local, socket, |root, _, frame| {
if let Some((_, parent)) = frame {
frames.insert(root, parent.into());
}
});
frames
}

fn roots_with(
&self,
world: &resonance_events::GameWorld,
local: impl Fn(Entity, &ActorPart) -> Option<Pose>,
mut socket: impl FnMut(Entity, Entity, &BTreeMap<Entity, Pose>) -> Option<GlobalTransform>,
mut resolved: impl FnMut(Entity, &ActorPart, Option<(&resonance_events::Attachment, Transform)>),
) -> BTreeMap<Entity, Pose> {
let mut parents = BTreeMap::new();
Expand Down Expand Up @@ -275,7 +306,7 @@ impl AttachedActors<'_, '_> {
.get(entity)
.ok()
.filter(|name| name.as_str() == attachment.bone)?;
let pose = helper.global_with(entity, &parents, None).ok()?;
let pose = socket(owner, entity, &parents)?;
Some(
Transform::from_translation(pose.translation()).with_rotation(
super::sparse_animation::affine::rotation(pose.affine()),
Expand All @@ -295,7 +326,7 @@ impl AttachedActors<'_, '_> {
if let Some(parent) = parent {
// sync() already applied the child's own scale, Euler rotation,
// fixed facing and visual displacement to its root.
let Ok(local) = helper.local(root) else {
let Some(local) = local(root, part) else {
continue;
};
let target = Pose::Affine(parent.compute_affine() * local.global().affine());
Expand Down
14 changes: 5 additions & 9 deletions crates/presentation/src/field_weapons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,19 +729,15 @@ fn dynamics<const VISIT: u8>(
if let Some(actor) = field.events.world.field_model_actor(actor_id) {
rig.controls(actor, &field.events.world);
}
let yaw = helper
let rotation = helper
.compute_global_transform(entity)
.map(|world| {
super::sparse_animation::affine::rotation(world.affine())
.to_euler(EulerRot::ZYX)
.0
.to_degrees()
})
.unwrap_or_default();
.map(|world| super::sparse_animation::affine::rotation(world.affine()))
.unwrap_or(Quat::IDENTITY);
if rig
.advance(
&helper,
yaw,
rotation,
None,
field.events.tick(),
state.checkpoint.is_some(),
layer
Expand Down
9 changes: 8 additions & 1 deletion crates/presentation/src/model_preview/motion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ pub(super) fn apply(
.map(|index| primary.spec.scene.clips[index].pose_chains.as_slice())
.unwrap_or_default();
let helper = transforms.p0();
let Some(()) = rig.advance(&helper, preview.yaw, menu.tick, true, roots) else {
let Some(()) = rig.advance(
&helper,
Quat::from_rotation_z(preview.yaw.to_radians()),
None,
menu.tick,
true,
roots,
) else {
return;
};
let pose = &rigs.get(root).unwrap().pose;
Expand Down
15 changes: 6 additions & 9 deletions crates/presentation/src/model_preview/prediction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,18 @@ pub(super) fn present(
});
let mut actor = resonance_events::Actor::new(0, [0.; 3]);
actor.heading = next.yaw;
if let Some(pose) = rig.predict(
&actor,
&Default::default(),
menu.tick,
Vec3::splat(model.scale),
roots,
|e| {
let mut world = resonance_events::GameWorld::default();
world.tick = menu.tick;
if let Some(pose) =
rig.predict(&actor, &world, Vec3::splat(model.scale), None, roots, |e| {
Some((
helper
.predicted_global(e, &locals, &authored, &empty, None)
.ok()?,
helper.predicted_has_affine(e, &locals),
))
},
) {
})
{
for part in viewer
.parts
.iter()
Expand Down
Loading
Loading