2011-02-23 10:52:22 +00:00
|
|
|
/*
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +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.
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup edrend
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_curve_types.h"
|
2019-02-27 12:34:56 +11:00
|
|
|
#include "DNA_light_types.h"
|
2018-07-10 15:02:25 +02:00
|
|
|
#include "DNA_lightprobe_types.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_node_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
2016-12-28 17:30:58 +01:00
|
|
|
#include "DNA_particle_types.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2010-03-11 07:43:49 +00:00
|
|
|
#include "DNA_space_types.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "DNA_world_types.h"
|
|
|
|
|
2015-04-28 07:24:56 +10:00
|
|
|
#include "BLI_listbase.h"
|
|
|
|
#include "BLI_math_vector.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-03-25 08:29:06 +00:00
|
|
|
|
2020-04-03 13:07:36 +02:00
|
|
|
#include "BKE_anim_data.h"
|
merge own commits into render branch into trunk since 27560
27562, 27570, 27571, 27574, 27576, 27577, 27579, 27590, 27591, 27594, 27595, 27596, 27599, 27605, 27611, 27612, 27613, 27614, 27623
2010-03-20 16:41:01 +00:00
|
|
|
#include "BKE_animsys.h"
|
2019-03-10 08:55:38 +01:00
|
|
|
#include "BKE_brush.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "BKE_context.h"
|
2011-09-14 00:37:27 +00:00
|
|
|
#include "BKE_curve.h"
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_editmesh.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "BKE_font.h"
|
2010-03-11 07:43:49 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_image.h"
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
#include "BKE_layer.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
2013-03-23 03:00:37 +00:00
|
|
|
#include "BKE_linestyle.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_material.h"
|
2020-08-30 13:33:35 +10:00
|
|
|
#include "BKE_object.h"
|
2010-03-11 07:43:49 +00:00
|
|
|
#include "BKE_report.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "BKE_scene.h"
|
|
|
|
#include "BKE_texture.h"
|
2018-04-24 15:20:17 +02:00
|
|
|
#include "BKE_workspace.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "BKE_world.h"
|
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
#include "DEG_depsgraph_build.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2014-11-28 15:50:43 +01:00
|
|
|
# include "BKE_freestyle.h"
|
2012-12-20 07:57:26 +00:00
|
|
|
# include "FRS_freestyle.h"
|
2014-11-28 15:50:43 +01:00
|
|
|
# include "RNA_enum_types.h"
|
2012-12-20 07:57:26 +00:00
|
|
|
#endif
|
2009-10-07 05:16:23 +00:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "ED_curve.h"
|
|
|
|
#include "ED_mesh.h"
|
2011-11-02 19:24:30 +00:00
|
|
|
#include "ED_node.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_object.h"
|
2020-09-21 14:43:29 +02:00
|
|
|
#include "ED_paint.h"
|
2011-04-08 16:56:44 +00:00
|
|
|
#include "ED_render.h"
|
2017-06-09 17:16:39 +02:00
|
|
|
#include "ED_scene.h"
|
2011-04-08 16:56:44 +00:00
|
|
|
#include "ED_screen.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
|
2020-12-04 08:13:54 +01:00
|
|
|
#include "RE_engine.h"
|
2011-08-28 23:24:34 +00:00
|
|
|
#include "RE_pipeline.h"
|
|
|
|
|
2018-07-10 15:02:25 +02:00
|
|
|
#include "engines/eevee/eevee_lightcache.h"
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
#include "render_intern.h" /* own include */
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2020-08-30 13:33:35 +10:00
|
|
|
static bool object_materials_supported_poll_ex(bContext *C, const Object *ob);
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Local Utilities
|
|
|
|
* \{ */
|
|
|
|
|
2020-08-30 13:33:35 +10:00
|
|
|
static bool object_array_for_shading_edit_mode_enabled_filter(Object *ob, void *user_data)
|
|
|
|
{
|
|
|
|
bContext *C = user_data;
|
|
|
|
if (object_materials_supported_poll_ex(C, ob)) {
|
|
|
|
if (BKE_object_is_in_editmode(ob) == true) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Object **object_array_for_shading_edit_mode_enabled(bContext *C, uint *r_objects_len)
|
|
|
|
{
|
2020-08-30 17:39:12 +10:00
|
|
|
return ED_object_array_in_mode_or_selected(
|
2020-08-30 13:33:35 +10:00
|
|
|
C, object_array_for_shading_edit_mode_enabled_filter, C, r_objects_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool object_array_for_shading_edit_mode_disabled_filter(Object *ob, void *user_data)
|
|
|
|
{
|
|
|
|
bContext *C = user_data;
|
|
|
|
if (object_materials_supported_poll_ex(C, ob)) {
|
|
|
|
if (BKE_object_is_in_editmode(ob) == false) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Object **object_array_for_shading_edit_mode_disabled(bContext *C, uint *r_objects_len)
|
|
|
|
{
|
2020-08-30 17:39:12 +10:00
|
|
|
return ED_object_array_in_mode_or_selected(
|
2020-08-30 13:33:35 +10:00
|
|
|
C, object_array_for_shading_edit_mode_disabled_filter, C, r_objects_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Shared Operator Poll Functions
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
static bool object_materials_supported_poll_ex(bContext *C, const Object *ob)
|
|
|
|
{
|
|
|
|
if (!ED_operator_object_active_local_editable_ex(C, ob)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const ID *data = ob->data;
|
|
|
|
return (OB_TYPE_SUPPORT_MATERIAL(ob->type) &&
|
|
|
|
/* Object data checks. */
|
|
|
|
data && !ID_IS_LINKED(data) && !ID_IS_OVERRIDE_LIBRARY(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool object_materials_supported_poll(bContext *C)
|
|
|
|
{
|
|
|
|
Object *ob = ED_object_context(C);
|
|
|
|
return object_materials_supported_poll_ex(C, ob);
|
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Material Slot Add Operator
|
|
|
|
* \{ */
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
2018-05-29 15:49:21 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-03-29 22:42:32 +00:00
|
|
|
Object *ob = ED_object_context(C);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!ob) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-05-29 15:49:21 +02:00
|
|
|
BKE_object_material_slot_add(bmain, ob);
|
2014-10-06 15:12:06 +02:00
|
|
|
|
2018-04-05 18:20:27 +02:00
|
|
|
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
|
2014-10-06 15:12:06 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-09-21 14:43:29 +02:00
|
|
|
ED_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
|
2014-10-06 15:12:06 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
|
2013-07-17 11:02:51 +00:00
|
|
|
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Material Slot";
|
|
|
|
ot->idname = "OBJECT_OT_material_slot_add";
|
|
|
|
ot->description = "Add a new material slot";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = material_slot_add_exec;
|
2020-08-30 13:33:35 +10:00
|
|
|
ot->poll = object_materials_supported_poll;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Material Slot Remove Operator
|
|
|
|
* \{ */
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
static int material_slot_remove_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Object *ob = ED_object_context(C);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!ob) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2020-09-30 20:09:02 +10:00
|
|
|
/* Removing material slots in edit mode screws things up, see bug T21822.*/
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob == CTX_data_edit_object(C)) {
|
2011-09-19 12:26:20 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode");
|
2010-10-15 08:11:26 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-05-29 15:49:21 +02:00
|
|
|
BKE_object_material_slot_remove(CTX_data_main(C), ob);
|
2014-10-06 15:12:06 +02:00
|
|
|
|
2018-04-05 18:20:27 +02:00
|
|
|
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
|
2014-10-06 15:12:06 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-09-21 14:43:29 +02:00
|
|
|
ED_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
|
2014-10-06 15:12:06 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
|
2013-07-17 11:02:51 +00:00
|
|
|
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_remove(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Remove Material Slot";
|
|
|
|
ot->idname = "OBJECT_OT_material_slot_remove";
|
|
|
|
ot->description = "Remove the selected material slot";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = material_slot_remove_exec;
|
2020-08-30 13:33:35 +10:00
|
|
|
ot->poll = object_materials_supported_poll;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Material Slot Assign Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
2018-09-25 18:50:57 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2018-12-03 15:26:25 +11:00
|
|
|
bool changed_multi = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-17 10:29:08 +01:00
|
|
|
Object *obact = CTX_data_active_object(C);
|
|
|
|
const Material *mat_active = obact ? BKE_object_material_get(obact, obact->actcol) : NULL;
|
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
uint objects_len = 0;
|
2020-08-30 13:33:35 +10:00
|
|
|
Object **objects = object_array_for_shading_edit_mode_enabled(C, &objects_len);
|
2018-12-03 15:26:25 +11:00
|
|
|
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
|
|
|
Object *ob = objects[ob_index];
|
2020-02-17 10:29:08 +01:00
|
|
|
short mat_nr_active = -1;
|
|
|
|
|
|
|
|
if (ob->totcol == 0) {
|
2018-12-03 15:26:25 +11:00
|
|
|
continue;
|
|
|
|
}
|
2020-02-17 10:29:08 +01:00
|
|
|
if (obact && (mat_active == BKE_object_material_get(ob, obact->actcol))) {
|
|
|
|
/* Avoid searching since there may be multiple slots with the same material.
|
|
|
|
* For the active object or duplicates: match the material slot index first. */
|
|
|
|
mat_nr_active = obact->actcol - 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Find the first matching material.
|
|
|
|
* Note: there may be multiple but that's not a common use case. */
|
2020-07-03 16:54:08 +02:00
|
|
|
for (int i = 0; i < ob->totcol; i++) {
|
2020-02-17 10:29:08 +01:00
|
|
|
const Material *mat = BKE_object_material_get(ob, i + 1);
|
|
|
|
if (mat_active == mat) {
|
|
|
|
mat_nr_active = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mat_nr_active == -1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
bool changed = false;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob->type == OB_MESH) {
|
2013-04-16 05:59:48 +00:00
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(ob);
|
2009-10-22 23:22:05 +00:00
|
|
|
BMFace *efa;
|
|
|
|
BMIter iter;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (em) {
|
2012-04-19 13:47:58 +00:00
|
|
|
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
|
2018-12-03 15:26:25 +11:00
|
|
|
if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
|
|
|
|
changed = true;
|
2020-02-17 10:29:08 +01:00
|
|
|
efa->mat_nr = mat_nr_active;
|
2018-12-03 15:26:25 +11:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
Nurb *nu;
|
2012-04-28 16:49:00 +00:00
|
|
|
ListBase *nurbs = BKE_curve_editNurbs_get((Curve *)ob->data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (nurbs) {
|
2015-07-09 14:31:27 +10:00
|
|
|
for (nu = nurbs->first; nu; nu = nu->next) {
|
2018-09-25 18:50:57 +02:00
|
|
|
if (ED_curve_nurb_select_check(v3d, nu)) {
|
2018-12-03 15:26:25 +11:00
|
|
|
changed = true;
|
2020-02-17 10:29:08 +01:00
|
|
|
nu->mat_nr = mat_nr_active;
|
2015-07-09 14:31:27 +10:00
|
|
|
}
|
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ob->type == OB_FONT) {
|
2012-03-29 22:42:32 +00:00
|
|
|
EditFont *ef = ((Curve *)ob->data)->editfont;
|
2010-03-22 09:30:00 +00:00
|
|
|
int i, selstart, selend;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-05 14:52:04 +00:00
|
|
|
if (ef && BKE_vfont_select_get(ob, &selstart, &selend)) {
|
2018-12-03 15:26:25 +11:00
|
|
|
for (i = selstart; i <= selend; i++) {
|
|
|
|
changed = true;
|
2020-02-17 10:29:08 +01:00
|
|
|
ef->textbufinfo[i].mat_nr = mat_nr_active + 1;
|
2018-12-03 15:26:25 +11:00
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
if (changed) {
|
|
|
|
changed_multi = true;
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2018-12-03 15:26:25 +11:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MEM_freeN(objects);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
return (changed_multi) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Assign Material Slot";
|
|
|
|
ot->idname = "OBJECT_OT_material_slot_assign";
|
2012-05-09 19:40:54 +00:00
|
|
|
ot->description = "Assign active material slot to selection";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = material_slot_assign_exec;
|
2020-08-30 13:33:35 +10:00
|
|
|
ot->poll = object_materials_supported_poll;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Material Slot (De)Select Operator
|
|
|
|
* \{ */
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
static int material_slot_de_select(bContext *C, bool select)
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
2018-12-03 15:26:25 +11:00
|
|
|
bool changed_multi = false;
|
2019-03-12 11:57:01 +11:00
|
|
|
Object *obact = CTX_data_active_object(C);
|
2020-02-05 11:23:58 +01:00
|
|
|
const Material *mat_active = obact ? BKE_object_material_get(obact, obact->actcol) : NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
uint objects_len = 0;
|
2020-08-30 13:33:35 +10:00
|
|
|
Object **objects = object_array_for_shading_edit_mode_enabled(C, &objects_len);
|
2018-12-03 15:26:25 +11:00
|
|
|
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
|
|
|
Object *ob = objects[ob_index];
|
2019-03-12 11:57:01 +11:00
|
|
|
short mat_nr_active = -1;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-12 11:57:01 +11:00
|
|
|
if (ob->totcol == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-02-05 11:23:58 +01:00
|
|
|
if (obact && (mat_active == BKE_object_material_get(ob, obact->actcol))) {
|
2019-03-12 11:57:01 +11:00
|
|
|
/* Avoid searching since there may be multiple slots with the same material.
|
|
|
|
* For the active object or duplicates: match the material slot index first. */
|
|
|
|
mat_nr_active = obact->actcol - 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Find the first matching material.
|
2019-08-01 13:53:25 +10:00
|
|
|
* Note: there may be multiple but that's not a common use case. */
|
2020-07-03 16:54:08 +02:00
|
|
|
for (int i = 0; i < ob->totcol; i++) {
|
2020-02-05 11:23:58 +01:00
|
|
|
const Material *mat = BKE_object_material_get(ob, i + 1);
|
2019-03-12 11:57:01 +11:00
|
|
|
if (mat_active == mat) {
|
|
|
|
mat_nr_active = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mat_nr_active == -1) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
if (ob->type == OB_MESH) {
|
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
if (em) {
|
2019-03-12 11:57:01 +11:00
|
|
|
changed = EDBM_deselect_by_material(em, mat_nr_active, select);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-12-03 15:26:25 +11:00
|
|
|
}
|
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
|
|
|
ListBase *nurbs = BKE_curve_editNurbs_get((Curve *)ob->data);
|
|
|
|
Nurb *nu;
|
|
|
|
BPoint *bp;
|
|
|
|
BezTriple *bezt;
|
|
|
|
int a;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
if (nurbs) {
|
|
|
|
for (nu = nurbs->first; nu; nu = nu->next) {
|
2019-03-12 11:57:01 +11:00
|
|
|
if (nu->mat_nr == mat_nr_active) {
|
2018-12-03 15:26:25 +11:00
|
|
|
if (nu->bezt) {
|
|
|
|
a = nu->pntsu;
|
|
|
|
bezt = nu->bezt;
|
|
|
|
while (a--) {
|
|
|
|
if (bezt->hide == 0) {
|
|
|
|
changed = true;
|
|
|
|
if (select) {
|
|
|
|
bezt->f1 |= SELECT;
|
|
|
|
bezt->f2 |= SELECT;
|
|
|
|
bezt->f3 |= SELECT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bezt->f1 &= ~SELECT;
|
|
|
|
bezt->f2 &= ~SELECT;
|
|
|
|
bezt->f3 &= ~SELECT;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-12-03 15:26:25 +11:00
|
|
|
}
|
|
|
|
bezt++;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
2018-12-03 15:26:25 +11:00
|
|
|
else if (nu->bp) {
|
|
|
|
a = nu->pntsu * nu->pntsv;
|
|
|
|
bp = nu->bp;
|
|
|
|
while (a--) {
|
|
|
|
if (bp->hide == 0) {
|
|
|
|
changed = true;
|
2019-04-22 09:19:45 +10:00
|
|
|
if (select) {
|
2018-12-03 15:26:25 +11:00
|
|
|
bp->f1 |= SELECT;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
else {
|
2018-12-03 15:26:25 +11:00
|
|
|
bp->f1 &= ~SELECT;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-12-03 15:26:25 +11:00
|
|
|
}
|
|
|
|
bp++;
|
2010-11-04 15:59:09 +00:00
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
if (changed) {
|
|
|
|
changed_multi = true;
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
|
2018-12-03 15:26:25 +11:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
|
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
MEM_freeN(objects);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-03 15:26:25 +11:00
|
|
|
return (changed_multi) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int material_slot_select_exec(bContext *C, wmOperator *UNUSED(op))
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
2014-04-01 11:34:00 +11:00
|
|
|
return material_slot_de_select(C, true);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_select(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Select Material Slot";
|
|
|
|
ot->idname = "OBJECT_OT_material_slot_select";
|
2012-05-09 19:40:54 +00:00
|
|
|
ot->description = "Select by active material slot";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = material_slot_select_exec;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int material_slot_deselect_exec(bContext *C, wmOperator *UNUSED(op))
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
2014-04-01 11:34:00 +11:00
|
|
|
return material_slot_de_select(C, false);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_deselect(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Deselect Material Slot";
|
|
|
|
ot->idname = "OBJECT_OT_material_slot_deselect";
|
2012-05-09 19:40:54 +00:00
|
|
|
ot->description = "Deselect by active material slot";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = material_slot_deselect_exec;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Material Slot Copy Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-10-07 16:32:55 +00:00
|
|
|
{
|
2018-05-29 15:49:21 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-03-29 22:42:32 +00:00
|
|
|
Object *ob = ED_object_context(C);
|
2020-07-28 18:26:56 +02:00
|
|
|
Material ***matar_obdata;
|
2009-10-07 16:32:55 +00:00
|
|
|
|
2020-07-28 18:26:56 +02:00
|
|
|
if (!ob || !(matar_obdata = BKE_object_material_array_p(ob))) {
|
2009-10-07 16:32:55 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2009-10-07 16:32:55 +00:00
|
|
|
|
2020-07-28 18:26:56 +02:00
|
|
|
BLI_assert(ob->totcol == *BKE_object_material_len_p(ob));
|
|
|
|
|
|
|
|
Material ***matar_object = &ob->mat;
|
|
|
|
|
|
|
|
Material **matar = MEM_callocN(sizeof(*matar) * (size_t)ob->totcol, __func__);
|
|
|
|
for (int i = ob->totcol; i--;) {
|
|
|
|
matar[i] = ob->matbits[i] ? (*matar_object)[i] : (*matar_obdata)[i];
|
|
|
|
}
|
|
|
|
|
2012-04-30 16:22:40 +00:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
|
2020-03-05 08:08:23 +11:00
|
|
|
if (ob != ob_iter && BKE_object_material_array_p(ob_iter)) {
|
2020-07-28 18:26:56 +02:00
|
|
|
/* If we are using the same obdata, we only assign slots in ob_iter that are using object
|
|
|
|
* materials, and not obdata ones. */
|
|
|
|
const bool is_same_obdata = ob->data == ob_iter->data;
|
|
|
|
BKE_object_material_array_assign(bmain, ob_iter, &matar, ob->totcol, is_same_obdata);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ob_iter->totcol == ob->totcol) {
|
|
|
|
ob_iter->actcol = ob->actcol;
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob_iter->id, ID_RECALC_GEOMETRY);
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter);
|
2009-10-07 16:32:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CTX_DATA_END;
|
|
|
|
|
2020-07-28 18:26:56 +02:00
|
|
|
MEM_freeN(matar);
|
|
|
|
|
2009-10-07 16:32:55 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_copy(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2018-11-01 15:57:17 +01:00
|
|
|
ot->name = "Copy Material to Selected";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "OBJECT_OT_material_slot_copy";
|
2018-11-01 15:57:17 +01:00
|
|
|
ot->description = "Copy material to selected objects";
|
2009-10-07 16:32:55 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = material_slot_copy_exec;
|
2009-10-07 16:32:55 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2009-10-07 16:32:55 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Material Slot Move Operator
|
|
|
|
* \{ */
|
|
|
|
|
2015-04-28 07:24:56 +10:00
|
|
|
static int material_slot_move_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Object *ob = ED_object_context(C);
|
|
|
|
|
2020-04-03 16:21:24 +11:00
|
|
|
uint *slot_remap;
|
2015-04-28 07:24:56 +10:00
|
|
|
int index_pair[2];
|
|
|
|
|
|
|
|
int dir = RNA_enum_get(op->ptr, "direction");
|
|
|
|
|
|
|
|
if (!ob || ob->totcol < 2) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* up */
|
|
|
|
if (dir == 1 && ob->actcol > 1) {
|
|
|
|
index_pair[0] = ob->actcol - 2;
|
|
|
|
index_pair[1] = ob->actcol - 1;
|
|
|
|
ob->actcol--;
|
|
|
|
}
|
|
|
|
/* down */
|
|
|
|
else if (dir == -1 && ob->actcol < ob->totcol) {
|
|
|
|
index_pair[0] = ob->actcol - 1;
|
|
|
|
index_pair[1] = ob->actcol - 0;
|
|
|
|
ob->actcol++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2020-04-03 16:21:24 +11:00
|
|
|
slot_remap = MEM_mallocN(sizeof(uint) * ob->totcol, __func__);
|
2015-04-28 07:24:56 +10:00
|
|
|
|
|
|
|
range_vn_u(slot_remap, ob->totcol, 0);
|
|
|
|
|
|
|
|
slot_remap[index_pair[0]] = index_pair[1];
|
|
|
|
slot_remap[index_pair[1]] = index_pair[0];
|
|
|
|
|
2020-03-05 08:08:23 +11:00
|
|
|
BKE_object_material_remap(ob, slot_remap);
|
2015-04-28 07:24:56 +10:00
|
|
|
|
|
|
|
MEM_freeN(slot_remap);
|
|
|
|
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2018-01-25 10:10:21 -02:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
|
2015-04-28 07:24:56 +10:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_move(wmOperatorType *ot)
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem material_slot_move[] = {
|
2015-04-28 07:24:56 +10:00
|
|
|
{1, "UP", 0, "Up", ""},
|
|
|
|
{-1, "DOWN", 0, "Down", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2015-04-28 07:24:56 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Move Material";
|
|
|
|
ot->idname = "OBJECT_OT_material_slot_move";
|
|
|
|
ot->description = "Move the active material up/down in the list";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = material_slot_move_exec;
|
2020-08-30 13:33:35 +10:00
|
|
|
ot->poll = object_materials_supported_poll;
|
2015-04-28 07:24:56 +10:00
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
2016-09-16 17:03:44 +02:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
"direction",
|
|
|
|
material_slot_move,
|
|
|
|
0,
|
|
|
|
"Direction",
|
|
|
|
"Direction to move the active material towards");
|
2015-04-28 07:24:56 +10:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Material Slot Remove Unused Operator
|
|
|
|
* \{ */
|
|
|
|
|
2019-07-31 12:04:52 -07:00
|
|
|
static int material_slot_remove_unused_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2020-09-30 20:09:02 +10:00
|
|
|
/* Removing material slots in edit mode screws things up, see bug T21822. */
|
2020-08-30 13:33:35 +10:00
|
|
|
Object *ob_active = CTX_data_active_object(C);
|
|
|
|
if (ob_active && BKE_object_is_in_editmode(ob_active)) {
|
2019-07-31 12:04:52 -07:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2020-08-30 13:33:35 +10:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2019-07-31 12:04:52 -07:00
|
|
|
int removed = 0;
|
|
|
|
|
2020-08-30 13:33:35 +10:00
|
|
|
uint objects_len = 0;
|
|
|
|
Object **objects = object_array_for_shading_edit_mode_disabled(C, &objects_len);
|
|
|
|
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
|
|
|
Object *ob = objects[ob_index];
|
|
|
|
int actcol = ob->actcol;
|
|
|
|
for (int slot = 1; slot <= ob->totcol; slot++) {
|
|
|
|
while (slot <= ob->totcol && !BKE_object_material_slot_used(ob->data, slot)) {
|
|
|
|
ob->actcol = slot;
|
|
|
|
BKE_object_material_slot_remove(bmain, ob);
|
|
|
|
|
|
|
|
if (actcol >= slot) {
|
|
|
|
actcol--;
|
|
|
|
}
|
2019-07-31 12:04:52 -07:00
|
|
|
|
2020-08-30 13:33:35 +10:00
|
|
|
removed++;
|
|
|
|
}
|
2019-07-31 12:04:52 -07:00
|
|
|
}
|
2020-08-30 13:33:35 +10:00
|
|
|
ob->actcol = actcol;
|
2019-07-31 12:04:52 -07:00
|
|
|
|
2020-08-30 13:33:35 +10:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
|
|
|
}
|
|
|
|
MEM_freeN(objects);
|
2019-07-31 12:04:52 -07:00
|
|
|
|
|
|
|
if (!removed) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
BKE_reportf(op->reports, RPT_INFO, "Removed %d slots", removed);
|
|
|
|
|
2020-08-30 13:33:35 +10:00
|
|
|
if (ob_active->mode & OB_MODE_TEXTURE_PAINT) {
|
2019-07-31 12:04:52 -07:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-09-21 14:43:29 +02:00
|
|
|
ED_paint_proj_mesh_data_check(scene, ob_active, NULL, NULL, NULL, NULL);
|
2019-07-31 12:04:52 -07:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
|
|
|
}
|
|
|
|
|
2020-08-30 13:33:35 +10:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_active);
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob_active);
|
|
|
|
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob_active);
|
2019-07-31 12:04:52 -07:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_remove_unused(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Remove Unused Slots";
|
|
|
|
ot->idname = "OBJECT_OT_material_slot_remove_unused";
|
|
|
|
ot->description = "Remove unused material slots";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = material_slot_remove_unused_exec;
|
2020-08-30 13:33:35 +10:00
|
|
|
ot->poll = object_materials_supported_poll;
|
2019-07-31 12:04:52 -07:00
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
/** \name Create Material Operators
|
2020-08-25 15:10:36 +10:00
|
|
|
* \{ */
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
struct MaterialCreationData {
|
|
|
|
Object *ob;
|
|
|
|
PropertyPointerRNA pprop;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void material_creation_data_init_from_UI_context(bContext *C,
|
|
|
|
struct MaterialCreationData *r_create_data)
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
PointerRNA ptr;
|
2009-10-01 23:32:57 +00:00
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-03 12:33:12 +11:00
|
|
|
/* hook into UI */
|
|
|
|
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
r_create_data->ob = (prop && RNA_struct_is_a(ptr.type, &RNA_Object)) ? ptr.data : NULL;
|
|
|
|
r_create_data->pprop.ptr = ptr;
|
|
|
|
r_create_data->pprop.prop = prop;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
static void material_creation_assign(bContext *C,
|
|
|
|
Material *ma,
|
|
|
|
struct MaterialCreationData *create_data)
|
|
|
|
{
|
|
|
|
Main *bmain = CTX_data_main(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
if (create_data->pprop.prop) {
|
|
|
|
if (create_data->ob != NULL) {
|
2019-01-03 12:15:03 +11:00
|
|
|
/* Add slot follows user-preferences for creating new slots,
|
|
|
|
* RNA pointer assignment doesn't, see: T60014. */
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
if (BKE_object_material_get_p(create_data->ob, create_data->ob->actcol) == NULL) {
|
|
|
|
BKE_object_material_slot_add(bmain, create_data->ob);
|
2019-01-03 12:15:03 +11:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-01 23:32:57 +00:00
|
|
|
/* when creating new ID blocks, use is already 1, but RNA
|
2015-08-23 21:12:48 +10:00
|
|
|
* pointer use also increases user, so this compensates it */
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&ma->id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
PointerRNA idptr;
|
2009-10-01 23:32:57 +00:00
|
|
|
RNA_id_pointer_create(&ma->id, &idptr);
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
RNA_property_pointer_set(&create_data->pprop.ptr, create_data->pprop.prop, idptr, NULL);
|
|
|
|
RNA_property_update(C, &create_data->pprop.ptr, create_data->pprop.prop);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
struct MaterialCreationData create_data;
|
|
|
|
|
|
|
|
material_creation_data_init_from_UI_context(C, &create_data);
|
|
|
|
|
|
|
|
const char *name = DATA_("Material");
|
|
|
|
Material *ma;
|
|
|
|
if ((create_data.ob == NULL) || (create_data.ob->type != OB_GPENCIL)) {
|
|
|
|
ma = BKE_material_add(bmain, name);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ma = BKE_gpencil_material_add(bmain, name);
|
|
|
|
}
|
|
|
|
ED_node_shader_default(C, &ma->id);
|
|
|
|
ma->use_nodes = true;
|
|
|
|
|
|
|
|
material_creation_assign(C, ma, &create_data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_MATERIAL | NA_ADDED, ma);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MATERIAL_OT_new(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "New Material";
|
|
|
|
ot->idname = "MATERIAL_OT_new";
|
|
|
|
ot->description = "Add a new material";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = new_material_exec;
|
2020-08-30 13:33:35 +10:00
|
|
|
ot->poll = object_materials_supported_poll;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
static int duplicate_material_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Material *old_ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
|
|
|
|
|
|
|
|
if (!old_ma) {
|
|
|
|
BKE_report(
|
|
|
|
op->reports,
|
|
|
|
RPT_ERROR,
|
|
|
|
"Incorrect context for duplicating a material (did not find material to duplicate)");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
struct MaterialCreationData create_data;
|
|
|
|
|
|
|
|
material_creation_data_init_from_UI_context(C, &create_data);
|
|
|
|
|
|
|
|
Material *new_ma = (Material *)BKE_id_copy_ex(
|
|
|
|
bmain, &old_ma->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
|
|
|
|
|
|
|
|
material_creation_assign(C, new_ma, &create_data);
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_MATERIAL | NA_ADDED, new_ma);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MATERIAL_OT_duplicate(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Duplicate Material";
|
|
|
|
ot->idname = "MATERIAL_OT_duplicate";
|
|
|
|
ot->description = "Duplicate an existing material";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = duplicate_material_exec;
|
|
|
|
ot->poll = object_materials_supported_poll;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
|
|
|
}
|
2020-08-25 15:10:36 +10:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
/** \name Create Texture Operators
|
2020-08-25 15:10:36 +10:00
|
|
|
* \{ */
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
static void texture_creation_assign(bContext *C, Tex *tex)
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
2009-10-01 23:32:57 +00:00
|
|
|
PointerRNA ptr, idptr;
|
|
|
|
PropertyRNA *prop;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2009-10-01 23:32:57 +00:00
|
|
|
/* hook into UI */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (prop) {
|
2009-10-01 23:32:57 +00:00
|
|
|
/* when creating new ID blocks, use is already 1, but RNA
|
2016-07-21 07:14:47 +10:00
|
|
|
* pointer use also increases user, so this compensates it */
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&tex->id);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2009-10-01 23:32:57 +00:00
|
|
|
RNA_id_pointer_create(&tex->id, &idptr);
|
2019-05-20 18:06:09 +10:00
|
|
|
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
|
2009-10-01 23:32:57 +00:00
|
|
|
RNA_property_update(C, &ptr, prop);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Tex *tex = BKE_texture_add(bmain, DATA_("Texture"));
|
|
|
|
|
|
|
|
texture_creation_assign(C, tex);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, tex);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TEXTURE_OT_new(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "New Texture";
|
|
|
|
ot->idname = "TEXTURE_OT_new";
|
|
|
|
ot->description = "Add a new texture";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = new_texture_exec;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
static int duplicate_texture_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
|
|
|
|
|
|
|
|
if (!tex) {
|
|
|
|
BKE_report(op->reports,
|
|
|
|
RPT_ERROR,
|
|
|
|
"Incorrect context for duplicating a texture (did not find texture to duplicate)");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add or copy texture */
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
tex = (Tex *)BKE_id_copy(bmain, &tex->id);
|
|
|
|
|
|
|
|
texture_creation_assign(C, tex);
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, tex);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TEXTURE_OT_duplicate(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Duplicate Texture";
|
|
|
|
ot->idname = "TEXTURE_OT_duplicate";
|
|
|
|
ot->description = "Duplicate an existing texture";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = duplicate_texture_exec;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
/** \name Create world operators
|
2020-08-25 15:10:36 +10:00
|
|
|
* \{ */
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
static void world_creation_assign(bContext *C, World *wo)
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
2009-10-01 23:32:57 +00:00
|
|
|
PointerRNA ptr, idptr;
|
|
|
|
PropertyRNA *prop;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2009-10-01 23:32:57 +00:00
|
|
|
/* hook into UI */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
|
2009-10-01 23:32:57 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (prop) {
|
2009-10-01 23:32:57 +00:00
|
|
|
/* when creating new ID blocks, use is already 1, but RNA
|
2016-07-21 07:14:47 +10:00
|
|
|
* pointer use also increases user, so this compensates it */
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&wo->id);
|
2009-10-01 23:32:57 +00:00
|
|
|
|
|
|
|
RNA_id_pointer_create(&wo->id, &idptr);
|
2019-05-20 18:06:09 +10:00
|
|
|
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
|
2009-10-01 23:32:57 +00:00
|
|
|
RNA_property_update(C, &ptr, prop);
|
|
|
|
}
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
|
|
|
World *wo = BKE_world_add(bmain, DATA_("World"));
|
|
|
|
ED_node_shader_default(C, &wo->id);
|
|
|
|
wo->use_nodes = true;
|
|
|
|
|
|
|
|
world_creation_assign(C, wo);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_WORLD | NA_ADDED, wo);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WORLD_OT_new(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "New World";
|
|
|
|
ot->idname = "WORLD_OT_new";
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
ot->description = "Create a new world data-block";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = new_world_exec;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
static int duplicate_world_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
|
|
|
|
|
|
|
|
if (wo) {
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
wo = (World *)BKE_id_copy(bmain, &wo->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
world_creation_assign(C, wo);
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_WORLD | NA_ADDED, wo);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WORLD_OT_duplicate(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Duplicate World";
|
|
|
|
ot->idname = "WORLD_OT_duplicate";
|
|
|
|
ot->description = "Duplicate an existing world data-block";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = duplicate_world_exec;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Render Layer Add Operator
|
|
|
|
* \{ */
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2020-03-26 19:33:27 +01:00
|
|
|
static int view_layer_add_exec(bContext *C, wmOperator *op)
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
2018-07-04 13:00:46 +02:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2012-03-29 22:42:32 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-03-26 19:33:27 +01:00
|
|
|
ViewLayer *view_layer_current = WM_window_get_active_view_layer(win);
|
|
|
|
ViewLayer *view_layer_new = BKE_view_layer_add(
|
|
|
|
scene, view_layer_current->name, view_layer_current, RNA_enum_get(op->ptr, "type"));
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2018-07-04 13:00:46 +02:00
|
|
|
if (win) {
|
2020-03-26 19:33:27 +01:00
|
|
|
WM_window_set_active_view_layer(win, view_layer_new);
|
2018-04-24 15:20:17 +02:00
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&scene->id, 0);
|
|
|
|
DEG_relations_tag_update(CTX_data_main(C));
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
void SCENE_OT_view_layer_add(wmOperatorType *ot)
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
2020-03-26 19:33:27 +01:00
|
|
|
static EnumPropertyItem type_items[] = {
|
|
|
|
{VIEWLAYER_ADD_NEW, "NEW", 0, "New", "Add a new view layer"},
|
|
|
|
{VIEWLAYER_ADD_COPY, "COPY", 0, "Copy Settings", "Copy settings of current view layer"},
|
|
|
|
{VIEWLAYER_ADD_EMPTY,
|
|
|
|
"EMPTY",
|
|
|
|
0,
|
|
|
|
"Blank",
|
|
|
|
"Add a new view layer with all collections disabled"},
|
|
|
|
{0, NULL, 0, NULL, NULL},
|
|
|
|
};
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* identifiers */
|
2017-11-22 10:52:39 -02:00
|
|
|
ot->name = "Add View Layer";
|
|
|
|
ot->idname = "SCENE_OT_view_layer_add";
|
|
|
|
ot->description = "Add a view layer";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* api callbacks */
|
2017-11-22 10:52:39 -02:00
|
|
|
ot->exec = view_layer_add_exec;
|
2020-03-26 19:33:27 +01:00
|
|
|
ot->invoke = WM_menu_invoke;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2020-03-26 19:33:27 +01:00
|
|
|
|
|
|
|
/* properties */
|
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Render Layer Remove Operator
|
|
|
|
* \{ */
|
|
|
|
|
2019-01-22 20:34:06 +01:00
|
|
|
static bool view_layer_remove_poll(bContext *C)
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
return (scene->view_layers.first != scene->view_layers.last);
|
|
|
|
}
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
static int view_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
2017-06-09 17:16:39 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2011-11-18 07:11:54 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
if (!ED_scene_view_layer_delete(bmain, scene, view_layer, NULL)) {
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
}
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
2017-06-09 17:16:39 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
void SCENE_OT_view_layer_remove(wmOperatorType *ot)
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2017-11-22 10:52:39 -02:00
|
|
|
ot->name = "Remove View Layer";
|
|
|
|
ot->idname = "SCENE_OT_view_layer_remove";
|
|
|
|
ot->description = "Remove the selected view layer";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
/* api callbacks */
|
2017-11-22 10:52:39 -02:00
|
|
|
ot->exec = view_layer_remove_exec;
|
2019-01-22 20:34:06 +01:00
|
|
|
ot->poll = view_layer_remove_poll;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
2020-12-04 08:13:54 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name View Layer Add AOV Operator
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
static int view_layer_add_aov_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
|
|
|
|
BKE_view_layer_add_aov(view_layer);
|
|
|
|
|
|
|
|
RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
|
|
|
|
if (engine_type->update_render_passes) {
|
|
|
|
RenderEngine *engine = RE_engine_create(engine_type);
|
|
|
|
if (engine) {
|
|
|
|
BKE_view_layer_verify_aov(engine, scene, view_layer);
|
|
|
|
}
|
|
|
|
RE_engine_free(engine);
|
|
|
|
engine = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEG_id_tag_update(&scene->id, 0);
|
|
|
|
DEG_relations_tag_update(CTX_data_main(C));
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_view_layer_add_aov(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Add AOV";
|
|
|
|
ot->idname = "SCENE_OT_view_layer_add_aov";
|
|
|
|
ot->description = "Add a Shader AOV";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = view_layer_add_aov_exec;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name View Layer Remove AOV Operator
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
static int view_layer_remove_aov_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
BKE_view_layer_remove_aov(view_layer, view_layer->active_aov);
|
|
|
|
|
|
|
|
RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
|
|
|
|
if (engine_type->update_render_passes) {
|
|
|
|
RenderEngine *engine = RE_engine_create(engine_type);
|
|
|
|
if (engine) {
|
|
|
|
BKE_view_layer_verify_aov(engine, scene, view_layer);
|
|
|
|
}
|
|
|
|
RE_engine_free(engine);
|
|
|
|
engine = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEG_id_tag_update(&scene->id, 0);
|
|
|
|
DEG_relations_tag_update(CTX_data_main(C));
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_view_layer_remove_aov(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Remove AOV";
|
|
|
|
ot->idname = "SCENE_OT_view_layer_remove_aov";
|
|
|
|
ot->description = "Remove Active AOV";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = view_layer_remove_aov_exec;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Light Cache Bake Operator
|
|
|
|
* \{ */
|
|
|
|
|
2018-07-10 15:02:25 +02:00
|
|
|
enum {
|
|
|
|
LIGHTCACHE_SUBSET_ALL = 0,
|
|
|
|
LIGHTCACHE_SUBSET_DIRTY,
|
|
|
|
LIGHTCACHE_SUBSET_CUBE,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void light_cache_bake_tag_cache(Scene *scene, wmOperator *op)
|
|
|
|
{
|
2020-03-11 17:12:01 +01:00
|
|
|
if (scene->eevee.light_cache_data != NULL) {
|
2018-07-10 15:02:25 +02:00
|
|
|
int subset = RNA_enum_get(op->ptr, "subset");
|
|
|
|
switch (subset) {
|
|
|
|
case LIGHTCACHE_SUBSET_ALL:
|
2020-03-11 17:12:01 +01:00
|
|
|
scene->eevee.light_cache_data->flag |= LIGHTCACHE_UPDATE_GRID | LIGHTCACHE_UPDATE_CUBE;
|
2018-07-10 15:02:25 +02:00
|
|
|
break;
|
|
|
|
case LIGHTCACHE_SUBSET_CUBE:
|
2020-03-11 17:12:01 +01:00
|
|
|
scene->eevee.light_cache_data->flag |= LIGHTCACHE_UPDATE_CUBE;
|
2018-07-10 15:02:25 +02:00
|
|
|
break;
|
|
|
|
case LIGHTCACHE_SUBSET_DIRTY:
|
|
|
|
/* Leave tag untouched. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* catch esc */
|
|
|
|
static int light_cache_bake_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|
|
|
{
|
|
|
|
Scene *scene = (Scene *)op->customdata;
|
|
|
|
|
|
|
|
/* no running blender, remove handler and pass through */
|
|
|
|
if (0 == WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) {
|
2020-08-04 19:52:18 +02:00
|
|
|
LightCache *lcache = scene->eevee.light_cache_data;
|
|
|
|
if (lcache && (lcache->flag & LIGHTCACHE_INVALID)) {
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Lightcache cannot allocate resources");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2018-07-10 15:02:25 +02:00
|
|
|
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* running render */
|
|
|
|
switch (event->type) {
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_ESCKEY:
|
2018-07-10 15:02:25 +02:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void light_cache_bake_cancel(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
Scene *scene = (Scene *)op->customdata;
|
|
|
|
|
|
|
|
/* kill on cancel, because job is using op->reports */
|
|
|
|
WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_RENDER);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* executes blocking render */
|
|
|
|
static int light_cache_bake_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
|
|
G.is_break = false;
|
|
|
|
|
|
|
|
/* TODO abort if selected engine is not eevee. */
|
2019-03-27 20:47:15 +01:00
|
|
|
void *rj = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, false, scene->r.cfra);
|
2018-07-10 15:02:25 +02:00
|
|
|
|
|
|
|
light_cache_bake_tag_cache(scene, op);
|
|
|
|
|
|
|
|
short stop = 0, do_update;
|
|
|
|
float progress; /* Not actually used. */
|
|
|
|
EEVEE_lightbake_job(rj, &stop, &do_update, &progress);
|
|
|
|
EEVEE_lightbake_job_data_free(rj);
|
|
|
|
|
|
|
|
/* No redraw needed, we leave state as we entered it. */
|
2019-07-25 16:36:22 +02:00
|
|
|
ED_update_for_newframe(bmain, CTX_data_depsgraph_pointer(C));
|
2018-07-10 15:02:25 +02:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int light_cache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
|
|
|
{
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
int delay = RNA_int_get(op->ptr, "delay");
|
|
|
|
|
2019-03-27 20:47:15 +01:00
|
|
|
wmJob *wm_job = EEVEE_lightbake_job_create(
|
|
|
|
wm, win, bmain, view_layer, scene, delay, scene->r.cfra);
|
2018-07-10 15:02:25 +02:00
|
|
|
|
|
|
|
if (!wm_job) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add modal handler for ESC */
|
|
|
|
WM_event_add_modal_handler(C, op);
|
|
|
|
|
|
|
|
light_cache_bake_tag_cache(scene, op);
|
|
|
|
|
|
|
|
/* store actual owner of job, so modal operator could check for it,
|
|
|
|
* the reason of this is that active scene could change when rendering
|
2020-09-30 20:09:02 +10:00
|
|
|
* several layers from compositor T31800. */
|
2018-07-10 15:02:25 +02:00
|
|
|
op->customdata = scene;
|
|
|
|
|
|
|
|
WM_jobs_start(wm, wm_job);
|
|
|
|
|
|
|
|
WM_cursor_wait(0);
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_light_cache_bake(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
static const EnumPropertyItem light_cache_subset_items[] = {
|
2019-03-15 08:53:22 +11:00
|
|
|
{LIGHTCACHE_SUBSET_ALL,
|
|
|
|
"ALL",
|
|
|
|
0,
|
2020-12-24 13:11:22 -06:00
|
|
|
"All Light Probes",
|
2019-03-15 08:53:22 +11:00
|
|
|
"Bake both irradiance grids and reflection cubemaps"},
|
|
|
|
{LIGHTCACHE_SUBSET_DIRTY,
|
|
|
|
"DIRTY",
|
|
|
|
0,
|
|
|
|
"Dirty Only",
|
2020-12-24 13:11:22 -06:00
|
|
|
"Only bake light probes that are marked as dirty"},
|
2019-03-15 08:53:22 +11:00
|
|
|
{LIGHTCACHE_SUBSET_CUBE,
|
|
|
|
"CUBEMAPS",
|
|
|
|
0,
|
|
|
|
"Cubemaps Only",
|
|
|
|
"Try to only bake reflection cubemaps if irradiance grids are up to date"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2018-07-10 15:02:25 +02:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-10 15:02:25 +02:00
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Bake Light Cache";
|
|
|
|
ot->idname = "SCENE_OT_light_cache_bake";
|
|
|
|
ot->description = "Bake the active view layer lighting";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-10 15:02:25 +02:00
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke = light_cache_bake_invoke;
|
|
|
|
ot->modal = light_cache_bake_modal;
|
|
|
|
ot->cancel = light_cache_bake_cancel;
|
|
|
|
ot->exec = light_cache_bake_exec;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-10 15:02:25 +02:00
|
|
|
ot->prop = RNA_def_int(ot->srna,
|
|
|
|
"delay",
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
2000,
|
|
|
|
"Delay",
|
|
|
|
"Delay in millisecond before baking starts",
|
|
|
|
0,
|
|
|
|
2000);
|
|
|
|
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-10 15:02:25 +02:00
|
|
|
ot->prop = RNA_def_enum(
|
|
|
|
ot->srna, "subset", light_cache_subset_items, 0, "Subset", "Subset of probes to update");
|
|
|
|
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
|
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Light Cache Free Operator
|
|
|
|
* \{ */
|
|
|
|
|
2018-07-10 15:02:25 +02:00
|
|
|
static bool light_cache_free_poll(bContext *C)
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
2020-03-11 17:12:01 +01:00
|
|
|
return scene->eevee.light_cache_data;
|
2018-07-10 15:02:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int light_cache_free_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
2018-10-04 11:24:17 +02:00
|
|
|
/* kill potential bake job first (see T57011) */
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_LIGHT_BAKE);
|
|
|
|
|
2020-03-11 17:12:01 +01:00
|
|
|
if (!scene->eevee.light_cache_data) {
|
2018-07-10 15:02:25 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2020-03-11 17:12:01 +01:00
|
|
|
EEVEE_lightcache_free(scene->eevee.light_cache_data);
|
|
|
|
scene->eevee.light_cache_data = NULL;
|
2018-07-10 15:02:25 +02:00
|
|
|
|
|
|
|
EEVEE_lightcache_info_update(&scene->eevee);
|
|
|
|
|
2018-12-06 17:52:37 +01:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
|
2018-07-10 15:02:25 +02:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_light_cache_free(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2019-01-31 19:49:47 +01:00
|
|
|
ot->name = "Delete Light Cache";
|
2018-07-10 15:02:25 +02:00
|
|
|
ot->idname = "SCENE_OT_light_cache_free";
|
2019-01-31 19:49:47 +01:00
|
|
|
ot->description = "Delete cached indirect lighting";
|
2018-07-10 15:02:25 +02:00
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = light_cache_free_exec;
|
|
|
|
ot->poll = light_cache_free_poll;
|
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Render View Remove Operator
|
|
|
|
* \{ */
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool render_view_remove_poll(bContext *C)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
|
|
/* don't allow user to remove "left" and "right" views */
|
|
|
|
return scene->r.actview > 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int render_view_add_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
|
|
BKE_scene_add_render_view(scene, NULL);
|
|
|
|
scene->r.actview = BLI_listbase_count(&scene->r.views) - 1;
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_render_view_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Add Render View";
|
|
|
|
ot->idname = "SCENE_OT_render_view_add";
|
|
|
|
ot->description = "Add a render view";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = render_view_add_exec;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Render View Add Operator
|
|
|
|
* \{ */
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static int render_view_remove_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderView *rv = BLI_findlink(&scene->r.views, scene->r.actview);
|
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!BKE_scene_remove_render_view(scene, rv)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_render_view_remove(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Remove Render View";
|
|
|
|
ot->idname = "SCENE_OT_render_view_remove";
|
|
|
|
ot->description = "Remove the selected render view";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = render_view_remove_exec;
|
|
|
|
ot->poll = render_view_remove_poll;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2013-03-23 03:00:37 +00:00
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Module Add Operator
|
|
|
|
* \{ */
|
|
|
|
|
2013-10-01 02:51:39 +00:00
|
|
|
static bool freestyle_linestyle_check_report(FreestyleLineSet *lineset, ReportList *reports)
|
|
|
|
{
|
|
|
|
if (!lineset) {
|
2014-06-05 22:58:51 +09:00
|
|
|
BKE_report(reports,
|
|
|
|
RPT_ERROR,
|
|
|
|
"No active lineset and associated line style to manipulate the modifier");
|
2013-10-01 02:51:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!lineset->linestyle) {
|
|
|
|
BKE_report(reports,
|
|
|
|
RPT_ERROR,
|
|
|
|
"The active lineset does not have a line style (indicating data corruption)");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool freestyle_active_module_poll(bContext *C)
|
2013-04-08 07:07:10 +00:00
|
|
|
{
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
|
|
|
|
FreestyleModuleConfig *module = ptr.data;
|
|
|
|
|
|
|
|
return module != NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-16 21:11:39 +00:00
|
|
|
static int freestyle_module_add_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-10-07 05:16:23 +00:00
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
BKE_freestyle_module_add(&view_layer->freestyle_config);
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2012-12-11 22:00:22 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
|
|
|
|
2009-10-07 05:16:23 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_module_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Add Freestyle Module";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_module_add";
|
|
|
|
ot->description = "Add a style module into the list of modules";
|
|
|
|
|
2009-10-07 05:16:23 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_module_add_exec;
|
2009-10-07 05:16:23 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2009-10-07 05:16:23 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Module Remove Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-12-16 21:11:39 +00:00
|
|
|
static int freestyle_module_remove_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-10-07 05:16:23 +00:00
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2012-12-11 22:00:22 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
|
|
|
|
FreestyleModuleConfig *module = ptr.data;
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
BKE_freestyle_module_delete(&view_layer->freestyle_config, module);
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&scene->id, 0);
|
2012-12-11 22:00:22 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
|
|
|
|
2009-10-07 05:16:23 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_module_remove(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Remove Freestyle Module";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_module_remove";
|
|
|
|
ot->description = "Remove the style module from the stack";
|
|
|
|
|
2009-10-07 05:16:23 +00:00
|
|
|
/* api callbacks */
|
2013-04-08 07:07:10 +00:00
|
|
|
ot->poll = freestyle_active_module_poll;
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_module_remove_exec;
|
2009-10-07 05:16:23 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2009-10-07 05:16:23 +00:00
|
|
|
}
|
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
static int freestyle_module_move_exec(bContext *C, wmOperator *op)
|
2009-10-07 05:16:23 +00:00
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2012-12-11 22:00:22 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
|
|
|
|
FreestyleModuleConfig *module = ptr.data;
|
|
|
|
int dir = RNA_enum_get(op->ptr, "direction");
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
if (BKE_freestyle_module_move(&view_layer->freestyle_config, module, dir)) {
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&scene->id, 0);
|
2016-09-18 21:36:34 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
2012-12-11 22:00:22 +00:00
|
|
|
}
|
|
|
|
|
2009-10-07 05:16:23 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Module Move Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
void SCENE_OT_freestyle_module_move(wmOperatorType *ot)
|
2009-10-07 05:16:23 +00:00
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem direction_items[] = {
|
2016-09-18 21:36:34 +02:00
|
|
|
{-1, "UP", 0, "Up", ""},
|
|
|
|
{1, "DOWN", 0, "Down", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2010-06-25 22:45:42 +00:00
|
|
|
};
|
|
|
|
|
2009-10-07 05:16:23 +00:00
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Move Freestyle Module";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_module_move";
|
|
|
|
ot->description = "Change the position of the style module within in the list of style modules";
|
|
|
|
|
2009-10-07 05:16:23 +00:00
|
|
|
/* api callbacks */
|
2013-04-08 07:07:10 +00:00
|
|
|
ot->poll = freestyle_active_module_poll;
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_module_move_exec;
|
2009-10-07 05:16:23 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2009-10-07 05:16:23 +00:00
|
|
|
|
|
|
|
/* props */
|
2016-09-16 17:03:44 +02:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
"direction",
|
|
|
|
direction_items,
|
|
|
|
0,
|
|
|
|
"Direction",
|
|
|
|
"Direction to move the chosen style module towards");
|
2009-10-07 05:16:23 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Line Set Add Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-12-16 21:11:39 +00:00
|
|
|
static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-10-07 05:16:23 +00:00
|
|
|
{
|
2015-03-19 14:33:05 +11:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
BKE_freestyle_lineset_add(bmain, &view_layer->freestyle_config, NULL);
|
2010-06-25 22:45:42 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&scene->id, 0);
|
2012-12-11 22:00:22 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_lineset_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Add Line Set";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_lineset_add";
|
|
|
|
ot->description = "Add a line set into the list of line sets";
|
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_lineset_add_exec;
|
2010-06-25 22:45:42 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2010-06-25 22:45:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Line Set Copy Operator
|
|
|
|
* \{ */
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool freestyle_active_lineset_poll(bContext *C)
|
2010-07-20 17:57:33 +00:00
|
|
|
{
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2010-07-20 17:57:33 +00:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
if (!view_layer) {
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2013-10-18 09:45:21 +00:00
|
|
|
}
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
return BKE_freestyle_lineset_get_active(&view_layer->freestyle_config) != NULL;
|
2010-07-20 17:57:33 +00:00
|
|
|
}
|
|
|
|
|
2012-12-08 22:24:41 +00:00
|
|
|
static int freestyle_lineset_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
2011-11-13 21:55:13 +00:00
|
|
|
{
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2011-11-13 21:55:13 +00:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
FRS_copy_active_lineset(&view_layer->freestyle_config);
|
2011-11-13 21:55:13 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Copy Line Set";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_lineset_copy";
|
|
|
|
ot->description = "Copy the active line set to a buffer";
|
|
|
|
|
2011-11-13 21:55:13 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_lineset_copy_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
2011-11-13 21:55:13 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2011-11-13 21:55:13 +00:00
|
|
|
}
|
2011-11-20 23:44:50 +00:00
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Line Set Paste Operator
|
|
|
|
* \{ */
|
|
|
|
|
2012-12-08 22:24:41 +00:00
|
|
|
static int freestyle_lineset_paste_exec(bContext *C, wmOperator *UNUSED(op))
|
2011-11-20 23:44:50 +00:00
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2011-11-20 23:44:50 +00:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
FRS_paste_active_lineset(&view_layer->freestyle_config);
|
2011-11-20 23:44:50 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&scene->id, 0);
|
2012-12-11 22:00:22 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
|
|
|
|
2011-11-20 23:44:50 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_lineset_paste(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Paste Line Set";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_lineset_paste";
|
|
|
|
ot->description = "Paste the buffer content to the active line set";
|
|
|
|
|
2011-11-20 23:44:50 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_lineset_paste_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
2011-11-20 23:44:50 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2011-11-20 23:44:50 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Line Set Remove Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-12-16 21:11:39 +00:00
|
|
|
static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-06-25 22:45:42 +00:00
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2010-06-25 22:45:42 +00:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
FRS_delete_active_lineset(&view_layer->freestyle_config);
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&scene->id, 0);
|
2012-12-11 22:00:22 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
|
|
|
|
2009-10-07 05:16:23 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
void SCENE_OT_freestyle_lineset_remove(wmOperatorType *ot)
|
2009-10-07 05:16:23 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Remove Line Set";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_lineset_remove";
|
|
|
|
ot->description = "Remove the active line set from the list of line sets";
|
|
|
|
|
2009-10-07 05:16:23 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_lineset_remove_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
2010-06-25 22:45:42 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2010-06-25 22:45:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Line Set Move Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
static int freestyle_lineset_move_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2012-12-11 22:00:22 +00:00
|
|
|
int dir = RNA_enum_get(op->ptr, "direction");
|
2010-06-25 22:45:42 +00:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
if (FRS_move_active_lineset(&view_layer->freestyle_config, dir)) {
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&scene->id, 0);
|
2016-09-18 21:36:34 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
2010-06-25 22:45:42 +00:00
|
|
|
}
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot)
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem direction_items[] = {
|
2016-09-18 21:36:34 +02:00
|
|
|
{-1, "UP", 0, "Up", ""},
|
|
|
|
{1, "DOWN", 0, "Down", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2010-06-25 22:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Move Line Set";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_lineset_move";
|
|
|
|
ot->description = "Change the position of the active line set within the list of line sets";
|
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_lineset_move_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
2009-10-07 05:16:23 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2009-10-07 05:16:23 +00:00
|
|
|
|
|
|
|
/* props */
|
2016-09-16 17:03:44 +02:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
"direction",
|
|
|
|
direction_items,
|
|
|
|
0,
|
|
|
|
"Direction",
|
|
|
|
"Direction to move the active line set towards");
|
2010-06-25 22:45:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Line Set New Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2015-03-19 14:33:05 +11:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2017-11-22 10:52:39 -02:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config);
|
2010-06-25 22:45:42 +00:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
if (!lineset) {
|
2012-12-11 22:00:22 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "No active lineset to add a new line style to");
|
2010-07-20 17:57:33 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2013-09-30 23:02:29 +00:00
|
|
|
if (lineset->linestyle) {
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&lineset->linestyle->id);
|
2020-10-07 18:01:25 +02:00
|
|
|
lineset->linestyle = (FreestyleLineStyle *)BKE_id_copy(bmain, &lineset->linestyle->id);
|
2013-10-01 03:56:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-03-19 14:33:05 +11:00
|
|
|
lineset->linestyle = BKE_linestyle_new(bmain, "LineStyle");
|
2013-09-30 23:02:29 +00:00
|
|
|
}
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&lineset->linestyle->id, 0);
|
2014-06-06 00:56:04 +09:00
|
|
|
WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_linestyle_new(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "New Line Style";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_linestyle_new";
|
|
|
|
ot->description = "Create a new line style, reusable by multiple line sets";
|
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_linestyle_new_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
2010-07-20 17:57:33 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2010-07-20 17:57:33 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Modifier Add "Color" Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2017-11-22 10:52:39 -02:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config);
|
2012-12-11 22:00:22 +00:00
|
|
|
int type = RNA_enum_get(op->ptr, "type");
|
2010-07-20 17:57:33 +00:00
|
|
|
|
2013-10-01 02:51:39 +00:00
|
|
|
if (!freestyle_linestyle_check_report(lineset, op->reports)) {
|
2013-09-30 23:02:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2013-10-01 02:51:39 +00:00
|
|
|
|
2014-07-17 09:23:30 +09:00
|
|
|
if (BKE_linestyle_color_modifier_add(lineset->linestyle, NULL, type) == NULL) {
|
2013-04-07 10:21:22 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type");
|
2010-07-20 17:57:33 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&lineset->linestyle->id, 0);
|
2014-06-06 00:56:04 +09:00
|
|
|
WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_color_modifier_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Add Line Color Modifier";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_color_modifier_add";
|
2011-10-30 09:05:47 +00:00
|
|
|
ot->description =
|
|
|
|
"Add a line color modifier to the line style associated with the active lineset";
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = freestyle_color_modifier_add_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* properties */
|
2015-11-23 13:49:52 +11:00
|
|
|
ot->prop = RNA_def_enum(
|
|
|
|
ot->srna, "type", rna_enum_linestyle_color_modifier_type_items, 0, "Type", "");
|
2010-07-20 17:57:33 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Modifier Add "Alpha" Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2017-11-22 10:52:39 -02:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config);
|
2012-12-11 22:00:22 +00:00
|
|
|
int type = RNA_enum_get(op->ptr, "type");
|
2010-07-20 17:57:33 +00:00
|
|
|
|
2013-10-01 02:51:39 +00:00
|
|
|
if (!freestyle_linestyle_check_report(lineset, op->reports)) {
|
2013-09-30 23:02:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2013-10-01 02:51:39 +00:00
|
|
|
|
2014-07-17 09:23:30 +09:00
|
|
|
if (BKE_linestyle_alpha_modifier_add(lineset->linestyle, NULL, type) == NULL) {
|
2012-12-11 22:00:22 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type");
|
2010-07-20 17:57:33 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&lineset->linestyle->id, 0);
|
2014-06-06 00:56:04 +09:00
|
|
|
WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_alpha_modifier_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Add Alpha Transparency Modifier";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_alpha_modifier_add";
|
2011-10-30 09:05:47 +00:00
|
|
|
ot->description =
|
|
|
|
"Add an alpha transparency modifier to the line style associated with the active lineset";
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = freestyle_alpha_modifier_add_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* properties */
|
2015-11-23 13:49:52 +11:00
|
|
|
ot->prop = RNA_def_enum(
|
|
|
|
ot->srna, "type", rna_enum_linestyle_alpha_modifier_type_items, 0, "Type", "");
|
2010-07-20 17:57:33 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Modifier Add "Thickness" Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2017-11-22 10:52:39 -02:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config);
|
2012-12-11 22:00:22 +00:00
|
|
|
int type = RNA_enum_get(op->ptr, "type");
|
2010-07-20 17:57:33 +00:00
|
|
|
|
2013-10-01 02:51:39 +00:00
|
|
|
if (!freestyle_linestyle_check_report(lineset, op->reports)) {
|
2013-09-30 23:02:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2013-10-01 02:51:39 +00:00
|
|
|
|
2014-07-17 09:23:30 +09:00
|
|
|
if (BKE_linestyle_thickness_modifier_add(lineset->linestyle, NULL, type) == NULL) {
|
2012-12-11 22:00:22 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type");
|
2010-07-20 17:57:33 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&lineset->linestyle->id, 0);
|
2014-06-06 00:56:04 +09:00
|
|
|
WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_thickness_modifier_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Add Line Thickness Modifier";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_thickness_modifier_add";
|
2011-10-30 09:05:47 +00:00
|
|
|
ot->description =
|
|
|
|
"Add a line thickness modifier to the line style associated with the active lineset";
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = freestyle_thickness_modifier_add_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* properties */
|
2015-11-23 13:49:52 +11:00
|
|
|
ot->prop = RNA_def_enum(
|
|
|
|
ot->srna, "type", rna_enum_linestyle_thickness_modifier_type_items, 0, "Type", "");
|
2010-07-20 17:57:33 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Modifier Add "Geometry" Operator
|
|
|
|
* \{ */
|
|
|
|
|
2011-08-19 14:05:11 +00:00
|
|
|
static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2017-11-22 10:52:39 -02:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config);
|
2012-12-11 22:00:22 +00:00
|
|
|
int type = RNA_enum_get(op->ptr, "type");
|
2011-08-19 14:05:11 +00:00
|
|
|
|
2013-10-01 02:51:39 +00:00
|
|
|
if (!freestyle_linestyle_check_report(lineset, op->reports)) {
|
2013-09-30 23:02:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2013-10-01 02:51:39 +00:00
|
|
|
|
2014-07-17 09:23:30 +09:00
|
|
|
if (BKE_linestyle_geometry_modifier_add(lineset->linestyle, NULL, type) == NULL) {
|
2012-12-11 22:00:22 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type");
|
2011-08-19 14:05:11 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&lineset->linestyle->id, 0);
|
2014-06-06 00:56:04 +09:00
|
|
|
WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2011-08-19 14:05:11 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_geometry_modifier_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Add Stroke Geometry Modifier";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_geometry_modifier_add";
|
2011-10-30 09:05:47 +00:00
|
|
|
ot->description =
|
|
|
|
"Add a stroke geometry modifier to the line style associated with the active lineset";
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2011-08-19 14:05:11 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = freestyle_geometry_modifier_add_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
|
|
|
|
2011-08-19 14:05:11 +00:00
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2012-12-11 22:00:22 +00:00
|
|
|
|
2011-08-19 14:05:11 +00:00
|
|
|
/* properties */
|
2015-11-23 13:49:52 +11:00
|
|
|
ot->prop = RNA_def_enum(
|
|
|
|
ot->srna, "type", rna_enum_linestyle_geometry_modifier_type_items, 0, "Type", "");
|
2011-08-19 14:05:11 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Modifier Remove Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
static int freestyle_get_modifier_type(PointerRNA *ptr)
|
|
|
|
{
|
2019-04-22 09:19:45 +10:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_LineStyleColorModifier)) {
|
2010-07-20 17:57:33 +00:00
|
|
|
return LS_MODIFIER_TYPE_COLOR;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2020-07-03 17:30:31 +02:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_LineStyleAlphaModifier)) {
|
2010-07-20 17:57:33 +00:00
|
|
|
return LS_MODIFIER_TYPE_ALPHA;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2020-07-03 17:30:31 +02:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_LineStyleThicknessModifier)) {
|
2010-07-20 17:57:33 +00:00
|
|
|
return LS_MODIFIER_TYPE_THICKNESS;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2020-07-03 17:30:31 +02:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_LineStyleGeometryModifier)) {
|
2011-08-19 14:05:11 +00:00
|
|
|
return LS_MODIFIER_TYPE_GEOMETRY;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2010-07-20 17:57:33 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2017-11-22 10:52:39 -02:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config);
|
2012-12-11 22:00:22 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier);
|
|
|
|
LineStyleModifier *modifier = ptr.data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-01 02:51:39 +00:00
|
|
|
if (!freestyle_linestyle_check_report(lineset, op->reports)) {
|
2013-09-30 23:02:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
switch (freestyle_get_modifier_type(&ptr)) {
|
2013-07-19 15:23:42 +00:00
|
|
|
case LS_MODIFIER_TYPE_COLOR:
|
2014-07-17 09:23:30 +09:00
|
|
|
BKE_linestyle_color_modifier_remove(lineset->linestyle, modifier);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TYPE_ALPHA:
|
2014-07-17 09:23:30 +09:00
|
|
|
BKE_linestyle_alpha_modifier_remove(lineset->linestyle, modifier);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TYPE_THICKNESS:
|
2014-07-17 09:23:30 +09:00
|
|
|
BKE_linestyle_thickness_modifier_remove(lineset->linestyle, modifier);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TYPE_GEOMETRY:
|
2014-07-17 09:23:30 +09:00
|
|
|
BKE_linestyle_geometry_modifier_remove(lineset->linestyle, modifier);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BKE_report(
|
|
|
|
op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier");
|
|
|
|
return OPERATOR_CANCELLED;
|
2010-07-20 17:57:33 +00:00
|
|
|
}
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&lineset->linestyle->id, 0);
|
2014-06-06 00:56:04 +09:00
|
|
|
WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_modifier_remove(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Remove Modifier";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_modifier_remove";
|
|
|
|
ot->description = "Remove the modifier from the list of modifiers";
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_modifier_remove_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
2010-07-20 17:57:33 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2010-07-20 17:57:33 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Modifier Copy Operator
|
|
|
|
* \{ */
|
|
|
|
|
2012-08-02 20:30:23 +00:00
|
|
|
static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2017-11-22 10:52:39 -02:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config);
|
2012-12-11 22:00:22 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier);
|
|
|
|
LineStyleModifier *modifier = ptr.data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-01 02:51:39 +00:00
|
|
|
if (!freestyle_linestyle_check_report(lineset, op->reports)) {
|
2013-09-30 23:02:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-11 22:00:22 +00:00
|
|
|
switch (freestyle_get_modifier_type(&ptr)) {
|
2013-07-19 15:23:42 +00:00
|
|
|
case LS_MODIFIER_TYPE_COLOR:
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
BKE_linestyle_color_modifier_copy(lineset->linestyle, modifier, 0);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TYPE_ALPHA:
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
BKE_linestyle_alpha_modifier_copy(lineset->linestyle, modifier, 0);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TYPE_THICKNESS:
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
BKE_linestyle_thickness_modifier_copy(lineset->linestyle, modifier, 0);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TYPE_GEOMETRY:
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
BKE_linestyle_geometry_modifier_copy(lineset->linestyle, modifier, 0);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BKE_report(
|
|
|
|
op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier");
|
|
|
|
return OPERATOR_CANCELLED;
|
2012-12-11 22:00:22 +00:00
|
|
|
}
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&lineset->linestyle->id, 0);
|
2014-06-06 00:56:04 +09:00
|
|
|
WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-11 22:00:22 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2012-08-02 20:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_modifier_copy(wmOperatorType *ot)
|
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Copy Modifier";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_modifier_copy";
|
|
|
|
ot->description = "Duplicate the modifier within the list of modifiers";
|
2012-08-02 20:30:23 +00:00
|
|
|
|
2012-12-11 22:00:22 +00:00
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = freestyle_modifier_copy_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
2012-08-02 20:30:23 +00:00
|
|
|
|
2012-12-11 22:00:22 +00:00
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2012-08-02 20:30:23 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Modifier Move Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
static int freestyle_modifier_move_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2017-11-22 10:52:39 -02:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&view_layer->freestyle_config);
|
2012-12-11 22:00:22 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier);
|
|
|
|
LineStyleModifier *modifier = ptr.data;
|
|
|
|
int dir = RNA_enum_get(op->ptr, "direction");
|
2016-09-18 21:36:34 +02:00
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-01 02:51:39 +00:00
|
|
|
if (!freestyle_linestyle_check_report(lineset, op->reports)) {
|
2013-09-30 23:02:29 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
switch (freestyle_get_modifier_type(&ptr)) {
|
2013-07-19 15:23:42 +00:00
|
|
|
case LS_MODIFIER_TYPE_COLOR:
|
2016-09-18 21:36:34 +02:00
|
|
|
changed = BKE_linestyle_color_modifier_move(lineset->linestyle, modifier, dir);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TYPE_ALPHA:
|
2016-09-18 21:36:34 +02:00
|
|
|
changed = BKE_linestyle_alpha_modifier_move(lineset->linestyle, modifier, dir);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TYPE_THICKNESS:
|
2016-09-18 21:36:34 +02:00
|
|
|
changed = BKE_linestyle_thickness_modifier_move(lineset->linestyle, modifier, dir);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
case LS_MODIFIER_TYPE_GEOMETRY:
|
2016-09-18 21:36:34 +02:00
|
|
|
changed = BKE_linestyle_geometry_modifier_move(lineset->linestyle, modifier, dir);
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BKE_report(
|
|
|
|
op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier");
|
|
|
|
return OPERATOR_CANCELLED;
|
2010-07-20 17:57:33 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-09-18 21:36:34 +02:00
|
|
|
if (changed) {
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&lineset->linestyle->id, 0);
|
2016-09-18 21:36:34 +02:00
|
|
|
WM_event_add_notifier(C, NC_LINESTYLE, lineset->linestyle);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_modifier_move(wmOperatorType *ot)
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem direction_items[] = {
|
2016-09-18 21:36:34 +02:00
|
|
|
{-1, "UP", 0, "Up", ""},
|
|
|
|
{1, "DOWN", 0, "Down", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2010-07-20 17:57:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* identifiers */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->name = "Move Modifier";
|
|
|
|
ot->idname = "SCENE_OT_freestyle_modifier_move";
|
|
|
|
ot->description = "Move the modifier within the list of modifiers";
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
/* api callbacks */
|
2012-12-11 22:00:22 +00:00
|
|
|
ot->exec = freestyle_modifier_move_exec;
|
|
|
|
ot->poll = freestyle_active_lineset_poll;
|
2010-07-20 17:57:33 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2010-07-20 17:57:33 +00:00
|
|
|
|
|
|
|
/* props */
|
2016-09-16 17:03:44 +02:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
"direction",
|
|
|
|
direction_items,
|
|
|
|
0,
|
|
|
|
"Direction",
|
|
|
|
"Direction to move the chosen modifier towards");
|
2010-07-20 17:57:33 +00:00
|
|
|
}
|
2013-03-23 03:00:37 +00:00
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Free Style Stroke Material Create Operator
|
|
|
|
* \{ */
|
|
|
|
|
2014-06-28 19:18:47 +09:00
|
|
|
static int freestyle_stroke_material_create_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Main *bmain = CTX_data_main(C);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
FreestyleLineStyle *linestyle = BKE_linestyle_active_from_view_layer(view_layer);
|
2014-06-28 19:18:47 +09:00
|
|
|
|
2014-07-20 20:09:46 +09:00
|
|
|
if (!linestyle) {
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "No active line style in the current scene");
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2014-08-01 10:18:25 +09:00
|
|
|
FRS_create_stroke_material(bmain, linestyle);
|
2014-06-28 19:18:47 +09:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_freestyle_stroke_material_create(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Create Freestyle Stroke Material";
|
2014-07-29 14:36:11 +09:00
|
|
|
ot->idname = "SCENE_OT_freestyle_stroke_material_create";
|
2014-06-28 19:18:47 +09:00
|
|
|
ot->description = "Create Freestyle stroke material for testing";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = freestyle_stroke_material_create_exec;
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
}
|
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
#endif /* WITH_FREESTYLE */
|
2010-07-20 17:57:33 +00:00
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2020-08-26 09:41:30 +10:00
|
|
|
/** \name Texture Slot Move Operator
|
2020-08-25 15:10:36 +10:00
|
|
|
* \{ */
|
|
|
|
|
2013-07-28 17:06:31 +00:00
|
|
|
static int texture_slot_move_exec(bContext *C, wmOperator *op)
|
2009-10-12 16:00:39 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
|
2009-10-12 16:00:39 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id) {
|
2009-10-12 16:00:39 +00:00
|
|
|
MTex **mtex_ar, *mtexswap;
|
|
|
|
short act;
|
2012-03-29 22:42:32 +00:00
|
|
|
int type = RNA_enum_get(op->ptr, "type");
|
|
|
|
struct AnimData *adt = BKE_animdata_from_id(id);
|
2009-10-12 16:00:39 +00:00
|
|
|
|
|
|
|
give_active_mtex(id, &mtex_ar, &act);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (type == -1) { /* Up */
|
|
|
|
if (act > 0) {
|
2009-10-12 16:00:39 +00:00
|
|
|
mtexswap = mtex_ar[act];
|
2012-03-29 22:42:32 +00:00
|
|
|
mtex_ar[act] = mtex_ar[act - 1];
|
|
|
|
mtex_ar[act - 1] = mtexswap;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-30 13:04:29 +00:00
|
|
|
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act - 1, -1, 0);
|
|
|
|
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act - 1, 0);
|
|
|
|
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
set_active_mtex(id, act - 1);
|
2009-10-12 16:00:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else { /* Down */
|
2012-03-29 22:42:32 +00:00
|
|
|
if (act < MAX_MTEX - 1) {
|
2009-10-12 16:00:39 +00:00
|
|
|
mtexswap = mtex_ar[act];
|
2012-03-29 22:42:32 +00:00
|
|
|
mtex_ar[act] = mtex_ar[act + 1];
|
|
|
|
mtex_ar[act + 1] = mtexswap;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-30 13:04:29 +00:00
|
|
|
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act + 1, -1, 0);
|
|
|
|
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act + 1, 0);
|
|
|
|
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
set_active_mtex(id, act + 1);
|
2009-10-12 16:00:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(id, 0);
|
2009-10-12 16:00:39 +00:00
|
|
|
WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TEXTURE_OT_slot_move(wmOperatorType *ot)
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem slot_move[] = {
|
2009-10-12 16:00:39 +00:00
|
|
|
{-1, "UP", 0, "Up", ""},
|
|
|
|
{1, "DOWN", 0, "Down", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2009-10-12 16:00:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Move Texture Slot";
|
|
|
|
ot->idname = "TEXTURE_OT_slot_move";
|
|
|
|
ot->description = "Move texture slots up and down";
|
2009-10-12 16:00:39 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2013-07-28 17:06:31 +00:00
|
|
|
ot->exec = texture_slot_move_exec;
|
2009-10-12 16:00:39 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2009-10-12 16:00:39 +00:00
|
|
|
|
|
|
|
RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
|
|
|
|
}
|
2010-01-28 17:31:11 +00:00
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Material Copy Operator
|
|
|
|
* \{ */
|
2010-03-11 07:43:49 +00:00
|
|
|
|
2010-01-28 17:31:11 +00:00
|
|
|
/* material copy/paste */
|
2010-10-15 01:36:14 +00:00
|
|
|
static int copy_material_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-01-28 17:31:11 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
|
2010-01-28 17:31:11 +00:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ma == NULL) {
|
2010-01-28 19:18:35 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2010-01-28 17:31:11 +00:00
|
|
|
|
2020-02-05 11:23:58 +01:00
|
|
|
BKE_material_copybuf_copy(CTX_data_main(C), ma);
|
2010-01-28 17:31:11 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MATERIAL_OT_copy(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Copy Material";
|
|
|
|
ot->idname = "MATERIAL_OT_copy";
|
|
|
|
ot->description = "Copy the material settings and nodes";
|
2010-01-28 17:31:11 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = copy_material_exec;
|
2010-01-28 17:31:11 +00:00
|
|
|
|
|
|
|
/* flags */
|
2019-01-15 23:24:20 +11:00
|
|
|
/* no undo needed since no changes are made to the material */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL;
|
2010-01-28 17:31:11 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Material Paste Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-01-28 17:31:11 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
|
2010-01-28 17:31:11 +00:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ma == NULL) {
|
2010-01-28 17:50:50 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2010-01-28 17:31:11 +00:00
|
|
|
|
2020-02-05 11:23:58 +01:00
|
|
|
BKE_material_copybuf_paste(CTX_data_main(C), ma);
|
2010-01-28 17:31:11 +00:00
|
|
|
|
2019-01-17 08:59:02 +11:00
|
|
|
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
|
2012-11-26 08:52:07 +00:00
|
|
|
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma);
|
2010-01-28 17:31:11 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MATERIAL_OT_paste(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Paste Material";
|
|
|
|
ot->idname = "MATERIAL_OT_paste";
|
|
|
|
ot->description = "Paste the material settings and nodes";
|
2010-01-28 17:31:11 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = paste_material_exec;
|
2010-01-28 17:31:11 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2010-01-28 17:31:11 +00:00
|
|
|
}
|
2010-03-09 09:17:45 +00:00
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name #MTex Copy/Paste Utilities
|
|
|
|
* \{ */
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
static short mtexcopied = 0; /* must be reset on file load */
|
2010-03-29 05:37:34 +00:00
|
|
|
static MTex mtexcopybuf;
|
|
|
|
|
|
|
|
void ED_render_clear_mtex_copybuf(void)
|
2012-03-29 22:42:32 +00:00
|
|
|
{ /* use for file reload */
|
|
|
|
mtexcopied = 0;
|
2010-03-29 05:37:34 +00:00
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void copy_mtex_copybuf(ID *id)
|
2010-03-09 09:17:45 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
MTex **mtex = NULL;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
switch (GS(id->name)) {
|
2016-12-28 17:30:58 +01:00
|
|
|
case ID_PA:
|
|
|
|
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
|
|
|
|
break;
|
2014-05-03 18:51:53 +09:00
|
|
|
case ID_LS:
|
|
|
|
mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
|
|
|
|
break;
|
2017-08-28 11:19:58 +02:00
|
|
|
default:
|
|
|
|
break;
|
2010-03-29 05:37:34 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex && *mtex) {
|
2010-03-29 05:37:34 +00:00
|
|
|
memcpy(&mtexcopybuf, *mtex, sizeof(MTex));
|
2012-03-29 22:42:32 +00:00
|
|
|
mtexcopied = 1;
|
2010-03-29 05:37:34 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-29 22:42:32 +00:00
|
|
|
mtexcopied = 0;
|
2010-03-29 05:37:34 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-09 09:17:45 +00:00
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void paste_mtex_copybuf(ID *id)
|
2010-03-29 05:37:34 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
MTex **mtex = NULL;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (mtexcopied == 0 || mtexcopybuf.tex == NULL) {
|
2010-03-29 05:37:34 +00:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
switch (GS(id->name)) {
|
2016-12-28 17:30:58 +01:00
|
|
|
case ID_PA:
|
|
|
|
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
|
|
|
|
break;
|
2014-05-03 18:51:53 +09:00
|
|
|
case ID_LS:
|
|
|
|
mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
|
|
|
|
break;
|
2011-03-19 05:06:06 +00:00
|
|
|
default:
|
2017-07-24 17:32:09 +10:00
|
|
|
BLI_assert(!"invalid id type");
|
2011-03-19 05:06:06 +00:00
|
|
|
return;
|
2010-03-29 05:37:34 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mtex) {
|
2012-03-29 22:42:32 +00:00
|
|
|
if (*mtex == NULL) {
|
|
|
|
*mtex = MEM_mallocN(sizeof(MTex), "mtex copy");
|
2010-03-29 05:37:34 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if ((*mtex)->tex) {
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&(*mtex)->tex->id);
|
2010-03-29 05:37:34 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-03-29 05:37:34 +00:00
|
|
|
memcpy(*mtex, &mtexcopybuf, sizeof(MTex));
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-03-29 05:37:34 +00:00
|
|
|
id_us_plus((ID *)mtexcopybuf.tex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Texture Slot Copy Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-03-29 05:37:34 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
|
2010-03-29 05:37:34 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (id == NULL) {
|
2010-03-29 05:37:34 +00:00
|
|
|
/* copying empty slot */
|
|
|
|
ED_render_clear_mtex_copybuf();
|
2010-03-09 09:17:45 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2010-03-29 05:37:34 +00:00
|
|
|
}
|
2010-03-09 09:17:45 +00:00
|
|
|
|
2010-03-29 05:37:34 +00:00
|
|
|
copy_mtex_copybuf(id);
|
2010-03-09 09:17:45 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool copy_mtex_poll(bContext *C)
|
2010-03-29 05:37:34 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-03-29 05:37:34 +00:00
|
|
|
return (id != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TEXTURE_OT_slot_copy(wmOperatorType *ot)
|
2010-03-09 09:17:45 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Copy Texture Slot Settings";
|
|
|
|
ot->idname = "TEXTURE_OT_slot_copy";
|
|
|
|
ot->description = "Copy the material texture settings and nodes";
|
2010-03-09 09:17:45 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = copy_mtex_exec;
|
|
|
|
ot->poll = copy_mtex_poll;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-03-09 09:17:45 +00:00
|
|
|
/* flags */
|
2019-01-15 23:24:20 +11:00
|
|
|
/* no undo needed since no changes are made to the mtex */
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL;
|
2010-03-09 09:17:45 +00:00
|
|
|
}
|
|
|
|
|
2020-08-25 15:10:36 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Texture Slot Paste Operator
|
|
|
|
* \{ */
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-03-09 09:17:45 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
|
2010-03-09 09:17:45 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (id == NULL) {
|
|
|
|
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
|
2019-02-27 10:46:48 +11:00
|
|
|
Light *la = CTX_data_pointer_get_type(C, "light", &RNA_Light).data;
|
2012-03-29 22:42:32 +00:00
|
|
|
World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
|
2016-12-28 17:30:58 +01:00
|
|
|
ParticleSystem *psys =
|
|
|
|
CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
|
2014-05-03 18:51:53 +09:00
|
|
|
FreestyleLineStyle *linestyle =
|
|
|
|
CTX_data_pointer_get_type(C, "line_style", &RNA_FreestyleLineStyle).data;
|
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ma) {
|
2010-03-29 05:37:34 +00:00
|
|
|
id = &ma->id;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
else if (la) {
|
2010-03-29 05:37:34 +00:00
|
|
|
id = &la->id;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
else if (wo) {
|
2010-03-29 05:37:34 +00:00
|
|
|
id = &wo->id;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
else if (psys) {
|
2016-12-28 17:30:58 +01:00
|
|
|
id = &psys->part->id;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
else if (linestyle) {
|
2014-05-03 18:51:53 +09:00
|
|
|
id = &linestyle->id;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (id == NULL) {
|
2010-03-29 05:37:34 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2010-03-29 05:37:34 +00:00
|
|
|
}
|
2010-03-09 09:17:45 +00:00
|
|
|
|
2010-03-29 05:37:34 +00:00
|
|
|
paste_mtex_copybuf(id);
|
2010-03-09 09:17:45 +00:00
|
|
|
|
2012-11-26 08:52:07 +00:00
|
|
|
WM_event_add_notifier(C, NC_TEXTURE | ND_SHADING_LINKS, NULL);
|
2010-03-09 09:17:45 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2010-03-29 05:37:34 +00:00
|
|
|
void TEXTURE_OT_slot_paste(wmOperatorType *ot)
|
2010-03-09 09:17:45 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Paste Texture Slot Settings";
|
|
|
|
ot->idname = "TEXTURE_OT_slot_paste";
|
|
|
|
ot->description = "Copy the texture settings and nodes";
|
2010-03-09 09:17:45 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = paste_mtex_exec;
|
2010-03-09 09:17:45 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2010-03-09 09:17:45 +00:00
|
|
|
}
|
2020-08-25 15:10:36 +10:00
|
|
|
|
|
|
|
/** \} */
|