dust-engine / dot_vox

Rust parser for MagicaVoxel .vox files.
MIT License
53 stars 20 forks source link

thread 'main' panicked at 'Unrecognised material type 4291624755 with weight NaN', C:\Users\xxx\.cargo\registry\src\github.com-1ecc6299db9ec823\dot_vox-1.0.0\src\material\material_type.rs:24:18 #12

Closed xMAC94x closed 6 years ago

xMAC94x commented 6 years ago

Hi,

i get the following panic with the below file (see attachment at bottom) with version 1.0.0

with the following code:

    let vox = dot_vox::load("vox/examplechar.vox").unwrap();

thread 'main' panicked at 'Unrecognised material type 4291624755 with weight NaN', C:\Users\xxx.cargo\registry\src\github.com-1ecc6299db9ec823\dot_vox-1.0.0\src\material\material_type.rs:24:18 stack backtrace: 0: std::sys::windows::backtrace::unwind_backtrace at C:\projects\rust\src\libstd\sys\windows\backtrace\mod.rs:65 1: std::sys_common::backtrace::_print at C:\projects\rust\src\libstd\sys_common\backtrace.rs:71 2: std::sys_common::backtrace::print at C:\projects\rust\src\libstd\sys_common\backtrace.rs:59 3: std::panicking::default_hook::{{closure}} at C:\projects\rust\src\libstd\panicking.rs:211 4: std::panicking::default_hook at C:\projects\rust\src\libstd\panicking.rs:227 5: std::panicking::rust_panic_with_hook at C:\projects\rust\src\libstd\panicking.rs:511 6: std::panicking::begin_panic at C:\projects\rust\src\libstd\panicking.rs:445 7: dot_vox::material::material_type::MaterialType::from_u32 at C:\Users\xxx.cargo\registry\src\github.com-1ecc6299db9ec823\dot_vox-1.0.0\src\material\material_type.rs:24 8: dot_vox::material::material_type::parse_material_type at C:\Users\xxx.cargo\registry\src\github.com-1ecc6299db9ec823\dot_vox-1.0.0\src\material\material_type.rs:36 9: dot_vox::material::parse_material at C:\Users\xxx.cargo\registry\src\github.com-1ecc6299db9ec823\dot_vox-1.0.0\:13 10: dot_vox::material::extract_materials at C:\Users\xxx.cargo\registry\src\github.com-1ecc6299db9ec823\dot_vox-1.0.0\:34 11: dot_vox::parse_vox_file at C:\Users\xxx.cargo\registry\src\github.com-1ecc6299db9ec823\dot_vox-1.0.0\:13 12: dot_vox::load at C:\Users\xxx.cargo\registry\src\github.com-1ecc6299db9ec823\dot_vox-1.0.0\src\lib.rs:105 13: voxygen::game::Game::new<std::net::addr::SocketAddr,str*> at .\src\game.rs:47 14: voxygen::main at .\src\main.rs:69 15: std::rt::lang_start::{{closure}}<()> at C:\projects\rust\src\libstd\rt.rs:74 16: std::rt::lang_start_internal::{{closure}} at C:\projects\rust\src\libstd\rt.rs:59 17: std::panicking::try::do_call<closure,i32> at C:\projects\rust\src\libstd\panicking.rs:310 18: panic_unwind::rust_maybe_catch_panic at C:\projects\rust\src\libpanic_unwind\lib.rs:105 19: std::panicking::try at C:\projects\rust\src\libstd\panicking.rs:289 20: std::panic::catch_unwind at C:\projects\rust\src\libstd\panic.rs:392 21: std::rt::lang_start_internal at C:\projects\rust\src\libstd\rt.rs:58 22: std::rt::lang_start<()> at C:\projects\rust\src\libstd\rt.rs:74 23: main 24: invoke_main at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:64 25: scrt_common_main_seh at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253 26: BaseThreadInitThunk 27: RtlUserThreadStart error: process didn't exit successfully: C:\rust\game\target\debug\voxygen.exe (exit code: 101)

examplechar.zip

davidedmonds commented 6 years ago

Eek!

Thanks for the thorough bug report and sample file - I shall take a look as soon as I'm able to (most likely Wednesday & Thursday this week).

davidedmonds commented 6 years ago

Hi again!

Have pushed a short-term fix as dot_vox 1.0.1, which should remove the panic, replacing the mis-parsed material with an Unknown material for the moment.

This doesn't fix the underlying problem, which appears to be that the palette parsing is starting one block too early >.< Will continue to investigate the cause of this one and update when there's a fix.

Thanks again for the bug report - and love the model :)

davidedmonds commented 6 years ago

Hi again!

Have spent a bit of time rebuilding the parser, building up a tree of chunks and then mapping that into the DotVoxData. That seems to have resolved the issue around the data overflowing between chunks, which is a bit of an improvement ;) I've released this as 2.0.0 of the crate.

I've tried to parse your example character again, and in the process discovered a fairly big rewrite of the Material chunk format over in MagicaVoxel - which means that currently the material data in the file isn't being loaded. I'll spend some more time clearing that up and make another minor release before closing this issue off.

davidedmonds commented 6 years ago

Hi again!

Have finished rebuilding the Material parsing. Unfortunately, as the underlying format had changed quite substantially, I've ended up having to change the content of the Material chunks to match, meaning there's another major release (3.0.0) and some API changes.

There's still some chunks left in the file that aren't parsed, which seem to be around a scene graph. I'll have a go at implementing these at some point in the future, unless a PR gets there first ;)

All the best!