Preferences: Customize default empty size for collection instances

The old value (1.0) was often too large in practice. When many collection
instances are created, the large empties create a mess in the viewport.

This adds a new preference setting in `Editing -> Objects -> New Objects`
called `Instance Empty Size`.

The value will be used as display size for new empties containing a
collection instance.

Reviewers: Severin

Differential Revision: https://developer.blender.org/D7650
This commit is contained in:
Jacques Lucke 2020-05-12 10:59:41 +02:00
parent f1f3381873
commit e0b5a20231
7 changed files with 18 additions and 1 deletions

View File

@ -227,6 +227,8 @@ const UserDef U_default = {
.sequencer_disk_cache_size_limit = 100,
.sequencer_disk_cache_flag = 0,
.collection_instance_empty_size = 1.0f,
.runtime =
{
.is_dirty = 0,

View File

@ -360,6 +360,7 @@ class USERPREF_PT_edit_objects_new(EditingPanel, CenterAlignMixIn, Panel):
flow.prop(edit, "material_link", text="Link Materials to")
flow.prop(edit, "object_align", text="Align to")
flow.prop(edit, "use_enter_edit_mode", text="Enter Edit Mode")
flow.prop(edit, "collection_instance_empty_size", text="Instance Empty Size")
class USERPREF_PT_edit_objects_duplicate_data(EditingPanel, CenterAlignMixIn, Panel):

View File

@ -11942,6 +11942,7 @@ static void add_collections_to_scene(Main *mainvar,
/* BKE_object_add(...) messes with the selection. */
Object *ob = BKE_object_add_only_object(bmain, OB_EMPTY, collection->id.name + 2);
ob->type = OB_EMPTY;
ob->empty_drawsize = U.collection_instance_empty_size;
BKE_collection_object_add(bmain, active_collection, ob);
Base *base = BKE_view_layer_base_find(view_layer, ob);

View File

@ -764,6 +764,10 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
*/
{
/* Keep this block, even when empty. */
if (userdef->collection_instance_empty_size == 0) {
userdef->collection_instance_empty_size = 1.0f;
}
}
if (userdef->pixelsize == 0.0f) {

View File

@ -1357,6 +1357,7 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_add_type(
C, OB_EMPTY, collection->id.name + 2, loc, rot, false, local_view_bits);
ob->instance_collection = collection;
ob->empty_drawsize = U.collection_instance_empty_size;
ob->transflag |= OB_DUPLICOLLECTION;
id_us_plus(&collection->id);

View File

@ -873,9 +873,11 @@ typedef struct UserDef {
int sequencer_disk_cache_compression; /* eUserpref_DiskCacheCompression */
int sequencer_disk_cache_size_limit;
short sequencer_disk_cache_flag;
char _pad5[2];
float collection_instance_empty_size;
char _pad10[4];
struct WalkNavigation walk_navigation;
/** The UI for the user preferences. */

View File

@ -4840,6 +4840,12 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Enter Edit Mode", "Enter Edit Mode automatically after adding a new object");
prop = RNA_def_property(srna, "collection_instance_empty_size", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.001f, FLT_MAX);
RNA_def_property_ui_text(prop,
"Collection Instance Empty Size",
"Display size of the empty when new collection instances are created");
/* Undo */
prop = RNA_def_property(srna, "undo_steps", PROP_INT, PROP_NONE);