X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Flighting.cpp;h=239bdc19d0d03fdb9d0bcfaf58902d4c12abf4f6;hb=8dbd6316d277d2f9cbf85e7e61f2541421e01292;hp=2ba1edc5560e00889ecd31fa01592f121a68a993;hpb=70663ae97d5b70a6b468e07dd7e73475a175dc9b;p=libs%2Fgl.git diff --git a/source/lighting.cpp b/source/lighting.cpp index 2ba1edc5..239bdc19 100644 --- a/source/lighting.cpp +++ b/source/lighting.cpp @@ -1,4 +1,6 @@ #include +#include +#include "error.h" #include "light.h" #include "lighting.h" #include "lightunit.h" @@ -38,9 +40,6 @@ void Lighting::set_horizon_angle(const Geometry::Angle &a) void Lighting::attach(unsigned i, const Light &l) { - if(i>=LightUnit::get_n_units()) - throw out_of_range("Lighting::attach"); - if(i>=lights.size()) lights.resize(i+1); @@ -63,7 +62,7 @@ void Lighting::update_shader_data(ProgramData &shdata, const Matrix &view_matrix { shdata.uniform("ambient_color", ambient); shdata.uniform("sky_color", sky_color); - shdata.uniform("eye_sky_dir", Vector3(view_matrix*Vector4(sky_direction, 0.0f))); + shdata.uniform("eye_sky_dir", view_matrix.block<3, 3>(0, 0)*sky_direction); shdata.uniform("horizon_limit", horizon_angle.radians()); for(unsigned i=0; iLightUnit::get_n_units()) + throw invalid_operation("Lighting::bind"); + if(!set_current(this)) return;