Skip some files in ig build when possible

This commit is contained in:
kaetemi 2014-02-09 00:46:03 +01:00
parent 13e3849c89
commit 06e8090669
3 changed files with 156 additions and 106 deletions

View file

@ -205,6 +205,7 @@ struct SOptions : public SExportOptions
{ {
CIXml xml (true); CIXml xml (true);
xml.init (fileIn); xml.init (fileIn);
ZoneRegionFile = filename;
ZoneRegion = new CZoneRegion; ZoneRegion = new CZoneRegion;
ZoneRegion->serial (xml); ZoneRegion->serial (xml);
} }

View file

@ -2402,55 +2402,79 @@ void CExport::transformCMB (const std::string &name, const NLMISC::CMatrix &tran
_ExportCB->dispWarning("Can't find " + cmbNoExtension + ".cmb"); _ExportCB->dispWarning("Can't find " + cmbNoExtension + ".cmb");
return; return;
} }
CIFile inStream; std::string outFileName = _Options->OutCMBDir +"/" + cmbNoExtension + ".cmb";
if (inStream.open(cmbName)) bool needUpdate = true;
if (CFile::fileExists(outFileName))
{ {
try uint32 outModification = CFile::getFileModificationDate(outFileName);
needUpdate =
CFile::getFileModificationDate(cmbName) > outModification
|| (CFile::fileExists(_Options->HeightMapFile) && (CFile::getFileModificationDate(_Options->HeightMapFile) > outModification))
|| (CFile::fileExists(_Options->HeightMapFile2) && (CFile::getFileModificationDate(_Options->HeightMapFile2) > outModification))
|| (CFile::fileExists(_Options->ContinentFile) && (CFile::getFileModificationDate(_Options->ContinentFile) > outModification))
|| (CFile::fileExists(_Options->ZoneRegionFile) && (CFile::getFileModificationDate(_Options->ZoneRegionFile) > outModification));
}
if (needUpdate)
{
if (_ExportCB != NULL)
_ExportCB->dispInfo("UPDATE " + cmbName);
printf("UPDATE %s\n", cmbName.c_str());
CIFile inStream;
if (inStream.open(cmbName))
{ {
CCollisionMeshBuild cmb; try
cmb.serial(inStream);
// translate and save
cmb.transform (transfo);
COFile outStream;
std::string outFileName = _Options->OutCMBDir +"/" + cmbNoExtension + ".cmb";
if (!outStream.open(outFileName))
{ {
if (_ExportCB != NULL) CCollisionMeshBuild cmb;
_ExportCB->dispWarning("Couldn't open " + outFileName + "for writing, not exporting"); cmb.serial(inStream);
} // translate and save
else cmb.transform (transfo);
{ COFile outStream;
try if (!outStream.open(outFileName))
{ {
cmb.serial(outStream);
outStream.close();
}
catch (const EStream &e)
{
outStream.close();
if (_ExportCB != NULL) if (_ExportCB != NULL)
_ExportCB->dispWarning("Couldn't open " + outFileName + "for writing, not exporting");
}
else
{
try
{ {
_ExportCB->dispWarning("Error while writing " + outFileName); cmb.serial(outStream);
_ExportCB->dispWarning(e.what()); outStream.close();
}
catch (const EStream &e)
{
outStream.close();
if (_ExportCB != NULL)
{
_ExportCB->dispWarning("Error while writing " + outFileName);
_ExportCB->dispWarning(e.what());
}
} }
} }
inStream.close();
} }
inStream.close(); catch (const EStream &e)
}
catch (const EStream &e)
{
inStream.close();
if (_ExportCB != NULL)
{ {
_ExportCB->dispWarning("Error while reading " + cmbName); inStream.close();
_ExportCB->dispWarning(e.what()); if (_ExportCB != NULL)
{
_ExportCB->dispWarning("Error while reading " + cmbName);
_ExportCB->dispWarning(e.what());
}
} }
} }
else
{
if (_ExportCB != NULL)
_ExportCB->dispWarning("Unable to open " + cmbName);
}
} }
else else
{ {
if (_ExportCB != NULL) if (_ExportCB != NULL)
_ExportCB->dispWarning("Unable to open " + cmbName); _ExportCB->dispInfo("SKIP " + cmbName);
printf("SKIP %s\n", cmbName.c_str());
} }
} }
@ -2471,98 +2495,122 @@ void CExport::transformAdditionnalIG (const std::string &name, const NLMISC::CMa
_ExportCB->dispWarning("Can't find " + igNoExtension + ".cmb"); _ExportCB->dispWarning("Can't find " + igNoExtension + ".cmb");
return; return;
} }
CIFile inStream; std::string outFileName = _Options->AdditionnalIGOutDir +"/" + igNoExtension + ".ig";
if (inStream.open(igName)) bool needUpdate = true;
if (CFile::fileExists(outFileName))
{ {
try uint32 outModification = CFile::getFileModificationDate(outFileName);
needUpdate =
CFile::getFileModificationDate(igName) > outModification
|| (CFile::fileExists(_Options->HeightMapFile) && (CFile::getFileModificationDate(_Options->HeightMapFile) > outModification))
|| (CFile::fileExists(_Options->HeightMapFile2) && (CFile::getFileModificationDate(_Options->HeightMapFile2) > outModification))
|| (CFile::fileExists(_Options->ContinentFile) && (CFile::getFileModificationDate(_Options->ContinentFile) > outModification))
|| (CFile::fileExists(_Options->ZoneRegionFile) && (CFile::getFileModificationDate(_Options->ZoneRegionFile) > outModification));
}
if (needUpdate)
{
if (_ExportCB != NULL)
_ExportCB->dispInfo("UPDATE " + igName);
printf("UPDATE %s\n", igName.c_str());
CIFile inStream;
if (inStream.open(igName))
{ {
CInstanceGroup ig, igOut; try
ig.serial(inStream);
CVector globalPos;
CInstanceGroup::TInstanceArray IA;
std::vector<CCluster> Clusters;
std::vector<CPortal> Portals;
std::vector<CPointLightNamed> PLN;
ig.retrieve(globalPos, IA, Clusters, Portals, PLN);
bool realTimeSuncontribution = ig.getRealTimeSunContribution();
uint k;
// elevate instance
for(k = 0; k < IA.size(); ++k)
{ {
IA[k].Pos = transfo * IA[k].Pos; CInstanceGroup ig, igOut;
IA[k].Rot = rotTransfo * IA[k].Rot; ig.serial(inStream);
}
// lights CVector globalPos;
for(k = 0; k < PLN.size(); ++k) CInstanceGroup::TInstanceArray IA;
{ std::vector<CCluster> Clusters;
PLN[k].setPosition(transfo * PLN[k].getPosition()); std::vector<CPortal> Portals;
} std::vector<CPointLightNamed> PLN;
// portals
std::vector<CVector> portal; ig.retrieve(globalPos, IA, Clusters, Portals, PLN);
for(k = 0; k < Portals.size(); ++k) bool realTimeSuncontribution = ig.getRealTimeSunContribution();
{
Portals[k].getPoly(portal); uint k;
for(uint l = 0; l < portal.size(); ++l) // elevate instance
for(k = 0; k < IA.size(); ++k)
{ {
portal[l] = transfo * portal[l]; IA[k].Pos = transfo * IA[k].Pos;
IA[k].Rot = rotTransfo * IA[k].Rot;
} }
Portals[k].setPoly(portal); // lights
} for(k = 0; k < PLN.size(); ++k)
// clusters
for(k = 0; k < Clusters.size(); ++k)
{
Clusters[k].applyMatrix (transfo);
}
igOut.build(globalPos, IA, Clusters, Portals, PLN);
igOut.enableRealTimeSunContribution(realTimeSuncontribution);
COFile outStream;
std::string outFileName = _Options->AdditionnalIGOutDir +"/" + igNoExtension + ".ig";
if (!outStream.open(outFileName))
{
if (_ExportCB != NULL)
_ExportCB->dispWarning("Couldn't open " + outFileName + "for writing, not exporting");
}
else
{
try
{ {
igOut.serial(outStream); PLN[k].setPosition(transfo * PLN[k].getPosition());
outStream.close();
} }
catch (const EStream &e) // portals
std::vector<CVector> portal;
for(k = 0; k < Portals.size(); ++k)
{ {
outStream.close(); Portals[k].getPoly(portal);
if (_ExportCB != NULL) for(uint l = 0; l < portal.size(); ++l)
{ {
_ExportCB->dispWarning("Error while writing " + outFileName); portal[l] = transfo * portal[l];
_ExportCB->dispWarning(e.what()); }
Portals[k].setPoly(portal);
}
// clusters
for(k = 0; k < Clusters.size(); ++k)
{
Clusters[k].applyMatrix (transfo);
}
igOut.build(globalPos, IA, Clusters, Portals, PLN);
igOut.enableRealTimeSunContribution(realTimeSuncontribution);
COFile outStream;
if (!outStream.open(outFileName))
{
if (_ExportCB != NULL)
_ExportCB->dispWarning("Couldn't open " + outFileName + "for writing, not exporting");
}
else
{
try
{
igOut.serial(outStream);
outStream.close();
}
catch (const EStream &e)
{
outStream.close();
if (_ExportCB != NULL)
{
_ExportCB->dispWarning("Error while writing " + outFileName);
_ExportCB->dispWarning(e.what());
}
} }
} }
inStream.close();
} }
inStream.close(); catch (const EStream &e)
}
catch (const EStream &e)
{
inStream.close();
if (_ExportCB != NULL)
{ {
_ExportCB->dispWarning("Error while reading " + igName); inStream.close();
_ExportCB->dispWarning(e.what()); if (_ExportCB != NULL)
{
_ExportCB->dispWarning("Error while reading " + igName);
_ExportCB->dispWarning(e.what());
}
} }
} }
else
{
if (_ExportCB != NULL)
_ExportCB->dispWarning("Unable to open " + igName);
}
} }
else else
{ {
if (_ExportCB != NULL) if (_ExportCB != NULL)
_ExportCB->dispWarning("Unable to open " + igName); _ExportCB->dispInfo("SKIP " + igName);
printf("SKIP %s\n", igName.c_str());
} }
} }

View file

@ -107,6 +107,7 @@ struct SExportOptions
// Options not saved // Options not saved
std::string ZoneRegionFile;
NLLIGO::CZoneRegion *ZoneRegion; // The region to make NLLIGO::CZoneRegion *ZoneRegion; // The region to make
float CellSize; float CellSize;
float Threshold; float Threshold;