2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-24 10:33:10 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2008-12-24 10:33:10 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-24 10:33:10 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup spnode
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2019-02-27 12:34:56 +11:00
|
|
|
#include "DNA_light_types.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_node_types.h"
|
2012-11-03 14:32:26 +00:00
|
|
|
#include "DNA_text_types.h"
|
2011-11-02 18:55:32 +00:00
|
|
|
#include "DNA_world_types.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_math.h"
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_library.h"
|
|
|
|
#include "BKE_main.h"
|
2012-08-06 08:41:45 +00:00
|
|
|
#include "BKE_node.h"
|
|
|
|
#include "BKE_report.h"
|
2011-11-08 11:38:16 +00:00
|
|
|
#include "BKE_scene.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
2012-11-03 14:32:26 +00:00
|
|
|
#include "RE_engine.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "RE_pipeline.h"
|
|
|
|
|
2008-12-28 00:08:34 +00:00
|
|
|
|
2012-08-01 20:39:14 +00:00
|
|
|
#include "ED_node.h" /* own include */
|
2019-03-05 18:30:06 +11:00
|
|
|
#include "ED_select_utils.h"
|
2009-01-12 00:14:37 +00:00
|
|
|
#include "ED_screen.h"
|
2010-07-04 19:58:52 +00:00
|
|
|
#include "ED_render.h"
|
2009-01-12 00:14:37 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "RNA_enum_types.h"
|
2009-01-12 00:14:37 +00:00
|
|
|
|
|
|
|
#include "WM_api.h"
|
2008-12-28 00:08:34 +00:00
|
|
|
#include "WM_types.h"
|
|
|
|
|
2009-01-01 16:27:02 +00:00
|
|
|
#include "UI_view2d.h"
|
2010-04-07 17:06:22 +00:00
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "GPU_material.h"
|
|
|
|
|
2013-03-07 17:47:30 +00:00
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
2012-08-01 20:39:14 +00:00
|
|
|
#include "node_intern.h" /* own include */
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "NOD_composite.h"
|
|
|
|
#include "NOD_shader.h"
|
|
|
|
#include "NOD_texture.h"
|
|
|
|
|
2009-01-01 16:27:02 +00:00
|
|
|
|
2012-08-15 11:31:04 +00:00
|
|
|
#define USE_ESC_COMPO
|
|
|
|
|
2009-01-27 17:12:40 +00:00
|
|
|
/* ***************** composite job manager ********************** */
|
|
|
|
|
2013-03-20 18:01:47 +00:00
|
|
|
enum {
|
|
|
|
COM_RECALC_COMPOSITE = 1,
|
2019-01-15 23:57:49 +11:00
|
|
|
COM_RECALC_VIEWER = 2,
|
2013-03-20 18:01:47 +00:00
|
|
|
};
|
|
|
|
|
2009-01-27 17:12:40 +00:00
|
|
|
typedef struct CompoJob {
|
2018-06-11 15:40:37 +02:00
|
|
|
Main *bmain;
|
2009-01-27 17:12:40 +00:00
|
|
|
Scene *scene;
|
|
|
|
bNodeTree *ntree;
|
|
|
|
bNodeTree *localtree;
|
2014-04-27 00:22:49 +10:00
|
|
|
const short *stop;
|
2009-01-27 17:12:40 +00:00
|
|
|
short *do_update;
|
2010-05-27 08:22:16 +00:00
|
|
|
float *progress;
|
2013-03-20 18:01:47 +00:00
|
|
|
int recalc_flags;
|
2009-01-27 17:12:40 +00:00
|
|
|
} CompoJob;
|
|
|
|
|
2013-03-20 18:01:47 +00:00
|
|
|
static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags)
|
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
for (node = nodetree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->type == CMP_NODE_COMPOSITE) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (recalc_flags & COM_RECALC_COMPOSITE) {
|
2013-03-20 18:01:47 +00:00
|
|
|
node->flag |= NODE_DO_OUTPUT_RECALC;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-20 18:01:47 +00:00
|
|
|
}
|
2013-03-31 19:46:11 +00:00
|
|
|
else if (node->type == CMP_NODE_VIEWER || node->type == CMP_NODE_SPLITVIEWER) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (recalc_flags & COM_RECALC_VIEWER) {
|
2013-03-20 18:01:47 +00:00
|
|
|
node->flag |= NODE_DO_OUTPUT_RECALC;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-20 18:01:47 +00:00
|
|
|
}
|
|
|
|
else if (node->type == NODE_GROUP) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->id) {
|
2013-03-20 18:01:47 +00:00
|
|
|
compo_tag_output_nodes((bNodeTree *)node->id, recalc_flags);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-20 18:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int compo_get_recalc_flags(const bContext *C)
|
|
|
|
{
|
2013-04-30 06:03:17 +00:00
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
wmWindow *win;
|
2013-03-20 18:01:47 +00:00
|
|
|
int recalc_flags = 0;
|
|
|
|
|
2013-04-30 06:03:17 +00:00
|
|
|
for (win = wm->windows.first; win; win = win->next) {
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
const bScreen *sc = WM_window_get_active_screen(win);
|
2013-04-30 06:03:17 +00:00
|
|
|
ScrArea *sa;
|
|
|
|
|
|
|
|
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
|
|
|
if (sa->spacetype == SPACE_IMAGE) {
|
|
|
|
SpaceImage *sima = sa->spacedata.first;
|
|
|
|
if (sima->image) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (sima->image->type == IMA_TYPE_R_RESULT) {
|
2013-04-30 06:03:17 +00:00
|
|
|
recalc_flags |= COM_RECALC_COMPOSITE;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else if (sima->image->type == IMA_TYPE_COMPOSITE) {
|
2013-04-30 06:03:17 +00:00
|
|
|
recalc_flags |= COM_RECALC_VIEWER;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-04-30 06:03:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sa->spacetype == SPACE_NODE) {
|
|
|
|
SpaceNode *snode = sa->spacedata.first;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (snode->flag & SNODE_BACKDRAW) {
|
2013-03-20 18:01:47 +00:00
|
|
|
recalc_flags |= COM_RECALC_VIEWER;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-20 18:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return recalc_flags;
|
|
|
|
}
|
|
|
|
|
2009-01-27 17:12:40 +00:00
|
|
|
/* called by compo, only to check job 'stop' value */
|
|
|
|
static int compo_breakjob(void *cjv)
|
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
CompoJob *cj = cjv;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-15 11:31:04 +00:00
|
|
|
/* without G.is_break 'ESC' wont quit - which annoys users */
|
|
|
|
return (*(cj->stop)
|
|
|
|
#ifdef USE_ESC_COMPO
|
|
|
|
||
|
|
|
|
G.is_break
|
|
|
|
#endif
|
|
|
|
);
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
2015-03-27 18:21:39 +05:00
|
|
|
/* called by compo, wmJob sends notifier */
|
2015-03-28 02:36:00 +11:00
|
|
|
static void compo_statsdrawjob(void *cjv, const char *UNUSED(str))
|
2012-11-30 09:12:10 +00:00
|
|
|
{
|
|
|
|
CompoJob *cj = cjv;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
*(cj->do_update) = true;
|
2012-11-30 09:12:10 +00:00
|
|
|
}
|
|
|
|
|
2009-01-27 17:12:40 +00:00
|
|
|
/* called by compo, wmJob sends notifier */
|
2012-11-30 09:12:10 +00:00
|
|
|
static void compo_redrawjob(void *cjv)
|
2009-01-27 17:12:40 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
CompoJob *cj = cjv;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
*(cj->do_update) = true;
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void compo_freejob(void *cjv)
|
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
CompoJob *cj = cjv;
|
2009-01-27 17:12:40 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cj->localtree) {
|
2018-06-11 15:40:37 +02:00
|
|
|
ntreeLocalMerge(cj->bmain, cj->localtree, cj->ntree);
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
MEM_freeN(cj);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only now we copy the nodetree, so adding many jobs while
|
2012-03-03 16:31:46 +00:00
|
|
|
* sliding buttons doesn't frustrate */
|
2009-01-27 17:12:40 +00:00
|
|
|
static void compo_initjob(void *cjv)
|
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
CompoJob *cj = cjv;
|
2009-01-27 17:12:40 +00:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
cj->localtree = ntreeLocalize(cj->ntree);
|
2013-03-20 18:01:47 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (cj->recalc_flags) {
|
2013-03-20 18:01:47 +00:00
|
|
|
compo_tag_output_nodes(cj->localtree, cj->recalc_flags);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* called before redraw notifiers, it moves finished previews over */
|
2015-03-27 18:23:11 +05:00
|
|
|
static void compo_updatejob(void *UNUSED(cjv))
|
2009-01-27 17:12:40 +00:00
|
|
|
{
|
2013-06-24 22:41:27 +00:00
|
|
|
WM_main_add_notifier(NC_SCENE | ND_COMPO_RESULT, NULL);
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
2010-05-27 08:22:16 +00:00
|
|
|
static void compo_progressjob(void *cjv, float progress)
|
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
CompoJob *cj = cjv;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-05-27 08:22:16 +00:00
|
|
|
*(cj->progress) = progress;
|
|
|
|
}
|
|
|
|
|
2009-01-27 17:12:40 +00:00
|
|
|
/* only this runs inside thread */
|
2010-05-27 08:22:16 +00:00
|
|
|
static void compo_startjob(void *cjv, short *stop, short *do_update, float *progress)
|
2009-01-27 17:12:40 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
CompoJob *cj = cjv;
|
|
|
|
bNodeTree *ntree = cj->localtree;
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
Scene *scene = cj->scene;
|
2015-04-06 10:40:12 -03:00
|
|
|
SceneRenderView *srv;
|
2009-09-30 18:18:32 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (scene->use_nodes == false) {
|
2009-01-27 17:12:40 +00:00
|
|
|
return;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
cj->stop = stop;
|
|
|
|
cj->do_update = do_update;
|
|
|
|
cj->progress = progress;
|
|
|
|
|
|
|
|
ntree->test_break = compo_breakjob;
|
|
|
|
ntree->tbh = cj;
|
2012-11-30 09:12:10 +00:00
|
|
|
ntree->stats_draw = compo_statsdrawjob;
|
2012-06-21 13:19:19 +00:00
|
|
|
ntree->sdh = cj;
|
|
|
|
ntree->progress = compo_progressjob;
|
|
|
|
ntree->prh = cj;
|
2012-11-30 09:12:10 +00:00
|
|
|
ntree->update_draw = compo_redrawjob;
|
|
|
|
ntree->udh = cj;
|
|
|
|
|
2009-01-27 17:12:40 +00:00
|
|
|
// XXX BIF_store_spare();
|
2013-04-24 16:36:50 +00:00
|
|
|
/* 1 is do_previews */
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-04-07 16:37:16 -03:00
|
|
|
if ((cj->scene->r.scemode & R_MULTIVIEW) == 0) {
|
|
|
|
ntreeCompositExecTree(cj->scene, ntree, &cj->scene->r, false, true, &scene->view_settings, &scene->display_settings, "");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (srv = scene->r.views.first; srv; srv = srv->next) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (BKE_scene_multiview_is_render_view_active(&scene->r, srv) == false) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-04-07 16:37:16 -03:00
|
|
|
ntreeCompositExecTree(cj->scene, ntree, &cj->scene->r, false, true, &scene->view_settings, &scene->display_settings, srv->name);
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
ntree->test_break = NULL;
|
|
|
|
ntree->stats_draw = NULL;
|
|
|
|
ntree->progress = NULL;
|
2009-01-27 17:12:40 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-08-03 20:56:04 +00:00
|
|
|
/**
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param scene_owner: is the owner of the job,
|
2012-08-03 20:56:04 +00:00
|
|
|
* we don't use it for anything else currently so could also be a void pointer,
|
|
|
|
* but for now keep it an 'Scene' for consistency.
|
|
|
|
*
|
|
|
|
* \note only call from spaces `refresh` callbacks, not direct! - use with care.
|
|
|
|
*/
|
|
|
|
void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene *scene_owner)
|
2009-01-27 17:12:40 +00:00
|
|
|
{
|
2012-08-15 10:03:29 +00:00
|
|
|
wmJob *wm_job;
|
2009-09-30 18:18:32 +00:00
|
|
|
CompoJob *cj;
|
2018-06-11 15:40:37 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2014-04-30 18:12:55 +06:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2009-09-30 18:18:32 +00:00
|
|
|
|
2012-08-06 10:13:49 +00:00
|
|
|
/* to fix bug: [#32272] */
|
2012-08-08 18:37:06 +00:00
|
|
|
if (G.is_rendering) {
|
2012-08-06 10:13:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-15 11:31:04 +00:00
|
|
|
#ifdef USE_ESC_COMPO
|
2014-04-01 11:34:00 +11:00
|
|
|
G.is_break = false;
|
2012-08-15 11:31:04 +00:00
|
|
|
#endif
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
BKE_image_backup_render(scene, BKE_image_verify_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result"), false);
|
2014-04-30 18:12:55 +06:00
|
|
|
|
2012-08-15 10:03:29 +00:00
|
|
|
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene_owner, "Compositing",
|
|
|
|
WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, WM_JOB_TYPE_COMPOSITE);
|
2012-06-21 13:19:19 +00:00
|
|
|
cj = MEM_callocN(sizeof(CompoJob), "compo job");
|
2012-08-03 20:56:04 +00:00
|
|
|
|
2009-01-27 17:12:40 +00:00
|
|
|
/* customdata for preview thread */
|
2018-06-11 15:40:37 +02:00
|
|
|
cj->bmain = bmain;
|
2014-04-30 18:12:55 +06:00
|
|
|
cj->scene = scene;
|
2012-08-03 20:56:04 +00:00
|
|
|
cj->ntree = nodetree;
|
2013-03-20 18:01:47 +00:00
|
|
|
cj->recalc_flags = compo_get_recalc_flags(C);
|
2012-08-03 20:56:04 +00:00
|
|
|
|
2009-01-27 17:12:40 +00:00
|
|
|
/* setup job */
|
2012-08-15 10:03:29 +00:00
|
|
|
WM_jobs_customdata_set(wm_job, cj, compo_freejob);
|
2013-06-24 22:41:27 +00:00
|
|
|
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_COMPO_RESULT, NC_SCENE | ND_COMPO_RESULT);
|
2012-08-15 10:03:29 +00:00
|
|
|
WM_jobs_callbacks(wm_job, compo_startjob, compo_initjob, compo_updatejob, NULL);
|
2012-08-03 20:56:04 +00:00
|
|
|
|
2012-08-15 10:03:29 +00:00
|
|
|
WM_jobs_start(CTX_wm_manager(C), wm_job);
|
2009-01-27 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ***************************************** */
|
|
|
|
|
2011-01-17 18:38:44 +00:00
|
|
|
/* operator poll callback */
|
2018-07-02 11:47:00 +02:00
|
|
|
bool composite_node_active(bContext *C)
|
2011-01-17 18:38:44 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
if (ED_operator_node_active(C)) {
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ED_node_is_compositor(snode)) {
|
2011-01-17 18:38:44 +00:00
|
|
|
return 1;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-01-17 18:38:44 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-05 19:06:33 +00:00
|
|
|
/* operator poll callback */
|
2018-07-02 11:47:00 +02:00
|
|
|
bool composite_node_editable(bContext *C)
|
2013-06-05 19:06:33 +00:00
|
|
|
{
|
|
|
|
if (ED_operator_node_editable(C)) {
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ED_node_is_compositor(snode)) {
|
2013-06-05 19:06:33 +00:00
|
|
|
return 1;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-06-05 19:06:33 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:44:28 +00:00
|
|
|
void snode_dag_update(bContext *C, SpaceNode *snode)
|
2011-05-02 12:31:09 +00:00
|
|
|
{
|
2012-05-05 19:44:28 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
|
|
|
/* for groups, update all ID's using this */
|
2012-06-21 13:19:19 +00:00
|
|
|
if (snode->edittree != snode->nodetree) {
|
2018-11-30 15:22:01 +11:00
|
|
|
FOREACH_NODETREE_BEGIN(bmain, tntree, id) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ntreeHasTree(tntree, snode->edittree)) {
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(id, 0);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-11-30 15:22:01 +11:00
|
|
|
} FOREACH_NODETREE_END;
|
2012-05-05 19:44:28 +00:00
|
|
|
}
|
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(snode->id, 0);
|
2011-05-02 12:31:09 +00:00
|
|
|
}
|
|
|
|
|
2010-01-21 01:42:28 +00:00
|
|
|
void snode_notify(bContext *C, SpaceNode *snode)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2014-11-24 17:18:56 +01:00
|
|
|
ID *id = snode->id;
|
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
WM_event_add_notifier(C, NC_NODE | NA_EDITED, NULL);
|
2011-01-03 14:36:44 +00:00
|
|
|
|
2014-11-24 17:18:56 +01:00
|
|
|
if (ED_node_is_shader(snode)) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (GS(id->name) == ID_MA) {
|
2014-11-24 17:18:56 +01:00
|
|
|
WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else if (GS(id->name) == ID_LA) {
|
2014-11-24 17:18:56 +01:00
|
|
|
WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else if (GS(id->name) == ID_WO) {
|
2014-11-24 17:18:56 +01:00
|
|
|
WM_main_add_notifier(NC_WORLD | ND_WORLD, id);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2014-11-24 17:18:56 +01:00
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
else if (ED_node_is_compositor(snode)) {
|
2014-11-24 17:18:56 +01:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_NODES, id);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else if (ED_node_is_texture(snode)) {
|
2014-11-24 17:18:56 +01:00
|
|
|
WM_event_add_notifier(C, NC_TEXTURE | ND_NODES, id);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_set_tree_type(SpaceNode *snode, bNodeTreeType *typeinfo)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
if (typeinfo) {
|
2013-03-18 16:34:57 +00:00
|
|
|
BLI_strncpy(snode->tree_idname, typeinfo->idname, sizeof(snode->tree_idname));
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2013-03-18 16:34:57 +00:00
|
|
|
snode->tree_idname[0] = '\0';
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
bool ED_node_is_compositor(struct SpaceNode *snode)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2013-03-18 18:25:05 +00:00
|
|
|
return STREQ(snode->tree_idname, ntreeType_Composite->idname);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
bool ED_node_is_shader(struct SpaceNode *snode)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2013-03-18 18:25:05 +00:00
|
|
|
return STREQ(snode->tree_idname, ntreeType_Shader->idname);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
bool ED_node_is_texture(struct SpaceNode *snode)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2013-03-18 18:25:05 +00:00
|
|
|
return STREQ(snode->tree_idname, ntreeType_Texture->idname);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* assumes nothing being done in ntree yet, sets the default in/out node */
|
|
|
|
/* called from shading buttons or header */
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_shader_default(const bContext *C, ID *id)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
|
|
|
bNode *in, *out;
|
2011-11-08 11:38:16 +00:00
|
|
|
bNodeSocket *fromsock, *tosock, *sock;
|
2011-11-02 18:55:32 +00:00
|
|
|
bNodeTree *ntree;
|
|
|
|
int output_type, shader_type;
|
2013-03-18 16:34:57 +00:00
|
|
|
float color[4] = { 0.0f, 0.0f, 0.0f, 1.0f }, strength = 1.0f;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname);
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (GS(id->name)) {
|
2012-09-08 08:59:47 +00:00
|
|
|
case ID_MA:
|
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
Material *ma = (Material *)id;
|
2011-11-02 18:55:32 +00:00
|
|
|
ma->nodetree = ntree;
|
|
|
|
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
output_type = SH_NODE_OUTPUT_MATERIAL;
|
|
|
|
shader_type = SH_NODE_BSDF_PRINCIPLED;
|
2011-11-08 11:38:16 +00:00
|
|
|
|
|
|
|
copy_v3_v3(color, &ma->r);
|
2012-06-21 13:19:19 +00:00
|
|
|
strength = 0.0f;
|
2011-11-02 18:55:32 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case ID_WO:
|
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
World *wo = (World *)id;
|
2011-11-02 18:55:32 +00:00
|
|
|
wo->nodetree = ntree;
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
output_type = SH_NODE_OUTPUT_WORLD;
|
|
|
|
shader_type = SH_NODE_BACKGROUND;
|
|
|
|
|
|
|
|
copy_v3_v3(color, &wo->horr);
|
2012-06-21 13:19:19 +00:00
|
|
|
strength = 1.0f;
|
2011-11-02 18:55:32 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case ID_LA:
|
|
|
|
{
|
2019-02-27 10:46:48 +11:00
|
|
|
Light *la = (Light *)id;
|
2011-11-02 18:55:32 +00:00
|
|
|
la->nodetree = ntree;
|
|
|
|
|
2018-06-27 14:41:53 +02:00
|
|
|
output_type = SH_NODE_OUTPUT_LIGHT;
|
2011-11-08 11:38:16 +00:00
|
|
|
shader_type = SH_NODE_EMISSION;
|
|
|
|
|
|
|
|
copy_v3_v3(color, &la->r);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA) {
|
2012-06-21 13:19:19 +00:00
|
|
|
strength = 100.0f;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2012-06-21 13:19:19 +00:00
|
|
|
strength = 1.0f;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-11-02 18:55:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
printf("ED_node_shader_default called on wrong ID type.\n");
|
|
|
|
return;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
out = nodeAddStaticNode(C, ntree, output_type);
|
2012-06-21 13:19:19 +00:00
|
|
|
out->locx = 300.0f; out->locy = 300.0f;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
in = nodeAddStaticNode(C, ntree, shader_type);
|
2012-06-21 13:19:19 +00:00
|
|
|
in->locx = 10.0f; in->locy = 300.0f;
|
2011-11-02 18:55:32 +00:00
|
|
|
nodeSetActive(ntree, in);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* only a link from color to color */
|
2012-06-21 13:19:19 +00:00
|
|
|
fromsock = in->outputs.first;
|
|
|
|
tosock = out->inputs.first;
|
2011-11-02 18:55:32 +00:00
|
|
|
nodeAddLink(ntree, in, fromsock, out, tosock);
|
2011-11-08 11:38:16 +00:00
|
|
|
|
|
|
|
/* default values */
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
PointerRNA sockptr;
|
|
|
|
sock = in->inputs.first;
|
|
|
|
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
RNA_float_set_array(&sockptr, "default_value", color);
|
2011-11-08 11:38:16 +00:00
|
|
|
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
if (strength != 0.0f) {
|
|
|
|
sock = in->inputs.last;
|
|
|
|
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr);
|
|
|
|
RNA_float_set(&sockptr, "default_value", strength);
|
2011-11-08 11:38:16 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), ntree);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* assumes nothing being done in ntree yet, sets the default in/out node */
|
|
|
|
/* called from shading buttons or header */
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_composit_default(const bContext *C, struct Scene *sce)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
|
|
|
bNode *in, *out;
|
|
|
|
bNodeSocket *fromsock, *tosock;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* but lets check it anyway */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sce->nodetree) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (G.debug & G_DEBUG) {
|
2010-01-22 06:48:29 +00:00
|
|
|
printf("error in composite initialize\n");
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
sce->nodetree = ntreeAddTree(NULL, "Compositing Nodetree", ntreeType_Composite->idname);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
sce->nodetree->chunksize = 256;
|
|
|
|
sce->nodetree->edit_quality = NTREE_QUALITY_HIGH;
|
|
|
|
sce->nodetree->render_quality = NTREE_QUALITY_HIGH;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
out = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_COMPOSITE);
|
2012-06-21 13:19:19 +00:00
|
|
|
out->locx = 300.0f; out->locy = 400.0f;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
in = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_R_LAYERS);
|
2012-06-21 13:19:19 +00:00
|
|
|
in->locx = 10.0f; in->locy = 400.0f;
|
2008-12-24 10:33:10 +00:00
|
|
|
nodeSetActive(sce->nodetree, in);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* links from color to color */
|
2012-06-21 13:19:19 +00:00
|
|
|
fromsock = in->outputs.first;
|
|
|
|
tosock = out->inputs.first;
|
2008-12-24 10:33:10 +00:00
|
|
|
nodeAddLink(sce->nodetree, in, fromsock, out, tosock);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), sce->nodetree);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* assumes nothing being done in ntree yet, sets the default in/out node */
|
|
|
|
/* called from shading buttons or header */
|
2013-03-18 16:34:57 +00:00
|
|
|
void ED_node_texture_default(const bContext *C, Tex *tx)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
|
|
|
bNode *in, *out;
|
|
|
|
bNodeSocket *fromsock, *tosock;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* but lets check it anyway */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tx->nodetree) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (G.debug & G_DEBUG) {
|
2010-01-22 06:48:29 +00:00
|
|
|
printf("error in texture initialize\n");
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
tx->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
out = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_OUTPUT);
|
2012-06-21 13:19:19 +00:00
|
|
|
out->locx = 300.0f; out->locy = 300.0f;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
in = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_CHECKER);
|
2012-06-21 13:19:19 +00:00
|
|
|
in->locx = 10.0f; in->locy = 300.0f;
|
2008-12-24 10:33:10 +00:00
|
|
|
nodeSetActive(tx->nodetree, in);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
fromsock = in->outputs.first;
|
|
|
|
tosock = out->inputs.first;
|
2008-12-24 10:33:10 +00:00
|
|
|
nodeAddLink(tx->nodetree, in, fromsock, out, tosock);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), tx->nodetree);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* Here we set the active tree(s), even called for each redraw now, so keep it fast :) */
|
|
|
|
void snode_set_context(const bContext *C)
|
2009-10-07 22:05:30 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNodeTreeType *treetype = ntreeTypeFind(snode->tree_idname);
|
|
|
|
bNodeTree *ntree = snode->nodetree;
|
|
|
|
ID *id = snode->id, *from = snode->from;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* check the tree type */
|
2013-03-18 18:25:05 +00:00
|
|
|
if (!treetype ||
|
|
|
|
(treetype->poll && !treetype->poll(C, treetype)))
|
|
|
|
{
|
2013-07-08 11:38:09 +00:00
|
|
|
/* invalid tree type, skip
|
|
|
|
* NB: not resetting the node path here, invalid bNodeTreeType
|
|
|
|
* may still be registered at a later point.
|
|
|
|
*/
|
2013-03-18 16:34:57 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (snode->nodetree && !STREQ(snode->nodetree->idname, snode->tree_idname)) {
|
2013-03-18 16:34:57 +00:00
|
|
|
/* current tree does not match selected type, clear tree path */
|
|
|
|
ntree = NULL;
|
|
|
|
id = NULL;
|
|
|
|
from = NULL;
|
2009-10-07 22:05:30 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (!(snode->flag & SNODE_PIN) || ntree == NULL) {
|
2013-03-19 10:42:33 +00:00
|
|
|
if (treetype->get_from_context) {
|
|
|
|
/* reset and update from context */
|
|
|
|
ntree = NULL;
|
|
|
|
id = NULL;
|
|
|
|
from = NULL;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
treetype->get_from_context(C, treetype, &ntree, &id, &from);
|
2013-03-19 10:42:33 +00:00
|
|
|
}
|
2009-10-07 22:05:30 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2017-05-11 20:28:39 +02:00
|
|
|
if (snode->nodetree != ntree || snode->id != id || snode->from != from ||
|
2017-05-15 14:58:55 +10:00
|
|
|
(snode->treepath.last == NULL && ntree))
|
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
ED_node_tree_start(snode, ntree, id, from);
|
2013-03-18 18:25:05 +00:00
|
|
|
}
|
2009-10-07 22:05:30 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
void snode_update(SpaceNode *snode, bNode *node)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeTreePath *path;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* XXX this only updates nodes in the current node space tree path.
|
|
|
|
* The function supposedly should update any potential group node linking to changed tree,
|
|
|
|
* this really requires a working depsgraph ...
|
|
|
|
*/
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* update all edited group nodes */
|
2013-03-18 18:25:05 +00:00
|
|
|
path = snode->treepath.last;
|
2013-03-18 16:34:57 +00:00
|
|
|
if (path) {
|
|
|
|
bNodeTree *ngroup = path->nodetree;
|
2013-03-18 18:25:05 +00:00
|
|
|
for (path = path->prev; path; path = path->prev) {
|
|
|
|
nodeUpdateID(path->nodetree, (ID *)ngroup);
|
2013-03-18 16:34:57 +00:00
|
|
|
ngroup = path->nodetree;
|
2008-11-12 19:03:50 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2009-10-07 22:05:30 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node) {
|
2011-10-19 17:08:35 +00:00
|
|
|
nodeUpdate(snode->edittree, node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-04-19 15:15:50 +00:00
|
|
|
}
|
|
|
|
|
2011-08-12 18:27:48 +00:00
|
|
|
void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
|
|
|
|
{
|
2014-01-28 03:52:21 +11:00
|
|
|
const bool was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE) != 0;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2011-08-12 18:27:48 +00:00
|
|
|
nodeSetActive(ntree, node);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
if (node->type != NODE_GROUP) {
|
2014-01-28 03:52:21 +11:00
|
|
|
const bool was_output = (node->flag & NODE_DO_OUTPUT) != 0;
|
2014-04-01 11:34:00 +11:00
|
|
|
bool do_update = false;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* generic node group output: set node as active output */
|
|
|
|
if (node->type == NODE_GROUP_OUTPUT) {
|
|
|
|
bNode *tnode;
|
2019-03-26 21:16:47 +11:00
|
|
|
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
|
|
|
|
if (tnode->type == NODE_GROUP_OUTPUT) {
|
2013-03-18 16:34:57 +00:00
|
|
|
tnode->flag &= ~NODE_DO_OUTPUT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
node->flag |= NODE_DO_OUTPUT;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!was_output) {
|
2013-03-18 16:34:57 +00:00
|
|
|
do_update = 1;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* tree specific activate calls */
|
2012-06-21 13:19:19 +00:00
|
|
|
if (ntree->type == NTREE_SHADER) {
|
2008-12-24 10:33:10 +00:00
|
|
|
/* when we select a material, active texture is cleared, for buttons */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO)) {
|
2011-08-12 18:27:48 +00:00
|
|
|
nodeClearActiveID(ntree, ID_TE);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
if (ELEM(node->type, SH_NODE_OUTPUT_MATERIAL,
|
2018-06-27 14:41:53 +02:00
|
|
|
SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT, SH_NODE_OUTPUT_LINESTYLE))
|
2014-01-21 01:19:51 +11:00
|
|
|
{
|
2010-12-20 11:08:29 +00:00
|
|
|
bNode *tnode;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
|
|
|
|
if (tnode->type == node->type) {
|
2010-12-20 11:08:29 +00:00
|
|
|
tnode->flag &= ~NODE_DO_OUTPUT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-12-20 11:08:29 +00:00
|
|
|
node->flag |= NODE_DO_OUTPUT;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (was_output == 0) {
|
2016-02-05 01:39:42 +05:00
|
|
|
ED_node_tag_update_nodetree(bmain, ntree, node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2010-12-20 11:08:29 +00:00
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
else if (do_update) {
|
2016-02-05 01:39:42 +05:00
|
|
|
ED_node_tag_update_nodetree(bmain, ntree, node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2010-01-29 16:32:06 +00:00
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
/* if active texture changed, free glsl materials */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) {
|
2011-11-08 13:07:16 +00:00
|
|
|
Material *ma;
|
2014-11-24 17:18:56 +01:00
|
|
|
World *wo;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
for (ma = bmain->materials.first; ma; ma = ma->id.next) {
|
|
|
|
if (ma->nodetree && ma->use_nodes && ntreeHasTree(ma->nodetree, ntree)) {
|
2014-11-24 17:18:56 +01:00
|
|
|
GPU_material_free(&ma->gpumaterial);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
2012-04-13 09:31:37 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
for (wo = bmain->worlds.first; wo; wo = wo->id.next) {
|
|
|
|
if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree)) {
|
2014-11-24 17:18:56 +01:00
|
|
|
GPU_material_free(&wo->gpumaterial);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-06-14 15:30:06 +02:00
|
|
|
ED_node_tag_update_nodetree(bmain, ntree, node);
|
2012-04-13 09:31:37 +00:00
|
|
|
WM_main_add_notifier(NC_IMAGE, NULL);
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
WM_main_add_notifier(NC_MATERIAL | ND_NODES, node->id);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2012-06-21 13:19:19 +00:00
|
|
|
else if (ntree->type == NTREE_COMPOSIT) {
|
2008-12-24 10:33:10 +00:00
|
|
|
/* make active viewer, currently only 1 supported... */
|
2012-06-21 13:19:19 +00:00
|
|
|
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
|
2008-12-24 10:33:10 +00:00
|
|
|
bNode *tnode;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
|
|
|
|
if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
|
2008-12-24 10:33:10 +00:00
|
|
|
tnode->flag &= ~NODE_DO_OUTPUT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
node->flag |= NODE_DO_OUTPUT;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (was_output == 0) {
|
2016-02-05 01:39:42 +05:00
|
|
|
ED_node_tag_update_nodetree(bmain, ntree, node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-09-27 15:49:59 +02:00
|
|
|
/* addnode() doesn't link this yet... */
|
2018-06-11 15:40:37 +02:00
|
|
|
node->id = (ID *)BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2012-06-21 13:19:19 +00:00
|
|
|
else if (node->type == CMP_NODE_COMPOSITE) {
|
|
|
|
if (was_output == 0) {
|
2011-08-21 13:25:19 +00:00
|
|
|
bNode *tnode;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
|
|
|
|
if (tnode->type == CMP_NODE_COMPOSITE) {
|
2011-08-21 13:25:19 +00:00
|
|
|
tnode->flag &= ~NODE_DO_OUTPUT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-08-21 13:25:19 +00:00
|
|
|
node->flag |= NODE_DO_OUTPUT;
|
2016-02-05 01:39:42 +05:00
|
|
|
ED_node_tag_update_nodetree(bmain, ntree, node);
|
2011-08-21 13:25:19 +00:00
|
|
|
}
|
2010-12-19 15:03:27 +00:00
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
else if (do_update) {
|
2016-02-05 01:39:42 +05:00
|
|
|
ED_node_tag_update_nodetree(bmain, ntree, node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2012-06-21 13:19:19 +00:00
|
|
|
else if (ntree->type == NTREE_TEXTURE) {
|
2009-10-07 22:05:30 +00:00
|
|
|
// XXX
|
|
|
|
#if 0
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->id)
|
2012-06-21 13:19:19 +00:00
|
|
|
; // XXX BIF_preview_changed(-1);
|
2008-12-24 10:33:10 +00:00
|
|
|
// allqueue(REDRAWBUTSSHADING, 1);
|
|
|
|
// allqueue(REDRAWIPO, 0);
|
2009-10-07 22:05:30 +00:00
|
|
|
#endif
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
void ED_node_post_apply_transform(bContext *UNUSED(C), bNodeTree *UNUSED(ntree))
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
|
|
|
/* XXX This does not work due to layout functions relying on node->block,
|
|
|
|
* which only exists during actual drawing. Can we rely on valid totr rects?
|
|
|
|
*/
|
|
|
|
/* make sure nodes have correct bounding boxes after transform */
|
2012-05-22 14:13:33 +00:00
|
|
|
/* node_update_nodetree(C, ntree, 0.0f, 0.0f); */
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ***************** generic operator functions for nodes ***************** */
|
|
|
|
|
2011-09-20 08:48:48 +00:00
|
|
|
#if 0 /* UNUSED */
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool edit_node_poll(bContext *C)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
|
|
|
return ED_operator_node_active(C);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void edit_node_properties(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* XXX could node be a context pointer? */
|
2014-01-16 21:43:22 +11:00
|
|
|
RNA_def_string(ot->srna, "node", NULL, MAX_NAME, "Node", "");
|
2011-09-05 21:01:50 +00:00
|
|
|
RNA_def_int(ot->srna, "socket", 0, 0, MAX_SOCKET, "Socket", "", 0, MAX_SOCKET);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(ot->srna, "in_out", rna_enum_node_socket_in_out_items, SOCK_IN, "Socket Side", "");
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int edit_node_invoke_properties(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-01-11 16:32:12 +00:00
|
|
|
if (!RNA_struct_property_is_set(op->ptr, "node")) {
|
2012-06-21 13:19:19 +00:00
|
|
|
bNode *node = CTX_data_pointer_get_type(C, "node", &RNA_Node).data;
|
2011-09-05 21:01:50 +00:00
|
|
|
if (!node)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
RNA_string_set(op->ptr, "node", node->name);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-01-11 16:32:12 +00:00
|
|
|
if (!RNA_struct_property_is_set(op->ptr, "in_out"))
|
2011-09-05 21:01:50 +00:00
|
|
|
RNA_enum_set(op->ptr, "in_out", SOCK_IN);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-01-11 16:32:12 +00:00
|
|
|
if (!RNA_struct_property_is_set(op->ptr, "socket"))
|
2011-09-05 21:01:50 +00:00
|
|
|
RNA_int_set(op->ptr, "socket", 0);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **rnode, bNodeSocket **rsock, int *rin_out)
|
|
|
|
{
|
|
|
|
bNode *node;
|
2012-06-21 13:19:19 +00:00
|
|
|
bNodeSocket *sock = NULL;
|
2012-01-11 08:51:06 +00:00
|
|
|
char nodename[MAX_NAME];
|
2011-09-05 21:01:50 +00:00
|
|
|
int sockindex;
|
|
|
|
int in_out;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
RNA_string_get(op->ptr, "node", nodename);
|
|
|
|
node = nodeFindNodebyName(ntree, nodename);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
in_out = RNA_enum_get(op->ptr, "in_out");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
sockindex = RNA_int_get(op->ptr, "socket");
|
|
|
|
switch (in_out) {
|
2012-06-21 13:19:19 +00:00
|
|
|
case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break;
|
|
|
|
case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
if (rnode)
|
|
|
|
*rnode = node;
|
|
|
|
if (rsock)
|
|
|
|
*rsock = sock;
|
|
|
|
if (rin_out)
|
|
|
|
*rin_out = in_out;
|
2009-11-20 21:04:41 +00:00
|
|
|
}
|
2011-09-20 08:48:48 +00:00
|
|
|
#endif
|
2009-11-20 21:04:41 +00:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* ************************** Node generic ************** */
|
2009-09-15 11:35:10 +00:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* is rct in visible part of node? */
|
2012-08-05 20:40:26 +00:00
|
|
|
static bNode *visible_node(SpaceNode *snode, const rctf *rct)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
|
|
|
bNode *node;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
for (node = snode->edittree->nodes.last; node; node = node->prev) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (BLI_rctf_isect(&node->totr, rct, NULL)) {
|
2012-08-01 19:11:17 +00:00
|
|
|
break;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
return node;
|
2009-09-15 11:35:10 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* ********************** size widget operator ******************** */
|
2010-04-07 17:06:22 +00:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
typedef struct NodeSizeWidget {
|
|
|
|
float mxstart, mystart;
|
|
|
|
float oldlocx, oldlocy;
|
|
|
|
float oldoffsetx, oldoffsety;
|
|
|
|
float oldwidth, oldheight;
|
|
|
|
int directions;
|
|
|
|
} NodeSizeWidget;
|
2010-04-07 17:06:22 +00:00
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED(event), bNode *node, int dir)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
op->customdata = nsw;
|
2019-03-28 14:56:55 +01:00
|
|
|
nsw->mxstart = snode->cursor[0] * UI_DPI_FAC;
|
|
|
|
nsw->mystart = snode->cursor[1] * UI_DPI_FAC;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* store old */
|
|
|
|
nsw->oldlocx = node->locx;
|
|
|
|
nsw->oldlocy = node->locy;
|
|
|
|
nsw->oldoffsetx = node->offsetx;
|
|
|
|
nsw->oldoffsety = node->offsety;
|
|
|
|
nsw->oldwidth = node->width;
|
|
|
|
nsw->oldheight = node->height;
|
|
|
|
nsw->directions = dir;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-09-06 22:34:29 +00:00
|
|
|
WM_cursor_modal_set(CTX_wm_window(C), node_get_resize_cursor(dir));
|
2010-04-07 17:06:22 +00:00
|
|
|
/* add modal handler */
|
|
|
|
WM_event_add_modal_handler(C, op);
|
2011-01-31 14:42:55 +00:00
|
|
|
}
|
|
|
|
|
2013-10-30 23:08:53 +00:00
|
|
|
static void node_resize_exit(bContext *C, wmOperator *op, bool UNUSED(cancel))
|
2011-01-31 14:42:55 +00:00
|
|
|
{
|
2013-09-06 22:34:29 +00:00
|
|
|
WM_cursor_modal_restore(CTX_wm_window(C));
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-22 14:13:33 +00:00
|
|
|
MEM_freeN(op->customdata);
|
2012-08-01 19:11:17 +00:00
|
|
|
op->customdata = NULL;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2013-03-18 16:34:57 +00:00
|
|
|
bNode *node = nodeGetActive(snode->edittree);
|
2012-08-01 19:11:17 +00:00
|
|
|
NodeSizeWidget *nsw = op->customdata;
|
|
|
|
float mx, my, dx, dy;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-06 16:34:05 +00:00
|
|
|
switch (event->type) {
|
|
|
|
case MOUSEMOVE:
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
dx = (mx - nsw->mxstart) / UI_DPI_FAC;
|
|
|
|
dy = (my - nsw->mystart) / UI_DPI_FAC;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
if (node) {
|
2014-05-09 08:51:37 +02:00
|
|
|
float *pwidth;
|
|
|
|
float oldwidth, widthmin, widthmax;
|
2019-04-02 16:39:48 +02:00
|
|
|
|
|
|
|
pwidth = &node->width;
|
|
|
|
oldwidth = nsw->oldwidth;
|
|
|
|
widthmin = node->typeinfo->minwidth;
|
2016-03-12 19:10:36 +01:00
|
|
|
widthmax = node->typeinfo->maxwidth;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-05-09 08:51:37 +02:00
|
|
|
{
|
2012-08-01 19:11:17 +00:00
|
|
|
if (nsw->directions & NODE_RESIZE_RIGHT) {
|
2014-05-09 08:51:37 +02:00
|
|
|
*pwidth = oldwidth + dx;
|
|
|
|
CLAMP(*pwidth, widthmin, widthmax);
|
2012-05-19 13:28:19 +00:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
if (nsw->directions & NODE_RESIZE_LEFT) {
|
2014-05-09 08:51:37 +02:00
|
|
|
float locmax = nsw->oldlocx + oldwidth;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
node->locx = nsw->oldlocx + dx;
|
|
|
|
CLAMP(node->locx, locmax - widthmax, locmax - widthmin);
|
2014-05-09 08:51:37 +02:00
|
|
|
*pwidth = locmax - node->locx;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* height works the other way round ... */
|
|
|
|
{
|
|
|
|
float heightmin = UI_DPI_FAC * node->typeinfo->minheight;
|
|
|
|
float heightmax = UI_DPI_FAC * node->typeinfo->maxheight;
|
|
|
|
if (nsw->directions & NODE_RESIZE_TOP) {
|
|
|
|
float locmin = nsw->oldlocy - nsw->oldheight;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
node->locy = nsw->oldlocy + dy;
|
|
|
|
CLAMP(node->locy, locmin + heightmin, locmin + heightmax);
|
|
|
|
node->height = node->locy - locmin;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
if (nsw->directions & NODE_RESIZE_BOTTOM) {
|
|
|
|
node->height = nsw->oldheight - dy;
|
|
|
|
CLAMP(node->height, heightmin, heightmax);
|
2012-05-19 13:28:19 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* XXX make callback? */
|
|
|
|
if (node->type == NODE_FRAME) {
|
|
|
|
/* keep the offset symmetric around center point */
|
|
|
|
if (nsw->directions & NODE_RESIZE_LEFT) {
|
|
|
|
node->locx = nsw->oldlocx + 0.5f * dx;
|
|
|
|
node->offsetx = nsw->oldoffsetx + 0.5f * dx;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
if (nsw->directions & NODE_RESIZE_RIGHT) {
|
|
|
|
node->locx = nsw->oldlocx + 0.5f * dx;
|
|
|
|
node->offsetx = nsw->oldoffsetx - 0.5f * dx;
|
2012-05-15 12:40:43 +00:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
if (nsw->directions & NODE_RESIZE_TOP) {
|
|
|
|
node->locy = nsw->oldlocy + 0.5f * dy;
|
|
|
|
node->offsety = nsw->oldoffsety + 0.5f * dy;
|
|
|
|
}
|
|
|
|
if (nsw->directions & NODE_RESIZE_BOTTOM) {
|
|
|
|
node->locy = nsw->oldlocy + 0.5f * dy;
|
|
|
|
node->offsety = nsw->oldoffsety - 0.5f * dy;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2011-02-21 13:47:49 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
|
|
|
break;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
case LEFTMOUSE:
|
|
|
|
case MIDDLEMOUSE:
|
|
|
|
case RIGHTMOUSE:
|
2018-06-13 14:03:46 +02:00
|
|
|
if (event->val == KM_RELEASE) {
|
|
|
|
node_resize_exit(C, op, false);
|
|
|
|
ED_node_post_apply_transform(C, snode->edittree);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-06-13 14:03:46 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
break;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-06 16:34:05 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int node_resize_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2009-02-06 16:34:05 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2013-03-18 16:34:57 +00:00
|
|
|
bNode *node = nodeGetActive(snode->edittree);
|
2012-08-01 19:11:17 +00:00
|
|
|
int dir;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
if (node) {
|
2019-03-20 19:13:56 +01:00
|
|
|
float cursor[2];
|
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* convert mouse coordinates to v2d space */
|
|
|
|
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
|
2019-03-20 19:13:56 +01:00
|
|
|
&cursor[0], &cursor[1]);
|
|
|
|
dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]);
|
2012-08-01 19:11:17 +00:00
|
|
|
if (dir != 0) {
|
|
|
|
node_resize_init(C, op, event, node, dir);
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
2009-02-06 16:34:05 +00:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
|
2009-02-06 16:34:05 +00:00
|
|
|
}
|
|
|
|
|
2013-10-30 23:08:53 +00:00
|
|
|
static void node_resize_cancel(bContext *C, wmOperator *op)
|
2011-06-06 11:04:54 +00:00
|
|
|
{
|
2013-10-30 23:08:53 +00:00
|
|
|
node_resize_exit(C, op, true);
|
2011-06-06 11:04:54 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
void NODE_OT_resize(wmOperatorType *ot)
|
2009-02-06 16:34:05 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-08-01 19:11:17 +00:00
|
|
|
ot->name = "Resize Node";
|
|
|
|
ot->idname = "NODE_OT_resize";
|
|
|
|
ot->description = "Resize a node";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-06 16:34:05 +00:00
|
|
|
/* api callbacks */
|
2012-08-01 19:11:17 +00:00
|
|
|
ot->invoke = node_resize_invoke;
|
|
|
|
ot->modal = node_resize_modal;
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = ED_operator_node_active;
|
2012-08-01 19:11:17 +00:00
|
|
|
ot->cancel = node_resize_cancel;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-06 16:34:05 +00:00
|
|
|
/* flags */
|
2012-08-01 19:11:17 +00:00
|
|
|
ot->flag = OPTYPE_BLOCKING;
|
2009-02-06 16:34:05 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 10:16:41 +00:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* ********************** hidden sockets ******************** */
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
int node_has_hidden_sockets(bNode *node)
|
2009-11-20 06:31:49 +00:00
|
|
|
{
|
2012-08-01 19:11:17 +00:00
|
|
|
bNodeSocket *sock;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
for (sock = node->inputs.first; sock; sock = sock->next) {
|
|
|
|
if (sock->flag & SOCK_HIDDEN) {
|
2012-08-01 19:11:17 +00:00
|
|
|
return 1;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (sock = node->outputs.first; sock; sock = sock->next) {
|
|
|
|
if (sock->flag & SOCK_HIDDEN) {
|
2012-08-01 19:11:17 +00:00
|
|
|
return 1;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
2012-06-01 12:38:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
|
2012-06-01 12:38:03 +00:00
|
|
|
{
|
2012-08-01 19:11:17 +00:00
|
|
|
bNodeSocket *sock;
|
2012-06-01 12:38:03 +00:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
if (set == 0) {
|
2019-03-26 21:16:47 +11:00
|
|
|
for (sock = node->inputs.first; sock; sock = sock->next) {
|
2012-08-01 19:11:17 +00:00
|
|
|
sock->flag &= ~SOCK_HIDDEN;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
for (sock = node->outputs.first; sock; sock = sock->next) {
|
2012-08-01 19:11:17 +00:00
|
|
|
sock->flag &= ~SOCK_HIDDEN;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* hide unused sockets */
|
|
|
|
for (sock = node->inputs.first; sock; sock = sock->next) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (sock->link == NULL) {
|
2012-08-01 19:11:17 +00:00
|
|
|
sock->flag |= SOCK_HIDDEN;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
}
|
|
|
|
for (sock = node->outputs.first; sock; sock = sock->next) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (nodeCountSocketLinks(snode->edittree, sock) == 0) {
|
2012-08-01 19:11:17 +00:00
|
|
|
sock->flag |= SOCK_HIDDEN;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-06-01 12:38:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-07 14:03:34 +00:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* checks snode->mouse position, and returns found node/socket */
|
|
|
|
/* type is SOCK_IN and/or SOCK_OUT */
|
2013-09-05 13:03:03 +00:00
|
|
|
int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **sockp, float cursor[2], int in_out)
|
2009-02-07 14:03:34 +00:00
|
|
|
{
|
2012-08-01 19:11:17 +00:00
|
|
|
bNode *node;
|
|
|
|
bNodeSocket *sock;
|
|
|
|
rctf rect;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
*nodep = NULL;
|
|
|
|
*sockp = NULL;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* check if we click in a socket */
|
|
|
|
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
2017-03-05 20:51:23 +11:00
|
|
|
|
2017-03-08 23:10:31 +11:00
|
|
|
BLI_rctf_init_pt_radius(&rect, cursor, NODE_SOCKSIZE + 4);
|
2017-03-05 20:51:23 +11:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
if (!(node->flag & NODE_HIDDEN)) {
|
|
|
|
/* extra padding inside and out - allow dragging on the text areas too */
|
|
|
|
if (in_out == SOCK_IN) {
|
|
|
|
rect.xmax += NODE_SOCKSIZE;
|
|
|
|
rect.xmin -= NODE_SOCKSIZE * 4;
|
|
|
|
}
|
|
|
|
else if (in_out == SOCK_OUT) {
|
|
|
|
rect.xmax += NODE_SOCKSIZE * 4;
|
|
|
|
rect.xmin -= NODE_SOCKSIZE;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
if (in_out & SOCK_IN) {
|
|
|
|
for (sock = node->inputs.first; sock; sock = sock->next) {
|
|
|
|
if (!nodeSocketIsHidden(sock)) {
|
2012-08-23 18:25:45 +00:00
|
|
|
if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) {
|
2012-08-01 19:11:17 +00:00
|
|
|
if (node == visible_node(snode, &rect)) {
|
|
|
|
*nodep = node;
|
|
|
|
*sockp = sock;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (in_out & SOCK_OUT) {
|
|
|
|
for (sock = node->outputs.first; sock; sock = sock->next) {
|
|
|
|
if (!nodeSocketIsHidden(sock)) {
|
2012-08-23 18:25:45 +00:00
|
|
|
if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) {
|
2012-08-01 19:11:17 +00:00
|
|
|
if (node == visible_node(snode, &rect)) {
|
|
|
|
*nodep = node;
|
|
|
|
*sockp = sock;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
return 0;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* ****************** Duplicate *********************** */
|
|
|
|
|
|
|
|
static void node_duplicate_reparent_recursive(bNode *node)
|
2009-02-07 14:03:34 +00:00
|
|
|
{
|
2012-08-01 19:11:17 +00:00
|
|
|
bNode *parent;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
node->flag |= NODE_TEST;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* find first selected parent */
|
|
|
|
for (parent = node->parent; parent; parent = parent->parent) {
|
|
|
|
if (parent->flag & SELECT) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!(parent->flag & NODE_TEST)) {
|
2012-08-01 19:11:17 +00:00
|
|
|
node_duplicate_reparent_recursive(parent);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* reparent node copy to parent copy */
|
|
|
|
if (parent) {
|
|
|
|
nodeDetachNode(node->new_node);
|
|
|
|
nodeAttachNode(node->new_node, parent->new_node);
|
|
|
|
}
|
2009-02-07 14:03:34 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
static int node_duplicate_exec(bContext *C, wmOperator *op)
|
2012-02-27 17:38:16 +00:00
|
|
|
{
|
2018-06-09 15:16:44 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNodeTree *ntree = snode->edittree;
|
2012-08-01 19:11:17 +00:00
|
|
|
bNode *node, *newnode, *lastnode;
|
|
|
|
bNodeLink *link, *newlink, *lastlink;
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool keep_inputs = RNA_boolean_get(op->ptr, "keep_inputs");
|
2016-02-05 01:39:42 +05:00
|
|
|
bool do_tag_update = false;
|
|
|
|
|
2018-06-09 15:16:44 +02:00
|
|
|
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
lastnode = ntree->nodes.last;
|
2012-06-21 13:19:19 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->flag & SELECT) {
|
2019-02-13 14:58:38 +01:00
|
|
|
newnode = BKE_node_copy_ex(ntree, node, LIB_ID_COPY_DEFAULT);
|
|
|
|
|
|
|
|
/* to ensure redraws or rerenders happen */
|
|
|
|
ED_node_tag_update_id(snode->id);
|
2011-07-22 16:39:06 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* make sure we don't copy new nodes again! */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node == lastnode) {
|
2012-08-01 19:11:17 +00:00
|
|
|
break;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-07-22 16:39:06 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* copy links between selected nodes
|
|
|
|
* NB: this depends on correct node->new_node and sock->new_sock pointers from above copy!
|
|
|
|
*/
|
|
|
|
lastlink = ntree->links.last;
|
|
|
|
for (link = ntree->links.first; link; link = link->next) {
|
|
|
|
/* This creates new links between copied nodes.
|
|
|
|
* If keep_inputs is set, also copies input links from unselected (when fromnode==NULL)!
|
|
|
|
*/
|
|
|
|
if (link->tonode && (link->tonode->flag & NODE_SELECT) &&
|
|
|
|
(keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT))))
|
|
|
|
{
|
|
|
|
newlink = MEM_callocN(sizeof(bNodeLink), "bNodeLink");
|
|
|
|
newlink->flag = link->flag;
|
|
|
|
newlink->tonode = link->tonode->new_node;
|
|
|
|
newlink->tosock = link->tosock->new_sock;
|
|
|
|
if (link->fromnode && (link->fromnode->flag & NODE_SELECT)) {
|
|
|
|
newlink->fromnode = link->fromnode->new_node;
|
|
|
|
newlink->fromsock = link->fromsock->new_sock;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* input node not copied, this keeps the original input linked */
|
|
|
|
newlink->fromnode = link->fromnode;
|
|
|
|
newlink->fromsock = link->fromsock;
|
2012-03-08 12:04:06 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
BLI_addtail(&ntree->links, newlink);
|
2012-03-08 12:04:06 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* make sure we don't copy new links again! */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (link == lastlink) {
|
2012-08-01 19:11:17 +00:00
|
|
|
break;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-03-08 12:04:06 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* clear flags for recursive depth-first iteration */
|
2019-03-26 21:16:47 +11:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2012-08-01 19:11:17 +00:00
|
|
|
node->flag &= ~NODE_TEST;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
/* reparent copied nodes */
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) {
|
2012-08-01 19:11:17 +00:00
|
|
|
node_duplicate_reparent_recursive(node);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* only has to check old nodes */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node == lastnode) {
|
2012-08-01 19:11:17 +00:00
|
|
|
break;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* deselect old nodes, select the copies instead */
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->flag & SELECT) {
|
2012-08-01 19:11:17 +00:00
|
|
|
/* has been set during copy above */
|
|
|
|
newnode = node->new_node;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
nodeSetSelected(node, false);
|
2012-08-01 19:11:17 +00:00
|
|
|
node->flag &= ~NODE_ACTIVE;
|
2014-04-01 11:34:00 +11:00
|
|
|
nodeSetSelected(newnode, true);
|
2016-02-05 01:39:42 +05:00
|
|
|
|
2018-06-09 15:16:44 +02:00
|
|
|
do_tag_update |= (do_tag_update || node_connected_to_output(bmain, ntree, newnode));
|
2011-07-22 15:28:50 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* make sure we don't copy new nodes again! */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node == lastnode) {
|
2012-08-01 19:11:17 +00:00
|
|
|
break;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-07-22 15:28:50 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
snode_notify(C, snode);
|
2016-02-05 01:39:42 +05:00
|
|
|
if (do_tag_update) {
|
|
|
|
snode_dag_update(C, snode);
|
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2011-07-22 15:28:50 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
void NODE_OT_duplicate(wmOperatorType *ot)
|
2011-07-22 15:28:50 +00:00
|
|
|
{
|
2012-08-01 19:11:17 +00:00
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Duplicate Nodes";
|
|
|
|
ot->description = "Duplicate selected nodes";
|
|
|
|
ot->idname = "NODE_OT_duplicate";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = node_duplicate_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = ED_operator_node_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes");
|
2011-07-22 15:28:50 +00:00
|
|
|
}
|
|
|
|
|
2014-01-22 02:48:11 +11:00
|
|
|
bool ED_node_select_check(ListBase *lb)
|
2012-08-01 13:28:19 +00:00
|
|
|
{
|
2019-03-05 18:30:06 +11:00
|
|
|
for (bNode *node = lb->first; node; node = node->next) {
|
2012-08-01 13:28:19 +00:00
|
|
|
if (node->flag & NODE_SELECT) {
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
2012-08-01 13:28:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2012-08-01 13:28:19 +00:00
|
|
|
}
|
2011-07-22 15:28:50 +00:00
|
|
|
|
2019-03-05 18:30:06 +11:00
|
|
|
void ED_node_select_all(ListBase *lb, int action)
|
|
|
|
{
|
|
|
|
if (action == SEL_TOGGLE) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ED_node_select_check(lb)) {
|
2019-03-05 18:30:06 +11:00
|
|
|
action = SEL_DESELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2019-03-05 18:30:06 +11:00
|
|
|
action = SEL_SELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-03-05 18:30:06 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
for (bNode *node = lb->first; node; node = node->next) {
|
|
|
|
switch (action) {
|
|
|
|
case SEL_SELECT:
|
|
|
|
nodeSetSelected(node, true);
|
|
|
|
break;
|
|
|
|
case SEL_DESELECT:
|
|
|
|
nodeSetSelected(node, false);
|
|
|
|
break;
|
|
|
|
case SEL_INVERT:
|
|
|
|
nodeSetSelected(node, !(node->flag & SELECT));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-07 14:03:34 +00:00
|
|
|
/* ******************************** */
|
2009-11-20 06:31:49 +00:00
|
|
|
// XXX some code needing updating to operators...
|
2009-02-07 14:03:34 +00:00
|
|
|
|
2011-01-17 18:38:44 +00:00
|
|
|
|
2010-04-06 17:47:21 +00:00
|
|
|
/* goes over all scenes, reads render layers */
|
2017-11-22 10:52:39 -02:00
|
|
|
static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
Scene *curscene = CTX_data_scene(C), *scene;
|
2008-12-24 10:33:10 +00:00
|
|
|
bNode *node;
|
|
|
|
|
2014-11-18 15:51:31 +01:00
|
|
|
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
|
2010-07-04 19:58:52 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* first tag scenes unread */
|
2019-03-26 21:16:47 +11:00
|
|
|
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
scene->id.tag |= LIB_TAG_DOIT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->type == CMP_NODE_R_LAYERS) {
|
|
|
|
ID *id = node->id;
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
if (id->tag & LIB_TAG_DOIT) {
|
2009-02-07 14:03:34 +00:00
|
|
|
RE_ReadRenderResult(curscene, (Scene *)id);
|
2008-12-24 10:33:10 +00:00
|
|
|
ntreeCompositTagRender((Scene *)id);
|
Split id->flag in two, persistent flags and runtime tags.
This is purely internal sanitizing/cleanup, no change in behavior is expected at all.
This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.
id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.
New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.
Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.
Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1683
2015-12-27 11:53:50 +01:00
|
|
|
id->tag &= ~LIB_TAG_DOIT;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-04-06 17:47:21 +00:00
|
|
|
snode_notify(C, snode);
|
2011-05-02 12:31:09 +00:00
|
|
|
snode_dag_update(C, snode);
|
|
|
|
|
2010-04-06 17:47:21 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
void NODE_OT_read_viewlayers(wmOperatorType *ot)
|
2010-04-06 17:47:21 +00:00
|
|
|
{
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
ot->name = "Read View Layers";
|
|
|
|
ot->idname = "NODE_OT_read_viewlayers";
|
2012-05-05 17:10:51 +00:00
|
|
|
ot->description = "Read all render layers of all used scenes";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
ot->exec = node_read_viewlayers_exec;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = composite_node_active;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-04-06 17:47:21 +00:00
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2011-02-07 16:41:57 +00:00
|
|
|
int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
Scene *sce = CTX_data_scene(C);
|
2011-02-07 16:41:57 +00:00
|
|
|
bNode *node;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
for (node = sce->nodetree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->id == (ID *)sce && node->need_exec) {
|
2011-02-07 16:41:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node) {
|
2017-11-22 10:52:39 -02:00
|
|
|
ViewLayer *view_layer = BLI_findlink(&sce->view_layers, node->custom1);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
if (view_layer) {
|
2011-02-07 16:41:57 +00:00
|
|
|
PointerRNA op_ptr;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-02-07 16:41:57 +00:00
|
|
|
WM_operator_properties_create(&op_ptr, "RENDER_OT_render");
|
2017-11-22 10:52:39 -02:00
|
|
|
RNA_string_set(&op_ptr, "layer", view_layer->name);
|
2012-06-21 13:19:19 +00:00
|
|
|
RNA_string_set(&op_ptr, "scene", sce->id.name + 2);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-02-07 18:09:27 +00:00
|
|
|
/* to keep keypositions */
|
|
|
|
sce->r.scemode |= R_NO_FRAME_UPDATE;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-02-07 16:41:57 +00:00
|
|
|
WM_operator_name_call(C, "RENDER_OT_render", WM_OP_INVOKE_DEFAULT, &op_ptr);
|
|
|
|
|
|
|
|
WM_operator_properties_free(&op_ptr);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-02-07 16:41:57 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_render_changed(wmOperatorType *ot)
|
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Render Changed Layer";
|
|
|
|
ot->idname = "NODE_OT_render_changed";
|
2012-05-05 17:10:51 +00:00
|
|
|
ot->description = "Render current scene, when input node's layer has been changed";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = node_render_changed_exec;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->poll = composite_node_active;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-02-07 16:41:57 +00:00
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = 0;
|
2011-02-07 16:41:57 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2009-11-20 06:31:49 +00:00
|
|
|
/* ****************** Hide operator *********************** */
|
|
|
|
|
2010-06-07 20:03:40 +00:00
|
|
|
static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
|
2009-11-20 06:31:49 +00:00
|
|
|
{
|
|
|
|
bNode *node;
|
2012-06-21 13:19:19 +00:00
|
|
|
int tot_eq = 0, tot_neq = 0;
|
2010-06-07 20:03:40 +00:00
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
/* Toggles the flag on all selected nodes.
|
|
|
|
* If the flag is set on all nodes it is unset.
|
|
|
|
* If the flag is not set on all nodes, it is set.
|
|
|
|
*/
|
2012-06-21 13:19:19 +00:00
|
|
|
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->flag & SELECT) {
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) {
|
2010-06-09 14:17:22 +00:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) {
|
2011-12-18 12:51:50 +00:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (node->flag & toggle_flag) {
|
2010-06-07 20:03:40 +00:00
|
|
|
tot_eq++;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2010-06-07 20:03:40 +00:00
|
|
|
tot_neq++;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-11-20 06:31:49 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-21 13:19:19 +00:00
|
|
|
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->flag & SELECT) {
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) {
|
2010-06-09 14:17:22 +00:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) {
|
2011-12-18 12:51:50 +00:00
|
|
|
continue;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((tot_eq && tot_neq) || tot_eq == 0) {
|
2010-06-07 20:03:40 +00:00
|
|
|
node->flag |= toggle_flag;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2010-06-07 20:03:40 +00:00
|
|
|
node->flag &= ~toggle_flag;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-11-20 06:31:49 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-07 20:03:40 +00:00
|
|
|
}
|
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-06-07 20:03:40 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-06-07 20:03:40 +00:00
|
|
|
/* sanity checking (poll callback checks this already) */
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((snode == NULL) || (snode->edittree == NULL)) {
|
2010-06-07 20:03:40 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-06-07 20:03:40 +00:00
|
|
|
node_flag_toggle_exec(snode, NODE_HIDDEN);
|
2012-07-16 16:16:05 +00:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
|
|
|
|
2009-11-20 06:31:49 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2010-06-07 20:03:40 +00:00
|
|
|
void NODE_OT_hide_toggle(wmOperatorType *ot)
|
2009-11-20 06:31:49 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Hide";
|
|
|
|
ot->description = "Toggle hiding of selected nodes";
|
|
|
|
ot->idname = "NODE_OT_hide_toggle";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-11-20 06:31:49 +00:00
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = node_hide_toggle_exec;
|
|
|
|
ot->poll = ED_operator_node_active;
|
2010-06-07 20:03:40 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2010-06-07 20:03:40 +00:00
|
|
|
}
|
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
static int node_preview_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-06-07 20:03:40 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2010-06-07 20:03:40 +00:00
|
|
|
|
|
|
|
/* sanity checking (poll callback checks this already) */
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((snode == NULL) || (snode->edittree == NULL)) {
|
2010-06-07 20:03:40 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2010-06-07 20:03:40 +00:00
|
|
|
|
2014-11-18 15:51:31 +01:00
|
|
|
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
2010-07-04 19:58:52 +00:00
|
|
|
|
2010-06-07 20:03:40 +00:00
|
|
|
node_flag_toggle_exec(snode, NODE_PREVIEW);
|
|
|
|
|
|
|
|
snode_notify(C, snode);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_preview_toggle(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Toggle Node Preview";
|
|
|
|
ot->description = "Toggle preview display for selected nodes";
|
|
|
|
ot->idname = "NODE_OT_preview_toggle";
|
2010-06-07 20:03:40 +00:00
|
|
|
|
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = node_preview_toggle_exec;
|
|
|
|
ot->poll = ED_operator_node_active;
|
2011-12-18 12:51:50 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2011-12-18 12:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int node_options_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2011-12-18 12:51:50 +00:00
|
|
|
|
|
|
|
/* sanity checking (poll callback checks this already) */
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((snode == NULL) || (snode->edittree == NULL)) {
|
2011-12-18 12:51:50 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-12-18 12:51:50 +00:00
|
|
|
|
|
|
|
node_flag_toggle_exec(snode, NODE_OPTIONS);
|
|
|
|
|
2012-07-16 16:16:05 +00:00
|
|
|
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
2011-12-18 12:51:50 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_options_toggle(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Toggle Node Options";
|
|
|
|
ot->description = "Toggle option buttons display for selected nodes";
|
|
|
|
ot->idname = "NODE_OT_options_toggle";
|
2011-12-18 12:51:50 +00:00
|
|
|
|
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = node_options_toggle_exec;
|
|
|
|
ot->poll = ED_operator_node_active;
|
2010-06-07 20:03:40 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2010-06-07 20:03:40 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-06-07 20:03:40 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2010-06-07 20:03:40 +00:00
|
|
|
bNode *node;
|
2011-12-18 12:51:50 +00:00
|
|
|
int hidden;
|
2010-06-07 20:03:40 +00:00
|
|
|
|
|
|
|
/* sanity checking (poll callback checks this already) */
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((snode == NULL) || (snode->edittree == NULL)) {
|
2010-06-07 20:03:40 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2010-06-07 20:03:40 +00:00
|
|
|
|
2014-11-18 15:51:31 +01:00
|
|
|
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
2010-07-04 19:58:52 +00:00
|
|
|
|
2011-12-18 12:51:50 +00:00
|
|
|
/* Toggle for all selected nodes */
|
|
|
|
hidden = 0;
|
2012-06-21 13:19:19 +00:00
|
|
|
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->flag & SELECT) {
|
2012-04-16 10:50:57 +00:00
|
|
|
if (node_has_hidden_sockets(node)) {
|
2012-06-21 13:19:19 +00:00
|
|
|
hidden = 1;
|
2010-06-07 20:03:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->flag & SELECT) {
|
2012-04-16 10:50:57 +00:00
|
|
|
node_set_hidden_sockets(snode, node, !hidden);
|
2010-06-07 20:03:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
|
2010-06-07 20:03:40 +00:00
|
|
|
|
2012-07-16 16:16:05 +00:00
|
|
|
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
2010-06-07 20:03:40 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_hide_socket_toggle(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Toggle Hidden Node Sockets";
|
|
|
|
ot->description = "Toggle unused node socket display";
|
|
|
|
ot->idname = "NODE_OT_hide_socket_toggle";
|
2010-06-07 20:03:40 +00:00
|
|
|
|
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = node_socket_toggle_exec;
|
|
|
|
ot->poll = ED_operator_node_active;
|
2010-06-07 20:03:40 +00:00
|
|
|
|
2009-11-20 06:31:49 +00:00
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-11-20 06:31:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** Mute operator *********************** */
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int node_mute_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-11-20 06:31:49 +00:00
|
|
|
{
|
2018-06-09 15:16:44 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2009-11-20 06:31:49 +00:00
|
|
|
bNode *node;
|
2016-02-05 01:39:42 +05:00
|
|
|
bool do_tag_update = false;
|
2009-11-20 06:31:49 +00:00
|
|
|
|
2018-06-09 15:16:44 +02:00
|
|
|
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
|
2010-07-04 19:58:52 +00:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
2011-11-20 16:38:23 +00:00
|
|
|
/* Only allow muting of nodes having a mute func! */
|
2012-10-25 16:49:06 +00:00
|
|
|
if ((node->flag & SELECT) && node->typeinfo->update_internal_links) {
|
2012-02-27 17:38:16 +00:00
|
|
|
node->flag ^= NODE_MUTED;
|
|
|
|
snode_update(snode, node);
|
2018-06-09 15:16:44 +02:00
|
|
|
do_tag_update |= (do_tag_update || node_connected_to_output(bmain, snode->edittree, node));
|
2009-11-20 06:31:49 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-01-21 01:42:28 +00:00
|
|
|
snode_notify(C, snode);
|
2016-02-05 01:39:42 +05:00
|
|
|
if (do_tag_update) {
|
|
|
|
snode_dag_update(C, snode);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-11-20 06:31:49 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2010-06-07 20:03:40 +00:00
|
|
|
void NODE_OT_mute_toggle(wmOperatorType *ot)
|
2009-11-20 06:31:49 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Toggle Node Mute";
|
|
|
|
ot->description = "Toggle muting of the nodes";
|
|
|
|
ot->idname = "NODE_OT_mute_toggle";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-11-20 06:31:49 +00:00
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = node_mute_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = ED_operator_node_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-11-20 06:31:49 +00:00
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-11-20 06:31:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** Delete operator ******************* */
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int node_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-11-20 06:31:49 +00:00
|
|
|
{
|
2018-06-09 15:16:44 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2009-11-20 06:31:49 +00:00
|
|
|
bNode *node, *next;
|
2016-02-05 01:39:42 +05:00
|
|
|
bool do_tag_update = false;
|
|
|
|
|
2018-06-09 15:16:44 +02:00
|
|
|
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
|
2010-07-04 19:58:52 +00:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
for (node = snode->edittree->nodes.first; node; node = next) {
|
|
|
|
next = node->next;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->flag & SELECT) {
|
2018-06-09 15:16:44 +02:00
|
|
|
do_tag_update |= (do_tag_update || node_connected_to_output(bmain, snode->edittree, node));
|
2019-03-16 18:54:00 +01:00
|
|
|
nodeRemoveNode(bmain, snode->edittree, node, true);
|
2012-08-01 19:11:17 +00:00
|
|
|
}
|
2010-05-12 04:25:33 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2010-05-12 04:25:33 +00:00
|
|
|
snode_notify(C, snode);
|
2016-02-05 01:39:42 +05:00
|
|
|
if (do_tag_update) {
|
|
|
|
snode_dag_update(C, snode);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-05-12 04:25:33 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
void NODE_OT_delete(wmOperatorType *ot)
|
2010-05-12 04:25:33 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-08-01 19:11:17 +00:00
|
|
|
ot->name = "Delete";
|
|
|
|
ot->description = "Delete selected nodes";
|
|
|
|
ot->idname = "NODE_OT_delete";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = node_delete_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = ED_operator_node_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-05-12 04:25:33 +00:00
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2010-05-12 04:25:33 +00:00
|
|
|
}
|
2009-01-12 00:14:37 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* ****************** Switch View ******************* */
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool node_switch_view_poll(bContext *C)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (snode && snode->edittree) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return true;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int node_switch_view_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNode *node, *next;
|
|
|
|
|
|
|
|
for (node = snode->edittree->nodes.first; node; node = next) {
|
|
|
|
next = node->next;
|
|
|
|
if (node->flag & SELECT) {
|
|
|
|
/* call the update function from the Switch View node */
|
|
|
|
node->update = NODE_UPDATE_OPERATOR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
|
|
|
|
|
|
|
|
snode_notify(C, snode);
|
|
|
|
snode_dag_update(C, snode);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_switch_view_update(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Update Views";
|
|
|
|
ot->description = "Update views of selected node";
|
|
|
|
ot->idname = "NODE_OT_switch_view_update";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = node_switch_view_exec;
|
|
|
|
ot->poll = node_switch_view_poll;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
/* ****************** Delete with reconnect ******************* */
|
|
|
|
static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op))
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
2018-11-23 17:02:55 +01:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-08-01 19:11:17 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNode *node, *next;
|
2011-07-22 15:28:50 +00:00
|
|
|
|
2014-11-18 15:51:31 +01:00
|
|
|
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
2012-08-01 19:11:17 +00:00
|
|
|
|
|
|
|
for (node = snode->edittree->nodes.first; node; node = next) {
|
|
|
|
next = node->next;
|
|
|
|
if (node->flag & SELECT) {
|
|
|
|
nodeInternalRelink(snode->edittree, node);
|
2019-03-16 18:54:00 +01:00
|
|
|
nodeRemoveNode(bmain, snode->edittree, node, true);
|
2012-08-01 19:11:17 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
|
2012-08-01 19:11:17 +00:00
|
|
|
|
|
|
|
snode_notify(C, snode);
|
|
|
|
snode_dag_update(C, snode);
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
void NODE_OT_delete_reconnect(wmOperatorType *ot)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2013-01-27 07:23:58 +00:00
|
|
|
ot->name = "Delete with Reconnect";
|
2012-08-01 19:11:17 +00:00
|
|
|
ot->description = "Delete nodes; will reconnect nodes as if deletion was muted";
|
|
|
|
ot->idname = "NODE_OT_delete_reconnect";
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* api callbacks */
|
2012-08-01 19:11:17 +00:00
|
|
|
ot->exec = node_delete_reconnect_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = ED_operator_node_editable;
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
/* ****************** File Output Add Socket ******************* */
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
static int node_output_file_add_socket_exec(bContext *C, wmOperator *op)
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2013-04-24 16:59:56 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get(C, "node");
|
|
|
|
bNodeTree *ntree = NULL;
|
|
|
|
bNode *node = NULL;
|
2012-03-01 07:56:15 +00:00
|
|
|
char file_path[MAX_NAME];
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2013-04-24 16:59:56 +00:00
|
|
|
if (ptr.data) {
|
|
|
|
node = ptr.data;
|
|
|
|
ntree = ptr.id.data;
|
|
|
|
}
|
|
|
|
else if (snode && snode->edittree) {
|
|
|
|
ntree = snode->edittree;
|
|
|
|
node = nodeGetActive(snode->edittree);
|
|
|
|
}
|
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!node || node->type != CMP_NODE_OUTPUT_FILE) {
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
RNA_string_get(op->ptr, "file_path", file_path);
|
|
|
|
ntreeCompositOutputFileAddSocket(ntree, node, file_path, &scene->r.im_format);
|
2012-08-01 19:11:17 +00:00
|
|
|
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
snode_notify(C, snode);
|
2012-08-01 19:11:17 +00:00
|
|
|
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
void NODE_OT_output_file_add_socket(wmOperatorType *ot)
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add File Node Socket";
|
|
|
|
ot->description = "Add a new input to a file output node";
|
|
|
|
ot->idname = "NODE_OT_output_file_add_socket";
|
2012-08-01 19:11:17 +00:00
|
|
|
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = node_output_file_add_socket_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = composite_node_editable;
|
2012-08-01 19:11:17 +00:00
|
|
|
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-08-01 19:11:17 +00:00
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
RNA_def_string(ot->srna, "file_path", "Image", MAX_NAME, "File Path", "Sub-path of the output file");
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** Multi File Output Remove Socket ******************* */
|
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *UNUSED(op))
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2012-05-02 07:18:51 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get(C, "node");
|
2013-04-24 16:59:56 +00:00
|
|
|
bNodeTree *ntree = NULL;
|
|
|
|
bNode *node = NULL;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-04-24 16:59:56 +00:00
|
|
|
if (ptr.data) {
|
|
|
|
node = ptr.data;
|
|
|
|
ntree = ptr.id.data;
|
|
|
|
}
|
|
|
|
else if (snode && snode->edittree) {
|
|
|
|
ntree = snode->edittree;
|
|
|
|
node = nodeGetActive(snode->edittree);
|
|
|
|
}
|
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!node || node->type != CMP_NODE_OUTPUT_FILE) {
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node)) {
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
snode_notify(C, snode);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot)
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Remove File Node Socket";
|
|
|
|
ot->description = "Remove active input from a file output node";
|
|
|
|
ot->idname = "NODE_OT_output_file_remove_active_socket";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
/* callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = node_output_file_remove_active_socket_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = composite_node_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
}
|
2012-05-02 07:18:51 +00:00
|
|
|
|
|
|
|
/* ****************** Multi File Output Move Socket ******************* */
|
|
|
|
|
|
|
|
static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-06-21 13:19:19 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2012-05-02 07:18:51 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get(C, "node");
|
2013-04-24 16:59:56 +00:00
|
|
|
bNode *node = NULL;
|
2012-05-02 07:18:51 +00:00
|
|
|
NodeImageMultiFile *nimf;
|
|
|
|
bNodeSocket *sock;
|
|
|
|
int direction;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ptr.data) {
|
2013-04-24 16:59:56 +00:00
|
|
|
node = ptr.data;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else if (snode && snode->edittree) {
|
2013-04-24 16:59:56 +00:00
|
|
|
node = nodeGetActive(snode->edittree);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-04-24 16:59:56 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!node || node->type != CMP_NODE_OUTPUT_FILE) {
|
2012-05-02 07:18:51 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-04-24 16:59:56 +00:00
|
|
|
|
2012-05-02 07:18:51 +00:00
|
|
|
nimf = node->storage;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-02 07:18:51 +00:00
|
|
|
sock = BLI_findlink(&node->inputs, nimf->active_input);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!sock) {
|
2012-05-02 07:18:51 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-02 07:18:51 +00:00
|
|
|
direction = RNA_enum_get(op->ptr, "direction");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
if (direction == 1) {
|
2012-05-02 07:18:51 +00:00
|
|
|
bNodeSocket *before = sock->prev;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!before) {
|
2012-05-02 07:18:51 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-02 07:18:51 +00:00
|
|
|
BLI_remlink(&node->inputs, sock);
|
|
|
|
BLI_insertlinkbefore(&node->inputs, before, sock);
|
2012-08-22 16:44:32 +00:00
|
|
|
nimf->active_input--;
|
2012-05-02 07:18:51 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
bNodeSocket *after = sock->next;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!after) {
|
2012-05-02 07:18:51 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-02 07:18:51 +00:00
|
|
|
BLI_remlink(&node->inputs, sock);
|
|
|
|
BLI_insertlinkafter(&node->inputs, after, sock);
|
2012-08-22 16:44:32 +00:00
|
|
|
nimf->active_input++;
|
2012-05-02 07:18:51 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-02 07:18:51 +00:00
|
|
|
snode_notify(C, snode);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-02 07:18:51 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_output_file_move_active_socket(wmOperatorType *ot)
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem direction_items[] = {
|
2012-05-02 07:18:51 +00:00
|
|
|
{1, "UP", 0, "Up", ""},
|
2012-05-03 06:57:30 +00:00
|
|
|
{2, "DOWN", 0, "Down", ""},
|
2012-06-21 13:19:19 +00:00
|
|
|
{ 0, NULL, 0, NULL, NULL }
|
|
|
|
};
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-02 07:18:51 +00:00
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Move File Node Socket";
|
|
|
|
ot->description = "Move the active input of a file output node up or down the list";
|
|
|
|
ot->idname = "NODE_OT_output_file_move_active_socket";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-02 07:18:51 +00:00
|
|
|
/* callbacks */
|
|
|
|
ot->exec = node_output_file_move_active_socket_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = composite_node_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-02 07:18:51 +00:00
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-02 07:18:51 +00:00
|
|
|
RNA_def_enum(ot->srna, "direction", direction_items, 2, "Direction", "");
|
|
|
|
}
|
2012-05-22 14:13:33 +00:00
|
|
|
|
|
|
|
/* ****************** Copy Node Color ******************* */
|
|
|
|
|
|
|
|
static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNodeTree *ntree = snode->edittree;
|
|
|
|
bNode *node, *tnode;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!ntree) {
|
2012-05-22 14:13:33 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-22 14:13:33 +00:00
|
|
|
node = nodeGetActive(ntree);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!node) {
|
2012-05-22 14:13:33 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-06-21 13:19:19 +00:00
|
|
|
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
|
2012-05-22 14:13:33 +00:00
|
|
|
if (tnode->flag & NODE_SELECT && tnode != node) {
|
|
|
|
if (node->flag & NODE_CUSTOM_COLOR) {
|
|
|
|
tnode->flag |= NODE_CUSTOM_COLOR;
|
|
|
|
copy_v3_v3(tnode->color, node->color);
|
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
else {
|
2012-05-22 14:13:33 +00:00
|
|
|
tnode->flag &= ~NODE_CUSTOM_COLOR;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ED_node_sort(ntree);
|
2012-06-21 13:19:19 +00:00
|
|
|
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
2012-05-22 14:13:33 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_node_copy_color(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Copy Color";
|
|
|
|
ot->description = "Copy color to all selected nodes";
|
|
|
|
ot->idname = "NODE_OT_node_copy_color";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = node_copy_color_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = ED_operator_node_editable;
|
2012-05-22 14:13:33 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-06-21 13:19:19 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-05-22 14:13:33 +00:00
|
|
|
}
|
2012-08-02 09:52:37 +00:00
|
|
|
|
|
|
|
/* ****************** Copy to clipboard ******************* */
|
|
|
|
|
|
|
|
static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNodeTree *ntree = snode->edittree;
|
2012-10-12 14:35:10 +00:00
|
|
|
bNode *node;
|
2012-08-02 09:52:37 +00:00
|
|
|
bNodeLink *link, *newlink;
|
|
|
|
|
2014-11-18 15:51:31 +01:00
|
|
|
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
2012-08-02 09:52:37 +00:00
|
|
|
|
|
|
|
/* clear current clipboard */
|
2012-08-06 08:25:24 +00:00
|
|
|
BKE_node_clipboard_clear();
|
2012-08-06 08:41:45 +00:00
|
|
|
BKE_node_clipboard_init(ntree);
|
2012-08-02 09:52:37 +00:00
|
|
|
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->flag & SELECT) {
|
2019-02-13 14:58:38 +01:00
|
|
|
/* No ID refcounting, this node is virtual, detached from any actual Blender data currently. */
|
2019-02-15 14:29:10 +01:00
|
|
|
bNode *new_node = BKE_node_copy_ex(NULL, node, LIB_ID_CREATE_NO_USER_REFCOUNT);
|
2012-08-06 08:25:24 +00:00
|
|
|
BKE_node_clipboard_add_node(new_node);
|
2012-08-02 09:52:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-03 10:18:52 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->flag & SELECT) {
|
|
|
|
bNode *new_node = node->new_node;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-03 10:51:29 +00:00
|
|
|
/* ensure valid pointers */
|
2012-08-03 10:18:52 +00:00
|
|
|
if (new_node->parent) {
|
2019-01-15 23:24:20 +11:00
|
|
|
/* parent pointer must be redirected to new node or detached if parent is
|
|
|
|
* not copied */
|
2012-08-03 10:18:52 +00:00
|
|
|
if (new_node->parent->flag & NODE_SELECT) {
|
|
|
|
new_node->parent = new_node->parent->new_node;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nodeDetachNode(new_node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
/* copy links between selected nodes
|
|
|
|
* NB: this depends on correct node->new_node and sock->new_sock pointers from above copy!
|
|
|
|
*/
|
|
|
|
for (link = ntree->links.first; link; link = link->next) {
|
|
|
|
/* This creates new links between copied nodes. */
|
|
|
|
if (link->tonode && (link->tonode->flag & NODE_SELECT) &&
|
|
|
|
link->fromnode && (link->fromnode->flag & NODE_SELECT))
|
|
|
|
{
|
|
|
|
newlink = MEM_callocN(sizeof(bNodeLink), "bNodeLink");
|
|
|
|
newlink->flag = link->flag;
|
|
|
|
newlink->tonode = link->tonode->new_node;
|
|
|
|
newlink->tosock = link->tosock->new_sock;
|
|
|
|
newlink->fromnode = link->fromnode->new_node;
|
|
|
|
newlink->fromsock = link->fromsock->new_sock;
|
|
|
|
|
2012-08-06 08:25:24 +00:00
|
|
|
BKE_node_clipboard_add_link(newlink);
|
2012-08-02 09:52:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_clipboard_copy(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2013-01-27 07:23:58 +00:00
|
|
|
ot->name = "Copy to Clipboard";
|
2012-08-02 09:52:37 +00:00
|
|
|
ot->description = "Copies selected nodes to the clipboard";
|
|
|
|
ot->idname = "NODE_OT_clipboard_copy";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = node_clipboard_copy_exec;
|
|
|
|
ot->poll = ED_operator_node_active;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** Paste from clipboard ******************* */
|
|
|
|
|
2012-08-06 08:41:45 +00:00
|
|
|
static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
|
2012-08-02 09:52:37 +00:00
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNodeTree *ntree = snode->edittree;
|
2012-08-20 13:51:25 +00:00
|
|
|
const ListBase *clipboard_nodes_lb;
|
|
|
|
const ListBase *clipboard_links_lb;
|
2012-08-02 09:52:37 +00:00
|
|
|
bNode *node;
|
|
|
|
bNodeLink *link;
|
|
|
|
int num_nodes;
|
2012-08-20 13:59:19 +00:00
|
|
|
float center[2];
|
2014-01-28 03:52:21 +11:00
|
|
|
bool is_clipboard_valid, all_nodes_valid;
|
2012-08-02 09:52:37 +00:00
|
|
|
|
2012-08-20 13:59:19 +00:00
|
|
|
/* validate pointers in the clipboard */
|
|
|
|
is_clipboard_valid = BKE_node_clipboard_validate();
|
|
|
|
clipboard_nodes_lb = BKE_node_clipboard_get_nodes();
|
|
|
|
clipboard_links_lb = BKE_node_clipboard_get_links();
|
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
if (BLI_listbase_is_empty(clipboard_nodes_lb)) {
|
2012-08-20 13:59:19 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Clipboard is empty");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2012-08-06 08:41:45 +00:00
|
|
|
if (BKE_node_clipboard_get_type() != ntree->type) {
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Clipboard nodes are an incompatible type");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2012-08-20 13:59:19 +00:00
|
|
|
/* only warn */
|
2014-04-01 11:34:00 +11:00
|
|
|
if (is_clipboard_valid == false) {
|
2012-08-20 13:59:19 +00:00
|
|
|
BKE_report(op->reports, RPT_WARNING, "Some nodes references could not be restored, will be left empty");
|
|
|
|
}
|
|
|
|
|
2013-04-03 09:10:29 +00:00
|
|
|
/* make sure all clipboard nodes would be valid in the target tree */
|
2014-04-01 11:34:00 +11:00
|
|
|
all_nodes_valid = true;
|
2013-04-03 09:10:29 +00:00
|
|
|
for (node = clipboard_nodes_lb->first; node; node = node->next) {
|
2017-06-18 05:13:32 +02:00
|
|
|
if (!node->typeinfo->poll_instance || !node->typeinfo->poll_instance(node, ntree)) {
|
2014-04-01 11:34:00 +11:00
|
|
|
all_nodes_valid = false;
|
2013-04-04 02:05:11 +00:00
|
|
|
BKE_reportf(op->reports, RPT_ERROR, "Cannot add node %s into node tree %s", node->name, ntree->id.name + 2);
|
2013-04-03 09:10:29 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!all_nodes_valid) {
|
2013-04-03 09:10:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-04-03 09:10:29 +00:00
|
|
|
|
2014-11-18 15:51:31 +01:00
|
|
|
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
2012-08-02 09:52:37 +00:00
|
|
|
|
|
|
|
/* deselect old nodes */
|
|
|
|
node_deselect_all(snode);
|
|
|
|
|
|
|
|
/* calculate "barycenter" for placing on mouse cursor */
|
2012-08-20 13:59:19 +00:00
|
|
|
zero_v2(center);
|
|
|
|
for (node = clipboard_nodes_lb->first, num_nodes = 0; node; node = node->next, num_nodes++) {
|
2012-09-15 11:48:20 +00:00
|
|
|
center[0] += BLI_rctf_cent_x(&node->totr);
|
|
|
|
center[1] += BLI_rctf_cent_y(&node->totr);
|
2012-08-02 09:52:37 +00:00
|
|
|
}
|
2012-08-20 13:59:19 +00:00
|
|
|
mul_v2_fl(center, 1.0 / num_nodes);
|
2012-08-02 09:52:37 +00:00
|
|
|
|
|
|
|
/* copy nodes from clipboard */
|
2012-08-20 13:51:25 +00:00
|
|
|
for (node = clipboard_nodes_lb->first; node; node = node->next) {
|
2019-02-13 14:58:38 +01:00
|
|
|
bNode *new_node = BKE_node_copy_ex(ntree, node, LIB_ID_COPY_DEFAULT);
|
2012-08-20 13:51:25 +00:00
|
|
|
|
2012-08-02 09:52:37 +00:00
|
|
|
/* pasted nodes are selected */
|
2014-04-01 11:34:00 +11:00
|
|
|
nodeSetSelected(new_node, true);
|
2012-08-03 10:18:52 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-03 10:18:52 +00:00
|
|
|
/* reparent copied nodes */
|
2012-08-20 13:51:25 +00:00
|
|
|
for (node = clipboard_nodes_lb->first; node; node = node->next) {
|
2012-08-03 10:18:52 +00:00
|
|
|
bNode *new_node = node->new_node;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (new_node->parent) {
|
2012-08-03 10:18:52 +00:00
|
|
|
new_node->parent = new_node->parent->new_node;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-08-02 09:52:37 +00:00
|
|
|
}
|
|
|
|
|
2012-08-20 13:51:25 +00:00
|
|
|
for (link = clipboard_links_lb->first; link; link = link->next) {
|
2012-08-02 09:52:37 +00:00
|
|
|
nodeAddLink(ntree, link->fromnode->new_node, link->fromsock->new_sock,
|
|
|
|
link->tonode->new_node, link->tosock->new_sock);
|
|
|
|
}
|
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
|
2012-08-02 09:52:37 +00:00
|
|
|
|
|
|
|
snode_notify(C, snode);
|
|
|
|
snode_dag_update(C, snode);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_clipboard_paste(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2013-01-27 07:23:58 +00:00
|
|
|
ot->name = "Paste from Clipboard";
|
2012-08-02 09:52:37 +00:00
|
|
|
ot->description = "Pastes nodes from the clipboard to the active node tree";
|
|
|
|
ot->idname = "NODE_OT_clipboard_paste";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = node_clipboard_paste_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = ED_operator_node_editable;
|
2012-08-02 09:52:37 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-08-04 12:54:27 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2012-08-02 09:52:37 +00:00
|
|
|
}
|
2012-11-03 14:32:26 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/********************** Add interface socket operator *********************/
|
2012-11-03 14:32:26 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static bNodeSocket *ntree_get_active_interface_socket(ListBase *lb)
|
|
|
|
{
|
|
|
|
bNodeSocket *sock;
|
2019-03-26 21:16:47 +11:00
|
|
|
for (sock = lb->first; sock; sock = sock->next) {
|
|
|
|
if (sock->flag & SELECT) {
|
2013-03-18 16:34:57 +00:00
|
|
|
return sock;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-11-03 14:32:26 +00:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
static int ntree_socket_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNodeTree *ntree = snode->edittree;
|
|
|
|
int in_out = RNA_enum_get(op->ptr, "in_out");
|
|
|
|
PointerRNA ntree_ptr;
|
|
|
|
bNodeSocket *sock, *tsock, *active_sock;
|
|
|
|
const char *default_name;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
RNA_id_pointer_create((ID *)ntree, &ntree_ptr);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (in_out == SOCK_IN) {
|
|
|
|
active_sock = ntree_get_active_interface_socket(&ntree->inputs);
|
|
|
|
default_name = "Input";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
active_sock = ntree_get_active_interface_socket(&ntree->outputs);
|
|
|
|
default_name = "Output";
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
if (active_sock) {
|
|
|
|
/* insert a copy of the active socket right after it */
|
|
|
|
sock = ntreeInsertSocketInterface(ntree, in_out, active_sock->idname, active_sock->next, active_sock->name);
|
|
|
|
/* XXX this only works for actual sockets, not interface templates! */
|
|
|
|
/*nodeSocketCopyValue(sock, &ntree_ptr, active_sock, &ntree_ptr);*/
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* XXX TODO define default socket type for a tree! */
|
|
|
|
sock = ntreeAddSocketInterface(ntree, in_out, "NodeSocketFloat", default_name);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* deactivate sockets (has to check both lists) */
|
2019-03-26 21:16:47 +11:00
|
|
|
for (tsock = ntree->inputs.first; tsock; tsock = tsock->next) {
|
2013-03-18 16:34:57 +00:00
|
|
|
tsock->flag &= ~SELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
for (tsock = ntree->outputs.first; tsock; tsock = tsock->next) {
|
2013-03-18 16:34:57 +00:00
|
|
|
tsock->flag &= ~SELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
/* make the new socket active */
|
|
|
|
sock->flag |= SELECT;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), ntree);
|
2013-03-18 18:27:28 +00:00
|
|
|
|
2019-04-16 02:29:22 +02:00
|
|
|
snode_notify(C, snode);
|
|
|
|
snode_dag_update(C, snode);
|
|
|
|
|
2013-03-18 18:27:28 +00:00
|
|
|
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_tree_socket_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->name = "Add Node Tree Interface Socket";
|
2013-03-18 18:43:22 +00:00
|
|
|
ot->description = "Add an input or output socket to the current node tree";
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->idname = "NODE_OT_tree_socket_add";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* api callbacks */
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->exec = ntree_socket_add_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = ED_operator_node_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* flags */
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_enum(ot->srna, "in_out", rna_enum_node_socket_in_out_items, SOCK_IN, "Socket Type", "");
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************** Remove interface socket operator *********************/
|
|
|
|
|
|
|
|
static int ntree_socket_remove_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNodeTree *ntree = snode->edittree;
|
|
|
|
bNodeSocket *iosock, *active_sock;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
iosock = ntree_get_active_interface_socket(&ntree->inputs);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!iosock) {
|
2013-03-18 16:34:57 +00:00
|
|
|
iosock = ntree_get_active_interface_socket(&ntree->outputs);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
if (!iosock) {
|
2013-03-18 16:34:57 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* preferably next socket becomes active, otherwise try previous socket */
|
|
|
|
active_sock = (iosock->next ? iosock->next : iosock->prev);
|
|
|
|
ntreeRemoveSocketInterface(ntree, iosock);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* set active socket */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (active_sock) {
|
2013-03-18 16:34:57 +00:00
|
|
|
active_sock->flag |= SELECT;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), ntree);
|
2013-03-18 18:27:28 +00:00
|
|
|
|
2019-04-16 02:29:22 +02:00
|
|
|
snode_notify(C, snode);
|
|
|
|
snode_dag_update(C, snode);
|
|
|
|
|
2013-03-18 18:27:28 +00:00
|
|
|
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_tree_socket_remove(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->name = "Remove Node Tree Interface Socket";
|
2013-03-18 18:43:22 +00:00
|
|
|
ot->description = "Remove an input or output socket to the current node tree";
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->idname = "NODE_OT_tree_socket_remove";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* api callbacks */
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->exec = ntree_socket_remove_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = ED_operator_node_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* flags */
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************** Move interface socket operator *********************/
|
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem move_direction_items[] = {
|
2013-03-18 16:34:57 +00:00
|
|
|
{ 1, "UP", 0, "Up", "" },
|
|
|
|
{ 2, "DOWN", 0, "Down", "" },
|
|
|
|
{ 0, NULL, 0, NULL, NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static int ntree_socket_move_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNodeTree *ntree = snode->edittree;
|
|
|
|
int direction = RNA_enum_get(op->ptr, "direction");
|
|
|
|
bNodeSocket *iosock;
|
|
|
|
ListBase *lb;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
lb = &ntree->inputs;
|
|
|
|
iosock = ntree_get_active_interface_socket(lb);
|
|
|
|
if (!iosock) {
|
|
|
|
lb = &ntree->outputs;
|
|
|
|
iosock = ntree_get_active_interface_socket(lb);
|
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!iosock) {
|
2013-03-18 16:34:57 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
switch (direction) {
|
2013-07-19 10:40:43 +00:00
|
|
|
case 1:
|
|
|
|
{ /* up */
|
|
|
|
bNodeSocket *before = iosock->prev;
|
|
|
|
BLI_remlink(lb, iosock);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (before) {
|
2013-07-19 10:40:43 +00:00
|
|
|
BLI_insertlinkbefore(lb, before, iosock);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2013-07-19 10:40:43 +00:00
|
|
|
BLI_addhead(lb, iosock);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-07-19 10:40:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{ /* down */
|
|
|
|
bNodeSocket *after = iosock->next;
|
|
|
|
BLI_remlink(lb, iosock);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (after) {
|
2013-07-19 10:40:43 +00:00
|
|
|
BLI_insertlinkafter(lb, after, iosock);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2013-07-19 10:40:43 +00:00
|
|
|
BLI_addtail(lb, iosock);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-07-19 10:40:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-05-07 15:28:42 +00:00
|
|
|
ntreeUpdateTree(CTX_data_main(C), ntree);
|
2013-03-18 18:27:28 +00:00
|
|
|
|
2019-04-16 02:29:22 +02:00
|
|
|
snode_notify(C, snode);
|
|
|
|
snode_dag_update(C, snode);
|
|
|
|
|
2013-03-18 18:27:28 +00:00
|
|
|
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_tree_socket_move(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->name = "Move Node Tree Socket";
|
2013-03-18 18:43:22 +00:00
|
|
|
ot->description = "Move a socket up or down in the current node tree's sockets stack";
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->idname = "NODE_OT_tree_socket_move";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* api callbacks */
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->exec = ntree_socket_move_exec;
|
2013-06-05 19:06:33 +00:00
|
|
|
ot->poll = ED_operator_node_editable;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* flags */
|
2013-03-18 18:25:05 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
RNA_def_enum(ot->srna, "direction", move_direction_items, 1, "Direction", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ********************** Shader Script Update ******************/
|
2012-11-03 14:32:26 +00:00
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool node_shader_script_update_poll(bContext *C)
|
2012-11-03 14:32:26 +00:00
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-04-17 13:35:05 +02:00
|
|
|
RenderEngineType *type = RE_engines_find(scene->r.engine);
|
2013-04-24 16:59:56 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2012-11-03 14:32:26 +00:00
|
|
|
bNode *node;
|
|
|
|
Text *text;
|
|
|
|
|
|
|
|
/* test if we have a render engine that supports shaders scripts */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!(type && type->update_script_node)) {
|
2012-11-03 14:32:26 +00:00
|
|
|
return 0;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-11-03 14:32:26 +00:00
|
|
|
|
|
|
|
/* see if we have a shader script node in context */
|
|
|
|
node = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript).data;
|
2013-04-24 16:59:56 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!node && snode && snode->edittree) {
|
2013-04-24 16:59:56 +00:00
|
|
|
node = nodeGetActive(snode->edittree);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-04-24 16:59:56 +00:00
|
|
|
|
2012-11-03 15:35:03 +00:00
|
|
|
if (node && node->type == SH_NODE_SCRIPT) {
|
2012-11-03 14:32:26 +00:00
|
|
|
NodeShaderScript *nss = node->storage;
|
|
|
|
|
2012-11-03 15:35:03 +00:00
|
|
|
if (node->id || nss->filepath[0]) {
|
2013-06-10 20:10:03 +00:00
|
|
|
return ED_operator_node_editable(C);
|
2012-11-03 15:35:03 +00:00
|
|
|
}
|
2012-11-03 14:32:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* see if we have a text datablock in context */
|
|
|
|
text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (text) {
|
2012-11-03 14:32:26 +00:00
|
|
|
return 1;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-11-03 14:32:26 +00:00
|
|
|
|
|
|
|
/* we don't check if text datablock is actually in use, too slow for poll */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
/* recursively check for script nodes in groups using this text and update */
|
2014-04-11 11:25:41 +10:00
|
|
|
static bool node_shader_script_update_text_recursive(RenderEngine *engine, RenderEngineType *type, bNodeTree *ntree, Text *text)
|
2012-11-03 14:32:26 +00:00
|
|
|
{
|
2014-04-11 11:25:41 +10:00
|
|
|
bool found = false;
|
2012-11-03 14:32:26 +00:00
|
|
|
bNode *node;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
ntree->done = true;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-11-03 14:32:26 +00:00
|
|
|
/* update each script that is using this text datablock */
|
2012-11-03 15:35:03 +00:00
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->type == NODE_GROUP) {
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeTree *ngroup = (bNodeTree *)node->id;
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ngroup && !ngroup->done) {
|
2013-03-18 16:34:57 +00:00
|
|
|
found |= node_shader_script_update_text_recursive(engine, type, ngroup, text);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-11-03 14:32:26 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
else if (node->type == SH_NODE_SCRIPT && node->id == &text->id) {
|
|
|
|
type->update_script_node(engine, ntree, node);
|
2014-04-01 11:34:00 +11:00
|
|
|
found = true;
|
2012-11-03 14:32:26 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
return found;
|
2012-11-03 14:32:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int node_shader_script_update_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2013-04-24 16:59:56 +00:00
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2012-11-03 14:32:26 +00:00
|
|
|
PointerRNA nodeptr = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript);
|
2015-11-23 15:44:15 +11:00
|
|
|
bNodeTree *ntree_base = NULL;
|
2013-04-24 16:59:56 +00:00
|
|
|
bNode *node = NULL;
|
2013-03-18 16:34:57 +00:00
|
|
|
RenderEngine *engine;
|
|
|
|
RenderEngineType *type;
|
2014-04-11 11:25:41 +10:00
|
|
|
bool found = false;
|
2012-11-03 14:32:26 +00:00
|
|
|
|
|
|
|
/* setup render engine */
|
2018-04-17 13:35:05 +02:00
|
|
|
type = RE_engines_find(scene->r.engine);
|
2013-03-18 16:34:57 +00:00
|
|
|
engine = RE_engine_create(type);
|
|
|
|
engine->reports = op->reports;
|
2012-11-03 14:32:26 +00:00
|
|
|
|
2013-04-24 16:59:56 +00:00
|
|
|
/* get node */
|
2012-11-03 14:32:26 +00:00
|
|
|
if (nodeptr.data) {
|
2015-11-23 15:44:15 +11:00
|
|
|
ntree_base = nodeptr.id.data;
|
2013-04-24 16:59:56 +00:00
|
|
|
node = nodeptr.data;
|
|
|
|
}
|
|
|
|
else if (snode && snode->edittree) {
|
2015-11-23 15:44:15 +11:00
|
|
|
ntree_base = snode->edittree;
|
2013-04-24 16:59:56 +00:00
|
|
|
node = nodeGetActive(snode->edittree);
|
|
|
|
}
|
2012-11-03 14:32:26 +00:00
|
|
|
|
2013-04-24 16:59:56 +00:00
|
|
|
if (node) {
|
|
|
|
/* update single node */
|
2015-11-23 15:44:15 +11:00
|
|
|
type->update_script_node(engine, ntree_base, node);
|
2012-11-03 14:32:26 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
found = true;
|
2012-11-03 14:32:26 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* update all nodes using text datablock */
|
2013-03-18 16:34:57 +00:00
|
|
|
Text *text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
|
|
|
|
|
|
|
|
if (text) {
|
|
|
|
/* clear flags for recursion check */
|
2018-11-30 15:22:01 +11:00
|
|
|
FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ntree->type == NTREE_SHADER) {
|
2014-04-01 11:34:00 +11:00
|
|
|
ntree->done = false;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-11-30 15:22:01 +11:00
|
|
|
} FOREACH_NODETREE_END;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-11-30 15:22:01 +11:00
|
|
|
FOREACH_NODETREE_BEGIN(bmain, ntree, id) {
|
2013-03-18 16:34:57 +00:00
|
|
|
if (ntree->type == NTREE_SHADER) {
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!ntree->done) {
|
2013-03-18 16:34:57 +00:00
|
|
|
found |= node_shader_script_update_text_recursive(engine, type, ntree, text);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
2018-11-30 15:22:01 +11:00
|
|
|
} FOREACH_NODETREE_END;
|
2012-11-03 14:32:26 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (!found) {
|
2012-11-07 14:56:53 +00:00
|
|
|
BKE_report(op->reports, RPT_INFO, "Text not used by any node, no update done");
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-11-03 14:32:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
RE_engine_free(engine);
|
2012-11-03 14:32:26 +00:00
|
|
|
|
2013-03-31 03:28:46 +00:00
|
|
|
return (found) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
|
2012-11-03 14:32:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_shader_script_update(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Script Node Update";
|
|
|
|
ot->description = "Update shader script node with new sockets and options from the script";
|
|
|
|
ot->idname = "NODE_OT_shader_script_update";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = node_shader_script_update_exec;
|
|
|
|
ot->poll = node_shader_script_update_poll;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2013-03-07 17:47:30 +00:00
|
|
|
/* ********************** Viewer border ******************/
|
|
|
|
|
|
|
|
static void viewer_border_corner_to_backdrop(SpaceNode *snode, ARegion *ar, int x, int y,
|
|
|
|
int backdrop_width, int backdrop_height,
|
|
|
|
float *fx, float *fy)
|
|
|
|
{
|
|
|
|
float bufx, bufy;
|
|
|
|
|
|
|
|
bufx = backdrop_width * snode->zoom;
|
|
|
|
bufy = backdrop_height * snode->zoom;
|
|
|
|
|
|
|
|
*fx = (bufx > 0.0f ? ((float) x - 0.5f * ar->winx - snode->xof) / bufx + 0.5f : 0.0f);
|
|
|
|
*fy = (bufy > 0.0f ? ((float) y - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int viewer_border_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2018-06-11 15:40:37 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2013-03-07 17:47:30 +00:00
|
|
|
Image *ima;
|
|
|
|
void *lock;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
|
2013-03-07 17:47:30 +00:00
|
|
|
|
2018-06-11 15:40:37 +02:00
|
|
|
ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
|
2013-03-07 17:47:30 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
|
|
|
|
|
|
|
if (ibuf) {
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
2013-04-24 15:39:19 +00:00
|
|
|
bNodeTree *btree = snode->nodetree;
|
2013-03-07 17:47:30 +00:00
|
|
|
rcti rect;
|
|
|
|
rctf rectf;
|
|
|
|
|
|
|
|
/* get border from operator */
|
|
|
|
WM_operator_properties_border_to_rcti(op, &rect);
|
|
|
|
|
|
|
|
/* convert border to unified space within backdrop image */
|
|
|
|
viewer_border_corner_to_backdrop(snode, ar, rect.xmin, rect.ymin, ibuf->x, ibuf->y,
|
|
|
|
&rectf.xmin, &rectf.ymin);
|
|
|
|
|
|
|
|
viewer_border_corner_to_backdrop(snode, ar, rect.xmax, rect.ymax, ibuf->x, ibuf->y,
|
|
|
|
&rectf.xmax, &rectf.ymax);
|
|
|
|
|
|
|
|
/* clamp coordinates */
|
|
|
|
rectf.xmin = max_ff(rectf.xmin, 0.0f);
|
|
|
|
rectf.ymin = max_ff(rectf.ymin, 0.0f);
|
|
|
|
rectf.xmax = min_ff(rectf.xmax, 1.0f);
|
|
|
|
rectf.ymax = min_ff(rectf.ymax, 1.0f);
|
|
|
|
|
|
|
|
if (rectf.xmin < rectf.xmax && rectf.ymin < rectf.ymax) {
|
|
|
|
btree->viewer_border = rectf;
|
|
|
|
|
|
|
|
if (rectf.xmin == 0.0f && rectf.ymin == 0.0f &&
|
|
|
|
rectf.xmax == 1.0f && rectf.ymax == 1.0f)
|
|
|
|
{
|
|
|
|
btree->flag &= ~NTREE_VIEWER_BORDER;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
btree->flag |= NTREE_VIEWER_BORDER;
|
|
|
|
}
|
|
|
|
|
|
|
|
snode_notify(C, snode);
|
|
|
|
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
btree->flag &= ~NTREE_VIEWER_BORDER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, lock);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_viewer_border(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Viewer Border";
|
|
|
|
ot->description = "Set the boundaries for viewer operations";
|
|
|
|
ot->idname = "NODE_OT_viewer_border";
|
|
|
|
|
|
|
|
/* api callbacks */
|
2018-10-05 10:27:04 +10:00
|
|
|
ot->invoke = WM_gesture_box_invoke;
|
2013-03-07 17:47:30 +00:00
|
|
|
ot->exec = viewer_border_exec;
|
2018-10-05 10:27:04 +10:00
|
|
|
ot->modal = WM_gesture_box_modal;
|
|
|
|
ot->cancel = WM_gesture_box_cancel;
|
2013-03-07 17:47:30 +00:00
|
|
|
ot->poll = composite_node_active;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
/* properties */
|
2018-10-05 10:27:04 +10:00
|
|
|
WM_operator_properties_gesture_box_select(ot);
|
2013-03-07 17:47:30 +00:00
|
|
|
}
|
2014-06-05 20:05:41 +06:00
|
|
|
|
|
|
|
static int clear_viewer_border_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
bNodeTree *btree = snode->nodetree;
|
|
|
|
|
|
|
|
btree->flag &= ~NTREE_VIEWER_BORDER;
|
|
|
|
snode_notify(C, snode);
|
|
|
|
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_clear_viewer_border(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Clear Viewer Border";
|
|
|
|
ot->description = "Clear the boundaries for viewer operations";
|
|
|
|
ot->idname = "NODE_OT_clear_viewer_border";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = clear_viewer_border_exec;
|
|
|
|
ot->poll = composite_node_active;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
2018-07-18 13:03:09 +02:00
|
|
|
|
|
|
|
/* ****************** Cryptomatte Add Socket ******************* */
|
|
|
|
|
|
|
|
static int node_cryptomatte_add_socket_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get(C, "node");
|
|
|
|
bNodeTree *ntree = NULL;
|
|
|
|
bNode *node = NULL;
|
|
|
|
|
|
|
|
if (ptr.data) {
|
|
|
|
node = ptr.data;
|
|
|
|
ntree = ptr.id.data;
|
|
|
|
}
|
|
|
|
else if (snode && snode->edittree) {
|
|
|
|
ntree = snode->edittree;
|
|
|
|
node = nodeGetActive(snode->edittree);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!node || node->type != CMP_NODE_CRYPTOMATTE) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ntreeCompositCryptomatteAddSocket(ntree, node);
|
|
|
|
|
|
|
|
snode_notify(C, snode);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_cryptomatte_layer_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Add Cryptomatte Socket";
|
|
|
|
ot->description = "Add a new input layer to a Cryptomatte node";
|
|
|
|
ot->idname = "NODE_OT_cryptomatte_layer_add";
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
ot->exec = node_cryptomatte_add_socket_exec;
|
|
|
|
ot->poll = composite_node_editable;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** Cryptomatte Remove Socket ******************* */
|
|
|
|
|
|
|
|
static int node_cryptomatte_remove_socket_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
SpaceNode *snode = CTX_wm_space_node(C);
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get(C, "node");
|
|
|
|
bNodeTree *ntree = NULL;
|
|
|
|
bNode *node = NULL;
|
|
|
|
|
|
|
|
if (ptr.data) {
|
|
|
|
node = ptr.data;
|
|
|
|
ntree = ptr.id.data;
|
|
|
|
}
|
|
|
|
else if (snode && snode->edittree) {
|
|
|
|
ntree = snode->edittree;
|
|
|
|
node = nodeGetActive(snode->edittree);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!node || node->type != CMP_NODE_CRYPTOMATTE) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ntreeCompositCryptomatteRemoveSocket(ntree, node)) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
snode_notify(C, snode);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NODE_OT_cryptomatte_layer_remove(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Remove Cryptomatte Socket";
|
2018-12-24 15:02:20 +01:00
|
|
|
ot->description = "Remove layer from a Cryptomatte node";
|
2018-07-18 13:03:09 +02:00
|
|
|
ot->idname = "NODE_OT_cryptomatte_layer_remove";
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
ot->exec = node_cryptomatte_remove_socket_exec;
|
|
|
|
ot->poll = composite_node_editable;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|