- Make dupliverts inside a dupligroup render and draw as instances.
- Possible fix for a dupli render memory leak, but i'm not sure.
This commit is contained in:
@@ -44,7 +44,7 @@ typedef struct DupliObject {
|
||||
struct DupliObject *next, *prev;
|
||||
struct Object *ob;
|
||||
unsigned int origlay;
|
||||
int index, no_draw;
|
||||
int index, no_draw, type;
|
||||
float mat[4][4], omat[4][4];
|
||||
} DupliObject;
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* returns OK
|
||||
|
||||
/* ****************** DUPLICATOR ************** */
|
||||
|
||||
static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay, int index)
|
||||
static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay, int index, int type)
|
||||
{
|
||||
DupliObject *dob= MEM_callocN(sizeof(DupliObject), "dupliobject");
|
||||
|
||||
@@ -294,6 +294,7 @@ static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], i
|
||||
Mat4CpyMat4(dob->omat, ob->obmat);
|
||||
dob->origlay= ob->lay;
|
||||
dob->index= index;
|
||||
dob->type= type;
|
||||
ob->lay= lay;
|
||||
|
||||
return dob;
|
||||
@@ -321,7 +322,7 @@ static void group_duplilist(ListBase *lb, Object *ob, int level)
|
||||
if(go->ob!=ob) {
|
||||
|
||||
Mat4MulMat4(mat, go->ob->obmat, ob->obmat);
|
||||
dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0);
|
||||
dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP);
|
||||
dob->no_draw= (dob->origlay & group->layer)==0;
|
||||
|
||||
if(go->ob->transflag & OB_DUPLI) {
|
||||
@@ -360,7 +361,7 @@ static void frames_duplilist(ListBase *lb, Object *ob, int level)
|
||||
if(ok) {
|
||||
do_ob_ipo(ob);
|
||||
where_is_object_time(ob, (float)G.scene->r.cfra);
|
||||
new_dupli_object(lb, ob, ob->obmat, ob->lay, G.scene->r.cfra);
|
||||
new_dupli_object(lb, ob, ob->obmat, ob->lay, G.scene->r.cfra, OB_DUPLIFRAMES);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +406,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, vdd->par->lay, index);
|
||||
new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS);
|
||||
|
||||
if(vdd->ob->transflag & OB_DUPLI) {
|
||||
float tmpmat[4][4];
|
||||
@@ -631,7 +632,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *par, float (*par_space_
|
||||
Mat4CpyMat4(tmat, obmat);
|
||||
Mat4MulMat43(obmat, tmat, mat);
|
||||
|
||||
new_dupli_object(lb, ob, obmat, lay, a);
|
||||
new_dupli_object(lb, ob, obmat, lay, a, OB_DUPLIFACES);
|
||||
|
||||
if(ob->transflag & OB_DUPLI) {
|
||||
float tmpmat[4][4];
|
||||
@@ -772,7 +773,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, ParticleSy
|
||||
|
||||
VECADD(tmat[3], go->ob->obmat[3], state.co);
|
||||
|
||||
new_dupli_object(lb, go->ob, tmat, par->lay, counter);
|
||||
new_dupli_object(lb, go->ob, tmat, par->lay, counter, OB_DUPLIPARTS);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -789,7 +790,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, ParticleSy
|
||||
|
||||
VECCOPY(tmat[3], state.co);
|
||||
|
||||
new_dupli_object(lb, ob, tmat, par->lay, counter);
|
||||
new_dupli_object(lb, ob, tmat, par->lay, counter, OB_DUPLIPARTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -867,7 +868,7 @@ static void font_duplilist(ListBase *lb, Object *par, int level)
|
||||
Mat4CpyMat4(obmat, par->obmat);
|
||||
VECCOPY(obmat[3], vec);
|
||||
|
||||
new_dupli_object(lb, ob, obmat, par->lay, a);
|
||||
new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIVERTS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4067,10 +4067,10 @@ static int allow_render_object(Object *ob, int nolamps, int onlyselected, Object
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int allow_render_dupli_instance(Render *re, Object *ob, Object *obd)
|
||||
static int allow_render_dupli_instance(Render *re, DupliObject *dob, Object *obd)
|
||||
{
|
||||
return (render_object_type(obd->type) &&
|
||||
(!(ob->transflag & OB_DUPLIGROUP)) &&
|
||||
(!(dob->type == OB_DUPLIGROUP)) &&
|
||||
!(re->r.mode & R_RADIO));
|
||||
}
|
||||
|
||||
@@ -4127,7 +4127,7 @@ static void database_init_objects(Render *re, unsigned int lay, int nolamps, int
|
||||
if(!allow_render_object(obd, nolamps, onlyselected, actob))
|
||||
continue;
|
||||
|
||||
if(allow_render_dupli_instance(re, ob, obd)) {
|
||||
if(allow_render_dupli_instance(re, dob, obd)) {
|
||||
ParticleSystem *psys;
|
||||
int psysindex;
|
||||
float imat[4][4], mat[4][4];
|
||||
|
||||
@@ -822,14 +822,11 @@ void free_renderdata_tables(Render *re)
|
||||
re->totinstance= 0;
|
||||
re->instancetable.first= re->instancetable.last= NULL;
|
||||
}
|
||||
else {
|
||||
BLI_freelistN(&re->instancetable);
|
||||
|
||||
if(re->objecthash) {
|
||||
BLI_ghash_free(re->objecthash, NULL, NULL);
|
||||
re->objecthash= NULL;
|
||||
}
|
||||
}
|
||||
if(re->objecthash) {
|
||||
BLI_ghash_free(re->objecthash, NULL, NULL);
|
||||
re->objecthash= NULL;
|
||||
}
|
||||
|
||||
if(re->sortedhalos) {
|
||||
MEM_freeN(re->sortedhalos);
|
||||
@@ -843,6 +840,7 @@ void free_renderdata_tables(Render *re)
|
||||
|
||||
BLI_freelistN(&re->customdata_names);
|
||||
BLI_freelistN(&re->objecttable);
|
||||
BLI_freelistN(&re->instancetable);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
@@ -2657,10 +2657,6 @@ static void draw_dupli_objects_color(View3D *v3d, Base *base, int color)
|
||||
|
||||
if (base->object->restrictflag & OB_RESTRICT_VIEW) return;
|
||||
|
||||
/* test if we can do a displist */
|
||||
if(base->object->transflag & OB_DUPLIGROUP)
|
||||
use_displist= 0;
|
||||
|
||||
tbase.flag= OB_FROMDUPLI|base->flag;
|
||||
lb= object_duplilist(G.scene, base->object);
|
||||
|
||||
@@ -2689,7 +2685,7 @@ static void draw_dupli_objects_color(View3D *v3d, Base *base, int color)
|
||||
if(use_displist == -1) {
|
||||
|
||||
/* lamp drawing messes with matrices, could be handled smarter... but this works */
|
||||
if(dob->ob->type==OB_LAMP)
|
||||
if(dob->ob->type==OB_LAMP || dob->type==OB_DUPLIGROUP)
|
||||
use_displist= 0;
|
||||
else {
|
||||
/* disable boundbox check for list creation */
|
||||
|
||||
Reference in New Issue
Block a user