added maximum depth command-line argument (-d) and scene option (max_depth); prettified elapsed time output when greater than 60 seconds

git-svn-id: svn://anubis/fart/trunk@203 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop committed 2009-03-10 00:01:21 +00:00
1 parent 4716b200fd
commit 9f9ce1a8f5
8 files changed
+47 -6

No files matched your search

+4
View File
@@ -188,6 +188,10 @@ void Scene::processOptions(refptr<Node> node)
{
m_multisample_level = (*it)->getInteger();
}
else if ( typeid(**it) == typeid(MaxDepthNode) )
{
m_max_depth = (*it)->getInteger();
}
}
}
+4
View File
@@ -57,6 +57,10 @@ Scene::Scene(const map<string, const char *> & options,
{
m_output_file_name = it->second;
}
else if (it->first == "max-depth")
{
m_max_depth = atoi(it->second);
}
else if (it->first == "verbose")
{
m_verbose = true;
+26 -3
View File
@@ -36,11 +36,12 @@ int main(int argc, char * argv[])
{ "height", required_argument, NULL, 'h' },
{ "multisample", required_argument, NULL, 'm' },
{ "field-of-view", required_argument, NULL, 'f' },
{ "max-depth", required_argument, NULL, 'd' },
{ "verbose", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
};
while ((opt = getopt_long(argc, argv, "o:w:h:m:f:v",
while ((opt = getopt_long(argc, argv, "o:w:h:m:f:d:v",
long_options, &option_index)) != -1)
{
switch (opt)
@@ -63,6 +64,9 @@ int main(int argc, char * argv[])
case 'f':
scene_options["field-of-view"] = optarg;
break;
case 'd':
scene_options["max-depth"] = optarg;
break;
case 'v':
scene_options["verbose"] = optarg;
break;
@@ -87,8 +91,27 @@ int main(int argc, char * argv[])
double time_before = before.tv_sec + before.tv_usec / 1000000.0;
double time_after = after.tv_sec + after.tv_usec / 1000000.0;
double diff = time_after - time_before;
cout << "Elapsed time: " << diff << " seconds." << endl;
double total_seconds = time_after - time_before;
cout << "Elapsed time: " << total_seconds << " seconds";
double seconds = total_seconds;
int days = (int) (seconds / (60.0 * 60.0 * 24.0));
seconds -= days * 60.0 * 60.0 * 24.0;
int hours = (int) (seconds / (60.0 * 60.0));
seconds -= hours * 60.0 * 60.0;
int minutes = (int) (seconds / 60.0);
seconds -= minutes * 60.0;
if (days || hours || minutes)
{
cout << " (";
if (days)
cout << days << " days, ";
if (days || hours)
cout << hours << " hours, ";
cout << minutes << " minutes, ";
cout << seconds << " seconds)";
}
cout << endl;
return 0;
}