diff options
author | Joerg Mueller <nexyon@gmail.com> | 2010-08-07 19:45:07 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2010-08-07 19:45:07 +0400 |
commit | 64b36ffbb30ccfb13bc2346ecfd5b72e3e149c0f (patch) | |
tree | 95d2f5b12335cb4ba251f5f9c1559b503e46a22a /source/blender/blenkernel | |
parent | 0a796a465eb221ffda43aa879b4b61e058ab24c6 (diff) | |
parent | 2b3c8bdc27121e6c9103b26cffd705cee9e20b4a (diff) |
svn merge -r 31060:31144 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_curve.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 145 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 9 |
8 files changed, 121 insertions, 79 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index b9f0e6d0551..db6d995aa74 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -40,15 +40,15 @@ struct ListBase; struct BezTriple; struct BevList; -#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (((nu)->flagu & CU_NURB_CYCLIC) ? (nu->orderu-1) : 0) ) -#define KNOTSV(nu) ( (nu)->orderv+ (nu)->pntsv+ (((nu)->flagv & CU_NURB_CYCLIC) ? (nu->orderv-1) : 0) ) +#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (((nu)->flagu & CU_NURB_CYCLIC) ? ((nu)->orderu-1) : 0) ) +#define KNOTSV(nu) ( (nu)->orderv+ (nu)->pntsv+ (((nu)->flagv & CU_NURB_CYCLIC) ? ((nu)->orderv-1) : 0) ) /* Non cyclic nurbs have 1 less segment */ #define SEGMENTSU(nu) ( ((nu)->flagu & CU_NURB_CYCLIC) ? (nu)->pntsu : (nu)->pntsu-1 ) #define SEGMENTSV(nu) ( ((nu)->flagv & CU_NURB_CYCLIC) ? (nu)->pntsv : (nu)->pntsv-1 ) #define CU_DO_TILT(cu, nu) (((nu->flag & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1) -#define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || cu->bevobj || cu->ext1!=0.0 || cu->ext2!=0.0) ? 1:0) +#define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || ((cu)->flag & CU_PATH_RADIUS) || (cu)->bevobj || (cu)->ext1!=0.0 || (cu)->ext2!=0.0) ? 1:0) void unlink_curve( struct Curve *cu); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 292cd95e572..4bd4cc3792f 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -136,6 +136,7 @@ void ntreeMakeOwnType(struct bNodeTree *ntree); void ntreeUpdateType(struct bNodeTree *ntree, struct bNodeType *ntype); void ntreeFreeTree(struct bNodeTree *ntree); struct bNodeTree *ntreeCopyTree(struct bNodeTree *ntree, int internal_select); +void ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to); void ntreeMakeLocal(struct bNodeTree *ntree); void ntreeSocketUseFlags(struct bNodeTree *ntree); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index d87a49496ec..841bd635acf 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -127,7 +127,7 @@ Curve *add_curve(char *name, int type) cu= alloc_libblock(&G.main->curve, ID_CU, name); cu->size[0]= cu->size[1]= cu->size[2]= 1.0; - cu->flag= CU_FRONT|CU_BACK|CU_PATH_RADIUS; + cu->flag= CU_FRONT|CU_BACK|CU_DEFORM_BOUNDS_OFF|CU_PATH_RADIUS; cu->pathlen= 100; cu->resolu= cu->resolv= 12; cu->width= 1.0; @@ -1222,6 +1222,8 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) // XXX if( ob == obedit && ob->type == OB_FONT ) return; if(cu->bevobj) { + if (cu->bevobj->type!=OB_CURVE) return; + bevcu= cu->bevobj->data; if(bevcu->ext1==0.0 && bevcu->ext2==0.0) { ListBase bevdisp= {NULL, NULL}; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 09eac8e2d22..a44c5ace298 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1129,7 +1129,7 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) Curve *cu; DispList *dl; - if(taperobj==NULL) return 1.0; + if(taperobj==NULL || taperobj->type!=OB_CURVE) return 1.0; cu= taperobj->data; dl= cu->disp.first; @@ -1682,15 +1682,6 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba float (*deformedVerts)[3]; int numVerts; - /* Bevel and taper objects should always be curves */ - if (cu->bevobj && cu->bevobj->type != OB_CURVE) { - cu->bevobj = NULL; - } - - if (cu->taperobj && cu->taperobj->type != OB_CURVE) { - cu->taperobj = NULL; - } - nubase= BKE_curve_nurbs(cu); BLI_freelistN(&(cu->bev)); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 3dea1df2353..1eb7b5d2021 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -175,7 +175,7 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) bp= lt->def; for (i=0; i<lt->pntsu*lt->pntsv*lt->pntsw; i++,bp++) { - VECCOPY(bp->vec, vertexCos[i]); + copy_v3_v3(bp->vec, vertexCos[i]); } MEM_freeN(vertexCos); @@ -474,7 +474,9 @@ static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd, int dloc invert_m4_m4(par->imat, par->obmat); mul_v3_m4v3(cd->dloc, par->imat, ob->obmat[3]); } - else cd->dloc[0]=cd->dloc[1]=cd->dloc[2]= 0.0f; + else { + cd->dloc[0]=cd->dloc[1]=cd->dloc[2]= 0.0f; + } cd->no_rot_axis= 0; } @@ -507,15 +509,15 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir, if(ctime < 0.0) { sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec); mul_v3_fl(dvec, ctime*(float)path->len); - VECADD(vec, vec, dvec); - if(quat) QUATCOPY(quat, path->data[0].quat); + add_v3_v3(vec, dvec); + if(quat) copy_qt_qt(quat, path->data[0].quat); if(radius) *radius= path->data[0].radius; } else if(ctime > 1.0) { sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec); mul_v3_fl(dvec, (ctime-1.0)*(float)path->len); - VECADD(vec, vec, dvec); - if(quat) QUATCOPY(quat, path->data[path->len-1].quat); + add_v3_v3(vec, dvec); + if(quat) copy_qt_qt(quat, path->data[path->len-1].quat); if(radius) *radius= path->data[path->len-1].radius; /* weight - not used but could be added */ } @@ -608,7 +610,7 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather then * changing the axis before calculating the tilt but serves much the same purpose */ float dir_flat[3]={0,0,0}, q[4]; - VECCOPY(dir_flat, dir); + copy_v3_v3(dir_flat, dir); dir_flat[cd->no_rot_axis-1]= 0.0f; normalize_v3(dir); @@ -686,11 +688,11 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C mul_qt_v3(quat, cent); /* translation */ - VECADD(co, cent, loc); + add_v3_v3v3(co, cent, loc); if(quatp) - QUATCOPY(quatp, quat); - + copy_qt_qt(quatp, quat); + return 1; } return 0; @@ -711,7 +713,18 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh cu->flag |= (CU_PATH|CU_FOLLOW); // needed for path & bevlist init_curve_deform(cuOb, target, &cd, (cu->flag & CU_STRETCH)==0); - + + /* dummy bounds, keep if CU_DEFORM_BOUNDS_OFF is set */ + if(defaxis < 3) { + cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f; + cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f; + } + else { + /* negative, these bounds give a good rest position */ + cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= -1.0f; + cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 0.0f; + } + /* check whether to use vertex groups (only possible if target is a Mesh) * we want either a Mesh with no derived data, or derived data with * deformverts @@ -726,62 +739,84 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh use_vgroups = 0; if(vgroup && vgroup[0] && use_vgroups) { - bDeformGroup *curdef; Mesh *me= target->data; - int index; - - /* find the group (weak loop-in-loop) */ - for(index = 0, curdef = target->defbase.first; curdef; - curdef = curdef->next, index++) - if (!strcmp(curdef->name, vgroup)) - break; + int index= defgroup_name_index(target, vgroup); - if(curdef && (me->dvert || dm)) { + if(index != -1 && (me->dvert || dm)) { MDeformVert *dvert = me->dvert; float vec[3]; - int j; - - INIT_MINMAX(cd.dmin, cd.dmax); - - for(a = 0; a < numVerts; a++, dvert++) { - if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); + float weight; + - for(j = 0; j < dvert->totweight; j++) { - if(dvert->dw[j].def_nr == index) { + if(cu->flag & CU_DEFORM_BOUNDS_OFF) { + /* dummy bounds */ + cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f; + cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f; + + dvert = me->dvert; + for(a = 0; a < numVerts; a++, dvert++) { + if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); + weight= defvert_find_weight(dvert, index); + + if(weight > 0.0f) { mul_m4_v3(cd.curvespace, vertexCos[a]); - DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); - break; + copy_v3_v3(vec, vertexCos[a]); + calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); + interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight); + mul_m4_v3(cd.objectspace, vertexCos[a]); } } } - - dvert = me->dvert; - for(a = 0; a < numVerts; a++, dvert++) { - if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - - for(j = 0; j < dvert->totweight; j++) { - if(dvert->dw[j].def_nr == index) { - VECCOPY(vec, vertexCos[a]); + else { + /* set mesh min/max bounds */ + INIT_MINMAX(cd.dmin, cd.dmax); + + for(a = 0; a < numVerts; a++, dvert++) { + if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); + + if(defvert_find_weight(dvert, index) > 0.0f) { + mul_m4_v3(cd.curvespace, vertexCos[a]); + DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); + } + } + + dvert = me->dvert; + for(a = 0; a < numVerts; a++, dvert++) { + if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); + + weight= defvert_find_weight(dvert, index); + + if(weight > 0.0f) { + copy_v3_v3(vec, vertexCos[a]); calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); - interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, - dvert->dw[j].weight); + interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight); mul_m4_v3(cd.objectspace, vertexCos[a]); - break; } } } } - } else { - INIT_MINMAX(cd.dmin, cd.dmax); - - for(a = 0; a < numVerts; a++) { - mul_m4_v3(cd.curvespace, vertexCos[a]); - DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); + } + else { + if(cu->flag & CU_DEFORM_BOUNDS_OFF) { + for(a = 0; a < numVerts; a++) { + mul_m4_v3(cd.curvespace, vertexCos[a]); + calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL); + mul_m4_v3(cd.objectspace, vertexCos[a]); + } } - - for(a = 0; a < numVerts; a++) { - calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL); - mul_m4_v3(cd.objectspace, vertexCos[a]); + else { + /* set mesh min max bounds */ + INIT_MINMAX(cd.dmin, cd.dmax); + + for(a = 0; a < numVerts; a++) { + mul_m4_v3(cd.curvespace, vertexCos[a]); + DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); + } + + for(a = 0; a < numVerts; a++) { + calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL); + mul_m4_v3(cd.objectspace, vertexCos[a]); + } } } cu->flag = flag; @@ -803,8 +838,8 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco init_curve_deform(cuOb, target, &cd, 0); /* 0 no dloc */ cd.no_rot_axis= no_rot_axis; /* option to only rotate for XY, for example */ - VECCOPY(cd.dmin, orco); - VECCOPY(cd.dmax, orco); + copy_v3_v3(cd.dmin, orco); + copy_v3_v3(cd.dmax, orco); mul_m4_v3(cd.curvespace, vec); @@ -973,7 +1008,7 @@ float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3] vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts,"lt_vcos"); for (i=0; i<numVerts; i++) { - VECCOPY(vertexCos[i], lt->def[i].vec); + copy_v3_v3(vertexCos[i], lt->def[i].vec); } return vertexCos; @@ -985,7 +1020,7 @@ void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]) int i, numVerts = lt->pntsu*lt->pntsv*lt->pntsw; for (i=0; i<numVerts; i++) { - VECCOPY(lt->def[i].vec, vertexCos[i]); + copy_v3_v3(lt->def[i].vec, vertexCos[i]); } } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 2a4713ee25c..36c23216585 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1064,6 +1064,7 @@ bNodeTree *ntreeAddTree(int type) * - internal_select is only 1 when used for duplicating selected nodes (i.e. Shift-D duplicate operator) * - this gets called when executing compositing updates (for threaded previews) * - when the nodetree datablock needs to be copied (i.e. when users get copied) + * - for scene duplication use ntreeSwapID() after so we dont have stale pointers. */ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select) { @@ -1142,6 +1143,18 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select) return newtree; } +/* use when duplicating scenes */ +void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to) +{ + bNode *node; + /* for scene duplication only */ + for(node= ntree->nodes.first; node; node= node->next) { + if(node->id==id_from) { + node->id= id_to; + } + } +} + /* *************** preview *********** */ /* if node->preview, then we assume the rect to exist */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0f540bfa525..c08a3408505 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1627,10 +1627,7 @@ float bsystem_time(struct Scene *scene, Object *ob, float cfra, float ofs) void object_scale_to_mat3(Object *ob, float mat[][3]) { float vec[3]; - - vec[0]= ob->size[0]+ob->dsize[0]; - vec[1]= ob->size[1]+ob->dsize[1]; - vec[2]= ob->size[2]+ob->dsize[2]; + add_v3_v3v3(vec, ob->size, ob->dsize); size_to_mat3( mat,vec); } @@ -1688,7 +1685,7 @@ void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat) void object_apply_mat4(Object *ob, float mat[][4]) { float mat3[3][3]; - VECCOPY(ob->loc, mat[3]); + copy_v3_v3(ob->loc, mat[3]); mat4_to_size(ob->size, mat); copy_m3_m4(mat3, mat); object_mat3_to_rot(ob, mat3, 0); @@ -1796,7 +1793,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) copy_m4_m4(mat, rmat); } - VECCOPY(mat[3], vec); + copy_v3_v3(mat[3], vec); } } @@ -1823,7 +1820,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) copy_m4_m4(mat, pchan->pose_mat); /* but for backwards compatibility, the child has to move to the tail */ - VECCOPY(vec, mat[1]); + copy_v3_v3(vec, mat[1]); mul_v3_fl(vec, pchan->bone->length); add_v3_v3(mat[3], vec); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 0f44c02d16d..95705ea8c05 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -172,9 +172,12 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) BLI_duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces)); BLI_duplicatelist(&(scen->r.layers), &(sce->r.layers)); BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); - - scen->nodetree= ntreeCopyTree(sce->nodetree, 0); - + + if(sce->nodetree) { + scen->nodetree= ntreeCopyTree(sce->nodetree, 0); + ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); + } + obase= sce->base.first; base= scen->base.first; while(base) { |