From bd7ed4f077d3ff86c1043642b5d228a95d9334a6 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 29 Mar 2010 05:37:34 +0000 Subject: Fix [#21708] Copy/Paste Texture channels for Lamps/World not working --- source/blender/blenkernel/intern/material.c | 67 ----------------------------- 1 file changed, 67 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e877abea7cf..3b17ac1db1a 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1345,70 +1345,3 @@ void paste_matcopybuf(Material *ma) scrarea_queue_winredraw(curarea); */ } - - -static short mtexcopied=0; /* must be reset on file load */ -static MTex mtexcopybuf; - -void clear_mat_mtex_copybuf(void) -{ /* use for file reload */ - mtexcopied= 0; -} - -void copy_mat_mtex_copybuf(ID *id) -{ - MTex **mtex= NULL; - - switch(GS(id->name)) { - case ID_MA: - mtex= &(((Material *)id)->mtex[(int)((Material *)id)->texact]); - break; - case ID_LA: - // la->mtex[(int)la->texact] // TODO - break; - case ID_WO: - // mtex= wrld->mtex[(int)wrld->texact]; // TODO - break; - } - - if(mtex && *mtex) { - memcpy(&mtexcopybuf, *mtex, sizeof(MTex)); - mtexcopied= 1; - } - else { - mtexcopied= 0; - } -} - -void paste_mat_mtex_copybuf(ID *id) -{ - MTex **mtex= NULL; - - if(mtexcopied == 0 || mtexcopybuf.tex==NULL) - return; - - switch(GS(id->name)) { - case ID_MA: - mtex= &(((Material *)id)->mtex[(int)((Material *)id)->texact]); - break; - case ID_LA: - // la->mtex[(int)la->texact] // TODO - break; - case ID_WO: - // mtex= wrld->mtex[(int)wrld->texact]; // TODO - break; - } - - if(mtex) { - if(*mtex==NULL) { - *mtex= MEM_mallocN(sizeof(MTex), "mtex copy"); - } - else if((*mtex)->tex) { - (*mtex)->tex->id.us--; - } - - memcpy(*mtex, &mtexcopybuf, sizeof(MTex)); - - id_us_plus((ID *)mtexcopybuf.tex); - } -} -- cgit v1.2.3 From bdea39c809c606cb19641757db8bf0efe67ce11c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 30 Mar 2010 09:57:58 +0000 Subject: Fix #21827: Outer portions of extruded 2D curves do not render correctly DispList->rt is used by render stuff to set vlak flags. This rt field is setting to nurbs's flags in displist creation function. Possible flags for nurbs are CU_SMOOTH and CU_2D. CU_SMOOTH is ok, but CU_2D conflicts with R_NOPUNOFLIP. I cleared rt's CU_2D flag. Don't forget about possible conflicts if new nurbs flags will be added. --- source/blender/blenkernel/intern/displist.c | 57 ++++++++++++++++++----------- 1 file changed, 35 insertions(+), 22 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 487ecb810d4..29ee8aeab45 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1580,21 +1580,24 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, if(forRender || nu->hide==0) { if(nu->pntsv==1) { len= SEGMENTSU(nu)*nu->resolu; - + dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); - + BLI_addtail(dispbase, dl); dl->parts= 1; dl->nr= len; dl->col= nu->mat_nr; dl->charidx= nu->charidx; - dl->rt= nu->flag; - + + /* dl->rt will be used as flag for render face and */ + /* CU_2D conflicts with R_NOPUNOFLIP */ + dl->rt= nu->flag & ~CU_2D; + data= dl->verts; if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; else dl->type= DL_SEGM; - + makeNurbcurve(nu, data, NULL, NULL, nu->resolu, 3*sizeof(float)); } else { @@ -1606,11 +1609,14 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, dl->col= nu->mat_nr; dl->charidx= nu->charidx; - dl->rt= nu->flag; - + + /* dl->rt will be used as flag for render face and */ + /* CU_2D conflicts with R_NOPUNOFLIP */ + dl->rt= nu->flag & ~CU_2D; + data= dl->verts; dl->type= DL_SURF; - + dl->parts= (nu->pntsu*nu->resolu); /* in reverse, because makeNurbfaces works that way */ dl->nr= (nu->pntsv*nu->resolv); if(nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */ @@ -1683,26 +1689,29 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba float *fp1, *data; BevPoint *bevp; int a,b; - + if (bl->nr) { /* blank bevel lists can happen */ - + /* exception handling; curve without bevel or extrude, with width correction */ if(dlbev.first==NULL) { dl= MEM_callocN(sizeof(DispList), "makeDispListbev"); dl->verts= MEM_callocN(3*sizeof(float)*bl->nr, "dlverts"); BLI_addtail(dispbase, dl); - + if(bl->poly!= -1) dl->type= DL_POLY; else dl->type= DL_SEGM; - + if(dl->type==DL_SEGM) dl->flag = (DL_FRONT_CURVE|DL_BACK_CURVE); - + dl->parts= 1; dl->nr= bl->nr; dl->col= nu->mat_nr; dl->charidx= nu->charidx; - dl->rt= nu->flag; - + + /* dl->rt will be used as flag for render face and */ + /* CU_2D conflicts with R_NOPUNOFLIP */ + dl->rt= nu->flag & ~CU_2D; + a= dl->nr; bevp= (BevPoint *)(bl+1); data= dl->verts; @@ -1716,10 +1725,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } else { DispList *dlb; - + for (dlb=dlbev.first; dlb; dlb=dlb->next) { - /* for each part of the bevel use a separate displblock */ + /* for each part of the bevel use a separate displblock */ dl= MEM_callocN(sizeof(DispList), "makeDispListbev1"); dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts"); BLI_addtail(dispbase, dl); @@ -1734,11 +1743,15 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba dl->nr= dlb->nr; dl->col= nu->mat_nr; dl->charidx= nu->charidx; - dl->rt= nu->flag; + + /* dl->rt will be used as flag for render face and */ + /* CU_2D conflicts with R_NOPUNOFLIP */ + dl->rt= nu->flag & ~CU_2D; + dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "col2"); bevp= (BevPoint *)(bl+1); - /* for each point of poly make a bevel piece */ + /* for each point of poly make a bevel piece */ bevp= (BevPoint *)(bl+1); for(a=0; anr; a++,bevp++) { float fac=1.0; @@ -1748,7 +1761,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } else { fac = calc_taper(scene, cu->taperobj, a, bl->nr); } - + if (bevp->split_tag) { dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F); } @@ -1762,9 +1775,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba vec[0]= fp1[1]+widfac; vec[1]= fp1[2]; vec[2]= 0.0; - + mul_qt_v3(bevp->quat, vec); - + data[0]= bevp->vec[0] + fac*vec[0]; data[1]= bevp->vec[1] + fac*vec[1]; data[2]= bevp->vec[2] + fac*vec[2]; -- cgit v1.2.3 From 052cb2afd22b9f54fdb1528066e6e3cba6db6e99 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 30 Mar 2010 11:49:07 +0000 Subject: Rest shape key for cloth option, this makes it possible to specify different spring lengths. Implementation is quite ugly because the shape key has to be pulled through the modifier stack somehow, need a more flexible data mask system to solve this properly. (commits 27773,27775,27778 by Brecht from render25 branch) --- source/blender/blenkernel/BKE_cloth.h | 2 + source/blender/blenkernel/intern/DerivedMesh.c | 166 +++++++++++++++++-------- source/blender/blenkernel/intern/cloth.c | 40 ++++-- source/blender/blenkernel/intern/customdata.c | 5 +- source/blender/blenkernel/intern/modifier.c | 8 +- 5 files changed, 156 insertions(+), 65 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index a8a0d7daa89..d8b3fcfd0bb 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -126,6 +126,7 @@ typedef struct ClothVertex float mass; /* mass / weight of the vertex */ float goal; /* goal, from SB */ float impulse[3]; /* used in collision.c */ + float *xrest; /* temporary valid for building springs */ unsigned int impulse_count; /* same as above */ float avg_spring_len; /* average length of connected springs */ float struct_stiff; @@ -240,6 +241,7 @@ void cloth_init ( ClothModifierData *clmd ); DerivedMesh *clothModifier_do ( ClothModifierData *clmd, struct Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc ); void cloth_update_normals ( ClothVertex *verts, int nVerts, MFace *face, int totface ); +int cloth_uses_vgroup(ClothModifierData *clmd); // needed for collision.c void bvhtree_update_from_cloth ( ClothModifierData *clmd, int moving ); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 9d15ac3f348..f4e3a60803e 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_cloth_types.h" #include "DNA_key_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" @@ -49,6 +50,7 @@ #include "BKE_cdderivedmesh.h" #include "BKE_displist.h" +#include "BKE_key.h" #include "BKE_modifier.h" #include "BKE_mesh.h" #include "BKE_object.h" @@ -1450,55 +1452,88 @@ static float *get_editmesh_orco_verts(EditMesh *em) /* orco custom data layer */ -static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, EditMesh *em) +static void *get_orco_coords_dm(Object *ob, EditMesh *em, int layer, int *free) +{ + *free= 0; + + if(layer == CD_ORCO) { + /* get original coordinates */ + *free= 1; + + if(em) + return (float(*)[3])get_editmesh_orco_verts(em); + else + return (float(*)[3])get_mesh_orco_verts(ob); + } + else if(layer == CD_CLOTH_ORCO) { + /* apply shape key for cloth, this should really be solved + by a more flexible customdata system, but not simple */ + if(!em) { + ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); + KeyBlock *kb= key_get_keyblock(ob_get_key(ob), clmd->sim_parms->shapekey_rest); + + if(kb->data) + return kb->data; + } + + return NULL; + } + + return NULL; +} + +static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, EditMesh *em, int layer) { DerivedMesh *dm; float (*orco)[3]; + int free; - if(em) { - dm= CDDM_from_editmesh(em, me); - orco= (float(*)[3])get_editmesh_orco_verts(em); - } - else { - dm= CDDM_from_mesh(me, ob); - orco= (float(*)[3])get_mesh_orco_verts(ob); + if(em) dm= CDDM_from_editmesh(em, me); + else dm= CDDM_from_mesh(me, ob); + + orco= get_orco_coords_dm(ob, em, layer, &free); + + if(orco) { + CDDM_apply_vert_coords(dm, orco); + if(free) MEM_freeN(orco); } - CDDM_apply_vert_coords(dm, orco); CDDM_calc_normals(dm); - MEM_freeN(orco); return dm; } -static void add_orco_dm(Object *ob, EditMesh *em, DerivedMesh *dm, DerivedMesh *orcodm) +static void add_orco_dm(Object *ob, EditMesh *em, DerivedMesh *dm, DerivedMesh *orcodm, int layer) { float (*orco)[3], (*layerorco)[3]; - int totvert; + int totvert, free; totvert= dm->getNumVerts(dm); if(orcodm) { orco= MEM_callocN(sizeof(float)*3*totvert, "dm orco"); + free= 1; if(orcodm->getNumVerts(orcodm) == totvert) orcodm->getVertCos(orcodm, orco); else dm->getVertCos(dm, orco); } - else { - if(em) orco= (float(*)[3])get_editmesh_orco_verts(em); - else orco= (float(*)[3])get_mesh_orco_verts(ob); - } + else + orco= get_orco_coords_dm(ob, em, layer, &free); - transform_mesh_orco_verts(ob->data, orco, totvert, 0); + if(orco) { + if(layer == CD_ORCO) + transform_mesh_orco_verts(ob->data, orco, totvert, 0); + + if(!(layerorco = DM_get_vert_data_layer(dm, layer))) { + DM_add_vert_layer(dm, layer, CD_CALLOC, NULL); + layerorco = DM_get_vert_data_layer(dm, layer); + } - if((layerorco = DM_get_vert_data_layer(dm, CD_ORCO))) { - memcpy(layerorco, orco, sizeof(float)*totvert); - MEM_freeN(orco); + memcpy(layerorco, orco, sizeof(float)*3*totvert); + if(free) MEM_freeN(orco); } - else - DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco); } /* weight paint colors */ @@ -1604,9 +1639,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos Mesh *me = ob->data; ModifierData *firstmd, *md; LinkNode *datamasks, *curr; - CustomDataMask mask; + CustomDataMask mask, nextmask; float (*deformedVerts)[3] = NULL; - DerivedMesh *dm, *orcodm, *finaldm; + DerivedMesh *dm, *orcodm, *clothorcodm, *finaldm; int numVerts = me->totvert; int required_mode; @@ -1679,6 +1714,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos */ dm = NULL; orcodm = NULL; + clothorcodm = NULL; for(;md; md = md->next, curr = curr->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -1695,11 +1731,13 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue; /* add an orco layer if needed by this modifier */ - if(dm && mti->requiredDataMask) { + if(mti->requiredDataMask) mask = mti->requiredDataMask(ob, md); - if(mask & CD_MASK_ORCO) - add_orco_dm(ob, NULL, dm, orcodm); - } + else + mask = 0; + + if(dm && (mask & CD_MASK_ORCO)) + add_orco_dm(ob, NULL, dm, orcodm, CD_ORCO); /* How to apply modifier depends on (a) what we already have as * a result of previous modifiers (could be a DerivedMesh or just @@ -1766,26 +1804,20 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } } - /* create an orco derivedmesh in parallel */ - mask= (CustomDataMask)GET_INT_FROM_POINTER(curr->link); - if(mask & CD_MASK_ORCO) { - if(!orcodm) - orcodm= create_orco_dm(ob, me, NULL); - - mask &= ~CD_MASK_ORCO; - DM_set_only_copy(orcodm, mask); - ndm = mti->applyModifier(md, ob, orcodm, useRenderParams, 0); - - if(ndm) { - /* if the modifier returned a new dm, release the old one */ - if(orcodm && orcodm != ndm) orcodm->release(orcodm); - orcodm = ndm; - } - } - + /* determine which data layers are needed by following modifiers */ + if(curr->next) + nextmask= (CustomDataMask)GET_INT_FROM_POINTER(curr->next->link); + else + nextmask= dataMask; + /* set the DerivedMesh to only copy needed data */ + mask= (CustomDataMask)GET_INT_FROM_POINTER(curr->link); DM_set_only_copy(dm, mask); + /* add cloth rest shape key if need */ + if(mask & CD_MASK_CLOTH_ORCO) + add_orco_dm(ob, NULL, dm, clothorcodm, CD_CLOTH_ORCO); + /* add an origspace layer if needed */ if(((CustomDataMask)GET_INT_FROM_POINTER(curr->link)) & CD_MASK_ORIGSPACE) if(!CustomData_has_layer(&dm->faceData, CD_ORIGSPACE)) @@ -1806,6 +1838,38 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos deformedVerts = NULL; } } + + /* create an orco derivedmesh in parallel */ + if(nextmask & CD_MASK_ORCO) { + if(!orcodm) + orcodm= create_orco_dm(ob, me, NULL, CD_ORCO); + + nextmask &= ~CD_MASK_ORCO; + DM_set_only_copy(orcodm, nextmask); + ndm = mti->applyModifier(md, ob, orcodm, useRenderParams, 0); + + if(ndm) { + /* if the modifier returned a new dm, release the old one */ + if(orcodm && orcodm != ndm) orcodm->release(orcodm); + orcodm = ndm; + } + } + + /* create cloth orco derivedmesh in parallel */ + if(nextmask & CD_MASK_CLOTH_ORCO) { + if(!clothorcodm) + clothorcodm= create_orco_dm(ob, me, NULL, CD_CLOTH_ORCO); + + nextmask &= ~CD_MASK_CLOTH_ORCO; + DM_set_only_copy(clothorcodm, nextmask); + ndm = mti->applyModifier(md, ob, clothorcodm, useRenderParams, 0); + + if(ndm) { + /* if the modifier returned a new dm, release the old one */ + if(clothorcodm && clothorcodm != ndm) clothorcodm->release(clothorcodm); + clothorcodm = ndm; + } + } } /* grab modifiers until index i */ @@ -1846,16 +1910,18 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos /* add an orco layer if needed */ if(dataMask & CD_MASK_ORCO) { - add_orco_dm(ob, NULL, finaldm, orcodm); + add_orco_dm(ob, NULL, finaldm, orcodm, CD_ORCO); if(deform_r && *deform_r) - add_orco_dm(ob, NULL, *deform_r, NULL); + add_orco_dm(ob, NULL, *deform_r, NULL, CD_ORCO); } *final_r = finaldm; if(orcodm) orcodm->release(orcodm); + if(clothorcodm) + clothorcodm->release(clothorcodm); if(deformedVerts && deformedVerts != inputVertexCos) MEM_freeN(deformedVerts); @@ -1930,7 +1996,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri if(dm && mti->requiredDataMask) { mask = mti->requiredDataMask(ob, md); if(mask & CD_MASK_ORCO) - add_orco_dm(ob, em, dm, orcodm); + add_orco_dm(ob, em, dm, orcodm, CD_ORCO); } /* How to apply modifier depends on (a) what we already have as @@ -1987,7 +2053,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri mask= (CustomDataMask)GET_INT_FROM_POINTER(curr->link); if(mask & CD_MASK_ORCO) { if(!orcodm) - orcodm= create_orco_dm(ob, ob->data, em); + orcodm= create_orco_dm(ob, ob->data, em, CD_ORCO); mask &= ~CD_MASK_ORCO; DM_set_only_copy(orcodm, mask); @@ -2060,7 +2126,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri /* add an orco layer if needed */ if(dataMask & CD_MASK_ORCO) - add_orco_dm(ob, em, *final_r, orcodm); + add_orco_dm(ob, em, *final_r, orcodm, CD_ORCO); if(orcodm) orcodm->release(orcodm); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 33fe6212cd2..2b11c4bdfa0 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -721,6 +721,15 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh * } +int cloth_uses_vgroup(ClothModifierData *clmd) +{ + return (((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) || + (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) && + ((clmd->sim_parms->vgroup_mass>0) || + (clmd->sim_parms->vgroup_struct>0)|| + (clmd->sim_parms->vgroup_bend>0))); +} + /** * cloth_apply_vgroup - applies a vertex group as specified by type * @@ -744,11 +753,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) verts = clothObj->verts; - if (((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) || - (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) && - ((clmd->sim_parms->vgroup_mass>0) || - (clmd->sim_parms->vgroup_struct>0)|| - (clmd->sim_parms->vgroup_bend>0))) + if (cloth_uses_vgroup(clmd)) { for ( i = 0; i < numverts; i++, verts++ ) { @@ -805,6 +810,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d int i = 0; MVert *mvert = NULL; ClothVertex *verts = NULL; + float (*shapekey_rest)[3]= NULL; float tnull[3] = {0,0,0}; Cloth *cloth = NULL; float maxdist = 0; @@ -842,7 +848,11 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d clmd->clothObject->springs = NULL; clmd->clothObject->numsprings = -1; + if( clmd->sim_parms->shapekey_rest ) + shapekey_rest = dm->getVertDataArray ( dm, CD_CLOTH_ORCO ); + mvert = dm->getVertArray ( dm ); + verts = clmd->clothObject->verts; // set initial values @@ -850,8 +860,16 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d { if(first) { - VECCOPY ( verts->x, mvert[i].co ); + copy_v3_v3( verts->x, mvert[i].co ); + mul_m4_v3( ob->obmat, verts->x ); + + if( shapekey_rest ) { + verts->xrest= shapekey_rest[i]; + mul_m4_v3( ob->obmat, verts->xrest ); + } + else + verts->xrest = verts->x; } /* no GUI interface yet */ @@ -1070,7 +1088,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) { spring->ij = MIN2(medge[i].v1, medge[i].v2); spring->kl = MAX2(medge[i].v2, medge[i].v1); - VECSUB ( temp, cloth->verts[spring->kl].x, cloth->verts[spring->ij].x ); + VECSUB ( temp, cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest ); spring->restlen = sqrt ( INPR ( temp, temp ) ); clmd->sim_parms->avg_spring_len += spring->restlen; cloth->verts[spring->ij].avg_spring_len += spring->restlen; @@ -1116,7 +1134,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) spring->ij = MIN2(mface[i].v1, mface[i].v3); spring->kl = MAX2(mface[i].v3, mface[i].v1); - VECSUB ( temp, cloth->verts[spring->kl].x, cloth->verts[spring->ij].x ); + VECSUB ( temp, cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest ); spring->restlen = sqrt ( INPR ( temp, temp ) ); spring->type = CLOTH_SPRING_TYPE_SHEAR; spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0; @@ -1139,7 +1157,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) spring->ij = MIN2(mface[i].v2, mface[i].v4); spring->kl = MAX2(mface[i].v4, mface[i].v2); - VECSUB ( temp, cloth->verts[spring->kl].x, cloth->verts[spring->ij].x ); + VECSUB ( temp, cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest ); spring->restlen = sqrt ( INPR ( temp, temp ) ); spring->type = CLOTH_SPRING_TYPE_SHEAR; spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0; @@ -1181,7 +1199,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) spring->ij = MIN2(tspring2->ij, index2); spring->kl = MAX2(tspring2->ij, index2); - VECSUB ( temp, cloth->verts[spring->kl].x, cloth->verts[spring->ij].x ); + VECSUB ( temp, cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest ); spring->restlen = sqrt ( INPR ( temp, temp ) ); spring->type = CLOTH_SPRING_TYPE_BENDING; spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0; @@ -1221,7 +1239,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) spring->ij = tspring2->ij; spring->kl = tspring->kl; - VECSUB ( temp, cloth->verts[spring->kl].x, cloth->verts[spring->ij].x ); + VECSUB ( temp, cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest ); spring->restlen = sqrt ( INPR ( temp, temp ) ); spring->type = CLOTH_SPRING_TYPE_BENDING; spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index a755170aae6..447c1e2f035 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -794,13 +794,14 @@ const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerSwap_mcol, layerDefault_mcol}, {sizeof(MCol)*4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol, layerSwap_mcol, layerDefault_mcol}, + {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL} }; const char *LAYERTYPENAMES[CD_NUMTYPES] = { "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace", "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags","CDMFloatProperty", "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco", "CDMTexPoly", "CDMLoopUV", - "CDMloopCol", "CDTangent", "CDMDisps", "CDWeightMCol"}; + "CDMloopCol", "CDTangent", "CDMDisps", "CDWeightMCol", "CDClothOrco"}; const CustomDataMask CD_MASK_BAREMESH = CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE; @@ -813,7 +814,7 @@ const CustomDataMask CD_MASK_EDITMESH = CD_MASK_MCOL|CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS; const CustomDataMask CD_MASK_DERIVEDMESH = CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | - CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | + CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_CLOTH_ORCO | CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORCO | CD_MASK_TANGENT | CD_MASK_WEIGHT_MCOL; const CustomDataMask CD_MASK_BMESH = CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 96877a9ae9e..7dc6babba38 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -6978,9 +6978,13 @@ static void clothModifier_updateDepgraph( static CustomDataMask clothModifier_requiredDataMask(Object *ob, ModifierData *md) { CustomDataMask dataMask = 0; + ClothModifierData *clmd = (ClothModifierData*)md; - /* ask for vertexgroups if we need them */ - dataMask |= (1 << CD_MDEFORMVERT); + if(cloth_uses_vgroup(clmd)) + dataMask |= (1 << CD_MDEFORMVERT); + + if(clmd->sim_parms->shapekey_rest != 0) + dataMask |= (1 << CD_CLOTH_ORCO); return dataMask; } -- cgit v1.2.3 From 253de0ed86f273d0032acbbd0b8237a358b35cbd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 30 Mar 2010 12:01:17 +0000 Subject: * Assign weight from bones in weight paint mode now respects paint face mask, also avoid making vertex groups if they will not be filled. * Add back image pin option in image editor header. * Fix deep shadow not respecting Cast Buffer Shadows option. * Tangent space normal map baking should work again now. * Fix a problem with particle duplis, due to own bugfix for #20350, the problem for that seems to be in dupliverts, not particles. * Fix external multires data link getting lost on exiting editmode. (commits 27776,27777,27830,27840,27841,27862 by Brecht from render25 branch) --- source/blender/blenkernel/intern/anim.c | 10 +++------- source/blender/blenkernel/intern/customdata.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 1465f4550f5..e26072deb76 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1073,7 +1073,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p ParticleCacheKey *cache; float ctime, pa_time, scale = 1.0f; float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size=0.0; - float (*obmat)[4], (*oldobmat)[4], recurs_mat[4][4]; + float (*obmat)[4], (*oldobmat)[4]; int lay, a, b, counter, hair = 0; int totpart, totchild, totgroup=0, pa_num; @@ -1090,10 +1090,6 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if(!psys_check_enabled(par, psys)) return; - /* particles are already in world space, don't want the object mat twice */ - if(par_space_mat) - mul_m4_m4m4(recurs_mat, psys->imat, par_space_mat); - ctime = bsystem_time(scene, par, (float)scene->r.cfra, 0.0); totpart = psys->totpart; @@ -1237,7 +1233,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p mul_m4_m4m4(tmat, oblist[b]->obmat, pamat); mul_mat3_m4_fl(tmat, size*scale); if(par_space_mat) - mul_m4_m4m4(mat, tmat, recurs_mat); + mul_m4_m4m4(mat, tmat, par_space_mat); else copy_m4_m4(mat, tmat); @@ -1263,7 +1259,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p VECADD(tmat[3], tmat[3], vec); if(par_space_mat) - mul_m4_m4m4(mat, tmat, recurs_mat); + mul_m4_m4m4(mat, tmat, par_space_mat); else copy_m4_m4(mat, tmat); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 447c1e2f035..0afb9a450dd 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -848,7 +848,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, { const LayerTypeInfo *typeInfo; CustomDataLayer *layer, *newlayer; - int i, type, number = 0, lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0; + int i, type, number = 0, lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0, lastflag = 0; for(i = 0; i < source->totlayer; ++i) { layer = &source->layers[i]; @@ -863,15 +863,16 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, lastclone = layer->active_clone; lastmask = layer->active_mask; lasttype = type; + lastflag = layer->flag; } else number++; - if(layer->flag & CD_FLAG_NOCOPY) continue; + if(lastflag & CD_FLAG_NOCOPY) continue; else if(!((int)mask & (int)(1 << (int)type))) continue; else if(number < CustomData_number_of_layers(dest, type)) continue; - if((alloctype == CD_ASSIGN) && (layer->flag & CD_FLAG_NOFREE)) + if((alloctype == CD_ASSIGN) && (lastflag & CD_FLAG_NOFREE)) newlayer = customData_add_layer__internal(dest, type, CD_REFERENCE, layer->data, totelem, layer->name); else @@ -883,6 +884,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, newlayer->active_rnd = lastrender; newlayer->active_clone = lastclone; newlayer->active_mask = lastmask; + newlayer->flag |= lastflag & (CD_FLAG_EXTERNAL|CD_FLAG_IN_MEMORY); } } } @@ -892,6 +894,9 @@ void CustomData_copy(const struct CustomData *source, struct CustomData *dest, { memset(dest, 0, sizeof(*dest)); + if(source->external) + dest->external= MEM_dupallocN(source->external); + CustomData_merge(source, dest, mask, alloctype, totelem); } -- cgit v1.2.3 From 71446eea573db3ac6bac5f297c0655acbeada67c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 30 Mar 2010 12:15:16 +0000 Subject: * Multiply for panorama cameras * Some cases of struct name being set where it shouldnt have been. * Spelling: wich --> which * Copy and initialize uv modifier scale, remove unneeded enum. * Ability to pin any object into the context. * Update uv window while transforming (useful when used with UVProject modifier) * Patch by Wahooney, so new template's are internal text and dont get saved over by mistake. * Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186 Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process /usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted by Jochen Schmitt. * [#21816] bpy.data.add_image has stopped working on Windows. moved to bpy.data.images.load(), missed this call. (commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch) --- source/blender/blenkernel/BKE_library.h | 2 +- source/blender/blenkernel/intern/library.c | 14 +++++++------- source/blender/blenkernel/intern/modifier.c | 23 ++++++++++++++++++++++- 3 files changed, 30 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 454666566dc..cb61a08f3ba 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -53,7 +53,7 @@ int id_unlink(struct ID *id, int test); int new_id(struct ListBase *lb, struct ID *id, const char *name); -struct ListBase *wich_libbase(struct Main *mainlib, short type); +struct ListBase *which_libbase(struct Main *mainlib, short type); #define MAX_LIBARRAY 40 int set_listbasepointers(struct Main *main, struct ListBase **lb); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index bea641d2140..0eaafcb67ed 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -347,7 +347,7 @@ int id_unlink(ID *id, int test) if(id->us == 0) { if(test) return 1; - lb= wich_libbase(mainlib, GS(id->name)); + lb= which_libbase(mainlib, GS(id->name)); free_libblock(lb, id); return 1; @@ -356,7 +356,7 @@ int id_unlink(ID *id, int test) return 0; } -ListBase *wich_libbase(Main *mainlib, short type) +ListBase *which_libbase(Main *mainlib, short type) { switch( type ) { case ID_SCE: @@ -658,7 +658,7 @@ void *copy_libblock(void *rt) id= rt; - lb= wich_libbase(G.main, GS(id->name)); + lb= which_libbase(G.main, GS(id->name)); idn= alloc_libblock(lb, GS(id->name), id->name+2); if(idn==NULL) { @@ -867,7 +867,7 @@ void free_main(Main *mainvar) ID *find_id(char *type, char *name) /* type: "OB" or "MA" etc */ { - ListBase *lb= wich_libbase(G.main, GS(type)); + ListBase *lb= which_libbase(G.main, GS(type)); return BLI_findstring(lb, name, offsetof(ID, name) + 2); } @@ -1175,7 +1175,7 @@ int new_id(ListBase *lb, ID *id, const char *tname) if(id->lib) return 0; /* if no libdata given, look up based on ID */ - if(lb==NULL) lb= wich_libbase(G.main, GS(id->name)); + if(lb==NULL) lb= which_libbase(G.main, GS(id->name)); /* if no name given, use name of current ID * else make a copy (tname args can be const) */ @@ -1348,7 +1348,7 @@ void test_idbutton(char *name) ID *idtest; - lb= wich_libbase(G.main, GS(name-2) ); + lb= which_libbase(G.main, GS(name-2) ); if(lb==0) return; /* search for id */ @@ -1383,7 +1383,7 @@ void rename_id(ID *id, char *name) ListBase *lb; strncpy(id->name+2, name, 21); - lb= wich_libbase(G.main, GS(id->name) ); + lb= which_libbase(G.main, GS(id->name) ); new_id(lb, id, name); } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 7dc6babba38..3777c920be5 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -3606,6 +3606,7 @@ static void uvprojectModifier_initData(ModifierData *md) umd->flags = 0; umd->num_projectors = 1; umd->aspectx = umd->aspecty = 1.0f; + umd->scalex = umd->scaley = 1.0f; } static void uvprojectModifier_copyData(ModifierData *md, ModifierData *target) @@ -3621,6 +3622,8 @@ static void uvprojectModifier_copyData(ModifierData *md, ModifierData *target) tumd->num_projectors = umd->num_projectors; tumd->aspectx = umd->aspectx; tumd->aspecty = umd->aspecty; + tumd->scalex = umd->scalex; + tumd->scaley = umd->scaley; } static CustomDataMask uvprojectModifier_requiredDataMask(Object *ob, ModifierData *md) @@ -3692,6 +3695,8 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, char uvname[32]; float aspx= umd->aspectx ? umd->aspectx : 1.0f; float aspy= umd->aspecty ? umd->aspecty : 1.0f; + float scax= umd->scalex ? umd->scalex : 1.0f; + float scay= umd->scaley ? umd->scaley : 1.0f; int free_uci= 0; aspect = aspx / aspy; @@ -3829,6 +3834,22 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, project_from_camera(tface->uv[2], coords[mf->v3], projectors[0].uci); if(mf->v3) project_from_camera(tface->uv[3], coords[mf->v4], projectors[0].uci); + + if(scax != 1.0f) { + tface->uv[0][0] = ((tface->uv[0][0] - 0.5f) * scax) + 0.5f; + tface->uv[1][0] = ((tface->uv[1][0] - 0.5f) * scax) + 0.5f; + tface->uv[2][0] = ((tface->uv[2][0] - 0.5f) * scax) + 0.5f; + if(mf->v3) + tface->uv[3][0] = ((tface->uv[3][0] - 0.5f) * scax) + 0.5f; + } + + if(scay != 1.0f) { + tface->uv[0][1] = ((tface->uv[0][1] - 0.5f) * scay) + 0.5f; + tface->uv[1][1] = ((tface->uv[1][1] - 0.5f) * scay) + 0.5f; + tface->uv[2][1] = ((tface->uv[2][1] - 0.5f) * scay) + 0.5f; + if(mf->v3) + tface->uv[3][1] = ((tface->uv[3][1] - 0.5f) * scay) + 0.5f; + } } else { /* apply transformed coords as UVs */ @@ -6489,7 +6510,7 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, ed_loop_flip= 1; } else { - /* not so simple to work out wich edge is higher */ + /* not so simple to work out which edge is higher */ sub_v3_v3v3(tmp_vec1, tmpf1, vc_tmp->co); sub_v3_v3v3(tmp_vec1, tmpf2, vc_tmp->co); normalize_v3(tmp_vec1); -- cgit v1.2.3 From 515592438f0f5665cadbd12c7698554bd2b89146 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 30 Mar 2010 12:23:13 +0000 Subject: Baking for dupligroup & linked library objects - library data allows pointcache writing (hard to know how this should work long term so ifdef'd for now) - changing the frame now updates the dupligroup objects - BKE_ptcache_ids_from_object(), option to get the id's from duplis note! scene_update_tagged() is called from the main() loop, and runs BKE_ptcache_quick_cache_all(), this could become a performance issue, especially with duplis, should probably not call BKE_ptcache_quick_cache_all() all the time, even when not playing back animation. (commits 27856 by Campbell from render25 branch) --- source/blender/blenkernel/BKE_pointcache.h | 2 +- source/blender/blenkernel/intern/pointcache.c | 36 ++++++++++++++++++++++----- source/blender/blenkernel/intern/scene.c | 27 +++++++++++++++----- 3 files changed, 52 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 55f11e1066b..170965a223a 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -236,7 +236,7 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothMo void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd); void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd); -void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob); +void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis); /***************** Global funcs ****************************/ void BKE_ptcache_remove(void); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index cbe294f1347..8efa9e29698 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -48,6 +48,7 @@ #include "WM_api.h" +#include "BKE_anim.h" #include "BKE_blender.h" #include "BKE_cloth.h" #include "BKE_depsgraph.h" @@ -90,6 +91,9 @@ #define PTCACHE_DATA_FROM(data, type, from) if(data[type]) { memcpy(data[type], from, ptcache_data_size[type]); } #define PTCACHE_DATA_TO(data, type, index, to) if(data[type]) { memcpy(to, (char*)data[type] + (index ? index * ptcache_data_size[type] : 0), ptcache_data_size[type]); } +/* could be made into a pointcache option */ +#define DURIAN_POINTCACHE_LIB_OK 1 + int ptcache_data_size[] = { sizeof(int), // BPHYS_DATA_INDEX 3 * sizeof(float), // BPHYS_DATA_LOCATION: @@ -982,7 +986,7 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl pid->info_types= 0; } -void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob) +void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int duplis) { PTCacheID *pid; ParticleSystem *psys; @@ -1024,6 +1028,23 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob) } } } + + if(scene && (duplis-- > 0) && (ob->transflag & OB_DUPLI)) { + ListBase *lb_dupli_ob; + + if((lb_dupli_ob=object_duplilist(scene, ob))) { + DupliObject *dob; + for(dob= lb_dupli_ob->first; dob; dob= dob->next) { + ListBase lb_dupli_pid; + BKE_ptcache_ids_from_object(&lb_dupli_pid, dob->ob, scene, duplis); + addlisttolist(lb, &lb_dupli_pid); + if(lb_dupli_pid.first) + printf("Adding Dupli\n"); + } + + free_object_duplilist(lb_dupli_ob); /* does restore */ + } + } } @@ -1132,10 +1153,11 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) FILE *fp = NULL; char filename[(FILE_MAXDIR+FILE_MAXFILE)*2]; +#ifndef DURIAN_POINTCACHE_LIB_OK /* don't allow writing for linked objects */ if(pid->ob->id.lib && mode == PTCACHE_FILE_WRITE) return NULL; - +#endif if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL)==0) return NULL; /* save blend file before using disk pointcache */ BKE_ptcache_id_filename(pid, filename, cfra, 1, 1); @@ -1873,9 +1895,11 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) if(!pid->cache || pid->cache->flag & PTCACHE_BAKED) return; +#ifndef DURIAN_POINTCACHE_LIB_OK /* don't allow clearing for linked objects */ if(pid->ob->id.lib) return; +#endif /*if (!G.relbase_valid) return; *//* save blend file before using pointcache */ @@ -2310,7 +2334,7 @@ static int count_quick_cache(Scene *scene, int *quick_step) for(base = scene->base.first; base; base = base->next) { if(base->object) { - BKE_ptcache_ids_from_object(&pidlist, base->object); + BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); for(pid=pidlist.first; pid; pid=pid->next) { if((pid->cache->flag & PTCACHE_BAKED) @@ -2408,7 +2432,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) /* get all pids from the object and search for smoke low res */ ListBase pidlist2; PTCacheID *pid2; - BKE_ptcache_ids_from_object(&pidlist2, pid->ob); + BKE_ptcache_ids_from_object(&pidlist2, pid->ob, scene, MAX_DUPLI_RECUR); for(pid2=pidlist2.first; pid2; pid2=pid2->next) { if(pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) { @@ -2443,7 +2467,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) } else for(base=scene->base.first; base; base= base->next) { /* cache/bake everything in the scene */ - BKE_ptcache_ids_from_object(&pidlist, base->object); + BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); for(pid=pidlist.first; pid; pid=pid->next) { cache = pid->cache; @@ -2525,7 +2549,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) } } else for(base=scene->base.first; base; base= base->next) { - BKE_ptcache_ids_from_object(&pidlist, base->object); + BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); for(pid=pidlist.first; pid; pid=pid->next) { /* skip hair particles */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index dd2a3143d3d..51b18800474 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -891,15 +891,18 @@ float frame_to_float (Scene *scene, int cfra) /* see also bsystem_time in objec return ctime; } -static void scene_update_newframe(Scene *sce, unsigned int lay) +static void scene_update_newframe(Scene *scene, unsigned int lay) { Base *base; Object *ob; - for(base= sce->base.first; base; base= base->next) { + for(base= scene->base.first; base; base= base->next) { ob= base->object; - object_handle_update(sce, ob); // bke_object.h + object_handle_update(scene, ob); // bke_object.h + + if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) + group_handle_recalc_and_update(scene, ob, ob->dup_group); /* only update layer when an ipo */ // XXX old animation system @@ -914,6 +917,7 @@ void scene_update_tagged(Scene *scene) { Scene *sce; Base *base; + Object *ob; float ctime = frame_to_float(scene, scene->r.cfra); /* update all objects: drivers, matrices, displists, etc. flags set @@ -922,12 +926,23 @@ void scene_update_tagged(Scene *scene) /* sets first, we allow per definition current scene to have dependencies on sets, but not the other way around. */ if(scene->set) { - for(SETLOOPER(scene->set, base)) - object_handle_update(scene, base->object); + for(SETLOOPER(scene->set, base)) { + ob= base->object; + + object_handle_update(scene, ob); + + if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) + group_handle_recalc_and_update(scene, ob, ob->dup_group); + } } for(base= scene->base.first; base; base= base->next) { - object_handle_update(scene, base->object); + ob= base->object; + + object_handle_update(scene, ob); + + if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) + group_handle_recalc_and_update(scene, ob, ob->dup_group); } /* recalc scene animation data here (for sequencer) */ -- cgit v1.2.3 From d0f8d9f38cfffaa5117930f7724bddf3d4c68d72 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 30 Mar 2010 14:33:05 +0000 Subject: Fixed segmentation fault when non-curve object is setting as a taper Deny user to select non-curve objects for taper and bevel lists, also added some checking into displist and curve modules - object could be converted from curve to mesh (would be better to unset bevel/taper object in this case -- will try to implement a bit later). --- source/blender/blenkernel/intern/curve.c | 72 ++++++++++++++--------------- source/blender/blenkernel/intern/displist.c | 6 ++- 2 files changed, 39 insertions(+), 39 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 9087a7ec4f2..a95714e71d2 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1227,49 +1227,47 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) /* if a font object is being edited, then do nothing */ // XXX if( ob == obedit && ob->type == OB_FONT ) return; - if(cu->bevobj && cu->bevobj!=ob) { - if(cu->bevobj->type==OB_CURVE) { - bevcu= cu->bevobj->data; - if(bevcu->ext1==0.0 && bevcu->ext2==0.0) { - ListBase bevdisp= {NULL, NULL}; - facx= cu->bevobj->size[0]; - facy= cu->bevobj->size[1]; - - if (forRender) { - makeDispListCurveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0); - dl= bevdisp.first; - } else { + if(cu->bevobj && cu->bevobj!=ob && cu->bevobj->type==OB_CURVE) { + bevcu= cu->bevobj->data; + if(bevcu->ext1==0.0 && bevcu->ext2==0.0) { + ListBase bevdisp= {NULL, NULL}; + facx= cu->bevobj->size[0]; + facy= cu->bevobj->size[1]; + + if (forRender) { + makeDispListCurveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0); + dl= bevdisp.first; + } else { + dl= bevcu->disp.first; + if(dl==0) { + makeDispListCurveTypes(scene, cu->bevobj, 0); dl= bevcu->disp.first; - if(dl==0) { - makeDispListCurveTypes(scene, cu->bevobj, 0); - dl= bevcu->disp.first; - } } + } - while(dl) { - if ELEM(dl->type, DL_POLY, DL_SEGM) { - dlnew= MEM_mallocN(sizeof(DispList), "makebevelcurve1"); - *dlnew= *dl; - dlnew->verts= MEM_mallocN(3*sizeof(float)*dl->parts*dl->nr, "makebevelcurve1"); - memcpy(dlnew->verts, dl->verts, 3*sizeof(float)*dl->parts*dl->nr); - - if(dlnew->type==DL_SEGM) dlnew->flag |= (DL_FRONT_CURVE|DL_BACK_CURVE); - - BLI_addtail(disp, dlnew); - fp= dlnew->verts; - nr= dlnew->parts*dlnew->nr; - while(nr--) { - fp[2]= fp[1]*facy; - fp[1]= -fp[0]*facx; - fp[0]= 0.0; - fp+= 3; - } + while(dl) { + if ELEM(dl->type, DL_POLY, DL_SEGM) { + dlnew= MEM_mallocN(sizeof(DispList), "makebevelcurve1"); + *dlnew= *dl; + dlnew->verts= MEM_mallocN(3*sizeof(float)*dl->parts*dl->nr, "makebevelcurve1"); + memcpy(dlnew->verts, dl->verts, 3*sizeof(float)*dl->parts*dl->nr); + + if(dlnew->type==DL_SEGM) dlnew->flag |= (DL_FRONT_CURVE|DL_BACK_CURVE); + + BLI_addtail(disp, dlnew); + fp= dlnew->verts; + nr= dlnew->parts*dlnew->nr; + while(nr--) { + fp[2]= fp[1]*facy; + fp[1]= -fp[0]*facx; + fp[0]= 0.0; + fp+= 3; } - dl= dl->next; } - - freedisplist(&bevdisp); + dl= dl->next; } + + freedisplist(&bevdisp); } } else if(cu->ext1==0.0 && cu->ext2==0.0) { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 29ee8aeab45..4defa0e53a1 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1755,8 +1755,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba bevp= (BevPoint *)(bl+1); for(a=0; anr; a++,bevp++) { float fac=1.0; - if (cu->taperobj==NULL) { - if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) + if (cu->taperobj==NULL || + cu->taperobj->type != OB_CURVE || cu->taperobj == ob) { + if ( (cu->bevobj!=NULL && cu->bevobj->type == OB_CURVE) || + !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) fac = bevp->radius; } else { fac = calc_taper(scene, cu->taperobj, a, bl->nr); -- cgit v1.2.3 From 0d19b4167c7369cdf760a9d94298cbd08afdb558 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 30 Mar 2010 18:10:05 +0000 Subject: - Call DAG_id_flush_update for each object in convert operator if keep_original option is switched off. This fixes trouble when user converts curve which is set as taper/bevel object to mesh (scene kept unchanged until object recalculation). - Moved checking of taper/bevel objects type to RNA property update handlers. - Added resetting taper/bevel object in do_makeDispListCurveTypes it this objects aren't curves. --- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/displist.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index a95714e71d2..c87495d499e 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1227,7 +1227,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) /* if a font object is being edited, then do nothing */ // XXX if( ob == obedit && ob->type == OB_FONT ) return; - if(cu->bevobj && cu->bevobj!=ob && cu->bevobj->type==OB_CURVE) { + if(cu->bevobj) { 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 4defa0e53a1..c65fac7d474 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1657,6 +1657,15 @@ 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; + } + if(cu->editnurb) nubase= cu->editnurb; else @@ -1755,10 +1764,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba bevp= (BevPoint *)(bl+1); for(a=0; anr; a++,bevp++) { float fac=1.0; - if (cu->taperobj==NULL || - cu->taperobj->type != OB_CURVE || cu->taperobj == ob) { - if ( (cu->bevobj!=NULL && cu->bevobj->type == OB_CURVE) || - !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) + if (cu->taperobj==NULL) { + if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) fac = bevp->radius; } else { fac = calc_taper(scene, cu->taperobj, a, bl->nr); -- cgit v1.2.3 From 5f070227acf6e92bc584230dcac5a6708b4a5dca Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Mar 2010 22:43:43 +0000 Subject: trick to give correct normals for cyclic curves used with the screw modifier. --- source/blender/blenkernel/intern/mesh.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 543895a5973..a8afa779dba 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -629,6 +629,12 @@ static void make_edges_mdata(MVert *allvert, MFace *allface, int totvert, int to medge->v2= ed->v2; if(old==0 || ed->is_draw) medge->flag= ME_EDGEDRAW|ME_EDGERENDER; if(ed->is_loose) medge->flag|= ME_LOOSEEDGE; + + /* order is swapped so extruding this edge as a surface wont flip face normals + * with cyclic curves */ + if(ed->v1+1 != ed->v2) { + SWAP(int, medge->v1, medge->v2); + } medge++; } else { -- cgit v1.2.3 From c9f81c87b88574fa803050040a6b8ddf398968aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Mar 2010 23:16:42 +0000 Subject: bugfix [#21743] Incorrect Rim Normals with Screw mod and Solidify Mod on a Curve Object --- source/blender/blenkernel/intern/modifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 3777c920be5..acab22abde4 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5779,7 +5779,8 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, #define ADD_EDGE_USER(_v1, _v2, edge_ord) \ eidx= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edgehash, _v1, _v2)); \ if(edge_users[eidx] == INVALID_UNUSED) { \ - edge_users[eidx]= (_v1 < _v2) ? i:(i+numFaces); \ + ed= orig_medge + eidx; \ + edge_users[eidx]= (_v1 < _v2) == (ed->v1 < ed->v2) ? i:(i+numFaces); \ edge_order[eidx]= edge_ord; \ } else { \ edge_users[eidx]= INVALID_PAIR; \ -- cgit v1.2.3 From 8616d22dc33d63d22a2d7e779a38f8953c0917ef Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 31 Mar 2010 05:44:21 +0000 Subject: Fix [#21727] texture in compositor quickly results in crash Hopefully this is correct - looks like the CompBuf->node pointer was getting left out of the per-thread copying/localisation. --- source/blender/blenkernel/intern/node.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 5bd9694e768..9ff7f1f2982 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2573,6 +2573,8 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) for(sock= node->outputs.first; sock; sock= sock->next) { sock->new_sock->ns.data= sock->ns.data; + compbuf_set_node(sock->new_sock->ns.data, node->new_node); + sock->ns.data= NULL; sock->new_sock->new_sock= sock; } -- cgit v1.2.3 From 2910d75f2c68f79054e47348925f13b127ada9d6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 31 Mar 2010 07:22:18 +0000 Subject: svn merge https://svn.blender.org/svnroot/bf-blender/branches/render25 -r27875:27895 --- source/blender/blenkernel/intern/library.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 0eaafcb67ed..8605cf51b68 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1236,11 +1236,17 @@ static void image_fix_relative_path(Image *ima) #define LIBTAG(a) if(a && a->id.lib) {a->id.flag &=~LIB_INDIRECT; a->id.flag |= LIB_EXTERN;} -static void lib_indirect_test_id(ID *id) +static void lib_indirect_test_id(ID *id, Library *lib) { - if(id->lib) + if(id->lib) { + /* datablocks that were indirectly related are now direct links + * without this, appending data that has a link to other data will fail to write */ + if(lib && id->lib->parent == lib) { + id_lib_extern(id); + } return; + } if(GS(id->name)==ID_OB) { Object *ob= (Object *)id; @@ -1336,7 +1342,7 @@ void all_local(Library *lib, int untagged_only) a= set_listbasepointers(G.main, lbarray); while(a--) { for(id= lbarray[a]->first; id; id=id->next) - lib_indirect_test_id(id); + lib_indirect_test_id(id, lib); } } -- cgit v1.2.3 From ba627ff40c77c955a203449455494ff0549d5ffa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 31 Mar 2010 07:28:23 +0000 Subject: svn merge https://svn.blender.org/svnroot/bf-blender/branches/render25 -r27867:27871 --- source/blender/blenkernel/intern/modifier.c | 93 ++++++++++++++++++++++++----- 1 file changed, 78 insertions(+), 15 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index acab22abde4..76e49c0726b 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5718,6 +5718,7 @@ static void solidifyModifier_copyData(ModifierData *md, ModifierData *target) SolidifyModifierData *smd = (SolidifyModifierData*) md; SolidifyModifierData *tsmd = (SolidifyModifierData*) target; tsmd->offset = smd->offset; + tsmd->offset_fac = smd->offset_fac; tsmd->crease_inner = smd->crease_inner; tsmd->crease_outer = smd->crease_outer; tsmd->crease_rim = smd->crease_rim; @@ -5755,6 +5756,19 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, float (*vert_nors)[3]= NULL; + float ofs_orig= - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); + float ofs_new= smd->offset - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); + + /* weights */ + MDeformVert *dvert= NULL, *dv= NULL; + int defgrp_index= -1; + int defgrp_invert = ((smd->flag & MOD_SOLIDIFY_VGROUP_INV) != 0); + + defgrp_index= defgroup_name_index(ob, smd->defgrp_name); + + if (defgrp_index >= 0) + dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); + orig_mface = dm->getFaceArray(dm); orig_medge = dm->getEdgeArray(dm); orig_mvert = dm->getVertArray(dm); @@ -5888,16 +5902,38 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, if((smd->flag & MOD_SOLIDIFY_EVEN) == 0) { /* no even thickness, very simple */ - float scalar_short = smd->offset / 32767.0f; - - if(smd->offset < 0.0f) mv= mvert+numVerts; - else mv= mvert; + float scalar_short; + float scalar_short_vgroup; + + + if(ofs_new != 0.0f) { + scalar_short= scalar_short_vgroup= ofs_new / 32767.0f; + mv= mvert + ((ofs_new >= ofs_orig) ? 0 : numVerts); + dv= dvert; + for(i=0; ico, mv->co, mv->no, scalar_short_vgroup); + } + } - for(i=0; ico[0] += mv->no[0] * scalar_short; - mv->co[1] += mv->no[1] * scalar_short; - mv->co[2] += mv->no[2] * scalar_short; + if(ofs_orig != 0.0f) { + scalar_short= scalar_short_vgroup= ofs_orig / 32767.0f; + mv= mvert + ((ofs_new >= ofs_orig) ? numVerts : 0); /* same as above but swapped, intentional use of 'ofs_new' */ + dv= dvert; + for(i=0; ico, mv->co, mv->no, scalar_short_vgroup); + } } + } else { /* make a face normal layer if not present */ @@ -5949,12 +5985,38 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, } } - if(smd->offset < 0.0f) mv= mvert+numVerts; - else mv= mvert; + /* vertex group support */ + if(dvert) { + dv= dvert; + if(defgrp_invert) { + for(i=0; i= ofs_orig) ? 0 : numVerts); - for(i=0; ico, vert_nors[i], smd->offset * (vert_angles[i] / vert_accum[i])); + for(i=0; ico, vert_nors[i], ofs_new * (vert_angles[i] / vert_accum[i])); + } + } + } + + if(ofs_orig) { + mv= mvert + ((ofs_new >= ofs_orig) ? numVerts : 0); /* same as above but swapped, intentional use of 'ofs_new' */ + + for(i=0; ico, vert_nors[i], ofs_orig * (vert_angles[i] / vert_accum[i])); + } } } @@ -7943,10 +8005,11 @@ static void explodeModifier_createFacepa(ExplodeModifierData *emd, MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); float val; if(dvert){ - for(i=0; ivgroup-1; + for(i=0; iprotect)*val + emd->protect*0.5f; - if(val < defvert_find_weight(dvert+i,emd->vgroup-1)) + if(val < defvert_find_weight(dvert, defgrp_index)) vertpa[i] = -1; } } -- cgit v1.2.3 From f49a82b03ebf63f8416b238cf32f29382bc331c9 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 1 Apr 2010 02:28:08 +0000 Subject: Fix [#20711] Loop selection not working with Emulate MMB + Left mouse select Emulate 3 button mouse is now disabled when Left mouse select is used, to prevent keymap conflicts. Configs for single button macs etc we can do with keymap presets. --- source/blender/blenkernel/BKE_blender.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 8865757b85a..2f5e19fa83c 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -45,7 +45,7 @@ struct Scene; struct Main; #define BLENDER_VERSION 252 -#define BLENDER_SUBVERSION 2 +#define BLENDER_SUBVERSION 3 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 -- cgit v1.2.3 From ceebd182ed2e3310d6b65fa73574b941156aa1b0 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 1 Apr 2010 03:58:20 +0000 Subject: Fix [#21298] Colour Management: Convert To Float & Use Colour Balance Linearising VSE Strip Removed all colour management from sequencer, need better design/plan for this. --- source/blender/blenkernel/intern/sequencer.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 913ec3d4cae..790087334c6 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1750,19 +1750,15 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf if(seq->flag & SEQ_MAKE_FLOAT) { if (!se->ibuf->rect_float) { - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) { - IMB_float_from_rect(se->ibuf); - } else { - int profile = IB_PROFILE_NONE; - - /* no color management: - * don't disturb the existing profiles */ - SWAP(int, se->ibuf->profile, profile); + int profile = IB_PROFILE_NONE; + + /* no color management: + * don't disturb the existing profiles */ + SWAP(int, se->ibuf->profile, profile); - IMB_float_from_rect(se->ibuf); - - SWAP(int, se->ibuf->profile, profile); - } + IMB_float_from_rect(se->ibuf); + + SWAP(int, se->ibuf->profile, profile); } if (se->ibuf->rect) { imb_freerectImBuf(se->ibuf); -- cgit v1.2.3 From c46a955ee0e13d812780f8afe78a6a9c34bb84fa Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 1 Apr 2010 06:26:41 +0000 Subject: Assorted animsys fixes/tweaks: * Fixed all the dangerous code added in 27907. Using the code there, scripters could corrupt animation files in ways which would render them useless, with channels not appearing in any animation editors, and others not getting evaluated at all. * Partial fix of bug 21818, by disabling destructive replacement of keyframes. Will followup this commit with a more comprehensive commit which gets rid of the rest of the problems, by incorporating some requests from Durian team. * Fixed problems with users being able to see+edit the name of the active Keying Set in the Scene buttons. There is still a bug though with the list widget given how the indices are now interpreted... --- source/blender/blenkernel/BKE_action.h | 3 ++ source/blender/blenkernel/BKE_nla.h | 2 + source/blender/blenkernel/intern/action.c | 24 ++++++++++++ source/blender/blenkernel/intern/nla.c | 61 ++++++++++++++++++++++++++++++- 4 files changed, 89 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 214b5a32cd6..4d3f000c863 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -105,6 +105,9 @@ struct bActionGroup *get_active_actiongroup(struct bAction *act); /* Make the given Action Group the active one */ void set_active_action_group(struct bAction *act, struct bActionGroup *agrp, short select); +/* Add a new action group with the given name to the action */ +struct bActionGroup *action_groups_add_new(struct bAction *act, const char name[]); + /* Add given channel into (active) group */ void action_groups_add_channel(struct bAction *act, struct bActionGroup *agrp, struct FCurve *fcurve); diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 5b842965225..30bce613dbe 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -77,6 +77,8 @@ void BKE_nlatrack_sort_strips(struct NlaTrack *nlt); short BKE_nlatrack_add_strip(struct NlaTrack *nlt, struct NlaStrip *strip); +short BKE_nlatrack_get_bounds(struct NlaTrack *nlt, float bounds[2]); + /* ............ */ struct NlaStrip *BKE_nlastrip_find_active(struct NlaTrack *nlt); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 2d52d6061b9..7f8ae06a848 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -238,6 +238,30 @@ void set_active_action_group (bAction *act, bActionGroup *agrp, short select) } } +/* Add a new action group with the given name to the action */ +bActionGroup *action_groups_add_new (bAction *act, const char name[]) +{ + bActionGroup *agrp; + + /* sanity check: must have action and name */ + if (ELEM(NULL, act, name) || (name[0] == 0)) + return NULL; + + /* allocate a new one */ + agrp = MEM_callocN(sizeof(bActionGroup), "bActionGroup"); + + /* make it selected, with default name */ + agrp->flag = AGRP_SELECTED; + strncpy(agrp->name, name, sizeof(agrp->name)); + + /* add to action, and validate */ + BLI_addtail(&act->groups, agrp); + BLI_uniquename(&act->groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name)); + + /* return the new group */ + return agrp; +} + /* Add given channel into (active) group * - assumes that channel is not linked to anything anymore * - always adds at the end of the group diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 4af007a5f91..4b6a3a7e8e4 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -39,10 +39,12 @@ #include "BLI_ghash.h" #include "DNA_anim_types.h" +#include "DNA_scene_types.h" #include "BKE_action.h" #include "BKE_fcurve.h" #include "BKE_nla.h" +#include "BKE_global.h" #include "BKE_library.h" #include "BKE_utildefines.h" @@ -956,6 +958,35 @@ short BKE_nlatrack_add_strip (NlaTrack *nlt, NlaStrip *strip) return BKE_nlastrips_add_strip(&nlt->strips, strip); } +/* Get the extents of the given NLA-Track including gaps between strips, + * returning whether this succeeded or not + */ +short BKE_nlatrack_get_bounds (NlaTrack *nlt, float bounds[2]) +{ + NlaStrip *strip; + + /* initialise bounds */ + if (bounds) + bounds[0] = bounds[1] = 0.0f; + else + return 0; + + /* sanity checks */ + if ELEM(NULL, nlt, nlt->strips.first) + return 0; + + /* lower bound is first strip's start frame */ + strip = nlt->strips.first; + bounds[0] = strip->start; + + /* upper bound is last strip's end frame */ + strip = nlt->strips.last; + bounds[1] = strip->end; + + /* done */ + return 1; +} + /* NLA Strips -------------------------------------- */ /* Find the active NLA-strip within the given track */ @@ -1474,7 +1505,10 @@ short BKE_nla_tweakmode_enter (AnimData *adt) } } if ELEM3(NULL, activeTrack, activeStrip, activeStrip->act) { - printf("NLA tweakmode enter - neither active requirement found \n"); + if (G.f & G_DEBUG) { + printf("NLA tweakmode enter - neither active requirement found \n"); + printf("\tactiveTrack = %p, activeStrip = %p \n", activeTrack, activeStrip); + } return 0; } @@ -1553,4 +1587,29 @@ void BKE_nla_tweakmode_exit (AnimData *adt) adt->flag &= ~ADT_NLA_EDIT_ON; } +/* Baking Tools ------------------------------------------- */ + +void BKE_nla_bake (Scene *scene, ID *id, AnimData *adt, int flag) +{ + + /* verify that data is valid + * 1) Scene and AnimData must be provided + * 2) there must be tracks to merge... + */ + if ELEM3(NULL, scene, adt, adt->nla_tracks.first) + return; + + /* if animdata currently has an action, 'push down' this onto the stack first */ + if (adt->action) + BKE_nla_action_pushdown(adt); + + /* get range of motion to bake, and the channels involved... */ + + /* temporarily mute the action, and start keying to it */ + + /* start keying... */ + + /* unmute the action */ +} + /* *************************************************** */ -- cgit v1.2.3 From d1fef786b721183ebe20eeb7ada887db804d2560 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Apr 2010 08:39:08 +0000 Subject: allow action groups with "" name, (just uses "Group" instead) --- source/blender/blenkernel/intern/action.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 7f8ae06a848..365ac2371b8 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -244,7 +244,7 @@ bActionGroup *action_groups_add_new (bAction *act, const char name[]) bActionGroup *agrp; /* sanity check: must have action and name */ - if (ELEM(NULL, act, name) || (name[0] == 0)) + if (ELEM(NULL, act, name)) return NULL; /* allocate a new one */ @@ -252,7 +252,7 @@ bActionGroup *action_groups_add_new (bAction *act, const char name[]) /* make it selected, with default name */ agrp->flag = AGRP_SELECTED; - strncpy(agrp->name, name, sizeof(agrp->name)); + strncpy(agrp->name, name[0] ? name : "Group", sizeof(agrp->name)); /* add to action, and validate */ BLI_addtail(&act->groups, agrp); -- cgit v1.2.3 From 9822e07be6c02f80955cbc36be3353d1c88b80b4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 1 Apr 2010 12:51:24 +0000 Subject: Attempted fixes for render crashes on windows, still can't redo them here in a virtual machine, maybe that has some different threading behavior. Also should fix a problem with displaying render passes and multiple slots. --- source/blender/blenkernel/intern/image.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 2d582157233..63bfbc3d093 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1894,13 +1894,16 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ memset(&rres, 0, sizeof(RenderResult)); if(!(rres.rectx > 0 && rres.recty > 0)) { - RE_ReleaseResultImage(re); + if(from_render) + RE_ReleaseResultImage(re); return NULL; } /* release is done in BKE_image_release_ibuf using lock_r */ - if(from_render) + if(from_render) { + BLI_lock_thread(LOCK_VIEWER); *lock_r= re; + } /* this gives active layer, composite or seqence result */ rect= (unsigned int *)rres.rect32; @@ -1909,9 +1912,9 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ dither= iuser->scene->r.dither_intensity; /* get compo/seq result by default */ - if(rres.rectf && layer==0); + if(rres.compo_seq && layer==0); else if(rres.layers.first) { - RenderLayer *rl= BLI_findlink(&rres.layers, layer-(rres.rectf?1:0)); + RenderLayer *rl= BLI_findlink(&rres.layers, layer-(rres.compo_seq?1:0)); if(rl) { RenderPass *rpass; @@ -1934,6 +1937,9 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ } } + if(!(rectf || rect)) + return NULL; + ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); /* make ibuf if needed, and initialize it */ @@ -1942,17 +1948,12 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); } - if(!(rectf || rect)) - return ibuf; - ibuf->x= rres.rectx; ibuf->y= rres.recty; - if(ibuf->rect_float!=rectf || rect) { /* ensure correct redraw */ - BLI_lock_thread(LOCK_CUSTOM1); + if(ibuf->rect_float!=rectf || rect) /* ensure correct redraw */ imb_freerectImBuf(ibuf); - BLI_unlock_thread(LOCK_CUSTOM1); - } + if(rect) ibuf->rect= rect; @@ -1991,7 +1992,7 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame if(ima->lastframe != frame) ima->tpageflag |= IMA_TPAGE_REFRESH; ima->lastframe = frame; - } + } else if(ima->type==IMA_TYPE_MULTILAYER) { frame= iuser?iuser->framenr:ima->lastframe; index= iuser?iuser->multi_index:IMA_NO_INDEX; @@ -2155,10 +2156,13 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) void BKE_image_release_ibuf(Image *ima, void *lock) { /* for getting image during threaded render / compositing, need to release */ - if(lock == ima) + if(lock == ima) { BLI_unlock_thread(LOCK_VIEWER); /* viewer image */ - else if(lock) + } + else if(lock) { RE_ReleaseResultImage(lock); /* render result */ + BLI_unlock_thread(LOCK_VIEWER); /* view image imbuf */ + } } ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) -- cgit v1.2.3 From 68fb0d98d95ac73eb22b9ca0702131a058b3a632 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Thu, 1 Apr 2010 14:44:31 +0000 Subject: Smoke: * Bugfix for missing high res calculation when low res cache was already there * Bugfix for loading file with smoke but tfor the first "round" of alt-a nothing happened. Now the smoke gets calculated on file load, too. --- source/blender/blenkernel/intern/smoke.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 00e81063760..aa513ab0fb7 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1156,10 +1156,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM framenr = scene->r.cfra; - // printf("time: %d\n", scene->r.cfra); - - if(framenr == smd->time) - return; + printf("time: %d\n", scene->r.cfra); cache = sds->point_cache[0]; BKE_ptcache_id_from_smoke(&pid, ob, smd); @@ -1206,11 +1203,23 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(cache_result_wt == PTCACHE_READ_EXACT) { BKE_ptcache_validate(cache_wt, framenr); + + return; + } + else + { + ; /* don't return in the case we only got low res cache but no high res cache */ + /* we still need to calculate the high res cache */ } } - return; + else + return; } + /* only calculate something when we advanced a frame */ + if(framenr == smd->time) + return; + tstart(); smoke_calc_domain(scene, ob, smd); -- cgit v1.2.3 From 9105f6f0bd7f3fe48b624bb516ce16641a115c15 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Apr 2010 21:44:56 +0000 Subject: rna naming, *_frame --> frame_* --- source/blender/blenkernel/intern/nla.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 4b6a3a7e8e4..ab2a6f713cb 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -830,8 +830,8 @@ void BKE_nlameta_flush_transforms (NlaStrip *mstrip) strip->end= nEnd; RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &ptr); - RNA_float_set(&ptr, "start_frame", nStart); - RNA_float_set(&ptr, "end_frame", nEnd); + RNA_float_set(&ptr, "frame_start", nStart); + RNA_float_set(&ptr, "frame_end", nEnd); } else { /* just apply the changes in offset to both ends of the strip */ -- cgit v1.2.3 From 12149d8cd968af5bf2429f3930d27bca51c1c542 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 2 Apr 2010 01:04:26 +0000 Subject: Bump subversion number so that new defaults initialisations from prev commit will work ok. Missed this file when committing... --- source/blender/blenkernel/BKE_blender.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 2f5e19fa83c..64c5823f06f 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -45,7 +45,7 @@ struct Scene; struct Main; #define BLENDER_VERSION 252 -#define BLENDER_SUBVERSION 3 +#define BLENDER_SUBVERSION 4 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 -- cgit v1.2.3 From b1a0c861631c85479a25578b1965b34a48d150b1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Apr 2010 11:18:52 +0000 Subject: pointcache in set scenes wasnt updating --- source/blender/blenkernel/intern/scene.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 51b18800474..a494d947953 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -953,8 +953,13 @@ void scene_update_tagged(Scene *scene) BKE_animsys_evaluate_animdata(&scene->id, adt, ctime, 0); } + /* XXX - this is called far to often, should be made apart of the depgraph */ BKE_ptcache_quick_cache_all(scene); + sce= scene; + while((sce= sce->set)) + BKE_ptcache_quick_cache_all(sce); + /* in the future this should handle updates for all datablocks, not only objects and scenes. - brecht */ } -- cgit v1.2.3 From 70540fca3bfa90d21531c84e42aa7a4f74b52826 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Apr 2010 13:43:56 +0000 Subject: bugfix [#21230] set-scene animation updates not working fix for empty scenes with SETLOOPER macro. --- source/blender/blenkernel/BKE_scene.h | 5 ++--- source/blender/blenkernel/intern/scene.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 09fb705dd70..090979b33e9 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -47,9 +47,8 @@ struct Main; #define SCE_COPY_LINK_DATA 2 #define SCE_COPY_FULL 3 -/* note; doesn't work when scene is empty */ -#define SETLOOPER(s, b) sce= s, b= (Base*)sce->base.first; b; b= (Base*)(b->next?b->next:sce->set?(sce=sce->set)->base.first:NULL) - +#define SETLOOPER(s, b) sce= s, b= _setlooper_base_step(&sce, NULL); b; b= _setlooper_base_step(&sce, b) +struct Base *_setlooper_base_step(struct Scene **sce, struct Base *base); void free_avicodecdata(struct AviCodecData *acd); void free_qtcodecdata(struct QuicktimeCodecData *acd); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index a494d947953..c258f2d47b7 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1051,3 +1051,26 @@ float get_render_aosss_error(RenderData *r, float error) return error; } +/* helper function for the SETLOOPER macro */ +Base *_setlooper_base_step(Scene **sce, Base *base) +{ + if(base && base->next) { + /* common case, step to the next */ + return base->next; + } + else if(base==NULL && (*sce)->base.first) { + /* first time looping, return the scenes first base */ + return (Base *)(*sce)->base.first; + } + else { + /* reached the end, get the next base in the set */ + while((*sce= (*sce)->set)) { + base= (Base *)(*sce)->base.first; + if(base) { + return base; + } + } + } + + return NULL; +} -- cgit v1.2.3 From d4340289a61821b83e54b007fda3752f8ba82fbc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Apr 2010 14:57:12 +0000 Subject: Set Scenes and Physics - objects in a set scene now are evaluated with the frame from the current scene. - pointcache now loops over all set scene objects. --- source/blender/blenkernel/intern/pointcache.c | 12 +++++++----- source/blender/blenkernel/intern/scene.c | 17 +++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 8efa9e29698..807e25955a7 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -560,7 +560,7 @@ static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, flo static int ptcache_totpoint_cloth(void *cloth_v, int cfra) { ClothModifierData *clmd= cloth_v; - return clmd->clothObject->numverts; + return clmd->clothObject ? clmd->clothObject->numverts : 0; } /* Creating ID's */ @@ -2327,12 +2327,13 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old /* Baking */ static int count_quick_cache(Scene *scene, int *quick_step) { - Base *base = scene->base.first; + Base *base; PTCacheID *pid; ListBase pidlist; int autocache_count= 0; + Scene *sce; /* for macro only */ - for(base = scene->base.first; base; base = base->next) { + for(SETLOOPER(scene, base)) { if(base->object) { BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); @@ -2401,6 +2402,7 @@ static void *ptcache_make_cache_thread(void *ptr) { void BKE_ptcache_make_cache(PTCacheBaker* baker) { Scene *scene = baker->scene; + Scene *sce; /* SETLOOPER macro only */ Base *base; ListBase pidlist; PTCacheID *pid = baker->pid; @@ -2465,7 +2467,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache->flag &= ~PTCACHE_BAKED; } } - else for(base=scene->base.first; base; base= base->next) { + for(SETLOOPER(scene, base)) { /* cache/bake everything in the scene */ BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); @@ -2548,7 +2550,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) BKE_ptcache_write_cache(pid, 0); } } - else for(base=scene->base.first; base; base= base->next) { + else for(SETLOOPER(scene, base)) { BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); for(pid=pidlist.first; pid; pid=pid->next) { diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index c258f2d47b7..fc6b7e7d789 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -891,10 +891,12 @@ float frame_to_float (Scene *scene, int cfra) /* see also bsystem_time in objec return ctime; } -static void scene_update_newframe(Scene *scene, unsigned int lay) +static void scene_update_newframe(Scene *scene, int cfra, unsigned int lay) { Base *base; Object *ob; + int cfra_back= scene->r.cfra; + scene->r.cfra= cfra; for(base= scene->base.first; base; base= base->next) { ob= base->object; @@ -910,6 +912,8 @@ static void scene_update_newframe(Scene *scene, unsigned int lay) // base->lay= ob->lay; //} } + + scene->r.cfra= cfra_back; } /* this is called in main loop, doing tagged updates before redraw */ @@ -956,10 +960,6 @@ void scene_update_tagged(Scene *scene) /* XXX - this is called far to often, should be made apart of the depgraph */ BKE_ptcache_quick_cache_all(scene); - sce= scene; - while((sce= sce->set)) - BKE_ptcache_quick_cache_all(sce); - /* in the future this should handle updates for all datablocks, not only objects and scenes. - brecht */ } @@ -994,10 +994,11 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay) /* sets first, we allow per definition current scene to have dependencies on sets */ - for(sce_iter= sce->set; sce_iter; sce_iter= sce_iter->set) - scene_update_newframe(sce_iter, lay); + for(sce_iter= sce->set; sce_iter; sce_iter= sce_iter->set) { + scene_update_newframe(sce_iter, sce->r.cfra, lay); + } - scene_update_newframe(sce, lay); + scene_update_newframe(sce, sce->r.cfra, lay); } /* return default layer, also used to patch old files */ -- cgit v1.2.3 From a5156d139e2bd0a9db80ffd097ceb22e22ece16b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 4 Apr 2010 10:37:47 +0000 Subject: Fix crash entering edit mode on linked duplicate meshes with dupliverts. The flag mode & OB_MODE_EDIT only indicates that this object is being edited by the user, not if the mesh is in editmode or not, it should check for the existence of me->edit_mesh. Also corrected two other places for this. --- source/blender/blenkernel/intern/anim.c | 4 ++-- source/blender/blenkernel/intern/object.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index e26072deb76..b687062fe15 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -837,7 +837,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl /* mballs have a different dupli handling */ if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ - if(par->mode & OB_MODE_EDIT) { + if(me->edit_mesh) { dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void*) &vdd); } else { @@ -1048,7 +1048,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa else go= go->next; /* group loop */ } - if(par->mode & OB_MODE_EDIT) { + if(em) { MEM_freeN(mface); MEM_freeN(mvert); } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index bb7c77408ac..ac679adb9c1 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2502,7 +2502,7 @@ void object_handle_update(Scene *scene, Object *ob) BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); // here was vieweditdatamask? XXX - if(ob->mode & OB_MODE_EDIT) { + if(em) { makeDerivedMesh(scene, ob, em, CD_MASK_BAREMESH); BKE_mesh_end_editmesh(ob->data, em); } else -- cgit v1.2.3 From 694934a2f7225aba6c2d20f2563d7cbc25cbfa15 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 4 Apr 2010 11:07:34 +0000 Subject: Fix #21850: Modifier applied to surface doesnt work when only a curve. I removed 3D flag checking for DL_POLY displists in nurbs-to-mesh conversion function -- DL_POLY displist should be always converted to edge loop. DL_POLY which should be converted to something else is odd i think. This commit also fixes trouble cyclic surface curve to mesh conversion problem. --- source/blender/blenkernel/intern/mesh.c | 44 ++++++++++++++------------------- 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index a8afa779dba..9e8767406b1 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -774,11 +774,8 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int totvlak+= dl->parts*(dl->nr-1); } else if(dl->type==DL_POLY) { - /* cyclic polys are filled. except when 3D */ - if(cu->flag & CU_3D) { - totvert+= dl->parts*dl->nr; - totvlak+= dl->parts*dl->nr; - } + totvert+= dl->parts*dl->nr; + totvlak+= dl->parts*dl->nr; } else if(dl->type==DL_SURF) { totvert+= dl->parts*dl->nr; @@ -830,27 +827,24 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int } else if(dl->type==DL_POLY) { - /* 3d polys are not filled */ - if(cu->flag & CU_3D) { - startvert= vertcount; - a= dl->parts*dl->nr; - data= dl->verts; - while(a--) { - VECCOPY(mvert->co, data); - data+=3; - vertcount++; - mvert++; - } + startvert= vertcount; + a= dl->parts*dl->nr; + data= dl->verts; + while(a--) { + VECCOPY(mvert->co, data); + data+=3; + vertcount++; + mvert++; + } - for(a=0; aparts; a++) { - ofs= a*dl->nr; - for(b=0; bnr; b++) { - mface->v1= startvert+ofs+b; - if(b==dl->nr-1) mface->v2= startvert+ofs; - else mface->v2= startvert+ofs+b+1; - if(smooth) mface->flag |= ME_SMOOTH; - mface++; - } + for(a=0; aparts; a++) { + ofs= a*dl->nr; + for(b=0; bnr; b++) { + mface->v1= startvert+ofs+b; + if(b==dl->nr-1) mface->v2= startvert+ofs; + else mface->v2= startvert+ofs+b+1; + if(smooth) mface->flag |= ME_SMOOTH; + mface++; } } } -- cgit v1.2.3 From c5871b87502cfd35fa14881f1bcadbd5564e658f Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 4 Apr 2010 12:29:06 +0000 Subject: Fluid physics for particles by Raul Fernandez Hernandez (Farsthary) and Stephen Swhitehorn: This patch add SPH (Smoothed Particle Hydrodynamics)fluid dynamics to the blender particle system. SPH is an boundless Lagrangian interpolation technique to solve the fluid motion equations. From liquids to sand, goo and gases could be simulated using the particle system. It features internal viscosity, a double density relaxation that accounts for surface tension effects, static internal springs for plastic fluids, and buoyancy for gases. --------------------------------------- This is a commit of the core fluid physics. Raul will work on proper documentation soon and more features such as surface extraction from the particle point cloud and increasing stability by sub-frame calculations later. --- source/blender/blenkernel/intern/particle.c | 7 + source/blender/blenkernel/intern/particle_system.c | 178 ++++++++++++++++++++- 2 files changed, 183 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index bd9e041dab4..7ad65820bbe 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -355,6 +355,12 @@ int psys_uses_gravity(ParticleSimulationData *sim) /************************************************/ /* Freeing stuff */ /************************************************/ +void fluid_free_settings(SPHFluidSettings *fluid) +{ + if(fluid) + MEM_freeN(fluid); +} + void psys_free_settings(ParticleSettings *part) { BKE_free_animdata(&part->id); @@ -367,6 +373,7 @@ void psys_free_settings(ParticleSettings *part) BLI_freelistN(&part->dupliweights); boid_free_settings(part->boids); + fluid_free_settings(part->fluid); } void free_hair(Object *ob, ParticleSystem *psys, int dynamics) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a8446c0009f..aa48336247c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -24,7 +24,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Raul Fernandez Hernandez (Farsthary), Stephen Swhitehorn. * * ***** END GPL LICENSE BLOCK ***** */ @@ -2270,6 +2270,137 @@ static void psys_update_effectors(ParticleSimulationData *sim) precalc_guides(sim, sim->psys->effectors); } +/************************************************* + SPH fluid physics + + In theory, there could be unlimited implementation + of SPH simulators +**************************************************/ +void particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings *part, ParticleSimulationData *sim, float dfra, float cfra, float mass){ +/**************************************************************************************************************** +* This code uses in some parts adapted algorithms from the pseduo code as outlined in the Research paper +* Titled: Particle-based Viscoelastic Fluid Simulation. +* Authors: Simon Clavet, Philippe Beaudoin and Pierre Poulin +* +* Website: http://www.iro.umontreal.ca/labs/infographie/papers/Clavet-2005-PVFS/ +* Presented at Siggraph, (2005) +* +*****************************************************************************************************************/ + KDTree *tree = psys->tree; + KDTreeNearest *ptn = NULL; + + SPHFluidSettings *fluid = part->fluid; + ParticleData *second_particle; + + float start[3], end[3], v[3]; + float temp[3]; + float q, radius, D; + float p, pnear, pressure_near, pressure; + float dtime = dfra * psys_get_timestep(sim); + float omega = fluid->viscosity_omega; + float beta = fluid->viscosity_omega; + float massfactor = 1.0f/mass; + int n, neighbours; + + + radius = fluid->radius; + + VECCOPY(start, pa->prev_state.co); + VECCOPY(end, pa->state.co); + + sub_v3_v3v3(v, end, start); + mul_v3_fl(v, 1.f/dtime); + + neighbours = BLI_kdtree_range_search(tree, radius, start, NULL, &ptn); + + /* use ptn[n].co to store relative direction */ + for(n=1; n 0.f || beta > 0.f) { + float u, I; + + for(n=1; nparticles + ptn[n].index; + q = ptn[n].dist/radius; + + sub_v3_v3v3(temp, v, second_particle->prev_state.vel); + + u = dot_v3v3(ptn[n].co, temp); + + if (u > 0){ + I = dtime * ((1-q) * (omega * u + beta * u*u)) * 0.5f; + madd_v3_v3fl(v, ptn[n].co, -I * massfactor); + } + } + } + + /* Hooke's spring force */ + if (fluid->spring_k > 0.f) { + float D, L = fluid->rest_length; + for(n=1; nspring_k * (1.f - L) * (L - ptn[n].dist/radius); + madd_v3_v3fl(v, ptn[n].co, -D * massfactor); + } + } + /* Update particle position */ + VECADDFAC(end, start, v, dtime); + + /* Double Density Relaxation - Algorithm 2 */ + p = 0; + pnear = 0; + for(n=1; nmass; + pnear *= part->mass; + pressure = fluid->stiffness_k * (p - fluid->rest_density); + pressure_near = fluid->stiffness_knear * pnear; + + for(n=1; nbuoyancy >= 0.f && psys_uses_gravity(sim)) { + float B = -dtime * dtime * fluid->buoyancy * (p - fluid->rest_density) * 0.5f; + madd_v3_v3fl(end, sim->scene->physics_settings.gravity, -B * massfactor); + } + + /* apply final result and recalculate velocity */ + VECCOPY(pa->state.co, end); + sub_v3_v3v3(pa->state.vel, end, start); + mul_v3_fl(pa->state.vel, 1.f/dtime); + + if(ptn){ MEM_freeN(ptn); ptn=NULL;} +} + +static void apply_particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings *part, ParticleSimulationData *sim, float dfra, float cfra){ + ParticleTarget *pt; + float dtime = dfra*psys_get_timestep(sim); + float particle_mass = part->mass; + + particle_fluidsim(psys, pa, part, sim, dfra, cfra, particle_mass); + + /*----check other SPH systems (Multifluids) , each fluid has its own parameters---*/ + for(pt=sim->psys->targets.first; pt; pt=pt->next) { + ParticleSystem *epsys = psys_get_target_system(sim->ob, pt); + + if(epsys) + particle_fluidsim(epsys, pa, epsys->part, sim, dfra, cfra, particle_mass); + } + /*----------------------------------------------------------------*/ +} + /************************************************/ /* Newtonian physics */ /************************************************/ @@ -2799,7 +2930,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo deflections=max_deflections; } else { - float nor_vec[3], tan_vec[3], tan_vel[3], vel[3]; + float nor_vec[3], tan_vec[3], tan_vel[3]; float damp, frict; float inp, inp_v; @@ -3248,6 +3379,14 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); } } + else if(part->phystype==PART_PHYS_FLUID){ + ParticleTarget *pt = psys->targets.first; + psys_update_particle_tree(psys, cfra); + + for(; pt; pt=pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */ + if(pt->ob) psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); + } + } /* main loop: calculate physics for all particles */ LOOP_SHOWN_PARTICLES { @@ -3318,6 +3457,22 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) } break; } + case PART_PHYS_FLUID: + { + /* do global forces & effectors */ + apply_particle_forces(sim, p, pa_dfra, cfra); + + /* do fluid sim */ + apply_particle_fluidsim(psys, pa, part, sim, pa_dfra, cfra); + + /* deflection */ + if(sim->colliders) + deflect_particle(sim, p, pa_dfra, cfra); + + /* rotations, SPH particles are not physical particles, just interpolation particles, thus rotation has not a direct sense for them */ + rotate_particle(part, pa, pa_dfra, timestep); + break; + } } if(pa->alive == PARS_DYING){ @@ -3727,6 +3882,21 @@ void psys_check_boid_data(ParticleSystem *psys) pa->boid = NULL; } } + +static void fluid_default_settings(ParticleSettings *part){ + SPHFluidSettings *fluid = part->fluid; + + fluid->radius = 0.5f; + fluid->spring_k = 0.f; + fluid->rest_length = 0.5f; + fluid->viscosity_omega = 2.f; + fluid->viscosity_beta = 0.f; + fluid->stiffness_k = 0.1f; + fluid->stiffness_knear = 0.05f; + fluid->rest_density = 10.f; + fluid->buoyancy = 0.f; +} + static void psys_changed_physics(ParticleSimulationData *sim) { ParticleSettings *part = sim->psys->part; @@ -3756,6 +3926,10 @@ static void psys_changed_physics(ParticleSimulationData *sim) state->flag |= BOIDSTATE_CURRENT; BLI_addtail(&part->boids->states, state); } + else if(part->phystype == PART_PHYS_FLUID && part->fluid == NULL) { + part->fluid = MEM_callocN(sizeof(SPHFluidSettings), "SPH Fluid Settings"); + fluid_default_settings(part); + } psys_check_boid_data(sim->psys); } -- cgit v1.2.3