2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 15:44:56 +00:00

mesh cook bug fixes

This commit is contained in:
Jack Andersen
2015-10-03 18:35:18 -10:00
parent ab5451ea45
commit 051e16fdee
15 changed files with 515 additions and 326 deletions

View File

@@ -20,7 +20,7 @@ struct ToolPassInfo
{
HECL::SystemString pname;
HECL::SystemString cwd;
std::list<HECL::SystemString> args;
std::vector<HECL::SystemString> args;
HECL::SystemString output;
HECL::Database::Project* project = nullptr;
unsigned verbosityLevel = 0;
@@ -229,6 +229,7 @@ static HECL::SystemString MakePathArgAbsolute(const HECL::SystemString& arg,
void ToolPrintProgress(const HECL::SystemChar* message, const HECL::SystemChar* submessage,
int lidx, float factor, int& lineIdx)
{
bool blocks = factor >= 0.0;
factor = std::max(0.0f, std::min(1.0f, factor));
int iFactor = factor * 100.0;
if (XTERM_COLOR)
@@ -243,7 +244,11 @@ void ToolPrintProgress(const HECL::SystemChar* message, const HECL::SystemChar*
HECL::Printf(_S(" "));
int width = HECL::ConsoleWidth();
int half = width / 2 - 2;
int half;
if (blocks)
half = width / 2 - 2;
else
half = width - 4;
if (!message)
message = _S("");
@@ -278,29 +283,32 @@ void ToolPrintProgress(const HECL::SystemChar* message, const HECL::SystemChar*
}
}
if (XTERM_COLOR)
if (blocks)
{
size_t blocks = half - 7;
size_t filled = blocks * factor;
size_t rem = blocks - filled;
HECL::Printf(_S("" BOLD "%3d%% ["), iFactor);
for (int b=0 ; b<filled ; ++b)
HECL::Printf(_S("#"));
for (int b=0 ; b<rem ; ++b)
HECL::Printf(_S("-"));
HECL::Printf(_S("]" NORMAL ""));
}
else
{
size_t blocks = half - 7;
size_t filled = blocks * factor;
size_t rem = blocks - filled;
HECL::Printf(_S("%3d%% ["), iFactor);
for (int b=0 ; b<filled ; ++b)
HECL::Printf(_S("#"));
for (int b=0 ; b<rem ; ++b)
HECL::Printf(_S("-"));
HECL::Printf(_S("]"));
if (XTERM_COLOR)
{
size_t blocks = half - 7;
size_t filled = blocks * factor;
size_t rem = blocks - filled;
HECL::Printf(_S("" BOLD "%3d%% ["), iFactor);
for (int b=0 ; b<filled ; ++b)
HECL::Printf(_S("#"));
for (int b=0 ; b<rem ; ++b)
HECL::Printf(_S("-"));
HECL::Printf(_S("]" NORMAL ""));
}
else
{
size_t blocks = half - 7;
size_t filled = blocks * factor;
size_t rem = blocks - filled;
HECL::Printf(_S("%3d%% ["), iFactor);
for (int b=0 ; b<filled ; ++b)
HECL::Printf(_S("#"));
for (int b=0 ; b<rem ; ++b)
HECL::Printf(_S("-"));
HECL::Printf(_S("]"));
}
}
HECL::Printf(_S("\r"));

View File

@@ -6,7 +6,7 @@
class ToolCook final : public ToolBase
{
std::list<HECL::ProjectPath> m_selectedItems;
std::vector<HECL::ProjectPath> m_selectedItems;
std::unique_ptr<HECL::Database::Project> m_fallbackProj;
HECL::Database::Project* m_useProj;
bool m_recursive = false;
@@ -18,6 +18,7 @@ public:
if (info.args.size())
{
/* See if project path is supplied via args and use that over the getcwd one */
m_selectedItems.reserve(info.args.size());
for (const HECL::SystemString& arg : info.args)
{
if (arg.empty())
@@ -59,7 +60,11 @@ public:
/* Default case: recursive at root */
if (m_selectedItems.empty())
m_selectedItems.push_back({HECL::ProjectPath(*m_useProj, _S("."))});
{
m_selectedItems.reserve(1);
m_selectedItems.push_back({HECL::ProjectPath(*m_useProj, _S(""))});
m_recursive = true;
}
}
static void Help(HelpOutput& help)
@@ -124,11 +129,10 @@ public:
{
int lineIdx = 0;
m_useProj->cookPath(path,
[&lineIdx](const HECL::SystemChar* message, const HECL::SystemChar* submessage,
[&lineIdx](const HECL::SystemChar* message,
const HECL::SystemChar* submessage,
int lidx, float factor)
{
ToolPrintProgress(message, submessage, lidx, factor, lineIdx);
}, m_recursive);
{ToolPrintProgress(message, submessage, lidx, factor, lineIdx);}, m_recursive);
}
return 0;
}

View File

@@ -22,8 +22,8 @@ class ToolExtract final : public ToolBase
SpecExtractPass(const SpecExtractPass& other) = delete;
SpecExtractPass(SpecExtractPass&& other) = default;
};
std::list<SpecExtractPass> m_specPasses;
std::list<HECL::Database::IDataSpec::ExtractReport> m_reps;
std::vector<SpecExtractPass> m_specPasses;
std::vector<HECL::Database::IDataSpec::ExtractReport> m_reps;
std::unique_ptr<HECL::Database::Project> m_fallbackProj;
HECL::Database::Project* m_useProj;
public:
@@ -64,12 +64,13 @@ public:
m_einfo.srcpath = m_info.args.front();
m_einfo.force = info.force;
std::list<HECL::SystemString>::const_iterator it=info.args.begin();
m_einfo.extractArgs.reserve(info.args.size());
auto it=info.args.cbegin();
++it;
for (;it != info.args.end();
++it)
for (; it != info.args.cend(); ++it)
m_einfo.extractArgs.push_back(*it);
m_specPasses.reserve(HECL::Database::DATA_SPEC_REGISTRY.size());
for (const HECL::Database::DataSpecEntry* entry : HECL::Database::DATA_SPEC_REGISTRY)
{
HECL::Database::IDataSpec* ds = entry->m_factory(*m_useProj, HECL::Database::TOOL_EXTRACT);
@@ -187,11 +188,10 @@ public:
int lineIdx = 0;
ds.m_instance->doExtract(m_einfo,
[&lineIdx](const HECL::SystemChar* message, const HECL::SystemChar* submessage,
[&lineIdx](const HECL::SystemChar* message,
const HECL::SystemChar* submessage,
int lidx, float factor)
{
ToolPrintProgress(message, submessage, lidx, factor, lineIdx);
});
{ToolPrintProgress(message, submessage, lidx, factor, lineIdx);});
HECL::Printf(_S("\n\n"));
}

View File

@@ -129,14 +129,15 @@ public:
std::vector<HECL::SystemString> opSpecs;
auto it = m_info.args.begin();
++it;
for (;it != m_info.args.end();
++it)
for (; it != m_info.args.end() ; ++it)
{
HECL::SystemString itName = *it;
HECL::ToLower(itName);
for (auto& spec : specs)
{
if (!itName.compare(spec.spec.m_name))
HECL::SystemString compName(spec.spec.m_name);
HECL::ToLower(compName);
if (!itName.compare(compName))
{
opSpecs.push_back(spec.spec.m_name);
break;

View File

@@ -149,14 +149,15 @@ int main(int argc, const char** argv)
}
/* Concatenate args */
std::list<HECL::SystemString> args;
std::vector<HECL::SystemString> args;
args.reserve(argc-2);
for (int i=2 ; i<argc ; ++i)
args.push_back(HECL::SystemString(argv[i]));
if (!args.empty())
{
/* Extract output argument */
for (std::list<HECL::SystemString>::const_iterator it = args.begin() ; it != args.end() ;)
for (auto it = args.cbegin() ; it != args.cend() ;)
{
const HECL::SystemString& arg = *it;
HECL::SystemRegexMatch oMatch;
@@ -184,7 +185,7 @@ int main(int argc, const char** argv)
}
/* Count verbosity */
for (std::list<HECL::SystemString>::const_iterator it = args.begin() ; it != args.end() ;)
for (auto it = args.cbegin() ; it != args.cend() ;)
{
const HECL::SystemString& arg = *it;
HECL::SystemRegexMatch vMatch;
@@ -199,7 +200,7 @@ int main(int argc, const char** argv)
}
/* Check force argument */
for (std::list<HECL::SystemString>::const_iterator it = args.begin() ; it != args.end() ;)
for (auto it = args.cbegin() ; it != args.cend() ;)
{
const HECL::SystemString& arg = *it;
if (std::regex_search(arg, regFORCE))
@@ -212,6 +213,7 @@ int main(int argc, const char** argv)
}
/* Gather remaining args */
info.args.reserve(args.size());
for (const HECL::SystemString& arg : args)
info.args.push_back(arg);
}
@@ -270,7 +272,7 @@ int main(int argc, const char** argv)
{
/* Shortcut-case: implicit extract */
fclose(fp);
info.args.push_front(argv[1]);
info.args.insert(info.args.begin(), argv[1]);
tool.reset(new ToolExtract(info));
}
}