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.
This commit is contained in:
@@ -125,15 +125,15 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
|
||||
@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,12 +146,42 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
|
||||
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))
|
||||
|
||||
@@ -177,13 +207,10 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
|
||||
|
||||
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="")
|
||||
|
Reference in New Issue
Block a user