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:
parent
4716b200fd
commit
9f9ce1a8f5
2
.todo
2
.todo
@ -2,5 +2,3 @@ FART To-Do List
|
|||||||
===============
|
===============
|
||||||
- Shape definitions / reusability
|
- Shape definitions / reusability
|
||||||
- Add distribution infrastructure
|
- Add distribution infrastructure
|
||||||
- Add maximum recursion depth option / parameter
|
|
||||||
- Prettify elapsed time output
|
|
||||||
|
@ -188,6 +188,10 @@ void Scene::processOptions(refptr<Node> node)
|
|||||||
{
|
{
|
||||||
m_multisample_level = (*it)->getInteger();
|
m_multisample_level = (*it)->getInteger();
|
||||||
}
|
}
|
||||||
|
else if ( typeid(**it) == typeid(MaxDepthNode) )
|
||||||
|
{
|
||||||
|
m_max_depth = (*it)->getInteger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,10 @@ Scene::Scene(const map<string, const char *> & options,
|
|||||||
{
|
{
|
||||||
m_output_file_name = it->second;
|
m_output_file_name = it->second;
|
||||||
}
|
}
|
||||||
|
else if (it->first == "max-depth")
|
||||||
|
{
|
||||||
|
m_max_depth = atoi(it->second);
|
||||||
|
}
|
||||||
else if (it->first == "verbose")
|
else if (it->first == "verbose")
|
||||||
{
|
{
|
||||||
m_verbose = true;
|
m_verbose = true;
|
||||||
|
29
main/fart.cc
29
main/fart.cc
@ -36,11 +36,12 @@ int main(int argc, char * argv[])
|
|||||||
{ "height", required_argument, NULL, 'h' },
|
{ "height", required_argument, NULL, 'h' },
|
||||||
{ "multisample", required_argument, NULL, 'm' },
|
{ "multisample", required_argument, NULL, 'm' },
|
||||||
{ "field-of-view", required_argument, NULL, 'f' },
|
{ "field-of-view", required_argument, NULL, 'f' },
|
||||||
|
{ "max-depth", required_argument, NULL, 'd' },
|
||||||
{ "verbose", no_argument, NULL, 'v' },
|
{ "verbose", no_argument, NULL, 'v' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ 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)
|
long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
@ -63,6 +64,9 @@ int main(int argc, char * argv[])
|
|||||||
case 'f':
|
case 'f':
|
||||||
scene_options["field-of-view"] = optarg;
|
scene_options["field-of-view"] = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
scene_options["max-depth"] = optarg;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
scene_options["verbose"] = optarg;
|
scene_options["verbose"] = optarg;
|
||||||
break;
|
break;
|
||||||
@ -87,8 +91,27 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
double time_before = before.tv_sec + before.tv_usec / 1000000.0;
|
double time_before = before.tv_sec + before.tv_usec / 1000000.0;
|
||||||
double time_after = after.tv_sec + after.tv_usec / 1000000.0;
|
double time_after = after.tv_sec + after.tv_usec / 1000000.0;
|
||||||
double diff = time_after - time_before;
|
double total_seconds = time_after - time_before;
|
||||||
cout << "Elapsed time: " << diff << " seconds." << endl;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -153,6 +153,12 @@ class MaterialRefNode : public IdentifierNode
|
|||||||
bool isMaterial() { return true; }
|
bool isMaterial() { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MaxDepthNode : public IntegerNode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MaxDepthNode(int i) : IntegerNode(i) {}
|
||||||
|
};
|
||||||
|
|
||||||
class MultisampleNode : public IntegerNode
|
class MultisampleNode : public IntegerNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -51,6 +51,7 @@ intersect return INTERSECT;
|
|||||||
light return LIGHT;
|
light return LIGHT;
|
||||||
look_at return LOOKAT;
|
look_at return LOOKAT;
|
||||||
material return MATERIAL;
|
material return MATERIAL;
|
||||||
|
max_depth return MAXDEPTH;
|
||||||
multisample return MULTISAMPLE;
|
multisample return MULTISAMPLE;
|
||||||
options return OPTIONS;
|
options return OPTIONS;
|
||||||
plane return PLANE;
|
plane return PLANE;
|
||||||
|
@ -70,6 +70,7 @@ static refptr<Node> parsed_scene_node;
|
|||||||
%token LIGHT;
|
%token LIGHT;
|
||||||
%token LOOKAT;
|
%token LOOKAT;
|
||||||
%token MATERIAL;
|
%token MATERIAL;
|
||||||
|
%token MAXDEPTH;
|
||||||
%token MULTISAMPLE;
|
%token MULTISAMPLE;
|
||||||
%token OPTIONS;
|
%token OPTIONS;
|
||||||
%token PLANE;
|
%token PLANE;
|
||||||
@ -281,6 +282,9 @@ options_item: WIDTH DEC_NUMBER {
|
|||||||
| MULTISAMPLE DEC_NUMBER {
|
| MULTISAMPLE DEC_NUMBER {
|
||||||
$$ = new MultisampleNode($2->getInteger());
|
$$ = new MultisampleNode($2->getInteger());
|
||||||
}
|
}
|
||||||
|
| MAXDEPTH DEC_NUMBER {
|
||||||
|
$$ = new MaxDepthNode($2->getInteger());
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
plane: PLANE LCURLY plane_items RCURLY {
|
plane: PLANE LCURLY plane_items RCURLY {
|
||||||
|
@ -3,9 +3,10 @@ scene
|
|||||||
{
|
{
|
||||||
options
|
options
|
||||||
{
|
{
|
||||||
multisample 3
|
multisample 4
|
||||||
width 1024
|
width 1024
|
||||||
height 768
|
height 768
|
||||||
|
max_depth 15
|
||||||
}
|
}
|
||||||
|
|
||||||
camera
|
camera
|
||||||
|
Loading…
x
Reference in New Issue
Block a user