diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-09 20:31:54 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-09 20:31:54 +0400 |
commit | 885141c9dec9828172471b0e58dc4d975d250a04 (patch) | |
tree | 4901c666de40a3159f107f9b985a94a1612777e2 /source/blender/makesrna | |
parent | 1e0c3d315b8b5db4b5d594c05c7b1b92d5bf967a (diff) |
patch [#21740] Image support for Empty Objects
from Andy Braham (andybraham)
This adds support for empties to reference images and draw in the 3D view.
Modifications from the original patch.
- use an empty draw 'image' type
- use image aspect ratio for non-square-pixels
- when the image is not found, still draw the frame.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 33 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui_api.c | 2 |
2 files changed, 23 insertions, 12 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 11e7dd81cb6..d5d7f2917b9 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -307,22 +307,26 @@ static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) WM_main_add_notifier(NC_SCENE|ND_LAYER_CONTENT, scene); } -static int rna_Object_data_editable(PointerRNA *ptr) -{ - Object *ob= (Object*)ptr->data; - - return (ob->type == OB_EMPTY)? 0: PROP_EDITABLE; -} - static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) { Object *ob= (Object*)ptr->data; ID *id= value.data; - if(ob->type == OB_EMPTY || id == NULL || ob->mode & OB_MODE_EDIT) + if (id == NULL || ob->mode & OB_MODE_EDIT) return; - - if(ob->type == OB_MESH) { + + if (ob->type == OB_EMPTY) { + if(ob->data) { + id_us_min((ID*)ob->data); + ob->data = NULL; + } + + if (id && GS(id->name) == ID_IM) { + id_us_plus(id); + ob->data = id; + } + } + else if(ob->type == OB_MESH) { set_mesh(ob, (Mesh*)id); } else { @@ -346,6 +350,7 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) Object *ob= (Object*)ptr->data; switch(ob->type) { + case OB_EMPTY: return &RNA_Image; case OB_MESH: return &RNA_Mesh; case OB_CURVE: return &RNA_Curve; case OB_SURF: return &RNA_Curve; @@ -1691,6 +1696,7 @@ static void rna_def_object(BlenderRNA *brna) {OB_CUBE, "CUBE", 0, "Cube", ""}, {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""}, {OB_EMPTY_CONE, "CONE", 0, "Cone", ""}, + {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem track_items[] = { @@ -1758,7 +1764,6 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", NULL); - RNA_def_property_editable_func(prop, "rna_Object_data_editable"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Data", "Object data"); RNA_def_property_update(prop, 0, "rna_Object_internal_update_data"); @@ -2043,6 +2048,12 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Empty Display Size", "Size of display for empties in the viewport"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + prop= RNA_def_property(srna, "empty_image_offset", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "ima_ofs"); + RNA_def_property_ui_text(prop, "Origin Offset", "Origin offset distance"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1f, 2); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + /* render */ prop= RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "index"); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index ae308b9423f..d4ac9880290 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -389,7 +389,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); api_ui_item_rna_common(func); parm= RNA_def_pointer(func, "image_user", "ImageUser", "", ""); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL); RNA_def_boolean(func, "compact", 0, "", "Use more compact layout."); func= RNA_def_function(srna, "template_list", "uiTemplateList"); |