Skip to content

Commit

Permalink
Make car body mesh optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
logzero committed Oct 25, 2016
1 parent 35a60cd commit 911186e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/cargraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,17 @@ bool CarGraphics::Load(
LoadDrawable loadDrawable(carpath, anisotropy, content, models, textures, error_output);

// load body first
bodynode = topnode.AddNode();
const PTree * cfg_body;
std::string meshname;
std::vector<std::string> texname;
if (!cfg.get("body", cfg_body, error_output)) return false;
if (!cfg_body->get("mesh", meshname, error_output)) return false;
if (!cfg_body->get("texture", texname, error_output)) return false;
if (carpaint != "default") texname[0] = carpaint;
if (!loadDrawable(meshname, texname, *cfg_body, topnode, &bodynode)) return false;
if (cfg.get("body", cfg_body, error_output) &&
cfg_body->get("mesh", meshname, error_output))
{
if (!cfg_body->get("texture", texname, error_output)) return false;
if (carpaint != "default") texname[0] = carpaint;
if (!loadDrawable(meshname, texname, *cfg_body, topnode, &bodynode)) return false;
}

// load wheels
const PTree * cfg_wheels;
Expand Down Expand Up @@ -366,7 +369,7 @@ void CarGraphics::Update(const std::vector<float> & inputs)
void CarGraphics::Update(const CarDynamics & dynamics)
{
if (!bodynode.valid()) return;
assert(dynamics.GetNumBodies() == topnode.GetNodeList().size());
assert(dynamics.GetNumBodies() <= topnode.GetNodeList().size());

unsigned i = 0;
for (auto & node : topnode.GetNodeList())
Expand Down

0 comments on commit 911186e

Please sign in to comment.