jpaver / opengametools

A set of open c++ game development tools that are lightweight, easy-to-integrate and free to use. Currently hosting a magicavoxel .vox full scene loader.
MIT License
373 stars 35 forks source link

CHUNK_ID_XYZI voxel bounds check to improve handling of corrupt files #59

Open dougbinks opened 1 year ago

dougbinks commented 1 year ago

I've encountered a number of vox files which were corrupt with voxels outside the bounds of the model size. This results in the voxel array bounds being overwritten when loaded.

There's already an assert in the code, but this PR adds the same test to adding the voxel data to the array. I've been able to recover some data from models which otherwise would not load with this addition and I don't think the performance hit is significant.

mgerhardy commented 1 year ago

This is also part of https://github.com/jpaver/opengametools/pull/58 - with ogt_warn

dougbinks commented 1 year ago

Ah, I didn't spot that. This can be closed if you're intending to accept that change.

mgerhardy commented 1 year ago

Well, I would be thankful on your input on where I've added the ogt_warn stuff and where it still is ogt_assert. Not sure if my PR would get accepted that way. Let's see

dougbinks commented 1 year ago

I'll take a look soon.