Conversation
…fixes GAUSSIAN half-size mismatch
…yer), map bevel_deprecated->bevel
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 79 |
| Duplication | 43 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
rodolforg
left a comment
There was a problem hiding this comment.
Thank you for fixing this!
(I didn't understand the 'indexing' word in the PR title.)
| halfsizex = (int)(std::fabs(size_x*.5/pw) + 3); | ||
| halfsizey = (int)(std::fabs(size_y*.5/ph) + 3); | ||
|
|
There was a problem hiding this comment.
These lines can be moved to inside the first (agglomerated) branch of the switch statement below.
These values are not used for Blur::GAUSSIAN
There was a problem hiding this comment.
Done, thanks. The generic formula now lives only in the agglomerated branch.
I also added a default: label to that branch.
| src/modules/lyr_std/bevel_deprecated.cpp | ||
| src/modules/lyr_std/bevel_deprecated.h |
There was a problem hiding this comment.
I don't think we need a new layer for solve this compatibility issue.
We could just use the layer (bad) version to use the TaskBevelDeprecated in Layer_Bevel::build_composite_fork_task_vfunc.
There was a problem hiding this comment.
The new layer was introduced, because the following reason:
If you load synfig file with old (broken) version, then Synfig will bump layer version.
So, when you load the file after saving it will behave as new (fixed) version, which might not be desirable for user.
As solution, when broken version id loaded we are converting it to Deprecated Bevel. This allows to keep compatibility.
There was a problem hiding this comment.
What about adding a new (invisible) parameter as I did for that broken gradient stuff?
There was a problem hiding this comment.
I went with a separate layer type for two reasons:
- It quarantines the legacy code in one file pair that a future release
can drop wholesale, without touching bevel.cpp. A hidden version flag
leaves a legacy branch inside the current layer forever. - Users get an explicit, undoable way to migrate old files to the fixed
algorithm (Upgrade Layer in the layer menu). A hidden flag has no UI
affordance — the only way to "upgrade" would be recreating the layer or
hand-editing.
There was a problem hiding this comment.
1. It quarantines the legacy code in one file pair that a future release can drop wholesale, without touching bevel.cpp. A hidden version flag leaves a legacy branch inside the current layer forever.
I don't think we could 'ever' remove the legacy code. We could have ourselves old animations that we don't touch for years and then, when we want to do so, Synfig would render it wrong - as MS Word does with its documents between versions :(
With the hidden flag would be not as simple, but it would be a search for "if (flag)" and wouldn't need to remove the deprecated filenames off the CMake/Autotools/POTFILE.in and include headers ;)
2. Users get an explicit, undoable way to migrate old files to the fixed algorithm (Upgrade Layer in the layer menu). A hidden flag has no UI affordance — the only way to "upgrade" would be recreating the layer or hand-editing.
Your great idea and work can ... work... even with the hidden flag too. Wouldn't be a simple change in get_target_layer_name()? It would have a layer name and its flag of deprecation instead?
Maybe this info could even be in a 'database' in Layer class. So loadcanvas and this new synfigapp action would be always in sync.
| namespace lyr_std | ||
| { | ||
|
|
||
| class Layer_BevelDeprecated : public Layer_CompositeFork |
There was a problem hiding this comment.
If we want to keep this other version, maybe it should disappear of the Add Layer menu?
If so,
- make it inherit the Layer_Invisible class too.
- remove from the lyr_std/main.cpp
- include this header directly in loadcanvas.cpp (as
Layer_Mimeis, as it shouldn't appear to final user)
And take a look about the strategy I used in fix: inverted interpolation of gradient since 1.3.11 #3477 and see it fits.
There was a problem hiding this comment.
If we want to keep this other version, maybe it should disappear of the Add Layer menu?
Yes, it should disappear.
There was a problem hiding this comment.
Done — hidden via CATEGORY_DO_NOT_USE, the same mechanism svg_layer uses (mod_svg/layer_svg.cpp:58).
I kept the registration and used the category instead: unregistered,
Layer::create("bevel_deprecated") would fall back to Layer_Mime and break
the migration and the Upgrade action. Layer_Invisible wouldn't help
either — stroboscope, timeloop and freetime inherit it and are still in
the menu; the filter is category-based.
| private: | ||
| std::list<synfig::Layer::Handle> layers; | ||
|
|
||
| void prepare_upgrade_layer(const synfig::Layer::Handle &layer, const synfig::String &target_name); |
There was a problem hiding this comment.
please prefer the code style that places the reference character & next to type, not near the variable name (C-style).
There was a problem hiding this comment.
Done, thanks — all references in layerupgrade now use Type& style.
|
Pushed a round of review fixes:
Also corrected the origin story in the description: a render matrix against |
|
I think we can merge this. |
Please see this comment: #3784 (comment) |
|
@036006 @morevnaproject That's what I meant: |
Fixes #3769
The Bevel layer renders its highlight (Hi-Color) rotated ~30° CW compared to Synfig 1.0.2 — and has done so since ~v1.3.11 (bisect in #3769). This PR restores the original 1.0.2-era algorithm as Bevel v0.4, fixes two genuinely Cobra-era indexing defects, and keeps old project files rendering exactly as before.
Part 1. Bevel algorithm fixes (bevel.cpp → v0.4)
1. Highlight direction rotated ~30° CW (the main issue, #3769) — long-standing, not Cobra-era
d0(anglea),d1(a−45°) andd2(perpendicular). As written, the twod2taps make the sampling fan asymmetric — {θ−135°, θ−45°, θ} instead of {θ−45°, θ, θ+45°} — skewing the estimated bevel axis by ~30°.+=/-=on the twod2lines, restoring the symmetric fan. Verified by the render matrix above: v0.4 matches 1.0.2.d2lines are textually unchanged since 1.0.2, so the regression's exact origin between 1.3.10 and 1.3.11 is not in the layer itself (no semantic changes in that window in bevel.cpp, blur.cpp, or renddesc). The render matrix is the ground truth this fix is validated against. (Commit message "correct highlight direction after Cobra port" misattributes the origin — the port only preserved the pre-existing behavior.)2. Wrong indexing with
target_min(Cobra-era)TaskBevelSW::runstarted its loop atu = halfsizex + abs(offset_u) + target_min[0](same forv). Butblurredis indexed from zero relative to the expanded work surface, whiletarget_minis the absolute origin of the target rectangle. The correct start atix = target_min[0]is exactlyhalfsizex + abs(offset_u)— withouttarget_min. The bug is invisible whentarget_rect.min == 0(single full-canvas render), which is why it slipped through.+ target_min[0]/+ target_min[1]from theu/vinitialization.3. Half-size mismatch for GAUSSIAN blur (Cobra-era)
Blur::GAUSSIANthe bevel was computed with wrong geometry.set_coords_sub_taskssized the buffer with theGAUSSIAN_ADJUSTMENTformula, butrun()indexed it with the genericfabs(size*.5/pw)+3formula. The half-size logic was duplicated in two places and drifted apart. (The default FASTGAUSSIAN type was unaffected — the formulas match there.)bevel_calc_halfsize()used both to size the buffer and to index it. No duplication left, so they cannot drift again.Part 2. Backward compatibility (loadcanvas.cpp + bevel_deprecated)
bevel_deprecated(an unchanged copy of the v0.3 layer); Bevel itself is bumped to v0.4 with the 1.0.2-era algorithm.CanvasParser::parse_layernormalizes the layer type in one block (following thefilled_rectangle→rectanglepattern). A bevel of version 0.2–0.3 on canvas ≥ 1.1 is loaded asbevel_deprecated, preserving its old render result; otherwise it loads as the newbevel. This implements the plan from Bevel Layer renders incorrectly comparing to version 1.0.2 #3769: canvas ≥ 1.1 ⟺ Synfig ≥ 1.3.12, i.e. the era with the rotated highlight.bevel_deprecatedis hidden from the New Layer menu (CATEGORY_DO_NOT_USE, same assvg_layer) and from the CLI layer list, while remaining instantiable by name for loading and for the Upgrade action.Part 3. New "Upgrade Layer" action (synfig-studio)
upgrade), driven by a data map deprecated → current (currentlybevel_deprecated→bevel). Adding a new pair is one line inget_target_layer_name().set_param_list— the vocab is identical), description (user-set only; a default one falls back to the new layer's name), active state,exclude_from_rendering, group membership (Canvas::insertsyncsgroup_db_), and animated parameters (ValueNodes are shared, not cloned, so exported/animated links stay referenced). Full undo/redo via the action super-class.Part 4. Icons
action_layer_upgrade_icon(.sifasset) wired intoknown_icon_list(iconcontroller.cpp), so theupgradetask gets its stock icon; added toimages/CMakeLists.txtandMakefile.amfor the .sif → .png render.bevel_deprecatedlayer reuses the old bevel icon with an exclamation mark added, to visually mark it as deprecated.