]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/track.cpp
Code reformatting: add spaces around assignment operators
[r2c2.git] / source / 3d / track.cpp
index f9b03ed00220fc78659ee591730cc6f2125e0414..85050c97f597a50d0b9b56d185d574bf8735ea62 100644 (file)
@@ -27,38 +27,38 @@ Track3D::Track3D(Track &t, unsigned q):
 
 void Track3D::set_color(const Msp::GL::Color &c)
 {
-       color=c;
+       color = c;
 }
 
 void Track3D::set_quality(unsigned q)
 {
-       quality=q;
+       quality = q;
        build_object();
 }
 
 void Track3D::get_bounds(float angle, Point &minp, Point &maxp) const
 {
-       const Point &pos=track.get_position();
-       float rot=track.get_rotation();
+       const Point &pos = track.get_position();
+       float rot = track.get_rotation();
 
-       float c=cos(-angle);
-       float s=sin(-angle);
+       float c = cos(-angle);
+       float s = sin(-angle);
 
-       minp.x=maxp.x=c*pos.x-s*pos.y;
-       minp.y=maxp.y=s*pos.x+c*pos.y;
+       minp.x = maxp.x = c*pos.x-s*pos.y;
+       minp.y = maxp.y = s*pos.x+c*pos.y;
 
-       float c2=cos(rot-angle);
-       float s2=sin(rot-angle);
+       float c2 = cos(rot-angle);
+       float s2 = sin(rot-angle);
 
        for(vector<Point>::const_iterator i=border.begin(); i!=border.end(); ++i)
        {
-               float x=c*pos.x-s*pos.y + c2*i->x-s2*i->y;
-               float y=s*pos.x+c*pos.y + s2*i->x+c2*i->y;
+               float x = c*pos.x-s*pos.y + c2*i->x-s2*i->y;
+               float y = s*pos.x+c*pos.y + s2*i->x+c2*i->y;
 
-               minp.x=min(minp.x, x);
-               minp.y=min(minp.y, y);
-               maxp.x=max(maxp.x, x);
-               maxp.y=max(maxp.y, y);
+               minp.x = min(minp.x, x);
+               minp.y = min(minp.y, y);
+               maxp.x = max(maxp.x, x);
+               maxp.y = max(maxp.y, y);
        }
 }
 
@@ -85,18 +85,18 @@ void Track3D::render_endpoints() const
 {
        prepare_render();
 
-       const vector<Endpoint> &endpoints=track.get_type().get_endpoints();
+       const vector<Endpoint> &endpoints = track.get_type().get_endpoints();
        for(unsigned i=0; i<endpoints.size(); ++i)
        {
-               const Endpoint &ep=endpoints[i];
+               const Endpoint &ep = endpoints[i];
                GL::set(GL_CULL_FACE, track.get_link(i));
                if(track.get_link(i))
                        glColor4f(0.5, 0, 1, 0.5);
                else
                        glColor4f(1, 0, 0.5, 0.5);
 
-               float c=cos(ep.dir);
-               float s=sin(ep.dir);
+               float c = cos(ep.dir);
+               float s = sin(ep.dir);
 
                glBegin(GL_QUADS);
                glVertex3f(ep.pos.x-s*0.025, ep.pos.y+c*0.025, 0);
@@ -127,8 +127,8 @@ void Track3D::render_route(int route) const
 
 void Track3D::prepare_render() const
 {
-       const Point &pos=track.get_position();
-       float rot=track.get_rotation();
+       const Point &pos = track.get_position();
+       float rot = track.get_rotation();
 
        glPushMatrix();
        glTranslatef(pos.x, pos.y, pos.z);
@@ -145,8 +145,8 @@ void Track3D::build_object()
        route_seq.clear();
        route_seq.resize(track.get_type().get_n_routes());
 
-       const vector<TrackPart> &parts=track.get_type().get_parts();
-       unsigned index=0;
+       const vector<TrackPart> &parts = track.get_type().get_parts();
+       unsigned index = 0;
        for(vector<TrackPart>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
                build_part(*i, builder, index);
 }
@@ -174,26 +174,26 @@ void Track3D::build_part(const TrackPart &part, GL::VertexArrayBuilder &va_build
                profile.push_back(Point(0, -0.002, 0.012));
                profile.push_back(Point(0, 0.002, 0.012));
        }
-       static unsigned psize=profile.size();
+       static unsigned psize = profile.size();
 
-       unsigned nsegs=(part.radius ? static_cast<unsigned>(part.length*(1<<quality))+1 : 1);
-       float plen=part.length;
+       unsigned nsegs = (part.radius ? static_cast<unsigned>(part.length*(1<<quality))+1 : 1);
+       float plen = part.length;
        if(part.radius)
-               plen*=abs(part.radius);
+               plen *= abs(part.radius);
 
        for(unsigned i=0; i<=nsegs; ++i)
        {
-               float a=part.dir+(part.radius ? i*plen/nsegs/part.radius : 0);
-               float c=cos(a);
-               float s=sin(a);
-               Point p=part.get_point(i*plen/nsegs);
+               float a = part.dir+(part.radius ? i*plen/nsegs/part.radius : 0);
+               float c = cos(a);
+               float s = sin(a);
+               Point p = part.get_point(i*plen/nsegs);
 
-               for(unsigned j=0; j<profile.size(); ++j)
+               for(unsigned j=0; j<psize; ++j)
                {
-                       unsigned k=j&~1;
-                       float dy=profile[k+1].y-profile[k].y;
-                       float dz=profile[k+1].z-profile[k].z;
-                       float d=sqrt(dy*dy+dz*dz);
+                       unsigned k = j&~1;
+                       float dy = profile[k+1].y-profile[k].y;
+                       float dz = profile[k+1].z-profile[k].z;
+                       float d = sqrt(dy*dy+dz*dz);
                        va_builder.normal(s*dz/d, -c*dz/d, dy/d);
 
                        Point v(p.x+c*profile[j].x-s*profile[j].y, p.y+c*profile[j].y+s*profile[j].x, profile[j].z+i*track.get_slope()/nsegs);
@@ -225,7 +225,7 @@ void Track3D::build_part(const TrackPart &part, GL::VertexArrayBuilder &va_build
                route_seq[part.route].push_back(base_index+i*psize+19);
        }
 
-       base_index+=(nsegs+1)*psize;
+       base_index += (nsegs+1)*psize;
 }
 
 } // namespace Marklin