mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 21:07:06 +01:00
fix(e3d): the -e3d export no longer crashes on a submodel without a matrix
A submodel whose definition breaks off before its transform (no "type:" in its header) is still attached to the tree, without a matrix, and TSubModel::serialize dereferenced that matrix. It is written as -1 now, which the binary loader reads back as no matrix, so the .e3d holds the same tree the .t3d gives. The -e3d mode also runs the log service now. Without it nothing logged during the conversion came out, neither the included files the conversion scripts read from the standard output nor the error that names the broken submodel. A model that loaded nothing ends with exit code 1 and a message instead of a crash.
This commit is contained in:
+6
-1
@@ -1943,7 +1943,12 @@ void TSubModel::serialize(std::ostream &s, std::vector<TSubModel *> &models, std
|
||||
if (m_material > 0 && Global.iConvertModels & 16)
|
||||
flags &= ~0x30; // don't save phase information, will be guessed on binary load from material
|
||||
sn_utils::ls_uint32(s, flags);
|
||||
sn_utils::ls_int32(s, (int32_t)get_container_pos(transforms, *fMatrix));
|
||||
// a submodel whose definition broke off before its transform (see Load()) has no matrix. -1 is what the binary
|
||||
// loader reads back as no matrix
|
||||
if (fMatrix != nullptr)
|
||||
sn_utils::ls_int32(s, (int32_t)get_container_pos(transforms, *fMatrix));
|
||||
else
|
||||
sn_utils::ls_int32(s, -1);
|
||||
|
||||
sn_utils::ls_int32(s, m_geometry.vertex_count);
|
||||
sn_utils::ls_int32(s, m_geometry.vertex_offset);
|
||||
|
||||
Reference in New Issue
Block a user