Light objects do not have an icon set for their type in their bl_rna #89856

Open
opened 2021-07-14 17:11:55 +02:00 by Ray Mairlot · 6 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce RTX 2070 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 460.89

Blender Version
Broken:

  • version: 3.0.0 Alpha, branch: master, commit date: 2021-06-18 15:13, hash: 4c19fe4707
  • version: 2.93.0, branch: master, commit date: 2021-06-02 11:21, hash: 84da05a8b8
    Worked: -

Short description of error

When inspecting the icon property in each item returned from bpy.types.Lights.bl_rna.properties['type'].enum_items.items() no icon is returned for each type of light. Instead, None is returned.

For example, running the following in the Python Console in Blender:

for object_type in bpy.types.Object.bl_rna.properties['type'].enum_items.items():
    object_type[1].icon

Correctly results in:

'OUTLINER_OB_MESH'
'OUTLINER_OB_CURVE'
'OUTLINER_OB_SURFACE'
'OUTLINER_OB_META'
'OUTLINER_OB_FONT'
etc...

And running:

for probe_type in bpy.types.LightProbe.bl_rna.properties['type'].enum_items.items():
    probe_type[1].icon

Correctly results in:

'LIGHTPROBE_CUBEMAP'
'LIGHTPROBE_PLANAR'
'LIGHTPROBE_GRID'

But running:

for light_type in bpy.types.Light.bl_rna.properties['type'].enum_items.items():
    light_type[1].icon

Results in:

'NONE'
'NONE'
'NONE'
'NONE'

My expectation is that the following icon names should be returned:

'LIGHT_POINT'
'LIGHT_SUN'
'LIGHT_SPOT'
'LIGHT_AREA'

Exact steps for others to reproduce the error

Run the following in Blender's Python Console:

for light_type in bpy.types.Light.bl_rna.properties['type'].enum_items.items():
    light_type[1].icon
**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce RTX 2070 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 460.89 **Blender Version** Broken: - version: 3.0.0 Alpha, branch: master, commit date: 2021-06-18 15:13, hash: `4c19fe4707` - version: 2.93.0, branch: master, commit date: 2021-06-02 11:21, hash: `84da05a8b8` Worked: - **Short description of error** When inspecting the `icon` property in each item returned from `bpy.types.Lights.bl_rna.properties['type'].enum_items.items()` no icon is returned for each type of light. Instead, `None` is returned. For example, running the following in the Python Console in Blender: ``` for object_type in bpy.types.Object.bl_rna.properties['type'].enum_items.items(): object_type[1].icon ``` Correctly results in: ``` 'OUTLINER_OB_MESH' 'OUTLINER_OB_CURVE' 'OUTLINER_OB_SURFACE' 'OUTLINER_OB_META' 'OUTLINER_OB_FONT' etc... ``` And running: ``` for probe_type in bpy.types.LightProbe.bl_rna.properties['type'].enum_items.items(): probe_type[1].icon ``` Correctly results in: ``` 'LIGHTPROBE_CUBEMAP' 'LIGHTPROBE_PLANAR' 'LIGHTPROBE_GRID' ``` But running: ``` for light_type in bpy.types.Light.bl_rna.properties['type'].enum_items.items(): light_type[1].icon ``` Results in: ``` 'NONE' 'NONE' 'NONE' 'NONE' ``` My expectation is that the following icon names should be returned: ``` 'LIGHT_POINT' 'LIGHT_SUN' 'LIGHT_SPOT' 'LIGHT_AREA' ``` **Exact steps for others to reproduce the error** Run the following in Blender's Python Console: ``` for light_type in bpy.types.Light.bl_rna.properties['type'].enum_items.items(): light_type[1].icon ```
Author

Added subscriber: @RayMairlot

Added subscriber: @RayMairlot
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Looking at the code I could not notice any enum value defined in DNA_light_types.h`

But they are in DNA_lighprobe_types.h

enum {

LIGHTPROBE_TYPE_CUBE = 0,
LIGHTPROBE_TYPE_PLANAR = 1,
LIGHTPROBE_TYPE_GRID = 2,

};```

I am not sure if this is expected or so. Will leave this for others to answer.
Looking at the code I could not notice any enum value defined in DNA_light_types.h` But they are in `DNA_lighprobe_types.h` ```/* Probe->type */ enum { ``` LIGHTPROBE_TYPE_CUBE = 0, LIGHTPROBE_TYPE_PLANAR = 1, LIGHTPROBE_TYPE_GRID = 2, ``` };``` I am not sure if this is expected or so. Will leave this for others to answer.

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

The icons are apparently only available in the operator property.
They have been made available in 201e9d81

Although this is not really a bug, remove these duplicate enums could be a nice cleanup:

diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 8ae74fbfafa..a0384183e49 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -129,53 +129,19 @@
 /** \name Local Enum Declarations
  * \{ */
 
-/* this is an exact copy of the define in rna_light.c
- * kept here because of linking order.
- * Icons are only defined here */
-const EnumPropertyItem rna_enum_light_type_items[] = {
-    {LA_LOCAL, "POINT", ICON_LIGHT_POINT, "Point", "Omnidirectional point light source"},
-    {LA_SUN, "SUN", ICON_LIGHT_SUN, "Sun", "Constant direction parallel ray light source"},
-    {LA_SPOT, "SPOT", ICON_LIGHT_SPOT, "Spot", "Directional cone light source"},
-    {LA_AREA, "AREA", ICON_LIGHT_AREA, "Area", "Directional area light source"},
-    {0, NULL, 0, NULL, NULL},
-};
+static const EnumPropertyItem *rna_static_enum_find(StructRNA *type, const char *identifier)
+{
+  const EnumPropertyItem *r_enum;
 
-/* copy from rna_object_force.c */
-static const EnumPropertyItem field_type_items[] = {
-    {PFIELD_FORCE, "FORCE", ICON_FORCE_FORCE, "Force", ""},
-    {PFIELD_WIND, "WIND", ICON_FORCE_WIND, "Wind", ""},
-    {PFIELD_VORTEX, "VORTEX", ICON_FORCE_VORTEX, "Vortex", ""},
-    {PFIELD_MAGNET, "MAGNET", ICON_FORCE_MAGNETIC, "Magnetic", ""},
-    {PFIELD_HARMONIC, "HARMONIC", ICON_FORCE_HARMONIC, "Harmonic", ""},
-    {PFIELD_CHARGE, "CHARGE", ICON_FORCE_CHARGE, "Charge", ""},
-    {PFIELD_LENNARDJ, "LENNARDJ", ICON_FORCE_LENNARDJONES, "Lennard-Jones", ""},
-    {PFIELD_TEXTURE, "TEXTURE", ICON_FORCE_TEXTURE, "Texture", ""},
-    {PFIELD_GUIDE, "GUIDE", ICON_FORCE_CURVE, "Curve Guide", ""},
-    {PFIELD_BOID, "BOID", ICON_FORCE_BOID, "Boid", ""},
-    {PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", ""},
-    {PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""},
-    {PFIELD_FLUIDFLOW, "FLUID", ICON_FORCE_FLUIDFLOW, "Fluid Flow", ""},
-    {0, NULL, 0, NULL, NULL},
-};
+  PointerRNA ptr;
+  RNA_pointer_create(NULL, type, NULL, &ptr);
+  PropertyRNA *prop = RNA_struct_find_property(&ptr, "type");
+  bool free_dummy;
+  RNA_property_enum_items_ex(NULL, &ptr, prop, true, &r_enum, NULL, &free_dummy);
+  BLI_assert(!free_dummy);
 
-static EnumPropertyItem lightprobe_type_items[] = {
-    {LIGHTPROBE_TYPE_CUBE,
-     "CUBEMAP",
-     ICON_LIGHTPROBE_CUBEMAP,
-     "Reflection Cubemap",
-     "Reflection probe with spherical or cubic attenuation"},
-    {LIGHTPROBE_TYPE_PLANAR,
-     "PLANAR",
-     ICON_LIGHTPROBE_PLANAR,
-     "Reflection Plane",
-     "Planar reflection probe"},
-    {LIGHTPROBE_TYPE_GRID,
-     "GRID",
-     ICON_LIGHTPROBE_GRID,
-     "Irradiance Volume",
-     "Irradiance probe to capture diffuse indirect lighting"},
-    {0, NULL, 0, NULL, NULL},
-};
+  return r_enum;
+}
 
 enum {
   ALIGN_WORLD = 0,
@@ -786,6 +752,7 @@ void OBJECT_OT_lightprobe_add(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
   /* properties */
+  const EnumPropertyItem *lightprobe_type_items = rna_static_enum_find(&RNA_LightProbe, "type");
   ot->prop = RNA_def_enum(ot->srna, "type", lightprobe_type_items, 0, "Type", "");
 
   ED_object_add_unit_props_radius(ot);
@@ -904,6 +871,7 @@ void OBJECT_OT_effector_add(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
   /* properties */
+  const EnumPropertyItem *field_type_items = rna_static_enum_find(&RNA_FieldSettings, "type");
   ot->prop = RNA_def_enum(ot->srna, "type", field_type_items, 0, "Type", "");
 
   ED_object_add_unit_props_radius(ot);
@@ -1623,6 +1591,7 @@ void OBJECT_OT_light_add(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
   /* properties */
+  const EnumPropertyItem *rna_enum_light_type_items = rna_static_enum_find(&RNA_Light, "type");
   ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_light_type_items, 0, "Type", "");
   RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_LIGHT);
 
diff --git a/source/blender/makesrna/intern/rna_light.c b/source/blender/makesrna/intern/rna_light.c
index 0593db0dd56..3123c36f273 100644
--- a/source/blender/makesrna/intern/rna_light.c
+++ b/source/blender/makesrna/intern/rna_light.c
@@ -105,10 +105,10 @@ static void rna_Light_use_nodes_update(bContext *C, PointerRNA *ptr)
 #else
 /* Don't define icons here, so they don't show up in the Light UI (properties Editor) - DingTo */
 const EnumPropertyItem rna_enum_light_type_items[] = {
-    {LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source"},
-    {LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source"},
-    {LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source"},
-    {LA_AREA, "AREA", 0, "Area", "Directional area light source"},
+    {LA_LOCAL, "POINT", ICON_LIGHT_POINT, "Point", "Omnidirectional point light source"},
+    {LA_SUN, "SUN", ICON_LIGHT_SUN, "Sun", "Constant direction parallel ray light source"},
+    {LA_SPOT, "SPOT", ICON_LIGHT_SPOT, "Spot", "Directional cone light source"},
+    {LA_AREA, "AREA", ICON_LIGHT_AREA, "Area", "Directional area light source"},
     {0, NULL, 0, NULL, NULL},
 };
 

I think this is something for the #user_interface team to decide.

The icons are apparently only available in the operator property. They have been made available in 201e9d81 Although this is not really a bug, remove these duplicate enums could be a nice cleanup: ```lines=20 diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 8ae74fbfafa..a0384183e49 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -129,53 +129,19 @@ /** \name Local Enum Declarations * \{ */ -/* this is an exact copy of the define in rna_light.c - * kept here because of linking order. - * Icons are only defined here */ -const EnumPropertyItem rna_enum_light_type_items[] = { - {LA_LOCAL, "POINT", ICON_LIGHT_POINT, "Point", "Omnidirectional point light source"}, - {LA_SUN, "SUN", ICON_LIGHT_SUN, "Sun", "Constant direction parallel ray light source"}, - {LA_SPOT, "SPOT", ICON_LIGHT_SPOT, "Spot", "Directional cone light source"}, - {LA_AREA, "AREA", ICON_LIGHT_AREA, "Area", "Directional area light source"}, - {0, NULL, 0, NULL, NULL}, -}; +static const EnumPropertyItem *rna_static_enum_find(StructRNA *type, const char *identifier) +{ + const EnumPropertyItem *r_enum; -/* copy from rna_object_force.c */ -static const EnumPropertyItem field_type_items[] = { - {PFIELD_FORCE, "FORCE", ICON_FORCE_FORCE, "Force", ""}, - {PFIELD_WIND, "WIND", ICON_FORCE_WIND, "Wind", ""}, - {PFIELD_VORTEX, "VORTEX", ICON_FORCE_VORTEX, "Vortex", ""}, - {PFIELD_MAGNET, "MAGNET", ICON_FORCE_MAGNETIC, "Magnetic", ""}, - {PFIELD_HARMONIC, "HARMONIC", ICON_FORCE_HARMONIC, "Harmonic", ""}, - {PFIELD_CHARGE, "CHARGE", ICON_FORCE_CHARGE, "Charge", ""}, - {PFIELD_LENNARDJ, "LENNARDJ", ICON_FORCE_LENNARDJONES, "Lennard-Jones", ""}, - {PFIELD_TEXTURE, "TEXTURE", ICON_FORCE_TEXTURE, "Texture", ""}, - {PFIELD_GUIDE, "GUIDE", ICON_FORCE_CURVE, "Curve Guide", ""}, - {PFIELD_BOID, "BOID", ICON_FORCE_BOID, "Boid", ""}, - {PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", ""}, - {PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""}, - {PFIELD_FLUIDFLOW, "FLUID", ICON_FORCE_FLUIDFLOW, "Fluid Flow", ""}, - {0, NULL, 0, NULL, NULL}, -}; + PointerRNA ptr; + RNA_pointer_create(NULL, type, NULL, &ptr); + PropertyRNA *prop = RNA_struct_find_property(&ptr, "type"); + bool free_dummy; + RNA_property_enum_items_ex(NULL, &ptr, prop, true, &r_enum, NULL, &free_dummy); + BLI_assert(!free_dummy); -static EnumPropertyItem lightprobe_type_items[] = { - {LIGHTPROBE_TYPE_CUBE, - "CUBEMAP", - ICON_LIGHTPROBE_CUBEMAP, - "Reflection Cubemap", - "Reflection probe with spherical or cubic attenuation"}, - {LIGHTPROBE_TYPE_PLANAR, - "PLANAR", - ICON_LIGHTPROBE_PLANAR, - "Reflection Plane", - "Planar reflection probe"}, - {LIGHTPROBE_TYPE_GRID, - "GRID", - ICON_LIGHTPROBE_GRID, - "Irradiance Volume", - "Irradiance probe to capture diffuse indirect lighting"}, - {0, NULL, 0, NULL, NULL}, -}; + return r_enum; +} enum { ALIGN_WORLD = 0, @@ -786,6 +752,7 @@ void OBJECT_OT_lightprobe_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + const EnumPropertyItem *lightprobe_type_items = rna_static_enum_find(&RNA_LightProbe, "type"); ot->prop = RNA_def_enum(ot->srna, "type", lightprobe_type_items, 0, "Type", ""); ED_object_add_unit_props_radius(ot); @@ -904,6 +871,7 @@ void OBJECT_OT_effector_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + const EnumPropertyItem *field_type_items = rna_static_enum_find(&RNA_FieldSettings, "type"); ot->prop = RNA_def_enum(ot->srna, "type", field_type_items, 0, "Type", ""); ED_object_add_unit_props_radius(ot); @@ -1623,6 +1591,7 @@ void OBJECT_OT_light_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + const EnumPropertyItem *rna_enum_light_type_items = rna_static_enum_find(&RNA_Light, "type"); ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_light_type_items, 0, "Type", ""); RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_LIGHT); diff --git a/source/blender/makesrna/intern/rna_light.c b/source/blender/makesrna/intern/rna_light.c index 0593db0dd56..3123c36f273 100644 --- a/source/blender/makesrna/intern/rna_light.c +++ b/source/blender/makesrna/intern/rna_light.c @@ -105,10 +105,10 @@ static void rna_Light_use_nodes_update(bContext *C, PointerRNA *ptr) #else /* Don't define icons here, so they don't show up in the Light UI (properties Editor) - DingTo */ const EnumPropertyItem rna_enum_light_type_items[] = { - {LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source"}, - {LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source"}, - {LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source"}, - {LA_AREA, "AREA", 0, "Area", "Directional area light source"}, + {LA_LOCAL, "POINT", ICON_LIGHT_POINT, "Point", "Omnidirectional point light source"}, + {LA_SUN, "SUN", ICON_LIGHT_SUN, "Sun", "Constant direction parallel ray light source"}, + {LA_SPOT, "SPOT", ICON_LIGHT_SPOT, "Spot", "Directional cone light source"}, + {LA_AREA, "AREA", ICON_LIGHT_AREA, "Area", "Directional area light source"}, {0, NULL, 0, NULL, NULL}, }; ``` I think this is something for the #user_interface team to decide.
Philipp Oeser removed the
Interest
User Interface
label 2023-02-10 09:23:15 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#89856
No description provided.