diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-02-26 19:20:36 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-02-26 19:20:36 +0300 |
commit | 995262728f0550b6ff12028a160bc1d37e50d546 (patch) | |
tree | 26712de57ea75da12a81683d601f490a1bce05e2 | |
parent | f9fb9965aae0e2312329c04517f438718fd6a006 (diff) |
Fix for bug #6854: meta object crash with preview render. Meta objects
were using an ugly trick to store render orco's, but there's really no
reason for it, now it works like other primitives.
-rw-r--r-- | source/blender/blenkernel/BKE_mball.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mball.c | 16 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 19 |
3 files changed, 21 insertions, 18 deletions
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 269e7150768..038331747db 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -165,8 +165,8 @@ void free_mball(struct MetaBall *mb); struct MetaBall *add_mball(char *name); struct MetaBall *copy_mball(struct MetaBall *mb); void make_local_mball(struct MetaBall *mb); -void tex_space_mball( struct Object *ob); -void make_orco_mball( struct Object *ob); +void tex_space_mball(struct Object *ob); +float *make_orco_mball(struct Object *ob); struct Object *find_basis_mball( struct Object *ob); int is_basis_mball(struct Object *ob); void metaball_polygonize(struct Object *ob); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index e731f0fdfe0..d3fb9ceac7a 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -233,13 +233,15 @@ void tex_space_mball(Object *ob) boundbox_set_from_min_max(bb, min, max); } -void make_orco_mball(Object *ob) +float *make_orco_mball(Object *ob) { BoundBox *bb; DispList *dl; - float *data; + float *data, *orco, *orcodata; float loc[3], size[3]; int a; + + orcodata= MEM_mallocN(sizeof(float)*3*dl->nr, "MballOrco"); /* restore size and loc */ bb= ob->bb; @@ -252,14 +254,18 @@ void make_orco_mball(Object *ob) dl= ob->disp.first; data= dl->verts; + orco= orcodata; a= dl->nr; while(a--) { - data[0]= (data[0]-loc[0])/size[0]; - data[1]= (data[1]-loc[1])/size[1]; - data[2]= (data[2]-loc[2])/size[2]; + orco[0]= (data[0]-loc[0])/size[0]; + orco[1]= (data[1]-loc[1])/size[1]; + orco[2]= (data[2]-loc[2])/size[2]; data+= 3; + orco+= 3; } + + return orcodata; } /** \brief Test, if Object *ob is basic MetaBall. * diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 55a1dd664b2..448167ca35e 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -930,6 +930,8 @@ static float *get_object_orco(Render *re, Object *ob) orco = make_orco_curve(ob); } else if (ob->type==OB_SURF) { orco = make_orco_surf(ob); + } else if (ob->type==OB_MBALL) { + orco = make_orco_mball(ob); } if (orco) @@ -2346,7 +2348,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) VertRen *ver; VlakRen *vlr, *vlr1; Material *ma; - float *data, *nors, mat[4][4], imat[3][3], xn, yn, zn; + float *data, *nors, *orco, mat[4][4], imat[3][3], xn, yn, zn; int a, need_orco, *index; if (ob!=find_basis_mball(ob)) @@ -2369,8 +2371,9 @@ static void init_render_mball(Render *re, ObjectRen *obr) data= dl->verts; nors= dl->nors; + orco= get_object_orco(re, ob); - for(a=0; a<dl->nr; a++, data+=3, nors+=3) { + for(a=0; a<dl->nr; a++, data+=3, nors+=3, orco+=3) { ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, data); @@ -2388,7 +2391,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) Normalize(ver->n); //if(ob->transflag & OB_NEG_SCALE) VecMulf(ver->n. -1.0); - if(need_orco) ver->orco= data; + if(need_orco) ver->orco= orco; } index= dl->index; @@ -2422,14 +2425,8 @@ static void init_render_mball(Render *re, ObjectRen *obr) } } - if(need_orco) { - /* store displist and scale */ - make_orco_mball(ob); - } - else { - /* enforce display lists remade */ - freedisplist(&ob->disp); - } + /* enforce display lists remade */ + freedisplist(&ob->disp); /* this enforces remake for real, orco displist is small (in scale) */ ob->recalc |= OB_RECALC_DATA; |