mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 22:07:55 +01:00
Merge pull request #565 from MaSzyna-EU07/fix/e3d-export-null-matrix
fix(e3d): the -e3d export no longer crashes on a submodel without a matrix
This commit is contained in:
@@ -48,7 +48,7 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void export_e3d_standalone(std::string in, std::string out, int flags, bool dynamic);
|
||||
int export_e3d_standalone(std::string in, std::string out, int flags, bool dynamic);
|
||||
int export_btf_standalone(std::string in, std::string out);
|
||||
int generate_nodebank_previews(int Argc, char *Argv[]);
|
||||
|
||||
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
|
||||
std::string out(argv[3]);
|
||||
int flags = std::stoi(std::string(argv[4]));
|
||||
int dynamic = std::stoi(std::string(argv[5]));
|
||||
export_e3d_standalone(in, out, flags, dynamic);
|
||||
exitcode = export_e3d_standalone(in, out, flags, dynamic);
|
||||
}
|
||||
// standalone generation of preview images of the node bank models: -generate-nodebank-previews [options]
|
||||
else if (argc >= 2 && std::string(argv[1]) == "-generate-nodebank-previews")
|
||||
|
||||
@@ -1,17 +1,39 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "model/Model3d.h"
|
||||
#include "utilities/Globals.h"
|
||||
#include "utilities/Logs.h"
|
||||
#include "rendering/renderer.h"
|
||||
|
||||
void export_e3d_standalone(std::string in, std::string out, int flags, bool dynamic)
|
||||
int export_e3d_standalone(std::string in, std::string out, int flags, bool dynamic)
|
||||
{
|
||||
Global.iConvertModels = flags;
|
||||
Global.iWriteLogEnabled = 2;
|
||||
Global.ParserLogIncludes = true;
|
||||
// the log goes to the standard output only, where the conversion scripts read the included files from, so it is
|
||||
// written from the start. without the log service nothing logged here would come out at all
|
||||
OpenLogFiles();
|
||||
std::jthread logservice(LogService);
|
||||
|
||||
GfxRenderer = gfx_renderer_factory::get_instance()->create("null");
|
||||
TModel3d model;
|
||||
model.LoadFromTextFile(in, dynamic);
|
||||
model.Init();
|
||||
model.SaveToBinFile(out);
|
||||
}
|
||||
auto result{0};
|
||||
if (model.GetSMRoot() == nullptr)
|
||||
{
|
||||
ErrorLog("Bad model: failed to load 3d model \"" + in + "\"");
|
||||
result = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
model.SaveToBinFile(out);
|
||||
}
|
||||
|
||||
// the process ends without destructors, so the log service writes out what's left before it goes
|
||||
StopLogService();
|
||||
logservice.join();
|
||||
return result;
|
||||
}
|
||||
|
||||
+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