From 58d6e51cb5ab1fd54c3bdda6e5fe071bbc356fc6 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 14 Feb 2007 13:52:30 +0000 Subject: Bugfix, email report. Copying texture space from Mesh to Curve crashed. Bad code. cleaned up. --- source/blender/makesdna/DNA_curve_types.h | 1 + source/blender/makesdna/DNA_mesh_types.h | 1 + source/blender/makesdna/DNA_meta_types.h | 2 +- source/blender/src/editobject.c | 65 ++++++++++++++++++++----------- 4 files changed, 46 insertions(+), 23 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 626e7cf4167..9280dc2d4fa 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -147,6 +147,7 @@ typedef struct Curve { ListBase bev; + /* texture space, copied as one block in editobject.c */ float loc[3]; float size[3]; float rot[3]; diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index fae7c851343..5f2a77b8349 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -80,6 +80,7 @@ typedef struct Mesh { int totvert, totedge, totface, totselect, pad2; int texflag; + /* texture space, copied as one block in editobject.c */ float loc[3]; float size[3]; float rot[3]; diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h index 4a190fef433..c96681e2223 100644 --- a/source/blender/makesdna/DNA_meta_types.h +++ b/source/blender/makesdna/DNA_meta_types.h @@ -76,7 +76,7 @@ typedef struct MetaBall { short flag, totcol; int texflag; /* used to store MB_AUTOSPACE */ - /* These temporary values are only used for polygonization */ + /* texture space, copied as one block in editobject.c */ float loc[3]; float size[3]; float rot[3]; diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 3b4fe480a82..836518964b8 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -2985,14 +2985,54 @@ static void copymenu_modifiers(Object *ob) BIF_undo_push("Copy modifiers"); } +/* both pointers should exist */ +static void copy_texture_space(Object *to, Object *ob) +{ + float *poin1= NULL, *poin2= NULL; + int texflag= 0; + + if(ob->type==OB_MESH) { + texflag= ((Mesh *)ob->data)->texflag; + poin2= ((Mesh *)ob->data)->loc; + } + else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { + texflag= ((Curve *)ob->data)->texflag; + poin2= ((Curve *)ob->data)->loc; + } + else if(ob->type==OB_MBALL) { + texflag= ((MetaBall *)ob->data)->texflag; + poin2= ((MetaBall *)ob->data)->loc; + } + else + return; + + if(to->type==OB_MESH) { + ((Mesh *)ob->data)->texflag= texflag; + poin2= ((Mesh *)to->data)->loc; + } + else if (ELEM3(to->type, OB_CURVE, OB_SURF, OB_FONT)) { + ((Curve *)ob->data)->texflag= texflag; + poin2= ((Curve *)to->data)->loc; + } + else if(to->type==OB_MBALL) { + ((MetaBall *)ob->data)->texflag= texflag; + poin2= ((MetaBall *)to->data)->loc; + } + + memcpy(poin1, poin2, 9*sizeof(float)); /* this was noted in DNA_mesh, curve, mball */ + + if(to->type==OB_MESH) ; + else if(to->type==OB_MBALL) tex_space_mball(to); + else tex_space_curve(to->data); + +} void copy_attr(short event) { - Object *ob, *obt; + Object *ob; Base *base; Curve *cu, *cu1; Nurb *nu; - void *poin1, *poin2=0; int do_scene_sort= 0; if(G.scene->id.lib) return; @@ -3003,13 +3043,6 @@ void copy_attr(short event) /* obedit_copymenu(); */ return; } - - if ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL) { - if(ob->type==OB_MESH) poin2= &(((Mesh *)ob->data)->texflag); - else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) poin2= &(((Curve *)ob->data)->texflag); - else if(ob->type==OB_MBALL) poin2= &(((MetaBall *)ob->data)->texflag); - } - if(event==9) { copymenu_properties(ob); return; @@ -3073,19 +3106,7 @@ void copy_attr(short event) base->object->rdamping= ob->rdamping; } else if(event==17) { /* tex space */ - obt= base->object; - poin1= 0; - if(obt->type==OB_MESH) poin1= &(((Mesh *)obt->data)->texflag); - else if ELEM3(obt->type, OB_CURVE, OB_SURF, OB_FONT) poin1= &(((Curve *)obt->data)->texflag); - else if(obt->type==OB_MBALL) poin1= &(((MetaBall *)obt->data)->texflag); - - if(poin1) { - memcpy(poin1, poin2, 4+12+12+12); - - if(obt->type==OB_MESH) ; - else if(obt->type==OB_MBALL) tex_space_mball(obt); - else tex_space_curve(obt->data); - } + copy_texture_space(base->object, ob); } else if(event==18) { /* font settings */ -- cgit v1.2.3