mwl4 / ConverterPIX

Conversion tool that is able to convert from the game binary formats (.pmx) to the middle formats (.pix) in Euro Truck Simulator 2 & American Truck Simulator.
https://truckersmp.com/
GNU Lesser General Public License v3.0
67 stars 27 forks source link

Fix for crash when importing /model/mover/animal/deer_run_jump_herd model from ats 1.32. #29

Closed theHarven closed 5 years ago

theHarven commented 5 years ago

The crash happened because this particular model has 177 bones (there are 5 deers running next to each other). When importing those bones, m_parent which was signed 1 byte, started to flip below 0 after reaching 127. Then these negative indexes were used when accessing m_bones Array. Changing the type of m_parent to unsigned 1 byte fixed the issue but then the mesh started to float around. To fix this I had to change the type of Vertex::m_boneIndex to unsigned 1 byte as well so that vertexes were assigned to proper bones. Now converter_pix is not crashing and the model and the animation works very well after importing to blender.

theHarven commented 5 years ago

Ah and the crash wasn't happening on linux build but instead the resulting pis file had "(null)" parents in bones which had parent bones with indexes above 127.