]> git.tdb.fi Git - libs/gl.git/blobdiff - source/materials/lighting.cpp
Split reflection data from Program to a separate struct
[libs/gl.git] / source / materials / lighting.cpp
index 3bbc01a3fa8e4bd4d51fd0fafc924b95651b492d..4c22ba3c01e70b01d68852f31f411799fce2f91f 100644 (file)
@@ -1,11 +1,13 @@
 #include <stdexcept>
 #include <cmath>
 #include <msp/core/algorithm.h>
+#include <msp/datafile/collection.h>
+#include <msp/fs/utils.h>
+#include <msp/strings/format.h>
 #include "error.h"
 #include "light.h"
 #include "lighting.h"
 #include "matrix.h"
-#include "misc.h"
 
 using namespace std;
 
@@ -21,12 +23,6 @@ Lighting::Lighting():
        set_fog_density(0.0f);
 }
 
-Lighting::~Lighting()
-{
-       for(vector<Light *>::iterator i=owned_data.begin(); i!=owned_data.end(); ++i)
-               delete *i;
-}
-
 void Lighting::set_ambient(const Color &a)
 {
        ambient = a;
@@ -79,7 +75,7 @@ void Lighting::attach(const Light &l)
 
 void Lighting::detach(const Light &l)
 {
-       vector<AttachedLight>::iterator i = find_member(lights, &l, &AttachedLight::light);
+       auto i = find_member(lights, &l, &AttachedLight::light);
        if(i!=lights.end())
                lights.erase(i);
 }
@@ -200,8 +196,8 @@ void Lighting::Loader::light_inline()
 {
        RefPtr<Light> lgt = new Light;
        load_sub(*lgt);
-       obj.attach(*lgt);
-       obj.owned_data.push_back(lgt.release());
+       get_collection().add(format("%s/%d.light", FS::basename(get_source()), obj.lights.size()), lgt.get());
+       obj.attach(*lgt.release());
 }
 
 void Lighting::Loader::light_inline_index(unsigned)