Small config tweaks, removed cam/light check, code cleanup
This commit is contained in:
1 parent
4617c47ad0
commit
b800e5a68b
6 files changed
+148
-43
No files matched your search
+29
-19
@@ -35,7 +35,9 @@ class ModifiersCheck(Check):
|
||||
continue
|
||||
for name in issue.data["modifiers"]:
|
||||
try:
|
||||
with bpy.context.temp_override(object=ob, active_object=ob, selected_objects=[ob]):
|
||||
with bpy.context.temp_override(
|
||||
object=ob, active_object=ob, selected_objects=[ob]
|
||||
):
|
||||
bpy.ops.object.modifier_apply(modifier=name)
|
||||
except RuntimeError as exc:
|
||||
failed.append(f"{ob.name} / {name}: {str(exc).strip()}")
|
||||
@@ -58,7 +60,10 @@ class ApplyTransformCheck(Check):
|
||||
problems = []
|
||||
if channels.get("location") and loc.length > tolerance:
|
||||
problems.append("location")
|
||||
if channels.get("rotation") and min(rot.angle, math.tau - rot.angle) > tolerance:
|
||||
if (
|
||||
channels.get("rotation")
|
||||
and min(rot.angle, math.tau - rot.angle) > tolerance
|
||||
):
|
||||
problems.append("rotation")
|
||||
if channels.get("scale") and any(abs(s - 1.0) > tolerance for s in scale):
|
||||
problems.append("scale")
|
||||
@@ -73,11 +78,16 @@ class ApplyTransformCheck(Check):
|
||||
if ob is None:
|
||||
continue
|
||||
if ob.data is not None and ob.data.users > 1:
|
||||
failed.append(f"{ob.name}: data shared by {ob.data.users} users, apply by hand")
|
||||
failed.append(
|
||||
f"{ob.name}: data shared by {ob.data.users} users, apply by hand"
|
||||
)
|
||||
continue
|
||||
try:
|
||||
with bpy.context.temp_override(
|
||||
object=ob, active_object=ob, selected_objects=[ob], selected_editable_objects=[ob]
|
||||
object=ob,
|
||||
active_object=ob,
|
||||
selected_objects=[ob],
|
||||
selected_editable_objects=[ob],
|
||||
):
|
||||
bpy.ops.object.transform_apply(
|
||||
location=bool(channels.get("location")),
|
||||
@@ -89,20 +99,20 @@ class ApplyTransformCheck(Check):
|
||||
return failed
|
||||
|
||||
|
||||
class LightCameraCheck(Check):
|
||||
id = "lights_cameras"
|
||||
label = "Lights & cameras"
|
||||
description = "Asset files contain no lights or cameras."
|
||||
category = "Objects"
|
||||
contexts = contexts.ASSET
|
||||
fix_description = "Delete the lights and cameras"
|
||||
# class LightCameraCheck(Check):
|
||||
# id = "lights_cameras"
|
||||
# label = "Lights & cameras"
|
||||
# description = "Asset files contain no lights or cameras."
|
||||
# category = "Objects"
|
||||
# contexts = contexts.ASSET
|
||||
# fix_description = "Delete the lights and cameras"
|
||||
|
||||
def run(self, ctx):
|
||||
for ob in ctx.objects(*config.FORBIDDEN_ASSET_OBJECT_TYPES):
|
||||
yield Issue.for_id(f"{ob.type.capitalize()} '{ob.name}' must be removed", ob)
|
||||
# def run(self, ctx):
|
||||
# for ob in ctx.objects(*config.FORBIDDEN_ASSET_OBJECT_TYPES):
|
||||
# yield Issue.for_id(f"{ob.type.capitalize()} '{ob.name}' must be removed", ob)
|
||||
|
||||
def fix(self, ctx, issues):
|
||||
for issue in issues:
|
||||
ob = issue.get_id()
|
||||
if ob is not None:
|
||||
bpy.data.objects.remove(ob, do_unlink=True)
|
||||
# def fix(self, ctx, issues):
|
||||
# for issue in issues:
|
||||
# ob = issue.get_id()
|
||||
# if ob is not None:
|
||||
# bpy.data.objects.remove(ob, do_unlink=True)
|
||||
Reference in new issue
Block a user