Skip to content

Commit b5a4e54

Browse files
committed
Merge fast64/V5 into fast64/main
2 parents d464c8d + 54fa239 commit b5a4e54

36 files changed

+26372
-24180
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
__pycache__/
22
.vscode
3+
*.blend1
34
/.venv

LowPolySkinnedMario_V5.blend

5.28 MB
Binary file not shown.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ In F3D material properties, you can enable "Large Texture Mode". This will let y
4545
### Decomp vs Homebrew Compatibility
4646
There may occur cases where code is formatted differently based on the code use case. In the tools panel under the Fast64 File Settings subheader, you can toggle homebrew compatibility.
4747

48-
### Converting To F3D v4 Materials
49-
A new optimized shader graph was introduced to decrease processing times for material creation and exporting. If you have a project that still uses old materials, you may want to convert them to v4. To convert an old project, click the "Recreate F3D Materials As V4" operator near the top of the Fast64 tab in 3D view. This may take a while depending on the number of materials in the project. Then go to the outliner, change the display mode to "Orphan Data" (broken heart icon), then click "Purge" in the top right corner. Purge multiple times until all of the old node groups are gone.
48+
### Converting To F3D v5 Materials
49+
A new optimized shader graph was introduced to decrease processing times for material creation and exporting. If you have a project that still uses old materials, you may want to convert them to v5. To convert an old project, click the "Recreate F3D Materials As V5" operator near the top of the Fast64 tab in 3D view. This may take a while depending on the number of materials in the project. Then go to the outliner, change the display mode to "Orphan Data" (broken heart icon), then click "Purge" in the top right corner. Purge multiple times until all of the old node groups are gone.
5050

5151
### Updater
5252

__init__.py

Lines changed: 96 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
import traceback
77
import os
88
from pathlib import Path
9+
910
from .fast64_internal import *
1011
from .fast64_internal.panels import SM64_Panel
1112
from .fast64_internal.oot.oot_level import OOT_ObjectProperties
13+
from .fast64_internal.render_settings import (
14+
Fast64RenderSettings_Properties,
15+
resync_scene_props,
16+
on_update_render_settings,
17+
)
1218

1319
import cProfile
1420
import pstats
@@ -23,7 +29,7 @@
2329
"location": "3DView",
2430
"description": "Plugin for exporting F3D display lists and other game data related to Super Mario 64.",
2531
"category": "Import-Export",
26-
"blender": (2, 82, 0),
32+
"blender": (3, 2, 0),
2733
}
2834

2935
gameEditorEnum = (
@@ -203,7 +209,7 @@ def draw(self, context):
203209
col.prop(context.scene, "decomp_compatible", invert_checkbox=True, text="Homebrew Compatibility")
204210
col.prop(context.scene, "ignoreTextureRestrictions")
205211
if context.scene.ignoreTextureRestrictions:
206-
col.box().label(text="Width/height must be < 1024. Must be RGBA32. Must be png format.")
212+
col.box().label(text="Width/height must be < 1024. Must be png format.")
207213

208214

209215
class Fast64_GlobalObjectPanel(bpy.types.Panel):
@@ -306,6 +312,7 @@ class Fast64_Properties(bpy.types.PropertyGroup):
306312
sm64: bpy.props.PointerProperty(type=SM64_Properties, name="SM64 Properties")
307313
oot: bpy.props.PointerProperty(type=OOT_Properties, name="OOT Properties")
308314
settings: bpy.props.PointerProperty(type=Fast64Settings_Properties, name="Fast64 Settings")
315+
renderSettings: bpy.props.PointerProperty(type=Fast64RenderSettings_Properties, name="Fast64 Render Settings")
309316

310317

311318
class Fast64_BoneProperties(bpy.types.PropertyGroup):
@@ -327,6 +334,63 @@ class Fast64_ObjectProperties(bpy.types.PropertyGroup):
327334
oot: bpy.props.PointerProperty(type=OOT_ObjectProperties, name="OOT Object Properties")
328335

329336

337+
class UpgradeF3DMaterialsDialog(bpy.types.Operator):
338+
bl_idname = "dialog.upgrade_f3d_materials"
339+
bl_label = "Upgrade F3D Materials"
340+
bl_options = {"REGISTER", "UNDO"}
341+
342+
done = False
343+
344+
def draw(self, context):
345+
layout = self.layout
346+
if self.done:
347+
layout.label(text="Success!")
348+
box = layout.box()
349+
box.label(text="Materials were successfully upgraded.")
350+
box.label(text="Please purge your remaining materials.")
351+
352+
purge_box = box.box()
353+
purge_box.scale_y = 0.25
354+
purge_box.separator(factor=0.5)
355+
purge_box.label(text="How to purge:")
356+
purge_box.separator(factor=0.5)
357+
purge_box.label(text="Go to the outliner, change the display mode")
358+
purge_box.label(text='to "Orphan Data" (broken heart icon)')
359+
purge_box.separator(factor=0.25)
360+
purge_box.label(text='Click "Purge" in the top right corner.')
361+
purge_box.separator(factor=0.25)
362+
purge_box.label(text="Purge multiple times until the node groups")
363+
purge_box.label(text="are gone.")
364+
layout.separator(factor=0.25)
365+
layout.label(text="You may click anywhere to close this dialog.")
366+
return
367+
layout.alert = True
368+
box = layout.box()
369+
box.label(text="Your project contains F3D materials that need to be upgraded in order to continue!")
370+
box.label(text="Before upgrading, make sure to create a duplicate (backup) of this blend file.")
371+
box.separator()
372+
373+
col = box.column()
374+
col.alignment = "CENTER"
375+
col.alert = True
376+
col.label(text="Upgrade F3D Materials?")
377+
378+
def invoke(self, context, event):
379+
return context.window_manager.invoke_props_dialog(self, width=600)
380+
381+
def execute(self, context: "bpy.types.Context"):
382+
if context.mode != "OBJECT":
383+
bpy.ops.object.mode_set(mode="OBJECT")
384+
385+
upgradeF3DVersionAll(
386+
[obj for obj in bpy.data.objects if isinstance(obj.data, bpy.types.Mesh)],
387+
list(bpy.data.armatures),
388+
MatUpdateConvert.version,
389+
)
390+
self.done = True
391+
return {"FINISHED"}
392+
393+
330394
# def updateGameEditor(scene, context):
331395
# if scene.currentGameEditorMode == 'SM64':
332396
# sm64_panel_unregister()
@@ -354,6 +418,7 @@ def draw(self, context):
354418

355419
classes = (
356420
Fast64Settings_Properties,
421+
Fast64RenderSettings_Properties,
357422
Fast64_Properties,
358423
Fast64_BoneProperties,
359424
Fast64_ObjectProperties,
@@ -366,6 +431,7 @@ def draw(self, context):
366431
Fast64_GlobalSettingsPanel,
367432
SM64_ArmatureToolsPanel,
368433
Fast64_GlobalToolsPanel,
434+
UpgradeF3DMaterialsDialog,
369435
)
370436

371437

@@ -375,29 +441,43 @@ def upgrade_changed_props():
375441
SM64_ObjectProperties.upgrade_changed_props()
376442

377443

444+
def upgrade_scene_props_node():
445+
"""update f3d materials with SceneProperties node"""
446+
has_old_f3d_mats = any(mat.is_f3d and mat.mat_ver < MatUpdateConvert.version for mat in bpy.data.materials)
447+
if has_old_f3d_mats:
448+
bpy.ops.dialog.upgrade_f3d_materials("INVOKE_DEFAULT")
449+
450+
378451
@bpy.app.handlers.persistent
379452
def after_load(_a, _b):
380453
upgrade_changed_props()
454+
upgrade_scene_props_node()
455+
resync_scene_props()
456+
457+
458+
def gameEditorUpdate(self, context):
459+
if self.gameEditorMode == "SM64":
460+
self.f3d_type = "F3D"
461+
elif self.gameEditorMode == "OOT":
462+
self.f3d_type = "F3DEX2/LX2"
381463

382464

383465
# called on add-on enabling
384466
# register operators and panels here
385467
# append menu layout drawing function to an existing window
386468
def register():
387469

388-
if bpy.app.version >= (3, 1, 0):
470+
if bpy.app.version < (3, 2, 0):
389471
msg = "\n".join(
390472
(
391-
"This version of Fast64 does not work properly in Blender 3.1.0 and later Blender versions.",
473+
"This version of Fast64 does not support Blender 3.1.x and earlier Blender versions.",
392474
"Your Blender version is: " + ".".join(str(i) for i in bpy.app.version),
393-
"This is a known issue, the fix is not trivial and is in progress.",
394-
"See the GitHub issue: https://github.com/Fast-64/fast64/issues/85",
395-
"If it has been resolved, update Fast64.",
475+
"Please upgrade Blender to 3.2.0 or above.",
396476
)
397477
)
398478
print(msg)
399-
blender_3_1_0_and_later_unsupported = Exception("\n\n" + msg)
400-
raise blender_3_1_0_and_later_unsupported
479+
unsupported_exc = Exception("\n\n" + msg)
480+
raise unsupported_exc
401481

402482
# Register addon updater first,
403483
# this way if a broken version fails to register the user can still pick another version.
@@ -420,15 +500,17 @@ def register():
420500
# ROM
421501

422502
bpy.types.Scene.decomp_compatible = bpy.props.BoolProperty(name="Decomp Compatibility", default=True)
423-
bpy.types.Scene.ignoreTextureRestrictions = bpy.props.BoolProperty(
424-
name="Ignore Texture Restrictions (Breaks CI Textures)"
425-
)
503+
bpy.types.Scene.ignoreTextureRestrictions = bpy.props.BoolProperty(name="Ignore Texture Restrictions")
426504
bpy.types.Scene.fullTraceback = bpy.props.BoolProperty(name="Show Full Error Traceback", default=False)
427-
bpy.types.Scene.gameEditorMode = bpy.props.EnumProperty(name="Game", default="SM64", items=gameEditorEnum)
505+
bpy.types.Scene.gameEditorMode = bpy.props.EnumProperty(
506+
name="Game", default="SM64", items=gameEditorEnum, update=gameEditorUpdate
507+
)
428508
bpy.types.Scene.saveTextures = bpy.props.BoolProperty(name="Save Textures As PNGs (Breaks CI Textures)")
429509
bpy.types.Scene.generateF3DNodeGraph = bpy.props.BoolProperty(name="Generate F3D Node Graph", default=True)
430510
bpy.types.Scene.exportHiddenGeometry = bpy.props.BoolProperty(name="Export Hidden Geometry", default=True)
431-
bpy.types.Scene.blenderF3DScale = bpy.props.FloatProperty(name="F3D Blender Scale", default=100)
511+
bpy.types.Scene.blenderF3DScale = bpy.props.FloatProperty(
512+
name="F3D Blender Scale", default=100, update=on_update_render_settings
513+
)
432514

433515
bpy.types.Scene.fast64 = bpy.props.PointerProperty(type=Fast64_Properties, name="Fast64 Properties")
434516
bpy.types.Bone.fast64 = bpy.props.PointerProperty(type=Fast64_BoneProperties, name="Fast64 Bone Properties")

fast64_internal/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
from .oot.oot_skeleton import *
1717
from .oot.oot_cutscene import *
1818
from .oot.oot_operators import *
19+
from .utility import *

0 commit comments

Comments
 (0)