]> git.tdb.fi Git - libs/gl.git/blobdiff - source/shadowmap.cpp
Use libmspmath to provide vector and matrix operations
[libs/gl.git] / source / shadowmap.cpp
index c4dd07b03dbdb288fa55bda158dc305386813d70..d380257d83fc6910b4bab5a181b765ebfd41ebc4 100644 (file)
@@ -80,15 +80,10 @@ void ShadowMap::setup_frame() const
        {
                /* XXX Not really proper way to support positional lights, but good
                enough when the light source is far away */
-               lpos.x -= target.x;
-               lpos.y -= target.y;
-               lpos.z -= target.z;
+               lpos -= Vector4(target.x, target.y, target.z, 1.0f);
        }
 
-       float l = sqrt(lpos.x*lpos.x+lpos.y*lpos.y+lpos.z*lpos.z);
-       lpos.x /= l;
-       lpos.y /= l;
-       lpos.z /= l;
+       lpos.normalize();
 
        float matrix[16];
        if(abs(lpos.z)>=abs(lpos.x) && abs(lpos.z)>=abs(lpos.y))