2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2007 Blender Foundation. All rights reserved. */
|
2015-12-27 16:36:08 +11:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup wm
|
2015-12-27 16:36:08 +11:00
|
|
|
*
|
|
|
|
|
* Generic re-usable property definitions and accessors for operators to share.
|
|
|
|
|
* (`WM_operator_properties_*` functions).
|
|
|
|
|
*/
|
|
|
|
|
|
2022-05-23 20:32:36 +02:00
|
|
|
#include "DNA_ID_enums.h"
|
2015-12-27 16:36:08 +11:00
|
|
|
#include "DNA_space_types.h"
|
|
|
|
|
|
2022-05-23 20:32:36 +02:00
|
|
|
#include "BKE_lib_id.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
|
2015-12-27 17:46:55 +11:00
|
|
|
#include "BLI_math_base.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_rect.h"
|
2015-12-27 16:36:08 +11:00
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
#include "RNA_enum_types.h"
|
2022-03-14 16:54:46 +01:00
|
|
|
#include "RNA_prototypes.h"
|
2015-12-27 16:36:08 +11:00
|
|
|
|
2018-08-14 10:28:41 +10:00
|
|
|
#include "ED_select_utils.h"
|
|
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2018-11-20 10:06:02 +11:00
|
|
|
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_boolean(ot->srna, "confirm", true, "Confirm", "Prompt for confirmation");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 23:55:59 +01:00
|
|
|
/**
|
|
|
|
|
* Extends rna_enum_fileselect_params_sort_items with a default item for operators to use.
|
|
|
|
|
*/
|
|
|
|
|
static const EnumPropertyItem *wm_operator_properties_filesel_sort_items_itemf(
|
|
|
|
|
struct bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
|
|
|
|
|
{
|
|
|
|
|
EnumPropertyItem *items;
|
|
|
|
|
const EnumPropertyItem default_item = {
|
|
|
|
|
FILE_SORT_DEFAULT,
|
|
|
|
|
"DEFAULT",
|
|
|
|
|
0,
|
|
|
|
|
"Default",
|
|
|
|
|
"Automatically determine sort method for files",
|
|
|
|
|
};
|
|
|
|
|
int totitem = 0;
|
|
|
|
|
|
|
|
|
|
RNA_enum_item_add(&items, &totitem, &default_item);
|
|
|
|
|
RNA_enum_items_add(&items, &totitem, rna_enum_fileselect_params_sort_items);
|
|
|
|
|
RNA_enum_item_end(&items, &totitem);
|
|
|
|
|
*r_free = true;
|
|
|
|
|
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-07 22:56:20 +11:00
|
|
|
void WM_operator_properties_filesel(wmOperatorType *ot,
|
2022-03-26 18:39:42 +11:00
|
|
|
const int filter,
|
|
|
|
|
const short type,
|
|
|
|
|
const eFileSel_Action action,
|
|
|
|
|
const eFileSel_Flag flag,
|
|
|
|
|
const short display,
|
|
|
|
|
const short sort)
|
2015-12-27 16:36:08 +11:00
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem file_display_items[] = {
|
2015-12-27 16:36:08 +11:00
|
|
|
{FILE_DEFAULTDISPLAY,
|
|
|
|
|
"DEFAULT",
|
|
|
|
|
0,
|
|
|
|
|
"Default",
|
|
|
|
|
"Automatically determine display type for files"},
|
UI: File Browser Design Overhaul
This is a general redesign of the File Browser GUI and interaction
methods. For screenshots, check patch D5601.
Main changes in short:
* File Browser as floating window
* New layout of regions
* Popovers for view and filter options
* Vertical list view with interactive column header
* New and updated icons
* Keymap consistency fixes
* Many tweaks and fixes to the drawing of views
----
General:
* The file browser now opens as temporary floating window. It closes on
Esc. The header is hidden then.
* When the file browser is opened as regular editor, the header remains
visible.
* All file browser regions are now defined in Python (the button
layout).
* Adjusted related operator UI names.
Keymap:
Keymap is now consistent with other list-based views in Blender, such as
the Outliner.
* Left click to select, double-click to open
* Right-click context menus
* Shift-click to fill selection
* Ctrl-click to extend selection
Operator options:
These previously overlapped with the source list, which caused numerous
issues with resizing and presenting many settings in a small panel area.
It was also generally inconsistent with Blender.
* Moved to new sidebar, which can easily be shown or hidden using a
prominent Options toggle.
* IO operators have new layouts to match this new sidebar, using
sub-panels. This will have to be committed separately (Add-on
repository).
* If operators want to show the options by default, they have the option
to do so (see `WM_FILESEL_SHOW_PROPS`, `hide_props_region`), otherwise
they are hidden by default.
General Layout:
The layout has been changed to be simpler, more standard, and fits
better in with Blender 2.8.
* More conventional layout (file path at top, file name at the bottom,
execute/cancel buttons in bottom right).
* Use of popovers to group controls, and allow for more descriptive
naming.
* Search box is always live now, just like Outliner.
Views:
* Date Modified column combines both date and time, also uses user
friendly strings for recent dates (i.e. "Yesterday", "Today").
* Details columns (file size, modification date/time) are now toggleable
for all display types, they are not hardcoded per display type.
* File sizes now show as B, KB, MB, ... rather than B, KiB, MiB, … They
are now also calculated using base 10 of course.
* Option to sort in inverse order.
Vertical List View:
* This view now used a much simpler single vertical list with columns
for information.
* Users can click on the headers of these columns to order by that
category, and click again to reverse the ordering.
Icons:
* Updated icons by Jendrzych, with better centering.
* Files and folders have new icons in Icon view.
* Both files and folders have reworked superimposed icons that show
users the file/folder type.
* 3D file documents correctly use the 3d file icon, which was unused
previously.
* Workspaces now show their icon on Link/Append - also when listed in
the Outliner.
Minor Python-API breakage:
* `bpy.types.FileSelectParams.display_type`: `LIST_SHORT` and
`LIST_LONG` are replaced by `LIST_VERTICAL` and `LIST_HORIZONTAL`.
Removes the feature where directories would automatically be created if
they are entered into the file path text button, but don't exist. We
were not sure if users use it enough to keep it. We can definitely bring
it back.
----
//Combined effort by @billreynish, @harley, @jendrzych, my university
colleague Brian Meisenheimer and myself.//
Differential Revision: https://developer.blender.org/D5601
Reviewers: Brecht, Bastien
2019-09-03 15:43:38 +02:00
|
|
|
{FILE_VERTICALDISPLAY,
|
|
|
|
|
"LIST_VERTICAL",
|
|
|
|
|
ICON_SHORTDISPLAY, /* Name of deprecated short list */
|
2015-12-27 16:36:08 +11:00
|
|
|
"Short List",
|
|
|
|
|
"Display files as short list"},
|
UI: File Browser Design Overhaul
This is a general redesign of the File Browser GUI and interaction
methods. For screenshots, check patch D5601.
Main changes in short:
* File Browser as floating window
* New layout of regions
* Popovers for view and filter options
* Vertical list view with interactive column header
* New and updated icons
* Keymap consistency fixes
* Many tweaks and fixes to the drawing of views
----
General:
* The file browser now opens as temporary floating window. It closes on
Esc. The header is hidden then.
* When the file browser is opened as regular editor, the header remains
visible.
* All file browser regions are now defined in Python (the button
layout).
* Adjusted related operator UI names.
Keymap:
Keymap is now consistent with other list-based views in Blender, such as
the Outliner.
* Left click to select, double-click to open
* Right-click context menus
* Shift-click to fill selection
* Ctrl-click to extend selection
Operator options:
These previously overlapped with the source list, which caused numerous
issues with resizing and presenting many settings in a small panel area.
It was also generally inconsistent with Blender.
* Moved to new sidebar, which can easily be shown or hidden using a
prominent Options toggle.
* IO operators have new layouts to match this new sidebar, using
sub-panels. This will have to be committed separately (Add-on
repository).
* If operators want to show the options by default, they have the option
to do so (see `WM_FILESEL_SHOW_PROPS`, `hide_props_region`), otherwise
they are hidden by default.
General Layout:
The layout has been changed to be simpler, more standard, and fits
better in with Blender 2.8.
* More conventional layout (file path at top, file name at the bottom,
execute/cancel buttons in bottom right).
* Use of popovers to group controls, and allow for more descriptive
naming.
* Search box is always live now, just like Outliner.
Views:
* Date Modified column combines both date and time, also uses user
friendly strings for recent dates (i.e. "Yesterday", "Today").
* Details columns (file size, modification date/time) are now toggleable
for all display types, they are not hardcoded per display type.
* File sizes now show as B, KB, MB, ... rather than B, KiB, MiB, … They
are now also calculated using base 10 of course.
* Option to sort in inverse order.
Vertical List View:
* This view now used a much simpler single vertical list with columns
for information.
* Users can click on the headers of these columns to order by that
category, and click again to reverse the ordering.
Icons:
* Updated icons by Jendrzych, with better centering.
* Files and folders have new icons in Icon view.
* Both files and folders have reworked superimposed icons that show
users the file/folder type.
* 3D file documents correctly use the 3d file icon, which was unused
previously.
* Workspaces now show their icon on Link/Append - also when listed in
the Outliner.
Minor Python-API breakage:
* `bpy.types.FileSelectParams.display_type`: `LIST_SHORT` and
`LIST_LONG` are replaced by `LIST_VERTICAL` and `LIST_HORIZONTAL`.
Removes the feature where directories would automatically be created if
they are entered into the file path text button, but don't exist. We
were not sure if users use it enough to keep it. We can definitely bring
it back.
----
//Combined effort by @billreynish, @harley, @jendrzych, my university
colleague Brian Meisenheimer and myself.//
Differential Revision: https://developer.blender.org/D5601
Reviewers: Brecht, Bastien
2019-09-03 15:43:38 +02:00
|
|
|
{FILE_HORIZONTALDISPLAY,
|
|
|
|
|
"LIST_HORIZONTAL",
|
|
|
|
|
ICON_LONGDISPLAY, /* Name of deprecated long list */
|
2015-12-27 16:36:08 +11:00
|
|
|
"Long List",
|
|
|
|
|
"Display files as a detailed list"},
|
|
|
|
|
{FILE_IMGDISPLAY, "THUMBNAIL", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2015-12-27 16:36:08 +11:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-13 09:15:15 +02:00
|
|
|
if (flag & WM_FILESEL_FILEPATH) {
|
2015-12-27 16:36:08 +11:00
|
|
|
RNA_def_string_file_path(ot->srna, "filepath", NULL, FILE_MAX, "File Path", "Path to file");
|
2019-04-13 09:15:15 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-13 09:15:15 +02:00
|
|
|
if (flag & WM_FILESEL_DIRECTORY) {
|
2015-12-27 16:36:08 +11:00
|
|
|
RNA_def_string_dir_path(
|
|
|
|
|
ot->srna, "directory", NULL, FILE_MAX, "Directory", "Directory of the file");
|
2019-04-13 09:15:15 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-13 09:15:15 +02:00
|
|
|
if (flag & WM_FILESEL_FILENAME) {
|
2015-12-27 16:36:08 +11:00
|
|
|
RNA_def_string_file_name(
|
|
|
|
|
ot->srna, "filename", NULL, FILE_MAX, "File Name", "Name of the file");
|
2019-04-13 09:15:15 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-13 09:15:15 +02:00
|
|
|
if (flag & WM_FILESEL_FILES) {
|
2019-05-13 22:18:11 +02:00
|
|
|
prop = RNA_def_collection_runtime(
|
|
|
|
|
ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2019-04-13 09:15:15 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
UI: File Browser Design Overhaul
This is a general redesign of the File Browser GUI and interaction
methods. For screenshots, check patch D5601.
Main changes in short:
* File Browser as floating window
* New layout of regions
* Popovers for view and filter options
* Vertical list view with interactive column header
* New and updated icons
* Keymap consistency fixes
* Many tweaks and fixes to the drawing of views
----
General:
* The file browser now opens as temporary floating window. It closes on
Esc. The header is hidden then.
* When the file browser is opened as regular editor, the header remains
visible.
* All file browser regions are now defined in Python (the button
layout).
* Adjusted related operator UI names.
Keymap:
Keymap is now consistent with other list-based views in Blender, such as
the Outliner.
* Left click to select, double-click to open
* Right-click context menus
* Shift-click to fill selection
* Ctrl-click to extend selection
Operator options:
These previously overlapped with the source list, which caused numerous
issues with resizing and presenting many settings in a small panel area.
It was also generally inconsistent with Blender.
* Moved to new sidebar, which can easily be shown or hidden using a
prominent Options toggle.
* IO operators have new layouts to match this new sidebar, using
sub-panels. This will have to be committed separately (Add-on
repository).
* If operators want to show the options by default, they have the option
to do so (see `WM_FILESEL_SHOW_PROPS`, `hide_props_region`), otherwise
they are hidden by default.
General Layout:
The layout has been changed to be simpler, more standard, and fits
better in with Blender 2.8.
* More conventional layout (file path at top, file name at the bottom,
execute/cancel buttons in bottom right).
* Use of popovers to group controls, and allow for more descriptive
naming.
* Search box is always live now, just like Outliner.
Views:
* Date Modified column combines both date and time, also uses user
friendly strings for recent dates (i.e. "Yesterday", "Today").
* Details columns (file size, modification date/time) are now toggleable
for all display types, they are not hardcoded per display type.
* File sizes now show as B, KB, MB, ... rather than B, KiB, MiB, … They
are now also calculated using base 10 of course.
* Option to sort in inverse order.
Vertical List View:
* This view now used a much simpler single vertical list with columns
for information.
* Users can click on the headers of these columns to order by that
category, and click again to reverse the ordering.
Icons:
* Updated icons by Jendrzych, with better centering.
* Files and folders have new icons in Icon view.
* Both files and folders have reworked superimposed icons that show
users the file/folder type.
* 3D file documents correctly use the 3d file icon, which was unused
previously.
* Workspaces now show their icon on Link/Append - also when listed in
the Outliner.
Minor Python-API breakage:
* `bpy.types.FileSelectParams.display_type`: `LIST_SHORT` and
`LIST_LONG` are replaced by `LIST_VERTICAL` and `LIST_HORIZONTAL`.
Removes the feature where directories would automatically be created if
they are entered into the file path text button, but don't exist. We
were not sure if users use it enough to keep it. We can definitely bring
it back.
----
//Combined effort by @billreynish, @harley, @jendrzych, my university
colleague Brian Meisenheimer and myself.//
Differential Revision: https://developer.blender.org/D5601
Reviewers: Brecht, Bastien
2019-09-03 15:43:38 +02:00
|
|
|
if ((flag & WM_FILESEL_SHOW_PROPS) == 0) {
|
|
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"hide_props_region",
|
|
|
|
|
true,
|
|
|
|
|
"Hide Operator Properties",
|
|
|
|
|
"Collapse the region displaying the operator settings");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
if (action == FILE_SAVE) {
|
2021-07-03 23:08:40 +10:00
|
|
|
/* NOTE: this is only used to check if we should highlight the filename area red when the
|
2015-12-27 16:36:08 +11:00
|
|
|
* filepath is an existing file. */
|
|
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"check_existing",
|
|
|
|
|
true,
|
|
|
|
|
"Check Existing",
|
|
|
|
|
"Check and warn on overwriting existing files");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_blender", (filter & FILE_TYPE_BLENDER) != 0, "Filter .blend files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"filter_backup",
|
|
|
|
|
(filter & FILE_TYPE_BLENDER_BACKUP) != 0,
|
|
|
|
|
"Filter .blend files",
|
|
|
|
|
"");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_image", (filter & FILE_TYPE_IMAGE) != 0, "Filter image files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_movie", (filter & FILE_TYPE_MOVIE) != 0, "Filter movie files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_python", (filter & FILE_TYPE_PYSCRIPT) != 0, "Filter python files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_font", (filter & FILE_TYPE_FTFONT) != 0, "Filter font files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_sound", (filter & FILE_TYPE_SOUND) != 0, "Filter sound files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_text", (filter & FILE_TYPE_TEXT) != 0, "Filter text files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2019-09-05 07:54:41 +02:00
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_archive", (filter & FILE_TYPE_ARCHIVE) != 0, "Filter archive files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2015-12-27 16:36:08 +11:00
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_btx", (filter & FILE_TYPE_BTX) != 0, "Filter btx files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_collada", (filter & FILE_TYPE_COLLADA) != 0, "Filter COLLADA files", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_alembic", (filter & FILE_TYPE_ALEMBIC) != 0, "Filter Alembic files", "");
|
2020-01-29 12:59:57 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
USD: Introducing a simple USD Exporter
This commit introduces the first version of an exporter to Pixar's
Universal Scene Description (USD) format.
Reviewed By: sergey, LazyDodo
Differential Revision: https://developer.blender.org/D6287
- The USD libraries are built by `make deps`, but not yet built by
install_deps.sh.
- Only experimental support for instancing; by default all duplicated
objects are made real in the USD file. This is fine for exporting a
linked-in posed character, not so much for thousands of pebbles etc.
- The way materials and UV coordinates and Normals are exported is going
to change soon.
- This patch contains LazyDodo's fixes for building on Windows in D5359.
== Meshes ==
USD seems to support neither per-material nor per-face-group
double-sidedness, so we just use the flag from the first non-empty
material slot. If there is no material we default to double-sidedness.
Each UV map is stored on the mesh in a separate primvar. Materials can
refer to these UV maps, but this is not yet exported by Blender. The
primvar name is the same as the UV Map name. This is to allow the
standard name "st" for texture coordinates by naming the UV Map as such,
without having to guess which UV Map is the "standard" one.
Face-varying mesh normals are written to USD. When the mesh has custom
loop normals those are written. Otherwise the poly flag `ME_SMOOTH` is
inspected to determine the normals.
The UV maps and mesh normals take up a significant amount of space, so
exporting them is optional. They're still enabled by default, though.
For comparison: a shot of Spring (03_035_A) is 1.2 GiB when exported
with UVs and normals, and 262 MiB without. We probably have room for
optimisation of written UVs and normals.
The mesh subdivision scheme isn't using the default value 'Catmull
Clark', but uses 'None', indicating we're exporting a polygonal mesh.
This is necessary for USD to understand our normals; otherwise the mesh
is always rendered smooth. In the future we may want to expose this
choice of subdivision scheme to the user, or auto-detect it when we
actually support exporting pre-subdivision meshes.
A possible optimisation could be to inspect whether all polygons are
smooth or flat, and mark the USD mesh as such. This can be added when
needed.
== Animation ==
Mesh and transform animation are now written when passing
`animation=True` to the export operator. There is no inspection of
whether an object is actually animated or not; USD can handle
deduplication of static values for us.
The administration of which timecode to use for the export is left to
the file-format-specific concrete subclasses of
`AbstractHierarchyIterator`; the abstract iterator itself doesn't know
anything about the passage of time. This will allow subclasses for the
frame-based USD format and time-based Alembic format.
== Support for simple preview materials ==
Very simple versions of the materials are now exported, using only the
viewport diffuse RGB, metallic, and roughness.
When there are multiple materials, the mesh faces are stored as geometry
subset and each material is assigned to the appropriate subset. If there
is only one material this is skipped.
The first material if any) is always applied to the mesh itself
(regardless of the existence of geometry subsets), because the Hydra
viewport doesn't support materials on subsets. See
https://github.com/PixarAnimationStudios/USD/issues/542 for more info.
Note that the geometry subsets are not yet time-sampled, so it may break
when an animated mesh changes topology.
Materials are exported as a flat list under a top-level '/_materials'
namespace. This inhibits instancing of the objects using those
materials, so this is subject to change.
== Hair ==
Only the parent strands are exported, and only with a constant colour.
No UV coordinates, no information about the normals.
== Camera ==
Only perspective cameras are supported for now.
== Particles ==
Particles are only written when they are alive, which means that they
are always visible (there is currently no code that deals with marking
them as invisible outside their lifespan).
Particle-system-instanced objects are exported by suffixing the object
name with the particle's persistent ID, giving each particle XForm a
unique name.
== Instancing/referencing ==
This exporter has experimental support for instancing/referencing.
Dupli-object meshes are now written to USD as references to the original
mesh. This is still very limited in correctness, as there are issues
referencing to materials from a referenced mesh.
I am still committing this, as it gives us a place to start when
continuing the quest for proper instancing in USD.
== Lights ==
USD does not directly support spot lights, so those aren't exported yet.
It's possible to add this in the future via the UsdLuxShapingAPI. The
units used for the light intensity are also still a bit of a mystery.
== Fluid vertex velocities ==
Currently only fluid simulations (not meshes in general) have explicit
vertex velocities. This is the most important case for exporting
velocities, though, as the baked mesh changes topology all the time, and
thus computing the velocities at import time in a post-processing step
is hard.
== The Building Process ==
- USD is built as monolithic library, instead of 25 smaller libraries.
We were linking all of them as 'whole archive' anyway, so this doesn't
affect the final file size. It does, however, make life easier with
respect to linking order, and handling upstream changes.
- The JSON files required by USD are installed into datafiles/usd; they
are required on every platform. Set the `PXR_PATH_DEBUG` to any value
to have the USD library print the paths it uses to find those files.
- USD is patched so that it finds the aforementioned JSON files in a path
that we pass to it from Blender.
- USD is patched to have a `PXR_BUILD_USD_TOOLS` CMake option to disable
building the tools in its `bin` directory. This is sent as a pull
request at https://github.com/PixarAnimationStudios/USD/pull/1048
2019-12-13 10:27:40 +01:00
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_usd", (filter & FILE_TYPE_USD) != 0, "Filter USD files", "");
|
2022-01-03 14:49:31 -05:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_obj", (filter & FILE_TYPE_OBJECT_IO) != 0, "Filter OBJ files", "");
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2020-03-17 14:41:48 +01:00
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"filter_volume",
|
|
|
|
|
(filter & FILE_TYPE_VOLUME) != 0,
|
|
|
|
|
"Filter OpenVDB volume files",
|
|
|
|
|
"");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2015-12-27 16:36:08 +11:00
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_folder", (filter & FILE_TYPE_FOLDER) != 0, "Filter folders", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "filter_blenlib", (filter & FILE_TYPE_BLENDERLIB) != 0, "Filter Blender IDs", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-03 23:08:40 +10:00
|
|
|
/* TODO: asset only filter? */
|
2020-12-14 13:50:36 +01:00
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
prop = RNA_def_int(
|
|
|
|
|
ot->srna,
|
|
|
|
|
"filemode",
|
|
|
|
|
type,
|
|
|
|
|
FILE_LOADLIB,
|
|
|
|
|
FILE_SPECIAL,
|
|
|
|
|
"File Browser Mode",
|
|
|
|
|
"The setting for the file browser mode to load a .blend file, a library or a special file",
|
|
|
|
|
FILE_LOADLIB,
|
|
|
|
|
FILE_SPECIAL);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-13 09:15:15 +02:00
|
|
|
if (flag & WM_FILESEL_RELPATH) {
|
2015-12-27 16:36:08 +11:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"relative_path",
|
|
|
|
|
true,
|
|
|
|
|
"Relative Path",
|
|
|
|
|
"Select the file relative to the blend file");
|
2019-04-13 09:15:15 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
if ((filter & FILE_TYPE_IMAGE) || (filter & FILE_TYPE_MOVIE)) {
|
|
|
|
|
prop = RNA_def_boolean(ot->srna, "show_multiview", 0, "Enable Multi-View", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(ot->srna, "use_multiview", 0, "Use Multi-View", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
prop = RNA_def_enum(ot->srna, "display_type", file_display_items, display, "Display Type", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-02 23:55:59 +01:00
|
|
|
prop = RNA_def_enum(ot->srna, "sort_method", DummyRNA_NULL_items, sort, "File sorting mode", "");
|
|
|
|
|
RNA_def_enum_funcs(prop, wm_operator_properties_filesel_sort_items_itemf);
|
2015-12-27 16:36:08 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 20:54:15 +02:00
|
|
|
void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop_session_uuid = RNA_struct_find_property(ptr, "session_uuid");
|
|
|
|
|
PropertyRNA *prop_name = RNA_struct_find_property(ptr, "name");
|
|
|
|
|
|
|
|
|
|
if (prop_session_uuid) {
|
|
|
|
|
RNA_int_set(ptr, "session_uuid", (int)id->session_uuid);
|
|
|
|
|
}
|
|
|
|
|
else if (prop_name) {
|
|
|
|
|
RNA_string_set(ptr, "name", id->name + 2);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_assert_unreachable();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 20:32:36 +02:00
|
|
|
ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain,
|
2022-05-24 14:22:59 +02:00
|
|
|
PointerRNA *ptr,
|
2022-05-23 20:32:36 +02:00
|
|
|
const ID_Type type)
|
|
|
|
|
{
|
2022-05-24 14:22:59 +02:00
|
|
|
PropertyRNA *prop_session_uuid = RNA_struct_find_property(ptr, "session_uuid");
|
2022-05-24 15:32:30 +02:00
|
|
|
if (prop_session_uuid && RNA_property_is_set(ptr, prop_session_uuid)) {
|
|
|
|
|
const uint32_t session_uuid = (uint32_t)RNA_property_int_get(ptr, prop_session_uuid);
|
|
|
|
|
return BKE_libblock_find_session_uuid(bmain, type, session_uuid);
|
|
|
|
|
}
|
2022-05-23 20:32:36 +02:00
|
|
|
|
2022-05-24 15:32:30 +02:00
|
|
|
PropertyRNA *prop_name = RNA_struct_find_property(ptr, "name");
|
2022-05-24 14:22:59 +02:00
|
|
|
if (prop_name && RNA_property_is_set(ptr, prop_name)) {
|
2022-05-23 20:32:36 +02:00
|
|
|
char name[MAX_ID_NAME - 2];
|
2022-05-24 14:22:59 +02:00
|
|
|
RNA_property_string_get(ptr, prop_name, name);
|
2022-05-23 20:32:36 +02:00
|
|
|
return BKE_libblock_find_name(bmain, type, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 16:47:48 +02:00
|
|
|
bool WM_operator_properties_id_lookup_is_set(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
return RNA_struct_property_is_set(ptr, "session_uuid") ||
|
|
|
|
|
RNA_struct_property_is_set(ptr, "name");
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 20:32:36 +02:00
|
|
|
void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
if (add_name_prop) {
|
|
|
|
|
prop = RNA_def_string(ot->srna,
|
|
|
|
|
"name",
|
|
|
|
|
NULL,
|
|
|
|
|
MAX_ID_NAME - 2,
|
|
|
|
|
"Name",
|
|
|
|
|
"Name of the data-block to use by the operator");
|
|
|
|
|
RNA_def_property_flag(prop, (PropertyFlag)(PROP_SKIP_SAVE | PROP_HIDDEN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_int(ot->srna,
|
|
|
|
|
"session_uuid",
|
|
|
|
|
0,
|
|
|
|
|
INT32_MIN,
|
|
|
|
|
INT32_MAX,
|
|
|
|
|
"Session UUID",
|
|
|
|
|
"Session UUID of the data-block to use by the operator",
|
|
|
|
|
INT32_MIN,
|
|
|
|
|
INT32_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, (PropertyFlag)(PROP_SKIP_SAVE | PROP_HIDDEN));
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
static void wm_operator_properties_select_action_ex(wmOperatorType *ot,
|
|
|
|
|
int default_action,
|
2019-04-16 13:12:28 +02:00
|
|
|
const EnumPropertyItem *select_actions,
|
|
|
|
|
bool hide_gui)
|
2015-12-27 16:36:08 +11:00
|
|
|
{
|
2018-06-12 22:00:22 +02:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
prop = RNA_def_enum(
|
|
|
|
|
ot->srna, "action", select_actions, default_action, "Action", "Selection action to execute");
|
2019-04-16 13:12:28 +02:00
|
|
|
|
|
|
|
|
if (hide_gui) {
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
}
|
2015-12-27 16:36:08 +11:00
|
|
|
}
|
|
|
|
|
|
2019-04-16 13:12:28 +02:00
|
|
|
void WM_operator_properties_select_action(wmOperatorType *ot, int default_action, bool hide_gui)
|
2015-12-27 16:36:08 +11:00
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem select_actions[] = {
|
2015-12-27 16:36:08 +11:00
|
|
|
{SEL_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle selection for all elements"},
|
|
|
|
|
{SEL_SELECT, "SELECT", 0, "Select", "Select all elements"},
|
|
|
|
|
{SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"},
|
|
|
|
|
{SEL_INVERT, "INVERT", 0, "Invert", "Invert selection of all elements"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2015-12-27 16:36:08 +11:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-16 13:12:28 +02:00
|
|
|
wm_operator_properties_select_action_ex(ot, default_action, select_actions, hide_gui);
|
2015-12-27 16:36:08 +11:00
|
|
|
}
|
|
|
|
|
|
2019-04-16 13:12:28 +02:00
|
|
|
void WM_operator_properties_select_action_simple(wmOperatorType *ot,
|
|
|
|
|
int default_action,
|
|
|
|
|
bool hide_gui)
|
2015-12-27 16:36:08 +11:00
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem select_actions[] = {
|
2015-12-27 16:36:08 +11:00
|
|
|
{SEL_SELECT, "SELECT", 0, "Select", "Select all elements"},
|
|
|
|
|
{SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2015-12-27 16:36:08 +11:00
|
|
|
};
|
|
|
|
|
|
2019-04-16 13:12:28 +02:00
|
|
|
wm_operator_properties_select_action_ex(ot, default_action, select_actions, hide_gui);
|
2015-12-27 16:36:08 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WM_operator_properties_select_random(wmOperatorType *ot)
|
|
|
|
|
{
|
2021-01-27 11:19:54 -06:00
|
|
|
RNA_def_float_factor(ot->srna,
|
|
|
|
|
"ratio",
|
|
|
|
|
0.5f,
|
|
|
|
|
0.0f,
|
|
|
|
|
1.0f,
|
|
|
|
|
"Ratio",
|
|
|
|
|
"Portion of items to select randomly",
|
2021-03-04 16:55:50 +11:00
|
|
|
0.0f,
|
2021-01-27 11:19:54 -06:00
|
|
|
1.0f);
|
2015-12-27 16:36:08 +11:00
|
|
|
RNA_def_int(ot->srna,
|
|
|
|
|
"seed",
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
INT_MAX,
|
|
|
|
|
"Random Seed",
|
|
|
|
|
"Seed for the random number generator",
|
|
|
|
|
0,
|
|
|
|
|
255);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-16 13:12:28 +02:00
|
|
|
WM_operator_properties_select_action_simple(ot, SEL_SELECT, false);
|
2015-12-27 16:36:08 +11:00
|
|
|
}
|
|
|
|
|
|
2016-03-29 01:20:45 +11:00
|
|
|
int WM_operator_properties_select_random_seed_increment_get(wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "seed");
|
|
|
|
|
int value = RNA_property_int_get(op->ptr, prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-03-29 01:20:45 +11:00
|
|
|
if (op->flag & OP_IS_INVOKE) {
|
|
|
|
|
if (!RNA_property_is_set(op->ptr, prop)) {
|
|
|
|
|
value += 1;
|
|
|
|
|
RNA_property_int_set(op->ptr, prop, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
void WM_operator_properties_select_all(wmOperatorType *ot)
|
|
|
|
|
{
|
2019-04-16 13:12:28 +02:00
|
|
|
WM_operator_properties_select_action(ot, SEL_TOGGLE, true);
|
2015-12-27 16:36:08 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WM_operator_properties_border(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
prop = RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-12 14:26:43 +11:00
|
|
|
prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2015-12-27 16:36:08 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WM_operator_properties_border_to_rcti(struct wmOperator *op, rcti *rect)
|
|
|
|
|
{
|
|
|
|
|
rect->xmin = RNA_int_get(op->ptr, "xmin");
|
|
|
|
|
rect->ymin = RNA_int_get(op->ptr, "ymin");
|
|
|
|
|
rect->xmax = RNA_int_get(op->ptr, "xmax");
|
|
|
|
|
rect->ymax = RNA_int_get(op->ptr, "ymax");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect)
|
|
|
|
|
{
|
|
|
|
|
rcti rect_i;
|
|
|
|
|
WM_operator_properties_border_to_rcti(op, &rect_i);
|
|
|
|
|
BLI_rctf_rcti_copy(rect, &rect_i);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
void WM_operator_properties_gesture_box_ex(wmOperatorType *ot, bool deselect, bool extend)
|
2015-12-27 16:36:08 +11:00
|
|
|
{
|
2018-10-04 15:12:28 +10:00
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
WM_operator_properties_border(ot);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-16 21:58:51 +11:00
|
|
|
if (deselect) {
|
2018-10-04 15:12:28 +10:00
|
|
|
prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "deselect", false, "Deselect", "Deselect rather than select items");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2017-10-16 21:58:51 +11:00
|
|
|
}
|
2015-12-27 16:36:08 +11:00
|
|
|
if (extend) {
|
2018-10-04 15:12:28 +10:00
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"extend",
|
|
|
|
|
true,
|
|
|
|
|
"Extend",
|
|
|
|
|
"Extend selection instead of deselecting everything first");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2015-12-27 16:36:08 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-31 19:53:24 +10:00
|
|
|
void WM_operator_properties_use_cursor_init(wmOperatorType *ot)
|
|
|
|
|
{
|
2019-07-25 13:41:38 +10:00
|
|
|
PropertyRNA *prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"use_cursor_init",
|
|
|
|
|
true,
|
|
|
|
|
"Use Mouse Position",
|
|
|
|
|
"Allow the initial mouse position to be used");
|
2019-05-31 19:53:24 +10:00
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
void WM_operator_properties_gesture_box_select(wmOperatorType *ot)
|
2017-10-16 21:58:51 +11:00
|
|
|
{
|
2018-10-05 10:27:04 +10:00
|
|
|
WM_operator_properties_gesture_box_ex(ot, true, true);
|
2017-10-16 21:58:51 +11:00
|
|
|
}
|
2018-10-05 10:27:04 +10:00
|
|
|
void WM_operator_properties_gesture_box(wmOperatorType *ot)
|
2017-10-16 21:58:51 +11:00
|
|
|
{
|
2018-10-05 10:27:04 +10:00
|
|
|
WM_operator_properties_gesture_box_ex(ot, false, false);
|
2017-10-16 21:58:51 +11:00
|
|
|
}
|
|
|
|
|
|
2018-08-14 10:28:41 +10:00
|
|
|
void WM_operator_properties_select_operation(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
static const EnumPropertyItem select_mode_items[] = {
|
2019-05-06 16:47:13 +02:00
|
|
|
{SEL_OP_SET, "SET", ICON_SELECT_SET, "Set", "Set a new selection"},
|
|
|
|
|
{SEL_OP_ADD, "ADD", ICON_SELECT_EXTEND, "Extend", "Extend existing selection"},
|
|
|
|
|
{SEL_OP_SUB, "SUB", ICON_SELECT_SUBTRACT, "Subtract", "Subtract existing selection"},
|
2022-04-05 09:19:32 +02:00
|
|
|
{SEL_OP_XOR, "XOR", ICON_SELECT_DIFFERENCE, "Difference", "Invert existing selection"},
|
2019-05-06 16:47:13 +02:00
|
|
|
{SEL_OP_AND, "AND", ICON_SELECT_INTERSECT, "Intersect", "Intersect existing selection"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2018-08-14 10:28:41 +10:00
|
|
|
};
|
2018-11-13 14:02:28 +11:00
|
|
|
PropertyRNA *prop = RNA_def_enum(ot->srna, "mode", select_mode_items, SEL_OP_SET, "Mode", "");
|
2018-08-14 10:28:41 +10:00
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-23 17:52:28 +11:00
|
|
|
void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
static const EnumPropertyItem select_mode_items[] = {
|
2019-05-06 16:47:13 +02:00
|
|
|
{SEL_OP_SET, "SET", ICON_SELECT_SET, "Set", "Set a new selection"},
|
|
|
|
|
{SEL_OP_ADD, "ADD", ICON_SELECT_EXTEND, "Extend", "Extend existing selection"},
|
|
|
|
|
{SEL_OP_SUB, "SUB", ICON_SELECT_SUBTRACT, "Subtract", "Subtract existing selection"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2018-11-23 17:52:28 +11:00
|
|
|
};
|
|
|
|
|
PropertyRNA *prop = RNA_def_enum(ot->srna, "mode", select_mode_items, SEL_OP_SET, "Mode", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-02 16:05:59 +01:00
|
|
|
void WM_operator_properties_select_walk_direction(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
static const EnumPropertyItem direction_items[] = {
|
2020-12-17 19:06:21 -06:00
|
|
|
{UI_SELECT_WALK_UP, "UP", 0, "Previous", ""},
|
2020-03-02 16:05:59 +01:00
|
|
|
{UI_SELECT_WALK_DOWN, "DOWN", 0, "Next", ""},
|
|
|
|
|
{UI_SELECT_WALK_LEFT, "LEFT", 0, "Left", ""},
|
|
|
|
|
{UI_SELECT_WALK_RIGHT, "RIGHT", 0, "Right", ""},
|
|
|
|
|
{0, NULL, 0, NULL, NULL},
|
|
|
|
|
};
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
prop = RNA_def_enum(ot->srna,
|
|
|
|
|
"direction",
|
|
|
|
|
direction_items,
|
|
|
|
|
0,
|
|
|
|
|
"Walk Direction",
|
|
|
|
|
"Select/Deselect element in this direction");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
|
}
|
|
|
|
|
|
WM: Utilities for select operators to work with click-dragging items
Based on work by Bastien and Brecht in the Node Editor, this adds more
generalized support for selecting items so that click+drag actions on
items (nodes, makers, dopesheet keys, etc.) works as wanted.
Note that this only adds the barebones to support this in other editors,
it's not used yet (will be done in followup commits).
The behavior is supposed to work as follows:
* Clicking an unselected item immediately selects it, and deselects
other items (doesn't wait for release events).
* Click+drag on an unselected item immediately selects it, deselects
others and drags it in one go (don't require selecting it first!).
* Click+drag on a selected item won't change the selection state (and
won't send an undo push) and start dragging all selected items as soon
as the drag event is recognized.
* Clicking on a selected item will still deselect others, but that will
only happen on mouse release, when we know the intention is not to drag
the item.
Included in: https://developer.blender.org/D5979
Reviewed by: Brecht van Lommel, William Reynish
2019-10-04 15:11:19 +02:00
|
|
|
void WM_operator_properties_generic_select(wmOperatorType *ot)
|
|
|
|
|
{
|
2019-11-22 16:46:15 +01:00
|
|
|
/* On the initial mouse press, this is set by #WM_generic_select_modal() to let the select
|
|
|
|
|
* operator exec callback know that it should not __yet__ deselect other items when clicking on
|
|
|
|
|
* an already selected one. Instead should make sure the operator executes modal then (see
|
|
|
|
|
* #WM_generic_select_modal()), so that the exec callback can be called a second time on the
|
|
|
|
|
* mouse release event to do this part. */
|
WM: Utilities for select operators to work with click-dragging items
Based on work by Bastien and Brecht in the Node Editor, this adds more
generalized support for selecting items so that click+drag actions on
items (nodes, makers, dopesheet keys, etc.) works as wanted.
Note that this only adds the barebones to support this in other editors,
it's not used yet (will be done in followup commits).
The behavior is supposed to work as follows:
* Clicking an unselected item immediately selects it, and deselects
other items (doesn't wait for release events).
* Click+drag on an unselected item immediately selects it, deselects
others and drags it in one go (don't require selecting it first!).
* Click+drag on a selected item won't change the selection state (and
won't send an undo push) and start dragging all selected items as soon
as the drag event is recognized.
* Clicking on a selected item will still deselect others, but that will
only happen on mouse release, when we know the intention is not to drag
the item.
Included in: https://developer.blender.org/D5979
Reviewed by: Brecht van Lommel, William Reynish
2019-10-04 15:11:19 +02:00
|
|
|
PropertyRNA *prop = RNA_def_boolean(
|
2019-10-14 11:55:49 +02:00
|
|
|
ot->srna, "wait_to_deselect_others", false, "Wait to Deselect Others", "");
|
WM: Utilities for select operators to work with click-dragging items
Based on work by Bastien and Brecht in the Node Editor, this adds more
generalized support for selecting items so that click+drag actions on
items (nodes, makers, dopesheet keys, etc.) works as wanted.
Note that this only adds the barebones to support this in other editors,
it's not used yet (will be done in followup commits).
The behavior is supposed to work as follows:
* Clicking an unselected item immediately selects it, and deselects
other items (doesn't wait for release events).
* Click+drag on an unselected item immediately selects it, deselects
others and drags it in one go (don't require selecting it first!).
* Click+drag on a selected item won't change the selection state (and
won't send an undo push) and start dragging all selected items as soon
as the drag event is recognized.
* Clicking on a selected item will still deselect others, but that will
only happen on mouse release, when we know the intention is not to drag
the item.
Included in: https://developer.blender.org/D5979
Reviewed by: Brecht van Lommel, William Reynish
2019-10-04 15:11:19 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
|
|
|
|
|
RNA_def_int(ot->srna, "mouse_x", 0, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
void WM_operator_properties_gesture_box_zoom(wmOperatorType *ot)
|
2017-10-16 21:58:51 +11:00
|
|
|
{
|
|
|
|
|
WM_operator_properties_border(ot);
|
|
|
|
|
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
prop = RNA_def_boolean(ot->srna, "zoom_out", false, "Zoom Out", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-07 23:41:32 +11:00
|
|
|
void WM_operator_properties_gesture_lasso(wmOperatorType *ot)
|
2017-10-16 16:11:04 +11:00
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
prop = RNA_def_int(ot->srna, "xstart", 0, INT_MIN, INT_MAX, "X Start", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_int(ot->srna, "xend", 0, INT_MIN, INT_MAX, "X End", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_int(ot->srna, "ystart", 0, INT_MIN, INT_MAX, "Y Start", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_int(ot->srna, "yend", 0, INT_MIN, INT_MAX, "Y End", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2020-10-21 17:44:00 +02:00
|
|
|
prop = RNA_def_boolean(ot->srna, "flip", false, "Flip", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-27 16:36:08 +11:00
|
|
|
if (cursor) {
|
|
|
|
|
prop = RNA_def_int(ot->srna,
|
|
|
|
|
"cursor",
|
|
|
|
|
cursor,
|
|
|
|
|
0,
|
|
|
|
|
INT_MAX,
|
|
|
|
|
"Cursor",
|
|
|
|
|
"Mouse cursor style to use during the modal operator",
|
|
|
|
|
0,
|
|
|
|
|
INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-27 17:46:55 +11:00
|
|
|
|
2019-03-05 22:26:45 +11:00
|
|
|
void WM_operator_properties_gesture_circle(wmOperatorType *ot)
|
2017-10-16 15:32:09 +11:00
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
const int radius_default = 25;
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
|
|
|
|
RNA_def_int(ot->srna, "radius", radius_default, 1, INT_MAX, "Radius", "", 1, INT_MAX);
|
2017-10-16 21:58:51 +11:00
|
|
|
|
2018-12-12 14:26:43 +11:00
|
|
|
prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2017-10-16 15:32:09 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WM_operator_properties_mouse_select(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-16 15:32:09 +11:00
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"extend",
|
|
|
|
|
false,
|
|
|
|
|
"Extend",
|
|
|
|
|
"Extend selection instead of deselecting everything first");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Remove from selection");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
|
prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Selection", "Toggle the selection");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2019-04-29 11:33:50 +02:00
|
|
|
|
|
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"deselect_all",
|
2019-04-29 15:01:55 +02:00
|
|
|
false,
|
2019-04-29 11:33:50 +02:00
|
|
|
"Deselect On Nothing",
|
|
|
|
|
"Deselect all when nothing under the cursor");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2022-03-17 14:37:20 +11:00
|
|
|
|
|
|
|
|
/* TODO: currently only used for the 3D viewport. */
|
|
|
|
|
prop = RNA_def_boolean(ot->srna,
|
|
|
|
|
"select_passthrough",
|
|
|
|
|
false,
|
|
|
|
|
"Only Select Unselected",
|
|
|
|
|
"Ignore the select action when the element is already selected");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2017-10-16 15:32:09 +11:00
|
|
|
}
|
|
|
|
|
|
2015-12-27 17:46:55 +11:00
|
|
|
void WM_operator_properties_checker_interval(wmOperatorType *ot, bool nth_can_disable)
|
|
|
|
|
{
|
2019-09-04 22:46:24 +10:00
|
|
|
const int nth_default = nth_can_disable ? 0 : 1;
|
|
|
|
|
const int nth_min = min_ii(nth_default, 1);
|
2018-06-26 12:29:11 -04:00
|
|
|
RNA_def_int(ot->srna,
|
2019-09-04 22:46:24 +10:00
|
|
|
"skip",
|
2018-06-26 12:29:11 -04:00
|
|
|
nth_default,
|
|
|
|
|
nth_min,
|
|
|
|
|
INT_MAX,
|
2019-09-04 22:46:24 +10:00
|
|
|
"Deselected",
|
|
|
|
|
"Number of deselected elements in the repetitive sequence",
|
2018-06-26 12:29:11 -04:00
|
|
|
nth_min,
|
|
|
|
|
100);
|
2019-09-04 22:46:24 +10:00
|
|
|
RNA_def_int(ot->srna,
|
|
|
|
|
"nth",
|
|
|
|
|
1,
|
|
|
|
|
1,
|
|
|
|
|
INT_MAX,
|
|
|
|
|
"Selected",
|
|
|
|
|
"Number of selected elements in the repetitive sequence",
|
|
|
|
|
1,
|
|
|
|
|
100);
|
2018-06-26 12:29:11 -04:00
|
|
|
RNA_def_int(ot->srna,
|
|
|
|
|
"offset",
|
|
|
|
|
0,
|
|
|
|
|
INT_MIN,
|
|
|
|
|
INT_MAX,
|
|
|
|
|
"Offset",
|
|
|
|
|
"Offset from the starting point",
|
|
|
|
|
-100,
|
|
|
|
|
100);
|
2015-12-27 17:46:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WM_operator_properties_checker_interval_from_op(struct wmOperator *op,
|
|
|
|
|
struct CheckerIntervalParams *op_params)
|
|
|
|
|
{
|
2019-09-04 22:46:24 +10:00
|
|
|
const int nth = RNA_int_get(op->ptr, "nth");
|
2015-12-27 17:46:55 +11:00
|
|
|
const int skip = RNA_int_get(op->ptr, "skip");
|
|
|
|
|
int offset = RNA_int_get(op->ptr, "offset");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-27 17:46:55 +11:00
|
|
|
op_params->nth = nth;
|
|
|
|
|
op_params->skip = skip;
|
2019-08-14 23:29:46 +10:00
|
|
|
|
|
|
|
|
/* So input of offset zero ends up being (nth - 1). */
|
|
|
|
|
op_params->offset = mod_i(offset, nth + skip);
|
2015-12-27 17:46:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool WM_operator_properties_checker_interval_test(const struct CheckerIntervalParams *op_params,
|
|
|
|
|
int depth)
|
|
|
|
|
{
|
2019-09-04 22:46:24 +10:00
|
|
|
return ((op_params->skip == 0) ||
|
2015-12-27 17:46:55 +11:00
|
|
|
((op_params->offset + depth) % (op_params->skip + op_params->nth) >= op_params->skip));
|
|
|
|
|
}
|