Skip to content

Commit 928103b

Browse files
committed
draw property correctly, create new file for this, update to main
1 parent 99d3063 commit 928103b

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@
2121
"category": "3D View",
2222
}
2323

24+
from .light_prop import draw_light_color
2425
from . import auto_load
26+
import bpy
2527

2628
auto_load.init()
2729

2830

2931
def register():
32+
bpy.types.DATA_PT_light.append(draw_light_color)
3033
auto_load.register()
3134

3235

3336
def unregister():
3437
auto_load.unregister()
38+
bpy.types.DATA_PT_light.remove(draw_light_color)

common.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import mathutils
88
import gpu
99

10+
from bpy.types import Context
11+
1012
from .material.parser import (
1113
parse_f3d_rendermode_preset,
1214
quantize_direction,
@@ -235,3 +237,13 @@ def collect_obj_info(
235237

236238
info.mats.append((i, indices_count, f64mat))
237239
return info
240+
241+
242+
def check_if_using_renderer(context: Context):
243+
"""ONLY applies to view 3d. For ambigous cases use context.scene.render.engine != 'FAST64_RENDER_ENGINE'"""
244+
space_data = context.space_data
245+
return (
246+
context.scene.render.engine == "FAST64_RENDER_ENGINE"
247+
and space_data.type == "VIEW_3D"
248+
and space_data.shading.type in {"MATERIAL", "RENDERED"}
249+
)

light_prop.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from bpy.types import Context, Panel
2+
3+
4+
def draw_light_color(self: Panel, context: Context):
5+
if context.scene.render.engine != "FAST64_RENDER_ENGINE":
6+
return
7+
8+
layout = self.layout
9+
10+
layout.use_property_split = True
11+
layout.use_property_decorate = False
12+
13+
layout.separator()
14+
layout.prop(context.light, "color")

renderer.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from .utils.addon import addon_set_fast64_path
1313
from .material.parser import f64_parse_obj_light
14-
from .common import ObjRenderInfo, draw_f64_obj, get_scene_render_state, collect_obj_info
14+
from .common import draw_f64_obj, get_scene_render_state, collect_obj_info, check_if_using_renderer
1515
from .properties import F64RenderProperties, F64RenderSettings
1616
from .globals import F64_GLOBALS
1717

@@ -424,36 +424,10 @@ def draw(self, context):
424424

425425

426426
def draw_render_settings(self, context: bpy.types.Context):
427-
space_data = context.space_data
428-
if (
429-
context.scene.render.engine == Fast64RenderEngine.bl_idname
430-
and space_data.type == "VIEW_3D"
431-
and space_data.shading.type in {"MATERIAL", "RENDERED"}
432-
):
427+
if check_if_using_renderer(context):
433428
self.layout.popover(F64RenderSettingsPanel.bl_idname)
434429

435430

436-
# The light color is only shown in the UI in the DATA_PT_EEVEE_light panel,
437-
# which is only shown with EEVEE enabled. The DATA_PT_light panel is shown otherwise,
438-
# but only allows changing the light type.
439-
# This panel extends the DATA_PT_light panel to allow setting the light color.
440-
class LightDataPanel(bpy.types.Panel):
441-
bl_label = "f64render light data"
442-
bl_idname = "DATA_PT_f64render_light_data"
443-
bl_space_type = "PROPERTIES"
444-
bl_region_type = "WINDOW"
445-
bl_context = "data"
446-
bl_parent_id = "DATA_PT_light"
447-
bl_options = {"HIDE_HEADER"}
448-
449-
@classmethod
450-
def poll(cls, context):
451-
return context.scene is not None and context.scene.render.engine == Fast64RenderEngine.bl_idname
452-
453-
def draw(self, context):
454-
self.layout.prop(context.light, "color")
455-
456-
457431
# By default blender will hide quite a few panels like materials or vertex attributes
458432
# Add this method to override the check blender does by render engine
459433
def get_panels():

0 commit comments

Comments
 (0)