void PerformanceTesting::Test(
	const std::string & cardir,
	const std::string & carname,
	ContentManager & content,
	std::ostream & info_output,
	std::ostream & error_output)
{
	info_output << "Beginning car performance test on " << carname << std::endl;

	// init track
	assert(!track);
	assert(!plane);
	btVector3 planeNormal(0, 0, 1);
	btScalar planeConstant = 0;
	plane = new btStaticPlaneShape(planeNormal, planeConstant);
	plane->setUserPointer(static_cast<void*>(&surface));
	track = new btCollisionObject();
	track->setCollisionShape(plane);
	track->setActivationState(DISABLE_SIMULATION);
	track->setUserPointer(static_cast<void*>(&surface));
	world.addCollisionObject(track);

	//load the car dynamics
	std::tr1::shared_ptr<PTree> cfg;
	content.load(cfg, cardir, carname + ".car");
	if (!cfg->size())
	{
		return;
	}

	// position is the center of a 2 x 4 x 1 meter box on track surface
	btVector3 pos(0.0, -2.0, 0.5);
	btQuaternion rot = btQuaternion::getIdentity();
	const std::string tire = "";
	const bool damage = false;
	if (!car.Load(*cfg, cardir, tire, pos, rot, damage, world, content, error_output))
	{
		return;
	}

	info_output << "Car dynamics loaded" << std::endl;
	info_output << carname << " Summary:\n" <<
			"Mass (kg) including driver and fuel: " << 1 / car.GetInvMass() << "\n" <<
			"Center of mass (m): " << car.GetCenterOfMass() << std::endl;

	std::ostringstream statestream;
	joeserialize::BinaryOutputSerializer serialize_output(statestream);
	if (!car.Serialize(serialize_output))
	{
		error_output << "Serialization error" << std::endl;
	}
	//else info_output << "Car state: " << statestream.str();
	carstate = statestream.str();

	TestMaxSpeed(info_output, error_output);
	TestStoppingDistance(false, info_output, error_output);
	TestStoppingDistance(true, info_output, error_output);

	info_output << "Car performance test complete." << std::endl;
}
void PERFORMANCE_TESTING::Test(
	const std::string & carpath,
	const std::string & carname,
	const std::string & partspath,
	std::ostream & info_output,
	std::ostream & error_output)
{
	info_output << "Beginning car performance test on " << carname << std::endl;
	const std::string carfile = carpath+"/"+carname+".car";

	//load the car dynamics
	PTree cfg;
	file_open_basic fopen(carpath, partspath);
	if (!read_ini(carname+".car", fopen, cfg))
	{
		error_output << "Error loading car configuration file: " << carfile << std::endl;
		return;
	}

	btVector3 size(0, 0, 0), center(0, 0, 0), pos(0, 0, 0); // collision shape from wheel data
	btQuaternion rot = btQuaternion::getIdentity();
	bool damage = false;
	if (!car.dynamics.Load(cfg, size, center, pos, rot, damage, world, error_output))
	{
		error_output << "Error during car dynamics load: " << carfile << std::endl;
		return;
	}
	info_output << "Car dynamics loaded" << std::endl;

	info_output << carname << " Summary:\n" <<
			"Mass (kg) including driver and fuel: " << 1/car.GetInvMass() << "\n" <<
			"Center of mass (m): " << car.GetCenterOfMassPosition() << std::endl;

	std::stringstream statestream;
	joeserialize::BinaryOutputSerializer serialize_output(statestream);
	if (!car.Serialize(serialize_output))
	{
		error_output << "Serialization error" << std::endl;
	}
	//else info_output << "Car state: " << statestream.str();
	carstate = statestream.str();

	// fixme
	info_output << "Car performance test broken - exiting." << std::endl;
	return;

	TestMaxSpeed(info_output, error_output);
	TestStoppingDistance(false, info_output, error_output);
	TestStoppingDistance(true, info_output, error_output);

	info_output << "Car performance test complete." << std::endl;
}
void PERFORMANCE_TESTING::Test(
	const std::string & cardir,
	const std::string & carname,
	ContentManager & content,
	std::ostream & info_output,
	std::ostream & error_output)
{
	info_output << "Beginning car performance test on " << carname << std::endl;

	//load the car dynamics
	std::tr1::shared_ptr<PTree> cfg;
	content.load(cfg, cardir, carname + ".car");
	if (!cfg->size())
	{
		return;
	}

	btVector3 size(0, 0, 0), center(0, 0, 0), pos(0, 0, 0); // collision shape from wheel data
	btQuaternion rot = btQuaternion::getIdentity();
	bool damage = false;
	if (!car.Load(*cfg, size, center, pos, rot, damage, world, error_output))
	{
		return;
	}

	info_output << "Car dynamics loaded" << std::endl;
	info_output << carname << " Summary:\n" <<
			"Mass (kg) including driver and fuel: " << 1 / car.GetInvMass() << "\n" <<
			"Center of mass (m): " << car.GetCenterOfMass() << std::endl;

	std::stringstream statestream;
	joeserialize::BinaryOutputSerializer serialize_output(statestream);
	if (!car.Serialize(serialize_output))
	{
		error_output << "Serialization error" << std::endl;
	}
	//else info_output << "Car state: " << statestream.str();
	carstate = statestream.str();

	// fixme
	info_output << "Car performance test broken - exiting." << std::endl;
	return;

	TestMaxSpeed(info_output, error_output);
	TestStoppingDistance(false, info_output, error_output);
	TestStoppingDistance(true, info_output, error_output);

	info_output << "Car performance test complete." << std::endl;
}