From 946058fc0ab63cd582de06ee222473e4bdaa6905 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 11 May 2012 18:21:39 +0100 Subject: [PATCH] Fix build with clang --- include/IXMLParser.hpp | 14 +++++++------- include/Maths.hpp | 8 +++++++- src/SlopeTrack.cpp | 28 ++++++++++++++-------------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/include/IXMLParser.hpp b/include/IXMLParser.hpp index 6558610..f5f93fa 100644 --- a/include/IXMLParser.hpp +++ b/include/IXMLParser.hpp @@ -1,5 +1,5 @@ // -// Copyright (C) 2009 Nick Gasson +// Copyright (C) 2009, 2012 Nick Gasson // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -42,7 +42,7 @@ namespace { bool result; ss >> boolalpha >> result; // Is boolalpha affected by locale? - + if (ss.fail()) throw runtime_error( "Cannot parse Boolean attribute with value '" @@ -72,7 +72,7 @@ namespace { { return boost::lexical_cast(str); } - + } // Container for attributes @@ -98,7 +98,7 @@ public: int index = my_attrs.getIndex(xml_name); xercesc::XMLString::release(&xml_name); - + if (index != -1) { char* ascii = xercesc::XMLString::transcode( my_attrs.getValue(index)); @@ -124,7 +124,7 @@ public: { return has(name) ? get(name) : def; } - + private: const xercesc::Attributes& my_attrs; }; @@ -149,8 +149,8 @@ struct IXMLParser { }; typedef shared_ptr IXMLParserPtr; - + IXMLParserPtr make_xml_parser(const std::string& a_schema_file); - + #endif diff --git a/include/Maths.hpp b/include/Maths.hpp index 0bbf0c2..db6fa1a 100644 --- a/include/Maths.hpp +++ b/include/Maths.hpp @@ -1,5 +1,5 @@ // -// Copyright (C) 2009-2011 Nick Gasson +// Copyright (C) 2009-2012 Nick Gasson // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -251,6 +251,12 @@ void draw_normal(const Vector& a_position, const Vector& a_normal); // A 2D point in space +template +struct Point; + +template +Point make_point(T x, T y); + template struct Point { Point(T _x, T _y) : x(_x), y(_y) {} diff --git a/src/SlopeTrack.cpp b/src/SlopeTrack.cpp index 4e66d61..ecf2b93 100644 --- a/src/SlopeTrack.cpp +++ b/src/SlopeTrack.cpp @@ -51,7 +51,7 @@ public: void get_covers(vector >& output) const {}; void get_height_locked(vector >& output) const; ITrackSegmentPtr merge_exit(Point where, track::Direction dir); - + bool has_multiple_states() const { return false; } void next_state() {} void prev_state() {} @@ -64,7 +64,7 @@ private: void ensure_valid_direction(const track::Direction& dir) const; void transform(const track::TravelToken& token, float delta) const; float gradient(const track::TravelToken& token, float delta) const; - + Point origin; float height; IMeshBufferPtr rail_buf; @@ -80,7 +80,7 @@ SlopeTrack::SlopeTrack(track::Direction axis, Vector slope, const float OFF = 0.1f; assert(axis == axis::X || axis == axis::Y); - + const Vector avg_before = (slope + slope_before) / 2.0f; const Vector avg_after = (slope + slope_after) / 2.0f; @@ -95,7 +95,7 @@ SlopeTrack::SlopeTrack(track::Direction axis, Vector slope, const float x_delta1 = h_factor1; const float y_delta1 = h_factor1 * avg_after.y; - + Vector p1 = make_vector(0.0f, 0.0f, 0.0f); Vector p2 = make_vector(x_delta0, y_delta0, 0.0f); Vector p3 = make_vector(1.0f - x_delta1, slope.y - y_delta1, 0.0f); @@ -117,9 +117,9 @@ void SlopeTrack::merge(IMeshBufferPtr buf) const float y_angle = axis == axis::Y ? -90.0f : 0.0f; off += rotateY(make_vector(-0.5f, 0.0f, 0.0f), y_angle); - + buf->merge(rail_buf, off, y_angle); - + // Draw the sleepers for (float t = 0.1f; t < 1.0f; t += 0.25f) { float u_curve_value; @@ -132,9 +132,9 @@ void SlopeTrack::merge(IMeshBufferPtr buf) const rad_to_deg(atanf(deriv.y / deriv.x)); #endif - Vector t = make_vector(curve_value.x, curve_value.y, 0.0f); + Vector v = make_vector(curve_value.x, curve_value.y, 0.0f); - merge_sleeper(buf, off + rotateY(t, y_angle), y_angle); + merge_sleeper(buf, off + rotateY(v, y_angle), y_angle); } } @@ -188,7 +188,7 @@ track::TravelToken SlopeTrack::get_travel_token(track::Position pos, track::Direction dir) const { using namespace placeholders; - + ensure_valid_direction(dir); track::TravelToken tok = { @@ -204,7 +204,7 @@ track::TravelToken SlopeTrack::get_travel_token(track::Position pos, float SlopeTrack::gradient(const track::TravelToken& token, float delta) const { assert(delta < length && delta >= 0.0f); - + if (token.direction == -axis) delta = length - delta; @@ -224,7 +224,7 @@ void SlopeTrack::transform(const track::TravelToken& token, float delta) const << " f'(0.5)=" << curve.deriv(0.5f) << " f'(1.0)=" << curve.deriv(1.0f); #endif - + if (token.direction == -axis) delta = length - delta; @@ -232,11 +232,11 @@ void SlopeTrack::transform(const track::TravelToken& token, float delta) const float u_curve_delta; const Vector curve_value = curve.linear(curve_delta, &u_curve_delta); - + const float x_trans = axis == axis::X ? curve_value.x : 0.0f; const float y_trans =curve_value.y; const float z_trans = axis == axis::Y ? curve_value.x : 0.0f; - + glTranslated(static_cast(origin.x) + x_trans, height + y_trans, static_cast(origin.y) + z_trans); @@ -245,7 +245,7 @@ void SlopeTrack::transform(const track::TravelToken& token, float delta) const glRotated(-90.0, 0.0, 1.0, 0.0); glTranslated(-0.5, 0.0, 0.0); - + if (token.direction == -axis) glRotated(-180.0, 0.0, 1.0, 0.0); -- 2.39.2