Skip to content

Commit e2c786d

Browse files
authored
[OoT] Various fixes 2 (#612)
* fixed #418 * fixed issue where importing with an invalid path would create a folder * pack transition actor entry index in parameters * fixed quick import * fixed light import with recent decomp * fixed giant link * add `BLEND_RATE_AND_FOG_NEAR` macro to the backward compatibility list * revert door param change
1 parent 85bdf3c commit e2c786d

7 files changed

Lines changed: 58 additions & 22 deletions

File tree

fast64_internal/z64/exporter/scene/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ def getNewSceneFile(self, path: str, isSingleFile: bool, textureExportSettings:
293293
"#undef SCENE_CMD_SPAWN_LIST",
294294
"#define SCENE_CMD_SPAWN_LIST(spawnList) \\",
295295
indent + "{ SCENE_CMD_ID_ENTRANCE_LIST, 0, CMD_PTR(spawnList) }",
296+
"#endif\n",
297+
"#ifndef BLEND_RATE_AND_FOG_NEAR",
298+
"#define BLEND_RATE_AND_FOG_NEAR(blendRate, fogNear) (s16)((((blendRate) / 4) << 10) | (fogNear))",
296299
"#endif\n\n",
297300
]
298301

fast64_internal/z64/exporter/scene/general.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import bpy
12
import re
23

34
from dataclasses import dataclass
@@ -37,16 +38,24 @@ def from_data(raw_data: str, not_zapd_assets: bool):
3738
for match in re.finditer(r"(\{([0-9\-]*,[0-9\-]*,[0-9\-]*)\})", entry, re.DOTALL):
3839
colors_and_dirs.append([hexOrDecInt(value) for value in match.group(2).split(",")])
3940

40-
blend_and_fogs = entry.split("},")[-1].split(",")
41-
blend_split = blend_and_fogs[0].split("|")
42-
blend_raw = blend_split[0]
43-
fog_near = hexOrDecInt(blend_split[1])
44-
z_far = hexOrDecInt(blend_and_fogs[1])
45-
blend_rate = getEvalParamsInt(blend_raw)
46-
assert blend_rate is not None
47-
48-
if "/" in blend_raw:
41+
if "BLEND_RATE_AND_FOG_NEAR" in entry:
42+
blend_and_fogs = entry.replace(")", "").split("BLEND_RATE_AND_FOG_NEAR(")[-1].strip().split(",")
43+
fog_near = hexOrDecInt(blend_and_fogs[1])
44+
z_far = hexOrDecInt(blend_and_fogs[2])
45+
blend_rate = getEvalParamsInt(blend_and_fogs[0])
46+
assert blend_rate is not None
4947
blend_rate *= 4
48+
else:
49+
blend_and_fogs = entry.split("},")[-1].split(",")
50+
blend_split = blend_and_fogs[0].split("|")
51+
blend_raw = blend_split[0]
52+
fog_near = hexOrDecInt(blend_split[1])
53+
z_far = hexOrDecInt(blend_and_fogs[1])
54+
blend_rate = getEvalParamsInt(blend_raw)
55+
assert blend_rate is not None
56+
57+
if "/" in blend_raw:
58+
blend_rate *= 4
5059
else:
5160
split = entry.split(",")
5261

@@ -84,6 +93,9 @@ def from_data(raw_data: str, not_zapd_assets: bool):
8493
def getBlendFogNear(self):
8594
"""Returns the packed blend rate and fog near values"""
8695

96+
if bpy.context.scene.fast64.oot.useDecompFeatures:
97+
return f"BLEND_RATE_AND_FOG_NEAR({self.blendRate}, {self.fogNear})"
98+
8799
return f"(({self.blendRate} << 10) | {self.fogNear})"
88100

89101
def getColorValues(self, vector: tuple[int, int, int]):

fast64_internal/z64/f3d_writer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,5 +352,8 @@ def ootReadActorScale(basePath: str, overlayName: str, isLink: bool) -> Optional
352352
scale = scale[:-1]
353353
return getOOTScale(1 / float(scale))
354354

355+
if isLink:
356+
return getOOTScale(100.0)
357+
355358
print("WARNING: auto-detection failed, defaulting to this panel's actor scale property value")
356359
return None

fast64_internal/z64/importer/actor.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,23 @@ def parseTransActorList(
4242

4343
sharedSceneData.transDict[actor] = actorObj
4444

45-
fromRoom = roomObjs[actor.roomFrom]
46-
toRoom = roomObjs[actor.roomTo]
47-
if actor.roomFrom != actor.roomTo:
48-
parentObject(fromRoom, actorObj)
45+
# make sure the room is valid
46+
fromRoom = roomObjs[actor.roomFrom] if actor.roomFrom >= 0 else None
47+
toRoom = roomObjs[actor.roomTo] if actor.roomTo >= 0 else None
48+
transActorProp.isRoomTransition = actor.isRoomTransition
49+
50+
if actor.isRoomTransition:
51+
if fromRoom is not None:
52+
parentObject(fromRoom, actorObj)
53+
else:
54+
# make it obvious to the user that this transition actor has an issue
55+
actorObj.name = f"Invalid Front Room Index - {actorObj.name}"
56+
4957
transActorProp.fromRoom = fromRoom
5058
transActorProp.toRoom = toRoom
51-
transActorProp.isRoomTransition = True
5259
else:
53-
transActorProp.isRoomTransition = False
60+
# that side should always be valid
61+
assert toRoom is not None
5462
parentObject(toRoom, actorObj)
5563

5664
setCustomProperty(transActorProp, "cameraTransitionFront", actor.cameraFront, ootEnumCamTransition)

fast64_internal/z64/importer/scene.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def parseScene(
105105
sceneName,
106106
False,
107107
True,
108+
True,
108109
)
109110

110111
file_path = Path(sceneFolderPath).resolve() / f"{sceneName}_scene.c"

fast64_internal/z64/tools/quick_import.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,29 @@ def quick_import_exec(context: bpy.types.Context, sym_name: str):
7171
# this str cast completely useless, it's there to force linting to recognize a Path element
7272
extracted_dir_p = base_dir_p / str(context.scene.fast64.oot.get_extracted_path())
7373

74-
assets_paths: list[Path] = [
74+
assets_paths: list[tuple[Optional[Path], Path]] = [
7575
# objects
76-
extracted_dir_p / "assets" / "objects",
76+
(extracted_dir_p / "assets" / "objects", base_dir_p / "assets" / "objects"),
7777
# scenes
78-
extracted_dir_p / "assets" / "scenes",
78+
(extracted_dir_p / "assets" / "scenes", base_dir_p / "assets" / "scenes"),
7979
# other assets embedded in actors (cutscenes for instance)
80-
base_dir_p / "src" / "overlays" / "actors",
80+
(None, base_dir_p / "src" / "overlays" / "actors"),
8181
]
8282

83-
for path in assets_paths:
83+
for extracted_path, path in assets_paths:
8484
all_found_defs = get_found_defs(path, sym_name, sym_def_pattern)
8585

8686
if len(all_found_defs) > 0:
8787
found_dir_p = path
8888
break
8989

90+
if extracted_path is not None:
91+
all_found_defs = get_found_defs(extracted_path, sym_name, sym_def_pattern)
92+
93+
if len(all_found_defs) > 0:
94+
found_dir_p = extracted_path
95+
break
96+
9097
assert found_dir_p is not None
9198

9299
# Ideally if for example sym_name was gLinkAdultHookshotTipDL,

fast64_internal/z64/utility.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,9 @@ def ootGetObjectHeaderPath(isCustomExport: bool, exportPath: str, folderName: st
527527
return filepath
528528

529529

530-
def ootGetPath(exportPath, isCustomExport, subPath, folderName, makeIfNotExists, useFolderForCustom):
530+
def ootGetPath(
531+
exportPath, isCustomExport, subPath, folderName, makeIfNotExists, useFolderForCustom, is_import: bool = False
532+
):
531533
if isCustomExport:
532534
path = bpy.path.abspath(os.path.join(exportPath, (folderName if useFolderForCustom else "")))
533535
else:
@@ -536,7 +538,7 @@ def ootGetPath(exportPath, isCustomExport, subPath, folderName, makeIfNotExists,
536538
path = bpy.path.abspath(os.path.join(os.path.join(bpy.context.scene.ootDecompPath, subPath), folderName))
537539

538540
if not os.path.exists(path):
539-
if isCustomExport or makeIfNotExists:
541+
if not is_import and isCustomExport or makeIfNotExists:
540542
os.makedirs(path)
541543
else:
542544
raise PluginError(path + " does not exist.")

0 commit comments

Comments
 (0)