Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into sm64-global-fog
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 committed Dec 22, 2024
2 parents 1f9bea0 + 81fd463 commit 2fa420f
Show file tree
Hide file tree
Showing 60 changed files with 1,389 additions and 698 deletions.
Binary file removed LowPolySkinnedMario.blend
Binary file not shown.
Binary file removed LowPolySkinnedMario_V5.blend
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Make sure to save often, as this plugin is prone to crashing when creating mater

<https://developer.blender.org/T70574>

### Example models can be found [here](https://github.com/Fast-64/fast64-models)

![alt-text](/images/mat_inspector.png)

### Credits
Thanks to anonymous_moose, Cheezepin, Rovert, and especially InTheBeef for testing.
Thanks to InTheBeef for LowPolySkinnedMario.

### Discord Server
We have a Discord server for support as well as development [here](https://discord.gg/ny7PDcN2x8).
Expand Down
61 changes: 44 additions & 17 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from . import addon_updater_ops

from .fast64_internal.utility import prop_split, multilineLabel, draw_and_check_tab
from .fast64_internal.utility import prop_split, multilineLabel, set_prop_if_in_data

from .fast64_internal.repo_settings import (
draw_repo_settings,
Expand Down Expand Up @@ -49,14 +49,15 @@

from .fast64_internal.render_settings import (
Fast64RenderSettings_Properties,
ManualUpdatePreviewOperator,
resync_scene_props,
on_update_render_settings,
)

# info about add on
bl_info = {
"name": "Fast64",
"version": (2, 2, 0),
"version": (2, 3, 0),
"author": "kurethedead",
"location": "3DView",
"description": "Plugin for exporting F3D display lists and other game data related to Nintendo 64 games.",
Expand Down Expand Up @@ -87,7 +88,7 @@ def poll(cls, context):
def draw(self, context):
col = self.layout.column()
col.scale_y = 1.1 # extra padding
prop_split(col, context.scene, "f3d_type", "F3D Microcode")
prop_split(col, context.scene, "f3d_type", "Microcode")
col.prop(context.scene, "saveTextures")
col.prop(context.scene, "f3d_simple", text="Simple Material UI")
col.prop(context.scene, "exportInlineF3D", text="Bleed and Inline Material Exports")
Expand Down Expand Up @@ -212,6 +213,19 @@ class Fast64Settings_Properties(bpy.types.PropertyGroup):

internal_game_update_ver: bpy.props.IntProperty(default=0)

def to_repo_settings(self):
data = {}
data["autoLoad"] = self.auto_repo_load_settings
data["autoPickTextureFormat"] = self.auto_pick_texture_format
if self.auto_pick_texture_format:
data["preferRGBAOverCI"] = self.prefer_rgba_over_ci
return data

def from_repo_settings(self, data: dict):
set_prop_if_in_data(self, "auto_repo_load_settings", data, "autoLoad")
set_prop_if_in_data(self, "auto_pick_texture_format", data, "autoPickTextureFormat")
set_prop_if_in_data(self, "prefer_rgba_over_ci", data, "preferRGBAOverCI")


class Fast64_Properties(bpy.types.PropertyGroup):
"""
Expand Down Expand Up @@ -311,6 +325,7 @@ def draw(self, context):
classes = (
Fast64Settings_Properties,
Fast64RenderSettings_Properties,
ManualUpdatePreviewOperator,
Fast64_Properties,
Fast64_BoneProperties,
Fast64_ObjectProperties,
Expand All @@ -328,9 +343,10 @@ def upgrade_changed_props():
SM64_ObjectProperties.upgrade_changed_props()
OOT_ObjectProperties.upgrade_changed_props()
for scene in bpy.data.scenes:
if scene.fast64.settings.internal_game_update_ver != 1:
gameEditorUpdate(scene, bpy.context)
scene.fast64.settings.internal_game_update_ver = 1
settings: Fast64Settings_Properties = scene.fast64.settings
if settings.internal_game_update_ver != 1:
set_game_defaults(scene, False)
settings.internal_game_update_ver = 1
if scene.get("decomp_compatible", False):
scene.gameEditorMode = "Homebrew"
del scene["decomp_compatible"]
Expand Down Expand Up @@ -363,23 +379,34 @@ def after_load(_a, _b):
upgrade_changed_props()
upgrade_scene_props_node()
resync_scene_props()
try:
if settings.repo_settings_path:
load_repo_settings(bpy.context.scene, abspath(settings.repo_settings_path), True)
except Exception as exc:
print(exc)


def gameEditorUpdate(self, context):
def set_game_defaults(scene: bpy.types.Scene, set_ucode=True):
world_defaults = None
if self.gameEditorMode == "SM64":
self.f3d_type = "F3D"
if scene.gameEditorMode == "SM64":
f3d_type = "F3D"
world_defaults = sm64_world_defaults
elif self.gameEditorMode == "OOT":
self.f3d_type = "F3DEX2/LX2"
elif scene.gameEditorMode == "OOT":
f3d_type = "F3DEX2/LX2"
world_defaults = oot_world_defaults
elif self.gameEditorMode == "MK64":
self.f3d_type = "F3DEX/LX"
elif self.gameEditorMode == "Homebrew":
self.f3d_type = "F3D"
elif scene.gameEditorMode == "MK64":
f3d_type = "F3DEX/LX"
elif scene.gameEditorMode == "Homebrew":
f3d_type = "F3D"
world_defaults = {} # This will set some pretty bad defaults, but trust the user
if self.world is not None:
self.world.rdp_defaults.from_dict(world_defaults)
if set_ucode:
scene.f3d_type = f3d_type
if scene.world is not None:
scene.world.rdp_defaults.from_dict(world_defaults)


def gameEditorUpdate(scene: bpy.types.Scene, _context):
set_game_defaults(scene)


# called on add-on enabling
Expand Down
22 changes: 14 additions & 8 deletions fast64_internal/f3d/f3d_bleed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from dataclasses import dataclass, field

from ..utility import create_or_get_world
from .f3d_gbi import (
GfxTag,
GfxListTag,
Expand Down Expand Up @@ -63,7 +64,7 @@ def __init__(self):
self.build_default_othermodes()

def build_default_geo(self):
defaults = bpy.context.scene.world.rdp_defaults
defaults = create_or_get_world(bpy.context.scene).rdp_defaults

setGeo = SPSetGeometryMode([])
clearGeo = SPClearGeometryMode([])
Expand Down Expand Up @@ -91,7 +92,7 @@ def place_in_flaglist(flag: bool, enum: str, set_list: SPSetGeometryMode, clear_
self.default_clear_geo = clearGeo

def build_default_othermodes(self):
defaults = bpy.context.scene.world.rdp_defaults
defaults = create_or_get_world(bpy.context.scene).rdp_defaults

othermode_H = SPSetOtherMode("G_SETOTHERMODE_H", 4, 20 - self.is_f3d_old, [])
# if the render mode is set, it will be consider non-default a priori
Expand Down Expand Up @@ -225,9 +226,8 @@ def bleed_textures(self, cur_fmat: FMaterial, last_mat: FMaterial, bleed_state:
for j, cmd in enumerate(cur_fmat.texture_DL.commands):
if not cmd:
continue # some cmds are None from previous step
if self.bleed_individual_cmd(commands_bled, cmd, bleed_state):
if cmd in last_mat.texture_DL.commands:
commands_bled.commands[j] = None
if self.bleed_individual_cmd(commands_bled, cmd, bleed_state, last_mat.texture_DL.commands) is True:
commands_bled.commands[j] = None
# remove Nones from list
while None in commands_bled.commands:
commands_bled.commands.remove(None)
Expand Down Expand Up @@ -479,9 +479,15 @@ def bleed_SPSetOtherMode(self, cmd_list: GfxList, cmd: GbiMacro, bleed_state: in
else:
return cmd == self.default_othermode_L

# bleed if there are no tags to scroll and cmd was in last list
def bleed_DPSetTileSize(self, cmd_list: GfxList, cmd: GbiMacro, bleed_state: int, last_cmd_list: GfxList = None):
return cmd.tags != GfxTag.TileScroll0 and cmd.tags != GfxTag.TileScroll1 and cmd in last_cmd_list
# Don´t bleed if the cmd is used for scrolling or if the last cmd's tags are not the same (those are not hashed)
def bleed_DPSetTileSize(self, _cmd_list: GfxList, cmd: GbiMacro, _bleed_state: int, last_cmd_list: GfxList = None):
if cmd.tags == GfxTag.TileScroll0 or cmd.tags == GfxTag.TileScroll1:
return False
if cmd in last_cmd_list:
last_size_cmd = last_cmd_list[last_cmd_list.index(cmd)]
if last_size_cmd.tags == cmd.tags:
return True
return False

# At most, only one sync is needed after drawing tris. The f3d writer should
# already have placed the appropriate sync type required. If a second sync is
Expand Down
23 changes: 16 additions & 7 deletions fast64_internal/f3d/f3d_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,22 @@
}

enumF3D = [
("F3D", "F3D", "Original microcode used in SM64"),
("F3DEX/LX", "F3DEX/LX", "F3DEX version 1"),
("F3DLX.Rej", "F3DLX.Rej", "F3DLX.Rej"),
("F3DLP.Rej", "F3DLP.Rej", "F3DLP.Rej"),
("F3DEX2/LX2", "F3DEX2/LX2/ZEX", "Family of microcodes used in later N64 games including OoT and MM"),
("F3DEX2.Rej/LX2.Rej", "F3DEX2.Rej/LX2.Rej", "Variant of F3DEX2 family using vertex rejection instead of clipping"),
("F3DEX3", "F3DEX3", "Custom microcode by Sauraen"),
("", "F3D Family", "", 7),
("F3D", "F3D", "Original microcode used in SM64", 0),
("F3DEX/LX", "F3DEX/LX", "F3DEX version 1", 1),
("F3DLX.Rej", "F3DLX.Rej", "F3DLX.Rej", 2),
("F3DLP.Rej", "F3DLP.Rej", "F3DLP.Rej", 3),
("F3DEX2/LX2", "F3DEX2/LX2/ZEX", "Family of microcodes used in later N64 games including OoT and MM", 4),
(
"F3DEX2.Rej/LX2.Rej",
"F3DEX2.Rej/LX2.Rej",
"Variant of F3DEX2 family using vertex rejection instead of clipping",
5,
),
("F3DEX3", "F3DEX3", "Custom microcode by Sauraen", 6),
("", "Homebrew", "", 8),
("RDPQ", "RDPQ", "Base libdragon microcode", 9),
("T3D", "Tiny3D", "Custom libdragon microcode by HailToDodongo", 10),
]

enumLargeEdges = [
Expand Down
Loading

0 comments on commit 2fa420f

Please sign in to comment.