X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fvector.h;fp=source%2Fvector.h;h=25ebac1180c8fc1cc5dc531f0616e3eefe915589;hp=d1693af101ab04c5806038b247264302704e5295;hb=705986ebcdd24573791aa58c7a8f2b7549c918a3;hpb=aceaa08be594ac708efcd0b68e5d08547cbcbbe1 diff --git a/source/vector.h b/source/vector.h index d1693af1..25ebac11 100644 --- a/source/vector.h +++ b/source/vector.h @@ -11,12 +11,15 @@ Distributed under the LGPL namespace Msp { namespace GL { +struct Vector4; + struct Vector3 { float x, y, z; Vector3(): x(0), y(0), z(0) { } Vector3(float x_, float y_, float z_): x(x_), y(y_), z(z_) { } + Vector3(const Vector4 &); }; struct Vector4 @@ -29,6 +32,10 @@ struct Vector4 Vector4(const Vector3 &v): x(v.x), y(v.y), z(v.z), w(1) { } }; +inline Vector3::Vector3(const Vector4 &v): + x(v.x/v.w), y(v.y/v.w), z(v.z/v.w) +{ } + } // namespace GL } // namespace Msp