Page MenuHome
Paste P752

(An Untitled Masterwork)
ActivePublic

Authored by Brecht Van Lommel (brecht) on Jul 12 2018, 5:12 PM.
diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
index 07d75aa..58eb6d1 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -56,7 +56,7 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos
NodeInput *inputSocketImage = this->getInputSocket(0);
NodeOutput *outputSocketImage = this->getOutputSocket(0);
NodeOutput *outputSocketMatte = this->getOutputSocket(1);
- NodeOutput *outputCryptoPick = this->getOutputSocket(2);
+ NodeOutput *outputSocketPick = this->getOutputSocket(2);
bNode *node = this->getbNode();
NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage;
@@ -106,7 +106,7 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0));
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0));
- converter.mapOutputSocket(outputCryptoPick, operation->getOutputSocket(0));
+ converter.mapOutputSocket(outputSocketPick, operation->getOutputSocket(0));
converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0));
converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1));
diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
index 13e23d5..267eb70 100644
--- a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
@@ -57,7 +57,7 @@ void CryptomatteOperation::executePixel(float output[4],
/* Write the frontmost object as false color for picking. */
output[0] = input[0];
uint32_t m3hash;
- ::memcpy(&m3hash, &input[0], 4);
+ ::memcpy(&m3hash, &input[0], sizeof(uint32_t));
output[1] = ((float) ((m3hash << 8)) / (float) UINT32_MAX);
output[2] = ((float) ((m3hash << 16)) / (float) UINT32_MAX);
}
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 2007a0a..eefbeee 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -969,7 +969,7 @@ void uiTemplateCurveMapping(
bool levels, bool brush, bool neg_slope);
void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic);
void uiTemplatePalette(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool color);
-void uiTemplateEyedropper(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
+void uiTemplateCryptoPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateLayers(
uiLayout *layout, struct PointerRNA *ptr, const char *propname,
PointerRNA *used_ptr, const char *used_propname, int active_layer);
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index a073129..67486f3 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -82,10 +82,10 @@ wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf)
/* assign to operators */
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_colorband");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color");
+ WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color_crypto");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_id");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_depth");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_driver");
- WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color_separate");
return keymap;
}
diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c
index 6975076..bcb6001 100644
--- a/source/blender/editors/interface/interface_eyedropper_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_color.c
@@ -28,7 +28,6 @@
*
* Defines:
* - #UI_OT_eyedropper_color
- * - #UI_OT_eyedropper_color_separate
*/
#include "MEM_guardedalloc.h"
@@ -37,6 +36,7 @@
#include "DNA_screen_types.h"
#include "BLI_math_vector.h"
+#include "BLI_string.h"
#include "BKE_context.h"
#include "BKE_main.h"
@@ -73,6 +73,8 @@ typedef struct Eyedropper {
bool accum_start; /* has mouse been pressed */
float accum_col[3];
int accum_tot;
+
+ bool accumulate; /* Color picking for cryptomatte, without accumulation. */
} Eyedropper;
static bool eyedropper_init(bContext *C, wmOperator *op)
@@ -81,6 +83,7 @@ static bool eyedropper_init(bContext *C, wmOperator *op)
Eyedropper *eye;
op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper");
+ eye->accumulate = !STREQ(op->type->idname, "UI_OT_eyedropper_color_crypto");
UI_context_active_but_prop_get(C, &eye->ptr, &eye->prop, &eye->index);
@@ -208,29 +211,30 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3
RNA_property_update(C, &eye->ptr, eye->prop);
}
-/* set sample from accumulated values */
-static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye)
-{
- float col[3];
- mul_v3_v3fl(col, eye->accum_col, 1.0f / (float)eye->accum_tot);
- eyedropper_color_set(C, eye, col);
-}
-
-/* single point sample & set */
static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my)
{
+ /* Accumulate color. */
float col[3];
eyedropper_color_sample_fl(C, mx, my, col);
- eyedropper_color_set(C, eye, col);
-}
-static void eyedropper_color_sample_accum(bContext *C, Eyedropper *eye, int mx, int my)
-{
- float col[3];
- eyedropper_color_sample_fl(C, mx, my, col);
- /* delay linear conversion */
- add_v3_v3(eye->accum_col, col);
- eye->accum_tot++;
+ if (eye->accumulate) {
+ add_v3_v3(eye->accum_col, col);
+ eye->accum_tot++;
+ }
+ else {
+ copy_v3_v3(eye->accum_col, col);
+ eye->accum_tot = 1;
+ }
+
+ /* Apply to property. */
+ float accum_col[3];
+ if (eye->accum_tot > 1) {
+ mul_v3_v3fl(accum_col, eye->accum_col, 1.0f / (float)eye->accum_tot);
+ }
+ else {
+ copy_v3_v3(accum_col, eye->accum_col);
+ }
+ eyedropper_color_set(C, eye, accum_col);
}
static void eyedropper_cancel(bContext *C, wmOperator *op)
@@ -255,29 +259,24 @@ static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (eye->accum_tot == 0) {
eyedropper_color_sample(C, eye, event->x, event->y);
}
- else {
- eyedropper_color_set_accum(C, eye);
- }
eyedropper_exit(C, op);
return OPERATOR_FINISHED;
case EYE_MODAL_SAMPLE_BEGIN:
/* enable accum and make first sample */
eye->accum_start = true;
- eyedropper_color_sample_accum(C, eye, event->x, event->y);
+ eyedropper_color_sample(C, eye, event->x, event->y);
break;
case EYE_MODAL_SAMPLE_RESET:
eye->accum_tot = 0;
zero_v3(eye->accum_col);
- eyedropper_color_sample_accum(C, eye, event->x, event->y);
- eyedropper_color_set_accum(C, eye);
+ eyedropper_color_sample(C, eye, event->x, event->y);
break;
}
}
- else if (event->type == MOUSEMOVE) {
+ else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
if (eye->accum_start) {
/* button is pressed so keep sampling */
- eyedropper_color_sample_accum(C, eye, event->x, event->y);
- eyedropper_color_set_accum(C, eye);
+ eyedropper_color_sample(C, eye, event->x, event->y);
}
}
@@ -322,20 +321,9 @@ static int eyedropper_exec(bContext *C, wmOperator *op)
static bool eyedropper_poll(bContext *C)
{
- PointerRNA ptr;
- PropertyRNA *prop;
- int index_dummy;
- uiBut *but;
-
- /* Only color buttons */
- if ((CTX_wm_window(C) != NULL) &&
- (but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) &&
- (but->type == UI_BTYPE_COLOR))
- {
- return 1;
- }
-
- return 0;
+ /* Actual test for active button happens later, since we don't
+ * know which one is active until mouse over. */
+ return (CTX_wm_window(C) != NULL);
}
void UI_OT_eyedropper_color(wmOperatorType *ot)
@@ -354,32 +342,22 @@ void UI_OT_eyedropper_color(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
-
- /* properties */
-}
-
-static bool eyedropper_separate(bContext *C)
-{
- if(!CTX_wm_window(C)) return 0;
- else return 1;
}
-void UI_OT_eyedropper_color_separate(wmOperatorType *ot)
+void UI_OT_eyedropper_color_crypto(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Eyedropper";
- ot->idname = "UI_OT_eyedropper_color_separate";
- ot->description = "Sample a color from the Blender Window to store in a property";
+ ot->name = "Cryptomatte Eyedropper";
+ ot->idname = "UI_OT_eyedropper_color_crypto";
+ ot->description = "Pick a color from Cryptomatte node Pick output image";
/* api callbacks */
ot->invoke = eyedropper_invoke;
ot->modal = eyedropper_modal;
ot->cancel = eyedropper_cancel;
ot->exec = eyedropper_exec;
- ot->poll = eyedropper_separate;
+ ot->poll = eyedropper_poll;
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
-
- /* properties */
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index f4ccdde..dc5e100 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -763,6 +763,7 @@ struct wmKeyMap *eyedropper_colorband_modal_keymap(struct wmKeyConfig *keyconf);
/* interface_eyedropper_color.c */
void UI_OT_eyedropper_color(struct wmOperatorType *ot);
+void UI_OT_eyedropper_color_crypto(struct wmOperatorType *ot);
/* interface_eyedropper_colorband.c */
void UI_OT_eyedropper_colorband(struct wmOperatorType *ot);
@@ -776,6 +777,5 @@ void UI_OT_eyedropper_depth(struct wmOperatorType *ot);
/* interface_eyedropper_driver.c */
void UI_OT_eyedropper_driver(struct wmOperatorType *ot);
-void UI_OT_eyedropper_color_separate(struct wmOperatorType *ot);
#endif /* __INTERFACE_INTERN_H__ */
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 83f3418..1e67ecd 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -1138,12 +1138,12 @@ void ED_operatortypes_ui(void)
/* external */
WM_operatortype_append(UI_OT_eyedropper_color);
+ WM_operatortype_append(UI_OT_eyedropper_color_crypto);
WM_operatortype_append(UI_OT_eyedropper_colorband);
WM_operatortype_append(UI_OT_eyedropper_colorband_point);
WM_operatortype_append(UI_OT_eyedropper_id);
WM_operatortype_append(UI_OT_eyedropper_depth);
WM_operatortype_append(UI_OT_eyedropper_driver);
- WM_operatortype_append(UI_OT_eyedropper_color_separate);
}
/**
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 029899c..daee0d3 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -2572,12 +2572,11 @@ void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname,
}
}
-void uiTemplateEyedropper(uiLayout *layout, PointerRNA *ptr, const char *propname)
+void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propname)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
uiBlock *block;
uiBut *but;
- uiLayout *col;
if (!prop) {
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
@@ -2586,11 +2585,7 @@ void uiTemplateEyedropper(uiLayout *layout, PointerRNA *ptr, const char *propnam
block = uiLayoutGetBlock(layout);
- col = uiLayoutColumn(layout, true);
- uiLayoutRow(col, true);
-
- uiDefBut(block, UI_BTYPE_LABEL, 0, RNA_property_ui_name(prop), 0, 19, 145, 19, NULL, 0, 0, 0, 0, RNA_property_ui_description(prop));
- but = uiDefIconButO(block, UI_BTYPE_BUT, "UI_OT_eyedropper_color_separate", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
+ but = uiDefIconTextButO(block, UI_BTYPE_BUT, "UI_OT_eyedropper_color_crypto", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, RNA_property_ui_name(prop), 0, 0, UI_UNIT_X, UI_UNIT_Y, RNA_property_ui_description(prop));
but->rnapoin = *ptr;
but->rnaprop = prop;
but->rnaindex = -1;
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 55d44a5..d67dbc2 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -2544,9 +2544,15 @@ static void node_composit_buts_sunbeams(uiLayout *layout, bContext *UNUSED(C), P
static void node_composit_buts_cryptomatte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
- uiItemR(layout, ptr, "matte_id", 0, NULL, ICON_NONE);
- uiTemplateEyedropper(layout, ptr, "add");
- uiTemplateEyedropper(layout, ptr, "remove");
+ uiLayout *col = uiLayoutColumn(layout, true);
+
+ uiItemL(col, IFACE_("Matte Objects:"), ICON_NONE);
+
+ uiLayout *row = uiLayoutRow(col, true);
+ uiTemplateCryptoPicker(row, ptr, "add");
+ uiTemplateCryptoPicker(row, ptr, "remove");
+
+ uiItemR(col, ptr, "matte_id", 0, "", ICON_NONE);
}
static void node_composit_buts_cryptomatte_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *UNUSED(ptr))
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 0b1aafc..54fc1a4 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -6973,25 +6973,19 @@ static void def_cmp_cryptomatte(StructRNA *srna)
RNA_def_struct_sdna_from(srna, "NodeCryptomatte", "storage");
prop = RNA_def_property(srna, "matte_id", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "matte_id");
- RNA_def_property_ui_text(prop, "Matte List", "");
+ RNA_def_property_ui_text(prop, "Matte Objects", "List of object and material crypto IDs to include in matte");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "add", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "add");
- RNA_def_property_array(prop, 3);
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
- RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
- RNA_def_property_ui_text(prop, "Add", "Add to matte");
+ RNA_def_property_ui_text(prop, "Add", "Add object or material to matte, by picking a color from the Pick output");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeCryptomatte_update_add");
prop = RNA_def_property(srna, "remove", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_float_sdna(prop, NULL, "remove");
- RNA_def_property_array(prop, 3);
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
- RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
- RNA_def_property_ui_text(prop, "Remove", "Remove from matte");
+ RNA_def_property_ui_text(prop, "Remove", "Remove object or material from matte, by picking a color from the Pick output");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeCryptomatte_update_remove");
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
index 1941f54..0d78053 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -195,7 +195,7 @@ static void cryptomatte_remove(NodeCryptomatte*n, float f)
static bNodeSocketTemplate outputs[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ SOCK_FLOAT, 0, N_("Matte")},
- { SOCK_RGBA, 0, N_("CryptoPick")},
+ { SOCK_RGBA, 0, N_("Pick")},
{ -1, 0, "" }
};