[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56437] branches/vgroup_modifiers: Rework a bit how textures are handled in Properties, BI render engine.
Bastien Montagne
montagne29 at wanadoo.fr
Wed May 1 12:42:43 CEST 2013
Revision: 56437
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56437
Author: mont29
Date: 2013-05-01 10:42:43 +0000 (Wed, 01 May 2013)
Log Message:
-----------
Rework a bit how textures are handled in Properties, BI render engine.
Actually basically adding a generic "Other" tex context which reuses Cycles' list of textures, but limited to "non-texslots" texture users (i.e. modifiers, force field and brush). This way we finally can access modifiers or field textures whitout having to select them in a material or similar trick.
This code is still a bit WIP, but works rather nice.
Modified Paths:
--------------
branches/vgroup_modifiers/intern/cycles/blender/addon/ui.py
branches/vgroup_modifiers/release/scripts/startup/bl_ui/properties_texture.py
branches/vgroup_modifiers/source/blender/editors/interface/interface_templates.c
branches/vgroup_modifiers/source/blender/editors/space_buttons/buttons_context.c
branches/vgroup_modifiers/source/blender/editors/space_buttons/buttons_header.c
branches/vgroup_modifiers/source/blender/editors/space_buttons/buttons_texture.c
branches/vgroup_modifiers/source/blender/makesdna/DNA_space_types.h
branches/vgroup_modifiers/source/blender/makesrna/intern/rna_space.c
branches/vgroup_modifiers/source/blender/windowmanager/intern/wm_keymap.c
branches/vgroup_modifiers/source/blenderplayer/bad_level_call_stubs/stubs.c
Added Paths:
-----------
branches/vgroup_modifiers/source/blender/editors/include/ED_buttons.h
Modified: branches/vgroup_modifiers/intern/cycles/blender/addon/ui.py
===================================================================
--- branches/vgroup_modifiers/intern/cycles/blender/addon/ui.py 2013-05-01 10:32:45 UTC (rev 56436)
+++ branches/vgroup_modifiers/intern/cycles/blender/addon/ui.py 2013-05-01 10:42:43 UTC (rev 56437)
@@ -882,6 +882,8 @@
use_pin_id = space.use_pin_id
user = context.texture_user
+ space.use_limited_texture_context = False
+
if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
pin_id = None
Modified: branches/vgroup_modifiers/release/scripts/startup/bl_ui/properties_texture.py
===================================================================
--- branches/vgroup_modifiers/release/scripts/startup/bl_ui/properties_texture.py 2013-05-01 10:32:45 UTC (rev 56436)
+++ branches/vgroup_modifiers/release/scripts/startup/bl_ui/properties_texture.py 2013-05-01 10:42:43 UTC (rev 56437)
@@ -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,35 @@
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)
+ if space.texture_context == 'OTHER':
+ layout.template_texture_user()
+ user = context.texture_user
+ if user:
+ 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)
+ 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:
Added: branches/vgroup_modifiers/source/blender/editors/include/ED_buttons.h
===================================================================
--- branches/vgroup_modifiers/source/blender/editors/include/ED_buttons.h (rev 0)
+++ branches/vgroup_modifiers/source/blender/editors/include/ED_buttons.h 2013-05-01 10:42:43 UTC (rev 56437)
@@ -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(struct bContext *C);
+bool ED_texture_context_check_material(struct bContext *C);
+bool ED_texture_context_check_lamp(struct bContext *C);
+bool ED_texture_context_check_particles(struct bContext *C);
+bool ED_texture_context_check_others(struct bContext *C);
+
+#endif /* __ED_BUTTONS_H__ */
Modified: branches/vgroup_modifiers/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/vgroup_modifiers/source/blender/editors/interface/interface_templates.c 2013-05-01 10:32:45 UTC (rev 56436)
+++ branches/vgroup_modifiers/source/blender/editors/interface/interface_templates.c 2013-05-01 10:42:43 UTC (rev 56437)
@@ -887,8 +887,6 @@
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
- if (mti->flags & eModifierTypeFlag_UsesPreview)
- uiItemR(row, &ptr, "use_preview", 0, "", ICON_NONE);
if (mti->flags & eModifierTypeFlag_SupportsEditmode)
uiItemR(row, &ptr, "show_in_editmode", 0, "", ICON_NONE);
}
Modified: branches/vgroup_modifiers/source/blender/editors/space_buttons/buttons_context.c
===================================================================
--- branches/vgroup_modifiers/source/blender/editors/space_buttons/buttons_context.c 2013-05-01 10:32:45 UTC (rev 56436)
+++ branches/vgroup_modifiers/source/blender/editors/space_buttons/buttons_context.c 2013-05-01 10:42:43 UTC (rev 56437)
@@ -409,29 +409,15 @@
/* 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)) {
wo = path->ptr[path->len - 1].data;
@@ -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 */
@@ -838,19 +811,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 +844,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)
CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]);
}
- else if ((ptr = get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */
- Brush *br = ptr->data;
- if (br)
- CTX_data_pointer_set(result, &br->id, &RNA_BrushTextureSlot, &br->mtex);
- }
- else 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]);
- }
-
return 1;
}
else if (CTX_data_equals(member, "bone")) {
Modified: branches/vgroup_modifiers/source/blender/editors/space_buttons/buttons_header.c
===================================================================
--- branches/vgroup_modifiers/source/blender/editors/space_buttons/buttons_header.c 2013-05-01 10:32:45 UTC (rev 56436)
+++ branches/vgroup_modifiers/source/blender/editors/space_buttons/buttons_header.c 2013-05-01 10:42:43 UTC (rev 56437)
@@ -38,10 +38,15 @@
#include "BLF_translation.h"
#include "BKE_context.h"
+#include "BKE_modifier.h"
+#include "BKE_paint.h"
+#include "ED_buttons.h"
#include "ED_screen.h"
#include "ED_types.h"
+#include "DNA_brush_types.h"
+#include "DNA_object_force.h"
#include "DNA_object_types.h"
#include "UI_interface.h"
@@ -54,25 +59,97 @@
#define B_CONTEXT_SWITCH 101
#define B_BUTSPREVIEW 102
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list