Skip to content

Transform your 3D texturing workflow with the power of generative AI, directly within Blender!

fix trellis.2 camera poll conflict, move shading toggle

sakalond45be75cc417b
diff --git a/stablegen/generator.py b/stablegen/generator.py
index d933201..40fc99c 100644
--- a/stablegen/generator.py
+++ b/stablegen/generator.py
@@ -4351,12 +4351,19 @@ class Trellis2Generate(bpy.types.Operator):
if _pm == 'fan_from_camera':
_cam_kwargs['fan_angle'] = getattr(context.scene, 'trellis2_fan_angle', 90.0)
- # Use temp_override so add_cameras gets proper region_data
- if _v3d_area and _v3d_region:
- with bpy.context.temp_override(area=_v3d_area, region=_v3d_region):
+ # Use temp_override so add_cameras gets proper region_data.
+ # Temporarily bypass the sg_modal_active() poll guard so
+ # add_cameras can run while this TRELLIS.2 modal is active.
+ from . import utils as _sg_utils
+ _sg_utils._sg_bypass_modal_check = True
+ try:
+ if _v3d_area and _v3d_region:
+ with bpy.context.temp_override(area=_v3d_area, region=_v3d_region):
+ bpy.ops.object.add_cameras(**_cam_kwargs)
+ else:
bpy.ops.object.add_cameras(**_cam_kwargs)
- else:
- bpy.ops.object.add_cameras(**_cam_kwargs)
+ finally:
+ _sg_utils._sg_bypass_modal_check = False
except Exception as cam_err:
print(f"[TRELLIS2] Warning: Camera placement failed: {cam_err}")
diff --git a/stablegen/stablegen.py b/stablegen/stablegen.py
index a395f19..9600154 100644
--- a/stablegen/stablegen.py
+++ b/stablegen/stablegen.py
@@ -973,11 +973,6 @@ class StableGenPanel(bpy.types.Panel):
split.label(text="Texture Mode:")
split.prop(scene, "trellis2_texture_mode", text="")
- # Mesh shading mode
- split = params_container.split(factor=0.5)
- split.label(text="Shading:")
- split.prop(scene, "trellis2_shade_mode", text="")
-
# Prompt + native/none: show initial-image architecture & checkpoint
_prompt_needs_initial = (
scene.trellis2_generate_from == 'prompt'
@@ -1133,6 +1128,10 @@ class StableGenPanel(bpy.types.Panel):
split = content_box.split(factor=0.5)
split.label(text="BG Removal:")
split.prop(scene, "trellis2_bg_removal", text="")
+
+ split = content_box.split(factor=0.5)
+ split.label(text="Shading:")
+ split.prop(scene, "trellis2_shade_mode", text="")
content_box.separator()
# --- TRELLIS.2: Native Texture Settings ---
diff --git a/stablegen/utils.py b/stablegen/utils.py
index 5642b3b..d0c5a32 100644
--- a/stablegen/utils.py
+++ b/stablegen/utils.py
@@ -15,9 +15,15 @@ _SG_BLOCKED_MODALS = frozenset({
'OBJECT_OT_export_orbit_gif',
})
+# Temporary bypass flag – set True to allow internal operator calls
+# (e.g. TRELLIS.2 modal calling add_cameras) to skip the poll guard.
+_sg_bypass_modal_check = False
+
def sg_modal_active(context):
"""Return True if any StableGen heavy modal operator is currently running."""
+ if _sg_bypass_modal_check:
+ return False
for window in context.window_manager.windows:
for op in window.modal_operators:
if op.bl_idname in _SG_BLOCKED_MODALS: