Update ObjectParser for new code style...

This commit is contained in:
Eryn Wells 2014-07-20 16:55:26 -07:00
parent 5a8d634590
commit 6f844f7c2a
2 changed files with 8 additions and 9 deletions

View file

@ -11,11 +11,15 @@
#include <vector> #include <vector>
#include "material.h" #include "material.h"
#include "object.h"
#include "object_sphere.h" #include "object_sphere.h"
#include "yaml/objectParser.hh" #include "yaml/objectParser.hh"
#include "yaml/vectorParser.hh" #include "yaml/vectorParser.hh"
using namespace charles;
namespace yaml { namespace yaml {
ObjectParser::ObjectParser(Scene& scene, ObjectParser::ObjectParser(Scene& scene,
@ -80,10 +84,7 @@ ObjectParser::HandleColorEvent(yaml_event_t& event)
} }
auto onDone = [this](Color color) { auto onDone = [this](Color color) {
if (!mObject->get_material()) { mObject->GetMaterial().SetDiffuseColor(color);
mObject->set_material(new Material());
}
mObject->get_material()->set_diffuse_color(color);
mSection = NoSection; mSection = NoSection;
SetShouldExpectKey(true); SetShouldExpectKey(true);
}; };
@ -102,7 +103,7 @@ ObjectParser::HandleOriginEvent(yaml_event_t& event)
} }
auto onDone = [this](Vector3 origin) { auto onDone = [this](Vector3 origin) {
mObject->set_origin(origin); mObject->SetOrigin(origin);
mSection = NoSection; mSection = NoSection;
SetShouldExpectKey(true); SetShouldExpectKey(true);
}; };

View file

@ -9,13 +9,11 @@
#ifndef __YAML_OBJECTPARSER_HH__ #ifndef __YAML_OBJECTPARSER_HH__
#define __YAML_OBJECTPARSER_HH__ #define __YAML_OBJECTPARSER_HH__
#include "object_sphere.h"
#include "yaml/parsers.hh" #include "yaml/parsers.hh"
#include "yaml/scalarMappingParser.hh" #include "yaml/scalarMappingParser.hh"
class Sphere;
namespace yaml { namespace yaml {
struct ObjectParser struct ObjectParser
@ -40,7 +38,7 @@ private:
void HandleOriginEvent(yaml_event_t& event); void HandleOriginEvent(yaml_event_t& event);
void HandleRadiusEvent(yaml_event_t& event); void HandleRadiusEvent(yaml_event_t& event);
Sphere* mObject; charles::Sphere::Ptr mObject;
Section mSection; Section mSection;
}; };