Add localize_lamp and localize_world functions as already existed for materials
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 19 May 2011 11:21:37 +0000 (11:21 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 19 May 2011 11:21:37 +0000 (11:21 +0000)
and textures, unused still.

source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_world.h
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/world.c

index 3a98f89..a6b5c04 100644 (file)
@@ -83,6 +83,7 @@ float dof_camera(struct Object *ob);
        
 void *add_lamp(const char *name);
 struct Lamp *copy_lamp(struct Lamp *la);
+struct Lamp *localize_lamp(struct Lamp *la);
 void make_local_lamp(struct Lamp *la);
 void free_camera(struct Camera *ca);
 void free_lamp(struct Lamp *la);
index 30780b8..6c8d1ba 100644 (file)
@@ -40,6 +40,7 @@ struct World;
 void free_world(struct World *sc); 
 struct World *add_world(const char *name);
 struct World *copy_world(struct World *wrld);
+struct World *localize_world(struct World *wrld);
 void make_local_world(struct World *wrld);
 
 #endif
index fd58dc2..334f018 100644 (file)
@@ -258,9 +258,8 @@ Material *localize_material(Material *ma)
        
        man->preview = NULL;
        
-       if(ma->nodetree) {
+       if(ma->nodetree)
                man->nodetree= ntreeLocalize(ma->nodetree);
-       }
        
        man->gpumaterial.first= man->gpumaterial.last= NULL;
        
index c3ea40b..bad6c62 100644 (file)
@@ -867,11 +867,32 @@ Lamp *copy_lamp(Lamp *la)
        
        lan->curfalloff = curvemapping_copy(la->curfalloff);
        
-#if 0 // XXX old animation system
-       id_us_plus((ID *)lan->ipo);
-#endif // XXX old animation system
+       if(la->preview)
+               lan->preview = BKE_previewimg_copy(la->preview);
+       
+       return lan;
+}
+
+Lamp *localize_lamp(Lamp *la)
+{
+       Lamp *lan;
+       int a;
+       
+       lan= copy_libblock(la);
+       BLI_remlink(&G.main->lamp, lan);
+
+       for(a=0; a<MAX_MTEX; a++) {
+               if(lan->mtex[a]) {
+                       lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp");
+                       memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
+                       /* free lamp decrements */
+                       id_us_plus((ID *)lan->mtex[a]->tex);
+               }
+       }
+       
+       lan->curfalloff = curvemapping_copy(la->curfalloff);
 
-       if (la->preview) lan->preview = BKE_previewimg_copy(la->preview);
+       lan->preview= NULL;
        
        return lan;
 }
index 7a76e61..8cecad9 100644 (file)
@@ -117,17 +117,36 @@ World *copy_world(World *wrld)
        
        for(a=0; a<MAX_MTEX; a++) {
                if(wrld->mtex[a]) {
-                       wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
+                       wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copy_world");
                        memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
                        id_us_plus((ID *)wrldn->mtex[a]->tex);
                }
        }
        
-       if (wrld->preview) wrldn->preview = BKE_previewimg_copy(wrld->preview);
+       if(wrld->preview)
+               wrldn->preview = BKE_previewimg_copy(wrld->preview);
 
-#if 0 // XXX old animation system
-       id_us_plus((ID *)wrldn->ipo);
-#endif // XXX old animation system
+       return wrldn;
+}
+
+World *localize_world(World *wrld)
+{
+       World *wrldn;
+       int a;
+       
+       wrldn= copy_libblock(wrld);
+       BLI_remlink(&G.main->world, wrldn);
+       
+       for(a=0; a<MAX_MTEX; a++) {
+               if(wrld->mtex[a]) {
+                       wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_world");
+                       memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
+                       /* free world decrements */
+                       id_us_plus((ID *)wrldn->mtex[a]->tex);
+               }
+       }
+
+       wrldn->preview= NULL;
        
        return wrldn;
 }