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
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_node_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
2011-02-13 12:35:26 +00: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_depsgraph.h"
|
|
|
|
#include "BKE_font.h"
|
2010-03-11 07:43:49 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_image.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"
|
|
|
|
#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
|
|
|
|
2010-03-11 07:43:49 +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-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"
|
|
|
|
#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"
|
|
|
|
|
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
|
|
|
{
|
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;
|
2014-10-06 15:12:06 +02:00
|
|
|
|
2016-07-21 05:56:12 +10:00
|
|
|
BKE_object_material_slot_add(ob);
|
2014-10-06 15:12:06 +02:00
|
|
|
|
|
|
|
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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);
|
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";
|
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;
|
|
|
|
}
|
2014-10-06 15:12:06 +02:00
|
|
|
|
2016-07-21 05:56:12 +10:00
|
|
|
BKE_object_material_slot_remove(ob);
|
2014-10-06 15:12:06 +02:00
|
|
|
|
|
|
|
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-12-22 17:38:08 +00:00
|
|
|
DAG_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);
|
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";
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-05 18:59:23 +00:00
|
|
|
DAG_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);
|
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";
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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";
|
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";
|
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
|
|
|
{
|
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)
|
|
|
|
assign_matarar(ob_iter, matar, ob->totcol);
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (ob_iter->totcol == ob->totcol) {
|
|
|
|
ob_iter->actcol = ob->actcol;
|
2014-01-17 13:16:07 +01:00
|
|
|
DAG_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);
|
|
|
|
|
2015-04-28 10:52:19 +02:00
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
2015-04-28 07:24:56 +10:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW | ND_DATA, ob);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_move(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
static EnumPropertyItem material_slot_move[] = {
|
|
|
|
{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;
|
|
|
|
|
|
|
|
RNA_def_enum(ot->srna, "direction", material_slot_move, 0, "Direction", "Direction to move, UP or DOWN");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
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);
|
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 {
|
2013-03-25 08:29:06 +00:00
|
|
|
ma = BKE_material_add(bmain, DATA_("Material"));
|
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:33:36 +00:00
|
|
|
if (BKE_scene_use_new_shading_nodes(scene)) {
|
2013-03-18 16:34:57 +00:00
|
|
|
ED_node_shader_default(C, &ma->id);
|
2014-04-01 11:34:00 +11:00
|
|
|
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);
|
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";
|
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
|
|
|
|
2014-05-28 08:19:41 +02:00
|
|
|
if (ptr.id.data && GS(((ID *)ptr.id.data)->name) == ID_MA &&
|
2014-06-06 07:54:05 +10:00
|
|
|
RNA_property_pointer_get(&ptr, prop).id.data == NULL)
|
|
|
|
{
|
2014-05-28 08:19:41 +02:00
|
|
|
/* In case we are assigning new texture to a material, and active slot was empty, reset 'use' flag. */
|
|
|
|
Material *ma = (Material *)ptr.id.data;
|
|
|
|
ma->septex &= ~(1 << ma->texact);
|
|
|
|
}
|
|
|
|
|
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);
|
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";
|
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
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
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 {
|
2013-03-26 14:33:53 +00:00
|
|
|
wo = add_world(bmain, DATA_("World"));
|
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:33:36 +00:00
|
|
|
if (BKE_scene_use_new_shading_nodes(scene)) {
|
2013-03-18 16:34:57 +00:00
|
|
|
ED_node_shader_default(C, &wo->id);
|
2014-04-01 11:34:00 +11:00
|
|
|
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);
|
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";
|
|
|
|
ot->description = "Add a new world";
|
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 *********************/
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int render_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
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Scene *scene = CTX_data_scene(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-05-05 14:33:36 +00:00
|
|
|
BKE_scene_add_render_layer(scene, NULL);
|
2014-11-16 13:57:58 +01:00
|
|
|
scene->r.actlay = BLI_listbase_count(&scene->r.layers) - 1;
|
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-02-26 18:35:55 +01:00
|
|
|
DAG_id_tag_update(&scene->id, 0);
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
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 SCENE_OT_render_layer_add(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Render Layer";
|
|
|
|
ot->idname = "SCENE_OT_render_layer_add";
|
|
|
|
ot->description = "Add a render layer";
|
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 = render_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
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int render_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
|
|
|
{
|
2011-11-18 07:11:54 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderLayer *rl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
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:33:36 +00:00
|
|
|
if (!BKE_scene_remove_render_layer(CTX_data_main(C), scene, rl))
|
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;
|
|
|
|
|
2014-02-26 18:35:55 +01:00
|
|
|
DAG_id_tag_update(&scene->id, 0);
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
|
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 SCENE_OT_render_layer_remove(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Remove Render Layer";
|
|
|
|
ot->idname = "SCENE_OT_render_layer_remove";
|
|
|
|
ot->description = "Remove the selected render layer";
|
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 = render_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
|
|
|
}
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/********************** render view operators *********************/
|
|
|
|
|
|
|
|
static int render_view_remove_poll(bContext *C)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-04-08 07:07:10 +00:00
|
|
|
static int freestyle_active_module_poll(bContext *C)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
BKE_freestyle_module_add(&srl->freestyleConfig);
|
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);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
|
|
|
|
FreestyleModuleConfig *module = ptr.data;
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
BKE_freestyle_module_delete(&srl->freestyleConfig, module);
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_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);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
|
|
|
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
|
|
|
|
2010-06-25 22:45:42 +00:00
|
|
|
if (dir == 1) {
|
2013-03-23 03:00:37 +00:00
|
|
|
BKE_freestyle_module_move_up(&srl->freestyleConfig, module);
|
2012-12-11 22:00:22 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-03-23 03:00:37 +00:00
|
|
|
BKE_freestyle_module_move_down(&srl->freestyleConfig, module);
|
2010-06-25 22:45:42 +00:00
|
|
|
}
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_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_module_move(wmOperatorType *ot)
|
2009-10-07 05:16:23 +00:00
|
|
|
{
|
2010-06-25 22:45:42 +00:00
|
|
|
static EnumPropertyItem direction_items[] = {
|
|
|
|
{1, "UP", 0, "Up", ""},
|
|
|
|
{-1, "DOWN", 0, "Down", ""},
|
|
|
|
{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 */
|
2010-06-25 22:45:42 +00:00
|
|
|
RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN");
|
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);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2015-03-19 14:33:05 +11:00
|
|
|
BKE_freestyle_lineset_add(bmain, &srl->freestyleConfig, NULL);
|
2010-06-25 22:45:42 +00:00
|
|
|
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_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
|
|
|
}
|
|
|
|
|
2010-07-20 17:57:33 +00:00
|
|
|
static int freestyle_active_lineset_poll(bContext *C)
|
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2010-07-20 17:57:33 +00:00
|
|
|
|
2013-10-18 09:45:21 +00:00
|
|
|
if (!srl) {
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2013-10-18 09:45:21 +00:00
|
|
|
}
|
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
return BKE_freestyle_lineset_get_active(&srl->freestyleConfig) != 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
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2011-11-13 21:55:13 +00:00
|
|
|
|
|
|
|
FRS_copy_active_lineset(&srl->freestyleConfig);
|
|
|
|
|
|
|
|
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);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2011-11-20 23:44:50 +00:00
|
|
|
|
|
|
|
FRS_paste_active_lineset(&srl->freestyleConfig);
|
|
|
|
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_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);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2010-06-25 22:45:42 +00:00
|
|
|
|
|
|
|
FRS_delete_active_lineset(&srl->freestyleConfig);
|
2009-10-07 05:16:23 +00:00
|
|
|
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_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);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
|
|
|
int dir = RNA_enum_get(op->ptr, "direction");
|
2010-06-25 22:45:42 +00:00
|
|
|
|
|
|
|
if (dir == 1) {
|
|
|
|
FRS_move_active_lineset_up(&srl->freestyleConfig);
|
2012-12-11 22:00:22 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-06-25 22:45:42 +00:00
|
|
|
FRS_move_active_lineset_down(&srl->freestyleConfig);
|
|
|
|
}
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_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_move(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
static EnumPropertyItem direction_items[] = {
|
|
|
|
{1, "UP", 0, "Up", ""},
|
|
|
|
{-1, "DOWN", 0, "Down", ""},
|
|
|
|
{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 */
|
2010-06-25 22:45:42 +00:00
|
|
|
RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN");
|
|
|
|
}
|
|
|
|
|
|
|
|
static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
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);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
|
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
|
|
|
}
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_id_tag_update(&lineset->linestyle->id, 0);
|
|
|
|
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)
|
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
|
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;
|
|
|
|
}
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_id_tag_update(&lineset->linestyle->id, 0);
|
|
|
|
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)
|
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
|
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;
|
|
|
|
}
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_id_tag_update(&lineset->linestyle->id, 0);
|
|
|
|
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)
|
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
|
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;
|
|
|
|
}
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_id_tag_update(&lineset->linestyle->id, 0);
|
|
|
|
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)
|
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
|
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;
|
|
|
|
}
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_id_tag_update(&lineset->linestyle->id, 0);
|
|
|
|
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)
|
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
|
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
|
|
|
}
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_id_tag_update(&lineset->linestyle->id, 0);
|
|
|
|
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)
|
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
|
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:
|
2014-07-17 09:23:30 +09:00
|
|
|
BKE_linestyle_color_modifier_copy(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_copy(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_copy(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_copy(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;
|
2012-12-11 22:00:22 +00:00
|
|
|
}
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_id_tag_update(&lineset->linestyle->id, 0);
|
|
|
|
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)
|
|
|
|
{
|
2012-12-11 22:00:22 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
|
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");
|
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_move(lineset->linestyle, modifier, dir);
|
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_move(lineset->linestyle, modifier, dir);
|
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_move(lineset->linestyle, modifier, dir);
|
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_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
|
|
|
}
|
2014-06-06 00:56:04 +09:00
|
|
|
DAG_id_tag_update(&lineset->linestyle->id, 0);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
static EnumPropertyItem direction_items[] = {
|
|
|
|
{1, "UP", 0, "Up", ""},
|
|
|
|
{-1, "DOWN", 0, "Down", ""},
|
|
|
|
{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 */
|
|
|
|
RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move, UP or DOWN");
|
|
|
|
}
|
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);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2014-07-20 20:09:46 +09:00
|
|
|
FreestyleLineStyle *linestyle = BKE_linestyle_active_from_scene(scene);
|
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;
|
2010-03-16 07:44:57 +00: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
|
|
|
if (GS(id->name) == ID_MA) {
|
|
|
|
Material *ma = (Material *)id;
|
|
|
|
int mtexuse = ma->septex & (1 << act);
|
|
|
|
ma->septex &= ~(1 << act);
|
|
|
|
ma->septex |= (ma->septex & (1 << (act - 1))) << 1;
|
|
|
|
ma->septex &= ~(1 << (act - 1));
|
2009-10-13 08:55:11 +00:00
|
|
|
ma->septex |= mtexuse >> 1;
|
|
|
|
}
|
2010-03-16 07:44:57 +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;
|
2010-03-16 07:44:57 +00: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
|
|
|
if (GS(id->name) == ID_MA) {
|
|
|
|
Material *ma = (Material *)id;
|
|
|
|
int mtexuse = ma->septex & (1 << act);
|
|
|
|
ma->septex &= ~(1 << act);
|
|
|
|
ma->septex |= (ma->septex & (1 << (act + 1))) >> 1;
|
|
|
|
ma->septex &= ~(1 << (act + 1));
|
2009-10-13 08:55:11 +00:00
|
|
|
ma->septex |= mtexuse << 1;
|
|
|
|
}
|
2010-03-16 07:44:57 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
set_active_mtex(id, act + 1);
|
2009-10-12 16:00:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-08 14:33:08 +00:00
|
|
|
DAG_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)
|
|
|
|
{
|
|
|
|
static EnumPropertyItem slot_move[] = {
|
|
|
|
{-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
|
|
|
/********************** environment map operators *********************/
|
|
|
|
|
2011-11-21 23:56:32 +00:00
|
|
|
static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, const char imtype)
|
2010-03-11 07:43:49 +00:00
|
|
|
{
|
2015-02-17 13:09:21 +11:00
|
|
|
PropertyRNA *prop;
|
2011-08-28 23:24:34 +00:00
|
|
|
float layout[12];
|
2015-02-17 13:09:21 +11:00
|
|
|
|
|
|
|
if ((prop = RNA_struct_find_property(op->ptr, "layout"))) {
|
|
|
|
RNA_property_float_get_array(op->ptr, prop, layout);
|
|
|
|
}
|
|
|
|
else {
|
2011-08-28 23:24:34 +00:00
|
|
|
memcpy(layout, default_envmap_layout, sizeof(layout));
|
2015-02-17 13:09:21 +11:00
|
|
|
}
|
2010-03-12 02:44:18 +00:00
|
|
|
|
2011-08-28 23:24:34 +00:00
|
|
|
if (RE_WriteEnvmapResult(op->reports, scene, env, path, imtype, layout)) {
|
|
|
|
return OPERATOR_FINISHED;
|
2010-03-12 02:44:18 +00:00
|
|
|
}
|
2011-01-13 04:53:55 +00:00
|
|
|
else {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2011-08-28 23:24:34 +00:00
|
|
|
|
2010-03-11 07:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int envmap_save_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
|
2010-03-11 07:43:49 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
//int imtype = RNA_enum_get(op->ptr, "file_type");
|
2011-11-21 23:56:32 +00:00
|
|
|
char imtype = scene->r.im_format.imtype;
|
2010-03-11 07:43:49 +00:00
|
|
|
char path[FILE_MAX];
|
|
|
|
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_string_get(op->ptr, "filepath", path);
|
2010-03-11 07:43:49 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene->r.scemode & R_EXTENSION) {
|
2015-01-24 16:48:23 +11:00
|
|
|
BKE_image_path_ensure_ext_from_imformat(path, &scene->r.im_format);
|
2010-03-11 07:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WM_cursor_wait(1);
|
|
|
|
|
|
|
|
save_envmap(op, scene, tex->env, path, imtype);
|
|
|
|
|
|
|
|
WM_cursor_wait(0);
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_TEXTURE, tex);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int envmap_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
2010-03-11 07:43:49 +00:00
|
|
|
{
|
|
|
|
//Scene *scene= CTX_data_scene(C);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "filepath"))
|
2010-03-11 07:43:49 +00:00
|
|
|
return envmap_save_exec(C, op);
|
|
|
|
|
2011-11-21 20:19:58 +00:00
|
|
|
//RNA_enum_set(op->ptr, "file_type", scene->r.im_format.imtype);
|
2010-10-18 06:41:16 +00:00
|
|
|
RNA_string_set(op->ptr, "filepath", G.main->name);
|
2010-03-11 07:43:49 +00:00
|
|
|
WM_event_add_fileselect(C, op);
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int envmap_save_poll(bContext *C)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
if (!tex)
|
|
|
|
return 0;
|
|
|
|
if (!tex->env || !tex->env->ok)
|
|
|
|
return 0;
|
2012-03-29 22:42:32 +00:00
|
|
|
if (tex->env->cube[1] == NULL)
|
2010-03-11 07:43:49 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TEXTURE_OT_envmap_save(wmOperatorType *ot)
|
|
|
|
{
|
2011-08-28 23:24:34 +00:00
|
|
|
PropertyRNA *prop;
|
2010-03-11 07:43:49 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Save Environment Map";
|
|
|
|
ot->idname = "TEXTURE_OT_envmap_save";
|
|
|
|
ot->description = "Save the current generated Environment map to an image file";
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = envmap_save_exec;
|
|
|
|
ot->invoke = envmap_save_invoke;
|
|
|
|
ot->poll = envmap_save_poll;
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL; /* no undo since this doesnt modify the env-map */
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
/* properties */
|
2012-10-11 23:46:12 +00:00
|
|
|
prop = RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f,
|
|
|
|
"File layout",
|
|
|
|
"Flat array describing the X,Y position of each cube face in the output image, "
|
|
|
|
"where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] "
|
|
|
|
"(use -1 to skip a face)", 0.0f, 0.0f);
|
2011-08-28 23:24:34 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN);
|
|
|
|
|
2016-02-07 22:56:20 +11:00
|
|
|
WM_operator_properties_filesel(
|
|
|
|
ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_SAVE,
|
|
|
|
WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
|
2010-03-11 07:43:49 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-03-11 07:43:49 +00:00
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
|
2010-03-11 07:43:49 +00:00
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
BKE_texture_envmap_free_data(tex->env);
|
2010-03-11 07:43:49 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex);
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int envmap_clear_poll(bContext *C)
|
|
|
|
{
|
2012-03-29 22:42:32 +00:00
|
|
|
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
if (!tex)
|
|
|
|
return 0;
|
|
|
|
if (!tex->env || !tex->env->ok)
|
|
|
|
return 0;
|
2012-03-29 22:42:32 +00:00
|
|
|
if (tex->env->cube[1] == NULL)
|
2010-03-11 07:43:49 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TEXTURE_OT_envmap_clear(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Clear Environment Map";
|
|
|
|
ot->idname = "TEXTURE_OT_envmap_clear";
|
|
|
|
ot->description = "Discard the environment map and free it from memory";
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = envmap_clear_exec;
|
|
|
|
ot->poll = envmap_clear_poll;
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
/* flags */
|
2014-02-11 15:20:30 +01:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
2010-03-11 07:43:49 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int envmap_clear_all_exec(bContext *C, wmOperator *UNUSED(op))
|
2010-03-11 07:43:49 +00:00
|
|
|
{
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
Tex *tex;
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
for (tex = bmain->tex.first; tex; tex = tex->id.next)
|
2010-03-12 02:44:18 +00:00
|
|
|
if (tex->env)
|
2015-03-29 03:16:55 +11:00
|
|
|
BKE_texture_envmap_free_data(tex->env);
|
2010-03-11 07:43:49 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex);
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TEXTURE_OT_envmap_clear_all(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Clear All Environment Maps";
|
|
|
|
ot->idname = "TEXTURE_OT_envmap_clear_all";
|
|
|
|
ot->description = "Discard all environment maps in the .blend file and free them from memory";
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = envmap_clear_all_exec;
|
|
|
|
ot->poll = envmap_clear_poll;
|
2010-03-11 07:43:49 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-29 22:42:32 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
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
|
|
|
|
|
|
|
copy_matcopybuf(ma);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
paste_matcopybuf(ma);
|
|
|
|
|
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;
|
2010-03-29 05:37:34 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
switch (GS(id->name)) {
|
2010-03-29 05:37:34 +00:00
|
|
|
case ID_MA:
|
2012-03-29 22:42:32 +00:00
|
|
|
mtex = &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
|
2010-03-29 05:37:34 +00:00
|
|
|
break;
|
|
|
|
case ID_LA:
|
2012-03-29 22:42:32 +00:00
|
|
|
mtex = &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
|
2010-03-29 05:37:34 +00:00
|
|
|
// la->mtex[(int)la->texact] // TODO
|
|
|
|
break;
|
|
|
|
case ID_WO:
|
2012-03-29 22:42:32 +00:00
|
|
|
mtex = &(((World *)id)->mtex[(int)((World *)id)->texact]);
|
2010-03-29 05:37:34 +00:00
|
|
|
// mtex= wrld->mtex[(int)wrld->texact]; // TODO
|
|
|
|
break;
|
2011-02-13 12:35:26 +00:00
|
|
|
case ID_PA:
|
2012-03-29 22:42:32 +00:00
|
|
|
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
|
2011-02-13 12:35:26 +00:00
|
|
|
break;
|
2014-05-03 18:51:53 +09:00
|
|
|
case ID_LS:
|
|
|
|
mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
|
|
|
|
break;
|
2010-03-29 05:37:34 +00: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;
|
2010-03-29 05:37:34 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (mtexcopied == 0 || mtexcopybuf.tex == NULL)
|
2010-03-29 05:37:34 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
switch (GS(id->name)) {
|
2010-03-29 05:37:34 +00:00
|
|
|
case ID_MA:
|
2012-03-29 22:42:32 +00:00
|
|
|
mtex = &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
|
2010-03-29 05:37:34 +00:00
|
|
|
break;
|
|
|
|
case ID_LA:
|
2012-03-29 22:42:32 +00:00
|
|
|
mtex = &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
|
2010-03-29 05:37:34 +00:00
|
|
|
// la->mtex[(int)la->texact] // TODO
|
|
|
|
break;
|
|
|
|
case ID_WO:
|
2012-03-29 22:42:32 +00:00
|
|
|
mtex = &(((World *)id)->mtex[(int)((World *)id)->texact]);
|
2010-03-29 05:37:34 +00:00
|
|
|
// mtex= wrld->mtex[(int)wrld->texact]; // TODO
|
|
|
|
break;
|
2011-02-13 12:35:26 +00:00
|
|
|
case ID_PA:
|
2012-03-29 22:42:32 +00:00
|
|
|
mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
|
2011-02-13 12:35:26 +00:00
|
|
|
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:
|
|
|
|
BLI_assert("invalid id type");
|
|
|
|
return;
|
2010-03-29 05:37:34 +00: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
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(*mtex, &mtexcopybuf, sizeof(MTex));
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-03-29 05:37:34 +00:00
|
|
|
static int copy_mtex_poll(bContext *C)
|
|
|
|
{
|
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
|
|
|
|
|
|
|
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;
|
2010-03-29 05:37:34 +00: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;
|
|
|
|
Lamp *la = CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data;
|
|
|
|
World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
|
|
|
|
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;
|
2011-02-13 12:35:26 +00:00
|
|
|
else if (psys)
|
|
|
|
id = &psys->part->id;
|
2014-05-03 18:51:53 +09:00
|
|
|
else if (linestyle)
|
|
|
|
id = &linestyle->id;
|
2010-03-29 05:37:34 +00:00
|
|
|
|
2012-03-29 22:42:32 +00:00
|
|
|
if (id == NULL)
|
2010-03-29 05:37:34 +00:00
|
|
|
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
|
|
|
}
|
2011-05-19 11:34:11 +00:00
|
|
|
|