-
Notifications
You must be signed in to change notification settings - Fork 14
ADD: index_count, more context for templates. UPDATE: ZZZ template, textures only components, and index_count usage #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b4ab031
b510716
9cf6399
23e6043
e4de9be
335ae88
2e1748b
5a2a714
3ba6343
03ec0e0
56d9aca
ec85a86
4863ea8
b0f6f78
56a08b0
a59a0b8
bb9815f
1ea7a28
d0c8912
e16dfac
942762f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ pyproject.toml | |
| uv.lock | ||
| .python-version | ||
| TODO.md | ||
| .idea/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,15 +47,18 @@ class TextureData: | |
|
|
||
| @dataclass | ||
| class Part: | ||
| name: str | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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", ""), | ||
|
|
@@ -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) | ||
|
|
@@ -336,11 +353,12 @@ def generate_buffers(self) -> None: | |
| layout=data_model.buffers_format["IB"] | ||
| ) | ||
| ib_offset: int = 0 | ||
| 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 | ||
| ) | ||
| if (component.draw_vb != "" and part.vertex_count > 0) or (component.draw_vb == "" and component.position_vb == ""): | ||
| 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 | ||
| ) | ||
| if component.draw_vb == "": | ||
| continue | ||
| for entry in part.objects: | ||
|
|
@@ -386,20 +404,21 @@ def generate_buffers(self) -> None: | |
| if self.outline_optimization: | ||
| self.optimize_outlines(out_buffers, component_ib) | ||
| if component.blend_vb != "": | ||
| self.files_to_write[ | ||
| self.destination / (component.fullname + "Position.buf") | ||
| ] = out_buffers["Position"].data | ||
| self.files_to_write[ | ||
| self.destination / (component.fullname + "Blend.buf") | ||
| ] = out_buffers["Blend"].data | ||
| self.files_to_write[ | ||
| self.destination / (component.fullname + "Texcoord.buf") | ||
| ] = out_buffers["TexCoord"].data | ||
| component.strides = { | ||
| k.lower(): v.stride | ||
| for k, v in data_model.buffers_format.items() | ||
| if k != "IB" | ||
| } | ||
| if any([part.vertex_count for part in component.parts]): | ||
| self.files_to_write[ | ||
| self.destination / (component.fullname + "Position.buf") | ||
| ] = out_buffers["Position"].data | ||
| self.files_to_write[ | ||
| self.destination / (component.fullname + "Blend.buf") | ||
| ] = out_buffers["Blend"].data | ||
| self.files_to_write[ | ||
| self.destination / (component.fullname + "Texcoord.buf") | ||
| ] = out_buffers["TexCoord"].data | ||
| component.strides = { | ||
| k.lower(): v.stride | ||
| for k, v in data_model.buffers_format.items() | ||
| if k != "IB" | ||
| } | ||
| continue | ||
| self.files_to_write[self.destination / (component.fullname + ".buf")] = ( | ||
| out_buffers["Position"].data | ||
|
|
@@ -494,6 +513,11 @@ def generate_ini( | |
| credit=self.credit, | ||
| game=self.game, | ||
| character_name=self.mod_name, | ||
| apply_modifiers=self.apply_modifiers, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the export settings should already be passed as attributes of mod_info
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't find any kind of |
||
| 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() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 }} | ||
|
|
@@ -69,38 +69,52 @@ | |
| {% endblock %} | ||
|
|
||
| {% block overridesibs %} | ||
| {% for component in mod_file.components if component.draw_vb != "" %} | ||
| [TextureOverride{{component.fullname}}IB] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's intentional to not have stray IB sections with just
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 %} | ||
|
|
@@ -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 | ||
|
|
@@ -139,7 +153,7 @@ | |
| stride = {{ component.strides.position }} | ||
| filename = {{ component.fullname }}.buf | ||
| {% endif %} | ||
|
|
||
| {% for part in component.parts %} | ||
| [Resource{{ part.fullname }}IB] | ||
| type = Buffer | ||
|
|
@@ -152,7 +166,7 @@ | |
|
|
||
| {% block resourcetextures %} | ||
| {% for component in mod_file.components %} | ||
| {% for part in component.parts %} | ||
| {% for part in component.parts if (component.draw_vb != "" and part.vertex_count > 0) or (component.draw_vb == "" and component.position_vb == "") %} | ||
| {% for texture in part.textures %} | ||
| [Resource{{ part.fullname }}{{ texture.name }}] | ||
| filename = {{ part.fullname }}{{ texture.name }}{{ texture.extension }} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💀