Skip to content
Open
Show file tree
Hide file tree
Changes from 19 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.

💀

24 changes: 23 additions & 1 deletion migoto/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ class TextureData:

@dataclass
class Part:
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

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


@dataclass
class Component:
name: str
fullname: str
parts: list[Part]
root_vs: str
Expand Down Expand Up @@ -167,6 +170,7 @@ def __post_init__(self) -> None:
for component in self.hash_data:
current_name: str = f"{self.mod_name}{component['component_name']}"
component_entry: Component = Component(
name=component['component_name'],
fullname=current_name,
parts=[],
root_vs=component.get("root_vs", ""),
Expand Down Expand Up @@ -229,12 +233,25 @@ def __post_init__(self) -> None:
self.obj_from_col(obj, None, objects)
else:
self.obj_from_col(obj, collection[0], objects)
index_count: int = 0
if len(objects) > 0:
index_count = objects[0].obj.get("3DMigoto:IndexCount", 0)
else:
try:
index_count = component["object_index_counts"][j] if "object_index_counts" in component else 0
except IndexError:
self.operator.report(
{"WARNING"},
f"Index count for part {part_name} not found in hash.json. Defaulting to 0.",
)
component_entry.parts.append(
Part(
fullname=part_name,
name=part,
objects=objects,
textures=textures,
first_index=component["object_indexes"][j],
index_count=index_count,
)
)
self.mod_file.components.append(component_entry)
Expand Down Expand Up @@ -494,6 +511,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 @@ -707,4 +729,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 @@ -526,6 +526,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 @@ -546,6 +547,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
90 changes: 52 additions & 38 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,38 +69,52 @@
{% endblock %}

{% block overridesibs %}
{% 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

{% for part in component.parts if part.vertex_count > 0 %}
{% for component in mod_file.components if component.draw_vb != "" %}
{% for part in component.parts %}
[TextureOverride{{ part.fullname }}]
hash = {{ component.ib }}
match_first_index = {{ part.first_index }}
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
{% for entry in part.objects if entry.vertex_count > 0 %}
{% if loop.previtem and loop.previtem.collection_name != entry.collection_name %}
; {{ entry.collection_name }}
{% if part.index_count > 0 %}
match_index_count = {{part.index_count}}
{% endif %}
handling = skip
{% if part.vertex_count > 0 %}
ib = Resource{{ part.fullname }}IB
{% 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 %}
; {{ entry.name }} ({{ entry.vertex_count }})
drawindexed = {{ entry.index_count}}, {{ entry.index_offset }}, 0
{% endfor %}
{% for entry in part.objects if entry.vertex_count > 0 %}
{% if loop.previtem and loop.previtem.collection_name != entry.collection_name %}
; {{ entry.collection_name }}
{% endif %}
; {{ entry.name }} ({{ entry.vertex_count }})
drawindexed = {{ entry.index_count}}, {{ entry.index_offset }}, 0
{% endfor %}
{% endif %}

{% 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 +137,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 +153,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 +193,4 @@
{{- self.resourcebuffers() -}}
{{- self.resourcetextures() -}}
{{- self.resourcecredit() -}}
{% endblock %}
{% endblock %}