Update addons for D9697 "_RNA_UI" removal
This is a followup patch for D9697 which applies the changes to the addon reporistory. Almost all of the changes are in rigify, but there is one change in "curve_tools" and two trivial changes in IO addons. Differential Revision: https://developer.blender.org/D9919
This commit is contained in:
parent
53c7859c91
commit
104ba1c568
Notes:
blender-bot
2023-02-14 18:06:52 +01:00
Referenced by commit 0574f418: Fix: Incorrect soft max after IDProperty UI data refactor
Referenced by commit 0574f418
, Fix: Incorrect soft max after IDProperty UI data refactor
|
@ -20,7 +20,6 @@ import bpy
|
|||
from bpy.types import Operator
|
||||
from bpy_extras import object_utils
|
||||
from mathutils import Vector
|
||||
from rna_prop_ui import rna_idprop_ui_prop_get
|
||||
from math import pi
|
||||
|
||||
from .create_widgets import (create_root_widget,
|
||||
|
@ -158,11 +157,8 @@ def setup_3d_rig(rig, cam):
|
|||
# Lens property
|
||||
pb = pose_bones['Camera']
|
||||
pb["lens"] = 50.0
|
||||
prop = rna_idprop_ui_prop_get(pb, "lens", create=True)
|
||||
prop["default"] = 50.0
|
||||
prop["min"] = 1.0
|
||||
prop["max"] = 1000000.0
|
||||
prop["soft_max"] = 5000.0
|
||||
ui_data = pb.id_properties_ui("lens")
|
||||
ui_data.update(min=1.0, max=1000000.0, soft_max = 5000.0, default=50.0)
|
||||
|
||||
# Build the widgets
|
||||
root_widget = create_root_widget("Camera_Root")
|
||||
|
@ -327,12 +323,8 @@ def create_2d_bones(context, rig, cam):
|
|||
|
||||
# Property to switch between rotation and switch mode
|
||||
pose_bones["Camera"]['rotation_shift'] = 0.0
|
||||
prop = rna_idprop_ui_prop_get(pose_bones["Camera"], 'rotation_shift', create=True)
|
||||
prop["min"] = 0.0
|
||||
prop["max"] = 1.0
|
||||
prop["soft_min"] = 0.0
|
||||
prop["soft_max"] = 1.0
|
||||
prop["description"] = 'rotation_shift'
|
||||
ui_data = pose_bones["Camera"].id_properties_ui('rotation_shift')
|
||||
ui_data.update(min=0.0, max=1.0, soft_max = 5000.0, description="rotation_shift")
|
||||
|
||||
# Rotation / shift switch driver
|
||||
driver = con.driver_add('influence').driver
|
||||
|
@ -526,18 +518,14 @@ def build_camera_rig(context, mode):
|
|||
# DOF Focus Distance property
|
||||
pb = pose_bones['Camera']
|
||||
pb["focus_distance"] = 10.0
|
||||
prop = rna_idprop_ui_prop_get(pb, "focus_distance", create=True)
|
||||
prop["default"] = 10.0
|
||||
prop["min"] = 0.0
|
||||
ui_data = pb.id_properties_ui('focus_distance')
|
||||
ui_data.update(min=0.0, default=10.0)
|
||||
|
||||
# DOF F-Stop property
|
||||
pb = pose_bones['Camera']
|
||||
pb["aperture_fstop"] = 2.8
|
||||
prop = rna_idprop_ui_prop_get(pb, "aperture_fstop", create=True)
|
||||
prop["default"] = 2.8
|
||||
prop["min"] = 0.0
|
||||
prop["soft_min"] = 0.1
|
||||
prop["soft_max"] = 128.0
|
||||
ui_data = pb.id_properties_ui('aperture_fstop')
|
||||
ui_data.update(min=0.0, soft_min=0.1, soft_max=128.0, default=2.8)
|
||||
|
||||
# Add drivers to link the camera properties to the custom props
|
||||
# on the armature
|
||||
|
|
|
@ -30,13 +30,10 @@ class OperatorAutoLoftCurves(Operator):
|
|||
|
||||
context.collection.objects.link(loftobj)
|
||||
loftobj["autoloft"] = True
|
||||
if loftobj.get('_RNA_UI') is None:
|
||||
loftobj['_RNA_UI'] = {}
|
||||
loftobj['_RNA_UI']["autoloft"] = {
|
||||
"name": "Auto Loft",
|
||||
"description": "Auto loft from %s to %s" % (curve0.name, curve1.name),
|
||||
"curve0": curve0.name,
|
||||
"curve1": curve1.name}
|
||||
ui_data = loftobj.id_properties_ui("autoloft")
|
||||
ui_data.update(description="Auto loft from %s to %s" % (curve0.name, curve1.name))
|
||||
loftobj["autoloft_curve0"] = curve0.name
|
||||
loftobj["autoloft_curve1"] = curve1.name
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
@ -59,9 +56,8 @@ class AutoLoftModalOperator(Operator):
|
|||
#print("TIMER", lofters)
|
||||
|
||||
for loftmesh in lofters:
|
||||
rna = loftmesh['_RNA_UI']["autoloft"].to_dict()
|
||||
curve0 = scene.objects.get(rna["curve0"])
|
||||
curve1 = scene.objects.get(rna["curve1"])
|
||||
curve0 = scene.objects.get(loftmesh['autoloft_curve0'])
|
||||
curve1 = scene.objects.get(loftmesh['autoloft_curve1'])
|
||||
if curve0 and curve1:
|
||||
ls = surfaces.LoftedSurface(curves.Curve(curve0), curves.Curve(curve1), loftmesh.name)
|
||||
ls.bMesh.to_mesh(loftmesh.data)
|
||||
|
|
|
@ -542,7 +542,7 @@ def fbx_data_element_custom_properties(props, bid):
|
|||
rna_properties = {prop.identifier for prop in bid.bl_rna.properties if prop.is_runtime}
|
||||
|
||||
for k, v in items:
|
||||
if k == '_RNA_UI' or k in rna_properties:
|
||||
if k in rna_properties:
|
||||
continue
|
||||
|
||||
list_val = getattr(v, "to_list", lambda: None)()
|
||||
|
|
|
@ -18,7 +18,7 @@ from .gltf2_blender_json import is_json_convertible
|
|||
|
||||
|
||||
# Custom properties, which are in most cases present and should not be imported/exported.
|
||||
BLACK_LIST = ['cycles', 'cycles_visibility', 'cycles_curves', '_RNA_UI', 'glTF2ExportSettings']
|
||||
BLACK_LIST = ['cycles', 'cycles_visibility', 'cycles_curves', 'glTF2ExportSettings']
|
||||
|
||||
|
||||
def generate_extras(blender_element):
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
import bpy
|
||||
import re
|
||||
import time
|
||||
from rna_prop_ui import rna_idprop_ui_prop_get
|
||||
|
||||
from .utils.errors import MetarigError
|
||||
from .utils.bones import new_bone
|
||||
|
@ -415,7 +414,6 @@ class Generator(base_generate.BaseGenerator):
|
|||
|
||||
#------------------------------------------
|
||||
# Put the rig_name in the armature custom properties
|
||||
rna_idprop_ui_prop_get(obj.data, "rig_id", create=True)
|
||||
obj.data["rig_id"] = self.rig_id
|
||||
|
||||
self.script = rig_ui_template.ScriptGenerator(self)
|
||||
|
|
|
@ -23,7 +23,7 @@ import re
|
|||
|
||||
from bpy.types import bpy_prop_collection, Material
|
||||
|
||||
from rna_prop_ui import rna_idprop_ui_create, rna_idprop_ui_prop_get
|
||||
from rna_prop_ui import rna_idprop_ui_create
|
||||
from rna_prop_ui import rna_idprop_quote_path as quote_property
|
||||
|
||||
from .misc import force_lazy
|
||||
|
@ -137,7 +137,7 @@ def make_property(
|
|||
"""
|
||||
|
||||
# Some keyword argument defaults differ
|
||||
return rna_idprop_ui_create(
|
||||
rna_idprop_ui_create(
|
||||
owner, name, default = default,
|
||||
min = min, max = max, soft_min = soft_min, soft_max = soft_max,
|
||||
description = description or name,
|
||||
|
@ -440,8 +440,9 @@ def deactivate_custom_properties(obj, *, reset=True):
|
|||
for key, value in obj.items():
|
||||
valtype = type(value)
|
||||
if valtype in {int, float}:
|
||||
info = rna_idprop_ui_prop_get(obj, key, create=False) or {}
|
||||
obj[key] = valtype(info.get("default", 0))
|
||||
ui_data = obj.id_properties_ui(key)
|
||||
rna_data = ui_data.as_dict()
|
||||
obj[key] = valtype(rna_data.get("default", 0))
|
||||
|
||||
|
||||
def reactivate_custom_properties(obj):
|
||||
|
@ -462,21 +463,19 @@ def reactivate_custom_properties(obj):
|
|||
def copy_custom_properties(src, dest, *, prefix='', dest_prefix='', link_driver=False, overridable=True):
|
||||
"""Copy custom properties with filtering by prefix. Optionally link using drivers."""
|
||||
res = []
|
||||
exclude = {'_RNA_UI', 'rigify_parameters', 'rigify_type'}
|
||||
exclude = {'rigify_parameters', 'rigify_type'}
|
||||
|
||||
for key, value in src.items():
|
||||
if key.startswith(prefix) and key not in exclude:
|
||||
new_key = dest_prefix + key[len(prefix):]
|
||||
|
||||
info = rna_idprop_ui_prop_get(src, key, create=False)
|
||||
ui_data_src = src.id_properties_ui(key)
|
||||
|
||||
|
||||
if src != dest or new_key != key:
|
||||
dest[new_key] = value
|
||||
|
||||
if info:
|
||||
info2 = rna_idprop_ui_prop_get(dest, new_key, create=True)
|
||||
for ki, vi in info.items():
|
||||
info2[ki] = vi
|
||||
dest.id_properties_ui(new_key).update_from(ui_data_src)
|
||||
|
||||
if link_driver:
|
||||
make_driver(src, quote_property(key), variables=[(dest.id_data, dest, new_key)])
|
||||
|
@ -484,7 +483,7 @@ def copy_custom_properties(src, dest, *, prefix='', dest_prefix='', link_driver=
|
|||
if overridable:
|
||||
dest.property_overridable_library_set(quote_property(new_key), True)
|
||||
|
||||
res.append((key, new_key, value, info))
|
||||
res.append((key, new_key, value))
|
||||
|
||||
return res
|
||||
|
||||
|
@ -500,7 +499,7 @@ def copy_custom_properties_with_ui(rig, src, dest_bone, *, ui_controls=None, **o
|
|||
if mapping:
|
||||
panel = rig.script.panel_with_selected_check(rig, ui_controls or rig.bones.flatten('ctrl'))
|
||||
|
||||
for key,new_key,value,info in sorted(mapping, key=lambda item: item[1]):
|
||||
for key,new_key,value in sorted(mapping, key=lambda item: item[1]):
|
||||
name = new_key
|
||||
|
||||
# Replace delimiters with spaces
|
||||
|
@ -513,6 +512,7 @@ def copy_custom_properties_with_ui(rig, src, dest_bone, *, ui_controls=None, **o
|
|||
if name.lower() == name:
|
||||
name = name.title()
|
||||
|
||||
info = bone.id_properties_ui(new_key).as_dict()
|
||||
slider = type(value) is float and info and info.get("min", None) == 0 and info.get("max", None) == 1
|
||||
|
||||
panel.custom_prop(dest_bone, new_key, text=name, slider=slider)
|
||||
|
|
Loading…
Reference in New Issue