]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/track.cpp
Add utility functions to make endpoint path mask operations clearer
[r2c2.git] / source / 3d / track.cpp
index 5d31a4de93294f1c2ec46b815ad804aa09767c3b..72973f3a9b4bc03501af1777d004a275f14cc5b6 100644 (file)
@@ -1,13 +1,5 @@
-/* $Id$
-
-This file is part of R²C²
-Copyright © 2006-2011 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
 #include <cmath>
 #include <msp/gl/matrix.h>
-#include <msp/gl/misc.h>
 #include <msp/gl/renderer.h>
 #include "libr2c2/tracktype.h"
 #include "endpoint.h"
@@ -55,14 +47,14 @@ Track3D::~Track3D()
                delete *i;
 }
 
-void Track3D::get_bounds(float angle, Point &minp, Point &maxp) const
+void Track3D::get_bounds(float angle, Vector &minp, Vector &maxp) const
 {
        type.get_bounds(angle-track.get_rotation(), minp, maxp);
 
        float c = cos(-angle);
        float s = sin(-angle);
 
-       const Point &pos = track.get_position();
+       const Vector &pos = track.get_position();
        minp.x += c*pos.x-s*pos.y;
        maxp.x += c*pos.x-s*pos.y;
        minp.y += s*pos.x+c*pos.y;
@@ -77,23 +69,23 @@ void Track3D::get_bounds(float angle, Point &minp, Point &maxp) const
                minp.z += slope;
 }
 
-Point Track3D::get_node() const
+Vector Track3D::get_node() const
 {
-       const Point &pos = track.get_position();
-       Point minp;
-       Point maxp;
+       const Vector &pos = track.get_position();
+       Vector minp;
+       Vector maxp;
        type.get_bounds(0, minp, maxp);
        float rot = track.get_rotation();
        float c = cos(rot);
        float s = sin(rot);
 
-       Point center((minp.x+maxp.x)/2, (minp.y+maxp.y)/2, 0);
-       return Point(pos.x+c*center.x-s*center.y, pos.y+s*center.x+c*center.y, pos.z+0.02);
+       Vector center((minp.x+maxp.x)/2, (minp.y+maxp.y)/2, 0);
+       return Vector(pos.x+c*center.x-s*center.y, pos.y+s*center.x+c*center.y, pos.z+0.02);
 }
 
-GL::Matrix Track3D::get_matrix() const
+GL::Matrix Track3D::create_matrix() const
 {
-       const Point &pos = track.get_position();
+       const Vector &pos = track.get_position();
        float rot = track.get_rotation();
 
        GL::Matrix matrix;
@@ -106,13 +98,7 @@ GL::Matrix Track3D::get_matrix() const
 
 void Track3D::setup_render(Msp::GL::Renderer &renderer, const GL::Tag &) const
 {
-       renderer.matrix_stack() *= get_matrix();
-       glPushName(reinterpret_cast<unsigned>(this));
-}
-
-void Track3D::finish_render(Msp::GL::Renderer &, const GL::Tag &) const
-{
-       glPopName();
+       renderer.matrix_stack() *= create_matrix();
 }
 
 void Track3D::link_changed(unsigned i, Track *trk)