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
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/render/render_shading.c
|
|
|
|
* \ingroup edrend
|
|
|
|
*/
|
|
|
|
|
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"
|
|
|
|
#include "DNA_lamp_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"
|
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2015-04-28 07:24:56 +10:00
|
|
|
#include "BLI_listbase.h"
|
|
|
|
#include "BLI_math_vector.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
|
|
|
|
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"
|
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"
|
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"
|
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_library.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"
|
2014-10-06 15:12:06 +02:00
|
|
|
#include "BKE_paint.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"
|
2013-04-13 20:31:52 +00: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
|
|
|
|
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"
|
|
|
|
|
2012-01-02 17:15:24 +00:00
|
|
|
#include "ED_object.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 "ED_curve.h"
|
|
|
|
#include "ED_mesh.h"
|
2011-11-02 19:24:30 +00:00
|
|
|
#include "ED_node.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"
|
|
|
|
|
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
|
|
|
|
|
|
|
/********************** material slot operators *********************/
|
|
|
|
|
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
|
|
|
|
2012-03-24 06:38:07 +00: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;
|
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);
|
|
|
|
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
|
|
|
|
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;
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2012-03-24 06:38:07 +00: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;
|
|
|
|
|
2010-10-15 08:11:26 +00:00
|
|
|
/* Removing material slots in edit mode screws things up, see bug #21822.*/
|
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);
|
|
|
|
BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
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;
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
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_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
|
|
|
{
|
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
|
|
|
|
2012-03-24 06:38:07 +00: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;
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ob && ob->actcol > 0) {
|
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;
|
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 (em) {
|
2012-04-19 13:47:58 +00:00
|
|
|
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (BM_elem_flag_test(efa, BM_ELEM_SELECT))
|
2012-03-29 22:42:32 +00:00
|
|
|
efa->mat_nr = ob->actcol - 1;
|
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);
|
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 (nurbs) {
|
2015-07-09 14:31:27 +10:00
|
|
|
for (nu = nurbs->first; nu; nu = nu->next) {
|
|
|
|
if (ED_curve_nurb_select_check(ob->data, nu)) {
|
2015-04-29 00:19:34 +10:00
|
|
|
nu->mat_nr = ob->actcol - 1;
|
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;
|
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-05-05 14:52:04 +00:00
|
|
|
if (ef && BKE_vfont_select_get(ob, &selstart, &selend)) {
|
2012-03-29 22:42:32 +00:00
|
|
|
for (i = selstart; i <= selend; i++)
|
2011-04-04 16:19:18 +00:00
|
|
|
ef->textbufinfo[i].mat_nr = ob->actcol;
|
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(&ob->id, OB_RECALC_DATA);
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
|
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_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;
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-03-02 12:09:49 +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
|
|
|
|
2012-03-24 06:38:07 +00: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;
|
|
|
|
|
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);
|
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 (em) {
|
2012-03-29 22:42:32 +00:00
|
|
|
EDBM_deselect_by_material(em, ob->actcol - 1, 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
|
|
|
}
|
|
|
|
}
|
2012-03-25 22:35:18 +00:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
2012-04-28 16:49:00 +00:00
|
|
|
ListBase *nurbs = BKE_curve_editNurbs_get((Curve *)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
|
|
|
Nurb *nu;
|
|
|
|
BPoint *bp;
|
|
|
|
BezTriple *bezt;
|
|
|
|
int a;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (nurbs) {
|
2012-03-29 22:42:32 +00:00
|
|
|
for (nu = nurbs->first; nu; nu = nu->next) {
|
|
|
|
if (nu->mat_nr == ob->actcol - 1) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (nu->bezt) {
|
2012-03-29 22:42:32 +00:00
|
|
|
a = nu->pntsu;
|
|
|
|
bezt = nu->bezt;
|
2012-03-24 06:38:07 +00:00
|
|
|
while (a--) {
|
2012-03-29 22:42:32 +00:00
|
|
|
if (bezt->hide == 0) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (select) {
|
2010-11-04 15:59:09 +00:00
|
|
|
bezt->f1 |= SELECT;
|
|
|
|
bezt->f2 |= SELECT;
|
|
|
|
bezt->f3 |= SELECT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bezt->f1 &= ~SELECT;
|
|
|
|
bezt->f2 &= ~SELECT;
|
|
|
|
bezt->f3 &= ~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
|
|
|
}
|
2010-11-04 15:59:09 +00:00
|
|
|
bezt++;
|
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 (nu->bp) {
|
2012-03-29 22:42:32 +00:00
|
|
|
a = nu->pntsu * nu->pntsv;
|
|
|
|
bp = nu->bp;
|
2012-03-24 06:38:07 +00:00
|
|
|
while (a--) {
|
2012-03-29 22:42:32 +00:00
|
|
|
if (bp->hide == 0) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (select) bp->f1 |= SELECT;
|
2010-11-04 15:59:09 +00:00
|
|
|
else bp->f1 &= ~SELECT;
|
|
|
|
}
|
|
|
|
bp++;
|
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-06-13 15:26:59 +02:00
|
|
|
DEG_id_tag_update(ob->data, DEG_TAG_SELECT_UPDATE);
|
2012-03-29 22:42:32 +00: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
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-10-07 16:32:55 +00:00
|
|
|
|
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);
|
2009-10-07 16:32:55 +00:00
|
|
|
Material ***matar;
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (!ob || !(matar = give_matarar(ob)))
|
2009-10-07 16:32:55 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-04-30 16:22:40 +00:00
|
|
|
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob != ob_iter && give_matarar(ob_iter)) {
|
2009-12-10 01:30:47 +00:00
|
|
|
if (ob->data != ob_iter->data)
|
2018-05-29 15:49:21 +02:00
|
|
|
assign_matarar(bmain, ob_iter, matar, ob->totcol);
|
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;
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&ob_iter->id, OB_RECALC_DATA);
|
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;
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_copy(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Copy Material to Others";
|
|
|
|
ot->idname = "OBJECT_OT_material_slot_copy";
|
|
|
|
ot->description = "Copies materials to other 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
|
|
|
}
|
|
|
|
|
2015-04-28 07:24:56 +10:00
|
|
|
static int material_slot_move_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
Object *ob = ED_object_context(C);
|
|
|
|
|
|
|
|
unsigned int *slot_remap;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
slot_remap = MEM_mallocN(sizeof(unsigned int) * ob->totcol, __func__);
|
|
|
|
|
|
|
|
range_vn_u(slot_remap, ob->totcol, 0);
|
|
|
|
|
|
|
|
slot_remap[index_pair[0]] = index_pair[1];
|
|
|
|
slot_remap[index_pair[1]] = index_pair[0];
|
|
|
|
|
|
|
|
BKE_material_remap_object(ob, slot_remap);
|
|
|
|
|
|
|
|
MEM_freeN(slot_remap);
|
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
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", ""},
|
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
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
|
|
|
/********************** new material operator *********************/
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int new_material_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
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
|
2013-02-05 12:46:15 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2018-07-31 10:22:19 +02:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
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
|
|
|
|
|
|
|
/* add or copy material */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma) {
|
2016-07-10 14:52:00 +02:00
|
|
|
ma = BKE_material_copy(bmain, ma);
|
2011-11-02 19:24:30 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-07-31 10:22:19 +02:00
|
|
|
if ((!ob) || (ob->type != OB_GPENCIL)) {
|
|
|
|
ma = BKE_material_add(bmain, DATA_("Material"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ma = BKE_material_add_gpencil(bmain, DATA_("Material"));
|
|
|
|
}
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
ED_node_shader_default(C, &ma->id);
|
|
|
|
ma->use_nodes = true;
|
2011-11-02 19:24:30 +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
|
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);
|
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(&ma->id, &idptr);
|
|
|
|
RNA_property_pointer_set(&ptr, prop, idptr);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_MATERIAL | NA_ADDED, ma);
|
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 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;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/********************** new texture operator *********************/
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int new_texture_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
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
|
2013-02-05 12:46:15 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
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
|
|
|
|
|
|
|
/* add or copy texture */
|
2013-03-26 14:33:53 +00:00
|
|
|
if (tex) {
|
2016-07-10 14:52:00 +02:00
|
|
|
tex = BKE_texture_copy(bmain, tex);
|
2013-03-26 14:33:53 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-03-29 03:16:55 +11:00
|
|
|
tex = BKE_texture_add(bmain, DATA_("Texture"));
|
2013-03-26 14:33:53 +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
|
|
|
|
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);
|
|
|
|
RNA_property_pointer_set(&ptr, prop, idptr);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/********************** new world operator *********************/
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int new_world_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
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
|
2013-02-05 12:46:15 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
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
|
|
|
|
|
|
|
/* add or copy world */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wo) {
|
2016-07-10 14:52:00 +02:00
|
|
|
wo = BKE_world_copy(bmain, wo);
|
2011-11-02 19:24:30 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-01-11 09:55:41 +11:00
|
|
|
wo = BKE_world_add(bmain, DATA_("World"));
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
ED_node_shader_default(C, &wo->id);
|
|
|
|
wo->use_nodes = true;
|
2011-11-02 19:24:30 +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);
|
|
|
|
RNA_property_pointer_set(&ptr, prop, idptr);
|
|
|
|
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
|
|
|
|
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";
|
2017-04-13 18:07:10 -04: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
|
|
|
}
|
|
|
|
|
|
|
|
/********************** render layer operators *********************/
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
static int view_layer_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-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);
|
2018-04-24 15:20:17 +02:00
|
|
|
ViewLayer *view_layer = BKE_view_layer_add(scene, 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
|
|
|
|
2018-07-04 13:00:46 +02:00
|
|
|
if (win) {
|
|
|
|
WM_window_set_active_view_layer(win, view_layer);
|
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
|
|
|
{
|
|
|
|
/* 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;
|
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
|
|
|
}
|
|
|
|
|
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;
|
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
|
|
|
}
|
|
|
|
|
2018-07-10 15:02:25 +02:00
|
|
|
/********************** light cache operators *********************/
|
|
|
|
enum {
|
|
|
|
LIGHTCACHE_SUBSET_ALL = 0,
|
|
|
|
LIGHTCACHE_SUBSET_DIRTY,
|
|
|
|
LIGHTCACHE_SUBSET_CUBE,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void light_cache_bake_tag_cache(Scene *scene, wmOperator *op)
|
|
|
|
{
|
|
|
|
if (scene->eevee.light_cache != NULL) {
|
|
|
|
int subset = RNA_enum_get(op->ptr, "subset");
|
|
|
|
switch (subset) {
|
|
|
|
case LIGHTCACHE_SUBSET_ALL:
|
|
|
|
scene->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_GRID | LIGHTCACHE_UPDATE_CUBE;
|
|
|
|
break;
|
|
|
|
case LIGHTCACHE_SUBSET_CUBE:
|
|
|
|
scene->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_CUBE;
|
|
|
|
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)) {
|
|
|
|
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* running render */
|
|
|
|
switch (event->type) {
|
|
|
|
case ESCKEY:
|
|
|
|
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. */
|
|
|
|
void *rj = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, false);
|
|
|
|
|
|
|
|
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
|
|
|
|
ED_update_for_newframe(bmain, CTX_data_depsgraph(C));
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
wmJob *wm_job = EEVEE_lightbake_job_create(wm, win, bmain, view_layer, scene, delay);
|
|
|
|
|
|
|
|
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
|
|
|
|
* several layers from compositor [#31800]
|
|
|
|
*/
|
|
|
|
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[] = {
|
|
|
|
{LIGHTCACHE_SUBSET_ALL, "ALL", 0, "All LightProbes", "Bake both irradiance grids and reflection cubemaps"},
|
|
|
|
{LIGHTCACHE_SUBSET_DIRTY, "DIRTY", 0, "Dirty Only", "Only bake lightprobes that are marked as dirty"},
|
|
|
|
{LIGHTCACHE_SUBSET_CUBE, "CUBEMAPS", 0, "Cubemaps Only", "Try to only bake reflection cubemaps if irradiance "
|
|
|
|
"grids are up to date"},
|
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Bake Light Cache";
|
|
|
|
ot->idname = "SCENE_OT_light_cache_bake";
|
|
|
|
ot->description = "Bake the active view layer lighting";
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool light_cache_free_poll(bContext *C)
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
|
|
return scene->eevee.light_cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int light_cache_free_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
|
|
if (!scene->eevee.light_cache) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
EEVEE_lightcache_free(scene->eevee.light_cache);
|
|
|
|
scene->eevee.light_cache = NULL;
|
|
|
|
|
|
|
|
EEVEE_lightcache_info_update(&scene->eevee);
|
|
|
|
|
|
|
|
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCENE_OT_light_cache_free(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Free Light Cache";
|
|
|
|
ot->idname = "SCENE_OT_light_cache_free";
|
|
|
|
ot->description = "Free cached indirect lighting";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->exec = light_cache_free_exec;
|
|
|
|
ot->poll = light_cache_free_poll;
|
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/********************** render view operators *********************/
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (!BKE_scene_remove_render_view(scene, rv))
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-12-20 07:57:26 +00:00
|
|
|
#ifdef WITH_FREESTYLE
|
2013-03-23 03:00:37 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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", ""},
|
2010-06-25 22:45:42 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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", ""},
|
2010-06-25 22:45:42 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2015-03-19 14:33:05 +11:00
|
|
|
lineset->linestyle = BKE_linestyle_copy(bmain, lineset->linestyle);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
static int freestyle_get_modifier_type(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_LineStyleColorModifier))
|
|
|
|
return LS_MODIFIER_TYPE_COLOR;
|
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleAlphaModifier))
|
|
|
|
return LS_MODIFIER_TYPE_ALPHA;
|
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleThicknessModifier))
|
|
|
|
return LS_MODIFIER_TYPE_THICKNESS;
|
2011-08-19 14:05:11 +00:00
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleGeometryModifier))
|
|
|
|
return LS_MODIFIER_TYPE_GEOMETRY;
|
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;
|
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;
|
|
|
|
}
|
2012-12-11 22:00:22 +00: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);
|
2012-12-11 22:00:22 +00: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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
}
|
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);
|
2012-08-02 20:30:23 +00: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
|
|
|
}
|
|
|
|
|
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;
|
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;
|
|
|
|
}
|
2012-12-11 22:00:22 +00: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
|
|
|
}
|
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);
|
|
|
|
}
|
2012-12-11 22:00:22 +00: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", ""},
|
2010-07-20 17:57:33 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
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
|
|
|
|
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
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
|
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", ""},
|
|
|
|
{0, NULL, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-11 07:43:49 +00:00
|
|
|
/********************** material operators *********************/
|
|
|
|
|
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
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ma == NULL)
|
2010-01-28 19:18:35 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2010-01-28 17:31:11 +00:00
|
|
|
|
2018-05-29 15:49:21 +02:00
|
|
|
copy_matcopybuf(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 */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL; /* no undo needed since no changes are made to the material */
|
2010-01-28 17:31:11 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ma == NULL)
|
2010-01-28 17:50:50 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2010-01-28 17:31:11 +00:00
|
|
|
|
2018-05-29 15:49:21 +02:00
|
|
|
paste_matcopybuf(CTX_data_main(C), ma);
|
2010-01-28 17:31:11 +00:00
|
|
|
|
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
|
|
|
|
2010-03-29 05:37:34 +00:00
|
|
|
|
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
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (mtexcopied == 0 || mtexcopybuf.tex == NULL)
|
2010-03-29 05:37:34 +00:00
|
|
|
return;
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
|
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
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
|
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 */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL; /* no undo needed since no changes are made to the mtex */
|
2010-03-09 09:17:45 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
|
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;
|
2018-06-27 14:41:53 +02:00
|
|
|
Lamp *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;
|
|
|
|
|
2010-03-29 05:37:34 +00:00
|
|
|
if (ma)
|
|
|
|
id = &ma->id;
|
|
|
|
else if (la)
|
|
|
|
id = &la->id;
|
|
|
|
else if (wo)
|
|
|
|
id = &wo->id;
|
2016-12-28 17:30:58 +01:00
|
|
|
else if (psys)
|
|
|
|
id = &psys->part->id;
|
2014-05-03 18:51:53 +09:00
|
|
|
else if (linestyle)
|
|
|
|
id = &linestyle->id;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (id == NULL)
|
2010-03-29 05:37:34 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
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
|
|
|
}
|