Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into patch-maker-collision
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 committed Dec 13, 2024
2 parents abc65b6 + 81fd463 commit c5831a0
Show file tree
Hide file tree
Showing 19 changed files with 406 additions and 245 deletions.
17 changes: 15 additions & 2 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 @@ -88,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 @@ -213,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
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
22 changes: 20 additions & 2 deletions fast64_internal/f3d/f3d_gbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class GfxMatWriteMethod(enum.Enum):
"F3DEX2/LX2": (32, 32),
"F3DEX2.Rej/LX2.Rej": (64, 64),
"F3DEX3": (56, 56),
"T3D": (70, 70),
}

sm64_default_draw_layers = {
Expand Down Expand Up @@ -144,6 +145,14 @@ def isUcodeF3DEX3(F3D_VER: str) -> bool:
return F3D_VER == "F3DEX3"


def is_ucode_t3d(UCODE_VER: str) -> bool:
return UCODE_VER == "T3D"


def is_ucode_f3d(UCODE_VER: str) -> bool:
return UCODE_VER not in {"T3D", "RDPQ"}


class F3D:
"""NOTE: do not initialize this class manually! use get_F3D_GBI so that the single instance is cached from the microcode type."""

Expand All @@ -154,15 +163,20 @@ def __init__(self, F3D_VER):
F3DEX_GBI_3 = self.F3DEX_GBI_3 = isUcodeF3DEX3(F3D_VER)
F3DLP_GBI = self.F3DLP_GBI = self.F3DEX_GBI
self.F3D_OLD_GBI = not (F3DEX_GBI or F3DEX_GBI_2 or F3DEX_GBI_3)
self.F3D_GBI = is_ucode_f3d(F3D_VER)

# F3DEX2 is F3DEX1 and F3DEX3 is F3DEX2, but F3DEX3 is not F3DEX1
if F3DEX_GBI_2:
F3DEX_GBI = self.F3DEX_GBI = True
elif F3DEX_GBI_3:
F3DEX_GBI_2 = self.F3DEX_GBI_2 = True

self.vert_buffer_size = vertexBufferSize[F3D_VER][0]
self.vert_load_size = vertexBufferSize[F3D_VER][1]
if F3D_VER in vertexBufferSize:
self.vert_buffer_size = vertexBufferSize[F3D_VER][0]
self.vert_load_size = vertexBufferSize[F3D_VER][1]
else:
self.vert_buffer_size = self.vert_load_size = None

self.G_MAX_LIGHTS = 9 if F3DEX_GBI_3 else 7
self.G_INPUT_BUFFER_CMDS = 21

Expand Down Expand Up @@ -2331,6 +2345,10 @@ def __init__(
self.materialRevert: Union[GfxList, None] = None
# F3D library
self.f3d: F3D = get_F3D_GBI()
if not self.f3d.F3D_GBI:
raise PluginError(
f"Current microcode {self.f3d.F3D_VER} is not part of the f3d family of microcodes, fast64 cannot export it"
)
# array of FModel
self.subModels: list[FModel] = []
self.parentModel: Union[FModel, None] = None
Expand Down
Loading

0 comments on commit c5831a0

Please sign in to comment.