2011-05-19 11:34:11 +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.
|
2011-05-19 11:34:11 +00:00
|
|
|
*
|
|
|
|
|
* 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,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edrend
|
2011-05-19 11:34:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2019-02-27 12:34:56 +11:00
|
|
|
#include "DNA_light_types.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
#include "DNA_material_types.h"
|
2012-12-18 12:42:13 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
#include "DNA_node_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2017-10-16 18:37:37 -02:00
|
|
|
#include "DNA_workspace_types.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
#include "DNA_world_types.h"
|
|
|
|
|
|
2017-09-25 20:07:02 +02:00
|
|
|
#include "DRW_engine.h"
|
|
|
|
|
|
2014-11-22 14:39:53 +01:00
|
|
|
#include "BLI_listbase.h"
|
2011-11-28 14:55:35 +00:00
|
|
|
#include "BLI_threads.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_icons.h"
|
2017-03-30 11:18:57 +02:00
|
|
|
#include "BKE_layer.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_material.h"
|
|
|
|
|
#include "BKE_node.h"
|
Paint refactoring commit, non-disruptive (in theory :p)
* Fix precision overflow issue with overlay previews,
* Expose alpha mask mapping to UI (still not functional but coming soon).
* More overlay refactoring:
Overlay now does minimal checking for texture refresh.
Instead, we now have invalidation flags to set an aspect of the brush
overlay as invalid. This is necessary because this way we will be able to
separate and preview different brush attributes on the overlays, using
different textures:
These attributes/aspects are:
Primary texture (main texture for sculpt, vertex, imapaint)
Secondary texture (mask/alpha texture for imapaint)
Cursor texture (cursor texture. It involves brush strength and curves)
Modified the relevant RNA property update functions and C update callback
functions to call the relevant cursor invalidation functions instead
of checking every frame for multiple properties.
Properties that affect this are:
Image changes, if image is used by current brush,
Texture slot changes, similarly
Curve changes,
Object mode change invalidates the cursor
Paint tool change invalidates the cursor.
These changes give slightly more invalidation cases than simply
comparing the relevant properties each frame, but these do not occur in
performance critical moments and it's a much more elegant system than
adding more variables to check per frame each time we add something on
the system.
2013-04-12 17:21:31 +00:00
|
|
|
#include "BKE_paint.h"
|
2015-08-27 12:10:01 +02:00
|
|
|
#include "BKE_scene.h"
|
2017-10-16 18:37:37 -02:00
|
|
|
#include "BKE_workspace.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2011-11-02 18:20:53 +00:00
|
|
|
#include "RE_engine.h"
|
2012-11-09 23:54:58 +00:00
|
|
|
#include "RE_pipeline.h"
|
2011-11-02 18:20:53 +00:00
|
|
|
|
2011-08-15 12:07:52 +00:00
|
|
|
#include "ED_node.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
#include "ED_render.h"
|
2015-03-17 12:02:10 +05:00
|
|
|
#include "ED_view3d.h"
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2017-11-28 13:04:21 +01:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
|
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
|
|
|
#include "WM_api.h"
|
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
#include "render_intern.h" // own include
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2011-11-02 18:20:53 +00:00
|
|
|
/***************************** Render Engines ********************************/
|
|
|
|
|
|
2017-11-28 13:04:21 +01:00
|
|
|
void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int updated)
|
2011-11-02 18:20:53 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* viewport rendering update on data changes, happens after depsgraph
|
|
|
|
|
* updates if there was any change. context is set to the 3d view */
|
|
|
|
|
Main *bmain = update_ctx->bmain;
|
|
|
|
|
Scene *scene = update_ctx->scene;
|
|
|
|
|
ViewLayer *view_layer = update_ctx->view_layer;
|
|
|
|
|
bContext *C;
|
|
|
|
|
wmWindowManager *wm;
|
|
|
|
|
wmWindow *win;
|
|
|
|
|
static bool recursive_check = false;
|
|
|
|
|
|
|
|
|
|
/* don't do this render engine update if we're updating the scene from
|
|
|
|
|
* other threads doing e.g. rendering or baking jobs */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!BLI_thread_is_main()) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* don't call this recursively for frame updates */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (recursive_check) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* Do not call if no WM available, see T42688. */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (BLI_listbase_is_empty(&bmain->wm)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
recursive_check = true;
|
|
|
|
|
|
|
|
|
|
C = CTX_create();
|
|
|
|
|
CTX_data_main_set(C, bmain);
|
|
|
|
|
CTX_data_scene_set(C, scene);
|
|
|
|
|
|
|
|
|
|
CTX_wm_manager_set(C, bmain->wm.first);
|
|
|
|
|
wm = bmain->wm.first;
|
|
|
|
|
|
|
|
|
|
for (win = wm->windows.first; win; win = win->next) {
|
2020-04-03 14:23:21 +02:00
|
|
|
bScreen *screen = WM_window_get_active_screen(win);
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area;
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
CTX_wm_window_set(C, win);
|
|
|
|
|
|
2020-04-03 14:23:21 +02:00
|
|
|
for (area = screen->areabase.first; area; area = area->next) {
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area->spacetype != SPACE_VIEW3D) {
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
2020-04-03 13:25:03 +02:00
|
|
|
View3D *v3d = area->spacedata.first;
|
|
|
|
|
for (region = area->regionbase.first; region; region = region->next) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->regiontype != RGN_TYPE_WINDOW) {
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
RegionView3D *rv3d = region->regiondata;
|
2019-04-17 06:17:24 +02:00
|
|
|
RenderEngine *engine = rv3d->render_engine;
|
|
|
|
|
/* call update if the scene changed, or if the render engine
|
|
|
|
|
* tagged itself for update (e.g. because it was busy at the
|
|
|
|
|
* time of the last update) */
|
|
|
|
|
if (engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) {
|
|
|
|
|
|
2020-04-03 14:23:21 +02:00
|
|
|
CTX_wm_screen_set(C, screen);
|
2020-04-03 13:25:03 +02:00
|
|
|
CTX_wm_area_set(C, area);
|
2020-03-06 16:56:42 +01:00
|
|
|
CTX_wm_region_set(C, region);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
engine->flag &= ~RE_ENGINE_DO_UPDATE;
|
2019-05-16 17:19:05 +02:00
|
|
|
/* NOTE: Important to pass non-updated depsgraph, This is because this function is called
|
|
|
|
|
* from inside dependency graph evaluation. Additionally, if we pass fully evaluated one
|
|
|
|
|
* we will loose updates stored in the graph. */
|
2019-07-25 16:36:22 +02:00
|
|
|
engine->type->view_update(engine, C, CTX_data_depsgraph_pointer(C));
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
|
|
|
|
|
if (updated) {
|
|
|
|
|
DRW_notify_view_update((&(DRWUpdateContext){
|
|
|
|
|
.bmain = bmain,
|
|
|
|
|
.depsgraph = update_ctx->depsgraph,
|
|
|
|
|
.scene = scene,
|
|
|
|
|
.view_layer = view_layer,
|
2020-03-06 16:56:42 +01:00
|
|
|
.region = region,
|
2020-04-03 13:25:03 +02:00
|
|
|
.v3d = (View3D *)area->spacedata.first,
|
2019-04-17 06:17:24 +02:00
|
|
|
.engine_type = engine_type,
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CTX_free(C);
|
|
|
|
|
|
|
|
|
|
recursive_check = false;
|
2011-11-02 18:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
void ED_render_engine_area_exit(Main *bmain, ScrArea *area)
|
2011-11-02 18:20:53 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* clear all render engines in this area */
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region;
|
2019-04-17 06:17:24 +02:00
|
|
|
wmWindowManager *wm = bmain->wm.first;
|
|
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area->spacetype != SPACE_VIEW3D) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
for (region = area->regionbase.first; region; region = region->next) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->regiontype != RGN_TYPE_WINDOW || !(region->regiondata)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_view3d_stop_render_preview(wm, region);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-11-02 18:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-26 12:30:37 +00:00
|
|
|
void ED_render_engine_changed(Main *bmain)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* on changing the render engine type, clear all running render engines */
|
2020-04-03 14:23:21 +02:00
|
|
|
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
|
|
|
|
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_render_engine_area_exit(bmain, area);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RE_FreePersistentData();
|
|
|
|
|
/* Inform all render engines and draw managers. */
|
|
|
|
|
DEGEditorUpdateContext update_ctx = {NULL};
|
|
|
|
|
update_ctx.bmain = bmain;
|
|
|
|
|
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
|
|
|
|
|
update_ctx.scene = scene;
|
|
|
|
|
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
|
|
|
|
|
/* TDODO(sergey): Iterate over depsgraphs instead? */
|
2019-09-09 14:49:05 +02:00
|
|
|
update_ctx.depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
update_ctx.view_layer = view_layer;
|
|
|
|
|
ED_render_id_flush_update(&update_ctx, &scene->id);
|
|
|
|
|
}
|
|
|
|
|
if (scene->nodetree) {
|
|
|
|
|
ntreeCompositUpdateRLayers(scene->nodetree);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-26 12:30:37 +00:00
|
|
|
}
|
|
|
|
|
|
2020-04-03 14:23:21 +02:00
|
|
|
void ED_render_view_layer_changed(Main *bmain, bScreen *screen)
|
2019-03-22 12:45:42 -03:00
|
|
|
{
|
2020-04-03 14:23:21 +02:00
|
|
|
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_render_engine_area_exit(bmain, area);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-03-22 12:45:42 -03:00
|
|
|
}
|
|
|
|
|
|
2011-05-19 11:34:11 +00:00
|
|
|
/***************************** Updates ***********************************
|
2017-08-16 11:52:27 +02:00
|
|
|
* ED_render_id_flush_update gets called from DEG_id_tag_update, to do *
|
2012-04-22 11:54:53 +00:00
|
|
|
* editor level updates when the ID changes. when these ID blocks are in *
|
|
|
|
|
* the dependency graph, we can get rid of the manual dependency checks */
|
2011-05-19 11:34:11 +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
|
|
|
static void material_changed(Main *UNUSED(bmain), Material *ma)
|
2011-05-19 11:34:11 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* icons */
|
|
|
|
|
BKE_icon_changed(BKE_icon_id_ensure(&ma->id));
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
2019-02-27 10:46:48 +11:00
|
|
|
static void lamp_changed(Main *UNUSED(bmain), Light *la)
|
2012-11-24 14:50:40 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* icons */
|
|
|
|
|
BKE_icon_changed(BKE_icon_id_ensure(&la->id));
|
2012-11-24 14:50:40 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-19 11:34:11 +00:00
|
|
|
static void texture_changed(Main *bmain, Tex *tex)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene;
|
|
|
|
|
ViewLayer *view_layer;
|
|
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
|
|
/* icons */
|
|
|
|
|
BKE_icon_changed(BKE_icon_id_ensure(&tex->id));
|
|
|
|
|
|
|
|
|
|
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
|
|
|
|
|
/* paint overlays */
|
|
|
|
|
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
|
|
|
|
|
BKE_paint_invalidate_overlay_tex(scene, view_layer, tex);
|
|
|
|
|
}
|
|
|
|
|
/* find compositing nodes */
|
|
|
|
|
if (scene->use_nodes && scene->nodetree) {
|
|
|
|
|
for (node = scene->nodetree->nodes.first; node; node = node->next) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (node->id == &tex->id) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ED_node_tag_update_id(&scene->id);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
2017-06-29 18:56:38 +02:00
|
|
|
static void world_changed(Main *UNUSED(bmain), World *wo)
|
2011-05-19 11:34:11 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* icons */
|
|
|
|
|
BKE_icon_changed(BKE_icon_id_ensure(&wo->id));
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void image_changed(Main *bmain, Image *ima)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Tex *tex;
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* icons */
|
|
|
|
|
BKE_icon_changed(BKE_icon_id_ensure(&ima->id));
|
2011-05-19 11:34:11 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* textures */
|
2019-04-22 09:19:45 +10:00
|
|
|
for (tex = bmain->textures.first; tex; tex = tex->id.next) {
|
2019-05-03 11:18:32 +02:00
|
|
|
if (tex->type == TEX_IMAGE && tex->ima == ima) {
|
2019-04-17 06:17:24 +02:00
|
|
|
texture_changed(bmain, tex);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
}
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-06 15:12:06 +02:00
|
|
|
static void scene_changed(Main *bmain, Scene *scene)
|
2011-05-19 11:34:11 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Object *ob;
|
|
|
|
|
|
|
|
|
|
/* glsl */
|
|
|
|
|
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
|
|
|
|
|
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
|
|
|
|
|
BKE_texpaint_slots_refresh_object(scene, ob);
|
|
|
|
|
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-28 13:04:21 +01:00
|
|
|
void ED_render_id_flush_update(const DEGEditorUpdateContext *update_ctx, ID *id)
|
2011-05-19 11:34:11 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* this can be called from render or baking thread when a python script makes
|
|
|
|
|
* changes, in that case we don't want to do any editor updates, and making
|
|
|
|
|
* GPU changes is not possible because OpenGL only works in the main thread */
|
|
|
|
|
if (!BLI_thread_is_main()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Main *bmain = update_ctx->bmain;
|
|
|
|
|
/* Internal ID update handlers. */
|
|
|
|
|
switch (GS(id->name)) {
|
|
|
|
|
case ID_MA:
|
|
|
|
|
material_changed(bmain, (Material *)id);
|
|
|
|
|
break;
|
|
|
|
|
case ID_TE:
|
|
|
|
|
texture_changed(bmain, (Tex *)id);
|
|
|
|
|
break;
|
|
|
|
|
case ID_WO:
|
|
|
|
|
world_changed(bmain, (World *)id);
|
|
|
|
|
break;
|
|
|
|
|
case ID_LA:
|
|
|
|
|
lamp_changed(bmain, (Light *)id);
|
|
|
|
|
break;
|
|
|
|
|
case ID_IM:
|
|
|
|
|
image_changed(bmain, (Image *)id);
|
|
|
|
|
break;
|
|
|
|
|
case ID_SCE:
|
|
|
|
|
scene_changed(bmain, (Scene *)id);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-05-19 11:34:11 +00:00
|
|
|
}
|