Add forgotten MP3 MAPA DNA

Fix crash when trying to add a seam to a missing edge
This commit is contained in:
Phillip Stephens 2015-12-05 23:28:29 -08:00
parent d3205718f2
commit 2dcd9fa789
2 changed files with 45 additions and 0 deletions

View File

@ -78,6 +78,11 @@ struct MAPA : BigDNA
{
/* magic */
magic = __dna_reader.readUint32Big();
if (magic != 0xDEADD00D)
{
LogDNACommon.report(LogVisor::Error, "invalid MAPA magic");
return;
}
/* version */
version = __dna_reader.readUint32Big();
if (version == 2)
@ -86,6 +91,12 @@ struct MAPA : BigDNA
header.reset(new HeaderMP2);
else if (version == 5)
header.reset(new HeaderMP3);
else
{
LogDNACommon.report(LogVisor::Error, "invalid MAPA version");
return;
}
header->read(__dna_reader);
for (int i = 0; i < header->mappableObjectCount(); i++)
@ -282,6 +293,8 @@ bool ReadMAPAToBlender(HECL::BlenderConnection& conn,
"def add_border(bm, verts):\n"
" verts = [bm.verts[vi] for vi in verts]\n"
" edge = bm.edges.get(verts)\n"
" if not edge:\n"
" edge = bm.edges.new(verts)\n"
" edge.seam = True\n"
"\n";

32
DataSpec/DNAMP3/MAPA.hpp Normal file
View File

@ -0,0 +1,32 @@
#ifndef __DNAMP3_MAPA_HPP__
#define __DNAMP3_MAPA_HPP__
#include "../DNACommon/PAK.hpp"
#include "../DNACommon/MAPA.hpp"
#include "DNAMP3.hpp"
namespace Retro
{
namespace DNAMP3
{
struct MAPA : DNAMAPA::MAPA
{
static bool Extract(const SpecBase& dataSpec,
PAKEntryReadStream& rs,
const HECL::ProjectPath& outPath,
PAKRouter<PAKBridge>& pakRouter,
const PAK::Entry& entry,
bool force,
std::function<void(const HECL::SystemChar*)> fileChanged)
{
MAPA mapa;
mapa.read(rs);
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
return DNAMAPA::ReadMAPAToBlender(conn, mapa, outPath, pakRouter, entry, force);
}
};
}
}
#endif