修复完美像素无法识别自身产物的网格 #169
@@ -1515,7 +1515,7 @@ export function registerRecentProjectsTests() {
|
||||
'open_game_creator_workspace_window',
|
||||
expect.anything(),
|
||||
);
|
||||
expect(screen.getByText('已打开项目目录')).not.toBeNull();
|
||||
expect(await screen.findByText('已打开项目目录')).not.toBeNull();
|
||||
expect(window.localStorage.length).toBe(1);
|
||||
});
|
||||
|
||||
@@ -1540,7 +1540,7 @@ export function registerRecentProjectsTests() {
|
||||
projectPath: '/tmp/typed-game',
|
||||
});
|
||||
});
|
||||
expect(screen.getByText('已打开项目目录')).not.toBeNull();
|
||||
expect(await screen.findByText('已打开项目目录')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('rejects invalid typed launcher project directories before opening them', () => {
|
||||
|
||||
@@ -588,10 +588,18 @@ fn estimate_step_size(profile: &[f64], config: SnapConfig) -> Option<f64> {
|
||||
return None;
|
||||
}
|
||||
let threshold = maximum * config.peak_threshold_multiplier;
|
||||
// The profile is a two-span central difference, so a hard block edge between
|
||||
// columns `b - 1` and `b` makes `profile[b - 1]` and `profile[b]` bitwise equal:
|
||||
// both straddle the same edge and sum the same per-row terms in the same order.
|
||||
// A strict comparison on both sides rejects both ends of that plateau, which is
|
||||
// why perfectly snapped pixel art used to yield zero peaks. Accepting equality on
|
||||
// the left keeps exactly one index per plateau — the right end, which is the real
|
||||
// boundary — while a strict comparison on the right still rejects the interior of
|
||||
// wider constant runs.
|
||||
let peaks = (1..profile.len().saturating_sub(1))
|
||||
.filter(|&index| {
|
||||
profile[index] > threshold
|
||||
&& profile[index] > profile[index - 1]
|
||||
&& profile[index] >= profile[index - 1]
|
||||
&& profile[index] > profile[index + 1]
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
@@ -694,7 +702,10 @@ fn walk(
|
||||
let mut best_index = start;
|
||||
let mut best_value = -1.0f64;
|
||||
for (index, value) in profile.iter().enumerate().take(end).skip(start) {
|
||||
if *value > best_value {
|
||||
// `>=` keeps the last index of an equal run, matching the plateau end that
|
||||
// `estimate_step_size` selects. Picking the first index instead would place
|
||||
// every cut one pixel left of the real block boundary.
|
||||
if *value >= best_value {
|
||||
best_value = *value;
|
||||
best_index = index;
|
||||
}
|
||||
@@ -878,7 +889,8 @@ fn snap_uniform_cuts(
|
||||
.take(end.min(profile.len().saturating_sub(1)) + 1)
|
||||
.skip(start)
|
||||
{
|
||||
if *value > best_value {
|
||||
// Same plateau-end convention as `walk`.
|
||||
if *value >= best_value {
|
||||
best_value = *value;
|
||||
best_index = index;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user