From 2cadabb28fa72c498d7bd5e0447dc55ba2a897c3 Mon Sep 17 00:00:00 2001 From: kurethedead Date: Tue, 16 Feb 2021 17:53:10 -0800 Subject: [PATCH] Objects hidden in viewport will now be exported by default. --- __init__.py | 3 +++ fast64_internal/oot/oot_level_writer.py | 7 +++++++ fast64_internal/sm64/sm64_level_writer.py | 7 +++++++ fast64_internal/utility.py | 16 ++++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/__init__.py b/__init__.py index cfb2caa..e6e1e6d 100644 --- a/__init__.py +++ b/__init__.py @@ -229,6 +229,7 @@ class Fast64_GlobalSettingsPanel(bpy.types.Panel): def draw(self, context): col = self.layout.column() prop_split(col, context.scene, 'gameEditorMode', "Game") + col.prop(context.scene, 'exportHiddenGeometry') col.prop(context.scene, 'fullTraceback') @@ -291,6 +292,7 @@ def register(): bpy.types.Scene.saveTextures = bpy.props.BoolProperty( name = 'Save Textures As PNGs (Breaks CI Textures)') bpy.types.Scene.generateF3DNodeGraph = bpy.props.BoolProperty(name = "Generate F3D Node Graph", default = True) + bpy.types.Scene.exportHiddenGeometry = bpy.props.BoolProperty(name = "Export Hidden Geometry", default = True) # called on add-on disabling def unregister(): @@ -308,6 +310,7 @@ def unregister(): del bpy.types.Scene.saveTextures del bpy.types.Scene.gameEditorMode del bpy.types.Scene.generateF3DNodeGraph + del bpy.types.Scene.exportHiddenGeometry for cls in classes: unregister_class(cls) diff --git a/fast64_internal/oot/oot_level_writer.py b/fast64_internal/oot/oot_level_writer.py index 4dcadf2..f63dcf1 100644 --- a/fast64_internal/oot/oot_level_writer.py +++ b/fast64_internal/oot/oot_level_writer.py @@ -319,10 +319,17 @@ def ootConvertScene(originalSceneObj, transformMatrix, if originalSceneObj.data is not None or originalSceneObj.ootEmptyType != "Scene": raise PluginError(originalSceneObj.name + " is not an empty with the \"Scene\" empty type.") + + if bpy.context.scene.exportHiddenGeometry: + hiddenObjs = unhideAllAndGetHiddenList(bpy.context.scene) # Don't remove ignore_render, as we want to resuse this for collision sceneObj, allObjs = \ ootDuplicateHierarchy(originalSceneObj, None, True, OOTObjectCategorizer()) + + if bpy.context.scene.exportHiddenGeometry: + hideObjsInList(hiddenObjs) + roomObjs = [child for child in sceneObj.children if child.data is None and child.ootEmptyType == 'Room'] if len(roomObjs) == 0: raise PluginError("The scene has no child empties with the 'Room' empty type.") diff --git a/fast64_internal/sm64/sm64_level_writer.py b/fast64_internal/sm64/sm64_level_writer.py index d8a0a81..824dc84 100644 --- a/fast64_internal/sm64/sm64_level_writer.py +++ b/fast64_internal/sm64/sm64_level_writer.py @@ -527,6 +527,10 @@ def exportLevelC(obj, transformMatrix, f3dType, isHWv1, levelName, exportDir, usesEnvFX = False echoLevels = ['0x00', '0x00', '0x00'] zoomFlags = [False, False, False, False] + + if bpy.context.scene.exportHiddenGeometry: + hiddenObjs = unhideAllAndGetHiddenList(bpy.context.scene) + for child in childAreas: if len(child.children) == 0: raise PluginError("Area for " + child.name + " has no children.") @@ -624,6 +628,9 @@ def exportLevelC(obj, transformMatrix, f3dType, isHWv1, levelName, exportDir, '_' + backgroundSegments[obj.background] + '_skybox_' + compressionFmt, 'LOAD_' + compressionFmt.upper(), 0x0A) levelscriptString = prevLevelScript.to_c(areaString) + if bpy.context.scene.exportHiddenGeometry: + hideObjsInList(hiddenObjs) + # Remove old areas. for f in os.listdir(levelDir): if re.search('area\_\d+', f): diff --git a/fast64_internal/utility.py b/fast64_internal/utility.py index 3acd49f..d9c8a90 100644 --- a/fast64_internal/utility.py +++ b/fast64_internal/utility.py @@ -36,6 +36,22 @@ enumCompressionFormat = [ ('yay0', 'YAY0', 'YAY0'), ] +def unhideAllAndGetHiddenList(scene): + hiddenObjs = [] + for obj in scene.objects: + if obj.hide_get(): + hiddenObjs.append(obj) + + if bpy.context.mode != 'OBJECT': + bpy.ops.object.mode_set(mode = "OBJECT") + bpy.ops.object.hide_view_clear() + return hiddenObjs + +def hideObjsInList(hiddenObjs): + for obj in hiddenObjs: + obj.hide_set(True) + + def readFile(filepath): datafile = open(filepath, 'r', newline = '\n', encoding = 'utf-8') data = datafile.read()