From: Mikko Rasa Date: Wed, 28 Jan 2015 18:47:28 +0000 (+0200) Subject: Adapt to changes in vector slicing and composing API X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b86f4adf319881697e6ecb46aaeaffe01d7b0a0a;p=r2c2.git Adapt to changes in vector slicing and composing API --- diff --git a/source/3d/layout.cpp b/source/3d/layout.cpp index f30e427..19b59ee 100644 --- a/source/3d/layout.cpp +++ b/source/3d/layout.cpp @@ -196,9 +196,9 @@ void Layout3D::tick() Transform::rotation(Angle::half_turn()-time_of_day, Vector(0, 0, 1))* Transform::rotation(axial_tilt, Vector(-1, 0, 0)); Vector sun_dir = trans.transform_linear(Vector(0, -1, 0)); - Vector diff = Vector(sun.get_position())-sun_dir; + Vector diff = sun.get_position().slice<3>(0)-sun_dir; if(diff.norm()>0.0025f) - sun.set_position(GL::Vector4(sun_dir, 0.0f)); + sun.set_position(compose(sun_dir, 0.0f)); double T = 5777; double h = 6.62606957e-34; // Planck constant diff --git a/source/3d/view.cpp b/source/3d/view.cpp index 8c35245..2050f58 100644 --- a/source/3d/view.cpp +++ b/source/3d/view.cpp @@ -60,7 +60,7 @@ Ray View3D::create_ray(float x, float y) const { const GL::Vector3 &start = camera.get_position(); GL::Vector4 ray = camera.unproject(GL::Vector4(x, y, 0, 0)); - return Ray(start, Vector(ray)); + return Ray(start, ray.slice<3>(0)); } void View3D::compute_bounds(Vector &minp, Vector &maxp) diff --git a/source/designer/designer.cpp b/source/designer/designer.cpp index 5daa16c..511c901 100644 --- a/source/designer/designer.cpp +++ b/source/designer/designer.cpp @@ -520,7 +520,7 @@ Object *Designer::pick_object(const Vector &pointer) const GL::Vector3 &cpos = view.get_camera().get_position(); GL::Vector4 cray = view.get_camera().unproject(GL::Vector4(pointer.x, pointer.y, 0, 0)); - return view.get_layout().get_layout().pick(Ray(cpos, Vector(cray))); + return view.get_layout().get_layout().pick(Ray(cpos, cray.slice<3>(0))); } void Designer::update_object_icon(Object &obj) diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index dedbf3c..fc93cf6 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -306,9 +306,9 @@ Object *Engineer::pick_object(const Vector &p) GL::Vector4 ray = main_view.get_camera().unproject(GL::Vector4(p.x, p.y, 0, 0)); // XXX Do this better; make this function a template? - if(Vehicle *veh = layout.pick(Ray(start, Vector(ray)))) + if(Vehicle *veh = layout.pick(Ray(start, ray.slice<3>(0)))) return veh; - return layout.pick(Ray(start, Vector(ray))); + return layout.pick(Ray(start, ray.slice<3>(0))); } void Engineer::emergency(Block *block, const string &msg) diff --git a/source/libr2c2/vehicleplacement.cpp b/source/libr2c2/vehicleplacement.cpp index 5bf9899..273a9cc 100644 --- a/source/libr2c2/vehicleplacement.cpp +++ b/source/libr2c2/vehicleplacement.cpp @@ -181,7 +181,7 @@ OrientedPoint VehiclePlacement::create_point(const Vector &front, const Vector & OrientedPoint result; result.position = front*(1-ratio)+back*ratio; result.rotation = Geometry::atan2(front.y-back.y, front.x-back.x); - result.tilt = Geometry::atan2(front.z-back.z, LinAl::Vector(front-back).norm()); + result.tilt = Geometry::atan2(front.z-back.z, (front-back).slice<2>(0).norm()); return result; }