Skip to content

Commit

Permalink
Fix depth projection with ControlNet (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
carson-katri authored Oct 28, 2023
1 parent e515cca commit 9927174
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 11 additions & 9 deletions operators/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,24 @@

def _validate_projection(context):
if len(context.selected_objects) == 0:
def fix_selection(context, layout):
if context.object.mode != 'OBJECT':
layout.operator("object.mode_set", text="Switch to Object Mode", icon="OBJECT_DATAMODE").mode = 'OBJECT'
layout.operator("object.select_by_type", text="Select All Meshes", icon="RESTRICT_SELECT_OFF").type = 'MESH'
def object_mode_operator(operator):
operator.mode = 'OBJECT'
def select_by_type_operator(operator):
operator.type = 'MESH'
raise FixItError(
"""No objects selected
Select at least one object to project onto.""",
fix_selection
FixItError.RunOperator("Switch to Object Mode", "object.mode_set", object_mode_operator)
if context.object.mode != 'OBJECT'
else FixItError.RunOperator("Select All Meshes", "object.select_by_type", select_by_type_operator)
)
if context.object is not None and context.object.mode != 'EDIT':
def fix_mode(_, layout):
layout.operator("object.mode_set", text="Switch to Edit Mode", icon="EDITMODE_HLT").mode = 'EDIT'
def fix_mode(operator):
operator.mode = 'EDIT'
raise FixItError(
"""Enter edit mode
In edit mode, select the faces to project onto.""",
fix_mode
FixItError.RunOperator("Switch to Edit Mode", "object.mode_set", fix_mode)
)
has_selection = False
for obj in context.selected_objects:
Expand All @@ -63,7 +65,7 @@ def fix_mode(_, layout):
raise FixItError(
"""No faces selected.
Select at least one face to project onto.""",
lambda ctx, layout: None
FixItError.RunOperator("Select All Faces", "mesh.select_all", lambda _: None)
)

def dream_texture_projection_panels():
Expand Down
1 change: 0 additions & 1 deletion property_groups/dream_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ def generate_args(self, context, iteration=0, init_image=None, control_images=No
net.conditioning_scale
)
for i, net in enumerate(self.control_nets)
if net.control_image is not None
]
)

Expand Down

0 comments on commit 9927174

Please sign in to comment.