Revision: 56870
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56870
Author: mont29
Date: 2013-05-17 07:10:10 +0000 (Fri, 17 May 2013)
Log Message:
-----------
This commit addresses the somewhat weak handling of stackless textures in
Blender with default (BI) renderer. To do so, it's defining an "other" texture
context, and when in this one, it switches to using the "new shading" texture
handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have
direct access to modifiers', force's or brushes' textures...
I also refactored a bit how texture contexts are handled (once again, we had
some quite similar code in both space_buttons and RNA sources). This should
also solve some harmless glitches like "no texture context selected in UI"
sometimes when you remove data related to current texture (see e.g. after
removing the material from default cube, in startup scene).
This usage of two different systems for textures, and the handling of switches
between them, has been a bit tricky to get working right, but it is OK now I
think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED
(use_limited_texture_context in RNA), which indicates "new shading" texture
code whether it has to ignore materials, lamps etc. (BI) or not (Cycles).
Btw, pinned textures from modifiers/force/etc. were also broken (showing
nothing), now it should work too.
Thanks to Brecht for reviewing.
Modified Paths:
--------------
trunk/blender/intern/cycles/blender/addon/ui.py
trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
trunk/blender/source/blender/editors/space_buttons/buttons_context.c
trunk/blender/source/blender/editors/space_buttons/buttons_header.c
trunk/blender/source/blender/editors/space_buttons/buttons_intern.h
trunk/blender/source/blender/editors/space_buttons/buttons_texture.c
trunk/blender/source/blender/makesdna/DNA_space_types.h
trunk/blender/source/blender/makesrna/intern/rna_space.c
trunk/blender/source/blenderplayer/bad_level_call_stubs/stubs.c
Added Paths:
-----------
trunk/blender/source/blender/editors/include/ED_buttons.h
Modified: trunk/blender/intern/cycles/blender/addon/ui.py
===================================================================
--- trunk/blender/intern/cycles/blender/addon/ui.py 2013-05-17 07:00:21 UTC
(rev 56869)
+++ trunk/blender/intern/cycles/blender/addon/ui.py 2013-05-17 07:10:10 UTC
(rev 56870)
@@ -885,13 +885,15 @@
use_pin_id = space.use_pin_id
user = context.texture_user
- if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
+ space.use_limited_texture_context = False
+
+ if not (use_pin_id and isinstance(pin_id, bpy.types.Texture)):
pin_id = None
if not pin_id:
layout.template_texture_user()
- if user:
+ if user or pin_id:
layout.separator()
split = layout.split(percentage=0.65)
Modified: trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
2013-05-17 07:00:21 UTC (rev 56869)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
2013-05-17 07:10:10 UTC (rev 56870)
@@ -125,15 +125,15 @@
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
- if not (hasattr(context, "texture_slot") or hasattr(context,
"texture_node")):
- return False
+ #if not (hasattr(context, "texture_slot") or hasattr(context,
"texture_node")):
+ #return False
return ((context.material or
context.world or
context.lamp or
- context.brush or
context.texture or
context.particle_system or
- isinstance(context.space_data.pin_id, ParticleSettings)) and
+ isinstance(context.space_data.pin_id, ParticleSettings) or
+ context.texture_user) and
(engine in cls.COMPAT_ENGINES))
def draw(self, context):
@@ -146,13 +146,43 @@
idblock = context_tex_datablock(context)
pin_id = space.pin_id
+ space.use_limited_texture_context = True
+
if space.use_pin_id and not isinstance(pin_id, Texture):
idblock = id_tex_datablock(pin_id)
pin_id = None
if not space.use_pin_id:
layout.prop(space, "texture_context", expand=True)
+ pin_id = None
+ if space.texture_context == 'OTHER':
+ if not pin_id:
+ layout.template_texture_user()
+ user = context.texture_user
+ if user or pin_id:
+ layout.separator()
+
+ split = layout.split(percentage=0.65)
+ col = split.column()
+
+ if pin_id:
+ col.template_ID(space, "pin_id")
+ else:
+ propname = context.texture_user_property.identifier
+ col.template_ID(user, propname, new="texture.new")
+
+ if tex:
+ split = layout.split(percentage=0.2)
+ if tex.use_nodes:
+ if slot:
+ split.label(text="Output:")
+ split.prop(slot, "output_node", text="")
+ else:
+ split.label(text="Type:")
+ split.prop(tex, "type", text="")
+ return
+
tex_collection = (pin_id is None) and (node is None) and (not
isinstance(idblock, Brush))
if tex_collection:
@@ -177,13 +207,10 @@
if tex:
split = layout.split(percentage=0.2)
-
if tex.use_nodes:
-
if slot:
split.label(text="Output:")
split.prop(slot, "output_node", text="")
-
else:
split.label(text="Type:")
split.prop(tex, "type", text="")
Added: trunk/blender/source/blender/editors/include/ED_buttons.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_buttons.h
(rev 0)
+++ trunk/blender/source/blender/editors/include/ED_buttons.h 2013-05-17
07:10:10 UTC (rev 56870)
@@ -0,0 +1,39 @@
+/*
+ * ***** 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2013, Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ED_buttons.h
+ * \ingroup editors
+ */
+
+#ifndef __ED_BUTTONS_H__
+#define __ED_BUTTONS_H__
+
+#include "BLI_utildefines.h"
+
+/* Used to check whether a given texture context is valid in current context.
*/
+bool ED_texture_context_check_world(const struct bContext *C);
+bool ED_texture_context_check_material(const struct bContext *C);
+bool ED_texture_context_check_lamp(const struct bContext *C);
+bool ED_texture_context_check_particles(const struct bContext *C);
+bool ED_texture_context_check_others(const struct bContext *C);
+
+#endif /* __ED_BUTTONS_H__ */
Modified: trunk/blender/source/blender/editors/space_buttons/buttons_context.c
===================================================================
--- trunk/blender/source/blender/editors/space_buttons/buttons_context.c
2013-05-17 07:00:21 UTC (rev 56869)
+++ trunk/blender/source/blender/editors/space_buttons/buttons_context.c
2013-05-17 07:10:10 UTC (rev 56870)
@@ -397,7 +397,7 @@
else if (GS(id->name) == ID_OB)
buttons_context_path_object(path);
}
-
+
if (ct->texture) {
RNA_id_pointer_create(&ct->texture->id,
&path->ptr[path->len]);
path->len++;
@@ -409,31 +409,17 @@
/* old shading system */
Material *ma;
Lamp *la;
- Brush *br;
World *wo;
ParticleSystem *psys;
Tex *tex;
PointerRNA *ptr = &path->ptr[path->len - 1];
- int orig_len = path->len;
/* if we already have a (pinned) texture, we're done */
if (RNA_struct_is_a(ptr->type, &RNA_Texture)) {
return 1;
}
- /* try brush */
- if ((path->tex_ctx == SB_TEXC_BRUSH) &&
buttons_context_path_brush(path)) {
- br = path->ptr[path->len - 1].data;
-
- if (br) {
- tex = give_current_brush_texture(br);
-
- RNA_id_pointer_create(&tex->id,
&path->ptr[path->len]);
- path->len++;
- return 1;
- }
- }
/* try world */
- if ((path->tex_ctx == SB_TEXC_WORLD) &&
buttons_context_path_world(path)) {
+ else if ((path->tex_ctx == SB_TEXC_WORLD) &&
buttons_context_path_world(path)) {
wo = path->ptr[path->len - 1].data;
if (wo && GS(wo->id.name) == ID_WO) {
@@ -445,7 +431,7 @@
}
}
/* try particles */
- if ((path->tex_ctx == SB_TEXC_PARTICLES) &&
buttons_context_path_particle(path)) {
+ else if ((path->tex_ctx == SB_TEXC_PARTICLES) &&
buttons_context_path_particle(path)) {
if (path->ptr[path->len - 1].type ==
&RNA_ParticleSettings) {
ParticleSettings *part = path->ptr[path->len -
1].data;
@@ -467,7 +453,7 @@
}
}
/* try material */
- if (buttons_context_path_material(path, 1)) {
+ else if ((path->tex_ctx == SB_TEXC_MATERIAL) &&
buttons_context_path_material(path, 1)) {
ma = path->ptr[path->len - 1].data;
if (ma) {
@@ -479,7 +465,7 @@
}
}
/* try lamp */
- if (buttons_context_path_data(path, OB_LAMP)) {
+ else if ((path->tex_ctx == SB_TEXC_LAMP) &&
buttons_context_path_data(path, OB_LAMP)) {
la = path->ptr[path->len - 1].data;
if (la) {
@@ -490,19 +476,6 @@
return 1;
}
}
- /* try brushes again in case of no material, lamp, etc */
- path->len = orig_len;
- if (buttons_context_path_brush(path)) {
- br = path->ptr[path->len - 1].data;
-
- if (br) {
- tex = give_current_brush_texture(br);
-
- RNA_id_pointer_create(&tex->id,
&path->ptr[path->len]);
- path->len++;
- return 1;
- }
- }
}
/* no path to a texture possible */
@@ -813,8 +786,9 @@
if (ct) {
/* new shading system */
- if (ct->user && ct->user->node)
+ if (ct->user && ct->user->node) {
CTX_data_pointer_set(result,
&ct->user->ntree->id, &RNA_Node, ct->user->node);
+ }
return 1;
}
@@ -838,19 +812,26 @@
ButsContextTexture *ct = sbuts->texuser;
PointerRNA *ptr;
- if ((ptr = get_pointer_type(path, &RNA_Material))) {
+ /* Particles slots are used in both old and new textures
handling. */
+ if ((ptr = get_pointer_type(path, &RNA_ParticleSystem))) {
+ ParticleSettings *part = ((ParticleSystem
*)ptr->data)->part;
+
+ if (part)
+ CTX_data_pointer_set(result, &part->id,
&RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]);
+ }
+ else if (ct) {
+ return 0; /* new shading system */
+ }
+ else if ((ptr = get_pointer_type(path, &RNA_Material))) {
Material *ma = ptr->data;
- if (ct)
- return 0; /* new shading system */
-
/* if we have a node material, get slot from material
in material node */
if (ma && ma->use_nodes && ma->nodetree) {
/* if there's an active texture node in the
node tree,
* then that texture is in context directly,
without a texture slot */
if (give_current_material_texture_node(ma))
return 0;
-
+
ma = give_node_material(ma);
if (ma)
CTX_data_pointer_set(result, &ma->id,
&RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
@@ -864,34 +845,16 @@
else if ((ptr = get_pointer_type(path, &RNA_Lamp))) {
Lamp *la = ptr->data;
- if (ct)
- return 0; /* new shading system */
-
if (la)
CTX_data_pointer_set(result, &la->id,
&RNA_LampTextureSlot, la->mtex[(int)la->texact]);
}
else if ((ptr = get_pointer_type(path, &RNA_World))) {
World *wo = ptr->data;
- if (ct)
- return 0; /* new shading system */
-
if (wo)
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs