Fix #119296 : Image object data - opacity tooltips text make no sense #119415

Open
Yuting-Chen wants to merge 6 commits from Yuting-Chen/blender:my-feature into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 33 additions and 6 deletions

View File

@ -53,8 +53,8 @@ class DATA_PT_empty(DataButtonsPanel, Panel):
sub.prop(ob, "use_empty_image_alpha", text="")
sub = sub.row(align=True)
sub.active = ob.use_empty_image_alpha
sub.prop(ob, "color", text="", index=3, slider=True)
row.prop_decorator(ob, "color", index=3)
sub.prop(ob, "empty_image_alpha", text="", slider=True)
row.prop_decorator(ob, "empty_image_alpha")
class DATA_PT_empty_image(DataButtonsPanel, Panel):

View File

@ -1592,6 +1592,22 @@ static PointerRNA rna_Object_field_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd);
}
static void rna_Object_empty_image_alpha_get(PointerRNA *ptr, float *value)
{
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
if (ob->type != OB_EMPTY) {
return;
}
value[0] = (float)(((float *)ob->color)[3]);
}
static void rna_Object_empty_image_alpha_set(PointerRNA *ptr, const float *value)
{
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
((float *)ob->color)[3] = std::clamp(value[0], 0.0f, 1.0f);
}
static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
{
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
@ -3523,10 +3539,7 @@ static void rna_def_object(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_empty_image_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "empty_image_flag", OB_EMPTY_IMAGE_USE_ALPHA_BLEND);
RNA_def_property_ui_text(
prop,
"Use Alpha",
"Use alpha blending instead of alpha test (can produce sorting artifacts)");
RNA_def_property_ui_text(prop, "Use Opacity", "Use the opacity property to add transparency");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
static EnumPropertyItem prop_empty_image_side_items[] = {
@ -3558,6 +3571,20 @@ static void rna_def_object(BlenderRNA *brna)
prop, "Pass Index", "Index number for the \"Object Index\" render pass");
RNA_def_property_update(prop, NC_OBJECT, "rna_Object_internal_update_draw");
prop = RNA_def_float(srna,
"empty_image_alpha",
1.0f,
0.0f,
1.0f,
"Image Opacity",
"Degree of transparency applied to the image",
0.0f,
1.0f);
RNA_def_property_array(prop, 1);
RNA_def_property_float_funcs(
prop, "rna_Object_empty_image_alpha_get", "rna_Object_empty_image_alpha_set", nullptr);
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_ui_text(
prop, "Color", "Object color and alpha, used when the Object Color mode is enabled");