Map RNA float array properties to mathutils types using subtype
RNA properties with subtypes like TRANSLATION, XYZ, EULER, QUATERNION, COLOR, MATRIX are now mapped to the corresponding mathutils types (Vector, Euler, Quaternion, Color, Matrix) instead of list[float]. Also: - Add gpu.types override for 5.1 (uniform_float accepts mathutils types) - Fix README snippet to use assert for active_object None check Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9484e364c2
commit
35a370a412
@ -34,8 +34,8 @@ import bpy
|
||||
|
||||
# Full autocomplete and type checking
|
||||
obj = bpy.context.active_object
|
||||
if obj is not None:
|
||||
print(obj.name)
|
||||
assert obj is not None
|
||||
obj.location.x = 1.0
|
||||
|
||||
# Collection types with proper methods
|
||||
bpy.data.objects.new("Cube", bpy.data.meshes.new("Mesh"))
|
||||
|
||||
@ -2138,6 +2138,21 @@ def rna_property_to_type(prop: object) -> str:
|
||||
if array_length == 0 and is_array:
|
||||
# Dynamic-length array — at runtime this is a bpy_prop_array
|
||||
return f"bpy_prop_array[{base}]"
|
||||
# Fixed-length float arrays with vector/matrix subtypes are mathutils types
|
||||
subtype: str = getattr(prop, "subtype", "NONE")
|
||||
if prop_type == "float" and subtype in (
|
||||
"TRANSLATION", "DIRECTION", "VELOCITY", "ACCELERATION",
|
||||
"XYZ", "XYZ_LENGTH",
|
||||
):
|
||||
return "mathutils.Vector"
|
||||
if prop_type == "float" and subtype == "EULER":
|
||||
return "mathutils.Euler"
|
||||
if prop_type == "float" and subtype == "QUATERNION":
|
||||
return "mathutils.Quaternion"
|
||||
if prop_type == "float" and subtype in ("COLOR", "COLOR_GAMMA") and array_length == 3:
|
||||
return "mathutils.Color"
|
||||
if prop_type == "float" and subtype == "MATRIX":
|
||||
return "mathutils.Matrix"
|
||||
return f"list[{base}]"
|
||||
|
||||
return RNA_TYPE_MAP.get(prop_type, prop_type)
|
||||
|
||||
4
main.py
4
main.py
@ -186,8 +186,8 @@ pip install "blender-python-stubs>={major_minor},<{next_minor}"
|
||||
import bpy
|
||||
|
||||
obj = bpy.context.active_object
|
||||
if obj is not None:
|
||||
print(obj.name)
|
||||
assert obj is not None
|
||||
obj.location.x = 1.0
|
||||
|
||||
bpy.data.objects.new("Cube", bpy.data.meshes.new("Mesh"))
|
||||
```
|
||||
|
||||
7
overrides/5.1/gpu.types.json
Normal file
7
overrides/5.1/gpu.types.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"GPUShader.uniform_float": {
|
||||
"params": {
|
||||
"value": "float | int | Sequence[float] | mathutils.Matrix | mathutils.Vector | mathutils.Euler | mathutils.Quaternion | mathutils.Color"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user