Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions fast64_internal/sm64/sm64_f3d_writer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
import shutil, copy, bpy, re, os
from typing import NamedTuple
from io import BytesIO
from math import ceil, log, radians
from mathutils import Matrix, Vector
Expand All @@ -14,6 +15,7 @@
ui_procAnim,
update_world_default_rendermode,
)
from .sm64_geolayout_utility import OverrideHash
from .sm64_texscroll import modifyTexScrollFiles, modifyTexScrollHeadersGroup
from .sm64_utility import (
END_IF_FOOTER,
Expand All @@ -26,7 +28,7 @@
)
from .sm64_level_parser import parse_level_binary
from .sm64_rom_tweaks import ExtendBank0x04
from typing import Tuple
from .sm64_geolayout_classes import BaseDisplayListNode

from ..f3d.f3d_bleed import BleedGraphics

Expand Down Expand Up @@ -102,12 +104,17 @@
}


class GfxOverride(NamedTuple):
gfx: GfxList
nodes: list["BaseDisplayListNode"]


class SM64Model(FModel):
def __init__(self, name, DLFormat, matWriteMethod):
FModel.__init__(self, name, DLFormat, matWriteMethod)
self.no_light_direction = bpy.context.scene.fast64.sm64.matstack_fix
self.layer_adapted_fmats = {}
self.draw_overrides: dict[FMesh, dict[tuple, tuple[GfxList, list["DisplayListNode"]]]] = {}
self.draw_overrides: dict[FMesh, dict[OverrideHash, GfxOverride]] = {}

def getDrawLayerV3(self, obj):
return int(obj.draw_layer_static)
Expand All @@ -124,7 +131,7 @@ def __init__(self, scrollMethod: ScrollMethod):
self.functionNodeDraw = False
GfxFormatter.__init__(self, scrollMethod, 8, "segmented_to_virtual")

def processGfxScrollCommand(self, commandIndex: int, command: GbiMacro, gfxListName: str) -> Tuple[str, str]:
def processGfxScrollCommand(self, commandIndex: int, command: GbiMacro, gfxListName: str) -> tuple[str, str]:
tags: GfxTag = command.tags
fMaterial: FMaterial = command.fMaterial

Expand Down
27 changes: 10 additions & 17 deletions fast64_internal/sm64/sm64_geolayout_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def getDrawLayers(self):

class Geolayout:
def __init__(self, name, isStartGeo):
self.nodes = []
self.nodes: list[TransformNode] = []
self.name = toAlnum(name)
self.startAddress = 0
self.isStartGeo = isStartGeo
Expand Down Expand Up @@ -284,7 +284,7 @@ def getDrawLayers(self):
class TransformNode:
def __init__(self, node):
self.node = node
self.children = []
self.children: list[TransformNode] = []
self.parent = None
self.skinned = False
self.skinnedWithoutDL = False
Expand Down Expand Up @@ -445,7 +445,7 @@ def __init__(self, material, specificMat, drawLayer, overrideType, texDimensions


class JumpNode:
def __init__(self, storeReturn, geolayout, geoRef: str = None):
def __init__(self, storeReturn, geolayout: Geolayout, geoRef: str = None):
self.geolayout = geolayout
self.storeReturn = storeReturn
self.hasDL = False
Expand Down Expand Up @@ -698,10 +698,9 @@ def __init__(self, drawLayer, fieldLayout, hasDL, translate, rotate, dlRef: str
self.rotate = rotate

self.fMesh = None
self.DLmicrocode = None

self.dlRef = dlRef
# exists to get the override DL from an fMesh
self.override_hash = None

def get_ptr_offsets(self):
if self.hasDL:
Expand Down Expand Up @@ -798,10 +797,9 @@ def __init__(self, drawLayer, useDeform, translate, dlRef: str = None):
self.hasDL = useDeform
self.translate = translate
self.fMesh = None
self.DLmicrocode = None

self.dlRef = dlRef
# exists to get the override DL from an fMesh
self.override_hash = None

def get_ptr_offsets(self):
return [8] if self.hasDL else []
Expand Down Expand Up @@ -842,10 +840,9 @@ def __init__(self, drawLayer, hasDL, rotate, dlRef: str = None):
self.hasDL = hasDL
self.rotate = rotate
self.fMesh = None
self.DLmicrocode = None

self.dlRef = dlRef
# exists to get the override DL from an fMesh
self.override_hash = None

def get_ptr_offsets(self):
return [8] if self.hasDL else []
Expand Down Expand Up @@ -884,10 +881,9 @@ def __init__(self, drawLayer, hasDL, translate, dlRef: str = None):
self.hasDL = hasDL
self.translate = translate
self.fMesh = None
self.DLmicrocode = None

self.dlRef = dlRef
# exists to get the override DL from an fMesh
self.override_hash = None

def get_ptr_offsets(self):
return [8] if self.hasDL else []
Expand Down Expand Up @@ -923,10 +919,9 @@ def __init__(self, drawLayer, dlRef: str = None):
self.drawLayer = drawLayer
self.hasDL = True
self.fMesh = None
self.DLmicrocode = None

self.dlRef = dlRef
# exists to get the override DL from an fMesh
self.override_hash = None

def get_ptr_offsets(self):
return [4]
Expand Down Expand Up @@ -979,10 +974,9 @@ def __init__(self, drawLayer, geo_scale, use_deform, dlRef: str = None):
self.scaleValue = geo_scale
self.hasDL = use_deform
self.fMesh = None
self.DLmicrocode = None

self.dlRef = dlRef
# exists to get the override DL from an fMesh
self.override_hash = None

def get_ptr_offsets(self):
return [8] if self.hasDL else []
Expand Down Expand Up @@ -1058,10 +1052,9 @@ def __init__(self, drawLayer, use_deform, translate, dlRef: str = None):
self.hasDL = use_deform
self.translate = translate
self.fMesh = None
self.DLmicrocode = None

self.dlRef = dlRef
# exists to get the override DL from an fMesh
self.override_hash = None

def size(self):
return 12
Expand Down
5 changes: 5 additions & 0 deletions fast64_internal/sm64/sm64_geolayout_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,17 @@ def updateBone(bone, context):
addBoneToGroup(armatureObj, bone.name)


OverrideHash = tuple[any, ...]


class BaseDisplayListNode:
"""Base displaylist node with common helper functions dealing with displaylists"""

dl_ext = "WITH_DL" # add dl_ext to geo command if command has a displaylist
override_layer = False
dlRef: str | GfxList | None
override_hash: OverrideHash | None = None
DLmicrocode = None

def get_dl_address(self):
assert not isinstance(self.dlRef, str), "dlRef string not supported in binary"
Expand Down
Loading