Render fix: object-duplicators now give their layer setting to the
authorTon Roosendaal <ton@blender.org>
Thu, 2 Feb 2006 19:31:15 +0000 (19:31 +0000)
committerTon Roosendaal <ton@blender.org>
Thu, 2 Feb 2006 19:31:15 +0000 (19:31 +0000)
duplicates, enabling lighting and layer-render properly.

source/blender/blenkernel/BKE_anim.h
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/scene.c
source/blender/render/intern/source/convertblender.c
source/blender/src/drawview.c
source/blender/src/editobject.c

index 69fb83aac3075dcdd4f16418ab5309e06cf420d4..d139afe6c25971592174c9da713d250999f55ed2 100644 (file)
@@ -38,10 +38,12 @@ struct Path;
 struct Object;
 struct PartEff;
 struct Scene;
+struct ListBase;
 
 typedef struct DupliObject {
        struct DupliObject *next, *prev;
        struct Object *ob;
+       unsigned int origlay;
        float mat[4][4], omat[4][4];
 } DupliObject;
 
@@ -50,7 +52,8 @@ void calc_curvepath(struct Object *ob);
 int interval_test(int min, int max, int p1, int cycl);
 int where_on_path(struct Object *ob, float ctime, float *vec, float *dir);
 
-ListBase *object_duplilist(struct Scene *sce, struct Object *ob);
+struct ListBase *object_duplilist(struct Scene *sce, struct Object *ob);
+void free_object_duplilist(struct ListBase *lb);
 int count_duplilist(struct Object *ob);
 
 #endif
index 5700be0fcbc6f25e8e7b6b5c6f005457dd6fdf0f..8ff5ca1d12b6e39a8a964611d8ef6bfd4052324e 100644 (file)
@@ -277,13 +277,15 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir)        /* returns OK
 
 /* ****************** DUPLICATOR ************** */
 
-static void new_dupli_object(ListBase *lb, Object *ob, float mat[][4])
+static void new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay)
 {
        DupliObject *dob= MEM_mallocN(sizeof(DupliObject), "dupliobject");
        BLI_addtail(lb, dob);
        dob->ob= ob;
        Mat4CpyMat4(dob->mat, mat);
        Mat4CpyMat4(dob->omat, ob->obmat);
+       dob->origlay= ob->lay;
+       ob->lay= lay;
 }
 
 static void group_duplilist(ListBase *lb, Object *ob)
@@ -300,7 +302,7 @@ static void group_duplilist(ListBase *lb, Object *ob)
        for(go= ob->dup_group->gobject.first; go; go= go->next) {
                if(go->ob!=ob) {
                        Mat4MulMat4(mat, go->ob->obmat, ob->obmat);
-                       new_dupli_object(lb, go->ob, mat);
+                       new_dupli_object(lb, go->ob, mat, ob->lay);
                }
        }
 }
@@ -329,7 +331,7 @@ static void frames_duplilist(ListBase *lb, Object *ob)
                if(ok) {
                        do_ob_ipo(ob);
                        where_is_object_time(ob, (float)G.scene->r.cfra);
-                       new_dupli_object(lb, ob, ob->obmat);
+                       new_dupli_object(lb, ob, ob->obmat, ob->lay);
                }
        }
 
@@ -367,7 +369,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
                Mat4CpyMat4(tmat, obmat);
                Mat4MulMat43(obmat, tmat, mat);
        }
-       new_dupli_object(vdd->lb, vdd->ob, obmat);
+       new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay);
 }
 
 static void vertex_duplilist(ListBase *lb, Scene *sce, Object *par)
@@ -495,7 +497,7 @@ static void particle_duplilist(ListBase *lb, Scene *sce, Object *par, PartEff *p
                                                                }
                                                                
                                                                VECCOPY(ob->obmat[3], vec);
-                                                               new_dupli_object(lb, ob, ob->obmat);
+                                                               new_dupli_object(lb, ob, ob->obmat, par->lay);
                                                        }
                                                }
                                                else { // non static particles
@@ -521,7 +523,7 @@ static void particle_duplilist(ListBase *lb, Scene *sce, Object *par, PartEff *p
                                                        }
 
                                                        VECCOPY(ob->obmat[3], vec);
-                                                       new_dupli_object(lb, ob, ob->obmat);
+                                                       new_dupli_object(lb, ob, ob->obmat, par->lay);
                                                }                                       
                                        }
                                        /* temp copy, to have ipos etc to work OK */
@@ -596,7 +598,7 @@ static void font_duplilist(ListBase *lb, Object *par)
                        Mat4CpyMat4(obmat, par->obmat);
                        VECCOPY(obmat[3], vec);
                        
-                       new_dupli_object(lb, ob, obmat);
+                       new_dupli_object(lb, ob, obmat, par->lay);
                }
                
        }
@@ -638,6 +640,14 @@ ListBase *object_duplilist(Scene *sce, Object *ob)
        return &duplilist;
 }
 
+void free_object_duplilist(ListBase *lb)
+{
+       DupliObject *dob;
+       
+       for(dob= lb->first; dob; dob= dob->next)
+               dob->ob->lay= dob->origlay;
+       BLI_freelistN(lb);
+}
 
 int count_duplilist(Object *ob)
 {
index 492c1b1c2649af703bdcc739c22f6f01973f5f18..9c927c80c7e1b6ea4e58ea59cdf912affc22ba21 100644 (file)
@@ -396,7 +396,7 @@ int next_object(int val, Base **base, Object **ob)
                                                Mat4CpyMat4(dupob->ob->obmat, dupob->omat);
                                        }
                                        
-                                       BLI_freelistN(duplilist);
+                                       free_object_duplilist(duplilist);
                                        duplilist= NULL;
                                        run_again= 1;
                                }
index beac431ce9d2290a66f55b3db1497cfbdc046566..aba817212f86f83af67ff4bff1246856b26f51a5 100644 (file)
@@ -2845,7 +2845,7 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view)
                                                }
                                                Mat4CpyMat4(obd->obmat, dob->omat);
                                        }
-                                       BLI_freelistN(lb);
+                                       free_object_duplilist(lb);
                                }
                        }
                        else {
@@ -3011,7 +3011,7 @@ static void database_fromscene_vectors(Render *re, Scene *scene)
                                                }
                                                Mat4CpyMat4(obd->obmat, dob->omat);
                                        }
-                                       BLI_freelistN(lb);
+                                       free_object_duplilist(lb);
                                }
                        }
                        else {
index 5e8cc3225eecac734dcf3f40d770c5bf3d9f5802..9e2dda987286bdce187e3ceced6e7fa216c94e20 100644 (file)
@@ -2170,7 +2170,7 @@ static void draw_dupli_objects(View3D *v3d, Base *base)
        }
        /* Transp afterdraw disabled, afterdraw only stores base pointers, and duplis can be same obj */
 
-       BLI_freelistN(lb);
+       free_object_duplilist(lb);
                                
 }
 
index 1498bf15c064f8814ca7f2488e0597cd6f0a5cdc..adb4d91725f0a641bdcb44e00cfcdf7b0a617a1c 100644 (file)
@@ -3200,7 +3200,7 @@ void make_duplilist_real()
                                        apply_obmat(ob);
                                }
                                
-                               BLI_freelistN(lb);
+                               free_object_duplilist(lb);
                                
                                base->object->transflag &= ~OB_DUPLI;   
                        }