forked from bartvdbraak/blender
51b796ff15
Brecht authored this commit, but he gave me the honours to actually do it. Here it goes; Blender Internal. Bye bye, you did great! * Point density, voxel data, ocean, environment map textures were removed, as these only worked within BI rendering. Note that the ocean modifier and the Cycles point density shader node continue to work. * Dynamic paint using material shading was removed, as this only worked with BI. If we ever wanted to support this again probably it should go through the baking API. * GPU shader export through the Python API was removed. This only worked for the old BI GLSL shaders, which no longer exists. Doing something similar for Eevee would be significantly more complicated because it uses a lot of multiplass rendering and logic outside the shader, it's probably impractical. * Collada material import / export code is mostly gone, as it only worked for BI materials. We need to add Cycles / Eevee material support at some point. * The mesh noise operator was removed since it only worked with BI material texture slots. A displacement modifier can be used instead. * The delete texture paint slot operator was removed since it only worked for BI material texture slots. Could be added back with node support. * Not all legacy viewport features are supported in the new viewport, but their code was removed. If we need to bring anything back we can look at older git revisions. * There is some legacy viewport code that I could not remove yet, and some that I probably missed. * Shader node execution code was left mostly intact, even though it is not used anywhere now. We may eventually use this to replace the texture nodes with Cycles / Eevee shader nodes. * The Cycles Bake panel now includes settings for baking multires normal and displacement maps. The underlying code needs to be merged properly, and we plan to add back support for multires AO baking and add support to Cycles baking for features like vertex color, displacement, and other missing baking features. * This commit removes DNA and the Python API for BI material, lamp, world and scene settings. This breaks a lot of addons. * There is more DNA that can be removed or renamed, where Cycles or Eevee are reusing some old BI properties but the names are not really correct anymore. * Texture slots for materials, lamps and world were removed. They remain for brushes, particles and freestyle linestyles. * 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and other renderers use this to find all panels to show, minus a few panels that they have their own replacement for.
74 lines
3.5 KiB
Python
74 lines
3.5 KiB
Python
import bpy
|
|
|
|
|
|
class MATERIAL_UL_matslots_example(bpy.types.UIList):
|
|
# The draw_item function is called for each item of the collection that is visible in the list.
|
|
# data is the RNA object containing the collection,
|
|
# item is the current drawn item of the collection,
|
|
# icon is the "computed" icon for the item (as an integer, because some objects like materials or textures
|
|
# have custom icons ID, which are not available as enum items).
|
|
# active_data is the RNA object containing the active property for the collection (i.e. integer pointing to the
|
|
# active item of the collection).
|
|
# active_propname is the name of the active property (use 'getattr(active_data, active_propname)').
|
|
# index is index of the current item in the collection.
|
|
# flt_flag is the result of the filtering process for this item.
|
|
# Note: as index and flt_flag are optional arguments, you do not have to use/declare them here if you don't
|
|
# need them.
|
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
|
ob = data
|
|
slot = item
|
|
ma = slot.material
|
|
# draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code.
|
|
if self.layout_type in {'DEFAULT', 'COMPACT'}:
|
|
# You should always start your row layout by a label (icon + text), or a non-embossed text field,
|
|
# this will also make the row easily selectable in the list! The later also enables ctrl-click rename.
|
|
# We use icon_value of label, as our given icon is an integer value, not an enum ID.
|
|
# Note "data" names should never be translated!
|
|
if ma:
|
|
layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
|
|
else:
|
|
layout.label(text="", translate=False, icon_value=icon)
|
|
# 'GRID' layout type should be as compact as possible (typically a single icon!).
|
|
elif self.layout_type in {'GRID'}:
|
|
layout.alignment = 'CENTER'
|
|
layout.label(text="", icon_value=icon)
|
|
|
|
|
|
# And now we can use this list everywhere in Blender. Here is a small example panel.
|
|
class UIListPanelExample(bpy.types.Panel):
|
|
"""Creates a Panel in the Object properties window"""
|
|
bl_label = "UIList Panel"
|
|
bl_idname = "OBJECT_PT_ui_list_example"
|
|
bl_space_type = 'PROPERTIES'
|
|
bl_region_type = 'WINDOW'
|
|
bl_context = "object"
|
|
|
|
def draw(self, context):
|
|
layout = self.layout
|
|
|
|
obj = context.object
|
|
|
|
# template_list now takes two new args.
|
|
# The first one is the identifier of the registered UIList to use (if you want only the default list,
|
|
# with no custom draw code, use "UI_UL_list").
|
|
layout.template_list("MATERIAL_UL_matslots_example", "", obj, "material_slots", obj, "active_material_index")
|
|
|
|
# The second one can usually be left as an empty string. It's an additional ID used to distinguish lists in case you
|
|
# use the same list several times in a given area.
|
|
layout.template_list("MATERIAL_UL_matslots_example", "compact", obj, "material_slots",
|
|
obj, "active_material_index", type='COMPACT')
|
|
|
|
|
|
def register():
|
|
bpy.utils.register_class(MATERIAL_UL_matslots_example)
|
|
bpy.utils.register_class(UIListPanelExample)
|
|
|
|
|
|
def unregister():
|
|
bpy.utils.unregister_class(MATERIAL_UL_matslots_example)
|
|
bpy.utils.unregister_class(UIListPanelExample)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
register()
|