Making the Hue Correct Curves Wrap #117114

Merged
Omar Emara merged 31 commits from JonasDichelle/blender:hue-correct-bezier-wrap into main 2024-03-21 15:35:13 +01:00
7 changed files with 9 additions and 19 deletions
Showing only changes of commit c7f6eabc80 - Show all commits

View File

@ -169,11 +169,6 @@ void BKE_curvemapping_premultiply(CurveMapping *cumap, bool restore);
void BKE_curvemapping_blend_write(BlendWriter *writer, const CurveMapping *cumap);
void BKE_curvemapping_curves_blend_write(BlendWriter *writer, const CurveMapping *cumap);
/**
* Set the wrapping mode for the curve map.
*/
void BKE_curvemap_set_wrapping(CurveMapping *cumap, bool use_wrapping);
/**
* \note `cumap` itself has been read already.
*/

View File

@ -274,11 +274,6 @@ CurveMapPoint *BKE_curvemap_insert(CurveMap *cuma, float x, float y)
return newcmp;
}
void BKE_curvemap_set_wrapping(CurveMapping *cumapping, bool use_wrapping)
{
cumapping->use_wrapping = use_wrapping;
}
void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
{
if (cuma->curve) {
@ -665,7 +660,7 @@ static void curvemap_make_table(const CurveMapping *cumap, CurveMap *cuma)
* side of the curve offset by the table range. The handles of these points are calculated, as if
* they were between the last and first real points. */
const bool use_wrapping = cumap->use_wrapping;
const bool use_wrapping = cumap->flag & CUMA_USE_WRAPPING;
JonasDichelle marked this conversation as resolved Outdated

Comment lines should start with a start per the style guide.
https://developer.blender.org/docs/handbook/guidelines/c_cpp/#cc-comments

/* Wrapping ensures that the heights of the first and last points are the same. It adds two virtual
 * points, which are copies of the first and last points, and moves them to the opposite side of the
 * curve offset by the table range. The handles of these points are calculated, as if they were
 * between the last and first real points. */
Comment lines should start with a start per the style guide. https://developer.blender.org/docs/handbook/guidelines/c_cpp/#cc-comments ``` /* Wrapping ensures that the heights of the first and last points are the same. It adds two virtual * points, which are copies of the first and last points, and moves them to the opposite side of the * curve offset by the table range. The handles of these points are calculated, as if they were * between the last and first real points. */ ```
if (cuma->curve == nullptr) {
return;
JonasDichelle marked this conversation as resolved Outdated

I would add a comment here that roughly describes the mechanism by which wrapping is implemented.

I would add a comment here that roughly describes the mechanism by which wrapping is implemented.
@ -1472,7 +1467,7 @@ void BKE_histogram_update_sample_line(Histogram *hist,
hist->channels = 3;
hist->x_resolution = 256;
hist->xmax = 1.0f;
/* hist->ymax = 1.0f; /* now do this on the operator _only_ */
// hist->ymax = 1.0f; /* now do this on the operator _only_ */
if (ibuf->byte_buffer.data == nullptr && ibuf->float_buffer.data == nullptr) {
return;

View File

@ -1953,7 +1953,7 @@ static bool seq_hue_correct_set_wrapping(Sequence *seq, void * /*user_data*/)
if (smd->type == seqModifierType_HueCorrect) {
HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
CurveMapping *cumap = (CurveMapping *)&hcmd->curve_mapping;
cumap->use_wrapping = true;
cumap->flag |= CUMA_USE_WRAPPING;
}
}
return true;
@ -1966,7 +1966,7 @@ static void versioning_node_hue_correct_set_wrappng(bNodeTree *ntree)
if (node->type == CMP_NODE_HUECORRECT) {
CurveMapping *cumap = (CurveMapping *)node->storage;
cumap->use_wrapping = true;
cumap->flag |= CUMA_USE_WRAPPING;
}
}
}

View File

@ -4415,7 +4415,7 @@ static uiBlock *curvemap_tools_func(
"");
}
if (show_extend && !cumap->use_wrapping) {
if (show_extend && !(cumap->flag & CUMA_USE_WRAPPING)) {
uiDefIconTextBut(block,
UI_BTYPE_BUT_MENU,
1,

View File

@ -80,8 +80,7 @@ typedef struct CurveMapping {
float sample[3];
short tone;
char use_wrapping;
char _pad[5];
char _pad[6];
JonasDichelle marked this conversation as resolved Outdated

Any specific reason for this being a new flag and not a flag like CUMA_DO_CLIP ?

Any specific reason for this being a new flag and not a flag like `CUMA_DO_CLIP` ?
} CurveMapping;
/** #CurveMapping.flag */
@ -93,6 +92,7 @@ typedef enum eCurveMappingFlags {
/** The curve is extended by extrapolation. When not set the curve is extended horizontally. */
CUMA_EXTEND_EXTRAPOLATE = (1 << 4),
CUMA_USE_WRAPPING = (1 << 5),
} eCurveMappingFlags;
/** #CurveMapping.preset */

View File

@ -43,7 +43,7 @@ static void node_composit_init_huecorrect(bNodeTree * /*ntree*/, bNode *node)
BKE_curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE);
}
/* use wrapping for all hue correct nodes */
BKE_curvemap_set_wrapping(cumapping, true);
cumapping->flag |= CUMA_USE_WRAPPING;
/* default to showing Saturation */
cumapping->cur = 1;
}

View File

@ -869,7 +869,7 @@ static void hue_correct_init_data(SequenceModifierData *smd)
cuma, &hcmd->curve_mapping.clipr, hcmd->curve_mapping.preset, CURVEMAP_SLOPE_POSITIVE);
}
/* use wrapping for all hue correct modifiers */
BKE_curvemap_set_wrapping(&hcmd->curve_mapping, true);
hcmd->curve_mapping.flag |= CUMA_USE_WRAPPING;
/* default to showing Saturation */
hcmd->curve_mapping.cur = 1;
}