This commit is contained in:
1 parent
9a67a25a15
commit
1ab3886028
24 files changed
+1836
-311
No files matched your search
@@ -1308,4 +1308,55 @@ mod tests {
|
||||
assert!(state.old_brush.is_none());
|
||||
assert!(!state.changed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn brush_element_release_uses_production_finalizer_and_round_trips() {
|
||||
let mut app = App::new();
|
||||
app.init_resource::<ActiveOperator>()
|
||||
.init_resource::<EditorHistory>()
|
||||
.init_resource::<SceneIo>()
|
||||
.init_resource::<BrushEditMode>()
|
||||
.init_resource::<BrushElementSelection>()
|
||||
.init_resource::<BrushElementGizmoState>()
|
||||
.add_systems(Update, apply_brush_element_gizmo);
|
||||
let original = BrushDesc::cuboid(Vec3::ONE);
|
||||
let preview = BrushDesc::cuboid(Vec3::new(1.5, 1.0, 1.0));
|
||||
let brush_entity = app
|
||||
.world_mut()
|
||||
.spawn((LevelObject, preview.clone(), GlobalTransform::default()))
|
||||
.id();
|
||||
let helper = app
|
||||
.world_mut()
|
||||
.spawn((
|
||||
BrushElementGizmo,
|
||||
Transform::default(),
|
||||
GizmoTarget::default(),
|
||||
))
|
||||
.id();
|
||||
*app.world_mut().resource_mut::<BrushEditMode>() = BrushEditMode::Vertex;
|
||||
*app.world_mut().resource_mut::<BrushElementSelection>() = BrushElementSelection {
|
||||
brush: Some(brush_entity),
|
||||
elements: vec![BrushElementKey::Vertex {
|
||||
face: original.faces[0].id.clone(),
|
||||
index: 0,
|
||||
}],
|
||||
};
|
||||
*app.world_mut().resource_mut::<BrushElementGizmoState>() = BrushElementGizmoState {
|
||||
entity: Some(helper),
|
||||
brush: Some(brush_entity),
|
||||
old_brush: Some(original.clone()),
|
||||
old_gizmo: Some(Transform::default()),
|
||||
last_gizmo: Some(Transform::from_translation(Vec3::X * 0.25)),
|
||||
changed: true,
|
||||
};
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
app.update();
|
||||
|
||||
harness.assert_committed(app.world_mut(), 1, 0);
|
||||
harness.assert_status(app.world(), "brush.edit_mode", OperatorPhase::Committed);
|
||||
assert_undo_redo_round_trip(app.world_mut(), original, preview, |world| {
|
||||
world.get::<BrushDesc>(brush_entity).unwrap().clone()
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user