Skip to content

ogt_vox: instance and group save order implementation#85

Open
dougbinks wants to merge 1 commit intojpaver:masterfrom
dougbinks:ogt-vox-save-order
Open

ogt_vox: instance and group save order implementation#85
dougbinks wants to merge 1 commit intojpaver:masterfrom
dougbinks:ogt-vox-save-order

Conversation

@dougbinks
Copy link
Copy Markdown
Collaborator

@dougbinks dougbinks commented Apr 12, 2026

This PR adds group and instance ordering to ensure that a file written by ogt_vox.h will preserve the instance ordering required for correct rendering.

The ordering is primarily based on the instance order in the scene.

This adds a mutable uint32_t _nodeId to the ogt_vox_instance and ogt_vox_group structs.

Some issues:

  1. This is only currently implemented for file version 200 ordering.
  2. Any groups without instances will not be written out. Currently groups without instances are not supported in MV, but some people may use them in .vox import/export. I could add support for writing these.
  3. We may want to add an unordered writer for speed when dealing with unordered scenes (non-overlapping chunks for example), though performance seems reaasonable.
  4. If the groups are not ordered correctly they will be written out but the resulting scene may not have the correct ordering. This could be fixed by sorting the groups which would require an allocation as we should not mutate the scene data supplied to the writer (other than the mutable uint32_t _nodeId).

This PR would resolve #84 for file version 200.

@dougbinks dougbinks changed the title ogt_vox: save order implementation ogt_vox: instance and group save order implementation Apr 12, 2026
Comment thread src/ogt_vox.h
uint32_t unassinged_groupIds = 0;
uint32_t group_index = instance->group_index;
while (group_index != k_invalid_group_index)
{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the formatting is wrong here

Comment thread src/ogt_vox.h
uint32_t groupsToWrite = instance->_nodeId - nodeIdToWrite;
while (instance->_nodeId - nodeIdToWrite)
{
// write out any groups
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

formatting is also wrong here.

Comment thread src/ogt_vox.h
_vox_file_write_chunk_nTRN(fp, node_id, child_node_id, instance->name, instance->hidden, &instance->transform, instance->layer_index, &instance->transform_anim);
uint32_t groupsToWrite = instance->_nodeId - nodeIdToWrite;
while (instance->_nodeId - nodeIdToWrite)
{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

also this block uses wrong formatting

@dougbinks
Copy link
Copy Markdown
Collaborator Author

Thanks for these - I'm bad at spotting formatting as I'm dyslexic.

I take it the issue here is that the { should be on the same line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ogt_vox: groups and instances are not correctly ordered

2 participants