Skip to content
Open
Show file tree
Hide file tree
Changes from 14 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pyproject.toml
uv.lock
.python-version
TODO.md
.idea/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💀

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💀

26 changes: 24 additions & 2 deletions migoto/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@ class TextureData:
@dataclass
class Part:
fullname: str
name: str
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name and classification both in Part and Component classes is redundant as the information from hash.json is already passed to the templates

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's for usage simplicity, to not require users to sync getting info from object and from hash.json, and just use object info

classification: str
objects: list[SubObj]
textures: list[TextureData]
first_index: int
index_count: int = 0
vertex_count: int = 0


@dataclass
class Component:
fullname: str
name: str
parts: list[Part]
root_vs: str
draw_vb: str
Expand Down Expand Up @@ -168,6 +172,7 @@ def __post_init__(self) -> None:
current_name: str = f"{self.mod_name}{component['component_name']}"
component_entry: Component = Component(
fullname=current_name,
name=component['component_name'],
parts=[],
root_vs=component.get("root_vs", ""),
draw_vb=component.get("draw_vb", ""),
Expand All @@ -180,7 +185,7 @@ def __post_init__(self) -> None:
comp_matching_objs: list[Object] = [
obj for obj in candidate_objs if obj.name.startswith(current_name)
]
if len(comp_matching_objs) == 0:
if len(comp_matching_objs) == 0 and component["draw_vb"] != "":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is odd- it is already like on the added side of things. Perhaps you need to rebase your branch?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did: 56d9aca

continue
for j, part in enumerate(component["object_classifications"]):
part_name: str = current_name + part
Expand Down Expand Up @@ -232,9 +237,12 @@ def __post_init__(self) -> None:
component_entry.parts.append(
Part(
fullname=part_name,
name=current_name,
classification=part,
objects=objects,
textures=textures,
first_index=component["object_indexes"][j],
index_count=component["object_index_counts"][j] if "object_index_counts" in component and component["object_index_counts"][j] > 0 else (objects[0].obj.get("3DMigoto:IndexCount", 0) if len(objects) > 0 else 0),
)
)
self.mod_file.components.append(component_entry)
Expand Down Expand Up @@ -302,6 +310,15 @@ def generate_buffers(self) -> None:
self.files_to_write = {}
self.files_to_copy = {}
for component in self.mod_file.components:
if component.draw_vb == "":
for part in component.parts:
print(f"Processing {part.fullname} " + "-" * 10)
for t in part.textures:
tex_name = part.fullname + t.name + t.extension
self.files_to_copy[self.dump_path / tex_name] = (
self.destination / tex_name
)
continue
data_model: DataModelXXMI = DataModelXXMI.from_obj(
component.parts[0].objects[0].obj,
game=self.game,
Expand Down Expand Up @@ -485,6 +502,11 @@ def generate_ini(
credit=self.credit,
game=self.game,
character_name=self.mod_name,
apply_modifiers=self.apply_modifiers,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the export settings should already be passed as attributes of mod_info

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't find any kind of mod_info

copy_textures=self.copy_textures,
ignore_duplicate_textures=self.ignore_duplicate_textures,
no_ramps=self.no_ramps,
write_buffers=self.write_buffers
)
)
ini_file.clean_up_indentation()
Expand Down Expand Up @@ -698,4 +720,4 @@ def load_hashes(self, path: Path) -> list[dict]:
with open(path, "r") as f:
char_hashes = json.load(f)
# TODO: Check for hash.json integrity
return char_hashes
return char_hashes
2 changes: 2 additions & 0 deletions migoto/import_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ def import_3dmigoto_vb_ib(
obj["3DMigoto:Topology"] = vb.topology
for raw_vb in vb.vbs:
obj["3DMigoto:VB%iStride" % raw_vb.idx] = raw_vb.stride
obj["3DMigoto:VertexCount"] = vb.vertex_count
obj["3DMigoto:FirstVertex"] = vb.first
# Record these import options so the exporter can set them to match by
# default. Might also consider adding them to the .fmt file so reimporting
Expand All @@ -547,6 +548,7 @@ def import_3dmigoto_vb_ib(
# Attach the index buffer layout to the object for later exporting.
obj["3DMigoto:IBFormat"] = ib.format
obj["3DMigoto:FirstIndex"] = ib.first
obj["3DMigoto:IndexCount"] = ib.index_count
elif vb.topology == "trianglelist":
import_faces_from_vb_trianglelist(mesh, vb, flip_winding)
elif vb.topology == "trianglestrip":
Expand Down
67 changes: 41 additions & 26 deletions templates/Zenless Zone Zero.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@

{% block overridesbuffers %}
{% for component in mod_file.components if component.draw_vb != "" and component.blend_vb != "" and component.vertex_count > 0 %}
[TextureOverride{{ component.fullname }}Blend]
hash = {{ component.blend_vb }}
handling = skip
vb2 = Resource{{ component.fullname }}Blend
if DRAW_TYPE == 1
vb0 = Resource{{ component.fullname }}Position
draw = {{ component.vertex_count }}, 0
{% if credit != "" %}

$active = 1
{% endif %}
endif
[TextureOverride{{ component.fullname }}Blend]
hash = {{ component.blend_vb }}
handling = skip
vb2 = Resource{{ component.fullname }}Blend
if DRAW_TYPE == 1
vb0 = Resource{{ component.fullname }}Position
draw = {{ component.vertex_count }}, 0
{% if credit != "" %}

$active = 1
{% endif %}
endif

[TextureOverride{{ component.fullname }}Texcoord]
hash = {{ component.texcoord_vb }}
Expand All @@ -69,7 +69,7 @@
{% endblock %}

{% block overridesibs %}
{% for component in mod_file.components if component.draw_vb != "" %}
{% for component in mod_file.components if component.draw_vb != "" %}
[TextureOverride{{component.fullname}}IB]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removal of the global handling skip for a IB section can lead to issues.

If a given IB gets more parts added to it in a subsequent version of the game it would only skip the ones the ini covers but not all of them making mods look functional but have a broken IB on top of it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's intentional to not have stray IB sections with just handling = skip, cuz those lead into issues w/o at least index filtering

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of issues? Any specific bug or simply misinterpretation from users?

Do they outweight the scenario I presented?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue like that, or that, and anything similar to them, when there stray skips of hair, or some small items like Mimiyabi hairpin, those will cause multiple issues with world, and having just first_index for them may not help, and need to have both index filters at least, can't remember if more was needed ever, but potentially might be

hash = {{ component.ib }}
handling = skip
Expand All @@ -78,11 +78,16 @@
[TextureOverride{{ part.fullname }}]
hash = {{ component.ib }}
match_first_index = {{ part.first_index }}
{% if part.index_count > 0 %}
match_index_count = {{part.index_count}}
{% endif %}
ib = Resource{{ part.fullname }}IB
{% for texture in part.textures %}
Resource\ZZMI\{{ texture.name }} = ref Resource{{ part.fullname }}{{ texture.name }}
{% endfor %}
run = CommandList\ZZMI\SetTextures
{% if part.textures|length > 0%}
{% for texture in part.textures %}
Resource\ZZMI\{{ texture.name }} = ref Resource{{ part.fullname }}{{ texture.name }}
{% endfor %}
run = CommandList\ZZMI\SetTextures
{% endif %}
{% for entry in part.objects if entry.vertex_count > 0 %}
{% if loop.previtem and loop.previtem.collection_name != entry.collection_name %}
; {{ entry.collection_name }}
Expand All @@ -93,14 +98,24 @@

{% endfor %}
{% endfor %}
{% for component in mod_file.components if component.draw_vb == "" %}
{% for component in mod_file.components if component.draw_vb == "" and component.position_vb == "" %}
{% set count = component.parts | selectattr('textures') | list | length %}
{% for part in component.parts %}
{% for texture in part.textures %}
[TextureOverride{{part.fullname}}{{ texture.name }}]
hash = {{ texture.hash }}
this = Resource{{part.fullname}}{{ texture.name }}
{% if part.textures|length > 0 %}
[TextureOverride{{ part.fullname }}]
hash = {{component.ib}}
{% if count > 1 %}
match_first_index = {{ part.first_index }}
{% if part.index_count > 0 %}
match_index_count = {{part.index_count}}
{% endif %}
{% endif %}
{% for texture in part.textures %}
Resource\ZZMI\{{ texture.name }} = ref Resource{{ part.fullname }}{{ texture.name }}
{% endfor %}
run = CommandList\ZZMI\SetTextures

{% endfor %}
{%endif%}
{% endfor %}
{% endfor %}
{% endblock %}
Expand All @@ -123,7 +138,7 @@
stride = {{ component.strides.texcoord }}
filename = {{ component.fullname }}Texcoord.buf
{% endif %}

{% for part in component.parts %}
[Resource{{ part.fullname }}IB]
type = Buffer
Expand All @@ -139,7 +154,7 @@
stride = {{ component.strides.position }}
filename = {{ component.fullname }}.buf
{% endif %}

{% for part in component.parts %}
[Resource{{ part.fullname }}IB]
type = Buffer
Expand Down Expand Up @@ -179,4 +194,4 @@
{{- self.resourcebuffers() -}}
{{- self.resourcetextures() -}}
{{- self.resourcecredit() -}}
{% endblock %}
{% endblock %}