From f7909598e47d29fad84f1f013790c4e2710ac01a Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 5 Mar 2010 01:29:56 +0000 Subject: Bugfix #21463: Bone driven Shapekey broken in 2.5Alpha2 (for drivers from 2.49b) Animation conversion needed to make transform channel driver vars (for bones) to be in local space, since that's what the old code did (albeit in a slightly more roundabout way). --- source/blender/blenkernel/intern/ipo.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index dbde6403226..807b584d6f8 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1051,6 +1051,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) if (idriver->name[0]) BLI_strncpy(dtar->pchan_name, idriver->name, 32); dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode); + dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */ } } else { /* Object */ -- cgit v1.2.3 From f4298de8aaafd36cb8da6f7051c24ca630589001 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Mar 2010 14:06:39 +0000 Subject: utility function object_camera_matrix, moved code from RE_SetCamera into this. use for getting the render matrix of a camera (view plane, winmat, clipstart/end) without rendering. --- source/blender/blenkernel/BKE_object.h | 5 ++ source/blender/blenkernel/intern/object.c | 109 ++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index a6a641a3219..1362a191919 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -45,6 +45,7 @@ struct SoftBody; struct BulletSoftBody; struct Group; struct bAction; +struct RenderData; void clear_workob(struct Object *workob); void what_does_parent(struct Scene *scene, struct Object *ob, struct Object *workob); @@ -128,6 +129,10 @@ int object_insert_ptcache(struct Object *ob); // void object_delete_ptcache(struct Object *ob, int index); struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob, char *name, int from_mix); +void object_camera_matrix( + struct RenderData *rd, struct Object *camera, int winx, int winy, short field_second, + float winmat[][4], struct rctf *viewplane, float *clipsta, float *clipend, float *lens, float *ycor, + float *viewdx, float *viewdy); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 46c26524f47..2d7fc08aa74 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2715,6 +2715,115 @@ int object_insert_ptcache(Object *ob) return i; } +/* 'lens' may be set for envmap only */ +void object_camera_matrix( + RenderData *rd, Object *camera, int winx, int winy, short field_second, + float winmat[][4], rctf *viewplane, float *clipsta, float *clipend, float *lens, float *ycor, + float *viewdx, float *viewdy +) { + Camera *cam=NULL; + float pixsize; + float shiftx=0.0, shifty=0.0, winside, viewfac; + + /* question mark */ + (*ycor)= rd->yasp / rd->xasp; + if(rd->mode & R_FIELDS) + (*ycor) *= 2.0f; + + if(camera->type==OB_CAMERA) { + cam= camera->data; + + if(cam->type==CAM_ORTHO) rd->mode |= R_ORTHO; + if(cam->flag & CAM_PANORAMA) rd->mode |= R_PANORAMA; + + /* solve this too... all time depending stuff is in convertblender.c? + * Need to update the camera early because it's used for projection matrices + * and other stuff BEFORE the animation update loop is done + * */ +#if 0 // XXX old animation system + if(cam->ipo) { + calc_ipo(cam->ipo, frame_to_float(re->scene, re->r.cfra)); + execute_ipo(&cam->id, cam->ipo); + } +#endif // XXX old animation system + shiftx=cam->shiftx; + shifty=cam->shifty; + (*lens)= cam->lens; + (*clipsta)= cam->clipsta; + (*clipend)= cam->clipend; + } + else if(camera->type==OB_LAMP) { + Lamp *la= camera->data; + float fac= cos( M_PI*la->spotsize/360.0 ); + float phi= acos(fac); + + (*lens)= 16.0*fac/sin(phi); + if((*lens)==0.0f) + (*lens)= 35.0; + (*clipsta)= la->clipsta; + (*clipend)= la->clipend; + } + else { /* envmap exception... */; + if((*lens)==0.0f) + (*lens)= 16.0; + + if((*clipsta)==0.0f || (*clipend)==0.0f) { + (*clipsta)= 0.1f; + (*clipend)= 1000.0f; + } + } + + /* ortho only with camera available */ + if(cam && rd->mode & R_ORTHO) { + if(rd->xasp*winx >= rd->yasp*winy) { + viewfac= winx; + } + else { + viewfac= (*ycor) * winy; + } + /* ortho_scale == 1.0 means exact 1 to 1 mapping */ + pixsize= cam->ortho_scale/viewfac; + } + else { + if(rd->xasp*winx >= rd->yasp*winy) viewfac= (winx*(*lens))/32.0; + else viewfac= (*ycor) * (winy*(*lens))/32.0; + pixsize= (*clipsta) / viewfac; + } + + /* viewplane fully centered, zbuffer fills in jittered between -.5 and +.5 */ + winside= MAX2(winx, winy); + viewplane->xmin= -0.5f*(float)winx + shiftx*winside; + viewplane->ymin= -0.5f*(*ycor)*(float)winy + shifty*winside; + viewplane->xmax= 0.5f*(float)winx + shiftx*winside; + viewplane->ymax= 0.5f*(*ycor)*(float)winy + shifty*winside; + + if(field_second) { + if(rd->mode & R_ODDFIELD) { + viewplane->ymin-= .5 * (*ycor); + viewplane->ymax-= .5 * (*ycor); + } + else { + viewplane->ymin+= .5* (*ycor); + viewplane->ymax+= .5* (*ycor); + } + } + /* the window matrix is used for clipping, and not changed during OSA steps */ + /* using an offset of +0.5 here would give clip errors on edges */ + viewplane->xmin= pixsize*(viewplane->xmin); + viewplane->xmax= pixsize*(viewplane->xmax); + viewplane->ymin= pixsize*(viewplane->ymin); + viewplane->ymax= pixsize*(viewplane->ymax); + + (*viewdx)= pixsize; + (*viewdy)= (*ycor) * pixsize; + + if(rd->mode & R_ORTHO) + orthographic_m4(winmat, viewplane->xmin, viewplane->xmax, viewplane->ymin, viewplane->ymax, *clipsta, *clipend); + else + perspective_m4(winmat, viewplane->xmin, viewplane->xmax, viewplane->ymin, viewplane->ymax, *clipsta, *clipend); + +} + #if 0 static int pc_findindex(ListBase *listbase, int index) { -- cgit v1.2.3 From d0c70ad1d581d69f650d604293c006b2e0023310 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 5 Mar 2010 16:47:52 +0000 Subject: Constructive modifiers for curves and surfaces Used approach with creating DerivedMesh for curves whet they've got such modifiers. Available modifiers are: array, edge split, mirror, solidify, subsurf. --- source/blender/blenkernel/BKE_DerivedMesh.h | 3 + source/blender/blenkernel/BKE_cdderivedmesh.h | 3 + source/blender/blenkernel/BKE_displist.h | 3 + source/blender/blenkernel/BKE_mesh.h | 2 + source/blender/blenkernel/intern/DerivedMesh.c | 36 ++-- source/blender/blenkernel/intern/cdderivedmesh.c | 30 +++ source/blender/blenkernel/intern/displist.c | 239 +++++++++++++++++++---- source/blender/blenkernel/intern/mesh.c | 166 +++++++++++----- source/blender/blenkernel/intern/modifier.c | 30 +-- source/blender/blenkernel/intern/object.c | 2 +- 10 files changed, 391 insertions(+), 123 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 883a3809b30..154c6347f50 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -538,5 +538,8 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, void DM_add_tangent_layer(DerivedMesh *dm); +/* Set object's bounding box based on DerivedMesh min/max data */ +void DM_set_object_boundbox(struct Object *ob, DerivedMesh *dm); + #endif diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h index 269dcbb4141..77a8ef518e9 100644 --- a/source/blender/blenkernel/BKE_cdderivedmesh.h +++ b/source/blender/blenkernel/BKE_cdderivedmesh.h @@ -54,6 +54,9 @@ struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh, struct Object *ob); /* creates a CDDerivedMesh from the given EditMesh */ struct DerivedMesh *CDDM_from_editmesh(struct EditMesh *em, struct Mesh *me); +/* creates a CDDerivedMesh from the given curve object */ +struct DerivedMesh *CDDM_from_curve(struct Object *ob); + /* Copies the given DerivedMesh with verts, faces & edges stored as * custom element data. */ diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index a250456f5c1..2baefc83678 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -102,5 +102,8 @@ void fastshade_free_render(void); float calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); +/* add Orco layer to the displist object which has got derived mesh and return orco */ +float *makeOrcoDispList(struct Scene *scene, struct Object *ob, int forRender); + #endif diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 0952871e28a..a82e3ffe45b 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -70,6 +70,8 @@ int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, struct Mesh *get_mesh(struct Object *ob); void set_mesh(struct Object *ob, struct Mesh *me); void mball_to_mesh(struct ListBase *lb, struct Mesh *me); +int nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *_totvert, + struct MEdge **alledge, int *_totedge, struct MFace **allface, int *_totface); void nurbs_to_mesh(struct Object *ob); void mesh_to_curve(struct Scene *scene, struct Object *ob); void free_dverts(struct MDeformVert *dvert, int totvert); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index fa6c2f333ee..28b093cd693 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2126,7 +2126,6 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) int editing = paint_facesel_test(ob); /* weight paint and face select need original indicies because of selection buffer drawing */ int needMapping = (ob==obact) && (editing || (ob->mode & OB_MODE_WEIGHT_PAINT) || editing); - float min[3], max[3]; clear_mesh_caches(ob); @@ -2134,13 +2133,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) &ob->derivedFinal, 0, 1, needMapping, dataMask, -1, 1); - INIT_MINMAX(min, max); - - ob->derivedFinal->getMinMax(ob->derivedFinal, min, max); - - if(!ob->bb) - ob->bb= MEM_callocN(sizeof(BoundBox), "bb"); - boundbox_set_from_min_max(ob->bb, min, max); + DM_set_object_boundbox (ob, ob->derivedFinal); ob->derivedFinal->needsFree = 0; ob->derivedDeform->needsFree = 0; @@ -2149,8 +2142,6 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) static void editmesh_build_data(Scene *scene, Object *obedit, EditMesh *em, CustomDataMask dataMask) { - float min[3], max[3]; - clear_mesh_caches(obedit); if (em->derivedFinal) { @@ -2167,16 +2158,9 @@ static void editmesh_build_data(Scene *scene, Object *obedit, EditMesh *em, Cust } editmesh_calc_modifiers(scene, obedit, em, &em->derivedCage, &em->derivedFinal, dataMask); - em->lastDataMask = dataMask; - - INIT_MINMAX(min, max); - - em->derivedFinal->getMinMax(em->derivedFinal, min, max); - - if(!obedit->bb) - obedit->bb= MEM_callocN(sizeof(BoundBox), "bb"); - boundbox_set_from_min_max(obedit->bb, min, max); + DM_set_object_boundbox (obedit, em->derivedFinal); + em->lastDataMask = dataMask; em->derivedFinal->needsFree = 0; em->derivedCage->needsFree = 0; } @@ -2624,3 +2608,17 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, } } +/* Set object's bounding box based on DerivedMesh min/max data */ +void DM_set_object_boundbox(Object *ob, DerivedMesh *dm) +{ + float min[3], max[3]; + + INIT_MINMAX(min, max); + + dm->getMinMax(dm, min, max); + + if(!ob->bb) + ob->bb= MEM_callocN(sizeof(BoundBox), "bb"); + + boundbox_set_from_min_max(ob->bb, min, max); +} diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index a3924e6c1ed..d0e50dc97a8 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1585,6 +1585,36 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *me) return dm; } +DerivedMesh *CDDM_from_curve(Object *ob) +{ + DerivedMesh *dm; + CDDerivedMesh *cddm; + MVert *allvert; + MEdge *alledge; + MFace *allface; + int totvert, totedge, totface; + + if (nurbs_to_mdata (ob, &allvert, &totvert, &alledge, &totedge, &allface, &totface) != 0) { + /* Error initializing mdata. This often happens when curve is empty */ + return CDDM_new(0, 0, 0); + } + + dm = CDDM_new(totvert, totedge, totface); + dm->deformedOnly = 1; + + cddm = (CDDerivedMesh*)dm; + + memcpy(cddm->mvert, allvert, totvert*sizeof(MVert)); + memcpy(cddm->medge, alledge, totedge*sizeof(MEdge)); + memcpy(cddm->mface, allface, totface*sizeof(MFace)); + + MEM_freeN(allvert); + MEM_freeN(alledge); + MEM_freeN(allface); + + return dm; +} + DerivedMesh *CDDM_copy(DerivedMesh *source) { CDDerivedMesh *cddm = cdDM_create("CDDM_copy cddm"); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 91716ce7266..b8b5ae300d9 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -65,6 +65,7 @@ #include "BKE_displist.h" #include "BKE_deform.h" #include "BKE_DerivedMesh.h" +#include "BKE_cdderivedmesh.h" #include "BKE_object.h" #include "BKE_world.h" #include "BKE_mesh.h" @@ -1209,7 +1210,7 @@ void makeDispListMBall(Scene *scene, Object *ob) boundbox_displist(ob); } -static ModifierData *curve_get_tesselate_point(Object *ob, int forRender, int editmode) +static ModifierData *curve_get_tesselate_point(Scene *scene, Object *ob, int forRender, int editmode) { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *preTesselatePoint; @@ -1222,10 +1223,7 @@ static ModifierData *curve_get_tesselate_point(Object *ob, int forRender, int ed preTesselatePoint = NULL; for (; md; md=md->next) { - ModifierTypeInfo *mti = modifierType_getInfo(md->type); - - if ((md->mode & required_mode) != required_mode) continue; - if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; + if (!modifier_isEnabled(scene, md, required_mode)) continue; if (ELEM3(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) { preTesselatePoint = md; @@ -1251,7 +1249,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl if(forRender) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; - preTesselatePoint = curve_get_tesselate_point(ob, forRender, editmode); + preTesselatePoint = curve_get_tesselate_point(scene, ob, forRender, editmode); if(editmode) required_mode |= eModifierMode_Editmode; @@ -1312,11 +1310,12 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba DispList *dl; int required_mode; int editmode = (!forRender && cu->editnurb); + DerivedMesh *dm= NULL, *ndm; if(forRender) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; - preTesselatePoint = curve_get_tesselate_point(ob, forRender, editmode); + preTesselatePoint = curve_get_tesselate_point(scene, ob, forRender, editmode); if(editmode) required_mode |= eModifierMode_Editmode; @@ -1324,6 +1323,10 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba md = preTesselatePoint->next; } + if (ob->derivedFinal) { + ob->derivedFinal->release (ob->derivedFinal); + } + for (; md; md=md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -1331,40 +1334,84 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba if ((md->mode & required_mode) != required_mode) continue; if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if (mti->type!=eModifierTypeType_OnlyDeform && mti->type!=eModifierTypeType_DeformOrConstruct) continue; + if (mti->type!=eModifierTypeType_OnlyDeform && + mti->type!=eModifierTypeType_DeformOrConstruct && + mti->type!=eModifierTypeType_Constructive) continue; /* need to put all verts in 1 block for curve deform */ - if(md->type==eModifierType_Curve) { - float *allverts, *fp; + /* we also need all verts in 1 block for derived mesh creation when handling constructive modifiers */ + if(md->type==eModifierType_Curve || mti->type==eModifierTypeType_Constructive) { + float *allverts = NULL, *fp; int totvert= 0; - - for (dl=dispbase->first; dl; dl=dl->next) - totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr; - - fp= allverts= MEM_mallocN(totvert*sizeof(float)*3, "temp vert"); - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); - memcpy(fp, dl->verts, sizeof(float) * offs); - fp+= offs; + + if (md->type==eModifierType_Curve || + (mti->type==eModifierTypeType_Constructive && !dm)) { + for (dl=dispbase->first; dl; dl=dl->next) + totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr; + + fp= allverts= MEM_mallocN(totvert*sizeof(float)*3, "temp vert"); + for (dl=dispbase->first; dl; dl=dl->next) { + int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + memcpy(fp, dl->verts, sizeof(float) * offs); + fp+= offs; + } } - - mti->deformVerts(md, ob, NULL, (float(*)[3]) allverts, totvert, forRender, editmode); - - fp= allverts; - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); - memcpy(dl->verts, fp, sizeof(float) * offs); - fp+= offs; + + if (mti->type==eModifierTypeType_Constructive) { + if (!dm) { + dm= CDDM_from_curve(ob); + /* + * TODO: Maybe we should apply deformedVerts? + * But for now it causes invalid working of SoftBody modifier + */ + CDDM_apply_vert_coords(dm, (float(*)[3]) allverts); + CDDM_calc_normals(dm); + } + + ndm = mti->applyModifier(md, ob, dm, forRender, editmode); + + if (dm && dm != ndm) /* Modifier */ + dm->release (dm); + dm = ndm; + } else { + mti->deformVerts(md, ob, NULL, (float(*)[3]) allverts, totvert, forRender, editmode); + } + + if (allverts) { + fp= allverts; + for (dl=dispbase->first; dl; dl=dl->next) { + int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + memcpy(dl->verts, fp, sizeof(float) * offs); + fp+= offs; + } + MEM_freeN(allverts); } - MEM_freeN(allverts); } else { - for (dl=dispbase->first; dl; dl=dl->next) { - mti->deformVerts(md, ob, NULL, (float(*)[3]) dl->verts, (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr, forRender, editmode); + if (dm) { + float (*deformedVerts)[3] = NULL; + int numVerts; + + numVerts = dm->getNumVerts(dm); + deformedVerts = + MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv"); + dm->getVertCos(dm, deformedVerts); + + mti->deformVerts(md, ob, dm, deformedVerts, numVerts, forRender, editmode); + + CDDM_apply_vert_coords(dm, deformedVerts); + + MEM_freeN(deformedVerts); + } else { + for (dl=dispbase->first; dl; dl=dl->next) { + mti->deformVerts(md, ob, dm, (float(*)[3]) dl->verts, (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr, forRender, editmode); + } } } } + ob->derivedFinal = dm; + if (deformedVerts) { curve_applyVertexCos(ob->data, nurb, originalVerts); MEM_freeN(originalVerts); @@ -1402,6 +1449,109 @@ static void displist_surf_indices(DispList *dl) } +static DerivedMesh *create_orco_dm(Scene *scene, Object *ob) +{ + DerivedMesh *dm; + float (*orco)[3]; + + dm= CDDM_from_curve(ob); + orco= (float(*)[3])make_orco_curve(scene, ob); + + CDDM_apply_vert_coords(dm, orco); + CDDM_calc_normals(dm); + MEM_freeN(orco); + + return dm; +} + +static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh *orcodm) +{ + float (*orco)[3], (*layerorco)[3]; + int totvert, a; + Curve *cu= ob->data; + + totvert= dm->getNumVerts(dm); + + if(orcodm) { + orco= MEM_callocN(sizeof(float)*3*totvert, "dm orco"); + + if(orcodm->getNumVerts(orcodm) == totvert) + orcodm->getVertCos(orcodm, orco); + else + dm->getVertCos(dm, orco); + } + else { + orco= (float(*)[3])make_orco_curve(scene, ob); + } + + for(a=0; aloc[0])/cu->size[0]; + co[1] = (co[1]-cu->loc[1])/cu->size[1]; + co[2] = (co[2]-cu->loc[2])/cu->size[2]; + } + + if((layerorco = DM_get_vert_data_layer(dm, CD_ORCO))) { + memcpy(layerorco, orco, sizeof(float)*totvert); + MEM_freeN(orco); + } + else + DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco); +} + +static void curve_calc_orcodm(Scene *scene, Object *ob, int forRender) +{ + /* this function represents logic of mesh's orcodm calculation */ + /* for displist-based objects */ + + ModifierData *md = modifiers_getVirtualModifierList(ob); + ModifierData *preTesselatePoint; + Curve *cu= ob->data; + int required_mode; + int editmode = (!forRender && cu->editnurb); + DerivedMesh *dm= ob->derivedFinal, *ndm, *orcodm= NULL; + + if(forRender) required_mode = eModifierMode_Render; + else required_mode = eModifierMode_Realtime; + + preTesselatePoint = curve_get_tesselate_point(scene, ob, forRender, editmode); + + if(editmode) required_mode |= eModifierMode_Editmode; + + if (preTesselatePoint) { + md = preTesselatePoint->next; + } + + for (; md; md=md->next) { + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + + md->scene= scene; + + if ((md->mode & required_mode) != required_mode) continue; + if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; + if (mti->type!=eModifierTypeType_Constructive) continue; + + if(!orcodm) + orcodm= create_orco_dm(scene, ob); + + ndm = mti->applyModifier(md, ob, orcodm, forRender, 0); + + if(ndm) { + /* if the modifier returned a new dm, release the old one */ + if(orcodm && orcodm != ndm) { + orcodm->release(orcodm); + } + orcodm = ndm; + } + } + + /* add an orco layer if needed */ + add_orco_dm(scene, ob, dm, orcodm); + + if(orcodm) + orcodm->release(orcodm); +} + void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int forRender, int forOrco) { ListBase *nubase; @@ -1643,8 +1793,31 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) if(!forOrco) curve_calc_modifiers_post(scene, ob, &cu->disp, 0, originalVerts, deformedVerts); tex_space_curve(cu); } - - boundbox_displist(ob); + + if (ob->derivedFinal) { + DM_set_object_boundbox (ob, ob->derivedFinal); + } else { + boundbox_displist (ob); + } +} + +/* add Orco layer to the displist object which has got derived mesh and return orco */ +/* XXX: is it good place to keep this function here? */ +float *makeOrcoDispList(Scene *scene, Object *ob, int forRender) { + float *orco; + DerivedMesh *dm= ob->derivedFinal; + + if (!dm->getVertDataArray(dm, CD_ORCO)) { + curve_calc_orcodm(scene, ob, forRender); + } + + orco= dm->getVertDataArray(dm, CD_ORCO); + + if(orco) { + orco= MEM_dupallocN(orco); + } + + return orco; } void imagestodisplist(void) @@ -1667,7 +1840,7 @@ static void boundbox_displist(Object *ob) Curve *cu= ob->data; int doit= 0; - if(cu->bb==0) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); + if(cu->bb==0) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); bb= cu->bb; dl= cu->disp.first; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index d629acf8747..c0dd3c7e43a 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -563,31 +563,49 @@ static int vergedgesort(const void *v1, const void *v2) return 0; } -void make_edges(Mesh *me, int old) +static void mfaces_strip_loose(MFace *mface, int *totface) +{ + int a,b; + + for (a=b=0; a<*totface; a++) { + if (mface[a].v3) { + if (a!=b) { + memcpy(&mface[b],&mface[a],sizeof(mface[b])); + } + b++; + } + } + + *totface= b; +} + +/* Create edges based on known verts and faces */ +static void make_edges_mdata(MVert *allvert, MFace *allface, int totvert, int totface, + int old, MEdge **alledge, int *_totedge) { MFace *mface; MEdge *medge; struct edgesort *edsort, *ed; int a, totedge=0, final=0; - + /* we put all edges in array, sort them, and detect doubles that way */ - - for(a= me->totface, mface= me->mface; a>0; a--, mface++) { + + for(a= totface, mface= allface; a>0; a--, mface++) { if(mface->v4) totedge+=4; else if(mface->v3) totedge+=3; else totedge+=1; } - + if(totedge==0) { /* flag that mesh has edges */ - me->medge = MEM_callocN(0, "make mesh edges"); - me->totedge = 0; + (*alledge)= MEM_callocN(0, "make mesh edges"); + (*_totedge) = 0; return; } - + ed= edsort= MEM_mallocN(totedge*sizeof(struct edgesort), "edgesort"); - - for(a= me->totface, mface= me->mface; a>0; a--, mface++) { + + for(a= totface, mface= allface; a>0; a--, mface++) { to_edgesort(ed++, mface->v1, mface->v2, !mface->v3, mface->edcode & ME_V1V2); if(mface->v4) { to_edgesort(ed++, mface->v2, mface->v3, 0, mface->edcode & ME_V2V3); @@ -599,21 +617,19 @@ void make_edges(Mesh *me, int old) to_edgesort(ed++, mface->v3, mface->v1, 0, mface->edcode & ME_V3V1); } } - + qsort(edsort, totedge, sizeof(struct edgesort), vergedgesort); - + /* count final amount */ for(a=totedge, ed=edsort; a>1; a--, ed++) { /* edge is unique when it differs from next edge, or is last */ if(ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) final++; } final++; - - medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, final); - me->medge= medge; - me->totedge= final; - + (*alledge)= medge= MEM_callocN(sizeof (MEdge) * final, "make_edges mdge"); + (*_totedge)= final; + for(a=totedge, ed=edsort; a>1; a--, ed++) { /* edge is unique when it differs from next edge, or is last */ if(ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) { @@ -636,6 +652,24 @@ void make_edges(Mesh *me, int old) medge->flag |= ME_EDGERENDER; MEM_freeN(edsort); +} + +void make_edges(Mesh *me, int old) +{ + MEdge *medge; + int totedge=0; + + make_edges_mdata(me->mvert, me->mface, me->totvert, me->totface, old, &medge, &totedge); + if(totedge==0) { + /* flag that mesh has edges */ + me->medge = medge; + me->totedge = 0; + return; + } + + medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, medge, totedge); + me->medge= medge; + me->totedge= totedge; mesh_strip_loose_faces(me); } @@ -657,7 +691,6 @@ void mesh_strip_loose_faces(Mesh *me) me->totface = b; } - void mball_to_mesh(ListBase *lb, Mesh *me) { DispList *dl; @@ -711,12 +744,12 @@ void mball_to_mesh(ListBase *lb, Mesh *me) } } -/* this may fail replacing ob->data, be sure to check ob->type */ -void nurbs_to_mesh(Object *ob) +/* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ +/* return non-zero on error */ +int nurbs_to_mdata(Object *ob, MVert **allvert, int *_totvert, + MEdge **alledge, int *_totedge, MFace **allface, int *_totface) { - Object *ob1; DispList *dl; - Mesh *me; Curve *cu; MVert *mvert; MFace *mface; @@ -750,26 +783,15 @@ void nurbs_to_mesh(Object *ob) } dl= dl->next; } + if(totvert==0) { /* error("can't convert"); */ /* Make Sure you check ob->data is a curve */ - return; + return -1; } - /* make mesh */ - me= add_mesh("Mesh"); - me->totvert= totvert; - me->totface= totvlak; - - me->totcol= cu->totcol; - me->mat= cu->mat; - cu->mat= 0; - cu->totcol= 0; - - mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert); - mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface); - me->mvert= mvert; - me->mface= mface; + *allvert= mvert= MEM_callocN(sizeof (MVert) * totvert, "nurbs_init mvert"); + *allface= mface= MEM_callocN(sizeof (MVert) * totvert, "nurbs_init mface"); /* verts and faces */ vertcount= 0; @@ -777,7 +799,7 @@ void nurbs_to_mesh(Object *ob) dl= cu->disp.first; while(dl) { int smooth= dl->rt & CU_SMOOTH ? 1 : 0; - + if(dl->type==DL_SEGM) { startvert= vertcount; a= dl->parts*dl->nr; @@ -812,7 +834,7 @@ void nurbs_to_mesh(Object *ob) vertcount++; mvert++; } - + for(a=0; aparts; a++) { ofs= a*dl->nr; for(b=0; bnr; b++) { @@ -844,13 +866,13 @@ void nurbs_to_mesh(Object *ob) mface->v3= startvert+index[1]; mface->v4= 0; test_index_face(mface, NULL, 0, 3); - + if(smooth) mface->flag |= ME_SMOOTH; mface++; index+= 3; } - - + + } else if(dl->type==DL_SURF) { startvert= vertcount; @@ -893,13 +915,13 @@ void nurbs_to_mesh(Object *ob) mface->v4= p2; mface->mat_nr= (unsigned char)dl->col; test_index_face(mface, NULL, 0, 4); - + if(smooth) mface->flag |= ME_SMOOTH; mface++; - p4= p3; + p4= p3; p3++; - p2= p1; + p2= p1; p1++; } } @@ -909,15 +931,62 @@ void nurbs_to_mesh(Object *ob) dl= dl->next; } - make_edges(me, 0); // all edges - mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); + *_totvert= totvert; + *_totface= totvlak; + + make_edges_mdata(*allvert, *allface, totvert, totvlak, 0, alledge, _totedge); + mfaces_strip_loose(*allface, _totface); + + return 0; +} + +/* this may fail replacing ob->data, be sure to check ob->type */ +void nurbs_to_mesh(Object *ob) +{ + Object *ob1; + DerivedMesh *dm= ob->derivedFinal; + Mesh *me; + Curve *cu; + MVert *allvert= NULL; + MEdge *alledge= NULL; + MFace *allface= NULL; + int totvert, totedge, totface; + + cu= ob->data; + + if (dm == NULL) { + if (nurbs_to_mdata (ob, &allvert, &totvert, &alledge, &totedge, &allface, &totface) != 0) { + /* Error initializing */ + return; + } + + /* make mesh */ + me= add_mesh("Mesh"); + me->totvert= totvert; + me->totface= totface; + me->totedge= totedge; + + me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_REFERENCE, allvert, me->totvert); + me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_REFERENCE, allface, me->totface); + me->medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_REFERENCE, alledge, me->totedge); + + mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); + } else { + me= add_mesh("Mesh"); + DM_to_mesh(dm, me); + } + + me->totcol= cu->totcol; + me->mat= cu->mat; + cu->mat= 0; + cu->totcol= 0; if(ob->data) { free_libblock(&G.main->curve, ob->data); } ob->data= me; ob->type= OB_MESH; - + /* other users */ ob1= G.main->object.first; while(ob1) { @@ -929,7 +998,6 @@ void nurbs_to_mesh(Object *ob) } ob1= ob1->id.next; } - } typedef struct EdgeLink { diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 146701f2976..0c3c1e2e041 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -163,25 +163,8 @@ static DerivedMesh *get_dm(Scene *scene, Object *ob, EditMesh *em, DerivedMesh * DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob)); } else if(ELEM3(ob->type,OB_FONT,OB_CURVE,OB_SURF)) { - Object *tmpobj; - Curve *tmpcu; - if(is_last_displist(ob)) { - /* copies object and modifiers (but not the data) */ - tmpobj= copy_object(ob); - tmpcu = (Curve *)tmpobj->data; - tmpcu->id.us--; - - /* copies the data */ - tmpobj->data = copy_curve((Curve *) ob->data); - - makeDispListCurveTypes(scene, tmpobj, 1); - nurbs_to_mesh(tmpobj); - - dm = CDDM_from_mesh((Mesh*)(tmpobj->data), tmpobj); - //CDDM_calc_normals(dm); - - free_libblock_us(&G.main->object, tmpobj); + dm= CDDM_from_curve(ob); } } @@ -8605,7 +8588,8 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->flags = eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsMapping | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode; + | eModifierTypeFlag_EnableInEditmode + | eModifierTypeFlag_AcceptsCVs; mti->initData = subsurfModifier_initData; mti->copyData = subsurfModifier_copyData; mti->freeData = subsurfModifier_freeData; @@ -8635,7 +8619,8 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->flags = eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsMapping | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode; + | eModifierTypeFlag_EnableInEditmode + | eModifierTypeFlag_AcceptsCVs; mti->initData = arrayModifier_initData; mti->copyData = arrayModifier_copyData; mti->foreachObjectLink = arrayModifier_foreachObjectLink; @@ -8648,7 +8633,8 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->flags = eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsMapping | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode; + | eModifierTypeFlag_EnableInEditmode + | eModifierTypeFlag_AcceptsCVs; mti->initData = mirrorModifier_initData; mti->copyData = mirrorModifier_copyData; mti->foreachObjectLink = mirrorModifier_foreachObjectLink; @@ -8659,6 +8645,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti = INIT_TYPE(EdgeSplit); mti->type = eModifierTypeType_Constructive; mti->flags = eModifierTypeFlag_AcceptsMesh + | eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsMapping | eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode; @@ -8956,6 +8943,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti = INIT_TYPE(Solidify); mti->type = eModifierTypeType_Constructive; mti->flags = eModifierTypeFlag_AcceptsMesh + | eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsMapping | eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 2d7fc08aa74..cfebe91365e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2289,7 +2289,7 @@ BoundBox *object_get_boundbox(Object *ob) bb = mesh_get_bb(ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - bb= ( (Curve *)ob->data )->bb; + bb= ob->bb ? ob->bb : ( (Curve *)ob->data )->bb; } else if(ob->type==OB_MBALL) { bb= ob->bb; -- cgit v1.2.3 From 6fd13b904cc2bd7cde48dbd9334d1a9ececc1480 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Mar 2010 19:57:10 +0000 Subject: bug from own commit 27277, ortho wasnt being disabled in render data once set. --- source/blender/blenkernel/intern/object.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index cfebe91365e..4d4ede8a59d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2725,6 +2725,8 @@ void object_camera_matrix( float pixsize; float shiftx=0.0, shifty=0.0, winside, viewfac; + rd->mode &= ~R_ORTHO; + /* question mark */ (*ycor)= rd->yasp / rd->xasp; if(rd->mode & R_FIELDS) -- cgit v1.2.3 From 1d21d6ca9a32d68e8b2457b60d416ee370a2009e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Mar 2010 22:01:42 +0000 Subject: reproject - use render mesh settings rather then view settings. - fixed bug with brush size being overwritten and allowing non mesh objects to be projected onto. - made the paint loop less messy & minor cleanup --- source/blender/blenkernel/intern/object.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 4d4ede8a59d..7f04b20a901 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2787,8 +2787,8 @@ void object_camera_matrix( pixsize= cam->ortho_scale/viewfac; } else { - if(rd->xasp*winx >= rd->yasp*winy) viewfac= (winx*(*lens))/32.0; - else viewfac= (*ycor) * (winy*(*lens))/32.0; + if(rd->xasp*winx >= rd->yasp*winy) viewfac= ((*lens) * winx)/32.0; + else viewfac= (*ycor) * ((*lens) * winy)/32.0; pixsize= (*clipsta) / viewfac; } @@ -2801,20 +2801,20 @@ void object_camera_matrix( if(field_second) { if(rd->mode & R_ODDFIELD) { - viewplane->ymin-= .5 * (*ycor); - viewplane->ymax-= .5 * (*ycor); + viewplane->ymin-= 0.5 * (*ycor); + viewplane->ymax-= 0.5 * (*ycor); } else { - viewplane->ymin+= .5* (*ycor); - viewplane->ymax+= .5* (*ycor); + viewplane->ymin+= 0.5 * (*ycor); + viewplane->ymax+= 0.5 * (*ycor); } } /* the window matrix is used for clipping, and not changed during OSA steps */ /* using an offset of +0.5 here would give clip errors on edges */ - viewplane->xmin= pixsize*(viewplane->xmin); - viewplane->xmax= pixsize*(viewplane->xmax); - viewplane->ymin= pixsize*(viewplane->ymin); - viewplane->ymax= pixsize*(viewplane->ymax); + viewplane->xmin *= pixsize; + viewplane->xmax *= pixsize; + viewplane->ymin *= pixsize; + viewplane->ymax *= pixsize; (*viewdx)= pixsize; (*viewdy)= (*ycor) * pixsize; -- cgit v1.2.3 From e3c10b9d08f20c68d1883b58e5be5de3c3867f2a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 6 Mar 2010 10:22:27 +0000 Subject: Fixed memory leak caused by incorrect adding data to mesh's layer in nurbs_to_mesh(). --- source/blender/blenkernel/intern/mesh.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index c0dd3c7e43a..03c9af26555 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -966,9 +966,9 @@ void nurbs_to_mesh(Object *ob) me->totface= totface; me->totedge= totedge; - me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_REFERENCE, allvert, me->totvert); - me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_REFERENCE, allface, me->totface); - me->medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_REFERENCE, alledge, me->totedge); + me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, allvert, me->totvert); + me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, allface, me->totface); + me->medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, alledge, me->totedge); mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); } else { -- cgit v1.2.3 From c0f56503bf6fcd92a65a8b05466c5093e083c96a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Mar 2010 18:21:57 +0000 Subject: disallow naming ID datablocks an empty string, this wont work, you cant select them in the ID user input and it can mess up writing files based on names. also fixed some warnings. --- source/blender/blenkernel/BKE_library.h | 4 +++- source/blender/blenkernel/intern/library.c | 37 ++++++++++++++++-------------- 2 files changed, 23 insertions(+), 18 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index b859dbe6f51..454666566dc 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -51,7 +51,6 @@ int id_make_local(struct ID *id, int test); int id_copy(struct ID *id, struct ID **newid, int test); int id_unlink(struct ID *id, int test); -int check_for_dupid(struct ListBase *lb, struct ID *id, char *name); int new_id(struct ListBase *lb, struct ID *id, const char *name); struct ListBase *wich_libbase(struct Main *mainlib, short type); @@ -82,5 +81,8 @@ void recalc_all_library_objects(struct Main *main); void set_free_windowmanager_cb(void (*func)(struct bContext *, struct wmWindowManager *) ); +/* use when "" is given to new_id() */ +#define ID_FALLBACK_NAME "Untitled" + #endif diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 3ea36450b80..79bc92bdbfb 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1093,15 +1093,16 @@ static ID *is_dupid(ListBase *lb, ID *id, char *name) * id is NULL; */ -int check_for_dupid(ListBase *lb, ID *id, char *name) +static int check_for_dupid(ListBase *lb, ID *id, char *name) { ID *idtest; int nr= 0, nrtest, a; const int maxtest=32; char left[32], leftest[32], in_use[32]; - + /* make sure input name is terminated properly */ - if( strlen(name) > 21 ) name[21]= 0; + /* if( strlen(name) > 21 ) name[21]= 0; */ + /* removed since this is only ever called from one place - campbell */ while (1) { @@ -1184,27 +1185,29 @@ int new_id(ListBase *lb, ID *id, const char *tname) { int result; char name[22]; - + /* if library, don't rename */ 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(tname==0) { /* if no name given, use name of current ID */ - strncpy(name, id->name+2, 21); - result= strlen(id->name+2); - } - else { /* else make a copy (tname args can be const) */ - strncpy(name, tname, 21); - result= strlen(tname); - } + /* if no name given, use name of current ID + * else make a copy (tname args can be const) */ + if(tname==NULL) + tname= id->name+2; + + strncpy(name, tname, sizeof(name)-1); + + /* if result > 21, strncpy don't put the final '\0' to name. + * easier to assign each time then to check if its needed */ + name[sizeof(name)-1]= 0; - /* if result > 21, strncpy don't put the final '\0' to name. */ - if( result >= 21 ) name[21]= 0; + if(name[0] == '\0') + strcpy(name, ID_FALLBACK_NAME); - result = check_for_dupid( lb, id, name ); - strcpy( id->name+2, name ); + result = check_for_dupid(lb, id, name); + strcpy(id->name+2, name); /* This was in 2.43 and previous releases * however all data in blender should be sorted, not just duplicate names @@ -1393,7 +1396,7 @@ void text_idbutton(struct ID *id, char *text) void rename_id(ID *id, char *name) { ListBase *lb; - + strncpy(id->name+2, name, 21); lb= wich_libbase(G.main, GS(id->name) ); -- cgit v1.2.3 From 782cb1f0e0d9c019bfb7b9391ffa4b827ed1aa6f Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 6 Mar 2010 21:45:46 +0000 Subject: Tab as Space as a User Preference option. to affect new and loaded text files. * I put it under General->System. Not sure is the better place for it though (space_userpref.py) ** also: creator.c fix to avoid autoplay of games when scripts are disabled. --- source/blender/blenkernel/intern/text.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 4dcc26827d0..c28f4fde8ed 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -190,7 +190,9 @@ Text *add_empty_text(char *name) init_undo_text(ta); ta->nlines=1; - ta->flags= TXT_ISDIRTY | TXT_ISMEM | TXT_TABSTOSPACES; + ta->flags= TXT_ISDIRTY | TXT_ISMEM; + if(U.flag & USER_TXT_TABSTOSPACES) + ta->flags |= TXT_TABSTOSPACES; ta->lines.first= ta->lines.last= NULL; ta->markers.first= ta->markers.last= NULL; @@ -354,9 +356,10 @@ Text *add_text(char *file, const char *relpath) ta->lines.first= ta->lines.last= NULL; ta->markers.first= ta->markers.last= NULL; ta->curl= ta->sell= NULL; - - ta->flags= TXT_TABSTOSPACES; - + + if(U.flag & USER_TXT_TABSTOSPACES) + ta->flags= TXT_TABSTOSPACES; + fseek(fp, 0L, SEEK_END); len= ftell(fp); fseek(fp, 0L, SEEK_SET); -- cgit v1.2.3 From 26fae8985bbc754325a15a77ca20a63a9669b2dd Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 6 Mar 2010 22:12:42 +0000 Subject: flipping "tab as space" option (so it's on by default - argh ;) (and fix error in creator.c last commit) --- source/blender/blenkernel/intern/text.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index c28f4fde8ed..b58caf14293 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -191,7 +191,7 @@ Text *add_empty_text(char *name) ta->nlines=1; ta->flags= TXT_ISDIRTY | TXT_ISMEM; - if(U.flag & USER_TXT_TABSTOSPACES) + if((U.flag & USER_TXT_TABSTOSPACES_DISABLE)==0) ta->flags |= TXT_TABSTOSPACES; ta->lines.first= ta->lines.last= NULL; @@ -357,7 +357,7 @@ Text *add_text(char *file, const char *relpath) ta->markers.first= ta->markers.last= NULL; ta->curl= ta->sell= NULL; - if(U.flag & USER_TXT_TABSTOSPACES) + if((U.flag & USER_TXT_TABSTOSPACES_DISABLE)==0) ta->flags= TXT_TABSTOSPACES; fseek(fp, 0L, SEEK_END); -- cgit v1.2.3 From c3c16603d26e7a25ebb578b91ca9a80596657ebd Mon Sep 17 00:00:00 2001 From: Jens Ole Wund Date: Sun, 7 Mar 2010 00:11:40 +0000 Subject: No code chanced .. just tagging hot spots for 2.5 paradigm 'animate everything' --- source/blender/blenkernel/intern/softbody.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index f3d69cc458a..343d11a2f34 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3242,6 +3242,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) /* we always make body points */ sb= ob->soft; bp= sb->bpoint; + /* should go to sb->scratch so we can pick it up at frame level thanks_a_TON*/ goalfac= ABS(sb->maxgoal - sb->mingoal); for(a=0; atotvert; a++, bp++) { @@ -3251,13 +3252,19 @@ static void mesh_to_softbody(Scene *scene, Object *ob) which can be done by caller but still .. i'd like it to go this way */ - if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { + if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { /* even this is a deprecated evil hack */ + /* I'd like to have it .. if (sb->namedVG_Goal[0]) */ + get_scalar_from_vertexgroup(ob, a,(short) (sb->vertgroup-1), &bp->goal); /* do this always, regardless successfull read from vertex group */ - bp->goal= sb->mingoal + bp->goal*goalfac; + /* this is where '2.5 every thing is animateable' goes wrong in the first place thanks_a_TON */ + /* don't ask me for evidence .. i might track to the very commit */ + /* 1st coding action to take : move this to frame level */ + /* reads: leave the bp->goal as it was read from vertex group / or default .. we will need it at per frame call */ + bp->goal= sb->mingoal + bp->goal*goalfac; /* do not do here thanks_a_TON */ } /* a little ad hoc changing the goal control to be less *sharp* */ - bp->goal = (float)pow(bp->goal, 4.0f); + bp->goal = (float)pow(bp->goal, 4.0f);/* do not do here thanks_a_TON */ /* to proove the concept this would enable per vertex *mass painting* -- cgit v1.2.3 From 3ad1bfa69e8cbffc0c60c322c1e084840aa6aaa6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 7 Mar 2010 05:04:22 +0000 Subject: Fix for convert_exec() "Keep original" option now works for all objects' types --- source/blender/blenkernel/intern/mesh.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 03c9af26555..2a6fc281624 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1036,7 +1036,7 @@ void mesh_to_curve(Scene *scene, Object *ob) int totedge = dm->getNumEdges(dm); int totface = dm->getNumFaces(dm); int totedges = 0; - int i; + int i, needsFree = 0; /* only to detect edge polylines */ EdgeHash *eh = BLI_edgehash_new(); @@ -1176,9 +1176,17 @@ void mesh_to_curve(Scene *scene, Object *ob) ((Mesh *)ob->data)->id.us--; ob->data= cu; ob->type= OB_CURVE; + + /* curve objects can't contain DM in usual cases, we could free memory */ + needsFree= 1; } + dm->needsFree = needsFree; dm->release(dm); + + if (needsFree) { + ob->derivedFinal = NULL; + } } void mesh_delete_material_index(Mesh *me, int index) -- cgit v1.2.3 From 8d53f3f04edc809ab0777d94b3b17b4b38a253f7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 7 Mar 2010 10:40:52 +0000 Subject: Enable "Build" modifier for curves/surfaces. --- source/blender/blenkernel/intern/displist.c | 20 ++++++++++---------- source/blender/blenkernel/intern/modifier.c | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index b8b5ae300d9..9f6f2e445fc 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1329,23 +1329,23 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba for (; md; md=md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - + + /* modifier depends on derived mesh and has got valid applyModifier call */ + int dmApplyMod = mti->type==eModifierTypeType_Constructive || + mti->type==eModifierTypeType_Nonconstructive; + md->scene= scene; - + if ((md->mode & required_mode) != required_mode) continue; if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if (mti->type!=eModifierTypeType_OnlyDeform && - mti->type!=eModifierTypeType_DeformOrConstruct && - mti->type!=eModifierTypeType_Constructive) continue; /* need to put all verts in 1 block for curve deform */ - /* we also need all verts in 1 block for derived mesh creation when handling constructive modifiers */ - if(md->type==eModifierType_Curve || mti->type==eModifierTypeType_Constructive) { + /* we also need all verts in 1 block for derived mesh creation */ + if(md->type==eModifierType_Curve || dmApplyMod) { float *allverts = NULL, *fp; int totvert= 0; - if (md->type==eModifierType_Curve || - (mti->type==eModifierTypeType_Constructive && !dm)) { + if (md->type==eModifierType_Curve || (dmApplyMod && !dm)) { for (dl=dispbase->first; dl; dl=dl->next) totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr; @@ -1357,7 +1357,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } } - if (mti->type==eModifierTypeType_Constructive) { + if (dmApplyMod) { if (!dm) { dm= CDDM_from_curve(ob); /* diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 0c3c1e2e041..601bee4f670 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -8599,7 +8599,8 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti = INIT_TYPE(Build); mti->type = eModifierTypeType_Nonconstructive; - mti->flags = eModifierTypeFlag_AcceptsMesh; + mti->flags = eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs; mti->initData = buildModifier_initData; mti->copyData = buildModifier_copyData; mti->dependsOnTime = buildModifier_dependsOnTime; -- cgit v1.2.3 From 3b105657d50bdcc2dfaf574ac3a5ad4f22b8b237 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Mar 2010 09:06:58 +0000 Subject: option to transform markers in the dope sheet, needed for re-timing animation. currently supports translate and extend. TODO: - select markers in dope sheet. - transform time scale. --- source/blender/blenkernel/BKE_scene.h | 2 ++ source/blender/blenkernel/intern/scene.c | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 5e5131f9ccc..d1b4e5aef1a 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -70,6 +70,8 @@ struct Object *scene_find_camera_switch(struct Scene *scene); // DURIAN_CAMERA_S char *scene_find_marker_name(struct Scene *scene, int frame); char *scene_find_last_marker_name(struct Scene *scene, int frame); +int scene_marker_tfm_translate(struct Scene *scene, int delta, int flag); +int scene_marker_tfm_extend(struct Scene *scene, int delta, int flag, int frame, char side); struct Base *scene_add_base(struct Scene *sce, struct Object *ob); void scene_deselect_all(struct Scene *sce); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 77b1202aa20..630ddb49c7e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -783,6 +783,39 @@ char *scene_find_last_marker_name(Scene *scene, int frame) return best_marker ? best_marker->name : NULL; } +/* markers need transforming from different parts of the code so have + * a generic function to do this */ +int scene_marker_tfm_translate(Scene *scene, int delta, int flag) +{ + TimeMarker *marker; + int tot= 0; + + for (marker= scene->markers.first; marker; marker= marker->next) { + if ((marker->flag & flag) == flag) { + marker->frame += delta; + tot++; + } + } + + return tot; +} + +int scene_marker_tfm_extend(Scene *scene, int delta, int flag, int frame, char side) +{ + TimeMarker *marker; + int tot= 0; + + for (marker= scene->markers.first; marker; marker= marker->next) { + if ((marker->flag & flag) == flag) { + if((side=='L' && marker->frame < frame) || (side=='R' && marker->frame > frame)) { + marker->frame += delta; + tot++; + } + } + } + + return tot; +} Base *scene_add_base(Scene *sce, Object *ob) { -- cgit v1.2.3 From 3ddbd2abe54fed5a30de12e023b1461a46ac26f1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Mar 2010 10:05:51 +0000 Subject: Fixed segmentation fault error when entering curve's edit mode when there is sufsurf modifier first in the stack. Some optimizations in curve_calc_modifiers_post(): - Calculate allverts array only for curve modifier applying to curve without derived mesh. - Do not calculate deformedVerts array each time deformation modifier is applying to derived mesh. --- source/blender/blenkernel/intern/displist.c | 115 ++++++++++++++++------------ 1 file changed, 66 insertions(+), 49 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 9f6f2e445fc..3b284b8574b 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1311,6 +1311,8 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba int required_mode; int editmode = (!forRender && cu->editnurb); DerivedMesh *dm= NULL, *ndm; + float (*dmDeformedVerts)[3] = NULL; + int numVerts; if(forRender) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; @@ -1330,52 +1332,27 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba for (; md; md=md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - /* modifier depends on derived mesh and has got valid applyModifier call */ - int dmApplyMod = mti->type==eModifierTypeType_Constructive || - mti->type==eModifierTypeType_Nonconstructive; - md->scene= scene; if ((md->mode & required_mode) != required_mode) continue; if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - /* need to put all verts in 1 block for curve deform */ - /* we also need all verts in 1 block for derived mesh creation */ - if(md->type==eModifierType_Curve || dmApplyMod) { + if(md->type==eModifierType_Curve && !dm) { + /* need to put all verts in 1 block for curve deform */ float *allverts = NULL, *fp; int totvert= 0; - if (md->type==eModifierType_Curve || (dmApplyMod && !dm)) { - for (dl=dispbase->first; dl; dl=dl->next) - totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr; + for (dl=dispbase->first; dl; dl=dl->next) + totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr; - fp= allverts= MEM_mallocN(totvert*sizeof(float)*3, "temp vert"); - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); - memcpy(fp, dl->verts, sizeof(float) * offs); - fp+= offs; - } + fp= allverts= MEM_mallocN(totvert*sizeof(float)*3, "temp vert"); + for (dl=dispbase->first; dl; dl=dl->next) { + int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + memcpy(fp, dl->verts, sizeof(float) * offs); + fp+= offs; } - if (dmApplyMod) { - if (!dm) { - dm= CDDM_from_curve(ob); - /* - * TODO: Maybe we should apply deformedVerts? - * But for now it causes invalid working of SoftBody modifier - */ - CDDM_apply_vert_coords(dm, (float(*)[3]) allverts); - CDDM_calc_normals(dm); - } - - ndm = mti->applyModifier(md, ob, dm, forRender, editmode); - - if (dm && dm != ndm) /* Modifier */ - dm->release (dm); - dm = ndm; - } else { - mti->deformVerts(md, ob, NULL, (float(*)[3]) allverts, totvert, forRender, editmode); - } + mti->deformVerts(md, ob, NULL, (float(*)[3]) allverts, totvert, forRender, editmode); if (allverts) { fp= allverts; @@ -1386,30 +1363,70 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } MEM_freeN(allverts); } - } - else { + } else if (mti->type == eModifierTypeType_OnlyDeform || + (mti->type == eModifierTypeType_DeformOrConstruct && !dm)) { if (dm) { - float (*deformedVerts)[3] = NULL; - int numVerts; - - numVerts = dm->getNumVerts(dm); - deformedVerts = - MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv"); - dm->getVertCos(dm, deformedVerts); - - mti->deformVerts(md, ob, dm, deformedVerts, numVerts, forRender, editmode); - - CDDM_apply_vert_coords(dm, deformedVerts); + if (!dmDeformedVerts) { + numVerts = dm->getNumVerts(dm); + dmDeformedVerts = + MEM_mallocN(sizeof(*dmDeformedVerts) * numVerts, "dfmv"); + dm->getVertCos(dm, dmDeformedVerts); + } - MEM_freeN(deformedVerts); + mti->deformVerts(md, ob, dm, dmDeformedVerts, numVerts, forRender, editmode); } else { for (dl=dispbase->first; dl; dl=dl->next) { mti->deformVerts(md, ob, dm, (float(*)[3]) dl->verts, (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr, forRender, editmode); } } + } else { + if (dm) { + if (dmDeformedVerts) { + DerivedMesh *tdm = CDDM_copy(dm); + dm->release(dm); + dm = tdm; + + CDDM_apply_vert_coords(dm, dmDeformedVerts); + CDDM_calc_normals(dm); + } + } else { + dm= CDDM_from_curve(ob); + + if(dmDeformedVerts) { + CDDM_apply_vert_coords(dm, dmDeformedVerts); + CDDM_calc_normals(dm); + } + + CDDM_calc_normals(dm); + } + + ndm = mti->applyModifier(md, ob, dm, forRender, editmode); + + if (ndm) { + /* Modifier returned a new derived mesh */ + + if (dm && dm != ndm) /* Modifier */ + dm->release (dm); + dm = ndm; + + if (dmDeformedVerts) { + MEM_freeN(dmDeformedVerts); + dmDeformedVerts= NULL; + } + } } } + if(dm && dmDeformedVerts) { + DerivedMesh *tdm = CDDM_copy(dm); + dm->release(dm); + dm = tdm; + + CDDM_apply_vert_coords(dm, dmDeformedVerts); + CDDM_calc_normals(dm); + MEM_freeN(dmDeformedVerts); + } + ob->derivedFinal = dm; if (deformedVerts) { -- cgit v1.2.3 From 57eac3b3e3fdf156c6cd043ca93c4d4b90acabad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Mar 2010 11:10:04 +0000 Subject: Ctrl+RMB support for selecting markers when sync markers is enabled. --- source/blender/blenkernel/intern/scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 630ddb49c7e..ca5efbef053 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -807,7 +807,7 @@ int scene_marker_tfm_extend(Scene *scene, int delta, int flag, int frame, char s for (marker= scene->markers.first; marker; marker= marker->next) { if ((marker->flag & flag) == flag) { - if((side=='L' && marker->frame < frame) || (side=='R' && marker->frame > frame)) { + if((side=='L' && marker->frame < frame) || (side=='R' && marker->frame >= frame)) { marker->frame += delta; tot++; } -- cgit v1.2.3 From 838842581cdae1030a0e49a80792a39c303a7a80 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Mar 2010 13:49:13 +0000 Subject: - Fixed trouble with rendering curves with disabled modifiers, which are disabled for realtime displaying but enabled for rendering. - Calculate tex space for curves before modifiers applying. --- source/blender/blenkernel/BKE_cdderivedmesh.h | 4 + source/blender/blenkernel/BKE_displist.h | 6 +- source/blender/blenkernel/BKE_mesh.h | 3 + source/blender/blenkernel/intern/cdderivedmesh.c | 9 +- source/blender/blenkernel/intern/curve.c | 17 ++-- source/blender/blenkernel/intern/displist.c | 101 ++++++++++++++--------- source/blender/blenkernel/intern/mesh.c | 15 +++- 7 files changed, 99 insertions(+), 56 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h index 77a8ef518e9..33e8f930c9d 100644 --- a/source/blender/blenkernel/BKE_cdderivedmesh.h +++ b/source/blender/blenkernel/BKE_cdderivedmesh.h @@ -57,6 +57,10 @@ struct DerivedMesh *CDDM_from_editmesh(struct EditMesh *em, struct Mesh *me); /* creates a CDDerivedMesh from the given curve object */ struct DerivedMesh *CDDM_from_curve(struct Object *ob); +/* creates a CDDerivedMesh from the given curve object and specified dispbase */ +/* useful for OrcoDM creation for curves with constructive modifiers */ +DerivedMesh *CDDM_from_curve_customDB(struct Object *ob, struct ListBase *dispbase); + /* Copies the given DerivedMesh with verts, faces & edges stored as * custom element data. */ diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 2baefc83678..e685dd90223 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -87,8 +87,10 @@ extern void count_displist(struct ListBase *lb, int *totvert, int *totface); extern void freedisplist(struct ListBase *lb); extern int displist_has_faces(struct ListBase *lb); -extern void makeDispListSurf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, int forRender, int forOrco); +extern void makeDispListSurf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forRender, int forOrco); extern void makeDispListCurveTypes(struct Scene *scene, struct Object *ob, int forOrco); +extern void makeDispListCurveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forOrco); +extern void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); extern void makeDispListMBall(struct Scene *scene, struct Object *ob); extern void shadeDispList(struct Scene *scene, struct Base *base); extern void shadeMeshMCol(struct Scene *scene, struct Object *ob, struct Mesh *me); @@ -103,7 +105,7 @@ void fastshade_free_render(void); float calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); /* add Orco layer to the displist object which has got derived mesh and return orco */ -float *makeOrcoDispList(struct Scene *scene, struct Object *ob, int forRender); +float *makeOrcoDispList(struct Scene *scene, struct Object *ob, struct DerivedMesh *derivedFinal, int forRender); #endif diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index a82e3ffe45b..3b6cf8803d8 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -72,6 +72,9 @@ void set_mesh(struct Object *ob, struct Mesh *me); void mball_to_mesh(struct ListBase *lb, struct Mesh *me); int nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *_totvert, struct MEdge **alledge, int *_totedge, struct MFace **allface, int *_totface); +int nurbs_to_mdata_customdb(struct Object *ob, struct ListBase *dispbase, + struct MVert **allvert, int *_totvert, struct MEdge **alledge, int *_totedge, + struct MFace **allface, int *_totface); void nurbs_to_mesh(struct Object *ob); void mesh_to_curve(struct Scene *scene, struct Object *ob); void free_dverts(struct MDeformVert *dvert, int totvert); diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index d0e50dc97a8..347a501dfcc 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -57,6 +57,7 @@ #include "DNA_object_fluidsim.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_curve_types.h" /* for Curve */ #include "MEM_guardedalloc.h" @@ -1586,6 +1587,11 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *me) } DerivedMesh *CDDM_from_curve(Object *ob) +{ + return CDDM_from_curve_customDB(ob, &((Curve *)ob->data)->disp); +} + +DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase) { DerivedMesh *dm; CDDerivedMesh *cddm; @@ -1594,7 +1600,8 @@ DerivedMesh *CDDM_from_curve(Object *ob) MFace *allface; int totvert, totedge, totface; - if (nurbs_to_mdata (ob, &allvert, &totvert, &alledge, &totedge, &allface, &totface) != 0) { + if (nurbs_to_mdata_customdb(ob, dispbase, &allvert, &totvert, &alledge, + &totedge, &allface, &totface) != 0) { /* Error initializing mdata. This often happens when curve is empty */ return CDDM_new(0, 0, 0); } diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index fb27327c3be..2430e417e51 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1099,17 +1099,12 @@ float *make_orco_curve(Scene *scene, Object *ob) DispList *dl; int u, v, numVerts; float *fp, *coord_array; - int remakeDisp = 0; + ListBase disp = {NULL, NULL}; - if (!(cu->flag&CU_UV_ORCO) && cu->key && cu->key->block.first) { - makeDispListCurveTypes(scene, ob, 1); - remakeDisp = 1; - } - - /* Assumes displist has been built */ + makeDispListCurveTypes_forOrco(scene, ob, &disp); numVerts = 0; - for (dl=cu->disp.first; dl; dl=dl->next) { + for (dl=disp.first; dl; dl=dl->next) { if (dl->type==DL_INDEX3) { numVerts += dl->nr; } else if (dl->type==DL_SURF) { @@ -1126,7 +1121,7 @@ float *make_orco_curve(Scene *scene, Object *ob) } fp= coord_array= MEM_mallocN(3*sizeof(float)*numVerts, "cu_orco"); - for (dl=cu->disp.first; dl; dl=dl->next) { + for (dl=disp.first; dl; dl=dl->next) { if (dl->type==DL_INDEX3) { for (u=0; unr; u++, fp+=3) { if (cu->flag & CU_UV_ORCO) { @@ -1174,9 +1169,7 @@ float *make_orco_curve(Scene *scene, Object *ob) } } - if (remakeDisp) { - makeDispListCurveTypes(scene, ob, 0); - } + freedisplist(&disp); return coord_array; } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 3b284b8574b..ee746a4dacd 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1280,7 +1280,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl deformedVerts = curve_getVertexCos(cu, nurb, &numVerts); originalVerts = MEM_dupallocN(deformedVerts); } - + mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, forRender, editmode); if (md==preTesselatePoint) @@ -1292,7 +1292,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl curve_applyVertexCos(cu, nurb, deformedVerts); if (keyVerts) /* these are not passed through modifier stack */ curve_applyKeyVertexTilts(cu, nurb, keyVerts); - + if(keyVerts) MEM_freeN(keyVerts); @@ -1301,7 +1301,8 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl *numVerts_r = numVerts; } -static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) +static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, + DerivedMesh **derivedFinal, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *preTesselatePoint; @@ -1325,8 +1326,8 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba md = preTesselatePoint->next; } - if (ob->derivedFinal) { - ob->derivedFinal->release (ob->derivedFinal); + if (*derivedFinal) { + (*derivedFinal)->release (*derivedFinal); } for (; md; md=md->next) { @@ -1427,7 +1428,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba MEM_freeN(dmDeformedVerts); } - ob->derivedFinal = dm; + (*derivedFinal) = dm; if (deformedVerts) { curve_applyVertexCos(ob->data, nurb, originalVerts); @@ -1469,14 +1470,13 @@ static void displist_surf_indices(DispList *dl) static DerivedMesh *create_orco_dm(Scene *scene, Object *ob) { DerivedMesh *dm; - float (*orco)[3]; + ListBase disp= {NULL, NULL}; - dm= CDDM_from_curve(ob); - orco= (float(*)[3])make_orco_curve(scene, ob); + /* OrcoDM should be created from underformed disp lists */ + makeDispListCurveTypes_forOrco(scene, ob, &disp); + dm= CDDM_from_curve_customDB(ob, &disp); - CDDM_apply_vert_coords(dm, orco); - CDDM_calc_normals(dm); - MEM_freeN(orco); + freedisplist(&disp); return dm; } @@ -1516,7 +1516,7 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco); } -static void curve_calc_orcodm(Scene *scene, Object *ob, int forRender) +static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) { /* this function represents logic of mesh's orcodm calculation */ /* for displist-based objects */ @@ -1526,7 +1526,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, int forRender) Curve *cu= ob->data; int required_mode; int editmode = (!forRender && cu->editnurb); - DerivedMesh *dm= ob->derivedFinal, *ndm, *orcodm= NULL; + DerivedMesh *ndm, *orcodm= NULL; if(forRender) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; @@ -1563,13 +1563,14 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, int forRender) } /* add an orco layer if needed */ - add_orco_dm(scene, ob, dm, orcodm); + add_orco_dm(scene, ob, derivedFinal, orcodm); if(orcodm) orcodm->release(orcodm); } -void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int forRender, int forOrco) +void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, + DerivedMesh **derivedFinal, int forRender, int forOrco) { ListBase *nubase; Nurb *nu; @@ -1642,23 +1643,20 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int forRende } if(!forOrco) - curve_calc_modifiers_post(scene, ob, dispbase, forRender, originalVerts, deformedVerts); + curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, + forRender, originalVerts, deformedVerts); } -void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) +static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase, + DerivedMesh **derivedFinal, int forRender, int forOrco) { Curve *cu = ob->data; - ListBase *dispbase; - + /* we do allow duplis... this is only displist on curve level */ if(!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; - freedisplist(&(ob->disp)); - dispbase= &(cu->disp); - freedisplist(dispbase); - if(ob->type==OB_SURF) { - makeDispListSurf(scene, ob, dispbase, 0, forOrco); + makeDispListSurf(scene, ob, dispbase, derivedFinal, forRender, forOrco); } else if (ELEM(ob->type, OB_CURVE, OB_FONT)) { ListBase dlbev; @@ -1671,15 +1669,15 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) nubase= cu->editnurb; else nubase= &cu->nurb; - + BLI_freelistN(&(cu->bev)); - + if(cu->path) free_path(cu->path); cu->path= NULL; - + if(ob->type==OB_FONT) BKE_text_to_curve(scene, ob, 0); - - if(!forOrco) curve_calc_modifiers_pre(scene, ob, 0, &originalVerts, &deformedVerts, &numVerts); + + if(!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); makeBevelList(ob); @@ -1807,9 +1805,24 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) if(cu->flag & CU_PATH) calc_curvepath(ob); - if(!forOrco) curve_calc_modifiers_post(scene, ob, &cu->disp, 0, originalVerts, deformedVerts); - tex_space_curve(cu); + if (!forRender) { + tex_space_curve(cu); + } + + if(!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); } +} + +void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) +{ + Curve *cu = ob->data; + ListBase *dispbase; + + freedisplist(&(ob->disp)); + dispbase= &(cu->disp); + freedisplist(dispbase); + + do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco); if (ob->derivedFinal) { DM_set_object_boundbox (ob, ob->derivedFinal); @@ -1818,17 +1831,29 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) } } +void makeDispListCurveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase, + DerivedMesh **derivedFinal, int forOrco) +{ + do_makeDispListCurveTypes(scene, ob, dispbase, derivedFinal, 1, forOrco); +} + +void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase) +{ + do_makeDispListCurveTypes(scene, ob, dispbase, NULL, 1, 1); +} + /* add Orco layer to the displist object which has got derived mesh and return orco */ -/* XXX: is it good place to keep this function here? */ -float *makeOrcoDispList(Scene *scene, Object *ob, int forRender) { +float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) { float *orco; - DerivedMesh *dm= ob->derivedFinal; - if (!dm->getVertDataArray(dm, CD_ORCO)) { - curve_calc_orcodm(scene, ob, forRender); + if (derivedFinal == NULL) + derivedFinal= ob->derivedFinal; + + if (!derivedFinal->getVertDataArray(derivedFinal, CD_ORCO)) { + curve_calc_orcodm(scene, ob, derivedFinal, forRender); } - orco= dm->getVertDataArray(dm, CD_ORCO); + orco= derivedFinal->getVertDataArray(derivedFinal, CD_ORCO); if(orco) { orco= MEM_dupallocN(orco); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 2a6fc281624..b7efc0c626b 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -746,7 +746,16 @@ void mball_to_mesh(ListBase *lb, Mesh *me) /* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ /* return non-zero on error */ -int nurbs_to_mdata(Object *ob, MVert **allvert, int *_totvert, +int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, + MEdge **alledge, int *totedge, MFace **allface, int *totface) +{ + return nurbs_to_mdata_customdb(ob, &((Curve *)ob->data)->disp, + allvert, totvert, alledge, totedge, allface, totface); +} + +/* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ +/* use specified dispbase */ +int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int *_totvert, MEdge **alledge, int *_totedge, MFace **allface, int *_totface) { DispList *dl; @@ -760,7 +769,7 @@ int nurbs_to_mdata(Object *ob, MVert **allvert, int *_totvert, cu= ob->data; /* count */ - dl= cu->disp.first; + dl= dispbase->first; while(dl) { if(dl->type==DL_SEGM) { totvert+= dl->parts*dl->nr; @@ -796,7 +805,7 @@ int nurbs_to_mdata(Object *ob, MVert **allvert, int *_totvert, /* verts and faces */ vertcount= 0; - dl= cu->disp.first; + dl= dispbase->first; while(dl) { int smooth= dl->rt & CU_SMOOTH ? 1 : 0; -- cgit v1.2.3 From 657e02106a48baf8c8c1525909907b87b6ee845e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 8 Mar 2010 15:21:39 +0000 Subject: Depsgraph: always execute scene camera as if it was on a visible layer, because even if it is not it can still affect the 3d view or render. --- source/blender/blenkernel/intern/depsgraph.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 0c9248c1eb9..c59569d88f1 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1925,15 +1925,33 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) sce->theDag->time++; // so we know which nodes were accessed lasttime= sce->theDag->time; - + /* update layer flags in nodes */ for(base= sce->base.first; base; base= base->next) { node= dag_get_node(sce->theDag, base->object); - if(node) - node->scelay= base->object->lay; - else - node->scelay= 0; + node->scelay= base->object->lay; + } + + /* ensure cameras are set as if they are on a visible layer, because + they ared still used for rendering or setting the camera view */ + if(sce->camera) { + node= dag_get_node(sce->theDag, sce->camera); + node->scelay= lay; } +#ifdef DURIAN_CAMERA_SWITCH + { + TimeMarker *m; + + for(m= sce->markers.first; m; m= m->next) { + if(m->camera) { + node= dag_get_node(sce->theDag, m->camera); + node->scelay= lay; + } + } + } +#endif + + /* flush layer nodes to dependencies */ for(itA = firstnode->child; itA; itA= itA->next) if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB) flush_layer_node(sce, itA->node, lasttime); -- cgit v1.2.3 From 23cfce769153be3ca990e1b11732738620192b5b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 8 Mar 2010 15:38:10 +0000 Subject: Depsgraph: more tweaks to last commit to get it actually working int more complex files. --- source/blender/blenkernel/intern/depsgraph.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index c59569d88f1..155cc2af05e 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1780,7 +1780,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) ob= node->ob; if(ob && (ob->recalc & OB_RECALC)) { - all_layer= ob->lay; + all_layer= node->scelay; /* got an object node that changes, now check relations */ for(itA = node->child; itA; itA= itA->next) { @@ -1935,7 +1935,7 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) they ared still used for rendering or setting the camera view */ if(sce->camera) { node= dag_get_node(sce->theDag, sce->camera); - node->scelay= lay; + node->scelay |= lay; } #ifdef DURIAN_CAMERA_SWITCH @@ -1945,7 +1945,7 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) for(m= sce->markers.first; m; m= m->next) { if(m->camera) { node= dag_get_node(sce->theDag, m->camera); - node->scelay= lay; + node->scelay |= lay; } } } -- cgit v1.2.3 From b356eb6a8bfad738028e67844c7755f5684f7ce3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Mar 2010 20:08:04 +0000 Subject: image re-project now uses offscreen render function and has input for render size. unrelated changes that ended up being more trouble to commit separate... - removed BLI_split_dirfile(), was nasty, occasionaly modifying the source string, it could create directories and used the $CWD in some cases. was only used in 2 places in filesel.c, if this gives problems can address without bringing back this function. renamed BLI_split_dirfile_basic --> BLI_split_dirfile - view3d_operator_needs_opengl was being called for offscreen render when it wasnt needed. --- source/blender/blenkernel/BKE_displist.h | 1 + source/blender/blenkernel/BKE_image.h | 2 + source/blender/blenkernel/intern/image.c | 21 ++++- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 119 ++++++++++++++------------ source/blender/blenkernel/intern/sound.c | 2 + source/blender/blenkernel/intern/text.c | 4 +- 7 files changed, 92 insertions(+), 59 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index e685dd90223..01a1126e464 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -62,6 +62,7 @@ struct Material; struct Bone; struct Mesh; struct EditMesh; +struct DerivedMesh; /* used for curves, nurbs, mball, importing */ typedef struct DispList { diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 6b22b10cf24..d1808366944 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -117,6 +117,8 @@ struct Image *BKE_add_image_file(const char *name, int frame); /* adds image, adds ibuf, generates color or pattern */ struct Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4]); +/* adds image from imbuf, owns imbuf */ +struct Image *BKE_add_image_imbuf(struct ImBuf *ibuf); /* for reload, refresh, pack */ void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index accadb3d434..ac107212e30 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -563,10 +563,8 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, int floatbuf, sho /* adds new image block, creates ImBuf and initializes color */ Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4]) { - Image *ima; - /* on save, type is changed to FILE in editsima.c */ - ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); + Image *ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); if (ima) { ImBuf *ibuf; @@ -585,6 +583,23 @@ Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short return ima; } +/* creates an image image owns the imbuf passed */ +Image *BKE_add_image_imbuf(ImBuf *ibuf) +{ + /* on save, type is changed to FILE in editsima.c */ + char filename[sizeof(ibuf->name)]; + BLI_split_dirfile(ibuf->name, NULL, filename); + Image *ima= image_alloc(filename, IMA_SRC_FILE, IMA_TYPE_IMAGE); + + if (ima) { + BLI_strncpy(ima->name, ibuf->name, FILE_MAX); + image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); + ima->ok= IMA_OK_LOADED; + } + + return ima; +} + /* packs rect from memory as PNG */ void BKE_image_memorypack(Image *ima) { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index b1319a81f5d..7ae2898ab8d 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1060,7 +1060,7 @@ static int ptcache_path(PTCacheID *pid, char *filename) blendfilename= (lib)? lib->filename: G.sce; - BLI_split_dirfile_basic(blendfilename, NULL, file); + BLI_split_dirfile(blendfilename, NULL, file); i = strlen(file); /* remove .blend */ diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 98dbf83f032..d3b05cf802c 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -79,6 +79,8 @@ static int seqrecty= 0; #define SELECT 1 ListBase seqbase_clipboard; int seqbase_clipboard_frame; +void *sequencer_view3d_cb= NULL; /* NULL in background mode */ + void printf_strip(Sequence *seq) { @@ -2104,7 +2106,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int } else if(seq->type == SEQ_SCENE) { // scene can be NULL after deletions Scene *sce= seq->scene;// *oldsce= scene; Render *re; - RenderResult rres; int have_seq= FALSE; int sce_valid= FALSE; @@ -2130,58 +2131,70 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if (!sce_valid) { se->ok = STRIPELEM_FAILED; } else if (se->ibuf==NULL && sce_valid) { - int oldcfra; - /* Hack! This function can be called from do_render_seq(), in that case - the seq->scene can already have a Render initialized with same name, - so we have to use a default name. (compositor uses scene name to - find render). - However, when called from within the UI (image preview in sequencer) - we do want to use scene Render, that way the render result is defined - for display in render/imagewindow - - Hmm, don't see, why we can't do that all the time, - and since G.rendering is uhm, gone... (Peter) - */ - - int rendering = 1; - int doseq; - - oldcfra = seq->scene->r.cfra; - - if(rendering) - re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT); - else - re= RE_NewRender(sce->id.name, RE_SLOT_VIEW); - - /* prevent eternal loop */ - doseq= scene->r.scemode & R_DOSEQ; - scene->r.scemode &= ~R_DOSEQ; - - RE_BlenderFrame(re, sce, NULL, - seq->sfra+se->nr+seq->anim_startofs); - - RE_AcquireResultImage(re, &rres); - - if(rres.rectf) { - se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); - memcpy(se->ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty); - if(rres.rectz) { - addzbuffloatImBuf(se->ibuf); - memcpy(se->ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty); + int do_opengl= 0; + if(do_opengl && have_seq==0 && (sequencer_view3d_cb!=NULL)) { + /* opengl offscreen render */ + + /* sequencer_view3d_cb */ + // void (*seq_view3d_cb)(Scene *, int, int, int, int)= sequencer_view3d_cb; + + // seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty); + } + else { + RenderResult rres; + int oldcfra; + /* Hack! This function can be called from do_render_seq(), in that case + the seq->scene can already have a Render initialized with same name, + so we have to use a default name. (compositor uses scene name to + find render). + However, when called from within the UI (image preview in sequencer) + we do want to use scene Render, that way the render result is defined + for display in render/imagewindow + + Hmm, don't see, why we can't do that all the time, + and since G.rendering is uhm, gone... (Peter) + */ + + int rendering = 1; + int doseq; + + oldcfra = seq->scene->r.cfra; + + if(rendering) + re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT); + else + re= RE_NewRender(sce->id.name, RE_SLOT_VIEW); + + /* prevent eternal loop */ + doseq= scene->r.scemode & R_DOSEQ; + scene->r.scemode &= ~R_DOSEQ; + + RE_BlenderFrame(re, sce, NULL, + seq->sfra+se->nr+seq->anim_startofs); + + RE_AcquireResultImage(re, &rres); + + if(rres.rectf) { + se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); + memcpy(se->ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty); + if(rres.rectz) { + addzbuffloatImBuf(se->ibuf); + memcpy(se->ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty); + } + } else if (rres.rect32) { + se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); + memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); } - } else if (rres.rect32) { - se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); - memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); - } - RE_ReleaseResultImage(re); - - // BIF_end_render_callbacks(); + RE_ReleaseResultImage(re); + + // BIF_end_render_callbacks(); + + /* restore */ + scene->r.scemode |= doseq; - /* restore */ - scene->r.scemode |= doseq; - - seq->scene->r.cfra = oldcfra; + seq->scene->r.cfra = oldcfra; + } copy_to_ibuf_still(seq, se); @@ -3803,7 +3816,7 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->len = seq->len = seq_load->len ? seq_load->len : 1; strip->us= 1; strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name); + BLI_split_dirfile(seq_load->path, strip->dir, se->name); seq_load_apply(scene, seq, seq_load); @@ -3853,7 +3866,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name); + BLI_split_dirfile(seq_load->path, strip->dir, se->name); seq->scene_sound = sound_add_scene_sound(scene, seq, seq_load->start_frame, seq_load->start_frame + strip->len, 0); @@ -3897,7 +3910,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name); + BLI_split_dirfile(seq_load->path, strip->dir, se->name); calc_sequence_disp(scene, seq); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index e014b209e07..23df930aa84 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -39,6 +39,7 @@ static int force_device = -1; +#ifdef WITH_JACK static void sound_sync_callback(void* data, int mode, float time) { struct Main* bmain = (struct Main*)data; @@ -58,6 +59,7 @@ static void sound_sync_callback(void* data, int mode, float time) scene = scene->id.next; } } +#endif int sound_define_from_str(char *str) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index b58caf14293..a7f80953f22 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -247,7 +247,7 @@ int reopen_text(Text *text) BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE); BLI_convertstringcode(str, G.sce); - BLI_split_dirfile_basic(str, NULL, sfile); + BLI_split_dirfile(str, NULL, sfile); fp= fopen(str, "r"); if(fp==NULL) return 0; @@ -345,7 +345,7 @@ Text *add_text(char *file, const char *relpath) BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE); if (relpath) /* can be NULL (bg mode) */ BLI_convertstringcode(str, relpath); - BLI_split_dirfile_basic(str, NULL, sfile); + BLI_split_dirfile(str, NULL, sfile); fp= fopen(str, "r"); if(fp==NULL) return NULL; -- cgit v1.2.3 From 754b22bd515790cd31b8e40f188b2e07196d76a8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Mar 2010 21:33:51 +0000 Subject: option to use offscreen opengl drawing with the sequencer scene strips. warning, uses bad level call, will need to resolve very very soon! --- source/blender/blenkernel/intern/image.c | 4 +- source/blender/blenkernel/intern/screen.c | 1 - source/blender/blenkernel/intern/sequencer.c | 79 ++++++++++++++++------------ 3 files changed, 47 insertions(+), 37 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ac107212e30..a0337704c2d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -587,9 +587,11 @@ Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short Image *BKE_add_image_imbuf(ImBuf *ibuf) { /* on save, type is changed to FILE in editsima.c */ + Image *ima; char filename[sizeof(ibuf->name)]; + BLI_split_dirfile(ibuf->name, NULL, filename); - Image *ima= image_alloc(filename, IMA_SRC_FILE, IMA_TYPE_IMAGE); + ima= image_alloc(filename, IMA_SRC_FILE, IMA_TYPE_IMAGE); if (ima) { BLI_strncpy(ima->name, ibuf->name, FILE_MAX); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 6d0057ca298..59a8bd74910 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -351,4 +351,3 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type) } return NULL; } - diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d3b05cf802c..994bbc3e70e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -39,6 +39,7 @@ #include "DNA_sequence_types.h" #include "DNA_scene_types.h" #include "DNA_anim_types.h" +#include "DNA_object_types.h" #include "BKE_global.h" #include "BKE_image.h" @@ -46,6 +47,7 @@ #include "BKE_sequencer.h" #include "BKE_fcurve.h" #include "BKE_utildefines.h" +#include "BKE_scene.h" #include "RNA_access.h" #include "RE_pipeline.h" @@ -1938,6 +1940,8 @@ static void check_limiter_refcount_comp(const char * func, TStripElem *se) static TStripElem* do_build_seq_array_recursively(Scene *scene, ListBase *seqbasep, int cfra, int chanshown, int render_size); +extern ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height); + static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, int build_proxy_run, int render_size) { @@ -2130,47 +2134,52 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if (!sce_valid) { se->ok = STRIPELEM_FAILED; - } else if (se->ibuf==NULL && sce_valid) { - int do_opengl= 0; - if(do_opengl && have_seq==0 && (sequencer_view3d_cb!=NULL)) { - /* opengl offscreen render */ + } + else if (se->ibuf==NULL && sce_valid) { + int frame= seq->sfra + se->nr + seq->anim_startofs; + int oldcfra = seq->scene->r.cfra; - /* sequencer_view3d_cb */ - // void (*seq_view3d_cb)(Scene *, int, int, int, int)= sequencer_view3d_cb; + /* Hack! This function can be called from do_render_seq(), in that case + the seq->scene can already have a Render initialized with same name, + so we have to use a default name. (compositor uses scene name to + find render). + However, when called from within the UI (image preview in sequencer) + we do want to use scene Render, that way the render result is defined + for display in render/imagewindow - // seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty); - } - else { - RenderResult rres; - int oldcfra; - /* Hack! This function can be called from do_render_seq(), in that case - the seq->scene can already have a Render initialized with same name, - so we have to use a default name. (compositor uses scene name to - find render). - However, when called from within the UI (image preview in sequencer) - we do want to use scene Render, that way the render result is defined - for display in render/imagewindow + Hmm, don't see, why we can't do that all the time, + and since G.rendering is uhm, gone... (Peter) + */ + + int rendering = 1; + int doseq; - Hmm, don't see, why we can't do that all the time, - and since G.rendering is uhm, gone... (Peter) - */ + /* prevent eternal loop */ + doseq= scene->r.scemode & R_DOSEQ; + scene->r.scemode &= ~R_DOSEQ; - int rendering = 1; - int doseq; + seq->scene->r.cfra= frame; + + if(G.background==0 && (seq->flag & SEQ_USE_SCENE_OPENGL) && have_seq==0) { + /* opengl offscreen render */ - oldcfra = seq->scene->r.cfra; +#ifdef DURIAN_CAMERA_SWITCH + Object *camera= scene_find_camera_switch(seq->scene); + if(camera) + seq->scene->camera= camera; +#endif + scene_update_for_newframe(seq->scene, seq->scene->lay); + se->ibuf= ED_view3d_draw_offscreen_imbuf_simple(seq->scene, seqrectx, seqrecty); // BAD LEVEL CALL! DONT ALLOW THIS FOR MORE THEN A FEW DAYS, USE A CALLBACK!!! - campell + } + else { + RenderResult rres; if(rendering) re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT); else re= RE_NewRender(sce->id.name, RE_SLOT_VIEW); - /* prevent eternal loop */ - doseq= scene->r.scemode & R_DOSEQ; - scene->r.scemode &= ~R_DOSEQ; - - RE_BlenderFrame(re, sce, NULL, - seq->sfra+se->nr+seq->anim_startofs); + RE_BlenderFrame(re, sce, NULL, frame); RE_AcquireResultImage(re, &rres); @@ -2189,12 +2198,12 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int RE_ReleaseResultImage(re); // BIF_end_render_callbacks(); - - /* restore */ - scene->r.scemode |= doseq; - - seq->scene->r.cfra = oldcfra; } + + /* restore */ + scene->r.scemode |= doseq; + + seq->scene->r.cfra = oldcfra; copy_to_ibuf_still(seq, se); -- cgit v1.2.3 From f03a17d0f935a0f33114dea24ede731b721c307e Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 9 Mar 2010 00:35:05 +0000 Subject: * Fix for crash using texture nodes in displace modifier Modifier code was asking for filtered textures without sending derivatives. Disabled this and also checks for filtered/non-filtered. Brecht, I assumed this was ok due to the existence of the p->osatex variable - if this isn't what you had in mind, please change or let me know :) --- source/blender/blenkernel/intern/modifier.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 601bee4f670..c5a420b85a8 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -3508,8 +3508,7 @@ static void get_texture_value(Tex *texture, float *tex_co, TexResult *texres) { int result_type; - result_type = multitex_ext(texture, tex_co, NULL, - NULL, 1, texres); + result_type = multitex_ext(texture, tex_co, NULL, NULL, 0, texres); /* if the texture gave an RGB value, we assume it didn't give a valid * intensity, so calculate one (formula from do_material_tex). -- cgit v1.2.3 From 979aa4e9904017144b049f90ff14a6cc928b437d Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 9 Mar 2010 03:01:18 +0000 Subject: Point cache optimization: only cache particles that are alive. This reduces point cache sizes dramatically especially if particle life time is small compared to total simulation length. For example with the settings: particle amount = 10000, start = 1, end = 200, life = 10, cache step = 1, the unoptimized blend file size (compressed) was a little over 22 Mb and with this optimization the file is a little under 2 Mb (again compressed). In addition to saving memory/disk space this also probably speeds up reading from cache, since there's less data to read. As an additional fix the memory cache size (displayed in cache panel) is now calculated correctly. --- source/blender/blenkernel/BKE_pointcache.h | 10 +- source/blender/blenkernel/intern/particle.c | 6 +- source/blender/blenkernel/intern/pointcache.c | 223 +++++++++++++++----------- 3 files changed, 138 insertions(+), 101 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 10550ccdc05..0268f2faf31 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -118,7 +118,7 @@ typedef struct PTCacheID { unsigned int data_types, info_types; /* copies point data to cache data */ - int (*write_elem)(int index, void *calldata, void **data); + int (*write_elem)(int index, void *calldata, void **data, int cfra); /* copies point data to cache data */ int (*write_stream)(PTCacheFile *pf, void *calldata); /* copies cache cata to point data */ @@ -128,10 +128,10 @@ typedef struct PTCacheID { /* interpolated between previously read point data and cache data */ void (*interpolate_elem)(int index, void *calldata, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data); - /* total number of simulated points */ - int (*totpoint)(void *calldata); - /* number of points written for current cache frame (currently not used) */ - int (*totwrite)(void *calldata); + /* total number of simulated points (the cfra parameter is just for using same function pointer with totwrite) */ + int (*totpoint)(void *calldata, int cfra); + /* number of points written for current cache frame */ + int (*totwrite)(void *calldata, int cfra); int (*write_header)(PTCacheFile *pf); int (*read_header)(PTCacheFile *pf); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index b88df677c9b..97e8d6c7f7d 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1067,12 +1067,12 @@ static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, int inde while(pm && pm->next && (float)pm->frame < t) pm = pm->next; - BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] : index, pm->data, (float)pm->frame); - BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] : index, pm->prev->data, (float)pm->prev->frame); + BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame); + BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame); } else if(cache->mem_cache.first) { PTCacheMem *pm2 = cache->mem_cache.first; - BKE_ptcache_make_particle_key(key2, pm2->index_array ? pm2->index_array[index] : index, pm2->data, (float)pm2->frame); + BKE_ptcache_make_particle_key(key2, pm2->index_array ? pm2->index_array[index] - 1 : index, pm2->data, (float)pm2->frame); copy_particle_key(key1, key2, 1); } } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 7ae2898ab8d..9c393ad0ae1 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -135,7 +135,7 @@ static int ptcache_write_basic_header(PTCacheFile *pf) return 1; } /* Softbody functions */ -static int ptcache_write_softbody(int index, void *soft_v, void **data) +static int ptcache_write_softbody(int index, void *soft_v, void **data, int cfra) { SoftBody *soft= soft_v; BodyPoint *bp = soft->bpoint + index; @@ -191,13 +191,13 @@ static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, f VECCOPY(bp->pos, keys->co); VECCOPY(bp->vec, keys->vel); } -static int ptcache_totpoint_softbody(void *soft_v) +static int ptcache_totpoint_softbody(void *soft_v, int cfra) { SoftBody *soft= soft_v; return soft->totpoint; } /* Particle functions */ -static int ptcache_write_particle(int index, void *psys_v, void **data) +static int ptcache_write_particle(int index, void *psys_v, void **data, int cfra) { ParticleSystem *psys= psys_v; ParticleData *pa = psys->particles + index; @@ -205,11 +205,9 @@ static int ptcache_write_particle(int index, void *psys_v, void **data) float times[3] = {pa->time, pa->dietime, pa->lifetime}; int step = psys->pointcache->step; - if(data[BPHYS_DATA_INDEX]) { - /* No need to store unborn or died particles */ - if(pa->time - step > pa->state.time || pa->dietime + step < pa->state.time) - return 0; - } + /* No need to store unborn or died particles outside cache step bounds */ + if(data[BPHYS_DATA_INDEX] && (cfra < pa->time - step || cfra > pa->dietime + step)) + return 0; PTCACHE_DATA_FROM(data, BPHYS_DATA_INDEX, &index); PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, pa->state.co); @@ -236,8 +234,14 @@ void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, flo static void ptcache_read_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float *old_data) { ParticleSystem *psys= psys_v; - ParticleData *pa = psys->particles + index; - BoidParticle *boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL; + ParticleData *pa; + BoidParticle *boid; + + if(index >= psys->totpart) + return; + + pa = psys->particles + index; + boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL; if(cfra > pa->state.time) memcpy(&pa->prev_state, &pa->state, sizeof(ParticleKey)); @@ -288,10 +292,19 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr static void ptcache_interpolate_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) { ParticleSystem *psys= psys_v; - ParticleData *pa = psys->particles + index; + ParticleData *pa; ParticleKey keys[4]; float dfra; + if(index >= psys->totpart) + return; + + pa = psys->particles + index; + + /* particle wasn't read from first cache so can't interpolate */ + if((int)cfra1 < pa->time - psys->pointcache->step || (int)cfra1 > pa->dietime + psys->pointcache->step) + return; + cfra = MIN2(cfra, pa->dietime); cfra1 = MIN2(cfra1, pa->dietime); cfra2 = MIN2(cfra2, pa->dietime); @@ -338,26 +351,20 @@ static void ptcache_interpolate_particle(int index, void *psys_v, void **data, f pa->state.time = cfra; } -static int ptcache_totpoint_particle(void *psys_v) +static int ptcache_totpoint_particle(void *psys_v, int cfra) { ParticleSystem *psys = psys_v; return psys->totpart; } -static int ptcache_totwrite_particle(void *psys_v) +static int ptcache_totwrite_particle(void *psys_v, int cfra) { ParticleSystem *psys = psys_v; + ParticleData *pa= psys->particles; + int p, step = psys->pointcache->step; int totwrite = 0; - /* TODO for later */ - //if((psys->part->flag & (PART_UNBORN|PART_DIED))==0) { - // ParticleData *pa= psys->particles; - // int p, step = psys->pointcache->step; - - // for(p=0; ptotpart; p++,pa++) - // totwrite += (pa->time - step > pa->state.time || pa->dietime + step > pa->state.time); - //} - //else - totwrite= psys->totpart; + for(p=0; ptotpart; p++,pa++) + totwrite += (cfra >= pa->time - step && cfra <= pa->dietime + step); return totwrite; } @@ -489,7 +496,7 @@ static int ptcache_totwrite_particle(void *psys_v) //} // /* Cloth functions */ -static int ptcache_write_cloth(int index, void *cloth_v, void **data) +static int ptcache_write_cloth(int index, void *cloth_v, void **data, int cfra) { ClothModifierData *clmd= cloth_v; Cloth *cloth= clmd->clothObject; @@ -554,7 +561,7 @@ static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, flo /* should vert->xconst be interpolated somehow too? - jahka */ } -static int ptcache_totpoint_cloth(void *cloth_v) +static int ptcache_totpoint_cloth(void *cloth_v, int cfra) { ClothModifierData *clmd= cloth_v; return clmd->clothObject->numverts; @@ -615,11 +622,7 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p pid->write_header= ptcache_write_basic_header; pid->read_header= ptcache_read_basic_header; - pid->data_types= (1<part->flag & (PART_UNBORN|PART_DIED))==0) - // pid->data_types|= (1<data_types= (1<part->phystype == PART_PHYS_BOIDS) pid->data_types|= (1<domain; @@ -648,7 +651,7 @@ static int ptcache_totpoint_smoke(void *smoke_v) } /* Smoke functions */ -static int ptcache_totpoint_smoke_turbulence(void *smoke_v) +static int ptcache_totpoint_smoke_turbulence(void *smoke_v, int cfra) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; @@ -1266,12 +1269,32 @@ static void ptcache_file_seek_pointers(int index, PTCacheFile *pf) int i, size=0; int data_types = pf->data_types; - for(i=0; idata_types & (1<fp, 8 + sizeof(int), SEEK_SET); + fread(&totpoint, sizeof(int), 1, pf->fp); + + totpoint++; + + fseek(pf->fp, 8 + sizeof(int), SEEK_SET); + fwrite(&totpoint, sizeof(int), 1, pf->fp); + + fseek(pf->fp, 0, SEEK_END); + } + else { + for(i=0; idata_types & (1<fp, 8 + 3*sizeof(int) + index * size, SEEK_SET); + } ptcache_file_init_pointers(pf); - /* size of default header + data up to index */ - fseek(pf->fp, 8 + 3*sizeof(int) + index * size, SEEK_SET); } void BKE_ptcache_mem_init_pointers(PTCacheMem *pm) { @@ -1291,13 +1314,24 @@ void BKE_ptcache_mem_incr_pointers(PTCacheMem *pm) pm->cur[i] = (char*)pm->cur[i] + ptcache_data_size[i]; } } -void BKE_ptcache_mem_seek_pointers(int index, PTCacheMem *pm) +static int BKE_ptcache_mem_seek_pointers(int point_index, PTCacheMem *pm) { int data_types = pm->data_types; - int i; + int i, index = pm->index_array ? pm->index_array[point_index] - 1 : point_index; + + if(index < 0) { + /* Can't give proper location without reallocation, so don't give any location. + * Some points will be cached improperly, but this only happens with simulation + * steps bigger than cache->step, so the cache has to be recalculated anyways + * at some point. + */ + return 0; + } for(i=0; icur[i] = data_types & (1<data[i] + index * ptcache_data_size[i] : NULL; + + return 1; } static void ptcache_alloc_data(PTCacheMem *pm) { @@ -1310,14 +1344,20 @@ static void ptcache_alloc_data(PTCacheMem *pm) pm->data[i] = MEM_callocN(totpoint * ptcache_data_size[i], "PTCache Data"); } } -static void ptcache_free_data(void *data[]) +static void ptcache_free_data(PTCacheMem *pm) { + void **data = pm->data; int i; for(i=0; iindex_array) { + MEM_freeN(pm->index_array); + pm->index_array = NULL; + } } static void ptcache_copy_data(void *from[], void *to[]) { @@ -1361,7 +1401,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) int ret = 0, error = 0; /* nothing to read to */ - if(pid->totpoint(pid->calldata) == 0) + if(pid->totpoint(pid->calldata, (int)cfra) == 0) return 0; if(pid->cache->flag & PTCACHE_READ_INFO) { @@ -1462,13 +1502,13 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) else if(pid->read_header(pf)) { ptcache_file_init_pointers(pf); totpoint = pf->totpoint; - index = pf->data_types & BPHYS_DATA_INDEX ? &pf->data.index : &i; + index = pf->data_types & (1<data.index : &i; } } else { /* fall back to old cache file format */ use_old = 1; - totpoint = pid->totpoint(pid->calldata); + totpoint = pid->totpoint(pid->calldata, (int) cfra); } } if(pf2) { @@ -1481,13 +1521,13 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) else if(pid->read_header(pf2)) { ptcache_file_init_pointers(pf2); totpoint2 = pf2->totpoint; - index2 = pf2->data_types & BPHYS_DATA_INDEX ? &pf2->data.index : &i; + index2 = pf2->data_types & (1<data.index : &i; } } else { /* fall back to old cache file format */ use_old = 1; - totpoint2 = pid->totpoint(pid->calldata); + totpoint2 = pid->totpoint(pid->calldata, (int) cfra); } } @@ -1500,7 +1540,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) if(!error) { if(pf && pid->read_stream) { - if(totpoint != pid->totpoint(pid->calldata)) + if(totpoint != pid->totpoint(pid->calldata, (int) cfra)) error = 1; else { @@ -1510,7 +1550,8 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) } } - totpoint = MIN2(totpoint, pid->totpoint(pid->calldata)); + if((pid->data_types & (1<totpoint(pid->calldata, (int) cfra)); if(!error) { @@ -1539,7 +1580,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) if(!error) { if(pf2 && pid->read_stream) { - if(totpoint2 != pid->totpoint(pid->calldata)) + if(totpoint2 != pid->totpoint(pid->calldata, (int) cfra)) error = 1; else { @@ -1549,7 +1590,8 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) } } - totpoint2 = MIN2(totpoint2, pid->totpoint(pid->calldata)); + if((pid->data_types & (1<totpoint(pid->calldata, (int) cfra)); if(!error) { @@ -1621,31 +1663,31 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) return (error ? 0 : ret); } /* TODO for later */ -//static void ptcache_make_index_array(PTCacheMem *pm, int totpoint) -//{ -// int i, *index; -// -// if(pm->index_array) { -// MEM_freeN(pm->index_array); -// pm->index_array = NULL; -// } -// -// if(!pm->data[BPHYS_DATA_INDEX]) -// return; -// -// pm->index_array = MEM_callocN(totpoint * sizeof(int), "PTCacheMem index_array"); -// index = pm->data[BPHYS_DATA_INDEX]; -// -// for(i=0; itotpoint; i++, index++) -// pm->index_array[*index] = i; -//} +static void ptcache_make_index_array(PTCacheMem *pm, int totpoint) +{ + int i, *index; + + if(pm->index_array) { + MEM_freeN(pm->index_array); + pm->index_array = NULL; + } + + if(!pm->data[BPHYS_DATA_INDEX]) + return; + + pm->index_array = MEM_callocN(totpoint * sizeof(int), "PTCacheMem index_array"); + index = pm->data[BPHYS_DATA_INDEX]; + + for(i=0; itotpoint; i++, index++) + pm->index_array[*index] = i + 1; +} /* writes cache to disk or memory */ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) { PointCache *cache = pid->cache; PTCacheFile *pf= NULL, *pf2= NULL; int i; - int totpoint = pid->totpoint(pid->calldata); + int totpoint = pid->totpoint(pid->calldata, cfra); int add = 0, overwrite = 0; if(totpoint == 0 || cfra < 0 @@ -1690,7 +1732,7 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) return 0; pf->type = pid->type; - pf->totpoint = cfra ? totpoint : pid->totwrite(pid->calldata); + pf->totpoint = cfra ? pid->totwrite(pid->calldata, cfra) : totpoint; pf->data_types = cfra ? pid->data_types : pid->info_types; if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) { @@ -1707,7 +1749,7 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) else for(i=0; iwrite_elem) { - int write = pid->write_elem(i, pid->calldata, pf->cur); + int write = pid->write_elem(i, pid->calldata, pf->cur, cfra); if(write) { if(!ptcache_file_write_data(pf)) { ptcache_file_close(pf); @@ -1727,7 +1769,7 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) pf2->data_types = pid->data_types; } ptcache_file_seek_pointers(i, pf2); - pid->write_elem(i, pid->calldata, pf2->cur); + pid->write_elem(i, pid->calldata, pf2->cur, cfra); if(!ptcache_file_write_data(pf2)) { ptcache_file_close(pf); ptcache_file_close(pf2); @@ -1773,7 +1815,7 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - pm->totpoint = pid->totwrite(pid->calldata); + pm->totpoint = pid->totwrite(pid->calldata, cfra); pm->data_types = cfra ? pid->data_types : pid->info_types; ptcache_alloc_data(pm); @@ -1781,20 +1823,20 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) for(i=0; iwrite_elem) { - int write = pid->write_elem(i, pid->calldata, pm->cur); + int write = pid->write_elem(i, pid->calldata, pm->cur, cfra); if(write) { BKE_ptcache_mem_incr_pointers(pm); /* newly born particles have to be copied to previous cached frame */ if(overwrite && write == 2) { pm2 = cache->mem_cache.last; - BKE_ptcache_mem_seek_pointers(i, pm2); - pid->write_elem(i, pid->calldata, pm2->cur); + if(BKE_ptcache_mem_seek_pointers(i, pm2)) + pid->write_elem(i, pid->calldata, pm2->cur, cfra); } } } } - //ptcache_make_index_array(pm, pid->totpoint(pid->calldata)); + ptcache_make_index_array(pm, pid->totpoint(pid->calldata, cfra)); pm->frame = cfra; BLI_addtail(&cache->mem_cache, pm); @@ -1899,15 +1941,15 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) if(mode == PTCACHE_CLEAR_ALL) { pid->cache->last_exact = 0; for(; pm; pm=pm->next) - ptcache_free_data(pm->data); + ptcache_free_data(pm); BLI_freelistN(&pid->cache->mem_cache); } else { while(pm) { if((mode==PTCACHE_CLEAR_BEFORE && pm->frame < cfra) || (mode==PTCACHE_CLEAR_AFTER && pm->frame > cfra) ) { link = pm; + ptcache_free_data(pm); pm = pm->next; - ptcache_free_data(link->data); BLI_freelinkN(&pid->cache->mem_cache, link); } else @@ -1929,7 +1971,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) for(; pm; pm=pm->next) { if(pm->frame == cfra) { - ptcache_free_data(pm->data); + ptcache_free_data(pm); BLI_freelinkN(&pid->cache->mem_cache, pm); break; } @@ -2214,11 +2256,8 @@ void BKE_ptcache_free_mem(ListBase *mem_cache) PTCacheMem *pm = mem_cache->first; if(pm) { - for(; pm; pm=pm->next) { - ptcache_free_data(pm->data); - if(pm->index_array) - MEM_freeN(pm->index_array); - } + for(; pm; pm=pm->next) + ptcache_free_data(pm); BLI_freelistN(mem_cache); } @@ -2587,7 +2626,7 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid) cache->flag |= PTCACHE_DISK_CACHE; - ptcache_free_data(pm->data); + ptcache_free_data(pm); MEM_freeN(pm); ptcache_file_close(pf); @@ -2597,7 +2636,7 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid) BKE_ptcache_mem_incr_pointers(pm); } - //ptcache_make_index_array(pm, pid->totpoint(pid->calldata)); + ptcache_make_index_array(pm, pid->totpoint(pid->calldata, cfra)); BLI_addtail(&pid->cache->mem_cache, pm); @@ -2813,16 +2852,14 @@ void BKE_ptcache_update_info(PTCacheID *pid) } else { PTCacheMem *pm = cache->mem_cache.first; - float framesize = 0.0f, bytes = 0.0f; - int mb; - - if(pm) - framesize = (float)ptcache_pid_old_elemsize(pid) * (float)pm->totpoint; + float bytes = 0.0f; + int i, mb; - for(; pm; pm=pm->next) + for(; pm; pm=pm->next) { + for(i=0; idata[i] ? MEM_allocN_len(pm->data[i]) : 0.0f; totframes++; - - bytes = totframes * framesize; + } mb = (bytes > 1024.0f * 1024.0f); -- cgit v1.2.3 From d4756d395bde04dc6cfeed696df1c38211ffbff9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Mar 2010 07:41:04 +0000 Subject: remove for bad-level-call & some minor changes to make camera switching neater. --- source/blender/blenkernel/BKE_scene.h | 3 ++- source/blender/blenkernel/BKE_sequencer.h | 4 ++++ source/blender/blenkernel/intern/scene.c | 14 +++++++++++++- source/blender/blenkernel/intern/sequencer.c | 14 ++++---------- 4 files changed, 23 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index d1b4e5aef1a..09fb705dd70 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -66,7 +66,8 @@ void unlink_scene(struct Main *bmain, struct Scene *sce, struct Scene *newsce); int next_object(struct Scene *scene, int val, struct Base **base, struct Object **ob); struct Object *scene_find_camera(struct Scene *sc); -struct Object *scene_find_camera_switch(struct Scene *scene); // DURIAN_CAMERA_SWITCH +struct Object *scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH +int scene_camera_switch_update(struct Scene *scene); char *scene_find_marker_name(struct Scene *scene, int frame); char *scene_find_last_marker_name(struct Scene *scene, int frame); diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index b0a810203cf..21cd2f694ca 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -233,6 +233,10 @@ struct Sequence *sequencer_add_image_strip(struct bContext *C, ListBase *seqbase struct Sequence *sequencer_add_sound_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); struct Sequence *sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); +/* view3d draw callback, run when not in background view */ +typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, int, int); +extern SequencerDrawView sequencer_view3d_cb; + /* copy/paste */ extern ListBase seqbase_clipboard; extern int seqbase_clipboard_frame; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index ca5efbef053..3f0ef5f5bff 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -722,7 +722,7 @@ Object *scene_find_camera(Scene *sc) } #ifdef DURIAN_CAMERA_SWITCH -Object *scene_find_camera_switch(Scene *scene) +Object *scene_camera_switch_find(Scene *scene) { TimeMarker *m; int cfra = scene->r.cfra; @@ -743,6 +743,18 @@ Object *scene_find_camera_switch(Scene *scene) } #endif +int scene_camera_switch_update(Scene *scene) +{ +#ifdef DURIAN_CAMERA_SWITCH + Object *camera= scene_camera_switch_find(scene); + if(camera) { + scene->camera= camera; + return 1; + } +#endif + return 0; +} + char *scene_find_marker_name(Scene *scene, int frame) { ListBase *markers= &scene->markers; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 994bbc3e70e..3a85676e23b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -81,7 +81,7 @@ static int seqrecty= 0; #define SELECT 1 ListBase seqbase_clipboard; int seqbase_clipboard_frame; -void *sequencer_view3d_cb= NULL; /* NULL in background mode */ +SequencerDrawView sequencer_view3d_cb= NULL; /* NULL in background mode */ void printf_strip(Sequence *seq) @@ -1940,8 +1940,6 @@ static void check_limiter_refcount_comp(const char * func, TStripElem *se) static TStripElem* do_build_seq_array_recursively(Scene *scene, ListBase *seqbasep, int cfra, int chanshown, int render_size); -extern ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height); - static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, int build_proxy_run, int render_size) { @@ -2160,16 +2158,12 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int seq->scene->r.cfra= frame; - if(G.background==0 && (seq->flag & SEQ_USE_SCENE_OPENGL) && have_seq==0) { + if(sequencer_view3d_cb && (seq->flag & SEQ_USE_SCENE_OPENGL) && have_seq==0) { /* opengl offscreen render */ -#ifdef DURIAN_CAMERA_SWITCH - Object *camera= scene_find_camera_switch(seq->scene); - if(camera) - seq->scene->camera= camera; -#endif + scene_camera_switch_update(seq->scene); scene_update_for_newframe(seq->scene, seq->scene->lay); - se->ibuf= ED_view3d_draw_offscreen_imbuf_simple(seq->scene, seqrectx, seqrecty); // BAD LEVEL CALL! DONT ALLOW THIS FOR MORE THEN A FEW DAYS, USE A CALLBACK!!! - campell + se->ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty); } else { RenderResult rres; -- cgit v1.2.3 From ec303cf980a696fa374dad3b1cdfd6440ed7f846 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 9 Mar 2010 07:41:27 +0000 Subject: Fix [#21188] HueCorrection Node, when reseting Curve, it goes to a incline instead of flat/straight --- source/blender/blenkernel/BKE_colortools.h | 9 +-------- source/blender/blenkernel/intern/brush.c | 3 ++- source/blender/blenkernel/intern/colortools.c | 12 +++++++++++- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index 3e1d4fe927b..dca8ccb6dbf 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -45,13 +45,6 @@ struct rctf; # define DO_INLINE static inline #endif -typedef enum CurveMappingPreset { - CURVE_PRESET_LINE, - CURVE_PRESET_SHARP, - CURVE_PRESET_SMOOTH, - CURVE_PRESET_MAX -} CurveMappingPreset; - void floatbuf_to_srgb_byte(float *rectf, unsigned char *rectc, int x1, int x2, int y1, int y2, int w); void floatbuf_to_byte(float *rectf, unsigned char *rectc, int x1, int x2, int y1, int y2, int w); @@ -62,7 +55,7 @@ void curvemapping_set_black_white(struct CurveMapping *cumap, float *black, f void curvemap_remove(struct CurveMap *cuma, int flag); void curvemap_insert(struct CurveMap *cuma, float x, float y); -void curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, CurveMappingPreset preset); +void curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, int preset); void curvemap_sethandle(struct CurveMap *cuma, int type); void curvemapping_changed(struct CurveMapping *cumap, int rem_doubles); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index bc30b2669e8..f2cb7d31592 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -237,7 +237,8 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) cm = b->curve->cm; cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; - curvemap_reset(cm, &b->curve->clipr, preset); + b->curve->preset = preset; + curvemap_reset(cm, &b->curve->clipr, b->curve->preset); curvemapping_changed(b->curve, 0); } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 71b497660e9..28b70b539c1 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -239,7 +239,7 @@ void curvemap_insert(CurveMap *cuma, float x, float y) cuma->curve= cmp; } -void curvemap_reset(CurveMap *cuma, rctf *clipr, CurveMappingPreset preset) +void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset) { if(cuma->curve) MEM_freeN(cuma->curve); @@ -249,6 +249,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, CurveMappingPreset preset) case CURVE_PRESET_SHARP: cuma->totpoint= 3; break; case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break; case CURVE_PRESET_MAX: cuma->totpoint= 2; break; + case CURVE_PRESET_MID9: cuma->totpoint= 9; } cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points"); @@ -286,6 +287,15 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, CurveMappingPreset preset) cuma->curve[1].x= 1; cuma->curve[1].y= 1; break; + case CURVE_PRESET_MID9: + { + int i; + for (i=0; i < cuma->totpoint; i++) + { + cuma->curve[i].x= i / ((float)cuma->totpoint-1); + cuma->curve[i].y= 0.5; + } + } } if(cuma->table) { -- cgit v1.2.3 From b7a73f9e5b74062d4498a5061281c0d0af9fb026 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Mar 2010 09:17:45 +0000 Subject: mtex buffer copy & paste back for materials. --- source/blender/blenkernel/BKE_material.h | 4 ++ source/blender/blenkernel/intern/material.c | 70 +++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 7ec5d172130..07ca5a1c0ee 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -83,6 +83,10 @@ void free_matcopybuf(void); void copy_matcopybuf(struct Material *ma); void paste_matcopybuf(struct Material *ma); +void clear_mat_mtex_copybuf(void); +void copy_mat_mtex_copybuf(struct ID *id); +void paste_mat_mtex_copybuf(struct ID *id); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 27b46c40d28..05f0f20feff 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1247,6 +1247,7 @@ static short matcopied=0; void clear_matcopybuf(void) { memset(&matcopybuf, 0, sizeof(Material)); + matcopied= 0; } void free_matcopybuf(void) @@ -1273,6 +1274,8 @@ void free_matcopybuf(void) matcopybuf.nodetree= NULL; } // default_mtex(&mtexcopybuf); + + matcopied= 0; } void copy_matcopybuf(Material *ma) @@ -1346,3 +1349,70 @@ 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 5f7bcee541131be75b82e6d57dcc2ecc89303dd3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Mar 2010 13:52:52 +0000 Subject: camera override option for scene strips. --- source/blender/blenkernel/intern/object.c | 11 +++++++++++ source/blender/blenkernel/intern/sequencer.c | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 7f04b20a901..336f45fc2e2 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -64,6 +64,7 @@ #include "DNA_particle_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_sequence_types.h" #include "DNA_space_types.h" #include "DNA_texture_types.h" #include "DNA_userdef_types.h" @@ -110,6 +111,7 @@ #include "BKE_sca.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_sequencer.h" #include "BKE_softbody.h" #include "LBM_fluidsim.h" @@ -591,7 +593,16 @@ void unlink_object(Scene *scene, Object *ob) } } #endif + if(sce->ed) { + Sequence *seq; + SEQ_BEGIN(sce->ed, seq) + if(seq->scene_camera==ob) { + seq->scene_camera= NULL; + } + SEQ_END + } } + sce= sce->id.next; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 3a85676e23b..481c1ef29cf 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2136,6 +2136,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int else if (se->ibuf==NULL && sce_valid) { int frame= seq->sfra + se->nr + seq->anim_startofs; int oldcfra = seq->scene->r.cfra; + Object *oldcamera= seq->scene->camera; /* Hack! This function can be called from do_render_seq(), in that case the seq->scene can already have a Render initialized with same name, @@ -2158,16 +2159,22 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int seq->scene->r.cfra= frame; - if(sequencer_view3d_cb && (seq->flag & SEQ_USE_SCENE_OPENGL) && have_seq==0) { + if(sequencer_view3d_cb && (seq->flag & SEQ_USE_SCENE_OPENGL) && (seq->scene == scene || have_seq==0)) { /* opengl offscreen render */ + if(seq->scene_camera) seq->scene->camera= seq->scene_camera; + else scene_camera_switch_update(seq->scene); - scene_camera_switch_update(seq->scene); scene_update_for_newframe(seq->scene, seq->scene->lay); se->ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty); } else { RenderResult rres; +#ifdef DURIAN_CAMERA_SWITCH + /* stooping to new low's in hackyness :( */ + scene_marker_tfm_translate(seq->scene, MAXFRAME*2, 0); +#endif + if(rendering) re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT); else @@ -2192,12 +2199,18 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int RE_ReleaseResultImage(re); // BIF_end_render_callbacks(); + +#ifdef DURIAN_CAMERA_SWITCH + /* stooping to new low's in hackyness :( */ + scene_marker_tfm_translate(seq->scene, MAXFRAME*-2, 0); +#endif } /* restore */ scene->r.scemode |= doseq; seq->scene->r.cfra = oldcfra; + seq->scene->camera= oldcamera; copy_to_ibuf_still(seq, se); -- cgit v1.2.3 From 1b28081102899654df629bafa876e19e629e8d7c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 9 Mar 2010 16:54:25 +0000 Subject: Mac + OpenMP + pthreads workaround: recent commit broke compile, just moved it into threads.c now instead of having it duplicated in various places. --- source/blender/blenkernel/intern/pointcache.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 9c393ad0ae1..2dbdfd06551 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -88,13 +88,6 @@ #include "BLI_winstuff.h" #endif -#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) -/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */ -#include -extern pthread_key_t gomp_tls_key; -static void *thread_tls_data; -#endif - #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]); } @@ -2375,11 +2368,6 @@ typedef struct { static void *ptcache_make_cache_thread(void *ptr) { ptcache_make_cache_data *data = (ptcache_make_cache_data*)ptr; -#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) - // Workaround for Apple gcc 4.2.1 omp vs background thread bug - pthread_setspecific (gomp_tls_key, thread_tls_data); -#endif - for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) scene_update_for_newframe(data->scene, data->scene->lay); @@ -2497,10 +2485,6 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) thread_data.thread_ended = FALSE; old_progress = -1; -#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) - // Workaround for Apple gcc 4.2.1 omp vs background thread bug - thread_tls_data = pthread_getspecific(gomp_tls_key); -#endif BLI_init_threads(&threads, ptcache_make_cache_thread, 1); BLI_insert_thread(&threads, (void*)&thread_data); -- cgit v1.2.3 From 1708ac07231cd222f269d3c0ddb9e22aba7aeec4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Mar 2010 17:36:23 +0000 Subject: rename some functions to use easier to understand names. 'BLI_makestringcode' --> 'BLI_path_rel' 'BLI_convertstringcwd' --> 'BLI_path_cwd' 'BLI_convertstringframe' --> 'BLI_path_frame' 'BLI_convertstringframe_range' --> 'BLI_path_frame_range' 'BLI_make_cwdpath' --> 'BLI_path_cwd' --- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/blenkernel/intern/fluidsim.c | 4 ++-- source/blender/blenkernel/intern/image.c | 22 +++++++++++----------- source/blender/blenkernel/intern/library.c | 4 ++-- source/blender/blenkernel/intern/packedFile.c | 6 +++--- source/blender/blenkernel/intern/particle_system.c | 4 ++-- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 12 ++++++------ source/blender/blenkernel/intern/sound.c | 4 ++-- source/blender/blenkernel/intern/text.c | 4 ++-- source/blender/blenkernel/intern/writeavi.c | 4 ++-- source/blender/blenkernel/intern/writeffmpeg.c | 4 ++-- 12 files changed, 36 insertions(+), 36 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 34ad6660294..07960dd2fa0 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2315,7 +2315,7 @@ static void customdata_external_filename(char filename[FILE_MAX], ID *id, Custom char *path = (id->lib)? id->lib->filename: G.sce; BLI_strncpy(filename, external->filename, FILE_MAX); - BLI_convertstringcode(filename, path); + BLI_path_abs(filename, path); } void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int totelem) diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 7d1f0510d71..22eb0578f72 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -431,8 +431,8 @@ DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifie strcat(targetDir,"fluidsurface_final_####"); } - BLI_convertstringcode(targetDir, G.sce); - BLI_convertstringframe(targetDir, curFrame, 0); // fixed #frame-no + BLI_path_abs(targetDir, G.sce); + BLI_path_frame(targetDir, curFrame, 0); // fixed #frame-no strcpy(targetFile,targetDir); strcat(targetFile, ".bobj.gz"); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a0337704c2d..ee3d685938b 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -391,7 +391,7 @@ Image *BKE_add_image_file(const char *name, int frame) } BLI_strncpy(str, name, sizeof(str)); - BLI_convertstringcode(str, G.sce); + BLI_path_abs(str, G.sce); /* exists? */ file= open(str, O_BINARY|O_RDONLY); @@ -402,7 +402,7 @@ Image *BKE_add_image_file(const char *name, int frame) for(ima= G.main->image.first; ima; ima= ima->id.next) { if(ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) { BLI_strncpy(strtest, ima->name, sizeof(ima->name)); - BLI_convertstringcode(strtest, G.sce); + BLI_path_abs(strtest, G.sce); if( strcmp(strtest, str)==0 ) { if(ima->anim==NULL || ima->id.us==0) { @@ -1428,8 +1428,8 @@ void BKE_makepicstring(char *string, char *base, int frame, int imtype, int use_ { if (string==NULL) return; BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ - BLI_convertstringcode(string, G.sce); - BLI_convertstringframe(string, frame, 4); + BLI_path_abs(string, G.sce); + BLI_path_frame(string, frame, 4); if(use_ext) BKE_add_image_extension(string, imtype); @@ -1684,9 +1684,9 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) BLI_strncpy(name, ima->name, sizeof(name)); if(ima->id.lib) - BLI_convertstringcode(name, ima->id.lib->filename); + BLI_path_abs(name, ima->id.lib->filename); else - BLI_convertstringcode(name, G.sce); + BLI_path_abs(name, G.sce); /* read ibuf */ ibuf = IMB_loadiffname(name, IB_rect|IB_multilayer); @@ -1791,9 +1791,9 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) BLI_strncpy(str, ima->name, FILE_MAX); if(ima->id.lib) - BLI_convertstringcode(str, ima->id.lib->filename); + BLI_path_abs(str, ima->id.lib->filename); else - BLI_convertstringcode(str, G.sce); + BLI_path_abs(str, G.sce); ima->anim = openanim(str, IB_cmap | IB_rect); @@ -1845,11 +1845,11 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) /* get the right string */ BLI_strncpy(str, ima->name, sizeof(str)); if(ima->id.lib) - BLI_convertstringcode(str, ima->id.lib->filename); + BLI_path_abs(str, ima->id.lib->filename); else - BLI_convertstringcode(str, G.sce); + BLI_path_abs(str, G.sce); - BLI_convertstringframe(str, cfra, 0); + BLI_path_frame(str, cfra, 0); /* read ibuf */ ibuf = IMB_loadiffname(str, IB_rect|IB_multilayer|IB_imginfo); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 79bc92bdbfb..83268a0a165 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1244,8 +1244,8 @@ static void image_fix_relative_path(Image *ima) { if(ima->id.lib==NULL) return; if(strncmp(ima->name, "//", 2)==0) { - BLI_convertstringcode(ima->name, ima->id.lib->filename); - BLI_makestringcode(G.sce, ima->name); + BLI_path_abs(ima->name, ima->id.lib->filename); + BLI_path_rel(ima->name, G.sce); } } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 55f09eede91..cdcdcc07eef 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -186,7 +186,7 @@ PackedFile *newPackedFile(ReportList *reports, char *filename) // convert relative filenames to absolute filenames strcpy(name, filename); - BLI_convertstringcode(name, G.sce); + BLI_path_abs(name, G.sce); // open the file // and create a PackedFile structure @@ -274,7 +274,7 @@ int writePackedFile(ReportList *reports, char *filename, PackedFile *pf, int gui if (guimode); //XXX waitcursor(1); strcpy(name, filename); - BLI_convertstringcode(name, G.sce); + BLI_path_abs(name, G.sce); if (BLI_exists(name)) { for (number = 1; number <= 999; number++) { @@ -339,7 +339,7 @@ int checkPackedFile(char *filename, PackedFile *pf) char name[FILE_MAXDIR + FILE_MAXFILE]; strcpy(name, filename); - BLI_convertstringcode(name, G.sce); + BLI_path_abs(name, G.sce); if (stat(name, &st)) { ret_val = PF_NOFILE; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 9b1d48ac8c3..491ecd6011b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3567,8 +3567,8 @@ static void particles_fluid_step(ParticleSimulationData *sim, int cfra) // ok, start loading strcpy(filename, fss->surfdataPath); strcat(filename, suffix); - BLI_convertstringcode(filename, G.sce); - BLI_convertstringframe(filename, curFrame, 0); // fixed #frame-no + BLI_path_abs(filename, G.sce); + BLI_path_frame(filename, curFrame, 0); // fixed #frame-no strcat(filename, suffix2); gzf = gzopen(filename, "rb"); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 2dbdfd06551..3908429e606 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1064,7 +1064,7 @@ static int ptcache_path(PTCacheID *pid, char *filename) file[i-6] = '\0'; snprintf(filename, MAX_PTCACHE_PATH, "//"PTCACHE_PATH"%s", file); /* add blend file name to pointcache dir */ - BLI_convertstringcode(filename, blendfilename); + BLI_path_abs(filename, blendfilename); return BLI_add_slash(filename); /* new strlen() */ } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 481c1ef29cf..601ead8654e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -586,7 +586,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) if (seq->type != SEQ_SCENE && seq->type != SEQ_META && seq->type != SEQ_IMAGE) { BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name); - BLI_convertstringcode(str, G.sce); + BLI_path_abs(str, G.sce); } if (seq->type == SEQ_IMAGE) { @@ -1247,7 +1247,7 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { BLI_join_dirfile(name, dir, seq->strip->proxy->file); - BLI_convertstringcode(name, G.sce); + BLI_path_abs(name, G.sce); return TRUE; } @@ -1276,8 +1276,8 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na render_size); } - BLI_convertstringcode(name, G.sce); - BLI_convertstringframe(name, frameno, 0); + BLI_path_abs(name, G.sce); + BLI_path_frame(name, frameno, 0); strcat(name, ".jpg"); @@ -2044,7 +2044,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if(se->ok == STRIPELEM_OK && se->ibuf == 0) { StripElem * s_elem = give_stripelem(seq, cfra); BLI_join_dirfile(name, seq->strip->dir, s_elem->name); - BLI_convertstringcode(name, G.sce); + BLI_path_abs(name, G.sce); if (!build_proxy_run) { se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); } @@ -2078,7 +2078,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if (se->ibuf == 0) { if(seq->anim==0) { BLI_join_dirfile(name, seq->strip->dir, seq->strip->stripdata->name); - BLI_convertstringcode(name, G.sce); + BLI_path_abs(name, G.sce); seq->anim = openanim( name, IB_rect | diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 23df930aa84..9d189237ba0 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -127,7 +127,7 @@ struct bSound* sound_new_file(struct Main *bmain, char* filename) int len; strcpy(str, filename); - BLI_convertstringcode(str, bmain->name); + BLI_path_abs(str, bmain->name); len = strlen(filename); while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') @@ -262,7 +262,7 @@ void sound_load(struct Main *bmain, struct bSound* sound) else path = bmain ? bmain->name : G.sce; - BLI_convertstringcode(fullpath, path); + BLI_path_abs(fullpath, path); /* but we need a packed file then */ if (pf) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index a7f80953f22..37c583943c6 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -246,7 +246,7 @@ int reopen_text(Text *text) if (!text || !text->name) return 0; BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE); - BLI_convertstringcode(str, G.sce); + BLI_path_abs(str, G.sce); BLI_split_dirfile(str, NULL, sfile); fp= fopen(str, "r"); @@ -344,7 +344,7 @@ Text *add_text(char *file, const char *relpath) BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE); if (relpath) /* can be NULL (bg mode) */ - BLI_convertstringcode(str, relpath); + BLI_path_abs(str, relpath); BLI_split_dirfile(str, NULL, sfile); fp= fopen(str, "r"); diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index d67a79154d2..f4bcb6d412f 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -124,12 +124,12 @@ static void filepath_avi (char *string, RenderData *rd) if (string==NULL) return; strcpy(string, rd->pic); - BLI_convertstringcode(string, G.sce); + BLI_path_abs(string, G.sce); BLI_make_existing_file(string); if (!BLI_testextensie(string, ".avi")) { - BLI_convertstringframe_range(string, rd->sfra, rd->efra, 4); + BLI_path_frame_range(string, rd->sfra, rd->efra, 4); strcat(string, ".avi"); } } diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 6e94602c0c9..8aa9282937c 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -789,7 +789,7 @@ void filepath_ffmpeg(char* string, RenderData* rd) { if (!string || !exts) return; strcpy(string, rd->pic); - BLI_convertstringcode(string, G.sce); + BLI_path_abs(string, G.sce); BLI_make_existing_file(string); @@ -810,7 +810,7 @@ void filepath_ffmpeg(char* string, RenderData* rd) { if (!*fe) { strcat(string, autosplit); - BLI_convertstringframe_range(string, rd->sfra, rd->efra, 4); + BLI_path_frame_range(string, rd->sfra, rd->efra, 4); strcat(string, *exts); } else { *(string + strlen(string) - strlen(*fe)) = 0; -- cgit v1.2.3 From 2df08632cd05f081d3673dd6bc433e4f0c3a7b08 Mon Sep 17 00:00:00 2001 From: Jens Ole Wund Date: Tue, 9 Mar 2010 23:30:32 +0000 Subject: softbody.c / preparing 2.5 / animate all .. still not happy with it loads of issues .. anyone like to join Ulysses? --- source/blender/blenkernel/intern/softbody.c | 44 +++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 343d11a2f34..09f7f32bc12 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3223,6 +3223,39 @@ static void springs_from_mesh(Object *ob) } + +/* helper functions for everything is animateble jow_go_for2_5 +++++++*/ +/* introducing them here, because i know: steps in properties ( at frame timing ) + will cause unwanted responses of the softbody system (which does inter frame calculations ) + so first 'cure' would be: interpolate linear in time .. + Q: why do i write this? + A: because it happend once, that some eger coder 'streamlined' code to fail. + We DO linear interpolation for goals .. and i think we should do on animated properties as well +*/ +static float _goalfac(SoftBody *sb)/*jow_go_for2_5 */ +{ + if (sb){ + return ABS(sb->maxgoal - sb->mingoal); + } + printf("_goalfac failed! sb==NULL \n" ); + return -9999.99f; /*using crude but spot able values some times helps debuggin */ +} + + +static float _final_goal(SoftBody *sb,BodyPoint *bp)/*jow_go_for2_5 */ +{ + float f = -1999.99f; + if (sb && bp){ + if (bp->goal < 0.0f) return (0.0f); + f = pow(_goalfac(sb), 4.0f); + return (bp->goal *f); + } + printf("_final_goal failed! sb or bp ==NULL \n" ); + return f; /*using crude but spot able values some times helps debuggin */ +} +/* helper functions for everything is animateble jow_go_for2_5 ------*/ + + /* makes totally fresh start situation */ static void mesh_to_softbody(Scene *scene, Object *ob) { @@ -3242,8 +3275,8 @@ static void mesh_to_softbody(Scene *scene, Object *ob) /* we always make body points */ sb= ob->soft; bp= sb->bpoint; - /* should go to sb->scratch so we can pick it up at frame level thanks_a_TON*/ - goalfac= ABS(sb->maxgoal - sb->mingoal); + /*pick it from _goalfac jow_go_for2_5*/ + goalfac= _goalfac(sb); for(a=0; atotvert; a++, bp++) { /* get scalar values needed *per vertex* from vertex group functions, @@ -3257,14 +3290,13 @@ static void mesh_to_softbody(Scene *scene, Object *ob) get_scalar_from_vertexgroup(ob, a,(short) (sb->vertgroup-1), &bp->goal); /* do this always, regardless successfull read from vertex group */ - /* this is where '2.5 every thing is animateable' goes wrong in the first place thanks_a_TON */ - /* don't ask me for evidence .. i might track to the very commit */ + /* this is where '2.5 every thing is animateable' goes wrong in the first place jow_go_for2_5 */ /* 1st coding action to take : move this to frame level */ /* reads: leave the bp->goal as it was read from vertex group / or default .. we will need it at per frame call */ - bp->goal= sb->mingoal + bp->goal*goalfac; /* do not do here thanks_a_TON */ + bp->goal= sb->mingoal + bp->goal*goalfac; /* do not do here jow_go_for2_5 */ } /* a little ad hoc changing the goal control to be less *sharp* */ - bp->goal = (float)pow(bp->goal, 4.0f);/* do not do here thanks_a_TON */ + bp->goal = (float)pow(bp->goal, 4.0f);/* do not do here jow_go_for2_5 */ /* to proove the concept this would enable per vertex *mass painting* -- cgit v1.2.3 From 54b4266bef2f6cb0f0060b325a5b1462404ac93a Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 10 Mar 2010 03:41:41 +0000 Subject: Fix for [#21411] Particles jitter when resting on a collision object * Particle now take particle acceleration during collisions into account. --- source/blender/blenkernel/BKE_particle.h | 1 + source/blender/blenkernel/intern/particle_system.c | 54 ++++++++++++++-------- 2 files changed, 37 insertions(+), 18 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 45166ebf022..fcef00ae9b3 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -169,6 +169,7 @@ typedef struct ParticleCollision float nor[3]; // normal at collision point float vel[3]; // velocity of collision point float co1[3], co2[3]; // ray start and end points + float ve1[3], ve2[3]; // particle velocities float ray_len; // original length of co2-co1, needed for collision time evaluation float t; // time of previous collision, needed for substracting face velocity } ParticleCollision; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 491ecd6011b..38808131f92 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2720,6 +2720,12 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo VECCOPY(col.co1, pa->prev_state.co); VECCOPY(col.co2, pa->state.co); + + VECCOPY(col.ve1, pa->prev_state.vel); + VECCOPY(col.ve2, pa->state.vel); + mul_v3_fl(col.ve1, timestep * dfra); + mul_v3_fl(col.ve2, timestep * dfra); + col.t = 0.0f; /* override for boids */ @@ -2765,12 +2771,20 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo int through = (BLI_frand() < pd->pdef_perm) ? 1 : 0; float co[3]; /* point of collision */ float vec[3]; /* movement through collision */ - float t = hit.dist/col.ray_len; /* time of collision between this iteration */ - float dt = col.t + t * (1.0f - col.t); /* time of collision between frame change*/ - - interp_v3_v3v3(co, col.co1, col.co2, t); + float acc[3]; /* acceleration */ + + float x = hit.dist/col.ray_len; /* location of collision between this iteration */ + float le = len_v3(col.ve1)/col.ray_len; + float ac = len_v3(col.ve2)/col.ray_len - le; /* (taking acceleration into account) */ + float t = (-le + sqrt(le*le + 2*ac*x))/ac; /* time of collision between this iteration */ + float dt = col.t + x * (1.0f - col.t); /* time of collision between frame change*/ + float it = 1.0 - t; + + interp_v3_v3v3(co, col.co1, col.co2, x); VECSUB(vec, col.co2, col.co1); + VECSUB(acc, col.ve2, col.ve1); + mul_v3_fl(col.vel, 1.0f-col.t); /* particle dies in collision */ @@ -2867,10 +2881,6 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* combine components together again */ VECADD(vec, nor_vec, tan_vec); - /* calculate velocity from collision vector */ - VECCOPY(vel, vec); - mul_v3_fl(vel, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); - /* make sure we don't hit the current face again */ VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f)); @@ -2878,21 +2888,25 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo BoidParticle *bpa = pa->boid; if(bpa->data.mode == eBoidMode_OnLand || co[2] <= boid_z) { co[2] = boid_z; - vel[2] = 0.0f; + vec[2] = 0.0f; } } - /* store state for reactors */ - //VECCOPY(reaction_state.co, co); - //interp_v3_v3v3(reaction_state.vel, pa->prev_state.vel, pa->state.vel, dt); - //interp_qt_qtqt(reaction_state.rot, pa->prev_state.rot, pa->state.rot, dt); - /* set coordinates for next iteration */ + + /* apply acceleration to final position, but make sure particle stays above surface */ + madd_v3_v3v3fl(acc, vec, acc, it); + ac = dot_v3v3(acc, col.nor); + if((!through && ac < 0.0f) || (through && ac > 0.0f)) + madd_v3_v3fl(acc, col.nor, -ac); + VECCOPY(col.co1, co); - VECADDFAC(col.co2, co, vec, 1.0f - t); - col.t = dt; + VECADDFAC(col.co2, co, acc, it); + + VECCOPY(col.ve1, vec); + VECCOPY(col.ve2, acc); - if(len_v3(vec) < 0.001 && len_v3(pa->state.vel) < 0.001) { + if(len_v3(vec) < 0.001 && len_v3v3(pa->state.co, pa->prev_state.co) < 0.001) { /* kill speed to stop slipping */ VECCOPY(pa->state.vel,zerovec); VECCOPY(pa->state.co, co); @@ -2902,10 +2916,14 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo } else { VECCOPY(pa->state.co, col.co2); + mul_v3_v3fl(pa->state.vel, acc, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); + /* Stickness to surface */ normalize_v3(nor_vec); - VECADDFAC(pa->state.vel, vel, nor_vec, -pd->pdef_stickness); + madd_v3_v3fl(pa->state.vel, nor_vec, -pd->pdef_stickness); } + + col.t = dt; } deflections++; -- cgit v1.2.3 From 3d222c3de6a281b4e7165634eb6e01f8010ecbc2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 10 Mar 2010 08:17:18 +0000 Subject: - scene sequencer camera override wasnt working for render strips (only opengl) - temp disable camera switching with override by clearning markers (hack) - check for GAMEBLENDER define else eclipse gets confused by multiple definitions of functons in the stub. --- source/blender/blenkernel/intern/sequencer.c | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 601ead8654e..341d0a542e6 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2107,7 +2107,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int } } else if(seq->type == SEQ_SCENE) { // scene can be NULL after deletions Scene *sce= seq->scene;// *oldsce= scene; - Render *re; int have_seq= FALSE; int sce_valid= FALSE; @@ -2137,6 +2136,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int int frame= seq->sfra + se->nr + seq->anim_startofs; int oldcfra = seq->scene->r.cfra; Object *oldcamera= seq->scene->camera; + ListBase oldmarkers; /* Hack! This function can be called from do_render_seq(), in that case the seq->scene can already have a Render initialized with same name, @@ -2158,23 +2158,24 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int scene->r.scemode &= ~R_DOSEQ; seq->scene->r.cfra= frame; + if(seq->scene_camera) seq->scene->camera= seq->scene_camera; + else scene_camera_switch_update(seq->scene); + +#ifdef DURIAN_CAMERA_SWITCH + /* stooping to new low's in hackyness :( */ + oldmarkers= seq->scene->markers; + seq->scene->markers.first= seq->scene->markers.last= NULL; +#endif if(sequencer_view3d_cb && (seq->flag & SEQ_USE_SCENE_OPENGL) && (seq->scene == scene || have_seq==0)) { /* opengl offscreen render */ - if(seq->scene_camera) seq->scene->camera= seq->scene_camera; - else scene_camera_switch_update(seq->scene); - scene_update_for_newframe(seq->scene, seq->scene->lay); se->ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty); } else { + Render *re; RenderResult rres; -#ifdef DURIAN_CAMERA_SWITCH - /* stooping to new low's in hackyness :( */ - scene_marker_tfm_translate(seq->scene, MAXFRAME*2, 0); -#endif - if(rendering) re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT); else @@ -2199,11 +2200,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int RE_ReleaseResultImage(re); // BIF_end_render_callbacks(); - -#ifdef DURIAN_CAMERA_SWITCH - /* stooping to new low's in hackyness :( */ - scene_marker_tfm_translate(seq->scene, MAXFRAME*-2, 0); -#endif } /* restore */ @@ -2212,6 +2208,11 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int seq->scene->r.cfra = oldcfra; seq->scene->camera= oldcamera; +#ifdef DURIAN_CAMERA_SWITCH + /* stooping to new low's in hackyness :( */ + seq->scene->markers= oldmarkers; +#endif + copy_to_ibuf_still(seq, se); if (!build_proxy_run) { -- cgit v1.2.3 From 69a7060678e96b53548a14f22a83510f4d9edcd0 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 11 Mar 2010 07:43:49 +0000 Subject: Restored Environment maps * Fixed up RNA and UI * Brought back 'Save' and 'Clear' operators (in the little triangle menu in environment map properties) * While I was at it, noticed that environment maps were only using 8bit colour, changed it to use full 32bit float instead for proper HDR colour etc, so environment map reflections have the correct colour range --> http://mke3.net/blender/devel/2.5/env_hdr.jpg This fixes [#20904] Environment Map does not render; also missing panel --- source/blender/blenkernel/intern/texture.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 10fdbc7fa14..16cb8a8fb49 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -483,10 +483,10 @@ void default_tex(Tex *tex) tex->vn_coltype = 0; if (tex->env) { - tex->env->stype=ENV_STATIC; + tex->env->stype=ENV_ANIM; tex->env->clipsta=0.1; tex->env->clipend=100; - tex->env->cuberes=100; + tex->env->cuberes=600; tex->env->depth=0; } @@ -1040,10 +1040,11 @@ EnvMap *BKE_add_envmap(void) env= MEM_callocN(sizeof(EnvMap), "envmap"); env->type= ENV_CUBE; - env->stype= ENV_STATIC; + env->stype= ENV_ANIM; env->clipsta= 0.1; env->clipend= 100.0; - env->cuberes= 100; + env->cuberes= 600; + env->viewscale = 0.5; return env; } -- cgit v1.2.3 From 6028470a9cb5410328df0d681582144573bbc781 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 11 Mar 2010 11:15:25 +0000 Subject: Motion Paths + Auto-Keying: Revised the conditions under which motion paths get recalculated after transforms (when auto-keying is enabled). Now, the type of path display does not matter, but rather that the object/bone in question has any paths at all. This makes animating with these a much smoother experience. --- source/blender/blenkernel/intern/anim.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 0aba2d8619d..08c8528384f 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -208,6 +208,9 @@ bMotionPath *animviz_verify_motionpaths(Scene *scene, Object *ob, bPoseChannel * /* allocate a cache */ mpath->points= MEM_callocN(sizeof(bMotionPathVert)*mpath->length, "bMotionPathVerts"); + /* tag viz settings as currently having some path(s) which use it */ + avs->path_bakeflag |= MOTIONPATH_BAKE_HAS_PATHS; + /* return it */ return mpath; } -- cgit v1.2.3 From b0dd7b8c9c45ee9d76b83dd8d410df80410b0bf5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 12 Mar 2010 12:09:58 +0000 Subject: Fix #21189: vertex paint not working with mirror modifier. --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 28b093cd693..9d7fbccec75 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2125,7 +2125,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) Object *obact = scene->basact?scene->basact->object:NULL; int editing = paint_facesel_test(ob); /* weight paint and face select need original indicies because of selection buffer drawing */ - int needMapping = (ob==obact) && (editing || (ob->mode & OB_MODE_WEIGHT_PAINT) || editing); + int needMapping = (ob==obact) && (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT|OB_MODE_VERTEX_PAINT)) || editing); clear_mesh_caches(ob); -- cgit v1.2.3 From 353a078d4c1fc12eb4c444f6d7a020652c23dd71 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 12 Mar 2010 12:29:12 +0000 Subject: Fix #21211: new indirect/environment/emit passes weren't showing up in compositor and outliner yet. --- source/blender/blenkernel/BKE_node.h | 4 +++- source/blender/blenkernel/intern/node.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index a6ebb72320c..0e5ad8e3ee9 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -290,9 +290,11 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat); #define RRES_OUT_AO 10 #define RRES_OUT_REFLECT 11 #define RRES_OUT_REFRACT 12 -#define RRES_OUT_RADIO 13 +#define RRES_OUT_INDIRECT 13 #define RRES_OUT_INDEXOB 14 #define RRES_OUT_MIST 15 +#define RRES_OUT_EMIT 16 +#define RRES_OUT_ENV 17 /* note: types are needed to restore callbacks, don't change values */ #define CMP_NODE_VIEWER 201 diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 844139dd871..77e54fe6769 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2809,12 +2809,16 @@ static void force_hidden_passes(bNode *node, int passflag) if(!(passflag & SCE_PASS_REFLECT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_REFRACT); if(!(passflag & SCE_PASS_REFRACT)) sock->flag |= SOCK_UNAVAIL; - sock= BLI_findlink(&node->outputs, RRES_OUT_RADIO); - if(!(passflag & SCE_PASS_RADIO)) sock->flag |= SOCK_UNAVAIL; + sock= BLI_findlink(&node->outputs, RRES_OUT_INDIRECT); + if(!(passflag & SCE_PASS_INDIRECT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXOB); if(!(passflag & SCE_PASS_INDEXOB)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_MIST); if(!(passflag & SCE_PASS_MIST)) sock->flag |= SOCK_UNAVAIL; + sock= BLI_findlink(&node->outputs, RRES_OUT_EMIT); + if(!(passflag & SCE_PASS_EMIT)) sock->flag |= SOCK_UNAVAIL; + sock= BLI_findlink(&node->outputs, RRES_OUT_ENV); + if(!(passflag & SCE_PASS_ENVIRONMENT)) sock->flag |= SOCK_UNAVAIL; } -- cgit v1.2.3 From 8252fa5a16b9e09662ad3d2a20f78bc4e324afa6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 12 Mar 2010 14:42:03 +0000 Subject: Fix smoke looking black in the viewport when compiling with -ffast-math. (memset works on byte level and bytes -1,-1,-1,-1 = NaN). --- source/blender/blenkernel/intern/smoke.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 2196e2ccd04..69209699a69 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1398,11 +1398,12 @@ static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct) { - int z; float bv[6]; - int slabsize=res[0]*res[1]; + int a, z, slabsize=res[0]*res[1], size= res[0]*res[1]*res[2]; + + for(a=0; a Date: Sat, 13 Mar 2010 00:17:52 +0000 Subject: Fix [#21351] PROPERTIES: Resolution changes based solely on changing encoding format Bypassed existing hardcoded ffmpeg presets that executed when changing format, replaced with bpy presets. Leaving old code there for now, haven't got python/rna access to the ffmpeg id properties.. Anyone know how to do this? Code snippets here: http://www.pasteall.org/11657/c --- source/blender/blenkernel/intern/writeffmpeg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 8aa9282937c..ccef6832be8 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1242,7 +1242,8 @@ void ffmpeg_verify_image_type(RenderData *rd) rd->ffcodecdata.video_bitrate <= 1) { rd->ffcodecdata.codec = CODEC_ID_MPEG2VIDEO; - ffmpeg_set_preset(rd, FFMPEG_PRESET_DVD); + /* Don't set preset, disturbs render resolution. + * ffmpeg_set_preset(rd, FFMPEG_PRESET_DVD); */ } audio= 1; -- cgit v1.2.3 From 9439c0b1cbc1b238a7bca5bf07f4381864fbce23 Mon Sep 17 00:00:00 2001 From: Jens Ole Wund Date: Sat, 13 Mar 2010 02:43:25 +0000 Subject: getting close to 2.5 'everything can be animated paradigm' well meshes do .. I've not been looking a the tail yet. softbody.c --- source/blender/blenkernel/intern/softbody.c | 94 +++++++++++++++++------------ 1 file changed, 54 insertions(+), 40 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 09f7f32bc12..d804f87daff 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -212,6 +212,41 @@ static float sb_time_scale(Object *ob) } /*--- frame based timing ---*/ +/* helper functions for everything is animateble jow_go_for2_5 +++++++*/ +/* introducing them here, because i know: steps in properties ( at frame timing ) + will cause unwanted responses of the softbody system (which does inter frame calculations ) + so first 'cure' would be: interpolate linear in time .. + Q: why do i write this? + A: because it happend once, that some eger coder 'streamlined' code to fail. + We DO linear interpolation for goals .. and i think we should do on animated properties as well +*/ +static float _goalfac(SoftBody *sb)/*jow_go_for2_5 */ +{ + if (sb){ + return ABS(sb->maxgoal - sb->mingoal); + } + printf("_goalfac failed! sb==NULL \n" ); + return -9999.99f; /*using crude but spot able values some times helps debuggin */ +} + + +static float _final_goal(Object *ob,BodyPoint *bp)/*jow_go_for2_5 */ +{ + float f = -1999.99f; + if (ob){ + SoftBody *sb= ob->soft; /* is supposed to be there */ + if(!(ob->softflag & OB_SB_GOAL)) return (0.0f); + if (sb&&bp){ + if (bp->goal < 0.0f) return (0.0f); + f = pow(_goalfac(sb), 4.0f); + return (bp->goal *f); + } + } + printf("_final_goal failed! sb or bp ==NULL \n" ); + return f; /*using crude but spot able values some times helps debuggin */ +} +/* helper functions for everything is animateble jow_go_for2_5 ------*/ + /*+++ collider caching and dicing +++*/ /******************** @@ -2219,7 +2254,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo } /* naive ball self collision done */ - if(bp->goal < SOFTGOALSNAP){ /* ommit this bp when it snaps */ + if(_final_goal(ob,bp) < SOFTGOALSNAP){ /* ommit this bp when it snaps */ float auxvect[3]; float velgoal[3]; @@ -2228,7 +2263,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* true elastic goal */ float ks,kd; sub_v3_v3v3(auxvect,bp->pos,bp->origT); - ks = 1.0f/(1.0f- bp->goal*sb->goalspring)-1.0f ; + ks = 1.0f/(1.0f- _final_goal(ob,bp)*sb->goalspring)-1.0f ; bp->force[0]+= -ks*(auxvect[0]); bp->force[1]+= -ks*(auxvect[1]); bp->force[2]+= -ks*(auxvect[2]); @@ -2616,7 +2651,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa } /* naive ball self collision done */ - if(bp->goal < SOFTGOALSNAP){ /* ommit this bp when it snaps */ + if(_final_goal(ob,bp) < SOFTGOALSNAP){ /* ommit this bp when it snaps */ float auxvect[3]; float velgoal[3]; @@ -2624,7 +2659,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if(ob->softflag & OB_SB_GOAL) { /* true elastic goal */ sub_v3_v3v3(auxvect,bp->pos,bp->origT); - ks = 1.0f/(1.0f- bp->goal*sb->goalspring)-1.0f ; + ks = 1.0f/(1.0f- _final_goal(ob,bp)*sb->goalspring)-1.0f ; bp->force[0]+= -ks*(auxvect[0]); bp->force[1]+= -ks*(auxvect[1]); bp->force[2]+= -ks*(auxvect[2]); @@ -2888,7 +2923,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * else timeovermass = forcetime/0.009999f; - if(bp->goal < SOFTGOALSNAP){ + if(_final_goal(ob,bp) < SOFTGOALSNAP){ /* this makes t~ = t */ if(mid_flags & MID_PRESERVE) VECCOPY(dx,bp->vec); @@ -3092,7 +3127,7 @@ static void softbody_apply_goalsnap(Object *ob) int a; for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - if (bp->goal >= SOFTGOALSNAP){ + if (_final_goal(ob,bp) >= SOFTGOALSNAP){ VECCOPY(bp->prevpos,bp->pos); VECCOPY(bp->pos,bp->origT); } @@ -3137,7 +3172,7 @@ static void interpolate_exciter(Object *ob, int timescale, int time) bp->origT[0] = bp->origS[0] + f*(bp->origE[0] - bp->origS[0]); bp->origT[1] = bp->origS[1] + f*(bp->origE[1] - bp->origS[1]); bp->origT[2] = bp->origS[2] + f*(bp->origE[2] - bp->origS[2]); - if (bp->goal >= SOFTGOALSNAP){ + if (_final_goal(ob,bp) >= SOFTGOALSNAP){ bp->vec[0] = bp->origE[0] - bp->origS[0]; bp->vec[1] = bp->origE[1] - bp->origS[1]; bp->vec[2] = bp->origE[2] - bp->origS[2]; @@ -3224,37 +3259,6 @@ static void springs_from_mesh(Object *ob) -/* helper functions for everything is animateble jow_go_for2_5 +++++++*/ -/* introducing them here, because i know: steps in properties ( at frame timing ) - will cause unwanted responses of the softbody system (which does inter frame calculations ) - so first 'cure' would be: interpolate linear in time .. - Q: why do i write this? - A: because it happend once, that some eger coder 'streamlined' code to fail. - We DO linear interpolation for goals .. and i think we should do on animated properties as well -*/ -static float _goalfac(SoftBody *sb)/*jow_go_for2_5 */ -{ - if (sb){ - return ABS(sb->maxgoal - sb->mingoal); - } - printf("_goalfac failed! sb==NULL \n" ); - return -9999.99f; /*using crude but spot able values some times helps debuggin */ -} - - -static float _final_goal(SoftBody *sb,BodyPoint *bp)/*jow_go_for2_5 */ -{ - float f = -1999.99f; - if (sb && bp){ - if (bp->goal < 0.0f) return (0.0f); - f = pow(_goalfac(sb), 4.0f); - return (bp->goal *f); - } - printf("_final_goal failed! sb or bp ==NULL \n" ); - return f; /*using crude but spot able values some times helps debuggin */ -} -/* helper functions for everything is animateble jow_go_for2_5 ------*/ - /* makes totally fresh start situation */ static void mesh_to_softbody(Scene *scene, Object *ob) @@ -3293,10 +3297,18 @@ static void mesh_to_softbody(Scene *scene, Object *ob) /* this is where '2.5 every thing is animateable' goes wrong in the first place jow_go_for2_5 */ /* 1st coding action to take : move this to frame level */ /* reads: leave the bp->goal as it was read from vertex group / or default .. we will need it at per frame call */ - bp->goal= sb->mingoal + bp->goal*goalfac; /* do not do here jow_go_for2_5 */ + /* should be fixed for meshes */ + // bp->goal= sb->mingoal + bp->goal*goalfac; /* do not do here jow_go_for2_5 */ + } + else{ + /* in consequence if no group was set .. but we want to animate it laters */ + /* logically attach to goal at first */ + if(ob->softflag & OB_SB_GOAL){bp->goal =1.0f;} } + /* a little ad hoc changing the goal control to be less *sharp* */ - bp->goal = (float)pow(bp->goal, 4.0f);/* do not do here jow_go_for2_5 */ + /* should be fixed for meshes */ + // bp->goal = (float)pow(bp->goal, 4.0f);/* do not do here jow_go_for2_5 */ /* to proove the concept this would enable per vertex *mass painting* @@ -3530,6 +3542,8 @@ static void lattice_to_softbody(Scene *scene, Object *ob) if(ob->softflag & OB_SB_GOAL){ BodyPoint *bp= sb->bpoint; BPoint *bpnt= lt->def; + /* goes wrong with jow_go_for2_5 */ + /* for now this is a built in bug .. by design */ float goalfac= ABS(sb->maxgoal - sb->mingoal); int a; -- cgit v1.2.3 From 975cf38d6a78b60b0db899abd5a7dc950df133c5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 13 Mar 2010 11:22:39 +0000 Subject: Fix #21282: Segfault when using "Text on curve" option Ignore textoncurve property if it's type isn't OB_CURVE, since only curves could have a path. --- source/blender/blenkernel/intern/font.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 36bb031744e..efd93aa362d 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -960,7 +960,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) } /* TEXT ON CURVE */ - if(cu->textoncurve) { + /* Note: Only OB_CURVE objects could have a path */ + if(cu->textoncurve && cu->textoncurve->type==OB_CURVE) { Curve *cucu= cu->textoncurve->data; int oldflag= cucu->flag; -- cgit v1.2.3 From eea945347063cb44ea99c00a490ffc06e0a714be Mon Sep 17 00:00:00 2001 From: Jens Ole Wund Date: Sat, 13 Mar 2010 19:12:54 +0000 Subject: softbody properties mingoal maxgoal are 'hot' now for meshes lattices and curves changes work immediately in the running simulation --- source/blender/blenkernel/intern/softbody.c | 50 +++++++++-------------------- 1 file changed, 15 insertions(+), 35 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index d804f87daff..8c44737adb6 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -212,7 +212,7 @@ static float sb_time_scale(Object *ob) } /*--- frame based timing ---*/ -/* helper functions for everything is animateble jow_go_for2_5 +++++++*/ +/* helper functions for everything is animatable jow_go_for2_5 +++++++*/ /* introducing them here, because i know: steps in properties ( at frame timing ) will cause unwanted responses of the softbody system (which does inter frame calculations ) so first 'cure' would be: interpolate linear in time .. @@ -220,16 +220,8 @@ static float sb_time_scale(Object *ob) A: because it happend once, that some eger coder 'streamlined' code to fail. We DO linear interpolation for goals .. and i think we should do on animated properties as well */ -static float _goalfac(SoftBody *sb)/*jow_go_for2_5 */ -{ - if (sb){ - return ABS(sb->maxgoal - sb->mingoal); - } - printf("_goalfac failed! sb==NULL \n" ); - return -9999.99f; /*using crude but spot able values some times helps debuggin */ -} - +/* animate sb->maxgoal,sb->mingoal */ static float _final_goal(Object *ob,BodyPoint *bp)/*jow_go_for2_5 */ { float f = -1999.99f; @@ -238,8 +230,9 @@ static float _final_goal(Object *ob,BodyPoint *bp)/*jow_go_for2_5 */ if(!(ob->softflag & OB_SB_GOAL)) return (0.0f); if (sb&&bp){ if (bp->goal < 0.0f) return (0.0f); - f = pow(_goalfac(sb), 4.0f); - return (bp->goal *f); + f = sb->mingoal + bp->goal*ABS(sb->maxgoal - sb->mingoal); + f = pow(f, 4.0f); + return (f); } } printf("_final_goal failed! sb or bp ==NULL \n" ); @@ -881,6 +874,10 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring for (i=0; ibpoint[i]; + + /* hum as far as i see this is overridden by _final_goal() now jow_go_for2_5 */ + /* sadly breaks compatibility with older versions */ + /* but makes goals behave the same for meshes, lattices and curves */ if(softflag & OB_SB_GOAL) { bp->goal= sb->defgoal; } @@ -3268,7 +3265,6 @@ static void mesh_to_softbody(Scene *scene, Object *ob) MEdge *medge= me->medge; BodyPoint *bp; BodySpring *bs; - float goalfac; int a, totedge; if (ob->softflag & OB_SB_EDGES) totedge= me->totedge; else totedge= 0; @@ -3279,8 +3275,6 @@ static void mesh_to_softbody(Scene *scene, Object *ob) /* we always make body points */ sb= ob->soft; bp= sb->bpoint; - /*pick it from _goalfac jow_go_for2_5*/ - goalfac= _goalfac(sb); for(a=0; atotvert; a++, bp++) { /* get scalar values needed *per vertex* from vertex group functions, @@ -3302,13 +3296,9 @@ static void mesh_to_softbody(Scene *scene, Object *ob) } else{ /* in consequence if no group was set .. but we want to animate it laters */ - /* logically attach to goal at first */ - if(ob->softflag & OB_SB_GOAL){bp->goal =1.0f;} + /* logically attach to goal with default first */ + if(ob->softflag & OB_SB_GOAL){bp->goal =sb->defgoal;} } - - /* a little ad hoc changing the goal control to be less *sharp* */ - /* should be fixed for meshes */ - // bp->goal = (float)pow(bp->goal, 4.0f);/* do not do here jow_go_for2_5 */ /* to proove the concept this would enable per vertex *mass painting* @@ -3542,15 +3532,11 @@ static void lattice_to_softbody(Scene *scene, Object *ob) if(ob->softflag & OB_SB_GOAL){ BodyPoint *bp= sb->bpoint; BPoint *bpnt= lt->def; - /* goes wrong with jow_go_for2_5 */ - /* for now this is a built in bug .. by design */ - float goalfac= ABS(sb->maxgoal - sb->mingoal); + /* jow_go_for2_5 */ int a; for(a=0; agoal= sb->mingoal + bpnt->weight*goalfac; - /* a little ad hoc changing the goal control to be less *sharp* */ - bp->goal = (float)pow(bp->goal, 4.0f); + bp->goal= bpnt->weight; } } @@ -3571,7 +3557,6 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) Nurb *nu; BezTriple *bezt; BPoint *bpnt; - float goalfac; int a, curindex=0; int totvert, totspring = 0, setgoal=0; @@ -3588,7 +3573,6 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) sb= ob->soft; /* can be created in renew_softbody() */ /* set vars now */ - goalfac= ABS(sb->maxgoal - sb->mingoal); bp= sb->bpoint; bs= sb->bspring; @@ -3602,9 +3586,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) if(nu->bezt) { for(bezt=nu->bezt, a=0; apntsu; a++, bezt++, bp+=3, curindex+=3) { if(setgoal) { - bp->goal= sb->mingoal + bezt->weight*goalfac; - /* a little ad hoc changing the goal control to be less *sharp* */ - bp->goal = (float)pow(bp->goal, 4.0f); + bp->goal= bezt->weight; /* all three triples */ (bp+1)->goal= bp->goal; @@ -3636,9 +3618,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) else { for(bpnt=nu->bp, a=0; apntsu*nu->pntsv; a++, bpnt++, bp++, curindex++) { if(setgoal) { - bp->goal= sb->mingoal + bpnt->weight*goalfac; - /* a little ad hoc changing the goal control to be less *sharp* */ - bp->goal = (float)pow(bp->goal, 4.0f); + bp->goal= bpnt->weight; } if(totspring && a>0) { bs->v1= curindex-1; -- cgit v1.2.3 From c56f04d349d0d09a62a850ab4c042e9bafa047c6 Mon Sep 17 00:00:00 2001 From: Jens Ole Wund Date: Sat, 13 Mar 2010 21:22:56 +0000 Subject: soft body property nodemass became 'hot' for meshes could not test for lattices and curves since parts of the UI is missing will try to fix this next .. hurms not knowing what i am doing there --- source/blender/blenkernel/intern/softbody.c | 34 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 8c44737adb6..a67cf98865f 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -238,6 +238,18 @@ static float _final_goal(Object *ob,BodyPoint *bp)/*jow_go_for2_5 */ printf("_final_goal failed! sb or bp ==NULL \n" ); return f; /*using crude but spot able values some times helps debuggin */ } + +static float _final_mass(Object *ob,BodyPoint *bp) +{ + if (ob){ + SoftBody *sb= ob->soft; /* is supposed to be there */ + if (sb&&bp){ + return(bp->mass*sb->nodemass); + } + } + printf("_final_mass failed! sb or bp ==NULL \n" ); + return 1.0f; +} /* helper functions for everything is animateble jow_go_for2_5 ------*/ /*+++ collider caching and dicing +++*/ @@ -894,7 +906,7 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring bp->colball = 0.0f; bp->flag = 0; bp->springweight = 1.0f; - bp->mass = sb->nodemass; + bp->mass = 1.0f; } } } @@ -2234,14 +2246,14 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo mid_v3_v3v3(velcenter, bp->vec, obp->vec); sub_v3_v3v3(dvel,velcenter,bp->vec); - mul_v3_fl(dvel,bp->mass); + mul_v3_fl(dvel,_final_mass(ob,bp)); Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); Vec3PlusStVec(bp->force,sb->balldamp,dvel); /* exploit force(a,b) == -force(b,a) part2/2 */ sub_v3_v3v3(dvel,velcenter,obp->vec); - mul_v3_fl(dvel,bp->mass); + mul_v3_fl(dvel,_final_mass(ob,bp)); Vec3PlusStVec(obp->force,sb->balldamp,dvel); Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def); @@ -2287,7 +2299,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if (sb && scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ float gravity[3]; VECCOPY(gravity, scene->physics_settings.gravity); - mul_v3_fl(gravity, sb_grav_force_scale(ob)*bp->mass*sb->effector_weights->global_gravity); /* individual mass of node here */ + mul_v3_fl(gravity, sb_grav_force_scale(ob)*_final_mass(ob,bp)*sb->effector_weights->global_gravity); /* individual mass of node here */ add_v3_v3v3(bp->force, bp->force, gravity); } @@ -2605,7 +2617,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa mid_v3_v3v3(velcenter, bp->vec, obp->vec); sub_v3_v3v3(dvel,velcenter,bp->vec); - mul_v3_fl(dvel,bp->mass); + mul_v3_fl(dvel,_final_mass(ob,bp)); Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); Vec3PlusStVec(bp->force,sb->balldamp,dvel); @@ -2636,7 +2648,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* exploit force(a,b) == -force(b,a) part2/2 */ sub_v3_v3v3(dvel,velcenter,obp->vec); - mul_v3_fl(dvel,(bp->mass+obp->mass)/2.0f); + mul_v3_fl(dvel,(_final_mass(ob,bp)+_final_mass(ob,obp))/2.0f); Vec3PlusStVec(obp->force,sb->balldamp,dvel); Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def); @@ -2696,7 +2708,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* gravitation */ - VECADDFAC(bp->force, bp->force, gravity, bp->mass); /* individual mass of node here */ + VECADDFAC(bp->force, bp->force, gravity, _final_mass(ob,bp)); /* individual mass of node here */ /* particle field & vortex */ @@ -2916,7 +2928,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { /* now we have individual masses */ /* claim a minimum mass for vertex */ - if (bp->mass > 0.009999f) timeovermass = forcetime/bp->mass; + if (_final_mass(ob,bp) > 0.009999f) timeovermass = forcetime/_final_mass(ob,bp); else timeovermass = forcetime/0.009999f; @@ -3301,10 +3313,8 @@ static void mesh_to_softbody(Scene *scene, Object *ob) } /* to proove the concept - this would enable per vertex *mass painting* + this enables per vertex *mass painting* */ - /* first set the default */ - bp->mass = sb->nodemass; if (sb->namedVG_Mass[0]) { @@ -3312,7 +3322,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) /* printf("VGN %s %d \n",sb->namedVG_Mass,grp); */ if(grp > -1){ get_scalar_from_vertexgroup(ob, a,(short) (grp), &bp->mass); - bp->mass = bp->mass * sb->nodemass; + /* 2.5 bp->mass = bp->mass * sb->nodemass; */ /* printf("bp->mass %f \n",bp->mass); */ } -- cgit v1.2.3 From 7da0c4c699f939c182cab4d22d692043ef2cb3c5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 14 Mar 2010 08:15:20 +0000 Subject: Fix #21599: Duplicating an object with solidify doesnt copy the flags correctly Someone forgot to copy solidify modifier's flag. --- source/blender/blenkernel/intern/modifier.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index c5a420b85a8..68087cb553c 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5697,6 +5697,7 @@ static void solidifyModifier_copyData(ModifierData *md, ModifierData *target) tsmd->crease_inner = smd->crease_inner; tsmd->crease_outer = smd->crease_outer; tsmd->crease_rim = smd->crease_rim; + tsmd->flag = smd->flag; strcpy(tsmd->defgrp_name, smd->defgrp_name); } -- cgit v1.2.3 From 94d06bf3d4648d101d6c0d5f8f16c2d99f848d87 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 14 Mar 2010 12:12:21 +0000 Subject: Fix #21594: converting bevel objects to mesh stops displaying them in spacial cases Mesh's boundbox should be re-calculated after curve->mesh conversion. To avoid troubles with displaying texture space i've used tex_space_mesh() for this. --- source/blender/blenkernel/intern/mesh.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index b7efc0c626b..8d2dfcd1989 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -987,6 +987,9 @@ void nurbs_to_mesh(Object *ob) me->totcol= cu->totcol; me->mat= cu->mat; + + tex_space_mesh(me); + cu->mat= 0; cu->totcol= 0; -- cgit v1.2.3 From ac76568e67ed224c57279ab2603817910cb8a42e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 14 Mar 2010 13:05:42 +0000 Subject: Fixed incorrect calculation of constructive modifiers when rendering. DerivedMesh was crating from object's disp instead of specified one. --- source/blender/blenkernel/intern/displist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index ee746a4dacd..b9588f4520c 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1391,7 +1391,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba CDDM_calc_normals(dm); } } else { - dm= CDDM_from_curve(ob); + dm= CDDM_from_curve_customDB(ob, dispbase); if(dmDeformedVerts) { CDDM_apply_vert_coords(dm, dmDeformedVerts); -- cgit v1.2.3 From 128ecc7e822cdc989175a348edcc20f6858d6805 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 14 Mar 2010 16:36:41 +0000 Subject: == Sequencer == This fixes [#21087] Opacity of 0 turns off effect rather than affecting transparency and makes the whole early_out-business in strip stack a lot more readable. The actual fix is just using the composited result in layer fall through case (se1->ibuf_comp instead of se1->ibuf). --- source/blender/blenkernel/intern/sequencer.c | 78 +++++++++++++++++++--------- 1 file changed, 53 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 341d0a542e6..d43747cf3f3 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2452,6 +2452,42 @@ static TStripElem* do_build_seq_recursively(Scene *scene, Sequence * seq, int cf return se; } +static int seq_must_swap_input_in_blend_mode(Sequence * seq) +{ + int swap_input = FALSE; + + /* bad hack, to fix crazy input ordering of + those two effects */ + + if (seq->blend_mode == SEQ_ALPHAOVER || + seq->blend_mode == SEQ_ALPHAUNDER || + seq->blend_mode == SEQ_OVERDROP) { + swap_input = TRUE; + } + + return swap_input; +} + +static int seq_get_early_out_for_blend_mode(Sequence * seq) +{ + struct SeqEffectHandle sh = get_sequence_blend(seq); + float facf = seq->blend_opacity / 100.0; + int early_out = sh.early_out(seq, facf, facf); + + if (early_out < 1) { + return early_out; + } + + if (seq_must_swap_input_in_blend_mode(seq)) { + if (early_out == 2) { + return 1; + } else if (early_out == 1) { + return 2; + } + } + return early_out; +} + static TStripElem* do_build_seq_array_recursively(Scene *scene, ListBase *seqbasep, int cfra, int chanshown, int render_size) { @@ -2460,7 +2496,8 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, int i; TStripElem* se = 0; - count = get_shown_sequences(seqbasep, cfra, chanshown, (Sequence **)&seq_arr); + count = get_shown_sequences(seqbasep, cfra, chanshown, + (Sequence **)&seq_arr); if (!count) { return 0; @@ -2483,7 +2520,8 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, if(count == 1) { - se = do_build_seq_recursively(scene, seq_arr[0], cfra, render_size); + se = do_build_seq_recursively(scene, seq_arr[0], + cfra, render_size); if (se->ibuf) { se->ibuf_comp = se->ibuf; IMB_refImBuf(se->ibuf_comp); @@ -2495,8 +2533,6 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, for (i = count - 1; i >= 0; i--) { int early_out; Sequence * seq = seq_arr[i]; - struct SeqEffectHandle sh; - float facf; se = give_tstripelem(seq, cfra); @@ -2506,7 +2542,9 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, break; } if (seq->blend_mode == SEQ_BLEND_REPLACE) { - do_build_seq_recursively(scene, seq, cfra, render_size); + do_build_seq_recursively( + scene, seq, cfra, render_size); + if (se->ibuf) { se->ibuf_comp = se->ibuf; IMB_refImBuf(se->ibuf); @@ -2521,16 +2559,14 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, break; } - sh = get_sequence_blend(seq); - - facf = seq->blend_opacity / 100.0; - - early_out = sh.early_out(seq, facf, facf); + early_out = seq_get_early_out_for_blend_mode(seq); switch (early_out) { case -1: case 2: - do_build_seq_recursively(scene, seq, cfra, render_size); + do_build_seq_recursively( + scene, seq, cfra, render_size); + if (se->ibuf) { se->ibuf_comp = se->ibuf; IMB_refImBuf(se->ibuf_comp); @@ -2554,7 +2590,9 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, } break; case 0: - do_build_seq_recursively(scene, seq, cfra, render_size); + do_build_seq_recursively( + scene, seq, cfra, render_size); + if (!se->ibuf) { se->ibuf = IMB_allocImBuf( (short)seqrectx, (short)seqrecty, @@ -2584,14 +2622,13 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, TStripElem* se2 = give_tstripelem(seq_arr[i], cfra); float facf = seq->blend_opacity / 100.0; - - int early_out = sh.early_out(seq, facf, facf); + int swap_input = seq_must_swap_input_in_blend_mode(seq); + int early_out = seq_get_early_out_for_blend_mode(seq); switch (early_out) { case 0: { int x= se2->ibuf->x; int y= se2->ibuf->y; - int swap_input = FALSE; if(se1->ibuf_comp == NULL) continue; @@ -2626,15 +2663,6 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, IMB_rect_from_float(se2->ibuf); } - /* bad hack, to fix crazy input ordering of - those two effects */ - - if (seq->blend_mode == SEQ_ALPHAOVER || - seq->blend_mode == SEQ_ALPHAUNDER || - seq->blend_mode == SEQ_OVERDROP) { - swap_input = TRUE; - } - if (swap_input) { sh.execute(scene, seq, cfra, facf, facf, x, y, @@ -2657,7 +2685,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, break; } case 1: { - se2->ibuf_comp = se1->ibuf; + se2->ibuf_comp = se1->ibuf_comp; if(se2->ibuf_comp) IMB_refImBuf(se2->ibuf_comp); -- cgit v1.2.3 From ed076d74ef3f0593971108511dc25e63cab7e829 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 14 Mar 2010 20:24:11 +0000 Subject: Rendering from 3d view in local view or with unlocked layer was not working yet, now layer is passed along to render engine, changes quite a few files because simple swapping trick no longer works with threading. --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d43747cf3f3..a4a0a533545 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2181,7 +2181,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int else re= RE_NewRender(sce->id.name, RE_SLOT_VIEW); - RE_BlenderFrame(re, sce, NULL, frame); + RE_BlenderFrame(re, sce, sce->lay, NULL, frame); RE_AcquireResultImage(re, &rres); -- cgit v1.2.3 From 9385c465814c2f14d9ec478bddf87100da903b40 Mon Sep 17 00:00:00 2001 From: Jens Ole Wund Date: Sun, 14 Mar 2010 21:15:22 +0000 Subject: soft bodies kind of bug fixing: After watching 2.5 from a distance, i did review the soft body module to match in 2.5 every thing can be animated rule. Until now i did not realize, that, by default, every property is 'fcurve'-able unless told to be not. I really like it that way. However SB code did assume some things not to be changing after birth of the SB object. After spending some hours with softbody.c /* as may be read in its history */ I think most of the SB properties are ready to go. For those that do not, some of them never will, i did reset the flag in the RNA definitions. There is one not completely resolved: bending stiffness which will work if the initial value was non zero, because only in this case the secondary set of springs needed is built at all. Duh, and there a zillions of cases to test .. please do so. --- source/blender/blenkernel/intern/softbody.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index a67cf98865f..1ebf613dea8 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3412,7 +3412,7 @@ static void reference_to_scratch(Object *ob) for(a=0; atotpoint; a++, rp++, bp++) { VECCOPY(rp->pos,bp->pos); VECADD(accu_pos,accu_pos,bp->pos); - accu_mass += bp-> mass; + accu_mass += _final_mass(ob,bp); } mul_v3_fl(accu_pos,1.0f/accu_mass); VECCOPY(sb->scratch->Ref.com,accu_pos); -- cgit v1.2.3 From 14c2fc3c12f2f5b43a8689f2a54c249a4325118c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 14 Mar 2010 21:25:01 +0000 Subject: Various warning fixes. --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index a4a0a533545..5e3ab5f5f84 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2181,7 +2181,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int else re= RE_NewRender(sce->id.name, RE_SLOT_VIEW); - RE_BlenderFrame(re, sce, sce->lay, NULL, frame); + RE_BlenderFrame(re, sce, NULL, sce->lay, frame); RE_AcquireResultImage(re, &rres); -- cgit v1.2.3 From ea4a987fd424de77465f1a2cd95a655ccf42fd31 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 16 Mar 2010 06:18:49 +0000 Subject: == Massive Keying Sets Recode == After a few days of wrong turns and learning the finer points of RNA-type-subclassing the hard way, this commit finally presents a refactored version of the Keying Sets system (now version 2) based on some requirements from Cessen. For a more thorough discussion of this commit, see http://sites.google.com/site/aligorith/keyingsets_2.pdf?attredirects=0&d=1 ------ The main highlight of this refactor is that relative Keying Sets have now been recoded so that Python callbacks are run to generate the Keying Set's list of paths everytime the Keying Set is used (to insert or delete keyframes), allowing complex heuristics to be used to determine whether a property gets keyframed based on the current context. These checks may include checking on selection status of related entities, or transform locks. Built-In KeyingSets have also been recoded, and moved from C and out into Python. These are now coded as Relative Keying Sets, and can to some extent serve as basis for adding new relative Keying Sets. However, these have mostly been coded in a slightly 'modular' way which may be confusing for those not so familiar with Python in general. A usable template will be added soon for more general usage. Keyframing settings (i.e. 'visual', 'needed') can now be specified on a per-path basis now, which is especially useful for Absolute Keying Sets, where control over this is often beneficial. Most of the places where Auto-Keyframing is performed have been tidied up for consistency. I'm sure quite a few issues still exist there, but these I'll clean up over the next few days. --- source/blender/blenkernel/BKE_animsys.h | 5 ++- source/blender/blenkernel/intern/anim_sys.c | 67 ++++++++++++++++------------- 2 files changed, 41 insertions(+), 31 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index f6950ba07b8..8644074d4e9 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -71,7 +71,7 @@ void BKE_animdata_make_local(struct AnimData *adt); struct KeyingSet *BKE_keyingset_add(struct ListBase *list, const char name[], short flag, short keyingflag); /* Add a path to a KeyingSet */ -void BKE_keyingset_add_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode); +struct KS_Path *BKE_keyingset_add_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode); /* Find the destination matching the criteria given */ struct KS_Path *BKE_keyingset_find_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode); @@ -79,6 +79,9 @@ struct KS_Path *BKE_keyingset_find_path(struct KeyingSet *ks, struct ID *id, con /* Copy all KeyingSets in the given list */ void BKE_keyingsets_copy(struct ListBase *newlist, struct ListBase *list); +/* Free the given Keying Set path */ +void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp); + /* Free data for KeyingSet but not set itself */ void BKE_keyingset_free(struct KeyingSet *ks); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index a880417a111..8ec8f24d5fe 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -621,53 +621,48 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho return ks; } -/* Add a destination to a KeyingSet. Nothing is returned for now... +/* Add a path to a KeyingSet. Nothing is returned for now... * Checks are performed to ensure that destination is appropriate for the KeyingSet in question */ -void BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode) +KS_Path *BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode) { KS_Path *ksp; /* sanity checks */ if ELEM(NULL, ks, rna_path) { - printf("ERROR: no Keying Set and/or RNA Path to add destination with \n"); - return; + printf("ERROR: no Keying Set and/or RNA Path to add path with \n"); + return NULL; } - /* ID is optional for relative KeyingSets, but is necessary for absolute KeyingSets */ + /* ID is required for all types of KeyingSets */ if (id == NULL) { - if (ks->flag & KEYINGSET_ABSOLUTE) { - printf("ERROR: No ID provided for absolute destination. \n"); - return; - } + printf("ERROR: No ID provided for Keying Set Path. \n"); + return NULL; } /* don't add if there is already a matching KS_Path in the KeyingSet */ if (BKE_keyingset_find_path(ks, id, group_name, rna_path, array_index, groupmode)) { if (G.f & G_DEBUG) printf("ERROR: destination already exists in Keying Set \n"); - return; + return NULL; } /* allocate a new KeyingSet Path */ ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path"); /* just store absolute info */ - if (ks->flag & KEYINGSET_ABSOLUTE) { - ksp->id= id; - if (group_name) - BLI_snprintf(ksp->group, 64, group_name); - else - strcpy(ksp->group, ""); - } + ksp->id= id; + if (group_name) + BLI_snprintf(ksp->group, 64, group_name); + else + strcpy(ksp->group, ""); /* store additional info for relative paths (just in case user makes the set relative) */ if (id) ksp->idtype= GS(id->name); /* just copy path info */ - // XXX no checks are performed for templates yet - // should array index be checked too? + // TODO: should array index be checked too? ksp->rna_path= BLI_strdupn(rna_path, strlen(rna_path)); ksp->array_index= array_index; @@ -677,20 +672,37 @@ void BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[], con /* add KeyingSet path to KeyingSet */ BLI_addtail(&ks->paths, ksp); + + /* return this path */ + return ksp; } +/* Free the given Keying Set path */ +void BKE_keyingset_free_path (KeyingSet *ks, KS_Path *ksp) +{ + /* sanity check */ + if ELEM(NULL, ks, ksp) + return; + + /* free RNA-path info */ + MEM_freeN(ksp->rna_path); + + /* free path itself */ + BLI_freelinkN(&ks->paths, ksp); +} + /* Copy all KeyingSets in the given list */ -void BKE_keyingsets_copy(ListBase *newlist, ListBase *list) +void BKE_keyingsets_copy (ListBase *newlist, ListBase *list) { KeyingSet *ksn; KS_Path *kspn; - + BLI_duplicatelist(newlist, list); - for(ksn=newlist->first; ksn; ksn=ksn->next) { + for (ksn=newlist->first; ksn; ksn=ksn->next) { BLI_duplicatelist(&ksn->paths, &ksn->paths); - - for(kspn=ksn->paths.first; kspn; kspn=kspn->next) + + for (kspn=ksn->paths.first; kspn; kspn=kspn->next) kspn->rna_path= MEM_dupallocN(kspn->rna_path); } } @@ -709,12 +721,7 @@ void BKE_keyingset_free (KeyingSet *ks) /* free each path as we go to avoid looping twice */ for (ksp= ks->paths.first; ksp; ksp= kspn) { kspn= ksp->next; - - /* free RNA-path info */ - MEM_freeN(ksp->rna_path); - - /* free path itself */ - BLI_freelinkN(&ks->paths, ksp); + BKE_keyingset_free_path(ks, ksp); } } -- cgit v1.2.3 From dc5945e7f0f5d7e85f9ff1dfbb5f762f45cf3509 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 16 Mar 2010 07:44:57 +0000 Subject: Fix [#21165] Moved textures don't move the animation curves --- source/blender/blenkernel/BKE_animsys.h | 2 +- source/blender/blenkernel/intern/anim_sys.c | 47 ++++++++++++++++------------- 2 files changed, 27 insertions(+), 22 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index 8644074d4e9..af5e31b1efa 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -92,7 +92,7 @@ void BKE_keyingsets_free(struct ListBase *list); /* Path Fixing API */ /* Fix all the paths for the given ID+AnimData */ -void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, char *prefix, char *oldName, char *newName); +void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, char *prefix, char *oldName, char *newName, int oldSubscript, int newSubscript, int verify_paths); /* Fix all the paths for the entire database... */ void BKE_all_animdata_fix_paths_rename(char *prefix, char *oldName, char *newName); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 8ec8f24d5fe..307ed1bfcd4 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -274,7 +274,7 @@ static short check_rna_path_is_valid (ID *owner_id, char *path) /* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate * NOTE: we assume that oldName and newName have [" "] padding around them */ -static char *rna_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, char *oldpath) +static char *rna_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, char *oldpath, int verify_paths) { char *prefixPtr= strstr(oldpath, prefix); char *oldNamePtr= strstr(oldpath, oldName); @@ -286,7 +286,7 @@ static char *rna_path_rename_fix (ID *owner_id, char *prefix, char *oldName, cha */ if ( (prefixPtr && oldNamePtr) && (prefixPtr+prefixLen == oldNamePtr) ) { /* if we haven't aren't able to resolve the path now, try again after fixing it */ - if (check_rna_path_is_valid(owner_id, oldpath) == 0) { + if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) { DynStr *ds= BLI_dynstr_new(); char *postfixPtr= oldNamePtr+oldNameLen; char *newPath = NULL; @@ -315,7 +315,7 @@ static char *rna_path_rename_fix (ID *owner_id, char *prefix, char *oldName, cha /* check if the new path will solve our problems */ // TODO: will need to check whether this step really helps in practice - if (check_rna_path_is_valid(owner_id, newPath)) { + if (!verify_paths || check_rna_path_is_valid(owner_id, newPath)) { /* free the old path, and return the new one, since we've solved the issues */ MEM_freeN(oldpath); return newPath; @@ -332,7 +332,7 @@ static char *rna_path_rename_fix (ID *owner_id, char *prefix, char *oldName, cha } /* Check RNA-Paths for a list of F-Curves */ -static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, ListBase *curves) +static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, ListBase *curves, int verify_paths) { FCurve *fcu; @@ -340,7 +340,7 @@ static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, for (fcu= curves->first; fcu; fcu= fcu->next) { /* firstly, handle the F-Curve's own path */ if (fcu->rna_path) - fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldName, newName, fcu->rna_path); + fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldName, newName, fcu->rna_path, verify_paths); /* driver? */ if (fcu->driver) { @@ -354,7 +354,7 @@ static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, { /* rename RNA path */ if (dtar->rna_path) - dtar->rna_path= rna_path_rename_fix(dtar->id, prefix, oldName, newName, dtar->rna_path); + dtar->rna_path= rna_path_rename_fix(dtar->id, prefix, oldName, newName, dtar->rna_path, verify_paths); /* also fix the bone-name (if applicable) */ // XXX this has been disabled because the old/new names have padding which means this check will fail @@ -371,7 +371,7 @@ static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, } /* Fix all RNA-Paths for Actions linked to NLA Strips */ -static void nlastrips_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, ListBase *strips) +static void nlastrips_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, ListBase *strips, int verify_paths) { NlaStrip *strip; @@ -379,11 +379,11 @@ static void nlastrips_path_rename_fix (ID *owner_id, char *prefix, char *oldName for (strip= strips->first; strip; strip= strip->next) { /* fix strip's action */ if (strip->act) - fcurves_path_rename_fix(owner_id, prefix, oldName, newName, &strip->act->curves); + fcurves_path_rename_fix(owner_id, prefix, oldName, newName, &strip->act->curves, verify_paths); /* ignore own F-Curves, since those are local... */ /* check sub-strips (if metas) */ - nlastrips_path_rename_fix(owner_id, prefix, oldName, newName, &strip->strips); + nlastrips_path_rename_fix(owner_id, prefix, oldName, newName, &strip->strips, verify_paths); } } @@ -391,31 +391,36 @@ static void nlastrips_path_rename_fix (ID *owner_id, char *prefix, char *oldName * NOTE: it is assumed that the structure we're replacing is <["><"]> * i.e. pose.bones["Bone"] */ -void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, char *oldName, char *newName) +void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, char *oldName, char *newName, int oldSubscript, int newSubscript, int verify_paths) { NlaTrack *nlt; char *oldN, *newN; /* if no AnimData, no need to proceed */ - if (ELEM4(NULL, owner_id, adt, oldName, newName)) + if (ELEM(NULL, owner_id, adt)) return; - /* pad the names with [" "] so that only exact matches are made */ - oldN= BLI_sprintfN("[\"%s\"]", oldName); - newN= BLI_sprintfN("[\"%s\"]", newName); + if (oldName != NULL && newName != NULL) { + /* pad the names with [" "] so that only exact matches are made */ + oldN= BLI_sprintfN("[\"%s\"]", oldName); + newN= BLI_sprintfN("[\"%s\"]", newName); + } else { + oldN= BLI_sprintfN("[%d]", oldSubscript); + newN= BLI_sprintfN("[%d]", newSubscript); + } /* Active action and temp action */ if (adt->action) - fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->action->curves); + fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->action->curves, verify_paths); if (adt->tmpact) - fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->tmpact->curves); + fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->tmpact->curves, verify_paths); /* Drivers - Drivers are really F-Curves */ - fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->drivers); + fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->drivers, verify_paths); /* NLA Data - Animation Data for Strips */ for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) - nlastrips_path_rename_fix(owner_id, prefix, oldN, newN, &nlt->strips); + nlastrips_path_rename_fix(owner_id, prefix, oldN, newN, &nlt->strips, verify_paths); /* free the temp names */ MEM_freeN(oldN); @@ -482,7 +487,7 @@ void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newNa #define RENAMEFIX_ANIM_IDS(first) \ for (id= first; id; id= id->next) { \ AnimData *adt= BKE_animdata_from_id(id); \ - BKE_animdata_fix_paths_rename(id, adt, prefix, oldName, newName);\ + BKE_animdata_fix_paths_rename(id, adt, prefix, oldName, newName, 0, 0, 1);\ } /* nodes */ @@ -532,11 +537,11 @@ void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newNa /* do compositing nodes first (since these aren't included in main tree) */ if (scene->nodetree) { AnimData *adt2= BKE_animdata_from_id((ID *)scene->nodetree); - BKE_animdata_fix_paths_rename((ID *)scene->nodetree, adt2, prefix, oldName, newName); + BKE_animdata_fix_paths_rename((ID *)scene->nodetree, adt2, prefix, oldName, newName, 0, 0, 1); } /* now fix scene animation data as per normal */ - BKE_animdata_fix_paths_rename((ID *)id, adt, prefix, oldName, newName); + BKE_animdata_fix_paths_rename((ID *)id, adt, prefix, oldName, newName, 0, 0, 1); } } -- cgit v1.2.3 From d617294c49912b1b0473bbbe58f62a3549641482 Mon Sep 17 00:00:00 2001 From: Roland Hess Date: Tue, 16 Mar 2010 12:55:56 +0000 Subject: New "Maintain Volume" constraint. When attached to a bone, you specify a "free" axis. Upon scaling, this free axis scales normally, but the constraint forces the other two axes to adjust themselves appropriately so that overall bone volume is maintained. So, setting "Y" as the free axis (the default) creates a bone that automatically squashes and stretches when scaling. Thanks to Aligorith, Fweeb, Cessen and others for the feedback. --- source/blender/blenkernel/intern/constraint.c | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 91bf4b8d8b2..08ac5e6acce 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1859,6 +1859,64 @@ static bConstraintTypeInfo CTI_TRANSLIKE = { translike_evaluate /* evaluate */ }; +/* ---------- Maintain Volume ---------- */ + +static void samevolume_new_data (void *cdata) +{ + bSameVolumeConstraint *data= (bSameVolumeConstraint *)cdata; + + data->flag = SAMEVOL_Y; + data->volume = 1.0f; +} + +static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob) +{ + bSameVolumeConstraint *data= con->data; + + float obsize[3]; + float volume=data->volume; + + mat4_to_size(obsize, cob->matrix); + + switch (data->flag) { + case SAMEVOL_X: + if (obsize[0]!=0) { + mul_v3_fl(cob->matrix[1], sqrt(volume/obsize[0])/obsize[0]); + mul_v3_fl(cob->matrix[2], sqrt(volume/obsize[0])/obsize[0]); + } + break; + case SAMEVOL_Y: + if (obsize[1]!=0) { + mul_v3_fl(cob->matrix[0], sqrt(volume/obsize[1])/obsize[1]); + mul_v3_fl(cob->matrix[2], sqrt(volume/obsize[1])/obsize[1]); + } + break; + case SAMEVOL_Z: + if (obsize[2]!=0) { + mul_v3_fl(cob->matrix[0], sqrt(volume/obsize[2])/obsize[2]); + mul_v3_fl(cob->matrix[1], sqrt(volume/obsize[2])/obsize[2]); + } + break; + } + +} + +static bConstraintTypeInfo CTI_SAMEVOL = { + CONSTRAINT_TYPE_SAMEVOL, /* type */ + sizeof(bSameVolumeConstraint), /* size */ + "Maintain Volume", /* name */ + "bSameVolumeConstraint", /* struct name */ + NULL, /* free data */ + NULL, /* relink data */ + NULL, /* id looper */ + NULL, /* copy data */ + samevolume_new_data, /* new data */ + NULL, /* get constraint targets */ + NULL, /* flush constraint targets */ + NULL, /* get target matrix */ + samevolume_evaluate /* evaluate */ +}; + /* ----------- Python Constraint -------------- */ static void pycon_free (bConstraint *con) @@ -3805,6 +3863,7 @@ static void constraints_init_typeinfo () { constraintsTypeInfo[21]= &CTI_DAMPTRACK; /* Damped TrackTo Constraint */ constraintsTypeInfo[22]= &CTI_SPLINEIK; /* Spline IK Constraint */ constraintsTypeInfo[23]= &CTI_TRANSLIKE; /* Copy Transforms Constraint */ + constraintsTypeInfo[24]= &CTI_SAMEVOL; /* Maintain Volume Constraint */ } /* This function should be used for getting the appropriate type-info when only -- cgit v1.2.3 From f17dcf58c86274661a10cf4f95939deb63a02fa7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 16 Mar 2010 16:58:45 +0000 Subject: Fixes for thread related render / compositing crashes: * Viewer node could free image while it is being redrawn, viewer image buffers now need acquire/release to be accessed as was already the case for render results. * The Composite node could free the image buffers outside of a lock, also causing simultaneous redraw to crash. * Especially on Windows, re-rendering could crash when drawing an image that was freed. When RE_RenderInProgress was true it would access the image buffer and simply return it while it could still contain a pointer to a render result buffer that was already freed. I don't understand why this case was there in the first place, so I've removed it. Possibly fixes bugs #20174, #21418, #21391, #21394. --- source/blender/blenkernel/intern/image.c | 191 +++++++++++++++---------------- 1 file changed, 90 insertions(+), 101 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ee3d685938b..f870fc1083b 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1932,113 +1932,93 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) /* always returns a single ibuf, also during render progress */ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_r) { - Render *re= NULL; - RenderResult *rr= NULL; - + Render *re; + RenderResult rres; + float *rectf, *rectz; + unsigned int *rect; + float dither; + int channels, layer, pass; + ImBuf *ibuf; + + if(!(iuser && iuser->scene)) + return NULL; + /* if we the caller is not going to release the lock, don't give the image */ if(!lock_r) return NULL; - if(iuser && iuser->scene) { - re= RE_GetRender(iuser->scene->id.name, RE_SLOT_VIEW); - rr= RE_AcquireResultRead(re); + re= RE_GetRender(iuser->scene->id.name, RE_SLOT_VIEW); + + channels= 4; + layer= (iuser)? iuser->layer: 0; + pass= (iuser)? iuser->pass: 0; + + /* this gives active layer, composite or seqence result */ + RE_AcquireResultImage(re, &rres); + rect= (unsigned int *)rres.rect32; + rectf= rres.rectf; + rectz= rres.rectz; + dither= iuser->scene->r.dither_intensity; + + /* get compo/seq result by default */ + if(rres.rectf && layer==0); + else if(rres.layers.first) { + RenderLayer *rl= BLI_findlink(&rres.layers, layer-(rres.rectf?1:0)); + if(rl) { + RenderPass *rpass; + + /* there's no combined pass, is in renderlayer itself */ + if(pass==0) { + rectf= rl->rectf; + } + else { + rpass= BLI_findlink(&rl->passes, pass-1); + if(rpass) { + channels= rpass->channels; + rectf= rpass->rect; + dither= 0.0f; /* don't dither passes */ + } + } - /* release is done in BKE_image_release_ibuf using lock_r */ - *lock_r= re; + for(rpass= rl->passes.first; rpass; rpass= rpass->next) + if(rpass->passtype == SCE_PASS_Z) + rectz= rpass->rect; + } } - - if(rr==NULL) - return NULL; - if(RE_RenderInProgress(re)) { - ImBuf *ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); - - /* make ibuf if needed, and initialize it */ - /* this only gets called when mutex locked */ - if(ibuf==NULL) { - ibuf= IMB_allocImBuf(rr->rectx, rr->recty, 32, IB_rect, 0); - image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - } - - return ibuf; + if(!(rectf || rect)) { + RE_ReleaseResultImage(re); + return NULL; } - else { - RenderResult rres; - float *rectf, *rectz; - unsigned int *rect; - float dither; - int channels, layer, pass; - - channels= 4; - layer= (iuser)? iuser->layer: 0; - pass= (iuser)? iuser->pass: 0; - - /* this gives active layer, composite or seqence result */ - RE_AcquireResultImage(RE_GetRender(iuser->scene->id.name, RE_SLOT_VIEW), &rres); - rect= (unsigned int *)rres.rect32; - rectf= rres.rectf; - rectz= rres.rectz; - dither= iuser->scene->r.dither_intensity; - - /* get compo/seq result by default */ - if(rr->rectf && layer==0); - else if(rr->layers.first) { - RenderLayer *rl= BLI_findlink(&rr->layers, layer-(rr->rectf?1:0)); - if(rl) { - RenderPass *rpass; - - /* there's no combined pass, is in renderlayer itself */ - if(pass==0) { - rectf= rl->rectf; - } - else { - rpass= BLI_findlink(&rl->passes, pass-1); - if(rpass) { - channels= rpass->channels; - rectf= rpass->rect; - dither= 0.0f; /* don't dither passes */ - } - } - for(rpass= rl->passes.first; rpass; rpass= rpass->next) - if(rpass->passtype == SCE_PASS_Z) - rectz= rpass->rect; - } - } - - if(rectf || rect) { - ImBuf *ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); + ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); - /* make ibuf if needed, and initialize it */ - if(ibuf==NULL) { - ibuf= IMB_allocImBuf(rr->rectx, rr->recty, 32, 0, 0); - image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - } - ibuf->x= rr->rectx; - ibuf->y= rr->recty; - - if(ibuf->rect_float!=rectf || rect) /* ensure correct redraw */ - imb_freerectImBuf(ibuf); - if(rect) - ibuf->rect= rect; - - ibuf->rect_float= rectf; - ibuf->flags |= IB_rectfloat; - ibuf->channels= channels; - ibuf->zbuf_float= rectz; - ibuf->flags |= IB_zbuffloat; - ibuf->dither= dither; + /* make ibuf if needed, and initialize it */ + if(ibuf==NULL) { + ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, 0, 0); + image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); + } + ibuf->x= rres.rectx; + ibuf->y= rres.recty; + + if(ibuf->rect_float!=rectf || rect) /* ensure correct redraw */ + imb_freerectImBuf(ibuf); + if(rect) + ibuf->rect= rect; + + ibuf->rect_float= rectf; + ibuf->flags |= IB_rectfloat; + ibuf->channels= channels; + ibuf->zbuf_float= rectz; + ibuf->flags |= IB_zbuffloat; + ibuf->dither= dither; - RE_ReleaseResultImage(re); + ima->ok= IMA_OK_LOADED; - ima->ok= IMA_OK_LOADED; - return ibuf; - } + /* release is done in BKE_image_release_ibuf using lock_r */ + *lock_r= re; - RE_ReleaseResultImage(re); - } - - return NULL; + return ibuf; } static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame_r, int *index_r) @@ -2199,10 +2179,17 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) ibuf= image_get_render_result(ima, iuser, lock_r); } else if(ima->type==IMA_TYPE_COMPOSITE) { - /* Composite Viewer, all handled in compositor */ - /* fake ibuf, will be filled in compositor */ - ibuf= IMB_allocImBuf(256, 256, 32, IB_rect, 0); - image_assign_ibuf(ima, ibuf, 0, frame); + /* requires lock/unlock, otherwise don't return image */ + if(lock_r) { + /* unlock in BKE_image_release_ibuf */ + BLI_lock_thread(LOCK_VIEWER); + *lock_r= ima; + + /* Composite Viewer, all handled in compositor */ + /* fake ibuf, will be filled in compositor */ + ibuf= IMB_allocImBuf(256, 256, 32, IB_rect, 0); + image_assign_ibuf(ima, ibuf, 0, frame); + } } } } @@ -2220,9 +2207,11 @@ 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, need to release */ - if(lock) - RE_ReleaseResult(lock); + /* for getting image during threaded render / compositing, need to release */ + if(lock == ima) + BLI_unlock_thread(LOCK_VIEWER); /* viewer image */ + else if(lock) + RE_ReleaseResultImage(lock); /* render result */ } ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) -- cgit v1.2.3 From 5c9c50e13bf9a9ce9f5f2f642ea692c8ce4aa331 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 16 Mar 2010 17:37:34 +0000 Subject: change the scene opengl sequence rendering to be a global option with rendering and scrubbing settings. still need to do a do_versions for this to work right without changing settings. (commit 27442 by Campbell from render25 branch) --- source/blender/blenkernel/BKE_sequencer.h | 2 +- source/blender/blenkernel/intern/scene.c | 6 +++++- source/blender/blenkernel/intern/sequencer.c | 7 +++++-- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 21cd2f694ca..40168882dcb 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -234,7 +234,7 @@ struct Sequence *sequencer_add_sound_strip(struct bContext *C, ListBase *seqbase struct Sequence *sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); /* view3d draw callback, run when not in background view */ -typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, int, int); +typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, int, int, int); extern SequencerDrawView sequencer_view3d_cb; /* copy/paste */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 3f0ef5f5bff..82aa5576a78 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -365,7 +365,11 @@ Scene *add_scene(char *name) sce->r.scemode= R_DOCOMP|R_DOSEQ|R_EXTENSION; sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_SCENE|R_STAMP_CAMERA|R_STAMP_RENDERTIME; sce->r.stamp_font_id= 12; - + + sce->r.seq_prev_type= OB_SOLID; + sce->r.seq_rend_type= OB_SOLID; + sce->r.seq_flag= R_SEQ_GL_PREV; + sce->r.threads= 1; sce->r.simplify_subsurf= 6; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5e3ab5f5f84..5b4278c21fb 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2152,6 +2152,9 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int int rendering = 1; int doseq; + int doseq_gl= G.rendering ? (scene->r.seq_flag & R_SEQ_GL_REND) : (scene->r.seq_flag & R_SEQ_GL_PREV); + + printf("%d\n", G.rendering); /* prevent eternal loop */ doseq= scene->r.scemode & R_DOSEQ; @@ -2167,10 +2170,10 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int seq->scene->markers.first= seq->scene->markers.last= NULL; #endif - if(sequencer_view3d_cb && (seq->flag & SEQ_USE_SCENE_OPENGL) && (seq->scene == scene || have_seq==0)) { + if(sequencer_view3d_cb && doseq_gl && (seq->scene == scene || have_seq==0)) { /* opengl offscreen render */ scene_update_for_newframe(seq->scene, seq->scene->lay); - se->ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty); + se->ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, scene->r.seq_prev_type); } else { Render *re; -- cgit v1.2.3 From 056972a97fec313e53fad24afcf718f013d77a4b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 16 Mar 2010 17:42:58 +0000 Subject: minor changes to rna names for consistancy (commit 27445 by Campbell from render25 branch) --- source/blender/blenkernel/intern/sequencer.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5b4278c21fb..42586ce18d7 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2154,8 +2154,6 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int int doseq; int doseq_gl= G.rendering ? (scene->r.seq_flag & R_SEQ_GL_REND) : (scene->r.seq_flag & R_SEQ_GL_PREV); - printf("%d\n", G.rendering); - /* prevent eternal loop */ doseq= scene->r.scemode & R_DOSEQ; scene->r.scemode &= ~R_DOSEQ; -- cgit v1.2.3 From d0c10cd0606a2832cdcec1fd9d3f888db06bd397 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 16 Mar 2010 17:49:31 +0000 Subject: draw option to only display what is rendered, used for sequencer, opengl drawing by default. since we use preview renders a lot the empties & armatures can get in the way also. (commit 27511 by Campbell from render25 branch) --- source/blender/blenkernel/BKE_global.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 6084b0cfb73..291deb5ea70 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -106,7 +106,7 @@ typedef struct Global { #define G_RENDER_OGL (1 << 0) #define G_SWAP_EXCHANGE (1 << 1) /* also uses G_FILE_AUTOPLAY */ -#define G_RENDER_SHADOW (1 << 3) +/* #define G_RENDER_SHADOW (1 << 3) */ /* temp flag, removed */ #define G_BACKBUFSEL (1 << 4) #define G_PICKSEL (1 << 5) -- cgit v1.2.3 From 14e29a62dc33abb0339020c284e564aa8d0b088f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 16 Mar 2010 21:09:53 +0000 Subject: "Fill deformed" option for 2D curves Add new option named "Fill deformed". If this option is switched on. 2D curve will be first deformed by modifiers and only then be filled with faces. --- source/blender/blenkernel/intern/displist.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index b9588f4520c..56eabc0f5ef 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1391,6 +1391,10 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba CDDM_calc_normals(dm); } } else { + if (ELEM(ob->type, OB_CURVE, OB_FONT) && (cu->flag & CU_DEFORM_FILL)) { + curve_to_filledpoly(cu, nurb, &cu->disp); + } + dm= CDDM_from_curve_customDB(ob, dispbase); if(dmDeformedVerts) { @@ -1801,7 +1805,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba freedisplist(&dlbev); } - curve_to_filledpoly(cu, nubase, dispbase); + if (!(cu->flag & CU_DEFORM_FILL)) { + curve_to_filledpoly(cu, nubase, dispbase); + } if(cu->flag & CU_PATH) calc_curvepath(ob); @@ -1810,6 +1816,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } if(!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); + + if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) { + curve_to_filledpoly(cu, nubase, dispbase); + } } } -- cgit v1.2.3 From be3d5f9d5df90737c01338266efd72b3367b9e6c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 17 Mar 2010 11:34:27 +0000 Subject: PyKeyingSet Bugfixes: * With multiple objects selected, only one of the objects got keyframed. The code which was checking for duplicate paths was wrongly assuming to ignore the ID-block used still. * Not registering a Keying Set as 'builtin' would crash on startup. I've made all Keying Sets fallback to adding as if they were local for now, but a better solution is coming soon. * Fixed a typo in RNA function wrappers for the generator callback, since it was looking for the iterator only. This doesn't seem to have caused any problems (thankfully). --- source/blender/blenkernel/intern/anim_sys.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 307ed1bfcd4..31743a6bd1a 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -557,15 +557,9 @@ KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[] KS_Path *ksp; /* sanity checks */ - if ELEM(NULL, ks, rna_path) + if ELEM3(NULL, ks, rna_path, id) return NULL; - /* ID is optional for relative KeyingSets, but is necessary for absolute KeyingSets */ - if (id == NULL) { - if (ks->flag & KEYINGSET_ABSOLUTE) - return NULL; - } - /* loop over paths in the current KeyingSet, finding the first one where all settings match * (i.e. the first one where none of the checks fail and equal 0) */ @@ -573,7 +567,7 @@ KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[] short eq_id=1, eq_path=1, eq_index=1, eq_group=1; /* id */ - if ((ks->flag & KEYINGSET_ABSOLUTE) && (id != ksp->id)) + if (id != ksp->id) eq_id= 0; /* path */ -- cgit v1.2.3 From 618b459e8b3630eea747523febec666889a364f7 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 18 Mar 2010 13:04:46 +0000 Subject: F-Modifier Goodies (as requested by @ndy): * Copy/Paste operators for F-Modifiers Available in Graph and NLA Editors. Use the Copy/Paste buttons beside the 'Add Modifier' buttons. Copy copies all the modifiers of the ACTIVE F-Curve or Strip depending on the editor. Paste pastes modifiers from the buffer to all the selected F-Curves or Strips, adding the new modifiers to the ends of each list. * 'Stepped Interpolation' F-Modifier This modifier holds each interpolated value from the F-Curve for several frames without changing the timing. This allows to preview motions 'on-twos' for example without altering the timing, or having to go through setting heaps of keyframes. In this case, Andy wanted to use this for CG <-> StopMo. --- source/blender/blenkernel/BKE_fcurve.h | 1 + source/blender/blenkernel/intern/fmodifier.c | 69 ++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index 9df6bfdbe7c..c4d74f86284 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -158,6 +158,7 @@ FModifierTypeInfo *get_fmodifier_typeinfo(int type); /* ---------------------- */ struct FModifier *add_fmodifier(ListBase *modifiers, int type); +struct FModifier *copy_fmodifier(struct FModifier *src); void copy_fmodifiers(ListBase *dst, ListBase *src); int remove_fmodifier(ListBase *modifiers, struct FModifier *fcm); int remove_fmodifier_index(ListBase *modifiers, int index); diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index bbef3227490..02f35bb78f8 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -871,6 +871,49 @@ static FModifierTypeInfo FMI_LIMITS = { fcm_limits_evaluate /* evaluate */ }; +/* Stepped F-Curve Modifier --------------------------- */ + +static void fcm_stepped_new_data (void *mdata) +{ + FMod_Stepped *data= (FMod_Stepped *)mdata; + + /* just need to set the step-size to 2-frames by default */ + // XXX: or would 5 be more normal? + data->step_size = 2.0f; +} + +static float fcm_stepped_time (FCurve *fcu, FModifier *fcm, float cvalue, float evaltime) +{ + FMod_Stepped *data= (FMod_Stepped *)fcm->data; + int snapblock; + + /* we snap to the start of the previous closest block of 'step_size' frames + * after the start offset has been discarded + * - i.e. round down + */ + snapblock = (int)((evaltime - data->start) / data->step_size); + + /* reapply the offset, and multiple the snapblock by the size of the steps to get + * the new time to evaluate at + */ + return ((float)snapblock * data->step_size) + data->start; +} + +static FModifierTypeInfo FMI_STEPPED = { + FMODIFIER_TYPE_STEPPED, /* type */ + sizeof(FMod_Limits), /* size */ + FMI_TYPE_GENERATE_CURVE, /* action type */ /* XXX... err... */ + FMI_REQUIRES_RUNTIME_CHECK, /* requirements */ + "Stepped", /* name */ + "FMod_Stepped", /* struct name */ + NULL, /* free data */ + NULL, /* copy data */ + fcm_stepped_new_data, /* new data */ + NULL, /* verify */ + fcm_stepped_time, /* evaluate time */ + NULL /* evaluate */ +}; + /* F-Curve Modifier API --------------------------- */ /* All of the F-Curve Modifier api functions use FModifierTypeInfo structs to carry out * and operations that involve F-Curve modifier specific code. @@ -892,6 +935,7 @@ static void fmods_init_typeinfo () fmodifiersTypeInfo[6]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented fmodifiersTypeInfo[7]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */ fmodifiersTypeInfo[8]= &FMI_LIMITS; /* Limits F-Curve Modifier */ + fmodifiersTypeInfo[9]= &FMI_STEPPED; /* Stepped F-Curve Modifier */ } /* This function should be used for getting the appropriate type-info when only @@ -968,6 +1012,31 @@ FModifier *add_fmodifier (ListBase *modifiers, int type) return fcm; } +/* Make a copy of the specified F-Modifier */ +FModifier *copy_fmodifier (FModifier *src) +{ + FModifierTypeInfo *fmi= fmodifier_get_typeinfo(src); + FModifier *dst; + + /* sanity check */ + if (src == NULL) + return NULL; + + /* copy the base data, clearing the links */ + dst = MEM_dupallocN(src); + dst->next = dst->prev = NULL; + + /* make a new copy of the F-Modifier's data */ + dst->data = MEM_dupallocN(src->data); + + /* only do specific constraints if required */ + if (fmi && fmi->copy_data) + fmi->copy_data(dst, src); + + /* return the new modifier */ + return dst; +} + /* Duplicate all of the F-Modifiers in the Modifier stacks */ void copy_fmodifiers (ListBase *dst, ListBase *src) { -- cgit v1.2.3 From d89a8c34f3dc1a2923b6853c260de4f1deab9466 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 19 Mar 2010 03:38:14 +0000 Subject: More F-Modifier Tweaks: This commit started out aiming to make the "Stepped" F-Modifier (committed last night) even more useful, but ended up fixing a few other finer-points of how F-Modifiers work. Firstly, the new stuff: I've addded options to the Stepped F-Modifier to not affect frames before and/or after specified values, and renamed the 'start offset' to 'offset' for clarity. The main objective of this is to allow Stepped F-Modifiers to only affect certain time ranges, so that by layering/using multiple instances of the F-Modifier, it can be possible to have multiple stepping-sizes. This allows for effects like: http://www.pasteall.org/blend/2230 or in words, it provides a convenient mechanism for animators to specify whether sections of the animation is shown "on twos", "fours", or even "forty-second-ths plus a smidgen", as can be easily done with 2D. Assorted changes to support this: * Properly fixed up how F-Modifiers that work with time, evaluate the time to evaluate the curve at. Now layered time effects like this should be possible in a much nicer way. * Added proper value range validation/clamping to many properties. There are still a lot more that need checking, but at least more properties now do "the right thing". --- source/blender/blenkernel/intern/fmodifier.c | 31 +++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 02f35bb78f8..969a4208cd3 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -887,16 +887,26 @@ static float fcm_stepped_time (FCurve *fcu, FModifier *fcm, float cvalue, float FMod_Stepped *data= (FMod_Stepped *)fcm->data; int snapblock; + /* check range clamping to see if we should alter the timing to achieve the desired results */ + if (data->flag & FCM_STEPPED_NO_BEFORE) { + if (evaltime < data->start_frame) + return evaltime; + } + if (data->flag & FCM_STEPPED_NO_AFTER) { + if (evaltime > data->end_frame) + return evaltime; + } + /* we snap to the start of the previous closest block of 'step_size' frames * after the start offset has been discarded * - i.e. round down */ - snapblock = (int)((evaltime - data->start) / data->step_size); + snapblock = (int)((evaltime - data->offset) / data->step_size); /* reapply the offset, and multiple the snapblock by the size of the steps to get * the new time to evaluate at */ - return ((float)snapblock * data->step_size) + data->start; + return ((float)snapblock * data->step_size) + data->offset; } static FModifierTypeInfo FMI_STEPPED = { @@ -1201,14 +1211,20 @@ short list_has_suitable_fmodifier (ListBase *modifiers, int mtype, short acttype float evaluate_time_fmodifiers (ListBase *modifiers, FCurve *fcu, float cvalue, float evaltime) { FModifier *fcm; - float m_evaltime= evaltime; /* sanity checks */ if ELEM(NULL, modifiers, modifiers->last) return evaltime; - /* find the first modifier from end of stack that modifies time, and calculate the time the modifier - * would calculate time at + /* Starting from the end of the stack, calculate the time effects of various stacked modifiers + * on the time the F-Curve should be evaluated at. + * + * This is done in reverse order to standard evaluation, as when this is done in standard + * order, each modifier would cause jumps to other points in the curve, forcing all + * previous ones to be evaluated again for them to be correct. However, if we did in the + * reverse order as we have here, we can consider them a macro to micro type of waterfall + * effect, which should get us the desired effects when using layered time manipulations + * (such as multiple 'stepped' modifiers in sequence, causing different stepping rates) */ for (fcm= modifiers->last; fcm; fcm= fcm->prev) { FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); @@ -1217,13 +1233,12 @@ float evaluate_time_fmodifiers (ListBase *modifiers, FCurve *fcu, float cvalue, // TODO: implement the 'influence' control feature... if (fmi && fmi->evaluate_modifier_time) { if ((fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0) - m_evaltime= fmi->evaluate_modifier_time(fcu, fcm, cvalue, evaltime); - break; + evaltime= fmi->evaluate_modifier_time(fcu, fcm, cvalue, evaltime); } } /* return the modified evaltime */ - return m_evaltime; + return evaltime; } /* Evalautes the given set of F-Curve Modifiers using the given data -- cgit v1.2.3 From 1e2be7a8c6e32589be706da407f75cddf879c077 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 20 Mar 2010 11:15:16 +0000 Subject: "Fix" aka implementation of [#21548] Audio doesn't work when adding scenes with audio to another scene. --- source/blender/blenkernel/BKE_sound.h | 2 ++ source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/sound.c | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index fa035d62d62..b89767d2586 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -72,6 +72,8 @@ void sound_create_scene(struct Scene *scene); void sound_destroy_scene(struct Scene *scene); +void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip); + void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip); void sound_remove_scene_sound(struct Scene *scene, void* handle); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 42586ce18d7..424ca162bb4 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3698,7 +3698,7 @@ static void seq_update_muting_recursive(Scene *scene, ListBase *seqbasep, Sequen seq_update_muting_recursive(scene, &seq->seqbase, metaseq, seqmute); } - else if(seq->type == SEQ_SOUND) { + else if((seq->type == SEQ_SOUND) || (seq->type == SEQ_SCENE)) { if(seq->scene_sound) { sound_mute_scene_sound(scene, seq->scene_sound, seqmute); } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 9d189237ba0..2f0cb318ca0 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -349,6 +349,11 @@ void sound_destroy_scene(struct Scene *scene) AUD_destroySequencer(scene->sound_scene); } +void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip) +{ + return AUD_addSequencer(scene->sound_scene, &(sequence->scene->sound_scene), startframe / FPS, endframe / FPS, frameskip / FPS, sequence); +} + void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip) { return AUD_addSequencer(scene->sound_scene, &(sequence->sound->playback_handle), startframe / FPS, endframe / FPS, frameskip / FPS, sequence); -- cgit v1.2.3 From 391cc2d004c5fc231ac546d89f64ae4ba5c062c0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 20 Mar 2010 16:41:01 +0000 Subject: merge own commits into render branch into trunk since 27560 27562, 27570, 27571, 27574, 27576, 27577, 27579, 27590, 27591, 27594, 27595, 27596, 27599, 27605, 27611, 27612, 27613, 27614, 27623 --- source/blender/blenkernel/BKE_curve.h | 11 +-- source/blender/blenkernel/intern/anim_sys.c | 26 +++++-- source/blender/blenkernel/intern/curve.c | 102 +++++++++++++++++++--------- source/blender/blenkernel/intern/displist.c | 18 ++--- source/blender/blenkernel/intern/font.c | 2 +- source/blender/blenkernel/intern/mesh.c | 2 +- 6 files changed, 111 insertions(+), 50 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 5fb44c52307..7119a725630 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -40,12 +40,12 @@ struct ListBase; struct BezTriple; struct BevList; -#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (((nu)->flagu & CU_CYCLIC) ? (nu->orderu-1) : 0) ) -#define KNOTSV(nu) ( (nu)->orderv+ (nu)->pntsv+ (((nu)->flagv & CU_CYCLIC) ? (nu->orderv-1) : 0) ) +#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (((nu)->flagu & CU_NURB_CYCLIC) ? (nu->orderu-1) : 0) ) +#define KNOTSV(nu) ( (nu)->orderv+ (nu)->pntsv+ (((nu)->flagv & CU_NURB_CYCLIC) ? (nu->orderv-1) : 0) ) /* Non cyclic nurbs have 1 less segment */ -#define SEGMENTSU(nu) ( ((nu)->flagu & CU_CYCLIC) ? (nu)->pntsu : (nu)->pntsu-1 ) -#define SEGMENTSV(nu) ( ((nu)->flagv & CU_CYCLIC) ? (nu)->pntsv : (nu)->pntsv-1 ) +#define SEGMENTSU(nu) ( ((nu)->flagu & CU_NURB_CYCLIC) ? (nu)->pntsu : (nu)->pntsu-1 ) +#define SEGMENTSV(nu) ( ((nu)->flagv & CU_NURB_CYCLIC) ? (nu)->pntsv : (nu)->pntsv-1 ) #define CU_DO_TILT(cu, nu) (((nu->flag & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1) #define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || cu->bevobj || cu->ext1!=0.0 || cu->ext2!=0.0) ? 1:0) @@ -89,6 +89,9 @@ void sethandlesNurb(ListBase *editnurb, short code); void switchdirectionNurb( struct Nurb *nu); +void addNurbPoints(struct Nurb *nu, int number); +void addNurbPointsBezier(struct Nurb *nu, int number); + float (*curve_getVertexCos(struct Curve *cu, struct ListBase *lb, int *numVerts_r))[3]; void curve_applyVertexCos(struct Curve *cu, struct ListBase *lb, float (*vertexCos)[3]); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 31743a6bd1a..1e9103fb951 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -771,6 +771,8 @@ static short animsys_remap_path (AnimMapper *remap, char *path, char **dst) /* Write the given value to a setting using RNA, and return success */ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value) { + // printf("%p %s %i %f\n", ptr, path, array_index, value); + PropertyRNA *prop; PointerRNA new_ptr; @@ -780,22 +782,35 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i /* set value - only for animatable numerical values */ if (RNA_property_animateable(&new_ptr, prop)) { + int array_len= RNA_property_array_length(&new_ptr, prop); + + if(array_len && array_index >= array_len) + { + if (G.f & G_DEBUG) { + printf("Animato: Invalid array index. ID = '%s', '%s[%d]', array length is %d \n", + (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "", + path, array_index, array_len-1); + } + + return 0; + } + switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(&new_ptr, prop)) + if (array_len) RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_boolean_set(&new_ptr, prop, (int)value); break; case PROP_INT: - if (RNA_property_array_length(&new_ptr, prop)) + if (array_len) RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_int_set(&new_ptr, prop, (int)value); break; case PROP_FLOAT: - if (RNA_property_array_length(&new_ptr, prop)) + if (array_len) RNA_property_float_set_index(&new_ptr, prop, array_index, value); else RNA_property_float_set(&new_ptr, prop, value); @@ -817,7 +832,7 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i // XXX don't tag as failed yet though, as there are some legit situations (Action Constraint) // where some channels will not exist, but shouldn't lock up Action if (G.f & G_DEBUG) { - printf("Animato: Invalid path. ID = '%s', '%s [%d]' \n", + printf("Animato: Invalid path. ID = '%s', '%s[%d]' \n", (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "", path, array_index); } @@ -989,6 +1004,9 @@ static void nlastrip_evaluate_controls (NlaStrip *strip, float ctime) /* execute these settings as per normal */ animsys_evaluate_fcurves(&strip_ptr, &strip->fcurves, NULL, ctime); } + + if (strip->flag & NLASTRIP_FLAG_USR_TIME && strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC) + strip->strip_time= fmod(strip->strip_time - strip->actstart, strip->actend - strip->actstart); } /* gets the strip active at the current time for a list of strips for evaluation purposes */ diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 2430e417e51..b476ebf4994 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -519,7 +519,47 @@ void minmaxNurb(Nurb *nu, float *min, float *max) bp++; } } +} + +/* be sure to call makeknots after this */ +void addNurbPoints(Nurb *nu, int number) +{ + BPoint *tmp= nu->bp; + int i; + nu->bp= (BPoint *)MEM_mallocN((nu->pntsu + number) * sizeof(BPoint), "rna_Curve_spline_points_add"); + + if(tmp) { + memmove(nu->bp, tmp, nu->pntsu * sizeof(BPoint)); + MEM_freeN(tmp); + } + + memset(nu->bp + nu->pntsu, 0, number * sizeof(BPoint)); + + for(i=0, tmp= nu->bp + nu->pntsu; i < number; i++, tmp++) { + tmp->radius= 1.0f; + } + + nu->pntsu += number; +} + +void addNurbPointsBezier(Nurb *nu, int number) +{ + BezTriple *tmp= nu->bezt; + int i; + nu->bezt= (BezTriple *)MEM_mallocN((nu->pntsu + number) * sizeof(BezTriple), "rna_Curve_spline_points_add"); + + if(tmp) { + memmove(nu->bezt, tmp, nu->pntsu * sizeof(BezTriple)); + MEM_freeN(tmp); + } + + memset(nu->bezt + nu->pntsu, 0, number * sizeof(BezTriple)); + + for(i=0, tmp= nu->bezt + nu->pntsu; i < number; i++, tmp++) { + tmp->radius= 1.0f; + } + nu->pntsu += number; } /* ~~~~~~~~~~~~~~~~~~~~Non Uniform Rational B Spline calculations ~~~~~~~~~~~ */ @@ -603,7 +643,7 @@ void makeknots(Nurb *nu, short uv) if(nu->knotsu) MEM_freeN(nu->knotsu); if(check_valid_nurb_u(nu)) { nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots"); - if(nu->flagu & CU_CYCLIC) { + if(nu->flagu & CU_NURB_CYCLIC) { calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0); /* cyclic should be uniform */ makecyclicknots(nu->knotsu, nu->pntsu, nu->orderu); } else { @@ -616,7 +656,7 @@ void makeknots(Nurb *nu, short uv) if(nu->knotsv) MEM_freeN(nu->knotsv); if(check_valid_nurb_v(nu)) { nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots"); - if(nu->flagv & CU_CYCLIC) { + if(nu->flagv & CU_NURB_CYCLIC) { calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0); /* cyclic should be uniform */ makecyclicknots(nu->knotsv, nu->pntsv, nu->orderv); } else { @@ -734,18 +774,18 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride) fp= nu->knotsu; ustart= fp[nu->orderu-1]; - if(nu->flagu & CU_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1]; + if(nu->flagu & CU_NURB_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1]; else uend= fp[nu->pntsu]; - ustep= (uend-ustart)/((nu->flagu & CU_CYCLIC) ? totu : totu - 1); + ustep= (uend-ustart)/((nu->flagu & CU_NURB_CYCLIC) ? totu : totu - 1); basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbfaces3"); fp= nu->knotsv; vstart= fp[nu->orderv-1]; - if(nu->flagv & CU_CYCLIC) vend= fp[nu->pntsv+nu->orderv-1]; + if(nu->flagv & CU_NURB_CYCLIC) vend= fp[nu->pntsv+nu->orderv-1]; else vend= fp[nu->pntsv]; - vstep= (vend-vstart)/((nu->flagv & CU_CYCLIC) ? totv : totv - 1); + vstep= (vend-vstart)/((nu->flagv & CU_NURB_CYCLIC) ? totv : totv - 1); len= KNOTSV(nu); basisv= (float *)MEM_mallocN(sizeof(float)*len*totv, "makeNurbfaces3"); @@ -753,7 +793,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride) jend= (int *)MEM_mallocN(sizeof(float)*totv, "makeNurbfaces5"); /* precalculation of basisv and jstart,jend */ - if(nu->flagv & CU_CYCLIC) cycl= nu->orderv-1; + if(nu->flagv & CU_NURB_CYCLIC) cycl= nu->orderv-1; else cycl= 0; v= vstart; basis= basisv; @@ -764,7 +804,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride) v+= vstep; } - if(nu->flagu & CU_CYCLIC) cycl= nu->orderu-1; + if(nu->flagu & CU_NURB_CYCLIC) cycl= nu->orderu-1; else cycl= 0; in= coord_array; u= ustart; @@ -882,13 +922,13 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu fp= nu->knotsu; ustart= fp[nu->orderu-1]; - if(nu->flagu & CU_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1]; + if(nu->flagu & CU_NURB_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1]; else uend= fp[nu->pntsu]; - ustep= (uend-ustart)/(resolu - ((nu->flagu & CU_CYCLIC) ? 0 : 1)); + ustep= (uend-ustart)/(resolu - ((nu->flagu & CU_NURB_CYCLIC) ? 0 : 1)); basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbcurve3"); - if(nu->flagu & CU_CYCLIC) cycl= nu->orderu-1; + if(nu->flagu & CU_NURB_CYCLIC) cycl= nu->orderu-1; else cycl= 0; u= ustart; @@ -1022,8 +1062,8 @@ float *make_orco_surf(Object *ob) sizeu = nu->pntsu*nu->resolu; sizev = nu->pntsv*nu->resolv; - if (nu->flagu & CU_CYCLIC) sizeu++; - if (nu->flagv & CU_CYCLIC) sizev++; + if (nu->flagu & CU_NURB_CYCLIC) sizeu++; + if (nu->flagv & CU_NURB_CYCLIC) sizev++; if(nu->pntsv>1) tot+= sizeu * sizev; nu= nu->next; @@ -1036,8 +1076,8 @@ float *make_orco_surf(Object *ob) if(nu->pntsv>1) { sizeu = nu->pntsu*nu->resolu; sizev = nu->pntsv*nu->resolv; - if (nu->flagu & CU_CYCLIC) sizeu++; - if (nu->flagv & CU_CYCLIC) sizev++; + if (nu->flagu & CU_NURB_CYCLIC) sizeu++; + if (nu->flagv & CU_NURB_CYCLIC) sizev++; if(cu->flag & CU_UV_ORCO) { for(b=0; b< sizeu; b++) { @@ -1063,12 +1103,12 @@ float *make_orco_surf(Object *ob) for(b=0; bflagu & CU_CYCLIC)) + if (b==sizeu-1 && (nu->flagu & CU_NURB_CYCLIC)) use_b= 0; for(a=0; aflagv & CU_CYCLIC)) + if (a==sizev-1 && (nu->flagv & CU_NURB_CYCLIC)) use_a= 0; tdata = _tdata + 3 * (use_b * (nu->pntsv*nu->resolv) + use_a); @@ -1511,14 +1551,14 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float * /* returns a point */ if(prevbezt==nu->bezt) { - if(nu->flagu & CU_CYCLIC) pprev= last; + if(nu->flagu & CU_NURB_CYCLIC) pprev= last; else pprev= prevbezt; } else pprev= prevbezt-1; /* next point */ if(bezt==last) { - if(nu->flagu & CU_CYCLIC) next= nu->bezt; + if(nu->flagu & CU_NURB_CYCLIC) next= nu->bezt; else next= bezt; } else next= bezt+1; @@ -1977,7 +2017,7 @@ void makeBevelList(Object *ob) bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList2"); BLI_addtail(&(cu->bev), bl); - if(nu->flagu & CU_CYCLIC) bl->poly= 0; + if(nu->flagu & CU_NURB_CYCLIC) bl->poly= 0; else bl->poly= -1; bl->nr= len; bl->dupe_nr= 0; @@ -1995,17 +2035,17 @@ void makeBevelList(Object *ob) } else if(nu->type == CU_BEZIER) { - len= resolu*(nu->pntsu+ (nu->flagu & CU_CYCLIC) -1)+1; /* in case last point is not cyclic */ + len= resolu*(nu->pntsu+ (nu->flagu & CU_NURB_CYCLIC) -1)+1; /* in case last point is not cyclic */ bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelBPoints"); BLI_addtail(&(cu->bev), bl); - if(nu->flagu & CU_CYCLIC) bl->poly= 0; + if(nu->flagu & CU_NURB_CYCLIC) bl->poly= 0; else bl->poly= -1; bevp= (BevPoint *)(bl+1); a= nu->pntsu-1; bezt= nu->bezt; - if(nu->flagu & CU_CYCLIC) { + if(nu->flagu & CU_NURB_CYCLIC) { a++; prevbezt= nu->bezt+(nu->pntsu-1); } @@ -2066,7 +2106,7 @@ void makeBevelList(Object *ob) bezt++; } - if((nu->flagu & CU_CYCLIC)==0) { /* not cyclic: endpoint */ + if((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic: endpoint */ VECCOPY(bevp->vec, prevbezt->vec[1]); bevp->alfa= prevbezt->alfa; bevp->radius= prevbezt->radius; @@ -2081,7 +2121,7 @@ void makeBevelList(Object *ob) BLI_addtail(&(cu->bev), bl); bl->nr= len; bl->dupe_nr= 0; - if(nu->flagu & CU_CYCLIC) bl->poly= 0; + if(nu->flagu & CU_NURB_CYCLIC) bl->poly= 0; else bl->poly= -1; bevp= (BevPoint *)(bl+1); @@ -2521,7 +2561,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */ a= nu->pntsu; bezt= nu->bezt; - if(nu->flagu & CU_CYCLIC) prev= bezt+(a-1); + if(nu->flagu & CU_NURB_CYCLIC) prev= bezt+(a-1); else prev= 0; next= bezt+1; @@ -2529,7 +2569,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */ calchandleNurb(bezt, prev, next, 0); prev= bezt; if(a==1) { - if(nu->flagu & CU_CYCLIC) next= nu->bezt; + if(nu->flagu & CU_NURB_CYCLIC) next= nu->bezt; else next= 0; } else next++; @@ -2986,7 +3026,7 @@ int check_valid_nurb_u( struct Nurb *nu ) if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ if (nu->pntsu < nu->orderu) return 0; - if (((nu->flag & CU_CYCLIC)==0) && ((nu->flagu>>1) & 2)) { /* Bezier U Endpoints */ + if (((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */ if (nu->orderu==4) { if (nu->pntsu < 5) return 0; /* bezier with 4 orderu needs 5 points */ } else if (nu->orderu != 3) return 0; /* order must be 3 or 4 */ @@ -3000,7 +3040,7 @@ int check_valid_nurb_v( struct Nurb *nu) if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ if (nu->pntsv < nu->orderv) return 0; - if (((nu->flag & CU_CYCLIC)==0) && ((nu->flagv>>1) & 2)) { /* Bezier V Endpoints */ + if (((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */ if (nu->orderv==4) { if (nu->pntsv < 5) return 0; /* bezier with 4 orderu needs 5 points */ } else if (nu->orderv != 3) return 0; /* order must be 3 or 4 */ @@ -3015,7 +3055,7 @@ int clamp_nurb_order_u( struct Nurb *nu ) nu->orderu= nu->pntsu; change= 1; } - if(((nu->flag & CU_CYCLIC)==0) && (nu->flagu>>1)&2) { + if(((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { CLAMP(nu->orderu, 3,4); change= 1; } @@ -3029,7 +3069,7 @@ int clamp_nurb_order_v( struct Nurb *nu) nu->orderv= nu->pntsv; change= 1; } - if(((nu->flag & CU_CYCLIC)==0) && (nu->flagv>>1)&2) { + if(((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { CLAMP(nu->orderv, 3,4); change= 1; } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 56eabc0f5ef..07ecf4c92a9 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -840,17 +840,17 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) /* count */ len= 0; a= nu->pntsu-1; - if(nu->flagu & CU_CYCLIC) a++; + if(nu->flagu & CU_NURB_CYCLIC) a++; prevbezt= nu->bezt; bezt= prevbezt+1; while(a--) { - if(a==0 && (nu->flagu & CU_CYCLIC)) bezt= nu->bezt; + if(a==0 && (nu->flagu & CU_NURB_CYCLIC)) bezt= nu->bezt; if(prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) len++; else len+= resolu; - if(a==0 && (nu->flagu & CU_CYCLIC)==0) len++; + if(a==0 && (nu->flagu & CU_NURB_CYCLIC)==0) len++; prevbezt= bezt; bezt++; @@ -867,7 +867,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) data= dl->verts; - if(nu->flagu & CU_CYCLIC) { + if(nu->flagu & CU_NURB_CYCLIC) { dl->type= DL_POLY; a= nu->pntsu; } @@ -920,7 +920,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) dl->charidx = nu->charidx; data= dl->verts; - if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY; + if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; else dl->type= DL_SEGM; makeNurbcurve(nu, data, NULL, NULL, resolu, 3*sizeof(float)); } @@ -935,7 +935,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) dl->charidx = nu->charidx; data= dl->verts; - if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY; + if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; else dl->type= DL_SEGM; a= len; @@ -1610,7 +1610,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, dl->rt= nu->flag; data= dl->verts; - if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY; + 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)); @@ -1631,8 +1631,8 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, dl->parts= (nu->pntsu*nu->resolu); /* in reverse, because makeNurbfaces works that way */ dl->nr= (nu->pntsv*nu->resolv); - if(nu->flagv & CU_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */ - if(nu->flagu & CU_CYCLIC) dl->flag|= DL_CYCL_V; + if(nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */ + if(nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V; makeNurbfaces(nu, data, 0); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index efd93aa362d..8ec4814dc94 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -473,7 +473,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i nu2->pntsv = 1; nu2->orderu = 4; nu2->orderv = 1; - nu2->flagu = CU_CYCLIC; + nu2->flagu = CU_NURB_CYCLIC; bp = (BPoint*)MEM_callocN(4 * sizeof(BPoint),"underline_bp"); if (bp == 0){ diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 8d2dfcd1989..08130f51b0e 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1165,7 +1165,7 @@ void mesh_to_curve(Scene *scene, Object *ob) nu->pntsu= totpoly; nu->pntsv= 1; nu->orderu= 4; - nu->flagu= 2 | (closed ? CU_CYCLIC:0); /* endpoint */ + nu->flagu= CU_NURB_ENDPOINT | (closed ? CU_NURB_CYCLIC:0); /* endpoint */ nu->resolu= 12; nu->bp= (BPoint *)MEM_callocN(sizeof(BPoint)*totpoly, "bpoints"); -- cgit v1.2.3 From 03acdd75e0c75b78bdf5c2c23bcf6c8cf40cb459 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Mar 2010 00:25:52 +0000 Subject: [#21660] improved UV test grid from shuvro sarker (shuvro) Added text to the patch and made other minor tweaks. moved image generation functions into their own file. --- source/blender/blenkernel/BKE_image.h | 5 + source/blender/blenkernel/intern/image.c | 115 +-------- source/blender/blenkernel/intern/image_gen.c | 360 +++++++++++++++++++++++++++ 3 files changed, 376 insertions(+), 104 deletions(-) create mode 100644 source/blender/blenkernel/intern/image_gen.c (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index d1808366944..df51d017594 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -162,6 +162,11 @@ struct Image *BKE_image_copy(struct Image *ima); /* merge source into dest, and free source */ void BKE_image_merge(struct Image *dest, struct Image *source); +/* image_gen.c */ +void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, float color[4]); +void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int height, int width); +void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, int height, int width); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index f870fc1083b..25a4f9b0a48 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -438,11 +438,8 @@ Image *BKE_add_image_file(const char *name, int frame) static ImBuf *add_ibuf_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4]) { ImBuf *ibuf; - float h=0.0, hoffs=0.0, hue=0.0, s=0.9, v=0.9, r, g, b; unsigned char *rect= NULL; float *rect_float= NULL; - int x, y; - int checkerwidth=32, dark=1; if (floatbuf) { ibuf= IMB_allocImBuf(width, height, 24, IB_rectfloat, 0); @@ -456,107 +453,17 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, int floatbuf, sho strcpy(ibuf->name, "//Untitled"); ibuf->userflags |= IB_BITMAPDIRTY; - if (uvtestgrid) { - /* these two passes could be combined into one, but it's more readable and - * easy to tweak like this, speed isn't really that much of an issue in this situation... */ - - /* checkers */ - for(y=0; y 0) { - rect_float[0] = rect_float[1] = rect_float[2] = 0.25f; - rect_float[3] = 1.0f; - } else { - rect_float[0] = rect_float[1] = rect_float[2] = 0.58f; - rect_float[3] = 1.0f; - } - rect_float+=4; - } - else { - if (dark > 0) { - rect[0] = rect[1] = rect[2] = 64; - rect[3] = 255; - } else { - rect[0] = rect[1] = rect[2] = 150; - rect[3] = 255; - } - rect += 4; - } - } - } - - /* 2nd pass, colored + */ - if (floatbuf) rect_float= (float*)ibuf->rect_float; - else rect= (unsigned char*)ibuf->rect; - - for(y=0; y +#include "BLI_math_color.h" +#include "BLF_api.h" + +void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, float color[4]) +{ + int x, y; + + /* blank image */ + if(rect_float) { + for(y= 0; y 0) { + rect_float[0]= rect_float[1]= rect_float[2]= 0.25f; + rect_float[3]= 1.0f; + } else { + rect_float[0]= rect_float[1]= rect_float[2]= 0.58f; + rect_float[3]= 1.0f; + } + rect_float+= 4; + } + else { + if (dark > 0) { + rect[0]= rect[1]= rect[2]= 64; + rect[3]= 255; + } else { + rect[0]= rect[1]= rect[2]= 150; + rect[3]= 255; + } + rect+= 4; + } + } + } + + /* 2nd pass, colored + */ + for(y= 0; y Date: Sun, 21 Mar 2010 01:14:04 +0000 Subject: Fix syntax for ID keyword. --- source/blender/blenkernel/BKE_idprop.h | 2 +- source/blender/blenkernel/BKE_softbody.h | 2 +- source/blender/blenkernel/intern/idprop.c | 2 +- source/blender/blenkernel/intern/image_gen.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 9634b872e91..6e364ef63b6 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -1,5 +1,5 @@ /** - * $Id: BKE_idprop.h + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h index e7fbf50ad82..30b7e8cda53 100644 --- a/source/blender/blenkernel/BKE_softbody.h +++ b/source/blender/blenkernel/BKE_softbody.h @@ -1,7 +1,7 @@ /** * BKE_softbody.h * - * $Id: BKE_softbody.h + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 37aee8fb4aa..e63a1c4c1ad 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -1,5 +1,5 @@ /** - * $Id: idprop.c + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index e11ddfd59fa..86d07d70e64 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -1,6 +1,6 @@ /* image_gen.c * - * $Id: + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * -- cgit v1.2.3 From f9999f3445db47c41d2da538af3abc0ef25576c5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Mar 2010 10:25:21 +0000 Subject: [#21692] Blender Crashes upon trying to view UV Test Grid (r27639) fix for mistake in own commit when moving grid color func into its own file. --- source/blender/blenkernel/intern/image_gen.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 86d07d70e64..2c4851b1835 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -72,6 +72,10 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt int checkerwidth= 32, dark= 1; int x, y; + + unsigned char *rect_orig= rect; + float *rect_float_orig= rect_float; + float h=0.0, hoffs=0.0, hue=0.0, s=0.9, v=0.9, r, g, b; @@ -104,7 +108,10 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt } } } - + + rect= rect_orig; + rect_float= rect_float_orig; + /* 2nd pass, colored + */ for(y= 0; y Date: Sun, 21 Mar 2010 13:42:25 +0000 Subject: removed unused includes, except for physics and particle related files --- source/blender/blenkernel/intern/BME_Customdata.c | 4 +-- source/blender/blenkernel/intern/BME_conversions.c | 8 ------ source/blender/blenkernel/intern/BME_eulers.c | 9 ------ source/blender/blenkernel/intern/BME_mesh.c | 4 --- source/blender/blenkernel/intern/BME_structure.c | 5 ---- source/blender/blenkernel/intern/BME_tools.c | 4 --- source/blender/blenkernel/intern/DerivedMesh.c | 24 ---------------- source/blender/blenkernel/intern/action.c | 12 -------- source/blender/blenkernel/intern/anim.c | 13 --------- source/blender/blenkernel/intern/anim_sys.c | 2 -- source/blender/blenkernel/intern/armature.c | 7 ----- source/blender/blenkernel/intern/blender.c | 14 ---------- source/blender/blenkernel/intern/bmfont.c | 2 -- source/blender/blenkernel/intern/boids.c | 6 ---- source/blender/blenkernel/intern/booleanops.c | 7 ----- source/blender/blenkernel/intern/booleanops_mesh.c | 14 ---------- source/blender/blenkernel/intern/brush.c | 4 --- source/blender/blenkernel/intern/bvhutils.c | 9 ------ source/blender/blenkernel/intern/cdderivedmesh.c | 8 ------ source/blender/blenkernel/intern/cloth.c | 11 -------- source/blender/blenkernel/intern/colortools.c | 6 ---- source/blender/blenkernel/intern/constraint.c | 2 -- source/blender/blenkernel/intern/context.c | 3 -- source/blender/blenkernel/intern/curve.c | 3 -- source/blender/blenkernel/intern/customdata.c | 4 --- source/blender/blenkernel/intern/deform.c | 17 ------------ source/blender/blenkernel/intern/depsgraph.c | 20 -------------- source/blender/blenkernel/intern/displist.c | 27 ------------------ source/blender/blenkernel/intern/exotic.c | 9 ------ source/blender/blenkernel/intern/fcurve.c | 3 -- source/blender/blenkernel/intern/fmodifier.c | 7 ----- source/blender/blenkernel/intern/font.c | 3 -- source/blender/blenkernel/intern/gpencil.c | 14 ---------- source/blender/blenkernel/intern/group.c | 5 ---- source/blender/blenkernel/intern/icons.c | 3 -- source/blender/blenkernel/intern/idprop.c | 5 ---- source/blender/blenkernel/intern/image.c | 7 ----- source/blender/blenkernel/intern/implicit.c | 3 -- source/blender/blenkernel/intern/ipo.c | 18 ------------ source/blender/blenkernel/intern/key.c | 5 ---- source/blender/blenkernel/intern/lattice.c | 9 ------ source/blender/blenkernel/intern/library.c | 15 ---------- source/blender/blenkernel/intern/material.c | 4 --- source/blender/blenkernel/intern/mball.c | 1 - source/blender/blenkernel/intern/mesh.c | 8 ------ source/blender/blenkernel/intern/modifier.c | 32 ---------------------- source/blender/blenkernel/intern/multires.c | 8 ------ source/blender/blenkernel/intern/nla.c | 6 ---- source/blender/blenkernel/intern/node.c | 27 ------------------ source/blender/blenkernel/intern/object.c | 17 ------------ source/blender/blenkernel/intern/packedFile.c | 3 -- source/blender/blenkernel/intern/paint.c | 2 -- source/blender/blenkernel/intern/particle.c | 14 ---------- source/blender/blenkernel/intern/pointcache.c | 1 - source/blender/blenkernel/intern/property.c | 2 -- source/blender/blenkernel/intern/report.c | 2 -- source/blender/blenkernel/intern/sca.c | 3 -- source/blender/blenkernel/intern/scene.c | 19 ------------- source/blender/blenkernel/intern/script.c | 7 ----- source/blender/blenkernel/intern/seqeffects.c | 4 --- source/blender/blenkernel/intern/sequencer.c | 3 -- source/blender/blenkernel/intern/shrinkwrap.c | 7 ----- source/blender/blenkernel/intern/simple_deform.c | 1 - source/blender/blenkernel/intern/softbody.c | 9 ------ source/blender/blenkernel/intern/sound.c | 3 -- source/blender/blenkernel/intern/subsurf_ccg.c | 6 ---- source/blender/blenkernel/intern/suggestions.c | 2 -- source/blender/blenkernel/intern/text.c | 3 -- source/blender/blenkernel/intern/texture.c | 8 ------ source/blender/blenkernel/intern/world.c | 10 ------- .../blender/blenkernel/intern/writeframeserver.c | 3 -- 71 files changed, 1 insertion(+), 569 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/BME_Customdata.c b/source/blender/blenkernel/intern/BME_Customdata.c index cd9254eef53..736b5e05798 100644 --- a/source/blender/blenkernel/intern/BME_Customdata.c +++ b/source/blender/blenkernel/intern/BME_Customdata.c @@ -34,13 +34,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include -#include "BKE_bmesh.h" #include "BKE_bmeshCustomData.h" #include "bmesh_private.h" -#include #include "MEM_guardedalloc.h" -#include "BLI_mempool.h" /********************* Layer type information **********************/ typedef struct BME_LayerTypeInfo { diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index c5c74b388ff..d6a00450e4a 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -33,22 +33,14 @@ */ #include "MEM_guardedalloc.h" -#include "BKE_customdata.h" -#include "DNA_listBase.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_utildefines.h" #include "BKE_mesh.h" -#include "BKE_bmesh.h" -#include "BKE_global.h" -#include "BKE_DerivedMesh.h" #include "BKE_cdderivedmesh.h" -#include "BLI_blenlib.h" -#include "BLI_editVert.h" #include "BLI_edgehash.h" //XXX #include "BIF_editmesh.h" //XXX #include "editmesh.h" diff --git a/source/blender/blenkernel/intern/BME_eulers.c b/source/blender/blenkernel/intern/BME_eulers.c index 647671d0ed8..9c9c71292c2 100644 --- a/source/blender/blenkernel/intern/BME_eulers.c +++ b/source/blender/blenkernel/intern/BME_eulers.c @@ -34,17 +34,8 @@ #include "MEM_guardedalloc.h" -#include "DNA_listBase.h" -#include "DNA_meshdata_types.h" -#include "DNA_mesh_types.h" -#include "BKE_utildefines.h" -#include "BKE_customdata.h" -#include "BKE_bmesh.h" - -#include "BLI_blenlib.h" #include "bmesh_private.h" -#include "BLI_ghash.h" /********************************************************* * "Euler API" * diff --git a/source/blender/blenkernel/intern/BME_mesh.c b/source/blender/blenkernel/intern/BME_mesh.c index c34695b2fb5..f616d21c6fd 100644 --- a/source/blender/blenkernel/intern/BME_mesh.c +++ b/source/blender/blenkernel/intern/BME_mesh.c @@ -34,13 +34,9 @@ #include "MEM_guardedalloc.h" -#include "DNA_listBase.h" -#include "BLI_blenlib.h" -#include "BKE_utildefines.h" #include "BKE_bmesh.h" #include "bmesh_private.h" - /* * BME MAKE MESH * diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c index da0ce4da43b..de3eb94beac 100644 --- a/source/blender/blenkernel/intern/BME_structure.c +++ b/source/blender/blenkernel/intern/BME_structure.c @@ -35,12 +35,7 @@ #include #include "MEM_guardedalloc.h" -#include "DNA_listBase.h" -#include "BKE_utildefines.h" #include "BKE_bmesh.h" -#include "BLI_blenlib.h" -#include "BLI_linklist.h" -#include "BLI_ghash.h" /** * MISC utility functions. * diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 05dda65a914..9753ad47488 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -35,15 +35,11 @@ #include "MEM_guardedalloc.h" -#include "DNA_listBase.h" #include "DNA_meshdata_types.h" -#include "DNA_mesh_types.h" #include "DNA_object_types.h" -#include "BKE_utildefines.h" #include "BKE_bmesh.h" #include "BLI_math.h" -#include "BLI_blenlib.h" /*split this all into a seperate bevel.c file in src*/ diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 9d7fbccec75..e69686eeb00 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -33,51 +33,27 @@ #include #endif -#include "PIL_time.h" #include "MEM_guardedalloc.h" -#include "DNA_effect_types.h" -#include "DNA_mesh_types.h" #include "DNA_key_types.h" #include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" #include "DNA_object_types.h" -#include "DNA_object_force.h" -#include "DNA_object_fluidsim.h" // N_T #include "DNA_scene_types.h" // N_T -#include "DNA_texture_types.h" -#include "DNA_view3d_types.h" -#include "DNA_screen_types.h" -#include "DNA_space_types.h" -#include "DNA_particle_types.h" #include "BLI_math.h" #include "BLI_blenlib.h" -#include "BLI_edgehash.h" #include "BLI_editVert.h" -#include "BLI_linklist.h" #include "BLI_memarena.h" #include "BKE_cdderivedmesh.h" -#include "BKE_customdata.h" -#include "BKE_DerivedMesh.h" -#include "BKE_deform.h" #include "BKE_displist.h" -#include "BKE_effect.h" -#include "BKE_fluidsim.h" -#include "BKE_global.h" -#include "BKE_key.h" -#include "BKE_material.h" #include "BKE_modifier.h" #include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_paint.h" -#include "BKE_subsurf.h" #include "BKE_texture.h" #include "BKE_utildefines.h" -#include "BKE_particle.h" -#include "BKE_bvhutils.h" #include "BLO_sys_types.h" // for intptr_t support diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 13f247e7c3c..cf61de195e5 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -38,26 +38,16 @@ #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" -#include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" -#include "DNA_curve_types.h" -#include "DNA_key_types.h" -#include "DNA_nla_types.h" -#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_anim.h" -#include "BKE_armature.h" -#include "BKE_blender.h" #include "BKE_constraint.h" -#include "BKE_displist.h" #include "BKE_global.h" #include "BKE_fcurve.h" -#include "BKE_key.h" -#include "BKE_lattice.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" @@ -68,10 +58,8 @@ #include "BLI_math.h" #include "BLI_blenlib.h" -#include "BLI_ghash.h" #include "RNA_access.h" -#include "RNA_types.h" /* *********************** NOTE ON POSE AND ACTION ********************** diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 08c8528384f..9eb6c3ad467 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -40,30 +40,18 @@ #include "BLI_math.h" #include "BLI_rand.h" -#include "DNA_listBase.h" #include "DNA_anim_types.h" -#include "DNA_action_types.h" #include "DNA_armature_types.h" -#include "DNA_curve_types.h" -#include "DNA_effect_types.h" #include "DNA_group_types.h" #include "DNA_key_types.h" -#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" -#include "DNA_object_types.h" -#include "DNA_particle_types.h" #include "DNA_scene_types.h" -#include "DNA_view3d_types.h" #include "DNA_vfont_types.h" #include "BKE_anim.h" -#include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_DerivedMesh.h" -#include "BKE_displist.h" -#include "BKE_effect.h" #include "BKE_font.h" #include "BKE_group.h" #include "BKE_global.h" @@ -81,7 +69,6 @@ #endif // XXX bad level call... -#include "ED_mesh.h" /* --------------------- */ /* forward declarations */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 1e9103fb951..584f31769ef 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -36,7 +36,6 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_math.h" #include "BLI_dynstr.h" #include "DNA_anim_types.h" @@ -51,7 +50,6 @@ #include "BKE_utildefines.h" #include "RNA_access.h" -#include "RNA_types.h" #include "nla_private.h" diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 36c78c9f947..387b8a1d5b2 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -39,25 +39,19 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" -#include "DNA_action_types.h" -#include "DNA_curve_types.h" #include "DNA_constraint_types.h" #include "DNA_mesh_types.h" #include "DNA_lattice_types.h" #include "DNA_meshdata_types.h" #include "DNA_nla_types.h" -#include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_view3d_types.h" #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_action.h" #include "BKE_anim.h" -#include "BKE_blender.h" #include "BKE_constraint.h" #include "BKE_curve.h" -#include "BKE_deform.h" #include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" #include "BKE_displist.h" @@ -67,7 +61,6 @@ #include "BKE_lattice.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_object.h" #include "BKE_utildefines.h" #include "BIK_api.h" #include "BKE_sketch.h" diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 171b48af974..d7f8d73e31f 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -48,45 +48,31 @@ #include "MEM_guardedalloc.h" -#include "DNA_curve_types.h" -#include "DNA_listBase.h" -#include "DNA_sdna_types.h" #include "DNA_userdef_types.h" -#include "DNA_object_types.h" -#include "DNA_mesh_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" -#include "DNA_sound_types.h" #include "DNA_sequence_types.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" -#include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "BKE_animsys.h" -#include "BKE_action.h" #include "BKE_blender.h" #include "BKE_context.h" -#include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_displist.h" -#include "BKE_font.h" #include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_ipo.h" #include "BKE_main.h" #include "BKE_node.h" -#include "BKE_object.h" #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_sequencer.h" -#include "BKE_sound.h" -#include "BLI_editVert.h" #include "BLO_undofile.h" #include "BLO_readfile.h" diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index 409e7edb519..5f9b4f11850 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -51,11 +51,9 @@ #include #include "MEM_guardedalloc.h" -#include "BLI_blenlib.h" #include "BKE_global.h" #include "IMB_imbuf_types.h" -#include "BKE_bmfont.h" #include "BKE_bmfont_types.h" #ifdef HAVE_CONFIG_H diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index b521ec41cba..25c42dfbf49 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -34,19 +34,13 @@ #include "MEM_guardedalloc.h" -#include "DNA_particle_types.h" -#include "DNA_modifier_types.h" #include "DNA_object_force.h" -#include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_boid_types.h" -#include "DNA_listBase.h" #include "BLI_rand.h" #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdtree.h" -#include "BLI_kdopbvh.h" #include "BKE_collision.h" #include "BKE_effect.h" #include "BKE_boids.h" diff --git a/source/blender/blenkernel/intern/booleanops.c b/source/blender/blenkernel/intern/booleanops.c index 14a740fb5d1..710bbfaf12b 100644 --- a/source/blender/blenkernel/intern/booleanops.c +++ b/source/blender/blenkernel/intern/booleanops.c @@ -34,7 +34,6 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" -#include "BLI_blenlib.h" #include "BLI_ghash.h" #include "DNA_material_types.h" @@ -45,17 +44,11 @@ #include "CSG_BooleanOps.h" -#include "BKE_booleanops.h" #include "BKE_cdderivedmesh.h" -#include "BKE_customdata.h" #include "BKE_depsgraph.h" -#include "BKE_DerivedMesh.h" -#include "BKE_global.h" -#include "BKE_library.h" #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_object.h" -#include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 1e99661f445..431e51cf149 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -30,24 +30,10 @@ */ #include "CSG_BooleanOps.h" -#include "BKE_booleanops.h" -#include "BKE_booleanops_mesh.h" #include "MEM_guardedalloc.h" -#include "DNA_material_types.h" -#include "DNA_mesh_types.h" -#include "DNA_object_types.h" -#include "DNA_scene_types.h" -#include "BKE_global.h" -#include "BKE_mesh.h" -#include "BKE_displist.h" -#include "BKE_object.h" -#include "BKE_utildefines.h" -#include "BKE_library.h" -#include "BKE_material.h" -#include "BLI_math.h" /** * Implementation of boolean ops mesh interface. diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index f2cb7d31592..4aaf95e7037 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -34,9 +34,6 @@ #include "DNA_brush_types.h" #include "DNA_color_types.h" -#include "DNA_image_types.h" -#include "DNA_object_types.h" -#include "DNA_texture_types.h" #include "DNA_scene_types.h" #include "DNA_windowmanager_types.h" @@ -56,7 +53,6 @@ #include "BKE_main.h" #include "BKE_paint.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index b7cda698a29..65fda678ce0 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -32,21 +32,12 @@ #include #include -#include "BKE_bvhutils.h" - -#include "DNA_object_types.h" -#include "DNA_modifier_types.h" #include "DNA_meshdata_types.h" #include "BKE_DerivedMesh.h" #include "BKE_utildefines.h" -#include "BKE_deform.h" -#include "BKE_cdderivedmesh.h" -#include "BKE_displist.h" -#include "BKE_global.h" #include "BLI_math.h" -#include "BLI_linklist.h" #include "MEM_guardedalloc.h" /* Math stuff for ray casting on mesh faces and for nearest surface */ diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 347a501dfcc..3a415d6564d 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -37,12 +37,8 @@ #include "BIF_gl.h" #include "BKE_cdderivedmesh.h" -#include "BKE_customdata.h" -#include "BKE_DerivedMesh.h" -#include "BKE_displist.h" #include "BKE_global.h" #include "BKE_mesh.h" -#include "BKE_multires.h" #include "BKE_utildefines.h" #include "BLI_math.h" @@ -51,12 +47,8 @@ #include "BLI_editVert.h" #include "BLI_pbvh.h" -#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" -#include "DNA_object_fluidsim.h" #include "DNA_object_types.h" -#include "DNA_scene_types.h" #include "DNA_curve_types.h" /* for Curve */ #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 855de95572a..7183a514225 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -29,25 +29,14 @@ #include "BKE_cloth.h" -#include "DNA_cloth_types.h" -#include "DNA_mesh_types.h" -#include "DNA_object_force.h" -#include "DNA_scene_types.h" -#include "DNA_particle_types.h" - -#include "BKE_deform.h" -#include "BKE_DerivedMesh.h" #include "BKE_cdderivedmesh.h" #include "BKE_effect.h" #include "BKE_global.h" -#include "BKE_object.h" #include "BKE_modifier.h" #include "BKE_utildefines.h" -#include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BLI_kdopbvh.h" #ifdef _WIN32 void tstart ( void ) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 28b70b539c1..6410d02603d 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -40,20 +40,14 @@ #include "DNA_color_types.h" #include "DNA_curve_types.h" -#include "DNA_image_types.h" -#include "DNA_texture_types.h" #include "BKE_colortools.h" #include "BKE_curve.h" -#include "BKE_global.h" #include "BKE_ipo.h" -#include "BKE_image.h" -#include "BKE_main.h" #include "BKE_utildefines.h" #include "BLI_blenlib.h" #include "BLI_math.h" -#include "BLI_threads.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 08ac5e6acce..78f1bb4e469 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -73,8 +73,6 @@ #include "BPY_extern.h" #endif -#include "ED_mesh.h" - #ifdef HAVE_CONFIG_H #include #endif diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 26320e2475f..e8f73a92ad5 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -27,8 +27,6 @@ #include "MEM_guardedalloc.h" -#include "DNA_ID.h" -#include "DNA_listBase.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" @@ -44,7 +42,6 @@ #include "BKE_context.h" #include "BKE_main.h" #include "BKE_screen.h" -#include "BKE_global.h" #ifndef DISABLE_PYTHON #include "BPY_extern.h" diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index b476ebf4994..06921a0b9af 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -42,12 +42,10 @@ #include "BLI_blenlib.h" #include "BLI_math.h" -#include "DNA_object_types.h" #include "DNA_curve_types.h" #include "DNA_material_types.h" /* for dereferencing pointers */ -#include "DNA_ID.h" #include "DNA_key_types.h" #include "DNA_scene_types.h" #include "DNA_vfont_types.h" @@ -61,7 +59,6 @@ #include "BKE_key.h" #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_utildefines.h" // VECCOPY diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 07960dd2fa0..a0eef4d666e 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -37,16 +37,12 @@ #include "MEM_guardedalloc.h" -#include "DNA_customdata_types.h" -#include "DNA_listBase.h" #include "DNA_meshdata_types.h" #include "DNA_ID.h" #include "BLI_blenlib.h" #include "BLI_linklist.h" -#include "BLI_math.h" #include "BLI_mempool.h" -#include "BLI_string.h" #include "BKE_customdata.h" #include "BKE_customdata_file.h" diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 728f77cd618..0ae8169cc67 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -38,29 +38,12 @@ #include "MEM_guardedalloc.h" -#include "DNA_curve_types.h" -#include "DNA_effect_types.h" -#include "DNA_lattice_types.h" -#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" -#include "DNA_object_force.h" -#include "DNA_scene_types.h" -#include "BKE_curve.h" #include "BKE_deform.h" -#include "BKE_displist.h" -#include "BKE_effect.h" -#include "BKE_global.h" -#include "BKE_key.h" -#include "BKE_lattice.h" -#include "BKE_object.h" -#include "BKE_softbody.h" -#include "BKE_utildefines.h" -#include "BKE_mesh.h" #include "BLI_blenlib.h" -#include "BLI_math.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 155cc2af05e..397a0526160 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -29,35 +29,16 @@ #include #include -#include "BLI_blenlib.h" -#include "BLI_math.h" #include "BLI_winstuff.h" #include "DNA_anim_types.h" -#include "DNA_action_types.h" -#include "DNA_armature_types.h" -#include "DNA_boid_types.h" -#include "DNA_curve_types.h" #include "DNA_camera_types.h" -#include "DNA_ID.h" -#include "DNA_effect_types.h" #include "DNA_group_types.h" #include "DNA_lattice_types.h" -#include "DNA_lamp_types.h" #include "DNA_key_types.h" #include "DNA_mesh_types.h" -#include "DNA_modifier_types.h" -#include "DNA_nla_types.h" -#include "DNA_object_types.h" -#include "DNA_object_force.h" -#include "DNA_object_fluidsim.h" -#include "DNA_outliner_types.h" -#include "DNA_particle_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" -#include "DNA_space_types.h" -#include "DNA_view2d_types.h" -#include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" #include "BLI_ghash.h" @@ -75,7 +56,6 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_utildefines.h" #include "BKE_scene.h" #include "BKE_screen.h" diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 07ecf4c92a9..ed7d11872c1 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -35,55 +35,28 @@ #include "MEM_guardedalloc.h" -#include "IMB_imbuf_types.h" -#include "DNA_texture_types.h" -#include "DNA_meta_types.h" #include "DNA_curve_types.h" -#include "DNA_effect_types.h" -#include "DNA_listBase.h" -#include "DNA_lamp_types.h" -#include "DNA_object_types.h" -#include "DNA_object_force.h" -#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" #include "DNA_scene_types.h" -#include "DNA_image_types.h" #include "DNA_material_types.h" -#include "DNA_view3d_types.h" -#include "DNA_lattice_types.h" -#include "DNA_key_types.h" #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_editVert.h" -#include "BLI_edgehash.h" -#include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_displist.h" -#include "BKE_deform.h" -#include "BKE_DerivedMesh.h" #include "BKE_cdderivedmesh.h" #include "BKE_object.h" -#include "BKE_world.h" -#include "BKE_mesh.h" -#include "BKE_effect.h" #include "BKE_mball.h" #include "BKE_material.h" #include "BKE_curve.h" #include "BKE_key.h" #include "BKE_anim.h" -#include "BKE_screen.h" -#include "BKE_texture.h" -#include "BKE_library.h" #include "BKE_font.h" #include "BKE_lattice.h" -#include "BKE_scene.h" -#include "BKE_subsurf.h" #include "BKE_modifier.h" -#include "BKE_customdata.h" #include "RE_pipeline.h" #include "RE_shader_ext.h" diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 9902503950b..772a589f520 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -55,35 +55,26 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_material_types.h" -#include "DNA_lamp_types.h" #include "DNA_curve_types.h" -#include "DNA_image_types.h" #include "DNA_camera_types.h" #include "DNA_scene_types.h" -#include "DNA_view3d_types.h" -#include "DNA_userdef_types.h" #include "BKE_utildefines.h" #include "BLI_blenlib.h" #include "BLI_math.h" -#include "BLI_editVert.h" #include "BKE_blender.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_library.h" -#include "BKE_global.h" #include "BKE_object.h" #include "BKE_material.h" -#include "BKE_exotic.h" #include "BKE_report.h" -#include "BKE_screen.h" #include "BKE_displist.h" #include "BKE_DerivedMesh.h" #include "BKE_curve.h" -#include "BKE_customdata.h" #ifndef DISABLE_PYTHON #include "BPY_extern.h" diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 807a723685a..5bfef86b7c6 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -45,7 +45,6 @@ #include "BLI_blenlib.h" #include "BLI_math.h" -#include "BLI_noise.h" #include "BKE_fcurve.h" #include "BKE_animsys.h" @@ -53,12 +52,10 @@ #include "BKE_armature.h" #include "BKE_curve.h" #include "BKE_global.h" -#include "BKE_idprop.h" #include "BKE_object.h" #include "BKE_utildefines.h" #include "RNA_access.h" -#include "RNA_types.h" #ifndef DISABLE_PYTHON #include "BPY_extern.h" diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 969a4208cd3..a5dd415c2ee 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -41,18 +41,11 @@ #include "DNA_anim_types.h" #include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_noise.h" #include "BKE_fcurve.h" -#include "BKE_curve.h" -#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_utildefines.h" -#include "RNA_access.h" -#include "RNA_types.h" - #ifndef DISABLE_PYTHON #include "BPY_extern.h" /* for BPY_pydriver_eval() */ #endif diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 8ec4814dc94..1ca39bbaac4 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -47,8 +47,6 @@ #include "DNA_packedFile_types.h" #include "DNA_curve_types.h" -#include "DNA_object_types.h" -#include "DNA_view3d_types.h" #include "DNA_vfont_types.h" #include "DNA_scene_types.h" @@ -60,7 +58,6 @@ #include "BKE_font.h" #include "BKE_global.h" #include "BKE_main.h" -#include "BKE_screen.h" #include "BKE_anim.h" #include "BKE_curve.h" #include "BKE_displist.h" diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index c65961d0953..5612d69ed76 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -33,27 +33,13 @@ #include "MEM_guardedalloc.h" -#include "IMB_imbuf.h" -#include "IMB_imbuf_types.h" -#include "BLI_math.h" #include "BLI_blenlib.h" -#include "DNA_listBase.h" #include "DNA_gpencil_types.h" -#include "DNA_object_types.h" -#include "DNA_scene_types.h" -#include "DNA_screen_types.h" -#include "DNA_space_types.h" -#include "DNA_userdef_types.h" -#include "DNA_vec_types.h" -#include "BKE_blender.h" -#include "BKE_context.h" -#include "BKE_curve.h" #include "BKE_global.h" #include "BKE_gpencil.h" -#include "BKE_image.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 4f768bbad23..5f35ab87cb2 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -32,11 +32,7 @@ #include "MEM_guardedalloc.h" -#include "DNA_action_types.h" -#include "DNA_effect_types.h" #include "DNA_group_types.h" -#include "DNA_ID.h" -#include "DNA_ipo_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_nla_types.h" @@ -47,7 +43,6 @@ #include "BKE_global.h" #include "BKE_group.h" -#include "BKE_ipo.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 1f22e8c1e3f..5580c73099e 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -38,8 +38,6 @@ #include "MEM_guardedalloc.h" -#include "DNA_ID.h" -#include "DNA_image_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_texture_types.h" @@ -48,7 +46,6 @@ #include "BLI_ghash.h" #include "BKE_icons.h" -#include "BKE_utildefines.h" #include "BKE_global.h" /* only for G.background test */ #include "BLO_sys_types.h" // for intptr_t support diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index e63a1c4c1ad..7981c66d2f6 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -29,13 +29,8 @@ #include #include -#include "DNA_listBase.h" -#include "DNA_ID.h" - #include "BKE_idprop.h" -#include "BKE_global.h" #include "BKE_library.h" -#include "BKE_utildefines.h" #include "BLI_blenlib.h" diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 25a4f9b0a48..85f15094740 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -52,16 +52,12 @@ #include "intern/openexr/openexr_multi.h" #endif -#include "DNA_image_types.h" #include "DNA_packedFile_types.h" #include "DNA_scene_types.h" #include "DNA_camera_types.h" #include "DNA_sequence_types.h" -#include "DNA_texture_types.h" -#include "DNA_sequence_types.h" #include "DNA_userdef_types.h" -#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_threads.h" @@ -73,8 +69,6 @@ #include "BKE_main.h" #include "BKE_packedFile.h" #include "BKE_scene.h" -#include "BKE_texture.h" -#include "BKE_utildefines.h" //XXX #include "BIF_editseq.h" @@ -84,7 +78,6 @@ #include "RE_pipeline.h" -#include "GPU_extensions.h" #include "GPU_draw.h" #include "BLO_sys_types.h" // for intptr_t support diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 6912a65886a..b4fb34d8464 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -31,13 +31,10 @@ #include "BKE_cloth.h" -#include "DNA_cloth_types.h" -#include "DNA_scene_types.h" #include "DNA_object_force.h" #include "BKE_effect.h" #include "BKE_global.h" -#include "BKE_cloth.h" #include "BKE_utildefines.h" #ifdef _WIN32 diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 807b584d6f8..717bf873d2e 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -48,46 +48,28 @@ #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" -#include "DNA_action_types.h" -#include "DNA_armature_types.h" #include "DNA_constraint_types.h" -#include "DNA_curve_types.h" #include "DNA_camera_types.h" #include "DNA_lamp_types.h" #include "DNA_ipo_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" -#include "DNA_mesh_types.h" #include "DNA_nla_types.h" -#include "DNA_object_types.h" -#include "DNA_object_force.h" -#include "DNA_particle_types.h" #include "DNA_sequence_types.h" #include "DNA_scene_types.h" -#include "DNA_sound_types.h" -#include "DNA_texture_types.h" -#include "DNA_view3d_types.h" #include "DNA_world_types.h" #include "BLI_blenlib.h" -#include "BLI_math.h" #include "BLI_dynstr.h" #include "BKE_utildefines.h" #include "BKE_animsys.h" #include "BKE_action.h" -#include "BKE_blender.h" -#include "BKE_curve.h" -#include "BKE_constraint.h" #include "BKE_fcurve.h" #include "BKE_global.h" -#include "BKE_ipo.h" -#include "BKE_library.h" #include "BKE_main.h" -#include "BKE_mesh.h" #include "BKE_nla.h" -#include "BKE_object.h" diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 413d25edd31..9c78742ada0 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -40,24 +40,19 @@ #include "BLI_editVert.h" #include "DNA_anim_types.h" -#include "DNA_curve_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" -#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BKE_animsys.h" -#include "BKE_action.h" -#include "BKE_blender.h" #include "BKE_curve.h" #include "BKE_customdata.h" #include "BKE_global.h" #include "BKE_key.h" #include "BKE_lattice.h" #include "BKE_library.h" -#include "BKE_mesh.h" #include "BKE_main.h" #include "BKE_object.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 8a06ce9234e..347fd01299f 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -41,22 +41,15 @@ #include "BLI_blenlib.h" #include "BLI_math.h" -#include "DNA_armature_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" -#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_lattice_types.h" #include "DNA_curve_types.h" #include "DNA_key_types.h" #include "BKE_anim.h" -#include "BKE_armature.h" -#include "BKE_curve.h" #include "BKE_cdderivedmesh.h" -#include "BKE_DerivedMesh.h" -#include "BKE_deform.h" #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_key.h" @@ -65,8 +58,6 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" -#include "BKE_object.h" -#include "BKE_screen.h" #include "BKE_utildefines.h" //XXX #include "BIF_editdeform.h" diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 83268a0a165..91e53742fea 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -47,17 +47,11 @@ #include "MEM_guardedalloc.h" /* all types are needed here, in order to do memory operations */ -#include "DNA_ID.h" -#include "DNA_listBase.h" #include "DNA_scene_types.h" -#include "DNA_object_types.h" #include "DNA_mesh_types.h" #include "DNA_lattice_types.h" -#include "DNA_curve_types.h" #include "DNA_meta_types.h" #include "DNA_material_types.h" -#include "DNA_texture_types.h" -#include "DNA_image_types.h" #include "DNA_wave_types.h" #include "DNA_lamp_types.h" #include "DNA_camera_types.h" @@ -70,17 +64,10 @@ #include "DNA_sound_types.h" #include "DNA_group_types.h" #include "DNA_armature_types.h" -#include "DNA_action_types.h" -#include "DNA_userdef_types.h" #include "DNA_node_types.h" #include "DNA_nla_types.h" -#include "DNA_effect_types.h" -#include "DNA_brush_types.h" -#include "DNA_particle_types.h" -#include "DNA_space_types.h" #include "DNA_windowmanager_types.h" #include "DNA_anim_types.h" -#include "DNA_gpencil_types.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" @@ -93,7 +80,6 @@ #include "BKE_sound.h" #include "BKE_object.h" #include "BKE_screen.h" -#include "BKE_script.h" #include "BKE_mesh.h" #include "BKE_material.h" #include "BKE_curve.h" @@ -112,7 +98,6 @@ #include "BKE_armature.h" #include "BKE_action.h" #include "BKE_node.h" -#include "BKE_effect.h" #include "BKE_brush.h" #include "BKE_idprop.h" #include "BKE_particle.h" diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 05f0f20feff..2a2d73ca6a0 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -42,14 +42,10 @@ #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_texture_types.h" -#include "DNA_userdef_types.h" -#include "BLI_blenlib.h" #include "BLI_math.h" #include "BKE_animsys.h" -#include "BKE_blender.h" #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_icons.h" diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 24eeb1ab43f..d65870b71ce 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -57,7 +57,6 @@ /* #include "BKE_object.h" */ #include "BKE_animsys.h" #include "BKE_scene.h" -#include "BKE_blender.h" #include "BKE_library.h" #include "BKE_displist.h" #include "BKE_mball.h" diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 08130f51b0e..15f9fc4ac11 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -40,26 +40,18 @@ #include "MEM_guardedalloc.h" -#include "DNA_ID.h" -#include "DNA_anim_types.h" -#include "DNA_curve_types.h" #include "DNA_scene_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" -#include "DNA_image_types.h" #include "DNA_key_types.h" -#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_ipo_types.h" #include "BKE_animsys.h" -#include "BKE_customdata.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_mesh.h" -#include "BKE_subsurf.h" #include "BKE_displist.h" #include "BKE_library.h" #include "BKE_material.h" diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 68087cb553c..4c4abf80db4 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -40,61 +40,30 @@ #include "math.h" #include "float.h" -#include "BLI_math.h" -#include "BLI_blenlib.h" -#include "BLI_kdopbvh.h" #include "BLI_kdtree.h" -#include "BLI_linklist.h" #include "BLI_rand.h" -#include "BLI_edgehash.h" -#include "BLI_ghash.h" -#include "BLI_memarena.h" #include "MEM_guardedalloc.h" -#include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" -#include "DNA_cloth_types.h" #include "DNA_curve_types.h" -#include "DNA_effect_types.h" -#include "DNA_group_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" -#include "DNA_object_types.h" #include "DNA_object_fluidsim.h" -#include "DNA_object_force.h" -#include "DNA_particle_types.h" -#include "DNA_scene_types.h" -#include "DNA_smoke_types.h" -#include "DNA_texture_types.h" -#include "BLI_editVert.h" - - - -#include "BKE_main.h" -#include "BKE_anim.h" #include "BKE_action.h" #include "BKE_bmesh.h" #include "BKE_booleanops.h" #include "BKE_cloth.h" -#include "BKE_collision.h" #include "BKE_cdderivedmesh.h" -#include "BKE_curve.h" -#include "BKE_customdata.h" -#include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_fluidsim.h" #include "BKE_global.h" #include "BKE_multires.h" #include "BKE_key.h" #include "BKE_lattice.h" -#include "BKE_library.h" #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_modifier.h" @@ -106,7 +75,6 @@ #include "BKE_softbody.h" #include "BKE_subsurf.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" #include "depsgraph_private.h" #include "BKE_deform.h" diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index cf1a81fc7e0..248b7ed407d 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -29,27 +29,19 @@ #include "MEM_guardedalloc.h" -#include "DNA_key_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_view3d_types.h" #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_pbvh.h" #include "BKE_cdderivedmesh.h" -#include "BKE_customdata.h" -#include "BKE_depsgraph.h" -#include "BKE_DerivedMesh.h" -#include "BKE_global.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_multires.h" -#include "BKE_object.h" #include "BKE_scene.h" #include "BKE_subsurf.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index bbef2b3e0db..56da45ed19a 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -36,20 +36,14 @@ #include "MEM_guardedalloc.h" -#include "BLI_blenlib.h" #include "BLI_ghash.h" #include "DNA_anim_types.h" -#include "DNA_action_types.h" -#include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_fcurve.h" #include "BKE_nla.h" -#include "BKE_blender.h" #include "BKE_library.h" -#include "BKE_object.h" -#include "BKE_utildefines.h" #include "RNA_access.h" #include "nla_private.h" diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 77e54fe6769..10da12753e7 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -36,42 +36,16 @@ #include #include "DNA_anim_types.h" -#include "DNA_ID.h" -#include "DNA_image_types.h" -#include "DNA_node_types.h" -#include "DNA_material_types.h" -#include "DNA_texture_types.h" -#include "DNA_text_types.h" -#include "DNA_scene_types.h" #include "RNA_access.h" -#include "BKE_blender.h" -#include "BKE_colortools.h" #include "BKE_fcurve.h" -#include "BKE_global.h" -#include "BKE_image.h" -#include "BKE_library.h" -#include "BKE_main.h" -#include "BKE_node.h" -#include "BKE_texture.h" -#include "BKE_text.h" -#include "BKE_utildefines.h" #include "BKE_animsys.h" /* BKE_free_animdata only */ -#include "BLI_math.h" -#include "BLI_blenlib.h" -#include "BLI_rand.h" -#include "BLI_threads.h" #include "PIL_time.h" #include "MEM_guardedalloc.h" -#include "IMB_imbuf.h" - -#include "RE_pipeline.h" -#include "RE_shader_ext.h" /* <- TexResult */ -#include "RE_render_ext.h" /* <- ibuf_sample() */ #include "CMP_node.h" #include "intern/CMP_util.h" /* stupid include path... */ @@ -80,7 +54,6 @@ #include "TEX_node.h" #include "intern/TEX_util.h" -#include "GPU_extensions.h" #include "GPU_material.h" static ListBase empty_list = {NULL, NULL}; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 336f45fc2e2..b08754a7a3f 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -40,34 +40,20 @@ #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" -#include "DNA_action_types.h" #include "DNA_armature_types.h" -#include "DNA_boid_types.h" #include "DNA_camera_types.h" #include "DNA_constraint_types.h" -#include "DNA_curve_types.h" #include "DNA_group_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" #include "DNA_material_types.h" -#include "DNA_mesh_types.h" #include "DNA_meta_types.h" -#include "DNA_curve_types.h" #include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" -#include "DNA_nla_types.h" -#include "DNA_object_types.h" -#include "DNA_object_force.h" -#include "DNA_object_fluidsim.h" -#include "DNA_outliner_types.h" -#include "DNA_particle_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_sequence_types.h" #include "DNA_space_types.h" -#include "DNA_texture_types.h" -#include "DNA_userdef_types.h" #include "DNA_view3d_types.h" #include "DNA_world_types.h" @@ -86,10 +72,8 @@ #include "BKE_colortools.h" #include "BKE_deform.h" #include "BKE_DerivedMesh.h" -#include "BKE_nla.h" #include "BKE_animsys.h" #include "BKE_anim.h" -#include "BKE_blender.h" #include "BKE_constraint.h" #include "BKE_curve.h" #include "BKE_displist.h" @@ -110,7 +94,6 @@ #include "BKE_property.h" #include "BKE_sca.h" #include "BKE_scene.h" -#include "BKE_screen.h" #include "BKE_sequencer.h" #include "BKE_softbody.h" diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index cdcdcc07eef..b62f856e1f3 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -49,17 +49,14 @@ #include "DNA_sound_types.h" #include "DNA_vfont_types.h" #include "DNA_packedFile_types.h" -#include "DNA_scene_types.h" #include "BLI_blenlib.h" #include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_main.h" -#include "BKE_screen.h" #include "BKE_sound.h" #include "BKE_image.h" -#include "BKE_font.h" #include "BKE_packedFile.h" #include "BKE_report.h" diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 5728c7a1fe0..cf5deb95258 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -27,13 +27,11 @@ #include "MEM_guardedalloc.h" -#include "DNA_brush_types.h" #include "DNA_object_types.h" #include "DNA_mesh_types.h" #include "DNA_scene_types.h" #include "BKE_brush.h" -#include "BKE_global.h" #include "BKE_library.h" #include "BKE_paint.h" diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 97e8d6c7f7d..f228dc5002e 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -35,27 +35,15 @@ #include "MEM_guardedalloc.h" -#include "DNA_boid_types.h" #include "DNA_curve_types.h" #include "DNA_group_types.h" -#include "DNA_ipo_types.h" // XXX old animation system stuff to remove! #include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" -#include "DNA_object_force.h" -#include "DNA_object_types.h" #include "DNA_particle_types.h" -#include "DNA_scene_types.h" #include "DNA_smoke_types.h" -#include "DNA_texture_types.h" -#include "BLI_math.h" -#include "BLI_blenlib.h" -#include "BLI_dynstr.h" #include "BLI_kdtree.h" -#include "BLI_listbase.h" #include "BLI_rand.h" #include "BLI_threads.h" @@ -72,9 +60,7 @@ #include "BKE_utildefines.h" #include "BKE_displist.h" #include "BKE_particle.h" -#include "BKE_DerivedMesh.h" #include "BKE_object.h" -#include "BKE_cloth.h" #include "BKE_material.h" #include "BKE_key.h" #include "BKE_library.h" diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 3908429e606..7e73f9b23e7 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -54,7 +54,6 @@ #include "BKE_global.h" #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_pointcache.h" diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index d65e3391f04..1129cc9d736 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -43,10 +43,8 @@ #include "DNA_property_types.h" #include "DNA_object_types.h" -#include "DNA_listBase.h" #include "BLI_blenlib.h" -#include "BKE_property.h" void free_property(bProperty *prop) { diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index a2a44ca53a7..a7800ddc12a 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -27,8 +27,6 @@ #include "MEM_guardedalloc.h" -#include "DNA_listBase.h" - #include "BLI_blenlib.h" #include "BLI_dynstr.h" diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 1c727ee1596..bc66f4d52d3 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -39,7 +39,6 @@ #include "MEM_guardedalloc.h" -#include "DNA_text_types.h" #include "DNA_controller_types.h" #include "DNA_sensor_types.h" #include "DNA_actuator_types.h" @@ -49,8 +48,6 @@ #include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_main.h" -#include "BKE_blender.h" -#include "BKE_sca.h" /* ******************* SENSORS ************************ */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 82aa5576a78..d36043a29ee 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -45,34 +45,15 @@ #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" -#include "DNA_armature_types.h" -#include "DNA_color_types.h" -#include "DNA_constraint_types.h" -#include "DNA_curve_types.h" #include "DNA_group_types.h" -#include "DNA_lamp_types.h" -#include "DNA_material_types.h" -#include "DNA_meta_types.h" -#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" -#include "DNA_texture_types.h" -#include "DNA_userdef_types.h" -#include "BKE_action.h" #include "BKE_anim.h" #include "BKE_animsys.h" -#include "BKE_armature.h" -#include "BKE_colortools.h" -#include "BKE_colortools.h" -#include "BKE_constraint.h" #include "BKE_depsgraph.h" #include "BKE_global.h" -#include "BKE_group.h" -#include "BKE_ipo.h" #include "BKE_idprop.h" -#include "BKE_image.h" -#include "BKE_key.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_node.h" diff --git a/source/blender/blenkernel/intern/script.c b/source/blender/blenkernel/intern/script.c index 424067a7046..c07032f71d7 100644 --- a/source/blender/blenkernel/intern/script.c +++ b/source/blender/blenkernel/intern/script.c @@ -31,17 +31,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -#include "BKE_script.h" -#include "DNA_space_types.h" #include "MEM_guardedalloc.h" /* -#include "BLI_blenlib.h" -#include "BKE_utildefines.h" -#include "BKE_library.h" -#include "BKE_global.h" -#include "BKE_main.h" #ifndef DISABLE_PYTHON #include "BPY_extern.h" // Blender Python library diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 770bcddfffd..77b1ae350d2 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -38,10 +38,6 @@ #include "DNA_sequence_types.h" #include "DNA_anim_types.h" -#include "BLI_blenlib.h" -#include "BLI_math.h" - -#include "BKE_global.h" #include "BKE_fcurve.h" #include "BKE_plugin_types.h" #include "BKE_sequencer.h" diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 424ca162bb4..1309bdf465b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -35,7 +35,6 @@ #include "MEM_guardedalloc.h" #include "MEM_CacheLimiterC-Api.h" -#include "DNA_listBase.h" #include "DNA_sequence_types.h" #include "DNA_scene_types.h" #include "DNA_anim_types.h" @@ -46,7 +45,6 @@ #include "BKE_main.h" #include "BKE_sequencer.h" #include "BKE_fcurve.h" -#include "BKE_utildefines.h" #include "BKE_scene.h" #include "RNA_access.h" #include "RE_pipeline.h" @@ -55,7 +53,6 @@ #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" -#include "BLI_threads.h" #include #include "IMB_imbuf.h" diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index f0b3db4dca5..574ec848291 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -45,21 +45,14 @@ #include "BKE_lattice.h" #include "BKE_utildefines.h" #include "BKE_deform.h" -#include "BKE_cdderivedmesh.h" -#include "BKE_displist.h" -#include "BKE_global.h" #include "BKE_mesh.h" #include "BKE_subsurf.h" #include "BLI_math.h" -#include "BLI_kdtree.h" -#include "BLI_kdopbvh.h" #include "BLI_editVert.h" -#include "RE_raytrace.h" #include "MEM_guardedalloc.h" -#include "ED_mesh.h" /* Util macros */ #define TO_STR(a) #a diff --git a/source/blender/blenkernel/intern/simple_deform.c b/source/blender/blenkernel/intern/simple_deform.c index f3984eb1c8b..8ceb327b63c 100644 --- a/source/blender/blenkernel/intern/simple_deform.c +++ b/source/blender/blenkernel/intern/simple_deform.c @@ -30,7 +30,6 @@ #include "DNA_modifier_types.h" #include "DNA_meshdata_types.h" -#include "BKE_simple_deform.h" #include "BKE_DerivedMesh.h" #include "BKE_lattice.h" #include "BKE_deform.h" diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 1ebf613dea8..af40d9be643 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -56,16 +56,11 @@ variables on the UI for now /* types */ #include "DNA_curve_types.h" -#include "DNA_object_types.h" -#include "DNA_object_force.h" /* here is the softbody struct */ -#include "DNA_key_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" #include "DNA_lattice_types.h" #include "DNA_scene_types.h" -#include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_ghash.h" #include "BLI_threads.h" @@ -73,13 +68,9 @@ variables on the UI for now #include "BKE_curve.h" #include "BKE_effect.h" #include "BKE_global.h" -#include "BKE_key.h" -#include "BKE_object.h" #include "BKE_softbody.h" -#include "BKE_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_pointcache.h" -#include "BKE_modifier.h" #include "BKE_deform.h" //XXX #include "BIF_editdeform.h" //XXX #include "BIF_graphics.h" diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 2f0cb318ca0..d40d4e02dc7 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -14,10 +14,8 @@ #include "DNA_anim_types.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" -#include "DNA_sound_types.h" #include "DNA_packedFile_types.h" #include "DNA_screen_types.h" -#include "DNA_userdef_types.h" #include "AUD_C-API.h" @@ -31,7 +29,6 @@ #include "BKE_fcurve.h" #include "BKE_animsys.h" -#include "RNA_access.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 5d542e143c3..c5c3ae0f022 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -42,20 +42,14 @@ #include "DNA_scene_types.h" #include "BKE_cdderivedmesh.h" -#include "BKE_customdata.h" -#include "BKE_DerivedMesh.h" -#include "BKE_displist.h" #include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_mesh.h" -#include "BKE_multires.h" #include "BKE_scene.h" #include "BKE_subsurf.h" #include "BLI_blenlib.h" #include "BLI_edgehash.h" -#include "BLI_editVert.h" -#include "BLI_linklist.h" #include "BLI_math.h" #include "BLI_memarena.h" #include "BLI_pbvh.h" diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c index 59635d4d344..1b720c1adaa 100644 --- a/source/blender/blenkernel/intern/suggestions.c +++ b/source/blender/blenkernel/intern/suggestions.c @@ -32,9 +32,7 @@ #include #include "MEM_guardedalloc.h" -#include "BLI_blenlib.h" #include "DNA_text_types.h" -#include "BKE_text.h" #include "BKE_suggestions.h" /**********************/ diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 37c583943c6..a0908529a3a 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -37,8 +37,6 @@ #include "BLI_blenlib.h" -#include "DNA_action_types.h" -#include "DNA_armature_types.h" #include "DNA_constraint_types.h" #include "DNA_controller_types.h" #include "DNA_scene_types.h" @@ -50,7 +48,6 @@ #include "BKE_global.h" #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_node.h" #include "BKE_text.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 16cb8a8fb49..0a3f46b617e 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -42,28 +42,21 @@ #include "BLI_blenlib.h" #include "BLI_math.h" -#include "BLI_rand.h" #include "BLI_kdopbvh.h" -#include "DNA_texture_types.h" #include "DNA_key_types.h" #include "DNA_object_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" -#include "DNA_image_types.h" #include "DNA_world_types.h" #include "DNA_brush_types.h" #include "DNA_node_types.h" #include "DNA_color_types.h" -#include "DNA_scene_types.h" -#include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "BKE_plugin_types.h" - #include "BKE_utildefines.h" - #include "BKE_global.h" #include "BKE_main.h" @@ -73,7 +66,6 @@ #include "BKE_texture.h" #include "BKE_key.h" #include "BKE_icons.h" -#include "BKE_brush.h" #include "BKE_node.h" #include "BKE_animsys.h" diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index fff0a08136b..0ac8b14166d 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -35,20 +35,10 @@ #include "MEM_guardedalloc.h" #include "DNA_world_types.h" -#include "DNA_texture_types.h" #include "DNA_scene_types.h" -#include "DNA_object_types.h" -#include "DNA_camera_types.h" - - -#include "BLI_blenlib.h" -#include "BLI_math.h" - -#include "BKE_utildefines.h" #include "BKE_library.h" #include "BKE_animsys.h" -#include "BKE_world.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_icons.h" diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 20d858fffeb..d715d18877d 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -44,14 +44,11 @@ #include #include "MEM_guardedalloc.h" -#include "BLI_blenlib.h" #include "DNA_userdef_types.h" #include "BKE_global.h" #include "BKE_report.h" -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" #include "DNA_scene_types.h" -- cgit v1.2.3 From f61b3ac81ab6e1925c6dfc7ff45fd5dac44a0f36 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sun, 21 Mar 2010 15:40:36 +0000 Subject: Fix for sequencer adding scene strips of the same scene resulting in an endless recursion. --- source/blender/blenkernel/intern/sound.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index d40d4e02dc7..7308146ef92 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -348,7 +348,9 @@ void sound_destroy_scene(struct Scene *scene) void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip) { - return AUD_addSequencer(scene->sound_scene, &(sequence->scene->sound_scene), startframe / FPS, endframe / FPS, frameskip / FPS, sequence); + if(scene != sequence->scene) + return AUD_addSequencer(scene->sound_scene, &(sequence->scene->sound_scene), startframe / FPS, endframe / FPS, frameskip / FPS, sequence); + return NULL; } void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip) -- cgit v1.2.3 From cc8f79019914a8ea15a149993b13e26daae92c91 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Mar 2010 15:47:13 +0000 Subject: recent removal of includes broke for msvc --- source/blender/blenkernel/intern/fmodifier.c | 1 + source/blender/blenkernel/intern/ipo.c | 1 + source/blender/blenkernel/intern/seqeffects.c | 1 + 3 files changed, 3 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index a5dd415c2ee..a0bba578613 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -42,6 +42,7 @@ #include "BLI_blenlib.h" +#include "BKE_math.h" /* windows needs for M_PI */ #include "BKE_fcurve.h" #include "BKE_idprop.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 717bf873d2e..d4e63160370 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -64,6 +64,7 @@ #include "BKE_utildefines.h" +#include "BKE_math.h" /* windows needs for M_PI */ #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_fcurve.h" diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 77b1ae350d2..83043eb70f0 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -38,6 +38,7 @@ #include "DNA_sequence_types.h" #include "DNA_anim_types.h" +#include "BKE_math.h" /* windows needs for M_PI */ #include "BKE_fcurve.h" #include "BKE_plugin_types.h" #include "BKE_sequencer.h" -- cgit v1.2.3 From dd4a8bff516bcc7c0dc14325cfff6ede17118e27 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Mar 2010 15:59:08 +0000 Subject: take 2... --- source/blender/blenkernel/intern/fmodifier.c | 2 +- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/seqeffects.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index a0bba578613..6c73a3ae64c 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -41,8 +41,8 @@ #include "DNA_anim_types.h" #include "BLI_blenlib.h" +#include "BLI_math.h" /* windows needs for M_PI */ -#include "BKE_math.h" /* windows needs for M_PI */ #include "BKE_fcurve.h" #include "BKE_idprop.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index d4e63160370..2c0ca0f69f9 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -59,12 +59,12 @@ #include "DNA_scene_types.h" #include "DNA_world_types.h" +#include "BLI_math.h" /* windows needs for M_PI */ #include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BKE_utildefines.h" -#include "BKE_math.h" /* windows needs for M_PI */ #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_fcurve.h" diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 83043eb70f0..7cabb620085 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -34,11 +34,12 @@ #include "MEM_guardedalloc.h" #include "PIL_dynlib.h" +#include "BLI_math.h" /* windows needs for M_PI */ + #include "DNA_scene_types.h" #include "DNA_sequence_types.h" #include "DNA_anim_types.h" -#include "BKE_math.h" /* windows needs for M_PI */ #include "BKE_fcurve.h" #include "BKE_plugin_types.h" #include "BKE_sequencer.h" -- cgit v1.2.3 From df7b696b73ccd018909e005e2a583e1430e2a620 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 21 Mar 2010 20:36:06 +0000 Subject: Big cleanup of particle system core, also some minor pointcache cleanup. Shouldn't contain any functional changes. --- source/blender/blenkernel/BKE_pointcache.h | 6 + source/blender/blenkernel/intern/cloth.c | 45 +- source/blender/blenkernel/intern/particle_system.c | 793 +++++++++------------ source/blender/blenkernel/intern/pointcache.c | 17 +- source/blender/blenkernel/intern/smoke.c | 12 +- source/blender/blenkernel/intern/softbody.c | 26 +- 6 files changed, 390 insertions(+), 509 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 0268f2faf31..55f11e1066b 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -302,4 +302,10 @@ void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid); /* Loads simulation from external (disk) cache files. */ void BKE_ptcache_load_external(struct PTCacheID *pid); +/* Set correct flags after successful simulation step */ +void BKE_ptcache_validate(struct PointCache *cache, int framenr); + +/* Set correct flags after unsuccessful simulation step */ +void BKE_ptcache_invalidate(struct PointCache *cache); + #endif diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 7183a514225..cf41392e24a 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -356,14 +356,12 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul /* initialize simulation data if it didn't exist already */ if(clmd->clothObject == NULL) { if(!cloth_from_object(ob, clmd, result, framenr, 1)) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; + BKE_ptcache_invalidate(cache); return 0; } if(clmd->clothObject == NULL) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; + BKE_ptcache_invalidate(cache); return 0; } @@ -436,20 +434,17 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, clmd->sim_parms->timescale= timescale; if(!result) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; + BKE_ptcache_invalidate(cache); return dm; } if(clmd->sim_parms->reset || (framenr == (startframe - clmd->sim_parms->preroll))) { clmd->sim_parms->reset = 0; - cache->flag |= PTCACHE_REDO_NEEDED; + cache->flag |= PTCACHE_OUTDATED; BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); - cache->simframe= 0; + BKE_ptcache_validate(cache, 0); cache->last_exact= 0; - cache->flag |= PTCACHE_SIMULATION_VALID; cache->flag &= ~PTCACHE_REDO_NEEDED; return result; } @@ -460,9 +455,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, * happen because of object changes! */ if(clmd->clothObject) { if(result->getNumVerts(result) != clmd->clothObject->numverts) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; + BKE_ptcache_invalidate(cache); return result; } } @@ -472,9 +465,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, /* handle continuous simulation with the play button */ if(BKE_ptcache_get_continue_physics() || ((clmd->sim_parms->preroll > 0) && (framenr > startframe - clmd->sim_parms->preroll) && (framenr < startframe))) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; + BKE_ptcache_invalidate(cache); /* do simulation */ if(!do_init_cloth(ob, clmd, result, framenr)) @@ -488,9 +479,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, /* simulation is only active during a specific period */ if(framenr < startframe) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; + BKE_ptcache_invalidate(cache); return result; } else if(framenr > endframe) { @@ -509,8 +498,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, if((framenr == startframe) && (clmd->sim_parms->preroll == 0)) { BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); do_init_cloth(ob, clmd, result, framenr); - cache->simframe= framenr; - cache->flag |= PTCACHE_SIMULATION_VALID; + BKE_ptcache_validate(cache, framenr); cache->flag &= ~PTCACHE_REDO_NEEDED; return result; } @@ -522,8 +510,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, implicit_set_positions(clmd); cloth_to_object (ob, clmd, result); - cache->simframe= framenr; - cache->flag |= PTCACHE_SIMULATION_VALID; + BKE_ptcache_validate(cache, framenr); if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) BKE_ptcache_write_cache(&pid, framenr); @@ -532,13 +519,10 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, } else if(cache_result==PTCACHE_READ_OLD) { implicit_set_positions(clmd); - cache->flag |= PTCACHE_SIMULATION_VALID; } else if( /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */ /* if baked and nothing in cache, do nothing */ - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; + BKE_ptcache_invalidate(cache); return result; } @@ -549,13 +533,10 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, clmd->sim_parms->timescale *= framenr - cache->simframe; /* do simulation */ - cache->flag |= PTCACHE_SIMULATION_VALID; - cache->simframe= framenr; + BKE_ptcache_validate(cache, framenr); if(!do_step_cloth(ob, clmd, result, framenr)) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; + BKE_ptcache_invalidate(cache); } else BKE_ptcache_write_cache(&pid, framenr); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 38808131f92..c73bd732d85 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -159,8 +159,7 @@ void psys_reset(ParticleSystem *psys, int mode) psys_free_path_cache(psys, psys->edit); /* reset point cache */ - psys->pointcache->flag &= ~PTCACHE_SIMULATION_VALID; - psys->pointcache->simframe= 0; + BKE_ptcache_invalidate(psys->pointcache); } static void realloc_particles(ParticleSimulationData *sim, int new_totpart) @@ -2215,21 +2214,17 @@ static void set_keyed_keys(ParticleSimulationData *sim) void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys) { PointCache *cache = psys->pointcache; - PTCacheID pid; - - if((cache->flag & PTCACHE_DISK_CACHE)==0 || cache->mem_cache.first) - return; - BKE_ptcache_id_from_particles(&pid, ob, psys); - - BKE_ptcache_disk_to_mem(&pid); + if(cache->flag & PTCACHE_DISK_CACHE && cache->mem_cache.first == NULL) { + PTCacheID pid; + BKE_ptcache_id_from_particles(&pid, ob, psys); + BKE_ptcache_disk_to_mem(&pid); + } } static void psys_clear_temp_pointcache(ParticleSystem *psys) { - if((psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) - return; - - BKE_ptcache_free_mem(&psys->pointcache->mem_cache); + if(psys->pointcache->flag & PTCACHE_DISK_CACHE) + BKE_ptcache_free_mem(&psys->pointcache->mem_cache); } void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra) { @@ -3202,15 +3197,11 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) { ParticleSystem *psys = sim->psys; ParticleSettings *part=psys->part; - KDTree *tree=0; - //IpoCurve *icu_esize=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system -/* Material *ma=give_current_material(sim->ob, part->omat); */ BoidBrainData bbd; PARTICLE_P; float timestep; - int totpart; /* current time */ - float ctime, ipotime; // XXX old animation system + float ctime; /* frame & time changes */ float dfra, dtime, pa_dtime, pa_dfra=0.0; float birthtime, dietime; @@ -3218,200 +3209,157 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* where have we gone in time since last time */ dfra= cfra - psys->cfra; - totpart=psys->totpart; - timestep = psys_get_timestep(sim); dtime= dfra*timestep; ctime= cfra*timestep; - ipotime= cfra; // XXX old animation system - -#if 0 // XXX old animation system - if(part->flag&PART_ABS_TIME && part->ipo){ - calc_ipo(part->ipo, cfra); - execute_ipo((ID *)part, part->ipo); - } -#endif // XXX old animation system if(dfra<0.0){ - float *vg_size=0; - //if(part->type==PART_REACTOR) - // vg_size=psys_cache_vgroup(sim->psmd->dm,psys,PSYS_VG_SIZE); - LOOP_EXISTING_PARTICLES { - /* set correct ipo timing */ -#if 0 // XXX old animation system - if((part->flag&PART_ABS_TIME)==0 && part->ipo){ - ipotime=100.0f*(cfra-pa->time)/pa->lifetime; - calc_ipo(part->ipo, ipotime); - execute_ipo((ID *)part, part->ipo); - } -#endif // XXX old animation system pa->size = part->size; if(part->randsize > 0.0) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); reset_particle(sim, pa, dtime, cfra); } - - if(vg_size) - MEM_freeN(vg_size); + return; } - else{ - BLI_srandom(31415926 + (int)cfra + psys->seed); - psys_update_effectors(sim); + BLI_srandom(31415926 + (int)cfra + psys->seed); - if(part->type != PART_HAIR) - sim->colliders = get_collider_cache(sim->scene, NULL); + psys_update_effectors(sim); - if(part->phystype==PART_PHYS_BOIDS){ - ParticleTarget *pt = psys->targets.first; - bbd.sim = sim; - bbd.part = part; - bbd.cfra = cfra; - bbd.dfra = dfra; - bbd.timestep = timestep; + if(part->type != PART_HAIR) + sim->colliders = get_collider_cache(sim->scene, NULL); - psys_update_particle_tree(psys, cfra); + if(part->phystype==PART_PHYS_BOIDS){ + ParticleTarget *pt = psys->targets.first; + bbd.sim = sim; + bbd.part = part; + bbd.cfra = cfra; + bbd.dfra = dfra; + bbd.timestep = timestep; - boids_precalc_rules(part, cfra); + psys_update_particle_tree(psys, cfra); - for(; pt; pt=pt->next) { - if(pt->ob) - psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); - } + boids_precalc_rules(part, cfra); + + for(; pt; pt=pt->next) { + 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 { - copy_particle_key(&pa->prev_state,&pa->state,1); - - /* set correct ipo timing */ -#if 0 // XXX old animation system - if((part->flag&PART_ABS_TIME)==0 && part->ipo){ - ipotime=100.0f*(cfra-pa->time)/pa->lifetime; - calc_ipo(part->ipo, ipotime); - execute_ipo((ID *)part, part->ipo); - } -#endif // XXX old animation system - //update_particle_settings(psys, part, &tpart, pa); + /* main loop: calculate physics for all particles */ + LOOP_SHOWN_PARTICLES { + copy_particle_key(&pa->prev_state,&pa->state,1); - pa->size = part->size; - if(part->randsize > 0.0) - pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); + pa->size = part->size; + if(part->randsize > 0.0) + pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); - ///* reactions can change birth time so they need to be checked first */ - //if(psys->reactevents.first && ELEM(pa->alive,PARS_DEAD,PARS_KILLED)==0) - // react_to_events(psys,p); + ///* reactions can change birth time so they need to be checked first */ + //if(psys->reactevents.first && ELEM(pa->alive,PARS_DEAD,PARS_KILLED)==0) + // react_to_events(psys,p); - birthtime = pa->time; - dietime = birthtime + pa->lifetime; + birthtime = pa->time; + dietime = birthtime + pa->lifetime; - pa_dfra = dfra; - pa_dtime = dtime; + pa_dfra = dfra; + pa_dtime = dtime; - if(dietime <= cfra && psys->cfra < dietime){ - /* particle dies some time between this and last step */ - pa_dfra = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra); - pa_dtime = pa_dfra * timestep; - pa->alive = PARS_DYING; - } - else if(birthtime <= cfra && birthtime >= psys->cfra){ - /* particle is born some time between this and last step*/ - reset_particle(sim, pa, dtime, cfra); - pa->alive = PARS_ALIVE; - pa_dfra = cfra - birthtime; - pa_dtime = pa_dfra*timestep; - } - else if(dietime < cfra){ - /* nothing to be done when particle is dead */ - } + if(dietime <= cfra && psys->cfra < dietime){ + /* particle dies some time between this and last step */ + pa_dfra = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra); + pa_dtime = pa_dfra * timestep; + pa->alive = PARS_DYING; + } + else if(birthtime <= cfra && birthtime >= psys->cfra){ + /* particle is born some time between this and last step*/ + reset_particle(sim, pa, dtime, cfra); + pa->alive = PARS_ALIVE; + pa_dfra = cfra - birthtime; + pa_dtime = pa_dfra*timestep; + } + else if(dietime < cfra){ + /* nothing to be done when particle is dead */ + } + + /* only reset unborn particles if they're shown or if the particle is born soon*/ + if(pa->alive==PARS_UNBORN + && (part->flag & PART_UNBORN || cfra + psys->pointcache->step > pa->time)) + reset_particle(sim, pa, dtime, cfra); + else if(part->phystype == PART_PHYS_NO) + reset_particle(sim, pa, dtime, cfra); + + if(dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){ + switch(part->phystype){ + case PART_PHYS_NEWTON: + /* do global forces & effectors */ + apply_particle_forces(sim, p, pa_dfra, cfra); + + /* deflection */ + if(sim->colliders) + deflect_particle(sim, p, pa_dfra, cfra); + + /* rotations */ + rotate_particle(part, pa, pa_dfra, timestep); + break; + case PART_PHYS_BOIDS: + { + bbd.goal_ob = NULL; + boid_brain(&bbd, p, pa); + if(pa->alive != PARS_DYING) { + boid_body(&bbd, pa); - /* only reset unborn particles if they're shown or if the particle is born soon*/ - if(pa->alive==PARS_UNBORN - && (part->flag & PART_UNBORN || cfra + psys->pointcache->step > pa->time)) - reset_particle(sim, pa, dtime, cfra); - else if(part->phystype == PART_PHYS_NO) - reset_particle(sim, pa, dtime, cfra); - - if(dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){ - switch(part->phystype){ - case PART_PHYS_NEWTON: - /* do global forces & effectors */ - apply_particle_forces(sim, p, pa_dfra, cfra); - /* deflection */ if(sim->colliders) deflect_particle(sim, p, pa_dfra, cfra); - - /* rotations */ - rotate_particle(part, pa, pa_dfra, timestep); - break; - case PART_PHYS_BOIDS: - { - bbd.goal_ob = NULL; - boid_brain(&bbd, p, pa); - if(pa->alive != PARS_DYING) { - boid_body(&bbd, pa); - - /* deflection */ - if(sim->colliders) - deflect_particle(sim, p, pa_dfra, cfra); - } - break; } + break; } + } - if(pa->alive == PARS_DYING){ - //push_reaction(ob,psys,p,PART_EVENT_DEATH,&pa->state); + if(pa->alive == PARS_DYING){ + //push_reaction(ob,psys,p,PART_EVENT_DEATH,&pa->state); - pa->alive=PARS_DEAD; - pa->state.time=pa->dietime; - } - else - pa->state.time=cfra; - - //push_reaction(ob,psys,p,PART_EVENT_NEAR,&pa->state); + pa->alive=PARS_DEAD; + pa->state.time=pa->dietime; } - } + else + pa->state.time=cfra; - free_collider_cache(&sim->colliders); + //push_reaction(ob,psys,p,PART_EVENT_NEAR,&pa->state); + } } - if(tree) - BLI_kdtree_free(tree); + free_collider_cache(&sim->colliders); +} +static void update_children(ParticleSimulationData *sim) +{ + if((sim->psys->part->type == PART_HAIR) && (sim->psys->flag & PSYS_HAIR_DONE)==0) + /* don't generate children while growing hair - waste of time */ + psys_free_children(sim->psys); + else if(sim->psys->part->childtype && sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys)) + distribute_particles(sim, PART_FROM_CHILD); + else + psys_free_children(sim->psys); } - /* updates cached particles' alive & other flags etc..*/ static void cached_step(ParticleSimulationData *sim, float cfra) { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; - //IpoCurve *icu_esize = NULL; //=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system -/* Material *ma = give_current_material(sim->ob,part->omat); */ PARTICLE_P; - float disp, birthtime, dietime, *vg_size= NULL; // XXX ipotime=cfra + float disp, birthtime, dietime; BLI_srandom(psys->seed); - if(part->from!=PART_FROM_PARTICLE) - vg_size= psys_cache_vgroup(sim->psmd->dm,psys,PSYS_VG_SIZE); - psys_update_effectors(sim); disp= (float)get_current_display_percentage(psys)/100.0f; LOOP_PARTICLES { -#if 0 // XXX old animation system - if((part->flag&PART_ABS_TIME)==0 && part->ipo){ - ipotime=100.0f*(cfra-pa->time)/pa->lifetime; - calc_ipo(part->ipo, ipotime); - execute_ipo((ID *)part, part->ipo); - } -#endif // XXX old animation system - //update_settings_with_particle(psys, part, pa); - pa->size = part->size; if(part->randsize > 0.0) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); @@ -3427,12 +3375,10 @@ static void cached_step(ParticleSimulationData *sim, float cfra) if(part->flag & PART_UNBORN && (psys->pointcache->flag & PTCACHE_EXTERNAL) == 0) reset_particle(sim, pa, 0.0f, cfra); } - else if(dietime <= cfra){ + else if(dietime <= cfra) pa->alive = PARS_DEAD; - } - else{ + else pa->alive = PARS_ALIVE; - } if(psys->lattice){ end_latt_deform(psys->lattice); @@ -3444,114 +3390,8 @@ static void cached_step(ParticleSimulationData *sim, float cfra) else pa->flag &= ~PARS_NO_DISP; } - - /* make sure that children are up to date */ - if(psys->part->childtype && psys->totchild != get_psys_tot_child(sim->scene, psys)) { - realloc_particles(sim, psys->totpart); - distribute_particles(sim, PART_FROM_CHILD); - } - - psys_update_path_cache(sim, cfra); - - if(vg_size) - MEM_freeN(vg_size); } -static void psys_changed_type(ParticleSimulationData *sim) -{ - ParticleSettings *part = sim->psys->part; - PTCacheID pid; - - BKE_ptcache_id_from_particles(&pid, sim->ob, sim->psys); - - /* system type has changed so set sensible defaults and clear non applicable flags */ - if(part->from == PART_FROM_PARTICLE) { - //if(part->type != PART_REACTOR) - part->from = PART_FROM_FACE; - if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT) - part->distr = PART_DISTR_JIT; - } - - if(part->phystype != PART_PHYS_KEYED) - sim->psys->flag &= ~PSYS_KEYED; - - if(part->type == PART_HAIR) { - if(ELEM4(part->ren_as, PART_DRAW_NOT, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)==0) - part->ren_as = PART_DRAW_PATH; - - if(ELEM3(part->draw_as, PART_DRAW_NOT, PART_DRAW_REND, PART_DRAW_PATH)==0) - part->draw_as = PART_DRAW_REND; - - CLAMP(part->path_start, 0.0f, 100.0f); - CLAMP(part->path_end, 0.0f, 100.0f); - - BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0); - } - else { - free_hair(sim->ob, sim->psys, 1); - - CLAMP(part->path_start, 0.0f, MAX2(100.0f, part->end + part->lifetime)); - CLAMP(part->path_end, 0.0f, MAX2(100.0f, part->end + part->lifetime)); - } - - psys_reset(sim->psys, PSYS_RESET_ALL); -} -void psys_check_boid_data(ParticleSystem *psys) -{ - BoidParticle *bpa; - PARTICLE_P; - - pa = psys->particles; - - if(!pa) - return; - - if(psys->part && psys->part->phystype==PART_PHYS_BOIDS) { - if(!pa->boid) { - bpa = MEM_callocN(psys->totpart * sizeof(BoidParticle), "Boid Data"); - - LOOP_PARTICLES - pa->boid = bpa++; - } - } - else if(pa->boid){ - MEM_freeN(pa->boid); - LOOP_PARTICLES - pa->boid = NULL; - } -} -static void psys_changed_physics(ParticleSimulationData *sim) -{ - ParticleSettings *part = sim->psys->part; - - if(ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) { - PTCacheID pid; - BKE_ptcache_id_from_particles(&pid, sim->ob, sim->psys); - BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0); - } - else { - free_keyed_keys(sim->psys); - sim->psys->flag &= ~PSYS_KEYED; - } - - if(part->phystype == PART_PHYS_BOIDS && part->boids == NULL) { - BoidState *state; - - part->boids = MEM_callocN(sizeof(BoidSettings), "Boid Settings"); - boid_default_settings(part->boids); - - state = boid_new_state(part->boids); - BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Separate)); - BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Flock)); - - ((BoidRule*)state->rules.first)->flag |= BOIDRULE_CURRENT; - - state->flag |= BOIDSTATE_CURRENT; - BLI_addtail(&part->boids->states, state); - } - - psys_check_boid_data(sim->psys); -} static void particles_fluid_step(ParticleSimulationData *sim, int cfra) { ParticleSystem *psys = sim->psys; @@ -3660,200 +3500,127 @@ static void particles_fluid_step(ParticleSimulationData *sim, int cfra) #endif // DISABLE_ELBEEM } -/* Calculates the next state for all particles of the system */ -/* In particles code most fra-ending are frames, time-ending are fra*timestep (seconds)*/ +static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float cfra) +{ + ParticleSystem *psys = sim->psys; + ParticleSettings *part = psys->part; + int oldtotpart = psys->totpart; + int totpart = oldtotpart; + + if(pid && psys->pointcache->flag & PTCACHE_EXTERNAL) + totpart = pid->cache->totpoint; + else if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT) + totpart = part->grid_res*part->grid_res*part->grid_res; + else + totpart = psys->part->totpart; + + if(totpart != oldtotpart) + realloc_particles(sim, totpart); + + return totpart - oldtotpart; +} +/* Calculates the next state for all particles of the system + * In particles code most fra-ending are frames, time-ending are fra*timestep (seconds) + * 1. Emit particles + * 2. Check cache (if used) and return if frame is cached + * 3. Do dynamics + * 4. Save to cache */ static void system_step(ParticleSimulationData *sim, float cfra) { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; PointCache *cache = psys->pointcache; - PTCacheID pid; + PTCacheID pid, *use_cache = NULL; PARTICLE_P; - int totpart, oldtotpart, totchild, oldtotchild; + int oldtotpart; float disp, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; - int init= 0, distr= 0, alloc= 0, usecache= 0, only_children_changed= 0; - int framenr, framedelta, startframe, endframe; + int init= 0, emit= 0, only_children_changed= 0; + int framenr, framedelta, startframe = 0, endframe = 100; framenr= (int)sim->scene->r.cfra; framedelta= framenr - cache->simframe; - /* set suitable cache range automatically */ - if((cache->flag & (PTCACHE_BAKING|PTCACHE_BAKED))==0 && !(psys->flag & PSYS_HAIR_DYNAMICS)) - psys_get_pointcache_start_end(sim->scene, sim->psys, &cache->startframe, &cache->endframe); - - BKE_ptcache_id_from_particles(&pid, sim->ob, psys); - BKE_ptcache_id_time(&pid, sim->scene, 0.0f, &startframe, &endframe, NULL); - - psys_clear_temp_pointcache(sim->psys); - - /* update ipo's */ -#if 0 // XXX old animation system - if((part->flag & PART_ABS_TIME) && part->ipo) { - calc_ipo(part->ipo, cfra); - execute_ipo((ID *)part, part->ipo); + /* cache shouldn't be used for hair or "continue physics" */ + if(part->type != PART_HAIR && BKE_ptcache_get_continue_physics() == 0) { + BKE_ptcache_id_from_particles(&pid, sim->ob, psys); + use_cache = &pid; } -#endif // XXX old animation system - /* hair if it's already done is handled separate */ - if(part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DONE)) { - hair_step(sim, cfra); - psys->cfra = cfra; - psys->recalc = 0; - return; - } - /* fluid is also handled separate */ - else if(part->type == PART_FLUID) { - particles_fluid_step(sim, framenr); - psys->cfra = cfra; - psys->recalc = 0; - return; - } + if(use_cache) { + psys_clear_temp_pointcache(sim->psys); - /* cache shouldn't be used for hair or "none" or "keyed" physics */ - if(part->type == PART_HAIR || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) - usecache= 0; - else if(BKE_ptcache_get_continue_physics()) - usecache= 0; - else - usecache= 1; + /* set suitable cache range automatically */ + if((cache->flag & (PTCACHE_BAKING|PTCACHE_BAKED))==0) + psys_get_pointcache_start_end(sim->scene, sim->psys, &cache->startframe, &cache->endframe); + + BKE_ptcache_id_time(&pid, sim->scene, 0.0f, &startframe, &endframe, NULL); - if(usecache) { - /* frame clamping */ + /* simulation is only active during a specific period */ if(framenr < startframe) { psys_reset(psys, PSYS_RESET_CACHE_MISS); - psys->cfra = cfra; - psys->recalc = 0; return; } else if(framenr > endframe) { framenr= endframe; } - + if(framenr == startframe) { - BKE_ptcache_id_reset(sim->scene, &pid, PTCACHE_RESET_OUTDATED); - cache->simframe= framenr; - cache->flag |= PTCACHE_SIMULATION_VALID; + BKE_ptcache_id_reset(sim->scene, use_cache, PTCACHE_RESET_OUTDATED); + BKE_ptcache_validate(cache, framenr); cache->flag &= ~PTCACHE_REDO_NEEDED; } } +/* 1. emit particles */ + /* verify if we need to reallocate */ oldtotpart = psys->totpart; - oldtotchild = psys->totchild; - - if(psys->pointcache->flag & PTCACHE_EXTERNAL) - totpart = pid.cache->totpoint; - else if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT) - totpart = part->grid_res*part->grid_res*part->grid_res; - else - totpart = psys->part->totpart; - totchild = get_psys_tot_child(sim->scene, psys); - - if(oldtotpart != totpart || oldtotchild != totchild) { - only_children_changed = (oldtotpart == totpart); - alloc = 1; - distr= 1; - init= 1; - } - if(psys->recalc & PSYS_RECALC_RESET) { - distr= 1; - init= 1; - } + emit = emit_particles(sim, use_cache, cfra); + init = emit*emit + (psys->recalc & PSYS_RECALC_RESET); if(init) { - if(distr) { - if(alloc) { - realloc_particles(sim, totpart); - - if(oldtotpart && usecache && !only_children_changed) { - BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0); - BKE_ptcache_id_from_particles(&pid, sim->ob, psys); - } - } - - if(!only_children_changed) - distribute_particles(sim, part->from); - - if((psys->part->type == PART_HAIR) && !(psys->flag & PSYS_HAIR_DONE)) - /* don't generate children while growing hair - waste of time */ - psys_free_children(psys); - else if(get_psys_tot_child(sim->scene, psys)) - distribute_particles(sim, PART_FROM_CHILD); - } - - if(!only_children_changed) { - free_keyed_keys(psys); - - initialize_all_particles(sim); - - - if(alloc) { - reset_all_particles(sim, 0.0, cfra, oldtotpart); - } - } + distribute_particles(sim, part->from); + initialize_all_particles(sim); + reset_all_particles(sim, 0.0, cfra, oldtotpart); /* flag for possible explode modifiers after this system */ sim->psmd->flag |= eParticleSystemFlag_Pars; } - /* try to read from the cache */ - if(usecache) { - int result = BKE_ptcache_read_cache(&pid, cfra, sim->scene->r.frs_sec); +/* 2. try to read from the cache */ + if(use_cache) { + int cache_result = BKE_ptcache_read_cache(use_cache, cfra, sim->scene->r.frs_sec); - if(result == PTCACHE_READ_EXACT || result == PTCACHE_READ_INTERPOLATED) { + if(ELEM(cache_result, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED)) { cached_step(sim, cfra); - psys->cfra=cfra; - psys->recalc = 0; + update_children(sim); + psys_update_path_cache(sim, cfra); - cache->simframe= framenr; - cache->flag |= PTCACHE_SIMULATION_VALID; + BKE_ptcache_validate(cache, framenr); - if(result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) - BKE_ptcache_write_cache(&pid, (int)cfra); + if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) + BKE_ptcache_write_cache(use_cache, framenr); return; } - else if(result==PTCACHE_READ_OLD) { + else if(cache_result == PTCACHE_READ_OLD) { psys->cfra = (float)cache->simframe; - LOOP_PARTICLES { - /* update alive status */ - if(pa->time > psys->cfra) - pa->alive = PARS_UNBORN; - else if(pa->dietime <= psys->cfra) - pa->alive = PARS_DEAD; - else - pa->alive = PARS_ALIVE; - } + cached_step(sim, psys->cfra); } else if(cfra != startframe && ( /*sim->ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED))) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */ psys_reset(psys, PSYS_RESET_CACHE_MISS); - psys->cfra=cfra; - psys->recalc = 0; return; } - } - else { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; - } - /* if on second frame, write cache for first frame */ - if(usecache && psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - BKE_ptcache_write_cache(&pid, startframe); - - if(part->phystype==PART_PHYS_KEYED) - psys_count_keyed_targets(sim); - - /* initialize vertex groups */ - if(part->from!=PART_FROM_PARTICLE) { - vg_vel= psys_cache_vgroup(sim->psmd->dm,psys,PSYS_VG_VEL); - vg_tan= psys_cache_vgroup(sim->psmd->dm,psys,PSYS_VG_TAN); - vg_rot= psys_cache_vgroup(sim->psmd->dm,psys,PSYS_VG_ROT); - vg_size= psys_cache_vgroup(sim->psmd->dm,psys,PSYS_VG_SIZE); + /* if on second frame, write cache for first frame */ + if(psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) + BKE_ptcache_write_cache(use_cache, startframe); } + else + BKE_ptcache_invalidate(cache); +/* 3. do dynamics */ /* set particles to be not calculated TODO: can't work with pointcache */ disp= (float)get_current_display_percentage(psys)/100.0f; @@ -3880,36 +3647,118 @@ static void system_step(ParticleSimulationData *sim, float cfra) } } - cache->simframe= framenr; - cache->flag |= PTCACHE_SIMULATION_VALID; - - psys->recalc = 0; - psys->cfra = cfra; - - /* only write cache starting from second frame */ - if(usecache && framenr != startframe) - BKE_ptcache_write_cache(&pid, (int)cfra); - - /* for keyed particles the path is allways known so it can be drawn */ - if(part->phystype==PART_PHYS_KEYED) { - set_keyed_keys(sim); - psys_update_path_cache(sim,(int)cfra); +/* 4. only write cache starting from second frame */ + if(use_cache) { + BKE_ptcache_validate(cache, framenr); + if(framenr != startframe) + BKE_ptcache_write_cache(use_cache, framenr); } - else if(psys->pathcache) - psys_free_path_cache(psys, NULL); - /* cleanup */ - if(vg_vel) MEM_freeN(vg_vel); - if(vg_tan) MEM_freeN(vg_tan); - if(vg_rot) MEM_freeN(vg_rot); - if(vg_size) MEM_freeN(vg_size); + if(init) + update_children(sim); +/* cleanup */ if(psys->lattice){ end_latt_deform(psys->lattice); psys->lattice= NULL; } } +/* system type has changed so set sensible defaults and clear non applicable flags */ +static void psys_changed_type(ParticleSimulationData *sim) +{ + ParticleSettings *part = sim->psys->part; + PTCacheID pid; + + BKE_ptcache_id_from_particles(&pid, sim->ob, sim->psys); + + if(part->from == PART_FROM_PARTICLE) { + //if(part->type != PART_REACTOR) + part->from = PART_FROM_FACE; + if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT) + part->distr = PART_DISTR_JIT; + } + + if(part->phystype != PART_PHYS_KEYED) + sim->psys->flag &= ~PSYS_KEYED; + + if(part->type == PART_HAIR) { + if(ELEM4(part->ren_as, PART_DRAW_NOT, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)==0) + part->ren_as = PART_DRAW_PATH; + + if(ELEM3(part->draw_as, PART_DRAW_NOT, PART_DRAW_REND, PART_DRAW_PATH)==0) + part->draw_as = PART_DRAW_REND; + + CLAMP(part->path_start, 0.0f, 100.0f); + CLAMP(part->path_end, 0.0f, 100.0f); + + BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0); + } + else { + free_hair(sim->ob, sim->psys, 1); + + CLAMP(part->path_start, 0.0f, MAX2(100.0f, part->end + part->lifetime)); + CLAMP(part->path_end, 0.0f, MAX2(100.0f, part->end + part->lifetime)); + } + + psys_reset(sim->psys, PSYS_RESET_ALL); +} +void psys_check_boid_data(ParticleSystem *psys) +{ + BoidParticle *bpa; + PARTICLE_P; + + pa = psys->particles; + + if(!pa) + return; + + if(psys->part && psys->part->phystype==PART_PHYS_BOIDS) { + if(!pa->boid) { + bpa = MEM_callocN(psys->totpart * sizeof(BoidParticle), "Boid Data"); + + LOOP_PARTICLES + pa->boid = bpa++; + } + } + else if(pa->boid){ + MEM_freeN(pa->boid); + LOOP_PARTICLES + pa->boid = NULL; + } +} +static void psys_changed_physics(ParticleSimulationData *sim) +{ + ParticleSettings *part = sim->psys->part; + + if(ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) { + PTCacheID pid; + BKE_ptcache_id_from_particles(&pid, sim->ob, sim->psys); + BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0); + } + else { + free_keyed_keys(sim->psys); + sim->psys->flag &= ~PSYS_KEYED; + } + + if(part->phystype == PART_PHYS_BOIDS && part->boids == NULL) { + BoidState *state; + + part->boids = MEM_callocN(sizeof(BoidSettings), "Boid Settings"); + boid_default_settings(part->boids); + + state = boid_new_state(part->boids); + BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Separate)); + BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Flock)); + + ((BoidRule*)state->rules.first)->flag |= BOIDRULE_CURRENT; + + state->flag |= BOIDSTATE_CURRENT; + BLI_addtail(&part->boids->states, state); + } + + psys_check_boid_data(sim->psys); +} static int hair_needs_recalc(ParticleSystem *psys) { if(!(psys->flag & PSYS_EDITED) && (!psys->edit || !psys->edit->edited) && @@ -3920,10 +3769,12 @@ static int hair_needs_recalc(ParticleSystem *psys) return 0; } -/* main particle update call, checks that things are ok on the large scale before actual particle calculations */ +/* main particle update call, checks that things are ok on the large scale and + * then advances in to actual particle calculations depending on particle type */ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) { ParticleSimulationData sim = {scene, ob, psys, NULL, NULL}; + ParticleSettings *part = psys->part; float cfra; /* drawdata is outdated after ANY change */ @@ -3947,35 +3798,81 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) return; /* execute drivers only, as animation has already been done */ - BKE_animsys_evaluate_animdata(&psys->part->id, psys->part->adt, cfra, ADT_RECALC_DRIVERS); + BKE_animsys_evaluate_animdata(&part->id, part->adt, cfra, ADT_RECALC_DRIVERS); if(psys->recalc & PSYS_RECALC_TYPE) psys_changed_type(&sim); else if(psys->recalc & PSYS_RECALC_PHYS) psys_changed_physics(&sim); - /* (re-)create hair */ - if(psys->part->type==PART_HAIR && hair_needs_recalc(psys)) { - float hcfra=0.0f; - int i; - - free_hair(ob, psys, 0); + switch(part->type) { + case PART_HAIR: + { + /* (re-)create hair */ + if(hair_needs_recalc(psys)) { + float hcfra=0.0f; + int i, recalc = psys->recalc; + + free_hair(ob, psys, 0); + + /* first step is negative so particles get killed and reset */ + psys->cfra= 1.0f; + + for(i=0; i<=part->hair_step; i++){ + hcfra=100.0f*(float)i/(float)psys->part->hair_step; + BKE_animsys_evaluate_animdata(&part->id, part->adt, hcfra, ADT_RECALC_ANIM); + system_step(&sim, hcfra); + psys->cfra = hcfra; + psys->recalc = 0; + save_hair(&sim, hcfra); + } - /* first step is negative so particles get killed and reset */ - psys->cfra= 1.0f; + psys->flag |= PSYS_HAIR_DONE; + psys->recalc = recalc; + } - for(i=0; i<=psys->part->hair_step; i++){ - hcfra=100.0f*(float)i/(float)psys->part->hair_step; - BKE_animsys_evaluate_animdata(&psys->part->id, psys->part->adt, hcfra, ADT_RECALC_ANIM); - system_step(&sim, hcfra); - save_hair(&sim, hcfra); + if(psys->flag & PSYS_HAIR_DONE) + hair_step(&sim, cfra); + break; + } + case PART_FLUID: + { + particles_fluid_step(&sim, (int)cfra); + break; } + default: + { + switch(part->phystype) { + case PART_PHYS_NO: + case PART_PHYS_KEYED: + { + if(emit_particles(&sim, NULL, cfra)) { + free_keyed_keys(psys); + distribute_particles(&sim, part->from); + initialize_all_particles(&sim); + } + reset_all_particles(&sim, 0.0, cfra, 0); - psys->flag |= PSYS_HAIR_DONE; + if(part->phystype == PART_PHYS_KEYED) { + psys_count_keyed_targets(&sim); + set_keyed_keys(&sim); + psys_update_path_cache(&sim,(int)cfra); + } + break; + } + default: + { + /* the main dynamic particle system step */ + system_step(&sim, cfra); + break; + } + } + break; + } } - /* the main particle system step */ - system_step(&sim, cfra); + psys->cfra = cfra; + psys->recalc = 0; /* save matrix for duplicators */ invert_m4_m4(psys->imat, ob->obmat); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 7e73f9b23e7..77c5a9e2673 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2081,9 +2081,8 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) } if(reset) { - cache->flag &= ~(PTCACHE_REDO_NEEDED|PTCACHE_SIMULATION_VALID); - cache->simframe= 0; - cache->last_exact= 0; + BKE_ptcache_invalidate(cache); + cache->flag &= ~PTCACHE_REDO_NEEDED; if(pid->type == PTCACHE_TYPE_CLOTH) cloth_free_modifier(pid->ob, pid->calldata); @@ -2861,3 +2860,15 @@ void BKE_ptcache_update_info(PTCacheID *pid) else sprintf(cache->info, "%s.", mem_info); } + +void BKE_ptcache_validate(PointCache *cache, int framenr) +{ + cache->flag |= PTCACHE_SIMULATION_VALID; + cache->simframe = framenr; +} +void BKE_ptcache_invalidate(PointCache *cache) +{ + cache->flag &= ~PTCACHE_SIMULATION_VALID; + cache->simframe = 0; + cache->last_exact = 0; +} \ No newline at end of file diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 69209699a69..129e39ca588 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1197,8 +1197,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(cache_result == PTCACHE_READ_EXACT) { - cache->flag |= PTCACHE_SIMULATION_VALID; - cache->simframe= framenr; + BKE_ptcache_validate(cache, framenr); if(sds->wt) { @@ -1206,8 +1205,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(cache_result_wt == PTCACHE_READ_EXACT) { - cache_wt->flag |= PTCACHE_SIMULATION_VALID; - cache_wt->simframe= framenr; + BKE_ptcache_validate(cache_wt, framenr); } } return; @@ -1223,8 +1221,6 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM /* do simulation */ // low res - cache->flag |= PTCACHE_SIMULATION_VALID; - cache->simframe= framenr; // simulate the actual smoke (c++ code in intern/smoke) // DG: interesting commenting this line + deactivating loading of noise files @@ -1239,6 +1235,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(get_lamp(scene, light)) smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx); + BKE_ptcache_validate(cache, framenr); BKE_ptcache_write_cache(&pid, framenr); if(sds->wt) @@ -1250,8 +1247,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smoke_turbulence_step(sds->wt, sds->fluid); } - cache_wt->flag |= PTCACHE_SIMULATION_VALID; - cache_wt->simframe= framenr; + BKE_ptcache_validate(cache_wt, framenr); BKE_ptcache_write_cache(&pid_wt, framenr); } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index af40d9be643..4b19e71dfca 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -4058,17 +4058,13 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i /* check for changes in mesh, should only happen in case the mesh * structure changes during an animation */ if(sb->bpoint && numVerts != sb->totpoint) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; + BKE_ptcache_invalidate(cache); return; } /* clamp frame ranges */ if(framenr < startframe) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - //cache->last_exact= 0; + BKE_ptcache_invalidate(cache); return; } else if(framenr > endframe) { @@ -4101,8 +4097,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i /* continue physics special case */ if(BKE_ptcache_get_continue_physics()) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; + BKE_ptcache_invalidate(cache); /* do simulation */ dtime = timescale; softbody_update_positions(ob, sb, vertexCos, numVerts); @@ -4121,8 +4116,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i /* first frame, no simulation to do, just set the positions */ softbody_update_positions(ob, sb, vertexCos, numVerts); - cache->simframe= framenr; - cache->flag |= PTCACHE_SIMULATION_VALID; + BKE_ptcache_validate(cache, framenr); cache->flag &= ~PTCACHE_REDO_NEEDED; return; } @@ -4133,8 +4127,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { softbody_to_object(ob, vertexCos, numVerts, sb->local); - cache->simframe= framenr; - cache->flag |= PTCACHE_SIMULATION_VALID; + BKE_ptcache_validate(cache, framenr); if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) BKE_ptcache_write_cache(&pid, framenr); @@ -4142,13 +4135,11 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i return; } else if(cache_result==PTCACHE_READ_OLD) { - cache->flag |= PTCACHE_SIMULATION_VALID; + ; /* do nothing */ } else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { /* if baked and nothing in cache, do nothing */ - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; + BKE_ptcache_invalidate(cache); return; } @@ -4166,8 +4157,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i softbody_to_object(ob, vertexCos, numVerts, 0); - cache->simframe= framenr; - cache->flag |= PTCACHE_SIMULATION_VALID; + BKE_ptcache_validate(cache, framenr); BKE_ptcache_write_cache(&pid, framenr); } -- cgit v1.2.3 From fb9546746efe63a2e6c2806ad12978a4401002d1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Mar 2010 00:22:52 +0000 Subject: Screw Modifier (old patch was called Lathe) didnt commit this patch because curves are generally better to create a shape to lathe however now that curves can have modifiers applied to them I think its good to have this. Added options to offset the lathe so it can work like the screw tool as well. - optional object for axis which also controls the center point. - screw offset so rather then just lathing this can work more like the screw tool. - screw optionally using the object distance along the axis. - iterations so the screw can be applied multiple times. tested to work well with curves. --- source/blender/blenkernel/intern/modifier.c | 813 ++++++++++++++++++++++++++++ 1 file changed, 813 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 4c4abf80db4..811836024f1 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5991,6 +5991,803 @@ static DerivedMesh *solidifyModifier_applyModifierEM(ModifierData *md, return solidifyModifier_applyModifier(md, ob, derivedData, 0, 1); } +/* Screw */ + +/* Screw */ +/* Screw modifier: revolves the edges about an axis +*/ + +/* used for gathering edge connectivity */ +typedef struct ScrewVertConnect { + float dist; /* distance from the center axis */ + float co[3]; /* loaction relative to the transformed axis */ + float no[3]; /* calc normal of the vertex */ + int v[2]; /* 2 verts on either side of this one */ + MEdge *e[2]; /* edges on either side, a bit of a waste since each edge ref's 2 edges */ + char flag; +} ScrewVertConnect; + +typedef struct ScrewVertIter { + ScrewVertConnect * v_array; + ScrewVertConnect * v_poin; + int v; + int v_other; + MEdge *e; +} ScrewVertIter; + +#define ScrewVertIter_INIT(iter, array, v_init, dir)\ + iter.v_array = array;\ + iter.v = v_init;\ + if (v_init>=0) {\ + iter.v_poin = &array[v_init];\ + iter.v_other = iter.v_poin->v[dir];\ + if (dir)\ + iter.e = iter.v_poin->e[0];\ + else\ + iter.e = iter.v_poin->e[1];\ + } else {\ + iter.v_poin= NULL;\ + iter.e= NULL;\ + } + + +#define ScrewVertIter_NEXT(iter)\ + if (iter.v_poin->v[0] == iter.v_other) {\ + iter.v_other= iter.v;\ + iter.v= iter.v_poin->v[1];\ + } else if (iter.v_poin->v[1] == iter.v_other) {\ + iter.v_other= iter.v;\ + iter.v= iter.v_poin->v[0];\ + }\ + if (iter.v >=0) {\ + iter.v_poin= &iter.v_array[iter.v];\ + if ( iter.v_poin->e[0] != iter.e ) iter.e= iter.v_poin->e[0];\ + else iter.e= iter.v_poin->e[1];\ + } else {\ + iter.e= NULL;\ + iter.v_poin= NULL;\ + } + +static void screwModifier_initData(ModifierData *md) +{ + ScrewModifierData *ltmd= (ScrewModifierData*) md; + ltmd->ob_axis= NULL; + ltmd->angle= M_PI * 2.0; + ltmd->axis= 2; + ltmd->flag= 0; + ltmd->steps= 16; + ltmd->render_steps= 16; + ltmd->iter= 1; +} + +static void screwModifier_copyData(ModifierData *md, ModifierData *target) +{ + ScrewModifierData *sltmd= (ScrewModifierData*) md; + ScrewModifierData *tltmd= (ScrewModifierData*) target; + + tltmd->ob_axis= sltmd->ob_axis; + tltmd->angle= sltmd->angle; + tltmd->axis= sltmd->axis; + tltmd->flag= sltmd->flag; + tltmd->steps= sltmd->steps; + tltmd->render_steps= sltmd->render_steps; + tltmd->iter= sltmd->iter; +} + +static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, + DerivedMesh *derivedData, + int useRenderParams, int isFinalCalc) +{ + DerivedMesh *dm= derivedData; + DerivedMesh *result; + ScrewModifierData *ltmd= (ScrewModifierData*) md; + + int *origindex; + int mface_index=0; + int i, j; + int i1,i2; + int steps= ltmd->steps; + int maxVerts=0, maxEdges=0, maxFaces=0; + int totvert= dm->getNumVerts(dm); + int totedge= dm->getNumEdges(dm); + + char axis_char, close; + float angle= ltmd->angle; + float screw_ofs= ltmd->screw_ofs; + float axis_vec[3]= {0.0f, 0.0f, 0.0f}; + float tmp_vec1[3], tmp_vec2[3]; + float mat3[3][3]; + float mtx_tx[4][4]; /* transform the coords by an object relative to this objects transformation */ + float mtx_tx_inv[4][4]; /* inverted */ + float mtx_tmp_a[4][4]; + + int vc_tot_linked= 0; + short other_axis_1, other_axis_2; + float *tmpf1, *tmpf2; + + MFace *mface_new, *mf_new; + MEdge *medge_orig, *med_orig, *med_new, *med_new_firstloop, *medge_new; + MVert *mvert_new, *mvert_orig, *mv_orig, *mv_new, *mv_new_base; + + ScrewVertConnect *vc, *vc_tmp, *vert_connect= NULL; + + + float mat[4][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 0.0f, 1.0f}}; + + /* dont do anything? */ + if (!totvert) + return CDDM_from_template(dm, 0, 0, 0); + + if (useRenderParams) + steps= ltmd->render_steps; + else + steps= ltmd->steps; + + if (ltmd->axis==0) { + other_axis_1=1; + other_axis_2=2; + } else if (ltmd->axis==1) { + other_axis_1=0; + other_axis_2=2; + } else { + other_axis_1=0; + other_axis_2=1; + } + + axis_vec[ltmd->axis]= 1.0; + if (ltmd->ob_axis) { + float mtx3_tx[3][3]; + /* calc the matrix relative to the axis object */ + invert_m4_m4(mtx_tmp_a, ob->obmat); + copy_m4_m4(mtx_tx_inv, ltmd->ob_axis->obmat); + mul_m4_m4m4(mtx_tx, mtx_tx_inv, mtx_tmp_a); + + copy_m3_m4(mtx3_tx, mtx_tx); + + /* calc the axis vec */ + mul_m3_v3(mtx3_tx, axis_vec); + normalize_v3(axis_vec); + + /* screw */ + if(ltmd->flag & MOD_SCREW_OBJECT_OFFSET) { + /* find the offset along this axis relative to this objects matrix */ + float totlen = len_v3(mtx_tx[3]); + + if(totlen != 0.0f) { + float zero[3]={0,0,0}; + float cp[3]; + screw_ofs= closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec); + } + else { + screw_ofs= 0.0f; + } + } + + /* angle */ + +#if 0 // cant incluide this, not pradictable enough, though quite fun,. + if(ltmd->flag & MOD_SCREW_OBJECT_ANGLE) { + + + float vec[3] = {0,1,0}; + float cross1[3]; + float cross2[3]; + cross_v3_v3v3(cross1, vec, axis_vec); + + mul_v3_m3v3(cross2, mtx3_tx, cross1); + { + float c1[3]; + float c2[3]; + float axis_tmp[3]; + + cross_v3_v3v3(c1, cross2, axis_vec); + cross_v3_v3v3(c2, axis_vec, c1); + + + angle= angle_v3v3(cross1, c2); + + cross_v3_v3v3(axis_tmp, cross1, c2); + normalize_v3(axis_tmp); + + if(len_v3v3(axis_tmp, axis_vec) > 1.0) + angle= -angle; + + } + } +#endif + + } else { + /* exis char is used by i_rotate*/ + axis_char= 'X' + ltmd->axis; + + /* useful to be able to use the axis vec in some cases still */ + zero_v3(axis_vec); + axis_vec[ltmd->axis]= 1.0; + } + + /* apply the multiplier */ + angle *= ltmd->iter; + screw_ofs *= ltmd->iter; + + /* multiplying the steps is a bit tricky, this works best */ + steps += 1; + steps = (steps * ltmd->iter) - (ltmd->iter - 1); + if(steps < 2) steps= 2; + + /* will the screw be closed? */ + if (fabs(screw_ofs) <= (FLT_EPSILON*100) && fabs(fabs(angle) - M_PI * 2.0) <= (FLT_EPSILON*100)) { + close= 1; + + maxVerts = totvert * steps; /* -1 because we're joining back up */ + maxEdges = (totvert * steps) + /* these are the edges between new verts */ + (totedge * steps); /* -1 because vert edges join */ + maxFaces = totedge * steps; + + screw_ofs= 0.0f; + } else { + close= 0; + + maxVerts = totvert * steps; /* -1 because we're joining back up */ + maxEdges = (totvert * (steps-1)) + /* these are the edges between new verts */ + (totedge * steps); /* -1 because vert edges join */ + maxFaces = totedge * (steps-1); + } + + result= CDDM_from_template(dm, maxVerts, maxEdges, maxFaces); + + /* copy verts from mesh */ + mvert_orig = dm->getVertArray(dm); + medge_orig = dm->getEdgeArray(dm); + + mvert_new = result->getVertArray(result); + mface_new = result->getFaceArray(result); + medge_new = result->getEdgeArray(result); + + origindex= result->getFaceDataArray(result, CD_ORIGINDEX); + + /* Set the locations of the first set of verts */ + + mv_new= mvert_new; + mv_orig= mvert_orig; + + /* Copy the first set of edges */ + med_orig= medge_orig; + med_new= medge_new; + for (i=0; i < totedge; i++, med_orig++, med_new++) { + med_new->v1= med_orig->v1; + med_new->v2= med_orig->v2; + med_new->crease= med_orig->crease; + med_new->flag= med_orig->flag & ~ME_LOOSEEDGE; + } + + if(ltmd->flag & MOD_SCREW_NORMAL_CALC) { + /* + * Normal Calculation (for face flipping) + * Sort edge verts for correct face flipping + * NOT REALLY NEEDED but face flipping is nice. + * + * */ + + + /* Notice! + * + * Since we are only ordering the edges here it can avoid mallocing the + * extra space by abusing the vert array berfore its filled with new verts. + * The new array for vert_connect must be at least sizeof(ScrewVertConnect) * totvert + * and the size of our resulting meshes array is sizeof(MVert) * totvert * 3 + * so its safe to use the second 2 thrids of MVert the array for vert_connect, + * just make sure ScrewVertConnect struct is no more then twice as big as MVert, + * at the moment there is no chance of that being a problem, + * unless MVert becomes half its current size. + * + * once the edges are ordered, vert_connect is not needed and it can be used for verts + * + * This makes the modifier faster with one less alloc. + */ + + vert_connect= MEM_mallocN(sizeof(ScrewVertConnect) * totvert, "ScrewVertConnect"); + //vert_connect= (ScrewVertConnect *) &medge_new[totvert]; /* skip the first slice of verts */ + vc= vert_connect; + + /* Copy Vert Locations */ + /* - We can do this in a later loop - only do here if no normal calc */ + if (!totedge) { + for (i=0; i < totvert; i++, mv_orig++, mv_new++) { + copy_v3_v3(mv_new->co, mv_orig->co); + normalize_v3_v3(vc->no, mv_new->co); /* no edges- this is realy a dummy normal */ + } + } else { + /*printf("\n\n\n\n\nStarting Modifier\n");*/ + /* set edge users */ + med_new= medge_new; + mv_new= mvert_new; + + if (ltmd->ob_axis) { + /*mtx_tx is initialized early on */ + for (i=0; i < totvert; i++, mv_new++, mv_orig++, vc++) { + vc->co[0]= mv_new->co[0]= mv_orig->co[0]; + vc->co[1]= mv_new->co[1]= mv_orig->co[1]; + vc->co[2]= mv_new->co[2]= mv_orig->co[2]; + + vc->flag= 0; + vc->e[0]= vc->e[1]= NULL; + vc->v[0]= vc->v[1]= -1; + + mul_m4_v3(mtx_tx, vc->co); + /* length in 2d, dont sqrt because this is only for comparison */ + vc->dist = vc->co[other_axis_1]*vc->co[other_axis_1] + + vc->co[other_axis_2]*vc->co[other_axis_2]; + + /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ + } + } else { + for (i=0; i < totvert; i++, mv_new++, mv_orig++, vc++) { + vc->co[0]= mv_new->co[0]= mv_orig->co[0]; + vc->co[1]= mv_new->co[1]= mv_orig->co[1]; + vc->co[2]= mv_new->co[2]= mv_orig->co[2]; + + vc->flag= 0; + vc->e[0]= vc->e[1]= NULL; + vc->v[0]= vc->v[1]= -1; + + /* length in 2d, dont sqrt because this is only for comparison */ + vc->dist = vc->co[other_axis_1]*vc->co[other_axis_1] + + vc->co[other_axis_2]*vc->co[other_axis_2]; + + /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ + } + } + + /* this loop builds connectivity info for verts */ + for (i=0; iv1]; + + if (vc->v[0]==-1) { /* unused */ + vc->v[0]= med_new->v2; + vc->e[0]= med_new; + } else if (vc->v[1]==-1) { + vc->v[1]= med_new->v2; + vc->e[1]= med_new; + } else { + vc->v[0]= vc->v[1]= -2; /* erro value - dont use, 3 edges on vert */ + } + + vc= &vert_connect[med_new->v2]; + + /* same as above but swap v1/2 */ + if (vc->v[0]==-1) { /* unused */ + vc->v[0]= med_new->v1; + vc->e[0]= med_new; + } else if (vc->v[1]==-1) { + vc->v[1]= med_new->v1; + vc->e[1]= med_new; + } else { + vc->v[0]= vc->v[1]= -2; /* erro value - dont use, 3 edges on vert */ + } + } + + /* find the first vert */ + vc= vert_connect; + for (i=0; i < totvert; i++, vc++) { + int VBEST=-1, ed_loop_closed=0; /* vert and vert new */ + int ed_loop_flip; + float fl= -1.0f; + ScrewVertIter lt_iter; + + /* Now do search for connected verts, order all edges and flip them + * so resulting faces are flipped the right way */ + vc_tot_linked= 0; /* count the number of linked verts for this loop */ + if (vc->flag==0) { + /*printf("Loop on connected vert: %i\n", i);*/ + + for(j=0; j<2; j++) { + /*printf("\tSide: %i\n", j);*/ + ScrewVertIter_INIT(lt_iter, vert_connect, i, j); + if (j==1) { + ScrewVertIter_NEXT(lt_iter); + } + while (lt_iter.v_poin) { + /*printf("\t\tVERT: %i\n", lt_iter.v);*/ + if (lt_iter.v_poin->flag) { + /*printf("\t\t\tBreaking Found end\n");*/ + //endpoints[0]= endpoints[1]= -1; + ed_loop_closed= 1; /* circle */ + break; + } + lt_iter.v_poin->flag= 1; + vc_tot_linked++; + /*printf("Testing 2 floats %f : %f\n", fl, lt_iter.v_poin->dist);*/ + if (fl <= lt_iter.v_poin->dist) { + fl= lt_iter.v_poin->dist; + VBEST= lt_iter.v; + /*printf("\t\t\tVERT BEST: %i\n", VBEST);*/ + } + ScrewVertIter_NEXT(lt_iter); + if (!lt_iter.v_poin) { + /*printf("\t\t\tFound End Also Num %i\n", j);*/ + /*endpoints[j]= lt_iter.v_other;*/ /* other is still valid */ + break; + } + } + } + + /* now we have a collection of used edges. flip their edges the right way*/ + /*if (VBEST !=-1) - */ + + /*printf("Done Looking - vc_tot_linked: %i\n", vc_tot_linked);*/ + + if (vc_tot_linked>1) { + float vf_1, vf_2, vf_best; + + vc_tmp= &vert_connect[VBEST]; + + tmpf1= vert_connect[vc_tmp->v[0]].co; + tmpf2= vert_connect[vc_tmp->v[1]].co; + + + /* edge connects on each side! */ + if ((vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) { + /*printf("Verts on each side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ + /* find out which is higher */ + + vf_1= tmpf1[ltmd->axis]; + vf_2= tmpf2[ltmd->axis]; + vf_best= vc_tmp->co[ltmd->axis]; + + if (vf_1 < vf_best && vf_best < vf_2) { + ed_loop_flip= 0; + } else if (vf_1 > vf_best && vf_best > vf_2) { + ed_loop_flip= 1; + } else { + /* not so simple to work out wich 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); + normalize_v3(tmp_vec2); + + if (tmp_vec1[ltmd->axis] < tmp_vec2[ltmd->axis]) { + ed_loop_flip= 1; + } else { + ed_loop_flip= 0; + } + } + } else if (vc_tmp->v[0] >= 0) { /*vertex only connected on 1 side */ + /*printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ + if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */ + ed_loop_flip= 1; + } else { /* best is below or even... in even case we cant know whet to do. */ + ed_loop_flip= 0; + } + + }/* else { + printf("No Connected ___\n"); + }*/ + + /*printf("flip direction %i\n", ed_loop_flip);*/ + + + /* switch the flip option if set */ + if (ltmd->flag & MOD_SCREW_NORMAL_FLIP) { + if (ed_loop_flip) ed_loop_flip= 0; + else ed_loop_flip= 1; + } + if (angle < 0.0f) { + if (ed_loop_flip) ed_loop_flip= 0; + else ed_loop_flip= 1; + } + + /* if its closed, we only need 1 loop */ + for(j=ed_loop_closed; j<2; j++) { + /*printf("Ordering Side J %i\n", j);*/ + + ScrewVertIter_INIT(lt_iter, vert_connect, VBEST, j); + /*printf("\n\nStarting - Loop\n");*/ + lt_iter.v_poin->flag= 1; /* so a non loop will traverse the other side */ + + + /* If this is the vert off the best vert and + * the best vert has 2 edges connected too it + * then swap the flip direction */ + if (j==1 && (vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) { + if (ed_loop_flip) ed_loop_flip= 0; + else ed_loop_flip= 1; + } + + while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) { + /*printf("\tOrdering Vert V %i\n", lt_iter.v);*/ + + lt_iter.v_poin->flag= 2; + if (lt_iter.e) { + if (lt_iter.v == lt_iter.e->v1) { + if (ed_loop_flip==0) { + /*printf("\t\t\tFlipping 0\n");*/ + SWAP( int, lt_iter.e->v1, lt_iter.e->v2 ); + }/* else { + printf("\t\t\tFlipping Not 0\n"); + }*/ + } else if (lt_iter.v == lt_iter.e->v2) { + if (ed_loop_flip==1) { + /*printf("\t\t\tFlipping 1\n");*/ + SWAP( int, lt_iter.e->v1, lt_iter.e->v2 ); + }/* else { + printf("\t\t\tFlipping Not 1\n"); + }*/ + }/* else { + printf("\t\tIncorrect edge topology"); + }*/ + }/* else { + printf("\t\tNo Edge at this point\n"); + }*/ + ScrewVertIter_NEXT(lt_iter); + } + } + } + } + + /* *VERTEX NORMALS* + * we know the surrounding edges are ordered correctly now + * so its safe to create vertex normals. + * + * calculate vertex normals that can be propodated on lathing + * use edge connectivity work this out */ + if (vc->v[0]>=0) { + if (vc->v[1]>=0) { + /* 2 edges connedted */ + /* make 2 connecting vert locations relative to the middle vert */ + sub_v3_v3v3(tmp_vec1, mvert_new[vc->v[0]].co, mvert_new[i].co); + sub_v3_v3v3(tmp_vec2, mvert_new[vc->v[1]].co, mvert_new[i].co); + /* normalize so both edges have the same influence, no matter their length */ + normalize_v3(tmp_vec1); + normalize_v3(tmp_vec2); + + /* vc_no_tmp1 - this line is the average direction of both connecting edges + * + * Use the edge order to make the subtraction, flip the normal the right way + * edge should be there but check just in case... */ + if (vc->e && vc->e[0]->v1 == i) { + sub_v3_v3v3(tmp_vec1, tmp_vec1, tmp_vec2); + } else { + sub_v3_v3v3(tmp_vec1, tmp_vec2, tmp_vec1); + } + + } else { + /* only 1 edge connected - same as above except + * dont need to average edge direction */ + if (vc->e && vc->e[0]->v2 == i) { + sub_v3_v3v3(tmp_vec1, mvert_new[i].co, mvert_new[vc->v[0]].co); + } else { + sub_v3_v3v3(tmp_vec1, mvert_new[vc->v[0]].co, mvert_new[i].co); + } + } + + /* vc_no_tmp2 - is a line 90d from the pivot to the vec + * This is used so the resulting normal points directly away from the middle */ + cross_v3_v3v3(tmp_vec2, axis_vec, vc->co); + + /* edge average vector and right angle to the pivot make the normal */ + cross_v3_v3v3(vc->no, tmp_vec1, tmp_vec2); + + } else { + copy_v3_v3(vc->no, vc->co); + } + + /* we wont be looping on this data again so copy normals here */ + if (angle < 0.0) + negate_v3(vc->no); + + normalize_v3(vc->no); + normal_float_to_short_v3(mvert_new[i].no, vc->no); + + /* Done with normals */ + } + } + } + else { + + if (ltmd->flag & MOD_SCREW_NORMAL_FLIP) { + mv_orig= mvert_orig; + mv_new= mvert_new + (totvert-1); + + for (i=0; i < totvert; i++, mv_new--, mv_orig++) { + copy_v3_v3(mv_new->co, mv_orig->co); + } + } + else { + mv_orig= mvert_orig; + mv_new= mvert_new; + + for (i=0; i < totvert; i++, mv_new++, mv_orig++) { + copy_v3_v3(mv_new->co, mv_orig->co); + } + } + } + /* done with edge connectivity based normal flipping */ + + + /* Add Faces */ + for (i=1; i < steps; i++) { + float step_angle; + float no_tx[3]; + /* Rotation Matrix */ + if (close) step_angle= (angle / steps) * i; + else step_angle= (angle / (steps-1)) * i; + + if (ltmd->ob_axis) { + axis_angle_to_mat3(mat3, axis_vec, step_angle); + copy_m4_m3(mat, mat3); + } else { + unit_m4(mat); + rotate_m4(mat, axis_char, step_angle); + copy_m3_m4(mat3, mat); + } + + if(screw_ofs) + madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)i / (float)(steps-1))); + + mv_new_base= mvert_new; + mv_new= &mvert_new[totvert*i]; /* advance to the next slice */ + + for (j=0; jno, no_tx); + } + + /* set location */ + copy_v3_v3(mv_new->co, mv_new_base->co); + + /* only need to set these if using non cleared memory */ + /*mv_new->mat_nr= mv_new->flag= 0;*/ + + if (ltmd->ob_axis) { + sub_v3_v3(mv_new->co, mtx_tx[3]); + + mul_m4_v3(mat, mv_new->co); + + add_v3_v3(mv_new->co, mtx_tx[3]); + } else { + mul_m4_v3(mat, mv_new->co); + } + + /* add the new edge */ + med_new->v1= j+(i*totvert); + med_new->v2= med_new->v1 - totvert; + med_new->flag= ME_EDGEDRAW|ME_EDGERENDER; + med_new++; + } + } + + /* we can avoid if using vert alloc trick */ + if(vert_connect) { + MEM_freeN(vert_connect); + vert_connect= NULL; + } + + if (close) { + /* last loop of edges, previous loop dosnt account for the last set of edges */ + for (i=0; iv1= i+((steps-1)*totvert); + med_new->v2= i; + med_new->flag= ME_EDGEDRAW|ME_EDGERENDER; + med_new++; + } + } + + mf_new= mface_new; + med_new_firstloop= medge_new; + + for (i=0; i < totedge; i++, med_new_firstloop++) { + /* for each edge, make a cylinder of quads */ + i1= med_new_firstloop->v1; + i2= med_new_firstloop->v2; + + for (j=0; j < steps-1; j++) { + + /* new face */ + mf_new->v1= i1; + mf_new->v2= i2; + mf_new->v3= i2 + totvert; + mf_new->v4= i1 + totvert; + + if( !mf_new->v3 || !mf_new->v4 ) { + SWAP( int, mf_new->v1, mf_new->v3 ); + SWAP( int, mf_new->v2, mf_new->v4 ); + } + mf_new->flag= ME_SMOOTH; + origindex[mface_index]= ORIGINDEX_NONE; + mf_new++; + mface_index++; + + /* new vertical edge */ + if (j) { /* The first set is alredy dome */ + med_new->v1= i1; + med_new->v2= i2; + med_new->flag= med_new_firstloop->flag; + med_new->crease= med_new_firstloop->crease; + med_new++; + } + i1 += totvert; + i2 += totvert; + } + + /* close the loop*/ + if (close) { + mf_new->v1= i1; + mf_new->v2= i2; + mf_new->v3= med_new_firstloop->v2; + mf_new->v4= med_new_firstloop->v1; + + if( !mf_new->v3 || !mf_new->v4 ) { + SWAP( int, mf_new->v1, mf_new->v3 ); + SWAP( int, mf_new->v2, mf_new->v4 ); + } + mf_new->flag= ME_SMOOTH; + origindex[mface_index]= ORIGINDEX_NONE; + mf_new++; + mface_index++; + } + + /* new vertical edge */ + med_new->v1= i1; + med_new->v2= i2; + med_new->flag= med_new_firstloop->flag & ~ME_LOOSEEDGE; + med_new->crease= med_new_firstloop->crease; + med_new++; + } + + if((ltmd->flag & MOD_SCREW_NORMAL_CALC)==0) { + CDDM_calc_normals(result); + } + + return result; +} + + +static void screwModifier_updateDepgraph( + ModifierData *md, DagForest *forest, + Scene *scene, Object *ob, DagNode *obNode) +{ + ScrewModifierData *ltmd= (ScrewModifierData*) md; + + if(ltmd->ob_axis) { + DagNode *curNode= dag_get_node(forest, ltmd->ob_axis); + + dag_add_relation(forest, curNode, obNode, + DAG_RL_DATA_DATA | DAG_RL_OB_DATA, + "Screw Modifier"); + } +} + +static void screwModifier_foreachObjectLink( + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) +{ + ScrewModifierData *ltmd= (ScrewModifierData*) md; + + walk(userData, ob, <md->ob_axis); +} + +/* This dosnt work with material*/ +static DerivedMesh *screwModifier_applyModifierEM( + ModifierData *md, Object *ob, EditMesh *editData, + DerivedMesh *derivedData) +{ + return screwModifier_applyModifier(md, ob, derivedData, 0, 1); +} + +static int screwModifier_dependsOnTime(ModifierData *md) +{ + return 0; +} + + /* Smoke */ static void smokeModifier_initData(ModifierData *md) @@ -8921,6 +9718,22 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->applyModifier = solidifyModifier_applyModifier; mti->applyModifierEM = solidifyModifier_applyModifierEM; typeArrInit = 0; + + mti = INIT_TYPE(Screw); + mti->type = eModifierTypeType_Constructive; + mti->flags = eModifierTypeFlag_AcceptsMesh + | eModifierTypeFlag_SupportsEditmode + | eModifierTypeFlag_EnableInEditmode + | eModifierTypeFlag_AcceptsCVs; + + mti->initData = screwModifier_initData; + mti->copyData = screwModifier_copyData; + mti->foreachObjectLink = screwModifier_foreachObjectLink; + mti->dependsOnTime = screwModifier_dependsOnTime; + mti->updateDepgraph = screwModifier_updateDepgraph; + mti->applyModifier = screwModifier_applyModifier; + mti->applyModifierEM = screwModifier_applyModifierEM; + #undef INIT_TYPE } -- cgit v1.2.3 From 9b2dd9aac65aa49c05176bb8b7aabde9fe1aeeac Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Mar 2010 08:49:12 +0000 Subject: fixes for screw modifier - steps for a closed screw was off by 1 - screw offset wasnt being copied --- source/blender/blenkernel/intern/modifier.c | 140 ++++++++++++++++------------ 1 file changed, 78 insertions(+), 62 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 811836024f1..7eb967aeb09 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5993,7 +5993,6 @@ static DerivedMesh *solidifyModifier_applyModifierEM(ModifierData *md, /* Screw */ -/* Screw */ /* Screw modifier: revolves the edges about an axis */ @@ -6071,12 +6070,13 @@ static void screwModifier_copyData(ModifierData *md, ModifierData *target) tltmd->flag= sltmd->flag; tltmd->steps= sltmd->steps; tltmd->render_steps= sltmd->render_steps; + tltmd->screw_ofs= sltmd->screw_ofs; tltmd->iter= sltmd->iter; } static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) + DerivedMesh *derivedData, + int useRenderParams, int isFinalCalc) { DerivedMesh *dm= derivedData; DerivedMesh *result; @@ -6111,7 +6111,6 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, ScrewVertConnect *vc, *vc_tmp, *vert_connect= NULL; - float mat[4][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 0.0f}, @@ -6121,23 +6120,25 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, if (!totvert) return CDDM_from_template(dm, 0, 0, 0); - if (useRenderParams) - steps= ltmd->render_steps; - else - steps= ltmd->steps; + steps= useRenderParams ? ltmd->render_steps : ltmd->steps; - if (ltmd->axis==0) { + switch(ltmd->axis) { + case 0: other_axis_1=1; other_axis_2=2; - } else if (ltmd->axis==1) { + break; + case 1: other_axis_1=0; other_axis_2=2; - } else { + break; + case 2: other_axis_1=0; other_axis_2=1; + break; } - axis_vec[ltmd->axis]= 1.0; + axis_vec[ltmd->axis]= 1.0f; + if (ltmd->ob_axis) { float mtx3_tx[3][3]; /* calc the matrix relative to the axis object */ @@ -6157,7 +6158,7 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, float totlen = len_v3(mtx_tx[3]); if(totlen != 0.0f) { - float zero[3]={0,0,0}; + float zero[3]={0.0f, 0.0f, 0.0f}; float cp[3]; screw_ofs= closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec); } @@ -6192,20 +6193,20 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, cross_v3_v3v3(axis_tmp, cross1, c2); normalize_v3(axis_tmp); - if(len_v3v3(axis_tmp, axis_vec) > 1.0) + if(len_v3v3(axis_tmp, axis_vec) > 1.0f) angle= -angle; } } #endif - - } else { + } + else { /* exis char is used by i_rotate*/ axis_char= 'X' + ltmd->axis; /* useful to be able to use the axis vec in some cases still */ zero_v3(axis_vec); - axis_vec[ltmd->axis]= 1.0; + axis_vec[ltmd->axis]= 1.0f; } /* apply the multiplier */ @@ -6213,13 +6214,14 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, screw_ofs *= ltmd->iter; /* multiplying the steps is a bit tricky, this works best */ - steps += 1; - steps = (steps * ltmd->iter) - (ltmd->iter - 1); - if(steps < 2) steps= 2; + steps = ((steps + 1) * ltmd->iter) - (ltmd->iter - 1); - /* will the screw be closed? */ - if (fabs(screw_ofs) <= (FLT_EPSILON*100) && fabs(fabs(angle) - M_PI * 2.0) <= (FLT_EPSILON*100)) { + /* will the screw be closed? + * Note! smaller then FLT_EPSILON*100 gives problems with float precission so its never closed. */ + if (fabs(screw_ofs) <= (FLT_EPSILON*100) && fabs(fabs(angle) - (M_PI * 2)) <= (FLT_EPSILON*100)) { close= 1; + steps--; + if(steps < 2) steps= 2; maxVerts = totvert * steps; /* -1 because we're joining back up */ maxEdges = (totvert * steps) + /* these are the edges between new verts */ @@ -6227,9 +6229,11 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, maxFaces = totedge * steps; screw_ofs= 0.0f; - } else { + } + else { close= 0; - + if(steps < 2) steps= 2; + maxVerts = totvert * steps; /* -1 because we're joining back up */ maxEdges = (totvert * (steps-1)) + /* these are the edges between new verts */ (totedge * steps); /* -1 because vert edges join */ @@ -6299,7 +6303,8 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, copy_v3_v3(mv_new->co, mv_orig->co); normalize_v3_v3(vc->no, mv_new->co); /* no edges- this is realy a dummy normal */ } - } else { + } + else { /*printf("\n\n\n\n\nStarting Modifier\n");*/ /* set edge users */ med_new= medge_new; @@ -6323,7 +6328,8 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ } - } else { + } + else { for (i=0; i < totvert; i++, mv_new++, mv_orig++, vc++) { vc->co[0]= mv_new->co[0]= mv_orig->co[0]; vc->co[1]= mv_new->co[1]= mv_orig->co[1]; @@ -6348,10 +6354,12 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, if (vc->v[0]==-1) { /* unused */ vc->v[0]= med_new->v2; vc->e[0]= med_new; - } else if (vc->v[1]==-1) { + } + else if (vc->v[1]==-1) { vc->v[1]= med_new->v2; vc->e[1]= med_new; - } else { + } + else { vc->v[0]= vc->v[1]= -2; /* erro value - dont use, 3 edges on vert */ } @@ -6361,10 +6369,12 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, if (vc->v[0]==-1) { /* unused */ vc->v[0]= med_new->v1; vc->e[0]= med_new; - } else if (vc->v[1]==-1) { + } + else if (vc->v[1]==-1) { vc->v[1]= med_new->v1; vc->e[1]= med_new; - } else { + } + else { vc->v[0]= vc->v[1]= -2; /* erro value - dont use, 3 edges on vert */ } } @@ -6439,9 +6449,11 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, if (vf_1 < vf_best && vf_best < vf_2) { ed_loop_flip= 0; - } else if (vf_1 > vf_best && vf_best > vf_2) { + } + else if (vf_1 > vf_best && vf_best > vf_2) { ed_loop_flip= 1; - } else { + } + else { /* not so simple to work out wich edge is higher */ sub_v3_v3v3(tmp_vec1, tmpf1, vc_tmp->co); sub_v3_v3v3(tmp_vec1, tmpf2, vc_tmp->co); @@ -6450,15 +6462,18 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, if (tmp_vec1[ltmd->axis] < tmp_vec2[ltmd->axis]) { ed_loop_flip= 1; - } else { + } + else { ed_loop_flip= 0; } } - } else if (vc_tmp->v[0] >= 0) { /*vertex only connected on 1 side */ + } + else if (vc_tmp->v[0] >= 0) { /*vertex only connected on 1 side */ /*printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */ ed_loop_flip= 1; - } else { /* best is below or even... in even case we cant know whet to do. */ + } + else { /* best is below or even... in even case we cant know whet to do. */ ed_loop_flip= 0; } @@ -6470,14 +6485,11 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, /* switch the flip option if set */ - if (ltmd->flag & MOD_SCREW_NORMAL_FLIP) { - if (ed_loop_flip) ed_loop_flip= 0; - else ed_loop_flip= 1; - } - if (angle < 0.0f) { - if (ed_loop_flip) ed_loop_flip= 0; - else ed_loop_flip= 1; - } + if (ltmd->flag & MOD_SCREW_NORMAL_FLIP) + ed_loop_flip= !ed_loop_flip; + + if (angle < 0.0f) + ed_loop_flip= !ed_loop_flip; /* if its closed, we only need 1 loop */ for(j=ed_loop_closed; j<2; j++) { @@ -6491,10 +6503,8 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, /* If this is the vert off the best vert and * the best vert has 2 edges connected too it * then swap the flip direction */ - if (j==1 && (vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) { - if (ed_loop_flip) ed_loop_flip= 0; - else ed_loop_flip= 1; - } + if (j==1 && (vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) + ed_loop_flip= !ed_loop_flip; while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) { /*printf("\tOrdering Vert V %i\n", lt_iter.v);*/ @@ -6504,14 +6514,15 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, if (lt_iter.v == lt_iter.e->v1) { if (ed_loop_flip==0) { /*printf("\t\t\tFlipping 0\n");*/ - SWAP( int, lt_iter.e->v1, lt_iter.e->v2 ); + SWAP(int, lt_iter.e->v1, lt_iter.e->v2); }/* else { printf("\t\t\tFlipping Not 0\n"); }*/ - } else if (lt_iter.v == lt_iter.e->v2) { + } + else if (lt_iter.v == lt_iter.e->v2) { if (ed_loop_flip==1) { /*printf("\t\t\tFlipping 1\n");*/ - SWAP( int, lt_iter.e->v1, lt_iter.e->v2 ); + SWAP(int, lt_iter.e->v1, lt_iter.e->v2); }/* else { printf("\t\t\tFlipping Not 1\n"); }*/ @@ -6549,16 +6560,18 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, * edge should be there but check just in case... */ if (vc->e && vc->e[0]->v1 == i) { sub_v3_v3v3(tmp_vec1, tmp_vec1, tmp_vec2); - } else { + } + else { sub_v3_v3v3(tmp_vec1, tmp_vec2, tmp_vec1); } - - } else { + } + else { /* only 1 edge connected - same as above except * dont need to average edge direction */ if (vc->e && vc->e[0]->v2 == i) { sub_v3_v3v3(tmp_vec1, mvert_new[i].co, mvert_new[vc->v[0]].co); - } else { + } + else { sub_v3_v3v3(tmp_vec1, mvert_new[vc->v[0]].co, mvert_new[i].co); } } @@ -6570,12 +6583,13 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, /* edge average vector and right angle to the pivot make the normal */ cross_v3_v3v3(vc->no, tmp_vec1, tmp_vec2); - } else { + } + else { copy_v3_v3(vc->no, vc->co); } /* we wont be looping on this data again so copy normals here */ - if (angle < 0.0) + if (angle < 0.0f) negate_v3(vc->no); normalize_v3(vc->no); @@ -6618,7 +6632,8 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, if (ltmd->ob_axis) { axis_angle_to_mat3(mat3, axis_vec, step_angle); copy_m4_m3(mat, mat3); - } else { + } + else { unit_m4(mat); rotate_m4(mat, axis_char, step_angle); copy_m3_m4(mat3, mat); @@ -6651,7 +6666,8 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, mul_m4_v3(mat, mv_new->co); add_v3_v3(mv_new->co, mtx_tx[3]); - } else { + } + else { mul_m4_v3(mat, mv_new->co); } @@ -6696,8 +6712,8 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, mf_new->v4= i1 + totvert; if( !mf_new->v3 || !mf_new->v4 ) { - SWAP( int, mf_new->v1, mf_new->v3 ); - SWAP( int, mf_new->v2, mf_new->v4 ); + SWAP(int, mf_new->v1, mf_new->v3); + SWAP(int, mf_new->v2, mf_new->v4); } mf_new->flag= ME_SMOOTH; origindex[mface_index]= ORIGINDEX_NONE; @@ -6724,8 +6740,8 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, mf_new->v4= med_new_firstloop->v1; if( !mf_new->v3 || !mf_new->v4 ) { - SWAP( int, mf_new->v1, mf_new->v3 ); - SWAP( int, mf_new->v2, mf_new->v4 ); + SWAP(int, mf_new->v1, mf_new->v3); + SWAP(int, mf_new->v2, mf_new->v4); } mf_new->flag= ME_SMOOTH; origindex[mface_index]= ORIGINDEX_NONE; -- cgit v1.2.3 From 1e9bf0cfdb6c925b28af6f0330467e7d9d798c05 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Mar 2010 09:30:00 +0000 Subject: spaces -> tabs, (4 spaces == 1 tab, only for white space preceding text) --- source/blender/blenkernel/BKE_DerivedMesh.h | 112 ++++----- source/blender/blenkernel/BKE_bmesh.h | 6 +- source/blender/blenkernel/BKE_booleanops.h | 2 +- source/blender/blenkernel/BKE_cdderivedmesh.h | 2 +- source/blender/blenkernel/BKE_context.h | 2 +- source/blender/blenkernel/BKE_customdata.h | 42 ++-- source/blender/blenkernel/BKE_displist.h | 8 +- source/blender/blenkernel/BKE_idprop.h | 2 +- source/blender/blenkernel/BKE_lattice.h | 8 +- source/blender/blenkernel/BKE_modifier.h | 54 ++-- source/blender/blenkernel/BKE_paint.h | 2 +- source/blender/blenkernel/BKE_softbody.h | 4 +- source/blender/blenkernel/BKE_subsurf.h | 10 +- source/blender/blenkernel/intern/BME_Customdata.c | 4 +- source/blender/blenkernel/intern/BME_eulers.c | 2 +- source/blender/blenkernel/intern/BME_mesh.c | 2 +- source/blender/blenkernel/intern/CCGSubSurf.c | 2 +- source/blender/blenkernel/intern/DerivedMesh.c | 102 ++++---- source/blender/blenkernel/intern/action.c | 24 +- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/anim_sys.c | 4 +- source/blender/blenkernel/intern/armature.c | 46 ++-- source/blender/blenkernel/intern/bmfont.c | 2 +- source/blender/blenkernel/intern/booleanops.c | 10 +- source/blender/blenkernel/intern/brush.c | 4 +- source/blender/blenkernel/intern/bvhutils.c | 2 +- source/blender/blenkernel/intern/cdderivedmesh.c | 64 ++--- source/blender/blenkernel/intern/cloth.c | 12 +- source/blender/blenkernel/intern/colortools.c | 8 +- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/curve.c | 40 +-- source/blender/blenkernel/intern/customdata.c | 150 ++++++------ source/blender/blenkernel/intern/depsgraph.c | 4 +- source/blender/blenkernel/intern/displist.c | 8 +- source/blender/blenkernel/intern/effect.c | 10 +- source/blender/blenkernel/intern/exotic.c | 108 ++++---- source/blender/blenkernel/intern/fluidsim.c | 6 +- source/blender/blenkernel/intern/fmodifier.c | 8 +- source/blender/blenkernel/intern/font.c | 18 +- source/blender/blenkernel/intern/idprop.c | 12 +- source/blender/blenkernel/intern/image.c | 20 +- source/blender/blenkernel/intern/image_gen.c | 82 +++---- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/key.c | 10 +- source/blender/blenkernel/intern/lattice.c | 10 +- source/blender/blenkernel/intern/library.c | 14 +- source/blender/blenkernel/intern/material.c | 90 +++---- source/blender/blenkernel/intern/mball.c | 14 +- source/blender/blenkernel/intern/mesh.c | 8 +- source/blender/blenkernel/intern/modifier.c | 272 ++++++++++----------- source/blender/blenkernel/intern/multires.c | 8 +- source/blender/blenkernel/intern/node.c | 22 +- source/blender/blenkernel/intern/object.c | 20 +- source/blender/blenkernel/intern/particle.c | 8 +- source/blender/blenkernel/intern/particle_system.c | 16 +- source/blender/blenkernel/intern/pointcache.c | 8 +- source/blender/blenkernel/intern/sca.c | 20 +- source/blender/blenkernel/intern/scene.c | 20 +- source/blender/blenkernel/intern/seqeffects.c | 240 +++++++++--------- source/blender/blenkernel/intern/sequencer.c | 144 +++++------ source/blender/blenkernel/intern/smoke.c | 160 ++++++------ source/blender/blenkernel/intern/softbody.c | 144 +++++------ source/blender/blenkernel/intern/subsurf_ccg.c | 74 +++--- source/blender/blenkernel/intern/text.c | 2 +- source/blender/blenkernel/intern/texture.c | 6 +- source/blender/blenkernel/intern/world.c | 6 +- source/blender/blenkernel/intern/writeffmpeg.c | 10 +- .../blender/blenkernel/intern/writeframeserver.c | 4 +- 68 files changed, 1172 insertions(+), 1172 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 154c6347f50..cb87638af44 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -165,28 +165,28 @@ struct DerivedMesh { * passed as a float or short array, only one should be non-NULL. */ void (*foreachMappedVert)( - DerivedMesh *dm, - void (*func)(void *userData, int index, float *co, - float *no_f, short *no_s), - void *userData); + DerivedMesh *dm, + void (*func)(void *userData, int index, float *co, + float *no_f, short *no_s), + void *userData); /* Iterate over each mapped edge in the derived mesh, calling the * given function with the original edge and the mapped edge's new * coordinates. */ void (*foreachMappedEdge)(DerivedMesh *dm, - void (*func)(void *userData, int index, - float *v0co, float *v1co), - void *userData); + void (*func)(void *userData, int index, + float *v0co, float *v1co), + void *userData); /* Iterate over each mapped face in the derived mesh, calling the * given function with the original face and the mapped face's (or * faces') center and normal. */ void (*foreachMappedFaceCenter)(DerivedMesh *dm, - void (*func)(void *userData, int index, - float *cent, float *no), - void *userData); + void (*func)(void *userData, int index, + float *cent, float *no), + void *userData); /* Iterate over all vertex points, calling DO_MINMAX with given args. * @@ -240,7 +240,7 @@ struct DerivedMesh { * Also called for *final* editmode DerivedMeshes */ void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4], - int fast, int (*setMaterial)(int, void *attribs)); + int fast, int (*setMaterial)(int, void *attribs)); /* Draw all faces * o If useTwoSided, draw front and back using col arrays @@ -248,14 +248,14 @@ struct DerivedMesh { * in ABGR format, and should be passed as per-face vertex color. */ void (*drawFacesColored)(DerivedMesh *dm, int useTwoSided, - unsigned char *col1, unsigned char *col2); + unsigned char *col1, unsigned char *col2); /* Draw all faces using MTFace * o Drawing options too complicated to enumerate, look at code. */ void (*drawFacesTex)(DerivedMesh *dm, - int (*setDrawOptions)(struct MTFace *tface, - struct MCol *mcol, int matnr)); + int (*setDrawOptions)(struct MTFace *tface, + struct MCol *mcol, int matnr)); /* Draw all faces with GLSL materials * o setMaterial is called for every different material nr @@ -278,17 +278,17 @@ struct DerivedMesh { * smooth shaded. */ void (*drawMappedFaces)(DerivedMesh *dm, - int (*setDrawOptions)(void *userData, int index, - int *drawSmooth_r), - void *userData, int useColors); + int (*setDrawOptions)(void *userData, int index, + int *drawSmooth_r), + void *userData, int useColors); /* Draw mapped faces using MTFace * o Drawing options too complicated to enumerate, look at code. */ void (*drawMappedFacesTex)(DerivedMesh *dm, - int (*setDrawOptions)(void *userData, - int index), - void *userData); + int (*setDrawOptions)(void *userData, + int index), + void *userData); /* Draw mapped faces with GLSL materials * o setMaterial is called for every different material nr @@ -304,8 +304,8 @@ struct DerivedMesh { * returns true */ void (*drawMappedEdges)(DerivedMesh *dm, - int (*setDrawOptions)(void *userData, int index), - void *userData); + int (*setDrawOptions)(void *userData, int index), + void *userData); /* Draw mapped edges as lines with interpolation values * o Only if !setDrawOptions or @@ -315,12 +315,12 @@ struct DerivedMesh { * NOTE: This routine is optional! */ void (*drawMappedEdgesInterp)(DerivedMesh *dm, - int (*setDrawOptions)(void *userData, - int index), - void (*setDrawInterpOptions)(void *userData, - int index, - float t), - void *userData); + int (*setDrawOptions)(void *userData, + int index), + void (*setDrawInterpOptions)(void *userData, + int index, + float t), + void *userData); /* Release reference to the DerivedMesh. This function decides internally * if the DerivedMesh will be freed, or cached for later use. */ @@ -337,14 +337,14 @@ void DM_init_funcs(DerivedMesh *dm); * sets up the custom data layers) */ void DM_init(DerivedMesh *dm, DerivedMeshType type, - int numVerts, int numEdges, int numFaces); + int numVerts, int numEdges, int numFaces); /* utility function to initialise a DerivedMesh for the desired number * of vertices, edges and faces, with a layer setup copied from source */ void DM_from_template(DerivedMesh *dm, DerivedMesh *source, - DerivedMeshType type, - int numVerts, int numEdges, int numFaces); + DerivedMeshType type, + int numVerts, int numEdges, int numFaces); /* utility function to release a DerivedMesh's layers * returns 1 if DerivedMesh has to be released by the backend, 0 otherwise @@ -371,11 +371,11 @@ void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask); * freed, see BKE_customdata.h for the different options */ void DM_add_vert_layer(struct DerivedMesh *dm, int type, int alloctype, - void *layer); + void *layer); void DM_add_edge_layer(struct DerivedMesh *dm, int type, int alloctype, - void *layer); + void *layer); void DM_add_face_layer(struct DerivedMesh *dm, int type, int alloctype, - void *layer); + void *layer); /* custom data access functions * return pointer to data from first layer which matches type @@ -408,11 +408,11 @@ void DM_set_face_data(struct DerivedMesh *dm, int index, int type, void *data); * these copy all layers for which the CD_FLAG_NOCOPY flag is not set */ void DM_copy_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest, - int source_index, int dest_index, int count); + int source_index, int dest_index, int count); void DM_copy_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest, - int source_index, int dest_index, int count); + int source_index, int dest_index, int count); void DM_copy_face_data(struct DerivedMesh *source, struct DerivedMesh *dest, - int source_index, int dest_index, int count); + int source_index, int dest_index, int count); /* custom data free functions * free count elements, starting at index @@ -427,8 +427,8 @@ void DM_free_face_data(struct DerivedMesh *dm, int index, int count); * indexed by dest_index in the dest mesh */ void DM_interp_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest, - int *src_indices, float *weights, - int count, int dest_index); + int *src_indices, float *weights, + int count, int dest_index); /* interpolates edge data from the edges indexed by src_indices in the * source mesh using the given weights and stores the result in the edge indexed @@ -439,9 +439,9 @@ void DM_interp_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest, */ typedef float EdgeVertWeight[SUB_ELEMS_EDGE][SUB_ELEMS_EDGE]; void DM_interp_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest, - int *src_indices, - float *weights, EdgeVertWeight *vert_weights, - int count, int dest_index); + int *src_indices, + float *weights, EdgeVertWeight *vert_weights, + int count, int dest_index); /* interpolates face data from the faces indexed by src_indices in the * source mesh using the given weights and stores the result in the face indexed @@ -452,9 +452,9 @@ void DM_interp_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest, */ typedef float FaceVertWeight[SUB_ELEMS_FACE][SUB_ELEMS_FACE]; void DM_interp_face_data(struct DerivedMesh *source, struct DerivedMesh *dest, - int *src_indices, - float *weights, FaceVertWeight *vert_weights, - int count, int dest_index); + int *src_indices, + float *weights, FaceVertWeight *vert_weights, + int count, int dest_index); void DM_swap_face_data(struct DerivedMesh *dm, int index, int *corner_indices); @@ -468,42 +468,42 @@ float *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob); /* */ DerivedMesh *mesh_get_derived_final(struct Scene *scene, struct Object *ob, - CustomDataMask dataMask); + CustomDataMask dataMask); DerivedMesh *mesh_get_derived_deform(struct Scene *scene, struct Object *ob, - CustomDataMask dataMask); + CustomDataMask dataMask); DerivedMesh *mesh_create_derived_for_modifier(struct Scene *scene, struct Object *ob, struct ModifierData *md); DerivedMesh *mesh_create_derived_render(struct Scene *scene, struct Object *ob, - CustomDataMask dataMask); + CustomDataMask dataMask); DerivedMesh *mesh_create_derived_index_render(struct Scene *scene, struct Object *ob, CustomDataMask dataMask, int index); /* same as above but wont use render settings */ DerivedMesh *mesh_create_derived_view(struct Scene *scene, struct Object *ob, - CustomDataMask dataMask); + CustomDataMask dataMask); DerivedMesh *mesh_create_derived_no_deform(struct Scene *scene, struct Object *ob, - float (*vertCos)[3], - CustomDataMask dataMask); + float (*vertCos)[3], + CustomDataMask dataMask); DerivedMesh *mesh_create_derived_no_deform_render(struct Scene *scene, struct Object *ob, - float (*vertCos)[3], - CustomDataMask dataMask); + float (*vertCos)[3], + CustomDataMask dataMask); /* for gameengine */ DerivedMesh *mesh_create_derived_no_virtual(struct Scene *scene, struct Object *ob, float (*vertCos)[3], - CustomDataMask dataMask); + CustomDataMask dataMask); DerivedMesh *editmesh_get_derived_base(struct Object *, struct EditMesh *em); DerivedMesh *editmesh_get_derived_cage(struct Scene *scene, struct Object *, struct EditMesh *em, CustomDataMask dataMask); DerivedMesh *editmesh_get_derived_cage_and_final(struct Scene *scene, struct Object *, struct EditMesh *em, DerivedMesh **final_r, - CustomDataMask dataMask); + CustomDataMask dataMask); void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct EditMesh *em, CustomDataMask dataMask); /* returns an array of deform matrices for crazyspace correction, and the number of modifiers left */ int editmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct EditMesh *em, - float (**deformmats)[3][3], float (**deformcos)[3]); + float (**deformmats)[3][3], float (**deformcos)[3]); void weight_to_rgb(float input, float *fr, float *fg, float *fb); diff --git a/source/blender/blenkernel/BKE_bmesh.h b/source/blender/blenkernel/BKE_bmesh.h index 470db28cb72..aff102f2e09 100644 --- a/source/blender/blenkernel/BKE_bmesh.h +++ b/source/blender/blenkernel/BKE_bmesh.h @@ -218,11 +218,11 @@ typedef struct BME_TransData { void *loc; /* a pointer to the data to transform (likely the vert's cos) */ float factor; /* primary scaling factor; also accumulates number of weighted edges for beveling tool */ float weight; /* another scaling factor; used primarily for propogating vertex weights to transforms; */ - /* weight is also used across recursive bevels to help with the math */ + /* weight is also used across recursive bevels to help with the math */ float maxfactor; /* the unscaled, original factor (used only by "edge verts" in recursive beveling) */ float *max; /* the maximum distance this vert can be transformed; negative is infinite - * it points to the "parent" maxfactor (where maxfactor makes little sense) - * where the max limit is stored (limits are stored per-corner) */ + * it points to the "parent" maxfactor (where maxfactor makes little sense) + * where the max limit is stored (limits are stored per-corner) */ } BME_TransData; typedef struct BME_TransData_Head { diff --git a/source/blender/blenkernel/BKE_booleanops.h b/source/blender/blenkernel/BKE_booleanops.h index d323725ec19..dcf71645db3 100644 --- a/source/blender/blenkernel/BKE_booleanops.h +++ b/source/blender/blenkernel/BKE_booleanops.h @@ -44,6 +44,6 @@ int NewBooleanMesh(struct Scene *scene, struct Base *base, struct Base *base_sel are in fact mesh object. On success returns a DerivedMesh. On failure returns NULL and reports an error. */ struct DerivedMesh *NewBooleanDerivedMesh(struct DerivedMesh *dm, struct Object *ob, struct DerivedMesh *dm_select, struct Object *ob_select, - int int_op_type); + int int_op_type); #endif diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h index 33e8f930c9d..bff9f16b489 100644 --- a/source/blender/blenkernel/BKE_cdderivedmesh.h +++ b/source/blender/blenkernel/BKE_cdderivedmesh.h @@ -71,7 +71,7 @@ struct DerivedMesh *CDDM_copy(struct DerivedMesh *dm); * elements are initialised to all zeros */ struct DerivedMesh *CDDM_from_template(struct DerivedMesh *source, - int numVerts, int numEdges, int numFaces); + int numVerts, int numEdges, int numFaces); /* applies vertex coordinates or normals to a CDDerivedMesh. if the MVert * layer is a referenced layer, it will be duplicate to not overwrite the diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index ae3fdb91edf..48e2dbf4fec 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -167,7 +167,7 @@ void CTX_wm_menu_set(bContext *C, struct ARegion *menu); /* Data Context - listbases consist of CollectionPointerLink items and must be - freed with BLI_freelistN! + freed with BLI_freelistN! - the dir listbase consits of LinkData items */ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member); diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 2f65dab9b83..c07b26fd372 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -57,18 +57,18 @@ extern const CustomDataMask CD_MASK_FACECORNERS; #define CD_DEFAULT 2 /* allocate and set to default */ #define CD_REFERENCE 3 /* use data pointers, set layer flag NOFREE */ #define CD_DUPLICATE 4 /* do a full copy of all layers, only allowed if source - has same number of elements */ + has same number of elements */ /* initialises a CustomData object with the same layer setup as source. * mask is a bitfield where (mask & (1 << (layer type))) indicates * if a layer should be copied or not. alloctype must be one of the above. */ void CustomData_copy(const struct CustomData *source, struct CustomData *dest, - CustomDataMask mask, int alloctype, int totelem); + CustomDataMask mask, int alloctype, int totelem); /* same as the above, except that this will preserve existing layers, and only * add the layers that were not there yet */ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, - CustomDataMask mask, int alloctype, int totelem); + CustomDataMask mask, int alloctype, int totelem); /* frees data associated with a CustomData object (doesn't free the object * itself, though) @@ -85,10 +85,10 @@ void CustomData_free_temporary(struct CustomData *data, int totelem); * in editmode, use EM_add_data_layer instead of this function */ void *CustomData_add_layer(struct CustomData *data, int type, int alloctype, - void *layer, int totelem); + void *layer, int totelem); /*same as above but accepts a name */ void *CustomData_add_layer_named(struct CustomData *data, int type, int alloctype, - void *layer, int totelem, char *name); + void *layer, int totelem, char *name); /* frees the active or first data layer with the give type. * returns 1 on succes, 0 if no layer with the given type is found @@ -117,14 +117,14 @@ int CustomData_number_of_layers(const struct CustomData *data, int type); * returns the layer data */ void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type); void *CustomData_duplicate_referenced_layer_named(struct CustomData *data, - int type, char *name); + int type, char *name); /* set the CD_FLAG_NOCOPY flag in custom data layers where the mask is * zero for the layer type, so only layer types specified by the mask * will be copied */ void CustomData_set_only_copy(const struct CustomData *data, - CustomDataMask mask); + CustomDataMask mask); /* copies data from one CustomData object to another * objects need not be compatible, each source layer is copied to the @@ -132,11 +132,11 @@ void CustomData_set_only_copy(const struct CustomData *data, * return 1 on success, 0 on failure */ void CustomData_copy_data(const struct CustomData *source, - struct CustomData *dest, int source_index, - int dest_index, int count); + struct CustomData *dest, int source_index, + int dest_index, int count); void CustomData_em_copy_data(const struct CustomData *source, - struct CustomData *dest, void *src_block, - void **dest_block); + struct CustomData *dest, void *src_block, + void **dest_block); void CustomData_bmesh_copy_data(const struct CustomData *source, struct CustomData *dest,void *src_block, void **dest_block); @@ -161,11 +161,11 @@ void CustomData_free_elem(struct CustomData *data, int index, int count); * returns 1 on success, 0 on failure */ void CustomData_interp(const struct CustomData *source, struct CustomData *dest, - int *src_indices, float *weights, float *sub_weights, - int count, int dest_index); + int *src_indices, float *weights, float *sub_weights, + int count, int dest_index); void CustomData_em_interp(struct CustomData *data, void **src_blocks, - float *weights, float *sub_weights, int count, - void *dest_block); + float *weights, float *sub_weights, int count, + void *dest_block); void CustomData_bmesh_interp(struct CustomData *data, void **src_blocks, float *weights, float *sub_weights, int count, void *dest_block); @@ -191,7 +191,7 @@ void *CustomData_bmesh_get_n(const struct CustomData *data, void *block, int typ void *CustomData_get_layer(const struct CustomData *data, int type); void *CustomData_get_layer_n(const struct CustomData *data, int type, int n); void *CustomData_get_layer_named(const struct CustomData *data, int type, - char *name); + char *name); int CustomData_get_layer_index(const struct CustomData *data, int type); int CustomData_get_named_layer_index(const struct CustomData *data, int type, char *name); @@ -209,11 +209,11 @@ int CustomData_get_stencil_layer(const struct CustomData *data, int type); * no effect if there is no layer of type */ void CustomData_set(const struct CustomData *data, int index, int type, - void *source); + void *source); void CustomData_em_set(struct CustomData *data, void *block, int type, - void *source); + void *source); void CustomData_em_set_n(struct CustomData *data, void *block, int type, int n, - void *source); + void *source); void CustomData_bmesh_set(const struct CustomData *data, void *block, int type, void *source); @@ -252,9 +252,9 @@ void CustomData_bmesh_free_block(struct CustomData *data, void **block); /* copy custom data to/from layers as in mesh/derivedmesh, to editmesh blocks of data. the CustomData's must not be compatible */ void CustomData_to_em_block(const struct CustomData *source, - struct CustomData *dest, int index, void **block); + struct CustomData *dest, int index, void **block); void CustomData_from_em_block(const struct CustomData *source, - struct CustomData *dest, void *block, int index); + struct CustomData *dest, void *block, int index); void CustomData_to_bmesh_block(const struct CustomData *source, struct CustomData *dest, int src_index, void **dest_block); void CustomData_from_bmesh_block(const struct CustomData *source, diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 01a1126e464..febe0a11ae6 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -66,10 +66,10 @@ struct DerivedMesh; /* used for curves, nurbs, mball, importing */ typedef struct DispList { - struct DispList *next, *prev; - short type, flag; - int parts, nr; - short col, rt; /* rt used by initrenderNurbs */ + struct DispList *next, *prev; + short type, flag; + int parts, nr; + short col, rt; /* rt used by initrenderNurbs */ float *verts, *nors; int *index; unsigned int *col1, *col2; diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 6e364ef63b6..e33239293a8 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -114,7 +114,7 @@ int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop); /*this is the same as IDP_AddToGroup, only you pass an item in the group list to be inserted after.*/ int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous, - struct IDProperty *pnew); + struct IDProperty *pnew); /*NOTE: this does not free the property!! diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index d99296068d9..f35dff53cd5 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -59,11 +59,11 @@ void curve_deform_vector(struct Scene *scene, struct Object *cuOb, struct Object float *orco, float *vec, float mat[][3], int no_rot_axis); void lattice_deform_verts(struct Object *laOb, struct Object *target, - struct DerivedMesh *dm, float (*vertexCos)[3], - int numVerts, char *vgroup); + struct DerivedMesh *dm, float (*vertexCos)[3], + int numVerts, char *vgroup); void armature_deform_verts(struct Object *armOb, struct Object *target, - struct DerivedMesh *dm, float (*vertexCos)[3], - float (*defMats)[3][3], int numVerts, int deformflag, + struct DerivedMesh *dm, float (*vertexCos)[3], + float (*defMats)[3][3], int numVerts, int deformflag, float (*prevCos)[3], const char *defgrp_name); float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]; diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index c9f56ef7e3e..6db610f4d8d 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -130,22 +130,22 @@ typedef struct ModifierTypeInfo { * and otherwise the ob argument. */ void (*deformVerts)(struct ModifierData *md, struct Object *ob, - struct DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, - int useRenderParams, int isFinalCalc); + struct DerivedMesh *derivedData, + float (*vertexCos)[3], int numVerts, + int useRenderParams, int isFinalCalc); /* Like deformVerts but called during editmode (for supporting modifiers) */ void (*deformVertsEM)( - struct ModifierData *md, struct Object *ob, - struct EditMesh *editData, struct DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts); + struct ModifierData *md, struct Object *ob, + struct EditMesh *editData, struct DerivedMesh *derivedData, + float (*vertexCos)[3], int numVerts); /* Set deform matrix per vertex for crazyspace correction */ void (*deformMatricesEM)( - struct ModifierData *md, struct Object *ob, - struct EditMesh *editData, struct DerivedMesh *derivedData, - float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); + struct ModifierData *md, struct Object *ob, + struct EditMesh *editData, struct DerivedMesh *derivedData, + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); /********************* Non-deform modifier functions *********************/ @@ -169,9 +169,9 @@ typedef struct ModifierTypeInfo { * modified form), but must not release it. */ struct DerivedMesh *(*applyModifier)( - struct ModifierData *md, struct Object *ob, - struct DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc); + struct ModifierData *md, struct Object *ob, + struct DerivedMesh *derivedData, + int useRenderParams, int isFinalCalc); /* Like applyModifier but called during editmode (for supporting * modifiers). @@ -181,9 +181,9 @@ typedef struct ModifierTypeInfo { * derivedData apply as for applyModifier. */ struct DerivedMesh *(*applyModifierEM)( - struct ModifierData *md, struct Object *ob, - struct EditMesh *editData, - struct DerivedMesh *derivedData); + struct ModifierData *md, struct Object *ob, + struct EditMesh *editData, + struct DerivedMesh *derivedData); /********************* Optional functions *********************/ @@ -236,7 +236,7 @@ typedef struct ModifierTypeInfo { * This function is optional. */ void (*updateDepgraph)(struct ModifierData *md, struct DagForest *forest, struct Scene *scene, - struct Object *ob, struct DagNode *obNode); + struct Object *ob, struct DagNode *obNode); /* Should return true if the modifier needs to be recalculated on time * changes. @@ -252,7 +252,7 @@ typedef struct ModifierTypeInfo { * This function is optional. */ void (*foreachObjectLink)(struct ModifierData *md, struct Object *ob, - ObjectWalkFunc walk, void *userData); + ObjectWalkFunc walk, void *userData); /* Should call the given walk function with a pointer to each ID * pointer (i.e. each datablock pointer) that the modifier data @@ -263,7 +263,7 @@ typedef struct ModifierTypeInfo { * will be used. */ void (*foreachIDLink)(struct ModifierData *md, struct Object *ob, - IDWalkFunc walk, void *userData); + IDWalkFunc walk, void *userData); } ModifierTypeInfo; ModifierTypeInfo *modifierType_getInfo (ModifierType type); @@ -286,15 +286,15 @@ int modifier_isEnabled(struct Scene *scene, struct ModifierData *md, i void modifier_setError(struct ModifierData *md, char *format, ...); void modifiers_foreachObjectLink(struct Object *ob, - ObjectWalkFunc walk, - void *userData); + ObjectWalkFunc walk, + void *userData); void modifiers_foreachIDLink(struct Object *ob, - IDWalkFunc walk, - void *userData); + IDWalkFunc walk, + void *userData); struct ModifierData *modifiers_findByType(struct Object *ob, ModifierType type); void modifiers_clearErrors(struct Object *ob); int modifiers_getCageIndex(struct Scene *scene, struct Object *ob, - int *lastPossibleCageIndex_r, int virtual_); + int *lastPossibleCageIndex_r, int virtual_); int modifiers_isSoftbodyEnabled(struct Object *ob); int modifiers_isClothEnabled(struct Object *ob); @@ -314,10 +314,10 @@ int modifiers_indexInObject(struct Object *ob, struct ModifierData *md * end of the stack. */ struct LinkNode *modifiers_calcDataMasks(struct Scene *scene, - struct Object *ob, - struct ModifierData *md, - CustomDataMask dataMask, - int required_mode); + struct Object *ob, + struct ModifierData *md, + CustomDataMask dataMask, + int required_mode); struct ModifierData *modifiers_getVirtualModifierList(struct Object *ob); #endif diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index e1c08e2cb3d..8fd4f079ebf 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -86,7 +86,7 @@ typedef struct SculptSession { unsigned int texcache_side, *texcache, texcache_actual; /* Layer brush persistence between strokes */ - float (*layer_co)[3]; /* Copy of the mesh vertices' locations */ + float (*layer_co)[3]; /* Copy of the mesh vertices' locations */ float *layer_disps; /* Displacements for each vertex */ struct SculptStroke *stroke; diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h index 30b7e8cda53..ef7fa473ad0 100644 --- a/source/blender/blenkernel/BKE_softbody.h +++ b/source/blender/blenkernel/BKE_softbody.h @@ -39,8 +39,8 @@ typedef struct BodyPoint { float origS[3], origE[3], origT[3], pos[3], vec[3], force[3]; float goal; float prevpos[3], prevvec[3], prevdx[3], prevdv[3]; /* used for Heun integration */ - float impdv[3],impdx[3]; - int nofsprings; int *springs; + float impdv[3],impdx[3]; + int nofsprings; int *springs; float choke,choke2,frozen; float colball; short flag; diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index 62ad86635c0..fca7c79d96b 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -45,10 +45,10 @@ struct DMGridAdjacency; /**************************** External *****************************/ struct DerivedMesh *subsurf_make_derived_from_derived( - struct DerivedMesh *dm, - struct SubsurfModifierData *smd, - int useRenderParams, float (*vertCos)[3], - int isFinalCalc, int editMode); + struct DerivedMesh *dm, + struct SubsurfModifierData *smd, + int useRenderParams, float (*vertCos)[3], + int isFinalCalc, int editMode); void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]); @@ -64,7 +64,7 @@ typedef struct CCGDerivedMesh { struct {int startVert; struct _CCGVert *vert;} *vertMap; struct {int startVert; int startEdge; struct _CCGEdge *edge;} *edgeMap; struct {int startVert; int startEdge; - int startFace; struct _CCGFace *face;} *faceMap; + int startFace; struct _CCGFace *face;} *faceMap; short *edgeFlags; char *faceFlags; diff --git a/source/blender/blenkernel/intern/BME_Customdata.c b/source/blender/blenkernel/intern/BME_Customdata.c index 736b5e05798..d8a6b66d5bb 100644 --- a/source/blender/blenkernel/intern/BME_Customdata.c +++ b/source/blender/blenkernel/intern/BME_Customdata.c @@ -135,7 +135,7 @@ static void BME_CD_alloc_block(BME_CustomData *data, void **block) } void BME_CD_copy_data(const BME_CustomData *source, BME_CustomData *dest, - void *src_block, void **dest_block) + void *src_block, void **dest_block) { const BME_LayerTypeInfo *typeInfo; int dest_i, src_i; @@ -151,7 +151,7 @@ void BME_CD_copy_data(const BME_CustomData *source, BME_CustomData *dest, * (this should work because layers are ordered by type) */ while(dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + && dest->layers[dest_i].type < source->layers[src_i].type) ++dest_i; /* if there are no more dest layers, we're done */ diff --git a/source/blender/blenkernel/intern/BME_eulers.c b/source/blender/blenkernel/intern/BME_eulers.c index 9c9c71292c2..036cd4a23e2 100644 --- a/source/blender/blenkernel/intern/BME_eulers.c +++ b/source/blender/blenkernel/intern/BME_eulers.c @@ -71,7 +71,7 @@ code. *The term "Euler Operator" is actually a misnomer when referring to a non-manifold - data structure. Its use is in keeping with the convention established by others. + data structure. Its use is in keeping with the convention established by others. TODO: -Finish inserting 'strict' validation in all Eulers diff --git a/source/blender/blenkernel/intern/BME_mesh.c b/source/blender/blenkernel/intern/BME_mesh.c index f616d21c6fd..1bb419937b0 100644 --- a/source/blender/blenkernel/intern/BME_mesh.c +++ b/source/blender/blenkernel/intern/BME_mesh.c @@ -87,7 +87,7 @@ void BME_free_mesh(BME_Mesh *bm) if(bm->ldata.totlayer) BLI_mempool_destroy(bm->ldata.pool); if(bm->pdata.totlayer) BLI_mempool_destroy(bm->pdata.pool); - /*free custom data*/ + /*free custom data*/ CustomData_free(&bm->vdata,0); CustomData_free(&bm->edata,0); CustomData_free(&bm->ldata,0); diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index eb316c64af4..6778c9eb8ad 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -170,7 +170,7 @@ static void *_ehashIterator_getCurrent(EHashIterator *ehi) { static void _ehashIterator_next(EHashIterator *ehi) { if (ehi->curEntry) { - ehi->curEntry = ehi->curEntry->next; + ehi->curEntry = ehi->curEntry->next; while (!ehi->curEntry) { ehi->curBucket++; if (ehi->curBucket==ehi->eh->curSize) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index e69686eeb00..6908d987a36 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -113,7 +113,7 @@ static MFace *dm_getFaceArray(DerivedMesh *dm) static MVert *dm_dupVertArray(DerivedMesh *dm) { MVert *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumVerts(dm), - "dm_dupVertArray tmp"); + "dm_dupVertArray tmp"); if(tmp) dm->copyVertArray(dm, tmp); @@ -123,7 +123,7 @@ static MVert *dm_dupVertArray(DerivedMesh *dm) static MEdge *dm_dupEdgeArray(DerivedMesh *dm) { MEdge *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumEdges(dm), - "dm_dupEdgeArray tmp"); + "dm_dupEdgeArray tmp"); if(tmp) dm->copyEdgeArray(dm, tmp); @@ -133,7 +133,7 @@ static MEdge *dm_dupEdgeArray(DerivedMesh *dm) static MFace *dm_dupFaceArray(DerivedMesh *dm) { MFace *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumFaces(dm), - "dm_dupFaceArray tmp"); + "dm_dupFaceArray tmp"); if(tmp) dm->copyFaceArray(dm, tmp); @@ -161,7 +161,7 @@ void DM_init_funcs(DerivedMesh *dm) } void DM_init(DerivedMesh *dm, DerivedMeshType type, - int numVerts, int numEdges, int numFaces) + int numVerts, int numEdges, int numFaces) { dm->type = type; dm->numVertData = numVerts; @@ -174,14 +174,14 @@ void DM_init(DerivedMesh *dm, DerivedMeshType type, } void DM_from_template(DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type, - int numVerts, int numEdges, int numFaces) + int numVerts, int numEdges, int numFaces) { CustomData_copy(&source->vertData, &dm->vertData, CD_MASK_DERIVEDMESH, - CD_CALLOC, numVerts); + CD_CALLOC, numVerts); CustomData_copy(&source->edgeData, &dm->edgeData, CD_MASK_DERIVEDMESH, - CD_CALLOC, numEdges); + CD_CALLOC, numEdges); CustomData_copy(&source->faceData, &dm->faceData, CD_MASK_DERIVEDMESH, - CD_CALLOC, numFaces); + CD_CALLOC, numFaces); dm->type = type; dm->numVertData = numVerts; @@ -352,24 +352,24 @@ void DM_set_face_data(DerivedMesh *dm, int index, int type, void *data) } void DM_copy_vert_data(DerivedMesh *source, DerivedMesh *dest, - int source_index, int dest_index, int count) + int source_index, int dest_index, int count) { CustomData_copy_data(&source->vertData, &dest->vertData, - source_index, dest_index, count); + source_index, dest_index, count); } void DM_copy_edge_data(DerivedMesh *source, DerivedMesh *dest, - int source_index, int dest_index, int count) + int source_index, int dest_index, int count) { CustomData_copy_data(&source->edgeData, &dest->edgeData, - source_index, dest_index, count); + source_index, dest_index, count); } void DM_copy_face_data(DerivedMesh *source, DerivedMesh *dest, - int source_index, int dest_index, int count) + int source_index, int dest_index, int count) { CustomData_copy_data(&source->faceData, &dest->faceData, - source_index, dest_index, count); + source_index, dest_index, count); } void DM_free_vert_data(struct DerivedMesh *dm, int index, int count) @@ -388,29 +388,29 @@ void DM_free_face_data(struct DerivedMesh *dm, int index, int count) } void DM_interp_vert_data(DerivedMesh *source, DerivedMesh *dest, - int *src_indices, float *weights, - int count, int dest_index) + int *src_indices, float *weights, + int count, int dest_index) { CustomData_interp(&source->vertData, &dest->vertData, src_indices, - weights, NULL, count, dest_index); + weights, NULL, count, dest_index); } void DM_interp_edge_data(DerivedMesh *source, DerivedMesh *dest, - int *src_indices, - float *weights, EdgeVertWeight *vert_weights, - int count, int dest_index) + int *src_indices, + float *weights, EdgeVertWeight *vert_weights, + int count, int dest_index) { CustomData_interp(&source->edgeData, &dest->edgeData, src_indices, - weights, (float*)vert_weights, count, dest_index); + weights, (float*)vert_weights, count, dest_index); } void DM_interp_face_data(DerivedMesh *source, DerivedMesh *dest, - int *src_indices, - float *weights, FaceVertWeight *vert_weights, - int count, int dest_index) + int *src_indices, + float *weights, FaceVertWeight *vert_weights, + int count, int dest_index) { CustomData_interp(&source->faceData, &dest->faceData, src_indices, - weights, (float*)vert_weights, count, dest_index); + weights, (float*)vert_weights, count, dest_index); } void DM_swap_face_data(DerivedMesh *dm, int index, int *corner_indices) @@ -635,8 +635,8 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, i, &drawSmooth); if(draw) { if (draw==2) { /* enabled with stipple */ - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(stipple_quarttone); + glEnable(GL_POLYGON_STIPPLE); + glPolygonStipple(stipple_quarttone); } glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT); @@ -706,9 +706,9 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us } static void emDM_drawFacesTex_common(DerivedMesh *dm, - int (*drawParams)(MTFace *tface, MCol *mcol, int matnr), - int (*drawParamsMapped)(void *userData, int index), - void *userData) + int (*drawParams)(MTFace *tface, MCol *mcol, int matnr), + int (*drawParamsMapped)(void *userData, int index), + void *userData) { EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; EditMesh *em= emdm->em; @@ -884,8 +884,8 @@ static void emDM_drawMappedFacesTex(DerivedMesh *dm, int (*setDrawOptions)(void } static void emDM_drawMappedFacesGLSL(DerivedMesh *dm, - int (*setMaterial)(int, void *attribs), - int (*setDrawOptions)(void *userData, int index), void *userData) + int (*setMaterial)(int, void *attribs), + int (*setDrawOptions)(void *userData, int index), void *userData) { EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; EditMesh *em= emdm->em; @@ -1034,7 +1034,7 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm, } static void emDM_drawFacesGLSL(DerivedMesh *dm, - int (*setMaterial)(int, void *attribs)) + int (*setMaterial)(int, void *attribs)) { dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL); } @@ -1151,7 +1151,7 @@ static void emDM_getFace(DerivedMesh *dm, int index, MFace *face_r) if(!v4) face_r->v4 = 0; for(i = 0, ev = em->verts.first; v1 || v2 || v3 || v4; - i++, ev = ev->next) { + i++, ev = ev->next) { if(ev == v1) { face_r->v1 = i; v1 = NULL; @@ -1297,12 +1297,12 @@ static void emDM_release(DerivedMesh *dm) } static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob, - float (*vertexCos)[3]) + float (*vertexCos)[3]) { EditMeshDerivedMesh *emdm = MEM_callocN(sizeof(*emdm), "emdm"); DM_init(&emdm->dm, DM_TYPE_EDITMESH, BLI_countlist(&em->verts), - BLI_countlist(&em->edges), BLI_countlist(&em->faces)); + BLI_countlist(&em->edges), BLI_countlist(&em->faces)); emdm->dm.getMinMax = emDM_getMinMax; @@ -1345,7 +1345,7 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob, for(eve = em->verts.first, i = 0; eve; eve = eve->next, ++i) DM_set_vert_data(&emdm->dm, i, CD_MDEFORMVERT, - CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT)); + CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT)); } if(vertexCos) { @@ -1596,9 +1596,9 @@ static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm) * - apply deform modifiers and input vertexco */ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos)[3], - DerivedMesh **deform_r, DerivedMesh **final_r, - int useRenderParams, int useDeform, - int needMapping, CustomDataMask dataMask, int index, int useCache) + DerivedMesh **deform_r, DerivedMesh **final_r, + int useRenderParams, int useDeform, + int needMapping, CustomDataMask dataMask, int index, int useCache) { Mesh *me = ob->data; ModifierData *firstmd, *md; @@ -1716,7 +1716,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos */ numVerts = dm->getNumVerts(dm); deformedVerts = - MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv"); + MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv"); dm->getVertCos(dm, deformedVerts); } else { deformedVerts = mesh_getVertexCos(me, &numVerts); @@ -1891,8 +1891,8 @@ static int editmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedM } static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, DerivedMesh **cage_r, - DerivedMesh **final_r, - CustomDataMask dataMask) + DerivedMesh **final_r, + CustomDataMask dataMask) { ModifierData *md; float (*deformedVerts)[3] = NULL; @@ -1947,7 +1947,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri */ numVerts = dm->getNumVerts(dm); deformedVerts = - MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv"); + MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv"); dm->getVertCos(dm, deformedVerts); } else { deformedVerts = editmesh_getVertexCos(em, &numVerts); @@ -2029,8 +2029,8 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri *cage_r = dm; } else { *cage_r = - getEditMeshDerivedMesh(em, ob, - deformedVerts ? MEM_dupallocN(deformedVerts) : NULL); + getEditMeshDerivedMesh(em, ob, + deformedVerts ? MEM_dupallocN(deformedVerts) : NULL); } } } @@ -2202,7 +2202,7 @@ DerivedMesh *mesh_create_derived_view(Scene *scene, Object *ob, CustomDataMask d } DerivedMesh *mesh_create_derived_no_deform(Scene *scene, Object *ob, float (*vertCos)[3], - CustomDataMask dataMask) + CustomDataMask dataMask) { DerivedMesh *final; @@ -2212,7 +2212,7 @@ DerivedMesh *mesh_create_derived_no_deform(Scene *scene, Object *ob, float (*ver } DerivedMesh *mesh_create_derived_no_virtual(Scene *scene, Object *ob, float (*vertCos)[3], - CustomDataMask dataMask) + CustomDataMask dataMask) { DerivedMesh *final; @@ -2222,8 +2222,8 @@ DerivedMesh *mesh_create_derived_no_virtual(Scene *scene, Object *ob, float (*ve } DerivedMesh *mesh_create_derived_no_deform_render(Scene *scene, Object *ob, - float (*vertCos)[3], - CustomDataMask dataMask) + float (*vertCos)[3], + CustomDataMask dataMask) { DerivedMesh *final; @@ -2235,7 +2235,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(Scene *scene, Object *ob, /***/ DerivedMesh *editmesh_get_derived_cage_and_final(Scene *scene, Object *obedit, EditMesh *em, DerivedMesh **final_r, - CustomDataMask dataMask) + CustomDataMask dataMask) { /* if there's no derived mesh or the last data mask used doesn't include * the data we need, rebuild the derived mesh diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index cf61de195e5..afd0b3a0f57 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -64,13 +64,13 @@ /* *********************** NOTE ON POSE AND ACTION ********************** - Pose is the local (object level) component of armature. The current - object pose is saved in files, and (will be) is presorted for dependency + object pose is saved in files, and (will be) is presorted for dependency - Actions have fewer (or other) channels, and write data to a Pose - Currently ob->pose data is controlled in where_is_pose only. The (recalc) - event system takes care of calling that + event system takes care of calling that - The NLA system (here too) uses Poses as interpolation format for Actions - Therefore we assume poses to be static, and duplicates of poses have channels in - same order, for quick interpolation reasons + same order, for quick interpolation reasons ****************************** (ton) ************************************ */ @@ -1138,17 +1138,17 @@ static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mo bone matching diagram, strips A and B - .------------------------. - | A | - '------------------------' + .------------------------. + | A | + '------------------------' . . b2 - . .-------------v----------. - . | B . | - . '------------------------' - . . . - . . . + . .-------------v----------. + . | B . | + . '------------------------' + . . . + . . . offset: . 0 . A-B . A-b2+B - . . . + . . . */ diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 9eb6c3ad467..b2ac32da138 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -439,7 +439,7 @@ void calc_curvepath(Object *ob) fp= dist+1; maxdist= dist+tot; fac= 1.0f/((float)path->len-1.0f); - fac = fac * path->totdist; + fac = fac * path->totdist; for(a=0; alen; a++) { diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 584f31769ef..a2749a5a457 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -769,7 +769,7 @@ static short animsys_remap_path (AnimMapper *remap, char *path, char **dst) /* Write the given value to a setting using RNA, and return success */ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value) { - // printf("%p %s %i %f\n", ptr, path, array_index, value); + // printf("%p %s %i %f\n", ptr, path, array_index, value); PropertyRNA *prop; PointerRNA new_ptr; @@ -1740,7 +1740,7 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re */ // TODO: need to double check that this all works correctly if ((recalc & ADT_RECALC_ANIM) || (adt->recalc & ADT_RECALC_ANIM)) - { + { /* evaluate NLA data */ if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF)) { diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 387b8a1d5b2..668ce9aadac 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -708,7 +708,7 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion, int re invert_m4_m4(b_bone_mats[0].mat, bone->arm_mat); /* then we make the b_bone_mats: - - first transform to local bone space + - first transform to local bone space - translate over the curve to the bbone mat space - transform with b_bone matrix - transform back into global space */ @@ -905,7 +905,7 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua } void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, - float (*vertexCos)[3], float (*defMats)[3][3], + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts, int deformflag, float (*prevCos)[3], const char *defgrp_name) { @@ -983,9 +983,9 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, if(use_dverts) { defnrToPC = MEM_callocN(sizeof(*defnrToPC) * numGroups, - "defnrToBone"); + "defnrToBone"); for(i = 0, dg = target->defbase.first; dg; - i++, dg = dg->next) { + i++, dg = dg->next) { defnrToPC[i] = get_pose_channel(armOb->pose, dg->name); /* exclude non-deforming bones */ if(defnrToPC[i]) { @@ -1070,10 +1070,10 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, if(bone && bone->flag & BONE_MULT_VG_ENV) { weight *= distfactor_to_bone(co, bone->arm_head, - bone->arm_tail, - bone->rad_head, - bone->rad_tail, - bone->dist); + bone->arm_tail, + bone->rad_head, + bone->rad_tail, + bone->dist); } pchan_bone_deform(pchan, weight, vec, dq, smat, co, &contrib); } @@ -1083,7 +1083,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, */ if(deformed == 0 && use_envelope) { for(pchan = armOb->pose->chanbase.first; pchan; - pchan = pchan->next) { + pchan = pchan->next) { if(!(pchan->bone->flag & BONE_NO_DEFORM)) contrib += dist_bone_deform(pchan, vec, dq, smat, co); } @@ -1091,7 +1091,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, } else if(use_envelope) { for(pchan = armOb->pose->chanbase.first; pchan; - pchan = pchan->next) { + pchan = pchan->next) { if(!(pchan->bone->flag & BONE_NO_DEFORM)) contrib += dist_bone_deform(pchan, vec, dq, smat, co); } @@ -1293,10 +1293,10 @@ void pchan_apply_mat4(bPoseChannel *pchan, float mat[][4]) */ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]) { - float imat[4][4]; + float imat[4][4]; - invert_m4_m4(imat, arm_mat); - mul_m4_m4m4(delta_mat, pose_mat, imat); + invert_m4_m4(imat, arm_mat); + mul_m4_m4m4(delta_mat, pose_mat, imat); } /* **************** Rotation Mode Conversions ****************************** */ @@ -1369,21 +1369,21 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa *************************************************************************** */ /* Computes vector and roll based on a rotation. "mat" must - contain only a rotation, and no scaling. */ + contain only a rotation, and no scaling. */ void mat3_to_vec_roll(float mat[][3], float *vec, float *roll) { - if (vec) - copy_v3_v3(vec, mat[1]); + if (vec) + copy_v3_v3(vec, mat[1]); - if (roll) { - float vecmat[3][3], vecmatinv[3][3], rollmat[3][3]; + if (roll) { + float vecmat[3][3], vecmatinv[3][3], rollmat[3][3]; - vec_roll_to_mat3(mat[1], 0.0f, vecmat); - invert_m3_m3(vecmatinv, vecmat); - mul_m3_m3m3(rollmat, vecmatinv, mat); + vec_roll_to_mat3(mat[1], 0.0f, vecmat); + invert_m3_m3(vecmatinv, vecmat); + mul_m3_m3m3(rollmat, vecmatinv, mat); - *roll= (float)atan2(rollmat[2][0], rollmat[2][2]); - } + *roll= (float)atan2(rollmat[2][0], rollmat[2][2]); + } } /* Calculates the rest matrix of a bone based diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index 5f9b4f11850..5f6a4278549 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -179,7 +179,7 @@ void detectBitmapFont(ImBuf *ibuf) int i; if (ibuf != NULL) { - // bitmap must have an x size that is a power of two + // bitmap must have an x size that is a power of two if (is_power_of_two(ibuf->x)) { rect = (unsigned char *) (ibuf->rect + (ibuf->x * (ibuf->y - 1))); // printf ("starts with: %s %c %c %c %c\n", rect, rect[0], rect[1], rect[2], rect[3]); diff --git a/source/blender/blenkernel/intern/booleanops.c b/source/blender/blenkernel/intern/booleanops.c index 710bbfaf12b..3e43dfbb4d5 100644 --- a/source/blender/blenkernel/intern/booleanops.c +++ b/source/blender/blenkernel/intern/booleanops.c @@ -137,7 +137,7 @@ static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, DerivedMesh it->pos = 0; - // assign iterator function pointers. + // assign iterator function pointers. output->Step = VertexIt_Step; output->Fill = VertexIt_Fill; output->Done = VertexIt_Done; @@ -353,9 +353,9 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( // create a new DerivedMesh result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements); CustomData_merge(&dm1->faceData, &result->faceData, CD_MASK_DERIVEDMESH, - CD_DEFAULT, face_it->num_elements); + CD_DEFAULT, face_it->num_elements); CustomData_merge(&dm2->faceData, &result->faceData, CD_MASK_DERIVEDMESH, - CD_DEFAULT, face_it->num_elements); + CD_DEFAULT, face_it->num_elements); // step through the vertex iterators: for (i = 0; !vertex_it->Done(vertex_it->it); i++) { @@ -422,7 +422,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( mface->mat_nr = 0; InterpCSGFace(result, orig_dm, i, orig_index, csgface.vertex_number, - (orig_me == me2)? mapmat: NULL); + (orig_me == me2)? mapmat: NULL); test_index_face(mface, &result->faceData, i, csgface.vertex_number); } @@ -588,7 +588,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) } DerivedMesh *NewBooleanDerivedMesh(DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, - int int_op_type) + int int_op_type) { return NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, NULL, NULL); } diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 4aaf95e7037..4b8c3a2a0f4 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -678,7 +678,7 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos) short flt; if ((brush->size != cache->lastsize) || (brush->alpha != cache->lastalpha) - || (brush->jitter != cache->lastjitter)) { + || (brush->jitter != cache->lastjitter)) { if (cache->ibuf) { IMB_freeImBuf(cache->ibuf); cache->ibuf= NULL; @@ -938,7 +938,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side) */ if(hasrgb & TEX_RGB) texres.tin = (0.35 * texres.tr + 0.45 * - texres.tg + 0.2 * texres.tb); + texres.tg + 0.2 * texres.tb); texres.tin = texres.tin * 255.0; ((char*)texcache)[(iy*side+ix)*4] = (char)texres.tin; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 65fda678ce0..1b7257519b1 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -210,7 +210,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const } else // Region 0 { - // Minimum at interior lv + // Minimum at interior lv float invDet; if(fabs(Det) > FLT_EPSILON) invDet = 1.0f / Det; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 3a415d6564d..cca554b5880 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -178,7 +178,7 @@ static ListBase *cdDM_getFaceMap(Object *ob, DerivedMesh *dm) Mesh *me= ob->data; create_vert_face_map(&cddm->fmap, &cddm->fmap_mem, me->mface, - me->totvert, me->totface); + me->totvert, me->totface); } return cddm->fmap; @@ -193,7 +193,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) cddm->pbvh = BLI_pbvh_new(); BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert, - me->totface, me->totvert); + me->totface, me->totvert); } return cddm->pbvh; @@ -573,9 +573,9 @@ static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha } static void cdDM_drawFacesTex_common(DerivedMesh *dm, - int (*drawParams)(MTFace *tface, MCol *mcol, int matnr), - int (*drawParamsMapped)(void *userData, int index), - void *userData) + int (*drawParams)(MTFace *tface, MCol *mcol, int matnr), + int (*drawParamsMapped)(void *userData, int index), + void *userData) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; MVert *mv = cddm->mvert; @@ -1272,10 +1272,10 @@ static void cdDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *us } static void cdDM_foreachMappedVert( - DerivedMesh *dm, - void (*func)(void *userData, int index, float *co, - float *no_f, short *no_s), - void *userData) + DerivedMesh *dm, + void (*func)(void *userData, int index, float *co, + float *no_f, short *no_s), + void *userData) { MVert *mv = CDDM_get_verts(dm); int i, orig, *index = DM_get_vert_data_layer(dm, CD_ORIGINDEX); @@ -1292,10 +1292,10 @@ static void cdDM_foreachMappedVert( } static void cdDM_foreachMappedEdge( - DerivedMesh *dm, - void (*func)(void *userData, int index, - float *v0co, float *v1co), - void *userData) + DerivedMesh *dm, + void (*func)(void *userData, int index, + float *v0co, float *v1co), + void *userData) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; MVert *mv = cddm->mvert; @@ -1314,10 +1314,10 @@ static void cdDM_foreachMappedEdge( } static void cdDM_foreachMappedFaceCenter( - DerivedMesh *dm, - void (*func)(void *userData, int index, - float *cent, float *no), - void *userData) + DerivedMesh *dm, + void (*func)(void *userData, int index, + float *cent, float *no), + void *userData) { CDDerivedMesh *cddm = (CDDerivedMesh*)dm; MVert *mv = cddm->mvert; @@ -1466,11 +1466,11 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *ob) alloctype= CD_REFERENCE; CustomData_merge(&mesh->vdata, &dm->vertData, mask, alloctype, - mesh->totvert); + mesh->totvert); CustomData_merge(&mesh->edata, &dm->edgeData, mask, alloctype, - mesh->totedge); + mesh->totedge); CustomData_merge(&mesh->fdata, &dm->faceData, mask, alloctype, - mesh->totface); + mesh->totface); cddm->mvert = CustomData_get_layer(&dm->vertData, CD_MVERT); cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE); @@ -1482,8 +1482,8 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *ob) DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *me) { DerivedMesh *dm = CDDM_new(BLI_countlist(&em->verts), - BLI_countlist(&em->edges), - BLI_countlist(&em->faces)); + BLI_countlist(&em->edges), + BLI_countlist(&em->faces)); CDDerivedMesh *cddm = (CDDerivedMesh*)dm; EditVert *eve; EditEdge *eed; @@ -1496,11 +1496,11 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *me) dm->deformedOnly = 1; CustomData_merge(&em->vdata, &dm->vertData, CD_MASK_DERIVEDMESH, - CD_CALLOC, dm->numVertData); + CD_CALLOC, dm->numVertData); /* CustomData_merge(&em->edata, &dm->edgeData, CD_MASK_DERIVEDMESH, - CD_CALLOC, dm->numEdgeData); */ + CD_CALLOC, dm->numEdgeData); */ CustomData_merge(&em->fdata, &dm->faceData, CD_MASK_DERIVEDMESH, - CD_CALLOC, dm->numFaceData); + CD_CALLOC, dm->numFaceData); /* set eve->hash to vert index */ for(i = 0, eve = em->verts.first; eve; eve = eve->next, ++i) @@ -1519,7 +1519,7 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *me) index = dm->getVertDataArray(dm, CD_ORIGINDEX); for(i = 0, eve = em->verts.first; i < dm->numVertData; - i++, eve = eve->next, index++) { + i++, eve = eve->next, index++) { MVert *mv = &mvert[i]; VECCOPY(mv->co, eve->co); @@ -1539,7 +1539,7 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *me) index = dm->getEdgeDataArray(dm, CD_ORIGINDEX); for(i = 0, eed = em->edges.first; i < dm->numEdgeData; - i++, eed = eed->next, index++) { + i++, eed = eed->next, index++) { MEdge *med = &medge[i]; med->v1 = eed->v1->tmp.l; @@ -1559,7 +1559,7 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *me) index = dm->getFaceDataArray(dm, CD_ORIGINDEX); for(i = 0, efa = em->faces.first; i < dm->numFaceData; - i++, efa = efa->next, index++) { + i++, efa = efa->next, index++) { MFace *mf = &mface[i]; mf->v1 = efa->v1->tmp.l; @@ -1648,7 +1648,7 @@ DerivedMesh *CDDM_copy(DerivedMesh *source) } DerivedMesh *CDDM_from_template(DerivedMesh *source, - int numVerts, int numEdges, int numFaces) + int numVerts, int numEdges, int numFaces) { CDDerivedMesh *cddm = cdDM_create("CDDM_from_template dest"); DerivedMesh *dm = &cddm->dm; @@ -1718,7 +1718,7 @@ void CDDM_calc_normals(DerivedMesh *dm) if(numVerts == 0) return; temp_nors = MEM_callocN(numVerts * sizeof(*temp_nors), - "CDDM_calc_normals temp_nors"); + "CDDM_calc_normals temp_nors"); /* we don't want to overwrite any referenced layers */ mv = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT); @@ -1728,7 +1728,7 @@ void CDDM_calc_normals(DerivedMesh *dm) face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL); if(!face_nors) face_nors = CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_CALLOC, - NULL, dm->numFaceData); + NULL, dm->numFaceData); /* calculate face normals and add to vertex normals */ mf = CDDM_get_faces(dm); @@ -1802,7 +1802,7 @@ void CDDM_calc_edges(DerivedMesh *dm) med = CustomData_get_layer(&edgeData, CD_MEDGE); index = CustomData_get_layer(&edgeData, CD_ORIGINDEX); for(i = 0; !BLI_edgehashIterator_isDone(ehi); - BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { + BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2); med->flag = ME_EDGEDRAW|ME_EDGERENDER; diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index cf41392e24a..33fe6212cd2 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -75,7 +75,7 @@ double tval() static CM_SOLVER_DEF solvers [] = { { "Implicit", CM_IMPLICIT, implicit_init, implicit_solver, implicit_free }, - // { "Implicit C++", CM_IMPLICITCPP, implicitcpp_init, implicitcpp_solver, implicitcpp_free }, + // { "Implicit C++", CM_IMPLICITCPP, implicitcpp_init, implicitcpp_solver, implicitcpp_free }, }; /* ********** cloth engine ******* */ @@ -745,10 +745,10 @@ 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))) + (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))) { for ( i = 0; i < numverts; i++, verts++ ) { @@ -770,7 +770,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) verts->goal = ( float ) pow ( verts->goal , 4.0f ); if ( verts->goal >=SOFTGOALSNAP ) { - verts->flags |= CLOTH_VERT_FLAG_PINNED; + verts->flags |= CLOTH_VERT_FLAG_PINNED; } } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 6410d02603d..4c0c10c127a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -754,10 +754,10 @@ void colorcorrection_do_ibuf(ImBuf *ibuf, const char *profile) cmsErrorAction(LCMS_ERROR_SHOW); hTransform = cmsCreateProofingTransform(imageProfile, TYPE_RGBA_8, imageProfile, TYPE_RGBA_8, - proofingProfile, - INTENT_ABSOLUTE_COLORIMETRIC, - INTENT_ABSOLUTE_COLORIMETRIC, - cmsFLAGS_SOFTPROOFING); + proofingProfile, + INTENT_ABSOLUTE_COLORIMETRIC, + INTENT_ABSOLUTE_COLORIMETRIC, + cmsFLAGS_SOFTPROOFING); cmsDoTransform(hTransform, ibuf->rect, ibuf->crect, ibuf->x * ibuf->y); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 78f1bb4e469..3ab5e9442b4 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3054,7 +3054,7 @@ static void rbj_new_data (void *cdata) bRigidBodyJointConstraint *data= (bRigidBodyJointConstraint *)cdata; // removed code which set target of this constraint - data->type=1; + data->type=1; } static void rbj_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 06921a0b9af..4fed662b6b4 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -569,7 +569,7 @@ static void calcknots(float *knots, short aantal, short order, short type) float k; int a, t; - t = aantal+order; + t = aantal+order; if(type==0) { for(a=0;a knots[opp2]) t= knots[opp2]; /* this part is order '1' */ - o2 = order + 1; + o2 = order + 1; for(i=0;i= knots[i] && t<=knots[i+1]) { basis[i]= 1.0; @@ -1002,18 +1002,18 @@ void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int i f*= it; rt3= (q3-q0+3.0f*(q1-q2))/f; - q0= rt0; + q0= rt0; q1= rt1+rt2+rt3; q2= 2*rt2+6*rt3; q3= 6*rt3; - for(a=0; a<=it; a++) { + for(a=0; a<=it; a++) { *p= q0; p = (float *)(((char *)p)+stride); q0+= q1; - q1+= q2; - q2+= q3; - } + q1+= q2; + q2+= q3; + } } static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float *p3, float *p, int it, int stride) @@ -1023,7 +1023,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float * * This could also be optimized like forward_diff_bezier */ int a; - for(a=0; a<=it; a++) { + for(a=0; a<=it; a++) { float t = (float)a / (float)it; int i; @@ -1032,7 +1032,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float } normalize_v3(p); p = (float *)(((char *)p)+stride); - } + } } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ @@ -1061,7 +1061,7 @@ float *make_orco_surf(Object *ob) sizev = nu->pntsv*nu->resolv; if (nu->flagu & CU_NURB_CYCLIC) sizeu++; if (nu->flagv & CU_NURB_CYCLIC) sizev++; - if(nu->pntsv>1) tot+= sizeu * sizev; + if(nu->pntsv>1) tot+= sizeu * sizev; nu= nu->next; } @@ -1464,7 +1464,7 @@ static short bevelinside(BevList *bl1,BevList *bl2) /* there's a transition, calc intersection point */ mode= cu_isectLL(prevbevp->vec, bevp->vec, hvec1, hvec2, 0, 1, &lab, &mu, vec); /* if lab==0.0 or lab==1.0 then the edge intersects exactly a transition - only allow for one situation: we choose lab= 1.0 + only allow for one situation: we choose lab= 1.0 */ if(mode>=0 && lab!=0.0) { if(vec[0]def_nr = dw->def_nr; tmp_dw->weight = dw->weight * interp_weight; BLI_linklist_prepend(&dest_dw, tmp_dw); @@ -188,7 +188,7 @@ static void layerInterp_mdeformvert(void **sources, float *weights, if(totweight) { dvert->dw = MEM_callocN(sizeof(*dvert->dw) * totweight, - "layerInterp_mdeformvert dvert->dw"); + "layerInterp_mdeformvert dvert->dw"); dvert->totweight = totweight; for(i = 0, node = dest_dw; node; node = node->next, ++i) @@ -202,7 +202,7 @@ static void layerInterp_mdeformvert(void **sources, float *weights, static void layerInterp_msticky(void **sources, float *weights, - float *sub_weights, int count, void *dest) + float *sub_weights, int count, void *dest) { float co[2], w; MSticky *mst; @@ -234,7 +234,7 @@ static void layerCopy_tface(const void *source, void *dest, int count) } static void layerInterp_tface(void **sources, float *weights, - float *sub_weights, int count, void *dest) + float *sub_weights, int count, void *dest) { MTFace *tf = dest; int i, j, k; @@ -278,9 +278,9 @@ static void layerSwap_tface(void *data, int *corner_indices) MTFace *tf = data; float uv[4][2]; static const short pin_flags[4] = - { TF_PIN1, TF_PIN2, TF_PIN3, TF_PIN4 }; + { TF_PIN1, TF_PIN2, TF_PIN3, TF_PIN4 }; static const char sel_flags[4] = - { TF_SEL1, TF_SEL2, TF_SEL3, TF_SEL4 }; + { TF_SEL1, TF_SEL2, TF_SEL3, TF_SEL4 }; short unwrap = tf->unwrap & ~(TF_PIN1 | TF_PIN2 | TF_PIN3 | TF_PIN4); char flag = tf->flag & ~(TF_SEL1 | TF_SEL2 | TF_SEL3 | TF_SEL4); int j; @@ -310,7 +310,7 @@ static void layerSwap_tface(void *data, int *corner_indices) static void layerDefault_tface(void *data, int count) { static MTFace default_tf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, NULL, - 0, 0, TF_DYNAMIC, 0, 0}; + 0, 0, TF_DYNAMIC, 0, 0}; MTFace *tf = (MTFace*)data; int i; @@ -466,7 +466,7 @@ static void layerSwap_mdisps(void *data, int *ci) } static void layerInterp_mdisps(void **sources, float *weights, float *sub_weights, - int count, void *dest) + int count, void *dest) { // XXX #if 0 @@ -680,7 +680,7 @@ static void layerInterp_mloopuv(void **sources, float *weights, } static void layerInterp_mcol(void **sources, float *weights, - float *sub_weights, int count, void *dest) + float *sub_weights, int count, void *dest) { MCol *mc = dest; int i, j, k; @@ -843,7 +843,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, int type, int alloctype, void *layerdata, int totelem, const char *name); void CustomData_merge(const struct CustomData *source, struct CustomData *dest, - CustomDataMask mask, int alloctype, int totelem) + CustomDataMask mask, int alloctype, int totelem) { const LayerTypeInfo *typeInfo; CustomDataLayer *layer, *newlayer; @@ -887,7 +887,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest, } void CustomData_copy(const struct CustomData *source, struct CustomData *dest, - CustomDataMask mask, int alloctype, int totelem) + CustomDataMask mask, int alloctype, int totelem) { memset(dest, 0, sizeof(*dest)); @@ -1142,7 +1142,7 @@ void CustomData_set_layer_flag(struct CustomData *data, int type, int flag) static int customData_resize(CustomData *data, int amount) { CustomDataLayer *tmp = MEM_callocN(sizeof(*tmp)*(data->maxlayer + amount), - "CustomData->layers"); + "CustomData->layers"); if(!tmp) return 0; data->maxlayer += amount; @@ -1230,13 +1230,13 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, } void *CustomData_add_layer(CustomData *data, int type, int alloctype, - void *layerdata, int totelem) + void *layerdata, int totelem) { CustomDataLayer *layer; const LayerTypeInfo *typeInfo= layerType_getInfo(type); layer = customData_add_layer__internal(data, type, alloctype, layerdata, - totelem, typeInfo->defaultname); + totelem, typeInfo->defaultname); if(layer) return layer->data; @@ -1246,12 +1246,12 @@ void *CustomData_add_layer(CustomData *data, int type, int alloctype, /*same as above but accepts a name*/ void *CustomData_add_layer_named(CustomData *data, int type, int alloctype, - void *layerdata, int totelem, char *name) + void *layerdata, int totelem, char *name) { CustomDataLayer *layer; layer = customData_add_layer__internal(data, type, alloctype, layerdata, - totelem, name); + totelem, name); if(layer) return layer->data; @@ -1345,7 +1345,7 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type) } void *CustomData_duplicate_referenced_layer_named(struct CustomData *data, - int type, char *name) + int type, char *name) { CustomDataLayer *layer; int layer_index; @@ -1390,7 +1390,7 @@ void CustomData_free_temporary(CustomData *data, int totelem) } void CustomData_set_only_copy(const struct CustomData *data, - CustomDataMask mask) + CustomDataMask mask) { int i; @@ -1400,7 +1400,7 @@ void CustomData_set_only_copy(const struct CustomData *data, } void CustomData_copy_data(const CustomData *source, CustomData *dest, - int source_index, int dest_index, int count) + int source_index, int dest_index, int count) { const LayerTypeInfo *typeInfo; int src_i, dest_i; @@ -1415,7 +1415,7 @@ void CustomData_copy_data(const CustomData *source, CustomData *dest, * (this should work because layers are ordered by type) */ while(dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + && dest->layers[dest_i].type < source->layers[src_i].type) ++dest_i; /* if there are no more dest layers, we're done */ @@ -1433,12 +1433,12 @@ void CustomData_copy_data(const CustomData *source, CustomData *dest, if(typeInfo->copy) typeInfo->copy(src_data + src_offset, - dest_data + dest_offset, - count); + dest_data + dest_offset, + count); else memcpy(dest_data + dest_offset, - src_data + src_offset, - count * typeInfo->size); + src_data + src_offset, + count * typeInfo->size); /* if there are multiple source & dest layers of the same type, * we don't want to copy all source layers to the same dest, so @@ -1462,7 +1462,7 @@ void CustomData_free_elem(CustomData *data, int index, int count) int offset = typeInfo->size * index; typeInfo->free((char *)data->layers[i].data + offset, - count, typeInfo->size); + count, typeInfo->size); } } } @@ -1471,8 +1471,8 @@ void CustomData_free_elem(CustomData *data, int index, int count) #define SOURCE_BUF_SIZE 100 void CustomData_interp(const CustomData *source, CustomData *dest, - int *src_indices, float *weights, float *sub_weights, - int count, int dest_index) + int *src_indices, float *weights, float *sub_weights, + int count, int dest_index) { int src_i, dest_i; int dest_offset; @@ -1485,7 +1485,7 @@ void CustomData_interp(const CustomData *source, CustomData *dest, */ if(count > SOURCE_BUF_SIZE) sources = MEM_callocN(sizeof(*sources) * count, - "CustomData_interp sources"); + "CustomData_interp sources"); /* interpolates a layer at a time */ dest_i = 0; @@ -1497,7 +1497,7 @@ void CustomData_interp(const CustomData *source, CustomData *dest, * (this should work because layers are ordered by type) */ while(dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + && dest->layers[dest_i].type < source->layers[src_i].type) ++dest_i; /* if there are no more dest layers, we're done */ @@ -1577,7 +1577,7 @@ void *CustomData_get_layer_n(const CustomData *data, int type, int n) } void *CustomData_get_layer_named(const struct CustomData *data, int type, - char *name) + char *name) { int layer_index = CustomData_get_named_layer_index(data, type, name); if(layer_index < 0) return NULL; @@ -1625,21 +1625,21 @@ void CustomData_set(const CustomData *data, int index, int type, void *source) void CustomData_em_free_block(CustomData *data, void **block) { - const LayerTypeInfo *typeInfo; - int i; + const LayerTypeInfo *typeInfo; + int i; if(!*block) return; - for(i = 0; i < data->totlayer; ++i) { - if(!(data->layers[i].flag & CD_FLAG_NOFREE)) { - typeInfo = layerType_getInfo(data->layers[i].type); + for(i = 0; i < data->totlayer; ++i) { + if(!(data->layers[i].flag & CD_FLAG_NOFREE)) { + typeInfo = layerType_getInfo(data->layers[i].type); - if(typeInfo->free) { + if(typeInfo->free) { int offset = data->layers[i].offset; - typeInfo->free((char*)*block + offset, 1, typeInfo->size); + typeInfo->free((char*)*block + offset, 1, typeInfo->size); } - } - } + } + } MEM_freeN(*block); *block = NULL; @@ -1659,7 +1659,7 @@ static void CustomData_em_alloc_block(CustomData *data, void **block) } void CustomData_em_copy_data(const CustomData *source, CustomData *dest, - void *src_block, void **dest_block) + void *src_block, void **dest_block) { const LayerTypeInfo *typeInfo; int dest_i, src_i; @@ -1675,7 +1675,7 @@ void CustomData_em_copy_data(const CustomData *source, CustomData *dest, * (this should work because layers are ordered by type) */ while(dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + && dest->layers[dest_i].type < source->layers[src_i].type) ++dest_i; /* if there are no more dest layers, we're done */ @@ -1752,7 +1752,7 @@ void CustomData_em_set_n(CustomData *data, void *block, int type, int n, void *s } void CustomData_em_interp(CustomData *data, void **src_blocks, float *weights, - float *sub_weights, int count, void *dest_block) + float *sub_weights, int count, void *dest_block) { int i, j; void *source_buf[SOURCE_BUF_SIZE]; @@ -1763,7 +1763,7 @@ void CustomData_em_interp(CustomData *data, void **src_blocks, float *weights, */ if(count > SOURCE_BUF_SIZE) sources = MEM_callocN(sizeof(*sources) * count, - "CustomData_interp sources"); + "CustomData_interp sources"); /* interpolates a layer at a time */ for(i = 0; i < data->totlayer; ++i) { @@ -1775,7 +1775,7 @@ void CustomData_em_interp(CustomData *data, void **src_blocks, float *weights, sources[j] = (char *)src_blocks[j] + layer->offset; typeInfo->interp(sources, weights, sub_weights, count, - (char *)dest_block + layer->offset); + (char *)dest_block + layer->offset); } } @@ -1801,7 +1801,7 @@ void CustomData_em_set_default(CustomData *data, void **block) } void CustomData_to_em_block(const CustomData *source, CustomData *dest, - int src_index, void **dest_block) + int src_index, void **dest_block) { const LayerTypeInfo *typeInfo; int dest_i, src_i, src_offset; @@ -1817,7 +1817,7 @@ void CustomData_to_em_block(const CustomData *source, CustomData *dest, * (this should work because layers are ordered by type) */ while(dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + && dest->layers[dest_i].type < source->layers[src_i].type) ++dest_i; /* if there are no more dest layers, we're done */ @@ -1847,7 +1847,7 @@ void CustomData_to_em_block(const CustomData *source, CustomData *dest, } void CustomData_from_em_block(const CustomData *source, CustomData *dest, - void *src_block, int dest_index) + void *src_block, int dest_index) { const LayerTypeInfo *typeInfo; int dest_i, src_i, dest_offset; @@ -1860,7 +1860,7 @@ void CustomData_from_em_block(const CustomData *source, CustomData *dest, * (this should work because layers are ordered by type) */ while(dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + && dest->layers[dest_i].type < source->layers[src_i].type) ++dest_i; /* if there are no more dest layers, we're done */ @@ -1923,20 +1923,20 @@ void CustomData_bmesh_init_pool(CustomData *data, int allocsize){ void CustomData_bmesh_free_block(CustomData *data, void **block) { - const LayerTypeInfo *typeInfo; - int i; + const LayerTypeInfo *typeInfo; + int i; if(!*block) return; - for(i = 0; i < data->totlayer; ++i) { - if(!(data->layers[i].flag & CD_FLAG_NOFREE)) { - typeInfo = layerType_getInfo(data->layers[i].type); + for(i = 0; i < data->totlayer; ++i) { + if(!(data->layers[i].flag & CD_FLAG_NOFREE)) { + typeInfo = layerType_getInfo(data->layers[i].type); - if(typeInfo->free) { + if(typeInfo->free) { int offset = data->layers[i].offset; typeInfo->free((char*)*block + offset, 1, typeInfo->size); } - } - } + } + } BLI_mempool_free(data->pool, *block); *block = NULL; @@ -1955,7 +1955,7 @@ static void CustomData_bmesh_alloc_block(CustomData *data, void **block) } void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest, - void *src_block, void **dest_block) + void *src_block, void **dest_block) { const LayerTypeInfo *typeInfo; int dest_i, src_i; @@ -1971,7 +1971,7 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest, * (this should work because layers are ordered by type) */ while(dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + && dest->layers[dest_i].type < source->layers[src_i].type) ++dest_i; /* if there are no more dest layers, we're done */ @@ -2049,7 +2049,7 @@ void CustomData_bmesh_set_n(CustomData *data, void *block, int type, int n, void } void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights, - float *sub_weights, int count, void *dest_block) + float *sub_weights, int count, void *dest_block) { int i, j; void *source_buf[SOURCE_BUF_SIZE]; @@ -2060,7 +2060,7 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights */ if(count > SOURCE_BUF_SIZE) sources = MEM_callocN(sizeof(*sources) * count, - "CustomData_interp sources"); + "CustomData_interp sources"); /* interpolates a layer at a time */ for(i = 0; i < data->totlayer; ++i) { @@ -2071,7 +2071,7 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights sources[j] = (char *)src_blocks[j] + layer->offset; typeInfo->interp(sources, weights, sub_weights, count, - (char *)dest_block + layer->offset); + (char *)dest_block + layer->offset); } } @@ -2097,7 +2097,7 @@ void CustomData_bmesh_set_default(CustomData *data, void **block) } void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest, - int src_index, void **dest_block) + int src_index, void **dest_block) { const LayerTypeInfo *typeInfo; int dest_i, src_i, src_offset; @@ -2113,7 +2113,7 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest, * (this should work because layers are ordered by type) */ while(dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + && dest->layers[dest_i].type < source->layers[src_i].type) ++dest_i; /* if there are no more dest layers, we're done */ @@ -2143,7 +2143,7 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest, } void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest, - void *src_block, int dest_index) + void *src_block, int dest_index) { const LayerTypeInfo *typeInfo; int dest_i, src_i, dest_offset; @@ -2156,7 +2156,7 @@ void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest, * (this should work because layers are ordered by type) */ while(dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + && dest->layers[dest_i].type < source->layers[src_i].type) ++dest_i; /* if there are no more dest layers, we're done */ @@ -2296,8 +2296,8 @@ int CustomData_verify_versions(struct CustomData *data, int index) } if (!keeplayer) { - for (i=index+1; i < data->totlayer; ++i) - data->layers[i-1] = data->layers[i]; + for (i=index+1; i < data->totlayer; ++i) + data->layers[i-1] = data->layers[i]; data->totlayer--; } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 397a0526160..4e0270315ad 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -951,7 +951,7 @@ static void dag_node_print_dependency_cycle(DagForest *dag, DagNode *startnode, { DagNode *node; - for(node = dag->DagNode.first; node; node= node->next) + for(node = dag->DagNode.first; node; node= node->next) node->color= DAG_WHITE; printf(" %s depends on %s through %s.\n", dag_node_name(endnode), dag_node_name(startnode), name); @@ -1533,7 +1533,7 @@ int is_acyclic( DagForest *dag) { void set_node_xy(DagNode *node, float x, float y) { - node->x = x; + node->x = x; node->y = y; } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index ed7d11872c1..8619b6ec87d 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -490,7 +490,7 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un float *orco, *vnors, *nors, imat[3][3], mat[4][4], vec[3]; int a, i, need_orco, totface, totvert; CustomDataMask dataMask = CD_MASK_BAREMESH | CD_MASK_MCOL - | CD_MASK_MTFACE | CD_MASK_NORMAL; + | CD_MASK_MTFACE | CD_MASK_NORMAL; init_fastshade_for_ob(re, ob, &need_orco, mat, imat); @@ -1784,9 +1784,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if(cu->flag & CU_PATH) calc_curvepath(ob); - if (!forRender) { - tex_space_curve(cu); - } + if (!forRender) { + tex_space_curve(cu); + } if(!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 14375c23d57..66e7f805f50 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -955,15 +955,15 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * } /* -------- pdDoEffectors() -------- - generic force/speed system, now used for particles and softbodies - scene = scene where it runs in, for time and stuff + generic force/speed system, now used for particles and softbodies + scene = scene where it runs in, for time and stuff lb = listbase with objects that take part in effecting opco = global coord, as input - force = force accumulator - speed = actual current speed which can be altered + force = force accumulator + speed = actual current speed which can be altered cur_time = "external" time in frames, is constant for static particles loc_time = "local" time in frames, range <0-1> for the lifetime of particle - par_layer = layer the caller is in + par_layer = layer the caller is in flags = only used for softbody wind now guide = old speed of particle diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 772a589f520..91c5a633ff6 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -129,19 +129,19 @@ static int is_stl(char *str) #define READSTLVERT { \ if (fread(mvert->co, sizeof(float), 3, fpSTL) != 3) { \ - char error_msg[255]; \ - MEM_freeN(vertdata); \ - MEM_freeN(facedata); \ - fclose(fpSTL); \ - sprintf(error_msg, "Problems reading face %d!", i); \ - return; \ + char error_msg[255]; \ + MEM_freeN(vertdata); \ + MEM_freeN(facedata); \ + fclose(fpSTL); \ + sprintf(error_msg, "Problems reading face %d!", i); \ + return; \ } \ else { \ - if (ENDIAN_ORDER==B_ENDIAN) { \ - SWITCH_INT(mvert->co[0]); \ - SWITCH_INT(mvert->co[1]); \ - SWITCH_INT(mvert->co[2]); \ - } \ + if (ENDIAN_ORDER==B_ENDIAN) { \ + SWITCH_INT(mvert->co[0]); \ + SWITCH_INT(mvert->co[1]); \ + SWITCH_INT(mvert->co[2]); \ + } \ } \ } @@ -267,9 +267,9 @@ static void read_stl_mesh_binary(Scene *scene, char *str) me->totvert = totvert; me->totface = totface; me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, - vertdata, totvert); + vertdata, totvert); me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, - facedata, totface); + facedata, totface); mesh_add_normals_flags(me); make_edges(me, 0); @@ -410,9 +410,9 @@ static void read_stl_mesh_ascii(Scene *scene, char *str) me->totface = totface; me->totvert = totvert; me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, - NULL, totvert); + NULL, totvert); me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, - NULL, totface); + NULL, totface); /* Copy vert coords and create topology */ mvert = me->mvert; @@ -862,7 +862,7 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb) /* count the nr of lines */ tot= 0; index= iv->data[0]; - lll = iv->datalen[0]-1; + lll = iv->datalen[0]-1; for(a=0; adata[0]; - lll = iv->datalen[0]-2; + lll = iv->datalen[0]-2; for(a=0; adata[0]; - lll=iv->datalen[0]-2; + lll=iv->datalen[0]-2; for(a=0; adata[0]; idata= dl->index; - lll=iv->datalen[0]-2; + lll=iv->datalen[0]-2; for(a=lll; a>0; a--) { if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) { @@ -1476,9 +1476,9 @@ static void displist_to_mesh(Scene *scene, DispList *dlfirst) me->totvert= totvert; me->totface= totface; me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, - NULL, me->totvert); + NULL, me->totvert); me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, - NULL, me->totface); + NULL, me->totface); maxvertidx= totvert-1; mvert= me->mvert; @@ -1956,8 +1956,8 @@ void write_stl(Scene *scene, char *str) fseek(fpSTL, 80, SEEK_SET); if (ENDIAN_ORDER==B_ENDIAN) { - SWITCH_INT(numfacets); - } + SWITCH_INT(numfacets); + } fwrite(&numfacets, 4*sizeof(char), 1, fpSTL); fclose(fpSTL); @@ -2574,13 +2574,13 @@ void write_dxf(struct Scene *scene, char *str) /* The header part of the DXF */ write_group(0, "SECTION"); - write_group(2, "HEADER"); + write_group(2, "HEADER"); write_group(0, "ENDSEC"); /* The blocks part of the DXF */ write_group(0, "SECTION"); - write_group(2, "BLOCKS"); + write_group(2, "BLOCKS"); /* only write meshes we're using in this scene */ @@ -2604,7 +2604,7 @@ void write_dxf(struct Scene *scene, char *str) /* The entities part of the DXF */ write_group(0, "SECTION"); - write_group(2, "ENTITIES"); + write_group(2, "ENTITIES"); /* Write all the mesh objects */ base= scene->base.first; @@ -3056,7 +3056,7 @@ static void dxf_read_line(Scene *scene, int noob) { hasbumped=1; } - /* 2D Polyline state vars */ + /* 2D Polyline state vars */ static Object *p2dhold=NULL; static Mesh *p2dmhold=NULL; static char oldplay[32]; @@ -3131,35 +3131,35 @@ static void dxf_read_ellipse(Scene *scene, int noob) read_group(id, val); while(id!=0) { if (id==8) { - BLI_strncpy(layname, val, sizeof(layname)); + BLI_strncpy(layname, val, sizeof(layname)); } else if (id==10) { - center[0]= (float) atof(val); + center[0]= (float) atof(val); } else if (id==20) { - center[1]= (float) atof(val); + center[1]= (float) atof(val); } else if (id==30) { - center[2]= (float) atof(val); + center[2]= (float) atof(val); } else if (id==11) { - axis_endpoint[0]= (float) atof(val); + axis_endpoint[0]= (float) atof(val); } else if (id==21) { - axis_endpoint[1]= (float) atof(val); + axis_endpoint[1]= (float) atof(val); } else if (id==31) { - axis_endpoint[2]= (float) atof(val); + axis_endpoint[2]= (float) atof(val); } else if (id==40) { - axis_ratio = (float) atof(val); + axis_ratio = (float) atof(val); } else if (id==41) { printf("dxf: start = %f", atof(val) * 180/M_PI); - start_angle = -atof(val) + M_PI_2; + start_angle = -atof(val) + M_PI_2; } else if (id==42) { printf("dxf: end = %f", atof(val) * 180/M_PI); end_angle = -atof(val) + M_PI_2; } else if (id==62) { - int colorid= atoi(val); - CLAMP(colorid, 1, 255); - dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); + int colorid= atoi(val); + CLAMP(colorid, 1, 255); + dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); } else if (id==67) { - vspace= atoi(val); + vspace= atoi(val); } else if (id==100) { - isArc = 1; + isArc = 1; } else if (id==210) { extrusion[0] = atof(val); } else if (id==220) { @@ -3290,28 +3290,28 @@ static void dxf_read_arc(Scene *scene, int noob) read_group(id, val); while(id!=0) { if (id==8) { - BLI_strncpy(layname, val, sizeof(layname)); + BLI_strncpy(layname, val, sizeof(layname)); } else if (id==10) { - center[0]= (float) atof(val); + center[0]= (float) atof(val); } else if (id==20) { - center[1]= (float) atof(val); + center[1]= (float) atof(val); } else if (id==30) { - center[2]= (float) atof(val); + center[2]= (float) atof(val); } else if (id==40) { - dia = (float) atof(val); + dia = (float) atof(val); } else if (id==62) { - int colorid= atoi(val); + int colorid= atoi(val); - CLAMP(colorid, 1, 255); - dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); + CLAMP(colorid, 1, 255); + dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); } else if (id==67) { - vspace= atoi(val); + vspace= atoi(val); } else if (id==100) { - isArc = 1; + isArc = 1; } else if (id==50) { - start_angle = (90 - atoi(val)) * M_PI/180.0; + start_angle = (90 - atoi(val)) * M_PI/180.0; } else if (id==51) { - end_angle = (90 - atoi(val)) * M_PI/180.0; + end_angle = (90 - atoi(val)) * M_PI/180.0; } else if (id==210) { extrusion[0] = atof(val); } else if (id==220) { diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 22eb0578f72..fe0f52e9b00 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -609,9 +609,9 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], //------------------------------------------------------------------------------- void initElbeemMesh(struct Scene *scene, struct Object *ob, - int *numVertices, float **vertices, - int *numTriangles, int **triangles, - int useGlobalCoords, int modifierIndex) + int *numVertices, float **vertices, + int *numTriangles, int **triangles, + int useGlobalCoords, int modifierIndex) { DerivedMesh *dm = NULL; MVert *mvert; diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 6c73a3ae64c..d4a5b5b2531 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -305,10 +305,10 @@ static void fcm_fn_generator_new_data (void *mdata) */ static double sinc (double x) { - if (fabs(x) < 0.0001) - return 1.0; - else - return sin(M_PI * x) / (M_PI * x); + if (fabs(x) < 0.0001) + return 1.0; + else + return sin(M_PI * x) / (M_PI * x); } static void fcm_fn_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime) diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 1ca39bbaac4..9b8c05ac88c 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -160,7 +160,7 @@ According to RFC 3629 "UTF-8, a transformation format of ISO 10646" (http://tools.ietf.org/html/rfc3629), the valid UTF-8 encoding are: Char. number range | UTF-8 octet sequence - (hexadecimal) | (binary) + (hexadecimal) | (binary) --------------------+--------------------------------------------- 0000 0000-0000 007F | 0xxxxxxx 0000 0080-0000 07FF | 110xxxxx 10xxxxxx @@ -202,7 +202,7 @@ int utf8towchar(wchar_t *w, char *c) *w = '?'; } } else - *w=(c[0] & 0x7f); + *w=(c[0] & 0x7f); c++; w++; @@ -832,8 +832,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) linedata4[lnr]= wsnr; if ( (tb->h != 0.0) && - ((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize))) && - (cu->totbox > (curbox+1)) ) { + ((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize))) && + (cu->totbox > (curbox+1)) ) { maxlen= 0; tb++; curbox++; @@ -927,13 +927,13 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) ct++; } } else if((cu->spacemode==CU_FLUSH) && - (cu->tb[0].w != 0.0)) { + (cu->tb[0].w != 0.0)) { for(i=0;i1) linedata[i]= (linedata3[i]-linedata[i])/(linedata2[i]-1); for (i=0; i<=slen; i++) { for (j=i; (mem[j]) && (mem[j]!='\n') && - (mem[j]!='\r') && (chartransdata[j].dobreak==0) && (jxof+= ct->charnr*linedata[ct->linenr]; // } @@ -944,10 +944,10 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) float curofs= 0.0f; for (i=0; i<=slen; i++) { for (j=i; (mem[j]) && (mem[j]!='\n') && - (mem[j]!='\r') && (chartransdata[j].dobreak==0) && (jlinenr]-linedata[ct->linenr])/linedata4[ct->linenr]; + ((chartransdata[j].dobreak!=0))) { + if (mem[i]==' ') curofs += (linedata3[ct->linenr]-linedata[ct->linenr])/linedata4[ct->linenr]; ct->xof+= curofs; } if (mem[i]=='\n' || mem[i]=='\r' || chartransdata[i].dobreak) curofs= 0; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 7981c66d2f6..98b3522059c 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -289,12 +289,12 @@ IDProperty *IDP_CopyArray(IDProperty *prop) /*taken from readfile.c*/ #define SWITCH_LONGINT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ - s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ - s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } + char s_i, *p_i; \ + p_i= (char *)&(a); \ + s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ + s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ + s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ + s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 85f15094740..1a3c53e293f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -446,16 +446,16 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, int floatbuf, sho strcpy(ibuf->name, "//Untitled"); ibuf->userflags |= IB_BITMAPDIRTY; - switch(uvtestgrid) { - case 1: - BKE_image_buf_fill_checker(rect, rect_float, width, height); - break; - case 2: - BKE_image_buf_fill_checker_color(rect, rect_float, width, height); - break; - default: - BKE_image_buf_fill_color(rect, rect_float, width, height, color); - } + switch(uvtestgrid) { + case 1: + BKE_image_buf_fill_checker(rect, rect_float, width, height); + break; + case 2: + BKE_image_buf_fill_checker_color(rect, rect_float, width, height); + break; + default: + BKE_image_buf_fill_color(rect, rect_float, width, height, color); + } return ibuf; } diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 2c4851b1835..eb256e3775b 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -73,8 +73,8 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt int checkerwidth= 32, dark= 1; int x, y; - unsigned char *rect_orig= rect; - float *rect_float_orig= rect_float; + unsigned char *rect_orig= rect; + float *rect_float_orig= rect_float; float h=0.0, hoffs=0.0, hue=0.0, s=0.9, v=0.9, r, g, b; @@ -109,8 +109,8 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt } } - rect= rect_orig; - rect_float= rect_float_orig; + rect= rect_orig; + rect_float= rect_float_orig; /* 2nd pass, colored + */ for(y= 0; yed->seqbasep->first; - seq; seq = seq->next) { + seq; seq = seq->next) { short adrcode = SEQ_FAC1; if (G.f & G_DEBUG) diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 9c78742ada0..31b0a809ebe 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -178,11 +178,11 @@ Key *copy_key(Key *key) void make_local_key(Key *key) { - /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ - if(key==0) return; + /* - only lib users: do nothing + * - only local users: set flag + * - mixed: make copy + */ + if(key==0) return; key->id.lib= 0; new_id(0, (ID *)key, 0); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 347fd01299f..b7003f45626 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -714,7 +714,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh /* find the group (weak loop-in-loop) */ for(index = 0, curdef = target->defbase.first; curdef; - curdef = curdef->next, index++) + curdef = curdef->next, index++) if (!strcmp(curdef->name, vgroup)) break; @@ -746,7 +746,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh VECCOPY(vec, vertexCos[a]); calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, - dvert->dw[j].weight); + dvert->dw[j].weight); mul_m4_v3(cd.objectspace, vertexCos[a]); break; } @@ -804,7 +804,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco } void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts, char *vgroup) + float (*vertexCos)[3], int numVerts, char *vgroup) { int a; int use_vgroups; @@ -834,7 +834,7 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, /* find the group (weak loop-in-loop) */ for(curdef = target->defbase.first; curdef; - curdef = curdef->next, index++) + curdef = curdef->next, index++) if(!strcmp(curdef->name, vgroup)) break; if(curdef && (me->dvert || dm)) { @@ -865,7 +865,7 @@ int object_deform_mball(Object *ob) for (dl=ob->disp.first; dl; dl=dl->next) { lattice_deform_verts(ob->parent, ob, NULL, - (float(*)[3]) dl->verts, dl->nr, NULL); + (float(*)[3]) dl->verts, dl->nr, NULL); } return 1; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 91e53742fea..bea641d2140 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -598,10 +598,10 @@ static ID *alloc_libblock_notest(short type) break; case ID_PA: id = MEM_callocN(sizeof(ParticleSettings), "ParticleSettings"); - break; + break; case ID_WM: id = MEM_callocN(sizeof(wmWindowManager), "Window manager"); - break; + break; case ID_GD: id = MEM_callocN(sizeof(bGPdata), "Grease Pencil"); break; @@ -682,7 +682,7 @@ void *copy_libblock(void *rt) static void free_library(Library *lib) { - /* no freeing needed for libraries yet */ + /* no freeing needed for libraries yet */ } static void (*free_windowmanager_cb)(bContext *, wmWindowManager *)= NULL; @@ -1362,17 +1362,17 @@ void text_idbutton(struct ID *id, char *text) if(id) { if(GS(id->name)==ID_SCE) strcpy(text, "SCE: "); - else if(GS(id->name)==ID_SCE) + else if(GS(id->name)==ID_SCE) strcpy(text, "SCR: "); - else if(GS(id->name)==ID_MA && ((Material*)id)->use_nodes) + else if(GS(id->name)==ID_MA && ((Material*)id)->use_nodes) strcpy(text, "NT: "); - else { + else { text[0]= id->name[0]; text[1]= id->name[1]; text[2]= ':'; text[3]= ' '; text[4]= 0; - } + } } else strcpy(text, ""); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 2a2d73ca6a0..e877abea7cf 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -244,9 +244,9 @@ void make_local_material(Material *ma) int a, local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(ma->id.lib==0) return; if(ma->id.us==1) { @@ -1064,15 +1064,15 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) } break; case MA_RAMP_DARK: - tmp=col[0]+((1-col[0])*facm); - if(tmp < *r) *r= tmp; - if(g) { - tmp=col[1]+((1-col[1])*facm); - if(tmp < *g) *g= tmp; - tmp=col[2]+((1-col[2])*facm); - if(tmp < *b) *b= tmp; - } - break; + tmp=col[0]+((1-col[0])*facm); + if(tmp < *r) *r= tmp; + if(g) { + tmp=col[1]+((1-col[1])*facm); + if(tmp < *g) *g= tmp; + tmp=col[2]+((1-col[2])*facm); + if(tmp < *b) *b= tmp; + } + break; case MA_RAMP_LIGHT: tmp= fac*col[0]; if(tmp > *r) *r= tmp; @@ -1124,7 +1124,7 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) if(tmp <= 0.0f) *r = 0.0f; else if (( tmp = (1.0f - (1.0f - (*r)) / tmp )) < 0.0f) - *r = 0.0f; + *r = 0.0f; else if (tmp > 1.0f) *r=1.0f; else @@ -1135,17 +1135,17 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) if(tmp <= 0.0f) *g = 0.0f; else if (( tmp = (1.0f - (1.0f - (*g)) / tmp )) < 0.0f ) - *g = 0.0f; + *g = 0.0f; else if(tmp >1.0f) *g=1.0f; else *g = tmp; - tmp = facm + fac*col[2]; - if(tmp <= 0.0f) + tmp = facm + fac*col[2]; + if(tmp <= 0.0f) *b = 0.0f; else if (( tmp = (1.0f - (1.0f - (*b)) / tmp )) < 0.0f ) - *b = 0.0f; + *b = 0.0f; else if(tmp >1.0f) *b= 1.0f; else @@ -1202,36 +1202,36 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) } } break; - case MA_RAMP_SOFT: - if (g){ - float scr, scg, scb; + case MA_RAMP_SOFT: + if (g){ + float scr, scg, scb; - /* first calculate non-fac based Screen mix */ - scr = 1.0f - (1.0f - col[0]) * (1.0f - *r); - scg = 1.0f - (1.0f - col[1]) * (1.0f - *g); - scb = 1.0f - (1.0f - col[2]) * (1.0f - *b); + /* first calculate non-fac based Screen mix */ + scr = 1.0f - (1.0f - col[0]) * (1.0f - *r); + scg = 1.0f - (1.0f - col[1]) * (1.0f - *g); + scb = 1.0f - (1.0f - col[2]) * (1.0f - *b); - *r = facm*(*r) + fac*(((1.0f - *r) * col[0] * (*r)) + (*r * scr)); - *g = facm*(*g) + fac*(((1.0f - *g) * col[1] * (*g)) + (*g * scg)); - *b = facm*(*b) + fac*(((1.0f - *b) * col[2] * (*b)) + (*b * scb)); - } - break; - case MA_RAMP_LINEAR: - if (col[0] > 0.5f) - *r = *r + fac*(2.0f*(col[0]-0.5f)); - else - *r = *r + fac*(2.0f*(col[0]) - 1.0f); - if (g){ - if (col[1] > 0.5f) - *g = *g + fac*(2.0f*(col[1]-0.5f)); - else - *g = *g + fac*(2.0f*(col[1]) -1.0f); - if (col[2] > 0.5f) - *b = *b + fac*(2.0f*(col[2]-0.5f)); - else - *b = *b + fac*(2.0f*(col[2]) - 1.0f); - } - break; + *r = facm*(*r) + fac*(((1.0f - *r) * col[0] * (*r)) + (*r * scr)); + *g = facm*(*g) + fac*(((1.0f - *g) * col[1] * (*g)) + (*g * scg)); + *b = facm*(*b) + fac*(((1.0f - *b) * col[2] * (*b)) + (*b * scb)); + } + break; + case MA_RAMP_LINEAR: + if (col[0] > 0.5f) + *r = *r + fac*(2.0f*(col[0]-0.5f)); + else + *r = *r + fac*(2.0f*(col[0]) - 1.0f); + if (g){ + if (col[1] > 0.5f) + *g = *g + fac*(2.0f*(col[1]-0.5f)); + else + *g = *g + fac*(2.0f*(col[1]) -1.0f); + if (col[2] > 0.5f) + *b = *b + fac*(2.0f*(col[2]-0.5f)); + else + *b = *b + fac*(2.0f*(col[2]) - 1.0f); + } + break; } } diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index d65870b71ce..98578312766 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -686,7 +686,7 @@ void *new_pgn_element(int size) if(cur) { if(size+offs < blocksize) { adr= (void *) (cur->data+offs); - offs+= size; + offs+= size; return adr; } } @@ -1091,7 +1091,7 @@ int getedge (EDGELIST *table[], q = table[HASH(i1, j1, k1)+HASH(i2, j2, k2)]; for (; q != NULL; q = q->next) if (q->i1 == i1 && q->j1 == j1 && q->k1 == k1 && - q->i2 == i2 && q->j2 == j2 && q->k2 == k2) + q->i2 == i2 && q->j2 == j2 && q->k2 == k2) return q->vid; return -1; } @@ -1240,7 +1240,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, p->z = neg.z; return; } - if((dx == 0.0f) && (dz == 0.0f)){ + if((dx == 0.0f) && (dz == 0.0f)){ p->x = neg.x; p->y = neg.y - negative*dy/(positive-negative); p->z = neg.z; @@ -1272,7 +1272,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, p->y = 0.5f*(pos.y + neg.y); if ((function(p->x,p->y,p->z)) > 0.0) pos.y = p->y; else neg.y = p->y; } - } + } if((dx == 0.0f) && (dy == 0.0f)){ p->x = neg.x; @@ -1580,7 +1580,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ if(ml->s > 10.0) ml->s = 10.0; /* Rotation of MetaElem is stored in quat */ - quat_to_mat4( temp3,ml->quat); + quat_to_mat4( temp3,ml->quat); /* Translation of MetaElem */ unit_m4(temp2); @@ -2120,8 +2120,8 @@ void metaball_polygonize(Scene *scene, Object *ob) /* don't polygonize metaballs with too high resolution (base mball to small) */ if(metaball_tree) { if(ob->size[0]<=0.0001f*(metaball_tree->first->x_max - metaball_tree->first->x_min) || - ob->size[1]<=0.0001f*(metaball_tree->first->y_max - metaball_tree->first->y_min) || - ob->size[2]<=0.0001f*(metaball_tree->first->z_max - metaball_tree->first->z_min)) + ob->size[1]<=0.0001f*(metaball_tree->first->y_max - metaball_tree->first->y_min) || + ob->size[2]<=0.0001f*(metaball_tree->first->z_max - metaball_tree->first->z_min)) { MEM_freeN(mainb); return; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 15f9fc4ac11..543895a5973 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -108,7 +108,7 @@ void unlink_mesh(Mesh *me) } if(me->key) { - me->key->id.us--; + me->key->id.us--; if (me->key->id.us == 0 && me->key->ipo ) me->key->ipo->id.us--; } @@ -274,9 +274,9 @@ void make_local_mesh(Mesh *me) int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(me->id.lib==0) return; if(me->id.us==1) { diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 7eb967aeb09..ad1fb80801f 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -204,7 +204,7 @@ static int curveModifier_isDisabled(ModifierData *md, int userRenderParams) } static void curveModifier_foreachObjectLink( - ModifierData *md, Object *ob, + ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { @@ -215,7 +215,7 @@ static void curveModifier_foreachObjectLink( static void curveModifier_updateDepgraph( ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) + Object *ob, DagNode *obNode) { CurveModifierData *cmd = (CurveModifierData*) md; @@ -228,7 +228,7 @@ static void curveModifier_updateDepgraph( } static void curveModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, + ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { CurveModifierData *cmd = (CurveModifierData*) md; @@ -239,7 +239,7 @@ static void curveModifier_deformVerts( static void curveModifier_deformVertsEM( ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; @@ -280,7 +280,7 @@ static int latticeModifier_isDisabled(ModifierData *md, int userRenderParams) } static void latticeModifier_foreachObjectLink( - ModifierData *md, Object *ob, + ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { @@ -317,7 +317,7 @@ static void modifier_vgroup_cache(ModifierData *md, float (*vertexCos)[3]) static void latticeModifier_deformVerts( ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) + float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { LatticeModifierData *lmd = (LatticeModifierData*) md; @@ -325,12 +325,12 @@ static void latticeModifier_deformVerts( modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ lattice_deform_verts(lmd->object, ob, derivedData, - vertexCos, numVerts, lmd->name); + vertexCos, numVerts, lmd->name); } static void latticeModifier_deformVertsEM( ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; @@ -463,22 +463,22 @@ static DerivedMesh *buildModifier_applyModifier(ModifierData *md, Object *ob, maxVerts = dm->getNumVerts(dm); vertMap = MEM_callocN(sizeof(*vertMap) * maxVerts, - "build modifier vertMap"); + "build modifier vertMap"); for(i = 0; i < maxVerts; ++i) vertMap[i] = i; maxEdges = dm->getNumEdges(dm); edgeMap = MEM_callocN(sizeof(*edgeMap) * maxEdges, - "build modifier edgeMap"); + "build modifier edgeMap"); for(i = 0; i < maxEdges; ++i) edgeMap[i] = i; maxFaces = dm->getNumFaces(dm); faceMap = MEM_callocN(sizeof(*faceMap) * maxFaces, - "build modifier faceMap"); + "build modifier faceMap"); for(i = 0; i < maxFaces; ++i) faceMap[i] = i; if (ob) { frac = bsystem_time(md->scene, ob, md->scene->r.cfra, - bmd->start - 1.0f) / bmd->length; + bmd->start - 1.0f) / bmd->length; } else { frac = md->scene->r.cfra - bmd->start / bmd->length; } @@ -493,7 +493,7 @@ static DerivedMesh *buildModifier_applyModifier(ModifierData *md, Object *ob, if(bmd->randomize) BLI_array_randomize(faceMap, sizeof(*faceMap), - maxFaces, bmd->seed); + maxFaces, bmd->seed); /* get the set of all vert indices that will be in the final mesh, * mapped to the new indices @@ -532,7 +532,7 @@ static DerivedMesh *buildModifier_applyModifier(ModifierData *md, Object *ob, } else if(numEdges) { if(bmd->randomize) BLI_array_randomize(edgeMap, sizeof(*edgeMap), - maxEdges, bmd->seed); + maxEdges, bmd->seed); /* get the set of all vert indices that will be in the final mesh, * mapped to the new indices @@ -563,7 +563,7 @@ static DerivedMesh *buildModifier_applyModifier(ModifierData *md, Object *ob, if(bmd->randomize) BLI_array_randomize(vertMap, sizeof(*vertMap), - maxVerts, bmd->seed); + maxVerts, bmd->seed); /* get the set of all vert indices that will be in the final mesh, * mapped to the new indices @@ -576,7 +576,7 @@ static DerivedMesh *buildModifier_applyModifier(ModifierData *md, Object *ob, * the mesh */ result = CDDM_from_template(dm, BLI_ghash_size(vertHash), - BLI_ghash_size(edgeHash), numFaces); + BLI_ghash_size(edgeHash), numFaces); /* copy the vertices across */ for(hashIter = BLI_ghashIterator_new(vertHash); @@ -662,7 +662,7 @@ static CustomDataMask maskModifier_requiredDataMask(Object *ob, ModifierData *md } static void maskModifier_foreachObjectLink( - ModifierData *md, Object *ob, + ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { @@ -1028,7 +1028,7 @@ static void arrayModifier_copyData(ModifierData *md, ModifierData *target) } static void arrayModifier_foreachObjectLink( - ModifierData *md, Object *ob, + ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { @@ -1124,13 +1124,13 @@ static int calc_mapping(IndexMapEntry *indexMap, int oldIndex, int copyNum) return indexMap[oldIndex].new; else return calc_mapping(indexMap, indexMap[oldIndex].merge, - copyNum - 1); + copyNum - 1); } } static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, Scene *scene, Object *ob, DerivedMesh *dm, - int initFlags) + int initFlags) { int i, j; /* offset matrix */ @@ -1160,7 +1160,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, unit_m4(offset); indexMap = MEM_callocN(sizeof(*indexMap) * dm->getNumVerts(dm), - "indexmap"); + "indexmap"); src_mvert = dm->getVertArray(dm); @@ -1185,7 +1185,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, mul_serie_m4(result_mat, offset, obinv, amd->offset_ob->obmat, - NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); copy_m4_m4(offset, result_mat); } @@ -1542,12 +1542,12 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, mface[numFaces].v4 = vert_map[mface[numFaces].v4]; test_index_face(&mface[numFaces], &result->faceData, - numFaces, 4); + numFaces, 4); } else { test_index_face(&mface[numFaces], &result->faceData, - numFaces, 3); + numFaces, 3); } origindex[numFaces] = ORIGINDEX_NONE; @@ -1643,12 +1643,12 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, mface[numFaces].v4 = vert_map[mface[numFaces].v4]; test_index_face(&mface[numFaces], &result->faceData, - numFaces, 4); + numFaces, 4); } else { test_index_face(&mface[numFaces], &result->faceData, - numFaces, 3); + numFaces, 3); } origindex[numFaces] = ORIGINDEX_NONE; @@ -1714,7 +1714,7 @@ static void mirrorModifier_copyData(ModifierData *md, ModifierData *target) } static void mirrorModifier_foreachObjectLink( - ModifierData *md, Object *ob, + ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { @@ -1924,7 +1924,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, } static DerivedMesh *mirrorModifier__doMirror(MirrorModifierData *mmd, - Object *ob, DerivedMesh *dm, + Object *ob, DerivedMesh *dm, int initFlags) { DerivedMesh *result = dm; @@ -2198,7 +2198,7 @@ static void smoothmesh_print(SmoothMesh *mesh) dm->getVert(dm, vert->oldIndex, &mv); printf("%3d: ind={%3d, %3d}, pos={% 5.1f, % 5.1f, % 5.1f}", - i, vert->oldIndex, vert->newIndex, + i, vert->oldIndex, vert->newIndex, mv.co[0], mv.co[1], mv.co[2]); printf(", faces={"); for(node = vert->faces; node != NULL; node = node->next) { @@ -2213,7 +2213,7 @@ static void smoothmesh_print(SmoothMesh *mesh) LinkNode *node; printf("%4d: indices={%4d, %4d}, verts={%4d, %4d}", - i, + i, edge->oldIndex, edge->newIndex, edge->verts[0]->newIndex, edge->verts[1]->newIndex); if(edge->verts[0] == edge->verts[1]) printf(" <- DUPLICATE VERTEX"); @@ -2229,7 +2229,7 @@ static void smoothmesh_print(SmoothMesh *mesh) SmoothFace *face = &mesh->faces[i]; printf("%4d: indices={%4d, %4d}, edges={", i, - face->oldIndex, face->newIndex); + face->oldIndex, face->newIndex); for(j = 0; j < SMOOTHFACE_MAX_EDGES && face->edges[j]; j++) { if(face->flip[j]) printf(" -%-2d", face->edges[j]->newIndex); @@ -2257,7 +2257,7 @@ static SmoothMesh *smoothmesh_from_derivedmesh(DerivedMesh *dm) totface = dm->getNumFaces(dm); mesh = smoothmesh_new(totvert, totedge, totface, - totvert, totedge, totface); + totvert, totedge, totface); mesh->dm = dm; @@ -2390,7 +2390,7 @@ static SmoothVert *other_vert(SmoothEdge *edge, SmoothVert *vert) * (this should never happen) */ static SmoothEdge *other_edge(SmoothFace *face, SmoothVert *vert, - SmoothEdge *edge) + SmoothEdge *edge) { int i,j; for(i = 0; i < SMOOTHFACE_MAX_EDGES && face->edges[i]; i++) { @@ -2584,7 +2584,7 @@ static void edge_replace_vert(void *ptr, void *userdata) #ifdef EDGESPLIT_DEBUG_3 printf("replacing vert %4d with %4d in edge %4d", - find->newIndex, replace->newIndex, edge->newIndex); + find->newIndex, replace->newIndex, edge->newIndex); printf(": {%4d, %4d}", edge->verts[0]->newIndex, edge->verts[1]->newIndex); #endif @@ -2620,14 +2620,14 @@ static void face_replace_edge(void *ptr, void *userdata) #ifdef EDGESPLIT_DEBUG_3 printf("replacing edge %4d with %4d in face %4d", - find->newIndex, replace->newIndex, face->newIndex); + find->newIndex, replace->newIndex, face->newIndex); if(face->edges[3]) printf(": {%2d %2d %2d %2d}", - face->edges[0]->newIndex, face->edges[1]->newIndex, + face->edges[0]->newIndex, face->edges[1]->newIndex, face->edges[2]->newIndex, face->edges[3]->newIndex); else printf(": {%2d %2d %2d}", - face->edges[0]->newIndex, face->edges[1]->newIndex, + face->edges[0]->newIndex, face->edges[1]->newIndex, face->edges[2]->newIndex); #endif @@ -2642,11 +2642,11 @@ static void face_replace_edge(void *ptr, void *userdata) #ifdef EDGESPLIT_DEBUG_3 if(face->edges[3]) printf(" -> {%2d %2d %2d %2d}\n", - face->edges[0]->newIndex, face->edges[1]->newIndex, + face->edges[0]->newIndex, face->edges[1]->newIndex, face->edges[2]->newIndex, face->edges[3]->newIndex); else printf(" -> {%2d %2d %2d}\n", - face->edges[0]->newIndex, face->edges[1]->newIndex, + face->edges[0]->newIndex, face->edges[1]->newIndex, face->edges[2]->newIndex); #endif } @@ -2696,7 +2696,7 @@ static SmoothEdge *find_other_sharp_edge(SmoothVert *vert, SmoothEdge *edge, LinkNode *visited_edges = NULL; #ifdef EDGESPLIT_DEBUG_1 printf("=== START === find_other_sharp_edge(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); + edge->newIndex, vert->newIndex); #endif /* get a face on which to start */ @@ -2717,10 +2717,10 @@ static SmoothEdge *find_other_sharp_edge(SmoothVert *vert, SmoothEdge *edge, * seen before */ while(face && !edge_is_sharp(edge2, flags, threshold) - && !linklist_contains(visited_edges, edge2)) { + && !linklist_contains(visited_edges, edge2)) { #ifdef EDGESPLIT_DEBUG_3 printf("current face %4d; current edge %4d\n", face->newIndex, - edge2->newIndex); + edge2->newIndex); #endif /* get the next face */ face = other_face(edge2, face); @@ -2738,30 +2738,30 @@ static SmoothEdge *find_other_sharp_edge(SmoothVert *vert, SmoothEdge *edge, edge2 = other_edge(face, vert, edge2); #ifdef EDGESPLIT_DEBUG_3 printf("next face %4d; next edge %4d\n", - face->newIndex, edge2->newIndex); + face->newIndex, edge2->newIndex); } else { printf("loose edge: %4d\n", edge2->newIndex); #endif } - } + } - /* either we came back to the start edge or we found a sharp/loose edge */ - if(linklist_contains(visited_edges, edge2)) - /* we came back to the start edge */ - edge2 = NULL; + /* either we came back to the start edge or we found a sharp/loose edge */ + if(linklist_contains(visited_edges, edge2)) + /* we came back to the start edge */ + edge2 = NULL; - BLI_linklist_free(visited_edges, NULL); + BLI_linklist_free(visited_edges, NULL); #ifdef EDGESPLIT_DEBUG_1 - printf("=== END === find_other_sharp_edge(edge = %4d, vert = %4d), " - "returning edge %d\n", + printf("=== END === find_other_sharp_edge(edge = %4d, vert = %4d), " + "returning edge %d\n", edge->newIndex, vert->newIndex, edge2 ? edge2->newIndex : -1); #endif - return edge2; + return edge2; } static void split_single_vert(SmoothVert *vert, SmoothFace *face, - SmoothMesh *mesh) + SmoothMesh *mesh) { SmoothVert *copy_vert; ReplaceData repdata; @@ -2819,17 +2819,17 @@ static void pop_propagate_stack(SmoothEdge **edge, SmoothVert **vert, SmoothMesh static void split_edge(SmoothEdge *edge, SmoothVert *vert, SmoothMesh *mesh); static void propagate_split(SmoothEdge *edge, SmoothVert *vert, - SmoothMesh *mesh) + SmoothMesh *mesh) { SmoothEdge *edge2; LinkNode *visited_faces = NULL; #ifdef EDGESPLIT_DEBUG_1 printf("=== START === propagate_split(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); + edge->newIndex, vert->newIndex); #endif edge2 = find_other_sharp_edge(vert, edge, &visited_faces, - mesh->threshold, mesh->flags); + mesh->threshold, mesh->flags); if(!edge2) { /* didn't find a sharp or loose edge, so we've hit a dead end */ @@ -2871,7 +2871,7 @@ static void propagate_split(SmoothEdge *edge, SmoothVert *vert, BLI_linklist_free(visited_faces, NULL); #ifdef EDGESPLIT_DEBUG_1 printf("=== END === propagate_split(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); + edge->newIndex, vert->newIndex); #endif } @@ -2884,11 +2884,11 @@ static void split_edge(SmoothEdge *edge, SmoothVert *vert, SmoothMesh *mesh) LinkNode *visited_faces = NULL; #ifdef EDGESPLIT_DEBUG_1 printf("=== START === split_edge(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); + edge->newIndex, vert->newIndex); #endif edge2 = find_other_sharp_edge(vert, edge, &visited_faces, - mesh->threshold, mesh->flags); + mesh->threshold, mesh->flags); if(!edge2) { /* didn't find a sharp or loose edge, so try the other vert */ @@ -2958,12 +2958,12 @@ static void split_edge(SmoothEdge *edge, SmoothVert *vert, SmoothMesh *mesh) BLI_linklist_free(visited_faces, NULL); #ifdef EDGESPLIT_DEBUG_1 printf("=== END === split_edge(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); + edge->newIndex, vert->newIndex); #endif } static void tag_and_count_extra_edges(SmoothMesh *mesh, float split_angle, - int flags, int *extra_edges) + int flags, int *extra_edges) { /* if normal1 dot normal2 < threshold, angle is greater, so split */ /* FIXME not sure if this always works */ @@ -3327,7 +3327,7 @@ static int displaceModifier_dependsOnTime(ModifierData *md) } static void displaceModifier_foreachObjectLink(ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) + ObjectWalkFunc walk, void *userData) { DisplaceModifierData *dmd = (DisplaceModifierData*) md; @@ -3352,7 +3352,7 @@ static int displaceModifier_isDisabled(ModifierData *md, int useRenderParams) } static void displaceModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, + ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) { DisplaceModifierData *dmd = (DisplaceModifierData*) md; @@ -3385,7 +3385,7 @@ static void validate_layer_name(const CustomData *data, int type, char *name, ch } static void get_texture_coords(DisplaceModifierData *dmd, Object *ob, - DerivedMesh *dm, + DerivedMesh *dm, float (*co)[3], float (*texco)[3], int numVerts) { @@ -3492,7 +3492,7 @@ static void get_texture_value(Tex *texture, float *tex_co, TexResult *texres) /* dm must be a CDDerivedMesh */ static void displaceModifier_do( DisplaceModifierData *dmd, Object *ob, - DerivedMesh *dm, float (*vertexCos)[3], int numVerts) + DerivedMesh *dm, float (*vertexCos)[3], int numVerts) { int i; MVert *mvert; @@ -3509,7 +3509,7 @@ static void displaceModifier_do( dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); tex_co = MEM_callocN(sizeof(*tex_co) * numVerts, - "displaceModifier_do tex_co"); + "displaceModifier_do tex_co"); get_texture_coords(dmd, ob, dm, vertexCos, tex_co, numVerts); for(i = 0; i < numVerts; ++i) { @@ -3565,12 +3565,12 @@ static void displaceModifier_do( static void displaceModifier_deformVerts( ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) + float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { DerivedMesh *dm= get_cddm(md->scene, ob, NULL, derivedData, vertexCos); displaceModifier_do((DisplaceModifierData *)md, ob, dm, - vertexCos, numVerts); + vertexCos, numVerts); if(dm != derivedData) dm->release(dm); @@ -3583,7 +3583,7 @@ static void displaceModifier_deformVertsEM( DerivedMesh *dm= get_cddm(md->scene, ob, editData, derivedData, vertexCos); displaceModifier_do((DisplaceModifierData *)md, ob, dm, - vertexCos, numVerts); + vertexCos, numVerts); if(dm != derivedData) dm->release(dm); @@ -3642,18 +3642,18 @@ static void uvprojectModifier_foreachObjectLink(ModifierData *md, Object *ob, } static void uvprojectModifier_foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { UVProjectModifierData *umd = (UVProjectModifierData*) md; walk(userData, ob, (ID **)&umd->image); uvprojectModifier_foreachObjectLink(md, ob, (ObjectWalkFunc)walk, - userData); + userData); } static void uvprojectModifier_updateDepgraph(ModifierData *md, - DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) + DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) { UVProjectModifierData *umd = (UVProjectModifierData*) md; int i; @@ -3711,7 +3711,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, numVerts = dm->getNumVerts(dm); coords = MEM_callocN(sizeof(*coords) * numVerts, - "uvprojectModifier_do coords"); + "uvprojectModifier_do coords"); dm->getVertCos(dm, coords); /* convert coords to world space */ @@ -4092,7 +4092,7 @@ static CustomDataMask smoothModifier_requiredDataMask(Object *ob, ModifierData * } static void smoothModifier_do( - SmoothModifierData *smd, Object *ob, DerivedMesh *dm, + SmoothModifierData *smd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; @@ -4220,7 +4220,7 @@ static void smoothModifier_do( } static void smoothModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, + ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { DerivedMesh *dm= get_dm(md->scene, ob, NULL, derivedData, NULL, 0); @@ -4234,7 +4234,7 @@ static void smoothModifier_deformVerts( static void smoothModifier_deformVertsEM( ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm= get_dm(md->scene, ob, editData, derivedData, NULL, 0); @@ -4302,7 +4302,7 @@ static CustomDataMask castModifier_requiredDataMask(Object *ob, ModifierData *md static void castModifier_foreachObjectLink( ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + void *userData) { CastModifierData *cmd = (CastModifierData*) md; @@ -4311,7 +4311,7 @@ static void castModifier_foreachObjectLink( static void castModifier_updateDepgraph( ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) + DagNode *obNode) { CastModifierData *cmd = (CastModifierData*) md; @@ -4325,7 +4325,7 @@ static void castModifier_updateDepgraph( static void castModifier_sphere_do( CastModifierData *cmd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; @@ -4502,7 +4502,7 @@ static void castModifier_sphere_do( static void castModifier_cuboid_do( CastModifierData *cmd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; Object *ctrl_ob = NULL; @@ -4772,7 +4772,7 @@ static void castModifier_cuboid_do( } static void castModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, + ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { DerivedMesh *dm = NULL; @@ -4795,7 +4795,7 @@ static void castModifier_deformVerts( } static void castModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, + ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = get_dm(md->scene, ob, editData, derivedData, NULL, 0); @@ -4873,7 +4873,7 @@ static void waveModifier_foreachObjectLink( } static void waveModifier_foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { WaveModifierData *wmd = (WaveModifierData*) md; @@ -4884,7 +4884,7 @@ static void waveModifier_foreachIDLink(ModifierData *md, Object *ob, static void waveModifier_updateDepgraph( ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) + DagNode *obNode) { WaveModifierData *wmd = (WaveModifierData*) md; @@ -4921,7 +4921,7 @@ static CustomDataMask waveModifier_requiredDataMask(Object *ob, ModifierData *md } static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob, - DerivedMesh *dm, + DerivedMesh *dm, float (*co)[3], float (*texco)[3], int numVerts) { @@ -5009,7 +5009,7 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob, static void waveModifier_do(WaveModifierData *md, Scene *scene, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + float (*vertexCos)[3], int numVerts) { WaveModifierData *wmd = (WaveModifierData*) md; MVert *mvert = NULL; @@ -5057,7 +5057,7 @@ static void waveModifier_do(WaveModifierData *md, if(wmd->texture) { tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts, - "waveModifier_do tex_co"); + "waveModifier_do tex_co"); wavemod_get_texture_coords(wmd, ob, dm, vertexCos, tex_co, numVerts); } @@ -5165,7 +5165,7 @@ static void waveModifier_do(WaveModifierData *md, } static void waveModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, + ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { DerivedMesh *dm= derivedData; @@ -5183,7 +5183,7 @@ static void waveModifier_deformVerts( } static void waveModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, + ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm= derivedData; @@ -5237,8 +5237,8 @@ static int armatureModifier_isDisabled(ModifierData *md, int useRenderParams) } static void armatureModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { ArmatureModifierData *amd = (ArmatureModifierData*) md; @@ -5247,7 +5247,7 @@ static void armatureModifier_foreachObjectLink( } static void armatureModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, Object *ob, + ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) { ArmatureModifierData *amd = (ArmatureModifierData*) md; @@ -5262,14 +5262,14 @@ static void armatureModifier_updateDepgraph( static void armatureModifier_deformVerts( ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) + float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { ArmatureModifierData *amd = (ArmatureModifierData*) md; modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ armature_deform_verts(amd->object, ob, derivedData, vertexCos, NULL, - numVerts, amd->deformflag, + numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); /* free cache */ if(amd->prevCos) { @@ -5288,15 +5288,15 @@ static void armatureModifier_deformVertsEM( if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); armature_deform_verts(amd->object, ob, dm, vertexCos, NULL, numVerts, - amd->deformflag, NULL, amd->defgrp_name); + amd->deformflag, NULL, amd->defgrp_name); if(!derivedData) dm->release(dm); } static void armatureModifier_deformMatricesEM( - ModifierData *md, Object *ob, EditMesh *editData, + ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], - float (*defMats)[3][3], int numVerts) + float (*defMats)[3][3], int numVerts) { ArmatureModifierData *amd = (ArmatureModifierData*) md; DerivedMesh *dm = derivedData; @@ -5304,7 +5304,7 @@ static void armatureModifier_deformMatricesEM( if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts, - amd->deformflag, NULL, amd->defgrp_name); + amd->deformflag, NULL, amd->defgrp_name); if(!derivedData) dm->release(dm); } @@ -5362,7 +5362,7 @@ static int hookModifier_isDisabled(ModifierData *md, int useRenderParams) static void hookModifier_foreachObjectLink( ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + void *userData) { HookModifierData *hmd = (HookModifierData*) md; @@ -5385,7 +5385,7 @@ static void hookModifier_updateDepgraph(ModifierData *md, DagForest *forest, Sce } static void hookModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, + ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { HookModifierData *hmd = (HookModifierData*) md; @@ -5405,7 +5405,7 @@ static void hookModifier_deformVerts( } invert_m4_m4(ob->imat, ob->obmat); mul_serie_m4(mat, ob->imat, dmat, hmd->parentinv, - NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); /* vertex indices? */ if(hmd->indexar) { @@ -5507,7 +5507,7 @@ static void hookModifier_deformVerts( } static void hookModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, + ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; @@ -5523,7 +5523,7 @@ static void hookModifier_deformVertsEM( static void softbodyModifier_deformVerts( ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) + float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { sbObjectStep(md->scene, ob, (float)md->scene->r.cfra, vertexCos, numVerts); } @@ -5984,9 +5984,9 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, } static DerivedMesh *solidifyModifier_applyModifierEM(ModifierData *md, - Object *ob, - EditMesh *editData, - DerivedMesh *derivedData) + Object *ob, + EditMesh *editData, + DerivedMesh *derivedData) { return solidifyModifier_applyModifier(md, ob, derivedData, 0, 1); } @@ -6075,8 +6075,8 @@ static void screwModifier_copyData(ModifierData *md, ModifierData *target) } static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) + DerivedMesh *derivedData, + int useRenderParams, int isFinalCalc) { DerivedMesh *dm= derivedData; DerivedMesh *result; @@ -6766,7 +6766,7 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, static void screwModifier_updateDepgraph( - ModifierData *md, DagForest *forest, + ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) { ScrewModifierData *ltmd= (ScrewModifierData*) md; @@ -6775,15 +6775,15 @@ static void screwModifier_updateDepgraph( DagNode *curNode= dag_get_node(forest, ltmd->ob_axis); dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, - "Screw Modifier"); + DAG_RL_DATA_DATA | DAG_RL_OB_DATA, + "Screw Modifier"); } } static void screwModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { ScrewModifierData *ltmd= (ScrewModifierData*) md; @@ -6792,8 +6792,8 @@ static void screwModifier_foreachObjectLink( /* This dosnt work with material*/ static DerivedMesh *screwModifier_applyModifierEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData) + ModifierData *md, Object *ob, EditMesh *editData, + DerivedMesh *derivedData) { return screwModifier_applyModifier(md, ob, derivedData, 0, 1); } @@ -6826,7 +6826,7 @@ static void smokeModifier_freeData(ModifierData *md) static void smokeModifier_deformVerts( ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) + float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { SmokeModifierData *smd = (SmokeModifierData*) md; DerivedMesh *dm = dm= get_cddm(md->scene, ob, NULL, derivedData, vertexCos); @@ -6844,7 +6844,7 @@ static int smokeModifier_dependsOnTime(ModifierData *md) static void smokeModifier_updateDepgraph( ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) + DagNode *obNode) { /*SmokeModifierData *smd = (SmokeModifierData *) md; if(smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) @@ -6916,7 +6916,7 @@ static DerivedMesh *clothModifier_applyModifier(ModifierData *md, Object *ob, static void clothModifier_updateDepgraph( ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) + DagNode *obNode) { ClothModifierData *clmd = (ClothModifierData*) md; @@ -7056,7 +7056,7 @@ static int collisionModifier_dependsOnTime(ModifierData *md) static void collisionModifier_deformVerts( ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) + float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { CollisionModifierData *collmd = (CollisionModifierData*) md; DerivedMesh *dm = NULL; @@ -7225,7 +7225,7 @@ static int surfaceModifier_dependsOnTime(ModifierData *md) static void surfaceModifier_deformVerts( ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) + float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { SurfaceModifierData *surmd = (SurfaceModifierData*) md; unsigned int numverts = 0, i = 0; @@ -7319,7 +7319,7 @@ static int booleanModifier_isDisabled(ModifierData *md, int useRenderParams) } static void booleanModifier_foreachObjectLink( - ModifierData *md, Object *ob, + ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { @@ -7351,7 +7351,7 @@ static DerivedMesh *booleanModifier_applyModifier( /* we do a quick sanity check */ if(dm && (derivedData->getNumFaces(derivedData) > 3) - && bmd->object && dm->getNumFaces(dm) > 3) { + && bmd->object && dm->getNumFaces(dm) > 3) { DerivedMesh *result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob, 1 + bmd->operation); @@ -7454,8 +7454,8 @@ static CustomDataMask particleSystemModifier_requiredDataMask(Object *ob, Modifi /* saves the current emitter state for a particle system and calculates particles */ static void particleSystemModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) + ModifierData *md, Object *ob, DerivedMesh *derivedData, + float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { DerivedMesh *dm = derivedData; ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; @@ -7524,8 +7524,8 @@ static void particleSystemModifier_deformVerts( * updates is coded */ #if 0 static void particleSystemModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, EditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; @@ -7844,7 +7844,7 @@ static CustomDataMask explodeModifier_requiredDataMask(Object *ob, ModifierData static void explodeModifier_createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *psmd, - Object *ob, DerivedMesh *dm) + Object *ob, DerivedMesh *dm) { ParticleSystem *psys=psmd->psys; MFace *fa=0, *mface=0; @@ -8683,7 +8683,7 @@ static DerivedMesh * fluidsimModifier_applyModifier( static void fluidsimModifier_updateDepgraph( ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) + Object *ob, DagNode *obNode) { FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; Base *base; @@ -8774,7 +8774,7 @@ static void meshdeformModifier_foreachObjectLink( } static void meshdeformModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, Object *ob, + ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) { MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; @@ -8842,7 +8842,7 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 static void meshdeformModifier_do( ModifierData *md, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + float (*vertexCos)[3], int numVerts) { MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; Mesh *me= (mmd->object)? mmd->object->data: NULL; @@ -9010,7 +9010,7 @@ static void meshdeformModifier_deformVerts( } static void meshdeformModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, + ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm; @@ -9263,7 +9263,7 @@ static void simpledeformModifier_deformVertsEM(ModifierData *md, Object *ob, Edi static void shapekeyModifier_deformVerts( ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) + float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { KeyBlock *kb= ob_get_keyblock(ob); float (*deformedVerts)[3]; @@ -9288,9 +9288,9 @@ static void shapekeyModifier_deformVertsEM( } static void shapekeyModifier_deformMatricesEM( - ModifierData *md, Object *ob, EditMesh *editData, + ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], - float (*defMats)[3][3], int numVerts) + float (*defMats)[3][3], int numVerts) { Key *key= ob_get_key(ob); KeyBlock *kb= ob_get_keyblock(ob); @@ -9738,7 +9738,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti = INIT_TYPE(Screw); mti->type = eModifierTypeType_Constructive; mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode + | eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_AcceptsCVs; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 248b7ed407d..0d508a4c4d1 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -650,7 +650,7 @@ void multires_stitch_grids(Object *ob) } DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int local_mmd, DerivedMesh *dm, Object *ob, - int useRenderParams, int isFinalCalc) + int useRenderParams, int isFinalCalc) { Mesh *me= ob->data; DerivedMesh *result; @@ -840,7 +840,7 @@ void multires_free(Multires *mr) } static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const MultiresFace *mface, - const int totvert, const int totface) + const int totvert, const int totface) { int i,j; IndexNode *node = NULL; @@ -859,7 +859,7 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult } static void create_old_vert_edge_map(ListBase **map, IndexNode **mem, const MultiresEdge *medge, - const int totvert, const int totedge) + const int totvert, const int totedge) { int i,j; IndexNode *node = NULL; @@ -925,7 +925,7 @@ static void multires_load_old_edges(ListBase **emap, MultiresLevel *lvl, int *vv } static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLevel *lvl, int *vvmap, int dst, - int v1, int v2, int v3, int v4, int st2, int st3) + int v1, int v2, int v3, int v4, int st2, int st3) { int fmid; int emid13, emid14, emid23, emid24; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 10da12753e7..98db81d90d0 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1048,11 +1048,11 @@ bNodeTree *ntreeAddTree(int type) ntree->alltypes.last = NULL; /* this helps RNA identify ID pointers as nodetree */ - if(ntree->type==NTREE_SHADER) + if(ntree->type==NTREE_SHADER) BLI_strncpy(ntree->id.name, "NTShader Nodetree", sizeof(ntree->id.name)); - else if(ntree->type==NTREE_COMPOSIT) + else if(ntree->type==NTREE_COMPOSIT) BLI_strncpy(ntree->id.name, "NTCompositing Nodetree", sizeof(ntree->id.name)); - else if(ntree->type==NTREE_TEXTURE) + else if(ntree->type==NTREE_TEXTURE) BLI_strncpy(ntree->id.name, "NTTexture Nodetree", sizeof(ntree->id.name)); ntreeInitTypes(ntree); @@ -1354,9 +1354,9 @@ void ntreeMakeLocal(bNodeTree *ntree) int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(ntree->id.lib==NULL) return; if(ntree->id.us==1) { @@ -1547,7 +1547,7 @@ bNode *nodeGetActiveID(bNodeTree *ntree, short idtype) if(ntree==NULL) return NULL; /* check for group edit */ - for(node= ntree->nodes.first; node; node= node->next) + for(node= ntree->nodes.first; node; node= node->next) if(node->flag & NODE_GROUP_EDIT) break; @@ -1571,7 +1571,7 @@ int nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id) if(ntree==NULL) return ok; /* check for group edit */ - for(node= ntree->nodes.first; node; node= node->next) + for(node= ntree->nodes.first; node; node= node->next) if(node->flag & NODE_GROUP_EDIT) break; @@ -2641,7 +2641,7 @@ static void gpu_from_node_stack(ListBase *sockets, bNodeStack **ns, GPUNodeStack for (sock=sockets->first, i=0; sock; sock=sock->next, i++) { memset(&gs[i], 0, sizeof(gs[i])); - QUATCOPY(gs[i].vec, ns[i]->vec); + QUATCOPY(gs[i].vec, ns[i]->vec); gs[i].link= ns[i]->data; if (sock->type == SOCK_VALUE) @@ -2734,7 +2734,7 @@ void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat) if(node->typeinfo->gpufunc(mat, node, gpuin, gpuout)) data_from_gpu_stack(&node->outputs, nsout, gpuout); } - else if(node->type==NODE_GROUP && node->id) { + else if(node->type==NODE_GROUP && node->id) { node_get_stack(node, stack, nsin, nsout); gpu_node_group_execute(stack, mat, node, nsin, nsout); } @@ -2994,7 +2994,7 @@ void nodeRegisterType(ListBase *typelist, const bNodeType *ntype) bNodeType *ntypen= MEM_callocN(sizeof(bNodeType), "node type"); *ntypen= *ntype; BLI_addtail(typelist, ntypen); - } + } } static void registerCompositNodes(ListBase *ntypelist) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index b08754a7a3f..b1cb83c0a51 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -710,9 +710,9 @@ void make_local_camera(Camera *cam) int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(cam->id.lib==0) return; if(cam->id.us==1) { @@ -858,9 +858,9 @@ void make_local_lamp(Lamp *la) int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(la->id.lib==0) return; if(la->id.us==1) { @@ -1356,9 +1356,9 @@ void make_local_object(Object *ob) int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(ob->id.lib==NULL) return; @@ -1766,7 +1766,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) /* vec: 4 items! */ - if( where_on_path(par, ctime, vec, dir, NULL, &radius) ) { + if( where_on_path(par, ctime, vec, dir, NULL, &radius) ) { if(cu->flag & CU_FOLLOW) { vec_to_quat( quat,dir, ob->trackflag, ob->upflag); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index f228dc5002e..48a5c956cc3 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3466,9 +3466,9 @@ void make_local_particlesettings(ParticleSettings *part) int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(part->id.lib==0) return; if(part->id.us==1) { @@ -4238,7 +4238,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa normalize_v3(side); cross_v3_v3v3(nor, vec, side); - unit_m4(mat); + unit_m4(mat); VECCOPY(mat[0], vec); VECCOPY(mat[1], side); VECCOPY(mat[2], nor); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index c73bd732d85..a99a8affbd3 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -286,7 +286,7 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys) node: the allocated links - total derived mesh element count nodearray: the array of nodes aligned with the base mesh's elements, so - each original elements can reference its derived elements + each original elements can reference its derived elements */ Mesh *me= (Mesh*)ob->data; PARTICLE_P; @@ -511,18 +511,18 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) static void hammersley_create(float *out, int n, int seed, float amount) { RNG *rng; - double p, t, offs[2]; - int k, kk; + double p, t, offs[2]; + int k, kk; rng = rng_new(31415926 + n + seed); offs[0]= rng_getDouble(rng) + amount; offs[1]= rng_getDouble(rng) + amount; rng_free(rng); - for (k = 0; k < n; k++) { - t = 0; - for (p = 0.5, kk = k; kk; p *= 0.5, kk >>= 1) - if (kk & 1) /* kk mod 2 = 1 */ + for (k = 0; k < n; k++) { + t = 0; + for (p = 0.5, kk = k; kk; p *= 0.5, kk >>= 1) + if (kk & 1) /* kk mod 2 = 1 */ t += p; out[2*k + 0]= fmod((double)k/(double)n + offs[0], 1.0); @@ -545,7 +545,7 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount) rng = rng_new(31415926 + num + seed2); x= 0; - num2 = 2 * num; + num2 = 2 * num; for(i=0; ifp= fp; - return pf; + return pf; } static void ptcache_file_close(PTCacheFile *pf) diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index bc66f4d52d3..e32f5aac517 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -446,18 +446,18 @@ void init_actuator(bActuator *act) case ACT_VISIBILITY: act->data= MEM_callocN(sizeof(bVisibilityActuator), "visibility act"); break; - case ACT_2DFILTER: - act->data = MEM_callocN(sizeof( bTwoDFilterActuator ), "2d filter act"); - break; - case ACT_PARENT: - act->data = MEM_callocN(sizeof( bParentActuator ), "parent act"); - break; + case ACT_2DFILTER: + act->data = MEM_callocN(sizeof( bTwoDFilterActuator ), "2d filter act"); + break; + case ACT_PARENT: + act->data = MEM_callocN(sizeof( bParentActuator ), "parent act"); + break; case ACT_STATE: - act->data = MEM_callocN(sizeof( bStateActuator ), "state act"); - break; + act->data = MEM_callocN(sizeof( bStateActuator ), "state act"); + break; case ACT_ARMATURE: - act->data = MEM_callocN(sizeof( bArmatureActuator ), "armature act"); - break; + act->data = MEM_callocN(sizeof( bArmatureActuator ), "armature act"); + break; default: ; /* this is very severe... I cannot make any memory for this */ /* logic brick... */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index d36043a29ee..44035afc059 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -203,17 +203,17 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) /* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations * are done outside of blenkernel with ED_objects_single_users! */ - /* camera */ + /* camera */ if(type == SCE_COPY_LINK_DATA || type == SCE_COPY_FULL) { - ID_NEW(scen->camera); + ID_NEW(scen->camera); } /* world */ if(type == SCE_COPY_FULL) { - if(scen->world) { - id_us_plus((ID *)scen->world); - scen->world= copy_world(scen->world); - } + if(scen->world) { + id_us_plus((ID *)scen->world); + scen->world= copy_world(scen->world); + } } sound_create_scene(scen); @@ -235,9 +235,9 @@ void free_scene(Scene *sce) if(sce->gpd) { #if 0 // removed since this can be invalid memory when freeing everything - // since the grease pencil data is free'd before the scene. - // since grease pencil data is not (yet?), shared between objects - // its probably safe not to do this, some save and reload will free this. + // since the grease pencil data is free'd before the scene. + // since grease pencil data is not (yet?), shared between objects + // its probably safe not to do this, some save and reload will free this. sce->gpd->id.us--; #endif sce->gpd= NULL; @@ -620,7 +620,7 @@ int next_object(Scene *scene, int val, Base **base, Object **ob) fase= F_SCENE; } else { - /* exception: empty scene */ + /* exception: empty scene */ if(scene->set && scene->set->base.first) { *base= scene->set->base.first; *ob= (*base)->object; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 7cabb620085..33c90d1a94e 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -230,9 +230,9 @@ static ImBuf * IMB_cast_away_list(ImBuf * i) } static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) + float facf0, float facf1, int x, int y, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3, struct ImBuf *out) { char *cp; int float_rendering; @@ -323,7 +323,7 @@ static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, } static int do_plugin_early_out(struct Sequence *seq, - float facf0, float facf1) + float facf0, float facf1) { return 0; } @@ -348,7 +348,7 @@ static void init_alpha_over_or_under(Sequence * seq) } static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y, - char * rect1, char *rect2, char *out) + char * rect1, char *rect2, char *out) { int fac2, mfac, fac, fac4; int xo, tempc; @@ -414,7 +414,7 @@ static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y, } static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, - float * rect1, float *rect2, float *out) + float * rect1, float *rect2, float *out) { float fac2, mfac, fac, fac4; int xo; @@ -568,8 +568,8 @@ void do_alphaunder_effect_byte( static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, - float *out) + float *rect1, float *rect2, + float *out) { float fac2, mfac, fac, fac4; int xo; @@ -763,9 +763,9 @@ void do_cross_effect_float(float facf0, float facf1, int x, int y, /* carefull: also used by speed effect! */ static void do_cross_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) + float facf0, float facf1, int x, int y, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3, struct ImBuf *out) { if (out->rect_float) { do_cross_effect_float( @@ -854,7 +854,7 @@ static float gammaCorrect(float c) if (i < 0) res = -pow(abs(c), valid_gamma); else if (i >= RE_GAMMA_TABLE_SIZE ) res = pow(c, valid_gamma); else res = gamma_range_table[i] + - ( (c - color_domain_table[i]) * gamfactor_table[i]); + ( (c - color_domain_table[i]) * gamfactor_table[i]); return res; } /* end of float gammaCorrect(float col) */ @@ -871,7 +871,7 @@ static float invGammaCorrect(float col) if (i < 0) res = -pow(abs(col), valid_inv_gamma); else if (i >= RE_GAMMA_TABLE_SIZE) res = pow(col, valid_inv_gamma); else res = inv_gamma_range_table[i] + - ( (col - color_domain_table[i]) * inv_gamfactor_table[i]); + ( (col - color_domain_table[i]) * inv_gamfactor_table[i]); return res; } /* end of float invGammaCorrect(float col) */ @@ -926,10 +926,10 @@ static void free_gammacross(Sequence * seq) } static void do_gammacross_effect_byte(float facf0, float facf1, - int x, int y, - unsigned char *rect1, - unsigned char *rect2, - unsigned char *out) + int x, int y, + unsigned char *rect1, + unsigned char *rect2, + unsigned char *out) { int fac1, fac2, col; int xo; @@ -982,9 +982,9 @@ static void do_gammacross_effect_byte(float facf0, float facf1, } static void do_gammacross_effect_float(float facf0, float facf1, - int x, int y, - float *rect1, float *rect2, - float *out) + int x, int y, + float *rect1, float *rect2, + float *out) { float fac1, fac2; int xo; @@ -1050,8 +1050,8 @@ static void do_gammacross_effect(Scene *scene, Sequence *seq, int cfra, ********************************************************************** */ static void do_add_effect_byte(float facf0, float facf1, int x, int y, - unsigned char *rect1, unsigned char *rect2, - unsigned char *out) + unsigned char *rect1, unsigned char *rect2, + unsigned char *out) { int col, xo, fac1, fac3; char *rt1, *rt2, *rt; @@ -1162,8 +1162,8 @@ static void do_add_effect(Scene *scene, Sequence *seq, int cfra, ********************************************************************** */ static void do_sub_effect_byte(float facf0, float facf1, - int x, int y, - char *rect1, char *rect2, char *out) + int x, int y, + char *rect1, char *rect2, char *out) { int col, xo, fac1, fac3; char *rt1, *rt2, *rt; @@ -1382,8 +1382,8 @@ static void do_drop_effect(Scene *scene, Sequence *seq, int cfra, ********************************************************************** */ static void do_mul_effect_byte(float facf0, float facf1, int x, int y, - unsigned char *rect1, unsigned char *rect2, - unsigned char *out) + unsigned char *rect1, unsigned char *rect2, + unsigned char *out) { int xo, fac1, fac3; char *rt1, *rt2, *rt; @@ -1431,8 +1431,8 @@ static void do_mul_effect_byte(float facf0, float facf1, int x, int y, } static void do_mul_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, - float *out) + float *rect1, float *rect2, + float *out) { int xo; float fac1, fac3; @@ -1611,13 +1611,13 @@ float hyp3,hyp4,b4,b5 output = in_band(wipezone,width,hyp,facf0,1,1); else output = in_band(wipezone,width,hyp,facf0,0,1); - } + } else { if(b1 < b2) output = in_band(wipezone,width,hyp,facf0,0,1); else output = in_band(wipezone,width,hyp,facf0,1,1); - } + } break; case DO_DOUBLE_WIPE: @@ -1657,50 +1657,50 @@ float hyp3,hyp4,b4,b5 if( hyp < hwidth && hyp2 > hwidth ) output = in_band(wipezone,hwidth,hyp,facf0,1,1); else if( hyp > hwidth && hyp2 < hwidth ) - output = in_band(wipezone,hwidth,hyp2,facf0,1,1); + output = in_band(wipezone,hwidth,hyp2,facf0,1,1); else - output = in_band(wipezone,hwidth,hyp2,facf0,1,1) * in_band(wipezone,hwidth,hyp,facf0,1,1); + output = in_band(wipezone,hwidth,hyp2,facf0,1,1) * in_band(wipezone,hwidth,hyp,facf0,1,1); } if(!wipe->forward)output = 1-output; - break; - case DO_CLOCK_WIPE: - /* - temp1: angle of effect center in rads - temp2: angle of line through (halfx,halfy) and (x,y) in rads - temp3: angle of low side of blur - temp4: angle of high side of blur - */ - output = 1.0f - facf0; - widthf = wipe->edgeWidth*2.0f*(float)M_PI; - temp1 = 2.0f * (float)M_PI * facf0; + break; + case DO_CLOCK_WIPE: + /* + temp1: angle of effect center in rads + temp2: angle of line through (halfx,halfy) and (x,y) in rads + temp3: angle of low side of blur + temp4: angle of high side of blur + */ + output = 1.0f - facf0; + widthf = wipe->edgeWidth*2.0f*(float)M_PI; + temp1 = 2.0f * (float)M_PI * facf0; - if(wipe->forward){ - temp1 = 2.0f*(float)M_PI - temp1; - } + if(wipe->forward){ + temp1 = 2.0f*(float)M_PI - temp1; + } - x = x - halfx; - y = y - halfy; - - temp2 = asin(abs(y)/sqrt(x*x + y*y)); - if(x <= 0 && y >= 0) temp2 = (float)M_PI - temp2; - else if(x<=0 && y <= 0) temp2 += (float)M_PI; - else if(x >= 0 && y <= 0) temp2 = 2.0f*(float)M_PI - temp2; - - if(wipe->forward){ - temp3 = temp1-(widthf*0.5f)*facf0; - temp4 = temp1+(widthf*0.5f)*(1-facf0); - } else{ - temp3 = temp1-(widthf*0.5f)*(1-facf0); - temp4 = temp1+(widthf*0.5f)*facf0; + x = x - halfx; + y = y - halfy; + + temp2 = asin(abs(y)/sqrt(x*x + y*y)); + if(x <= 0 && y >= 0) temp2 = (float)M_PI - temp2; + else if(x<=0 && y <= 0) temp2 += (float)M_PI; + else if(x >= 0 && y <= 0) temp2 = 2.0f*(float)M_PI - temp2; + + if(wipe->forward){ + temp3 = temp1-(widthf*0.5f)*facf0; + temp4 = temp1+(widthf*0.5f)*(1-facf0); + } else{ + temp3 = temp1-(widthf*0.5f)*(1-facf0); + temp4 = temp1+(widthf*0.5f)*facf0; } - if (temp3 < 0) temp3 = 0; - if (temp4 > 2.0f*(float)M_PI) temp4 = 2.0f*(float)M_PI; + if (temp3 < 0) temp3 = 0; + if (temp4 > 2.0f*(float)M_PI) temp4 = 2.0f*(float)M_PI; - if(temp2 < temp3) output = 0; - else if (temp2 > temp4) output = 1; - else output = (temp2-temp3)/(temp4-temp3); - if(x == 0 && y == 0) output = 1; + if(temp2 < temp3) output = 0; + else if (temp2 > temp4) output = 1; + else output = (temp2-temp3)/(temp4-temp3); + if(x == 0 && y == 0) output = 1; if(output != output) output = 1; if(wipe->forward) output = 1 - output; break; @@ -1735,9 +1735,9 @@ float hyp3,hyp4,b4,b5 if( hyp < hwidth && hyp2 > hwidth ) output = in_band(wipezone,hwidth,hyp,facf0,1,1); else if( hyp > hwidth && hyp2 < hwidth ) - output = in_band(wipezone,hwidth,hyp2,facf0,1,1); + output = in_band(wipezone,hwidth,hyp2,facf0,1,1); else - output = in_band(wipezone,hwidth,hyp2,facf0,1,1) * in_band(wipezone,hwidth,hyp,facf0,1,1); + output = in_band(wipezone,hwidth,hyp2,facf0,1,1) * in_band(wipezone,hwidth,hyp,facf0,1,1); } if(invert)facf0 = 1-facf0; @@ -1776,11 +1776,11 @@ float hyp3,hyp4,b4,b5 hwidth = width*0.5f; temp1 = (halfx-(halfx)*facf0); - pointdist = sqrt(temp1*temp1 + temp1*temp1); + pointdist = sqrt(temp1*temp1 + temp1*temp1); - temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y)); - if(temp2 > pointdist) output = in_band(wipezone,hwidth,fabs(temp2-pointdist),facf0,0,1); - else output = in_band(wipezone,hwidth,fabs(temp2-pointdist),facf0,1,1); + temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y)); + if(temp2 > pointdist) output = in_band(wipezone,hwidth,fabs(temp2-pointdist),facf0,0,1); + else output = in_band(wipezone,hwidth,fabs(temp2-pointdist),facf0,1,1); if(!wipe->forward) output = 1-output; @@ -1936,14 +1936,14 @@ static void do_wipe_effect(Scene *scene, Sequence *seq, int cfra, { if (out->rect_float) { do_wipe_effect_float(seq, - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, x, y, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_wipe_effect_byte(seq, - facf0, facf1, x, y, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, x, y, + (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, + (unsigned char*) out->rect); } } /* ********************************************************************** @@ -2466,8 +2466,8 @@ static void RVAddBitmaps_float (float* a, float* b, float* c, /* For each pixel whose total luminance exceeds the threshold, */ /* Multiply it's value by BOOST and add it to the output map */ static void RVIsolateHighlights_byte (unsigned char* in, unsigned char* out, - int width, int height, int threshold, - float boost, float clamp) + int width, int height, int threshold, + float boost, float clamp) { int x,y,index; int intensity; @@ -2475,7 +2475,7 @@ static void RVIsolateHighlights_byte (unsigned char* in, unsigned char* out, for(y=0;y< height;y++) { for (x=0;x< width;x++) { - index= (x+y*width)*4; + index= (x+y*width)*4; /* Isolate the intensity */ intensity=(in[index+GlowR]+in[index+GlowG]+in[index+GlowB]-threshold); @@ -2495,8 +2495,8 @@ static void RVIsolateHighlights_byte (unsigned char* in, unsigned char* out, } static void RVIsolateHighlights_float (float* in, float* out, - int width, int height, float threshold, - float boost, float clamp) + int width, int height, float threshold, + float boost, float clamp) { int x,y,index; float intensity; @@ -2504,7 +2504,7 @@ static void RVIsolateHighlights_float (float* in, float* out, for(y=0;y< height;y++) { for (x=0;x< width;x++) { - index= (x+y*width)*4; + index= (x+y*width)*4; /* Isolate the intensity */ intensity=(in[index+GlowR]+in[index+GlowG]+in[index+GlowB]-threshold); @@ -2593,14 +2593,14 @@ static void do_glow_effect(Scene *scene, Sequence *seq, int cfra, { if (out->rect_float) { do_glow_effect_float(seq, - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, x, y, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_glow_effect_byte(seq, - facf0, facf1, x, y, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, x, y, + (char*) ibuf1->rect, (char*) ibuf2->rect, + (char*) out->rect); } } @@ -2726,7 +2726,7 @@ static void init_speed_effect(Sequence *seq) if(seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct SpeedControlVars), - "speedcontrolvars"); + "speedcontrolvars"); v = (SpeedControlVars *)seq->effectdata; v->globalSpeed = 1.0; @@ -2807,7 +2807,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) return; } if (!seq->seq1) { /* make coverity happy and check for (CID 598) - input strip ... */ + input strip ... */ return; } @@ -2854,16 +2854,16 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) for (cfra = 1; cfra < v->length; cfra++) { if(fcu) { - if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) { - ctime = seq->startdisp + cfra; - div = 1.0; - } else { - ctime= cfra; - div= v->length / 100.0f; - if(div==0.0) return; - } + if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) { + ctime = seq->startdisp + cfra; + div = 1.0; + } else { + ctime= cfra; + div= v->length / 100.0f; + if(div==0.0) return; + } - facf = evaluate_fcurve(fcu, ctime/div); + facf = evaluate_fcurve(fcu, ctime/div); } else { facf = fallback_fac; } @@ -2885,19 +2885,19 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) for (cfra = 0; cfra < v->length; cfra++) { if(fcu) { - if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) { - ctime = seq->startdisp + cfra; - div = 1.0; - } else { - ctime= cfra; - div= v->length / 100.0f; - if(div==0.0) return; - } + if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) { + ctime = seq->startdisp + cfra; + div = 1.0; + } else { + ctime= cfra; + div= v->length / 100.0f; + if(div==0.0) return; + } - facf = evaluate_fcurve(fcu, ctime / div); - if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) { - facf *= v->length; - } + facf = evaluate_fcurve(fcu, ctime / div); + if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) { + facf *= v->length; + } } if (!fcu) { @@ -3005,16 +3005,16 @@ static void get_default_fac_fade(struct Sequence *seq, int cfra, } static void do_overdrop_effect(Scene *scene, Sequence *seq, int cfra, - float fac, float facf, - int x, int y, struct ImBuf * ibuf1, - struct ImBuf * ibuf2, - struct ImBuf * ibuf3, - struct ImBuf * out) + float fac, float facf, + int x, int y, struct ImBuf * ibuf1, + struct ImBuf * ibuf2, + struct ImBuf * ibuf3, + struct ImBuf * out) { do_drop_effect(scene, seq, cfra, fac, facf, x, y, - ibuf1, ibuf2, ibuf3, out); + ibuf1, ibuf2, ibuf3, out); do_alphaover_effect(scene, seq, cfra, fac, facf, x, y, - ibuf1, ibuf2, ibuf3, out); + ibuf1, ibuf2, ibuf3, out); } static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 1309bdf465b..17f6bd10859 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -426,7 +426,7 @@ void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq) } static void do_seq_count_cb(ListBase *seqbase, int *totseq, - int (*test_func)(Sequence * seq)) + int (*test_func)(Sequence * seq)) { Sequence *seq; @@ -444,7 +444,7 @@ static void do_seq_count_cb(ListBase *seqbase, int *totseq, } static void do_build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int depth, - int (*test_func)(Sequence * seq)) + int (*test_func)(Sequence * seq)) { Sequence *seq; @@ -466,7 +466,7 @@ static void do_build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int depth, } void build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int *totseq, - int (*test_func)(Sequence * seq)) + int (*test_func)(Sequence * seq)) { Sequence **tseqar; @@ -581,7 +581,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) new_tstripdata(seq); if (seq->type != SEQ_SCENE && seq->type != SEQ_META && - seq->type != SEQ_IMAGE) { + seq->type != SEQ_IMAGE) { BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(str, G.sce); } @@ -939,7 +939,7 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se) se3= se->se3; if ( (se1==0 || se2==0 || se3==0) - || (se1->ibuf==0 || se2->ibuf==0 || se3->ibuf==0)) { + || (se1->ibuf==0 || se2->ibuf==0 || se3->ibuf==0)) { make_black_ibuf(se->ibuf); return; } @@ -1056,7 +1056,7 @@ static TStripElem *give_tstripelem(Sequence *seq, int cfra) se = seq->strip->tstripdata; if (se == 0 && seq->len > 0) { se = seq->strip->tstripdata = alloc_tstripdata(seq->len, - "tstripelems"); + "tstripelems"); } nr = give_stripelem_index(seq, cfra); @@ -1074,7 +1074,7 @@ static TStripElem *give_tstripelem(Sequence *seq, int cfra) alpha over mode... */ if (seq->blend_mode != SEQ_BLEND_REPLACE || - (/*seq->ipo && seq->ipo->curve.first &&*/ + (/*seq->ipo && seq->ipo->curve.first &&*/ (!(seq->type & SEQ_EFFECT) || !seq->seq1))) { Strip * s = seq->strip; if (cfra < seq->start) { @@ -1325,7 +1325,7 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in #if 0 static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, - int build_proxy_run, int render_size); + int build_proxy_run, int render_size); static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int render_size) { @@ -1348,7 +1348,7 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re /* that's why it is called custom... */ if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { return; - } + } if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) { return; @@ -1425,7 +1425,7 @@ static void seq_proxy_rebuild(Scene *scene, Sequence * seq) sequential order */ if (seq->flag & SEQ_REVERSE_FRAMES) { for (cfra = seq->enddisp-seq->endstill-1; - cfra >= seq->startdisp + seq->startstill; cfra--) { + cfra >= seq->startdisp + seq->startstill; cfra--) { TStripElem * tse = give_tstripelem(seq, cfra); if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) { @@ -1439,7 +1439,7 @@ static void seq_proxy_rebuild(Scene *scene, Sequence * seq) } } else { for (cfra = seq->startdisp + seq->startstill; - cfra < seq->enddisp - seq->endstill; cfra++) { + cfra < seq->enddisp - seq->endstill; cfra++) { TStripElem * tse = give_tstripelem(seq, cfra); if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) { @@ -1499,12 +1499,12 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) } static void make_cb_table_byte(float lift, float gain, float gamma, - unsigned char * table, float mul) + unsigned char * table, float mul) { int y; for (y = 0; y < 256; y++) { - float v = 1.0 * y / 255; + float v = 1.0 * y / 255; v *= gain; v += lift; v = pow(v, gamma); @@ -1525,7 +1525,7 @@ static void make_cb_table_float(float lift, float gain, float gamma, int y; for (y = 0; y < 256; y++) { - float v = (float) y * 1.0 / 255.0; + float v = (float) y * 1.0 / 255.0; v *= gain; v += lift; v = pow(v, gamma); @@ -1574,7 +1574,7 @@ static void color_balance_byte_float(Sequence * seq, TStripElem* se, float mul) for (c = 0; c < 3; c++) { make_cb_table_float(cb.lift[c], cb.gain[c], cb.gamma[c], - cb_tab[c], mul); + cb_tab[c], mul); } for (i = 0; i < 256; i++) { @@ -1631,8 +1631,8 @@ static void color_balance(Sequence * seq, TStripElem* se, float mul) - Flip X + Flip Y (could be done afterwards, backward compatibility) - Promote image to float data (affects pipeline operations afterwards) - Color balance (is most efficient in the byte -> float - (future: half -> float should also work fine!) - case, if done on load, since we can use lookup tables) + (future: half -> float should also work fine!) + case, if done on load, since we can use lookup tables) - Premultiply */ @@ -1642,13 +1642,13 @@ static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se float mul; if ((seq->flag & SEQ_FILTERY) || - (seq->flag & SEQ_USE_CROP) || - (seq->flag & SEQ_USE_TRANSFORM) || - (seq->flag & SEQ_FLIPX) || - (seq->flag & SEQ_FLIPY) || - (seq->flag & SEQ_USE_COLOR_BALANCE) || - (seq->flag & SEQ_MAKE_PREMUL) || - (se->ibuf->x != seqrectx || se->ibuf->y != seqrecty)) { + (seq->flag & SEQ_USE_CROP) || + (seq->flag & SEQ_USE_TRANSFORM) || + (seq->flag & SEQ_FLIPX) || + (seq->flag & SEQ_FLIPY) || + (seq->flag & SEQ_USE_COLOR_BALANCE) || + (seq->flag & SEQ_MAKE_PREMUL) || + (se->ibuf->x != seqrectx || se->ibuf->y != seqrecty)) { return TRUE; } @@ -1703,8 +1703,8 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf } if (c.top + c.bottom >= se->ibuf->y || - c.left + c.right >= se->ibuf->x || - t.xofs >= dx || t.yofs >= dy) { + c.left + c.right >= se->ibuf->x || + t.xofs >= dx || t.yofs >= dy) { make_black_ibuf(se->ibuf); } else { ImBuf * i; @@ -1716,9 +1716,9 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf } IMB_rectcpy(i, se->ibuf, - t.xofs, t.yofs, - c.left, c.bottom, - sx, sy); + t.xofs, t.yofs, + c.left, c.bottom, + sx, sy); IMB_freeImBuf(se->ibuf); @@ -1783,7 +1783,7 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf if(se->ibuf->x != seqrectx || se->ibuf->y != seqrecty ) { if(scene->r.mode & R_OSA) { IMB_scaleImBuf(se->ibuf, - (short)seqrectx, (short)seqrecty); + (short)seqrectx, (short)seqrecty); } else { IMB_scalefastImBuf(se->ibuf, (short)seqrectx, (short)seqrecty); @@ -1818,14 +1818,14 @@ static void test_and_auto_discard_ibuf_stills(Strip * strip) { if (strip->ibuf_startstill) { if (!strip->ibuf_startstill->rect && - !strip->ibuf_startstill->rect_float) { + !strip->ibuf_startstill->rect_float) { IMB_freeImBuf(strip->ibuf_startstill); strip->ibuf_startstill = 0; } } if (strip->ibuf_endstill) { if (!strip->ibuf_endstill->rect && - !strip->ibuf_endstill->rect_float) { + !strip->ibuf_endstill->rect_float) { IMB_freeImBuf(strip->ibuf_endstill); strip->ibuf_endstill = 0; } @@ -1841,8 +1841,8 @@ static void copy_from_ibuf_still(Sequence * seq, TStripElem * se) se->ibuf = IMB_dupImBuf(seq->strip->ibuf_startstill); } if (se->nr == seq->len - 1 - && (seq->len != 1) - && seq->strip->ibuf_endstill) { + && (seq->len != 1) + && seq->strip->ibuf_endstill) { IMB_cache_limiter_touch(seq->strip->ibuf_endstill); se->ibuf = IMB_dupImBuf(seq->strip->ibuf_endstill); @@ -1938,7 +1938,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, ListBase *seqbasep, int cfra, int chanshown, int render_size); static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, - int build_proxy_run, int render_size) + int build_proxy_run, int render_size) { char name[FILE_MAXDIR+FILE_MAXFILE]; int use_limiter = TRUE; @@ -1973,7 +1973,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int se->ibuf = meta_se->ibuf_comp; if(se->ibuf && (!input_have_to_preprocess(scene, seq, se, cfra) || - build_proxy_run)) { + build_proxy_run)) { IMB_refImBuf(se->ibuf); if (build_proxy_run) { IMB_cache_limiter_unref(se->ibuf); @@ -2021,9 +2021,9 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int do_effect(scene, cfra, seq, se); if (input_have_to_preprocess(scene, seq, se, cfra) && - !build_proxy_run) { + !build_proxy_run) { if ((se->se1 && (se->ibuf == se->se1->ibuf)) || - (se->se2 && (se->ibuf == se->se2->ibuf))) { + (se->se2 && (se->ibuf == se->se2->ibuf))) { struct ImBuf * i = IMB_dupImBuf(se->ibuf); @@ -2087,8 +2087,8 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int se->ibuf = IMB_anim_absolute(seq->anim, se->nr + seq->anim_startofs); /* we don't need both (speed reasons)! */ if (se->ibuf - && se->ibuf->rect_float - && se->ibuf->rect) { + && se->ibuf->rect_float + && se->ibuf->rect) { imb_freerectImBuf(se->ibuf); } @@ -2347,7 +2347,7 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra } if (cfra_left == cfra_right || - (s->flags & SEQ_SPEED_BLEND) == 0) { + (s->flags & SEQ_SPEED_BLEND) == 0) { test_and_auto_discard_ibuf(se); if (se->ibuf == NULL) { @@ -2458,8 +2458,8 @@ static int seq_must_swap_input_in_blend_mode(Sequence * seq) those two effects */ if (seq->blend_mode == SEQ_ALPHAOVER || - seq->blend_mode == SEQ_ALPHAUNDER || - seq->blend_mode == SEQ_OVERDROP) { + seq->blend_mode == SEQ_ALPHAUNDER || + seq->blend_mode == SEQ_OVERDROP) { swap_input = TRUE; } @@ -2495,7 +2495,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, TStripElem* se = 0; count = get_shown_sequences(seqbasep, cfra, chanshown, - (Sequence **)&seq_arr); + (Sequence **)&seq_arr); if (!count) { return 0; @@ -2519,7 +2519,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, if(count == 1) { se = do_build_seq_recursively(scene, seq_arr[0], - cfra, render_size); + cfra, render_size); if (se->ibuf) { se->ibuf_comp = se->ibuf; IMB_refImBuf(se->ibuf_comp); @@ -2632,7 +2632,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, continue; if (se1->ibuf_comp->rect_float || - se2->ibuf->rect_float) { + se2->ibuf->rect_float) { se2->ibuf_comp = IMB_allocImBuf( (short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); @@ -2644,20 +2644,20 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, if (!se1->ibuf_comp->rect_float && - se2->ibuf_comp->rect_float) { + se2->ibuf_comp->rect_float) { IMB_float_from_rect(se1->ibuf_comp); } if (!se2->ibuf->rect_float && - se2->ibuf_comp->rect_float) { + se2->ibuf_comp->rect_float) { IMB_float_from_rect(se2->ibuf); } if (!se1->ibuf_comp->rect && - !se2->ibuf_comp->rect_float) { + !se2->ibuf_comp->rect_float) { IMB_rect_from_float(se1->ibuf_comp); } if (!se2->ibuf->rect && - !se2->ibuf_comp->rect_float) { + !se2->ibuf_comp->rect_float) { IMB_rect_from_float(se2->ibuf); } @@ -2944,8 +2944,8 @@ static void seq_stop_threads() seq_thread_shutdown = TRUE; - pthread_cond_broadcast(&wakeup_cond); - pthread_mutex_unlock(&wakeup_lock); + pthread_cond_broadcast(&wakeup_cond); + pthread_mutex_unlock(&wakeup_lock); for(tslot = running_threads.first; tslot; tslot= tslot->next) { pthread_join(tslot->pthread, NULL); @@ -3043,10 +3043,10 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int for (e = prefetch_done.first; e; e = e->next) { if (cfra == e->cfra && - chanshown == e->chanshown && - rectx == e->rectx && - recty == e->recty && - render_size == e->render_size) { + chanshown == e->chanshown && + rectx == e->rectx && + recty == e->recty && + render_size == e->render_size) { success = TRUE; found_something = TRUE; break; @@ -3056,10 +3056,10 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int if (!e) { for (e = prefetch_wait.first; e; e = e->next) { if (cfra == e->cfra && - chanshown == e->chanshown && - rectx == e->rectx && - recty == e->recty && - render_size == e->render_size) { + chanshown == e->chanshown && + rectx == e->rectx && + recty == e->recty && + render_size == e->render_size) { found_something = TRUE; break; } @@ -3070,13 +3070,13 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int PrefetchThread *tslot; for(tslot = running_threads.first; - tslot; tslot= tslot->next) { + tslot; tslot= tslot->next) { if (tslot->current && - cfra == tslot->current->cfra && - chanshown == tslot->current->chanshown && - rectx == tslot->current->rectx && - recty == tslot->current->recty && - render_size== tslot->current->render_size){ + cfra == tslot->current->cfra && + chanshown == tslot->current->chanshown && + rectx == tslot->current->rectx && + recty == tslot->current->recty && + render_size== tslot->current->render_size){ found_something = TRUE; break; } @@ -3148,19 +3148,19 @@ static void free_imbuf_seq_except(Scene *scene, int cfra) TStripElem * curelem = give_tstripelem(seq, cfra); for(a = 0, se = seq->strip->tstripdata; - a < seq->strip->len && se; a++, se++) { + a < seq->strip->len && se; a++, se++) { if(se != curelem) { free_imbuf_strip_elem(se); } } for(a = 0, se = seq->strip->tstripdata_startstill; - a < seq->strip->startstill && se; a++, se++) { + a < seq->strip->startstill && se; a++, se++) { if(se != curelem) { free_imbuf_strip_elem(se); } } for(a = 0, se = seq->strip->tstripdata_endstill; - a < seq->strip->endstill && se; a++, se++) { + a < seq->strip->endstill && se; a++, se++) { if(se != curelem) { free_imbuf_strip_elem(se); } @@ -3219,15 +3219,15 @@ void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage) for(seq= seqbase->first; seq; seq= seq->next) { if(seq->strip) { for(a = 0, se = seq->strip->tstripdata; - a < seq->strip->len && se; a++, se++) { + a < seq->strip->len && se; a++, se++) { free_imbuf_strip_elem(se); } for(a = 0, se = seq->strip->tstripdata_startstill; - a < seq->strip->startstill && se; a++, se++) { + a < seq->strip->startstill && se; a++, se++) { free_imbuf_strip_elem(se); } for(a = 0, se = seq->strip->tstripdata_endstill; - a < seq->strip->endstill && se; a++, se++) { + a < seq->strip->endstill && se; a++, se++) { free_imbuf_strip_elem(se); } if(seq->strip->ibuf_startstill) { diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 129e39ca588..00e81063760 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1279,11 +1279,11 @@ long long smoke_get_mem_req(int xres, int yres, int zres, int amplify) // print out memory requirements long long int coarseSize = sizeof(float) * totalCells * 22 + - sizeof(unsigned char) * totalCells; + sizeof(unsigned char) * totalCells; long long int fineSize = sizeof(float) * amplifiedCells * 7 + // big grids - sizeof(float) * totalCells * 8 + // small grids - sizeof(float) * 128 * 128 * 128; // noise tile + sizeof(float) * totalCells * 8 + // small grids + sizeof(float) * 128 * 128 * 128; // noise tile long long int totalMB = (coarseSize + fineSize) / (1024 * 1024); @@ -1292,83 +1292,83 @@ long long smoke_get_mem_req(int xres, int yres, int zres, int amplify) static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, float *tRay, bresenham_callback cb, float *result, float *input, int res[3], float correct) { - int dx, dy, dz, i, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2; - int pixel[3]; - - pixel[0] = x1; - pixel[1] = y1; - pixel[2] = z1; - - dx = x2 - x1; - dy = y2 - y1; - dz = z2 - z1; - - x_inc = (dx < 0) ? -1 : 1; - l = abs(dx); - y_inc = (dy < 0) ? -1 : 1; - m = abs(dy); - z_inc = (dz < 0) ? -1 : 1; - n = abs(dz); - dx2 = l << 1; - dy2 = m << 1; - dz2 = n << 1; - - if ((l >= m) && (l >= n)) { - err_1 = dy2 - l; - err_2 = dz2 - l; - for (i = 0; i < l; i++) { - if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) - break; - if (err_1 > 0) { - pixel[1] += y_inc; - err_1 -= dx2; - } - if (err_2 > 0) { - pixel[2] += z_inc; - err_2 -= dx2; - } - err_1 += dy2; - err_2 += dz2; - pixel[0] += x_inc; - } - } else if ((m >= l) && (m >= n)) { - err_1 = dx2 - m; - err_2 = dz2 - m; - for (i = 0; i < m; i++) { - if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) - break; - if (err_1 > 0) { - pixel[0] += x_inc; - err_1 -= dy2; - } - if (err_2 > 0) { - pixel[2] += z_inc; - err_2 -= dy2; - } - err_1 += dx2; - err_2 += dz2; - pixel[1] += y_inc; - } - } else { - err_1 = dy2 - n; - err_2 = dx2 - n; - for (i = 0; i < n; i++) { - if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) - break; - if (err_1 > 0) { - pixel[1] += y_inc; - err_1 -= dz2; - } - if (err_2 > 0) { - pixel[0] += x_inc; - err_2 -= dz2; - } - err_1 += dy2; - err_2 += dx2; - pixel[2] += z_inc; - } - } - cb(result, input, res, pixel, tRay, correct); + int dx, dy, dz, i, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2; + int pixel[3]; + + pixel[0] = x1; + pixel[1] = y1; + pixel[2] = z1; + + dx = x2 - x1; + dy = y2 - y1; + dz = z2 - z1; + + x_inc = (dx < 0) ? -1 : 1; + l = abs(dx); + y_inc = (dy < 0) ? -1 : 1; + m = abs(dy); + z_inc = (dz < 0) ? -1 : 1; + n = abs(dz); + dx2 = l << 1; + dy2 = m << 1; + dz2 = n << 1; + + if ((l >= m) && (l >= n)) { + err_1 = dy2 - l; + err_2 = dz2 - l; + for (i = 0; i < l; i++) { + if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) + break; + if (err_1 > 0) { + pixel[1] += y_inc; + err_1 -= dx2; + } + if (err_2 > 0) { + pixel[2] += z_inc; + err_2 -= dx2; + } + err_1 += dy2; + err_2 += dz2; + pixel[0] += x_inc; + } + } else if ((m >= l) && (m >= n)) { + err_1 = dx2 - m; + err_2 = dz2 - m; + for (i = 0; i < m; i++) { + if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) + break; + if (err_1 > 0) { + pixel[0] += x_inc; + err_1 -= dy2; + } + if (err_2 > 0) { + pixel[2] += z_inc; + err_2 -= dy2; + } + err_1 += dx2; + err_2 += dz2; + pixel[1] += y_inc; + } + } else { + err_1 = dy2 - n; + err_2 = dx2 - n; + for (i = 0; i < n; i++) { + if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) + break; + if (err_1 > 0) { + pixel[1] += y_inc; + err_1 -= dz2; + } + if (err_2 > 0) { + pixel[0] += x_inc; + err_2 -= dz2; + } + err_1 += dy2; + err_2 += dx2; + pixel[2] += z_inc; + } + } + cb(result, input, res, pixel, tRay, correct); } static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int correct) diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 4b19e71dfca..e6f500aab15 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -123,7 +123,7 @@ typedef struct SBScratch { typedef struct SB_thread_context { Scene *scene; - Object *ob; + Object *ob; float forcetime; float timenow; int ifirst; @@ -191,7 +191,7 @@ static float sb_time_scale(Object *ob) /*hrms .. this could be IPO as well :) estimated range [0.001 sluggish slug - 100.0 very fast (i hope ODE solver can handle that)] 1 approx = a unit 1 pendulum at g = 9.8 [earth conditions] has period 65 frames - theory would give a 50 frames period .. so there must be something inaccurate .. looking for that (BM) + theory would give a 50 frames period .. so there must be something inaccurate .. looking for that (BM) */ } return (1.0f); @@ -280,7 +280,7 @@ typedef struct ccd_Mesh { static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) { - ccd_Mesh *pccd_M = NULL; + ccd_Mesh *pccd_M = NULL; ccdf_minmax *mima =NULL; MFace *mface=NULL; float v[3],hull; @@ -299,17 +299,17 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) pccd_M->mprevvert=NULL; - /* blow it up with forcefield ranges */ + /* blow it up with forcefield ranges */ hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft); /* alloc and copy verts*/ pccd_M->mvert = dm->dupVertArray(dm); - /* ah yeah, put the verices to global coords once */ + /* ah yeah, put the verices to global coords once */ /* and determine the ortho BB on the fly */ for(i=0; i < pccd_M->totvert; i++){ mul_m4_v3(ob->obmat, pccd_M->mvert[i].co); - /* evaluate limits */ + /* evaluate limits */ VECCOPY(v,pccd_M->mvert[i].co); pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); @@ -321,10 +321,10 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) } /* alloc and copy faces*/ - pccd_M->mface = dm->dupFaceArray(dm); + pccd_M->mface = dm->dupFaceArray(dm); /* OBBs for idea1 */ - pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax)*pccd_M->totface,"ccd_Mesh_Faces_mima"); + pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax)*pccd_M->totface,"ccd_Mesh_Faces_mima"); mima = pccd_M->mima; mface = pccd_M->mface; @@ -334,7 +334,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) mima->minx=mima->miny=mima->minz=1e30f; mima->maxx=mima->maxy=mima->maxz=-1e30f; - VECCOPY(v,pccd_M->mvert[mface->v1].co); + VECCOPY(v,pccd_M->mvert[mface->v1].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); mima->minz = MIN2(mima->minz,v[2]-hull); @@ -342,7 +342,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - VECCOPY(v,pccd_M->mvert[mface->v2].co); + VECCOPY(v,pccd_M->mvert[mface->v2].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); mima->minz = MIN2(mima->minz,v[2]-hull); @@ -377,7 +377,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) } static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) { - ccdf_minmax *mima =NULL; + ccdf_minmax *mima =NULL; MFace *mface=NULL; float v[3],hull; int i; @@ -393,20 +393,20 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f; - /* blow it up with forcefield ranges */ + /* blow it up with forcefield ranges */ hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft); /* rotate current to previous */ if(pccd_M->mprevvert) MEM_freeN(pccd_M->mprevvert); - pccd_M->mprevvert = pccd_M->mvert; + pccd_M->mprevvert = pccd_M->mvert; /* alloc and copy verts*/ - pccd_M->mvert = dm->dupVertArray(dm); - /* ah yeah, put the verices to global coords once */ + pccd_M->mvert = dm->dupVertArray(dm); + /* ah yeah, put the verices to global coords once */ /* and determine the ortho BB on the fly */ for(i=0; i < pccd_M->totvert; i++){ mul_m4_v3(ob->obmat, pccd_M->mvert[i].co); - /* evaluate limits */ + /* evaluate limits */ VECCOPY(v,pccd_M->mvert[i].co); pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); @@ -416,7 +416,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1],v[1]+hull); pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2],v[2]+hull); - /* evaluate limits */ + /* evaluate limits */ VECCOPY(v,pccd_M->mprevvert[i].co); pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); @@ -437,7 +437,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) mima->minx=mima->miny=mima->minz=1e30f; mima->maxx=mima->maxy=mima->maxz=-1e30f; - VECCOPY(v,pccd_M->mvert[mface->v1].co); + VECCOPY(v,pccd_M->mvert[mface->v1].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); mima->minz = MIN2(mima->minz,v[2]-hull); @@ -445,7 +445,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - VECCOPY(v,pccd_M->mvert[mface->v2].co); + VECCOPY(v,pccd_M->mvert[mface->v2].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); mima->minz = MIN2(mima->minz,v[2]-hull); @@ -472,7 +472,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) } - VECCOPY(v,pccd_M->mprevvert[mface->v1].co); + VECCOPY(v,pccd_M->mprevvert[mface->v1].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); mima->minz = MIN2(mima->minz,v[2]-hull); @@ -480,7 +480,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - VECCOPY(v,pccd_M->mprevvert[mface->v2].co); + VECCOPY(v,pccd_M->mprevvert[mface->v2].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); mima->minz = MIN2(mima->minz,v[2]-hull); @@ -667,7 +667,7 @@ static void add_mesh_quad_diag_springs(Object *ob) } } - /* now we can announce new springs */ + /* now we can announce new springs */ ob->soft->totspring += nofquads *2; } } @@ -703,7 +703,7 @@ static void add_2nd_order_roller(Object *ob,float stiffness,int *counter, int ad } else {printf("oops we should not get here - add_2nd_order_springs");} } - if (bpo){/* so now we have a 2nd order humpdidump */ + if (bpo){/* so now we have a 2nd order humpdidump */ for(c=bpo->nofsprings;c>0;c--){ bs2 = sb->bspring + bpo->springs[c-1]; if ((bs2->v1 != notthis) && (bs2->v1 > v0)){ @@ -711,7 +711,7 @@ static void add_2nd_order_roller(Object *ob,float stiffness,int *counter, int ad if (addsprings){ bs3->v1= v0; bs3->v2= bs2->v1; - bs3->springtype =SB_BEND; + bs3->springtype =SB_BEND; bs3++; } } @@ -720,7 +720,7 @@ static void add_2nd_order_roller(Object *ob,float stiffness,int *counter, int ad if (addsprings){ bs3->v1= v0; bs3->v2= bs2->v2; - bs3->springtype =SB_BEND; + bs3->springtype =SB_BEND; bs3++; } @@ -1039,7 +1039,7 @@ static int sb_detect_aabb_collisionCached( float force[3], unsigned int par_laye hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); - while (!BLI_ghashIterator_isDone(ihash) ) { + while (!BLI_ghashIterator_isDone(ihash) ) { ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash); ob = BLI_ghashIterator_getKey (ihash); @@ -1068,7 +1068,7 @@ static int sb_detect_aabb_collisionCached( float force[3], unsigned int par_laye } /* so now we have the 2 boxes overlapping */ - /* forces actually not used */ + /* forces actually not used */ deflected = 2; } @@ -1114,7 +1114,7 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); - while (!BLI_ghashIterator_isDone(ihash) ) { + while (!BLI_ghashIterator_isDone(ihash) ) { ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash); ob = BLI_ghashIterator_getKey (ihash); @@ -1205,7 +1205,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); - while (!BLI_ghashIterator_isDone(ihash) ) { + while (!BLI_ghashIterator_isDone(ihash) ) { ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash); ob = BLI_ghashIterator_getKey (ihash); @@ -1396,11 +1396,11 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) for(a=0; ascratch->totface; a++, bf++) { if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT)) { - sb->bpoint[bf->v1].choke2=MAX2(sb->bpoint[bf->v1].choke2,choke); - sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke); - sb->bpoint[bf->v3].choke2=MAX2(sb->bpoint[bf->v3].choke2,choke); + sb->bpoint[bf->v1].choke2=MAX2(sb->bpoint[bf->v1].choke2,choke); + sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke); + sb->bpoint[bf->v3].choke2=MAX2(sb->bpoint[bf->v3].choke2,choke); if (bf->v4){ - sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke); + sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke); } } } @@ -1433,7 +1433,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); - while (!BLI_ghashIterator_isDone(ihash) ) { + while (!BLI_ghashIterator_isDone(ihash) ) { ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash); ob = BLI_ghashIterator_getKey (ihash); @@ -1583,7 +1583,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, add_v3_v3v3(bs->ext_force,bs->ext_force,feedback); bs->flag |= BSF_INTERSECT; //bs->cf=damp; - bs->cf=sb->choke*0.01f; + bs->cf=sb->choke*0.01f; } } @@ -1690,8 +1690,8 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow, } else sb_threads[i].ifirst = 0; - sb_threads[i].do_effector = do_effector; - sb_threads[i].do_deflector = 0;// not used here + sb_threads[i].do_effector = do_effector; + sb_threads[i].do_deflector = 0;// not used here sb_threads[i].fieldfactor = 0.0f;// not used here sb_threads[i].windfactor = 0.0f;// not used here sb_threads[i].nr= i; @@ -1707,7 +1707,7 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow, } else exec_scan_for_ext_spring_forces(&sb_threads[0]); - /* clean up */ + /* clean up */ MEM_freeN(sb_threads); pdEndEffectors(&do_effector); @@ -1722,7 +1722,7 @@ static int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,fl int winner =1; mindist = ABS(dot_v3v3(pos,a)); - cp = ABS(dot_v3v3(pos,b)); + cp = ABS(dot_v3v3(pos,b)); if ( mindist < cp ){ mindist = cp; winner =2; @@ -1751,7 +1751,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], GHash *hash; GHashIterator *ihash; float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3],d_nvect[3], dv1[3],ve[3],avel[3]={0.0,0.0,0.0}, - vv1[3], vv2[3], vv3[3], vv4[3], coledge[3]={0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f, + vv1[3], vv2[3], vv3[3], vv4[3], coledge[3]={0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f, outerforceaccu[3],innerforceaccu[3], facedist,n_mag,force_mag_norm,minx,miny,minz,maxx,maxy,maxz, innerfacethickness = -0.5f, outerfacethickness = 0.2f, @@ -1764,7 +1764,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], outerforceaccu[0]=outerforceaccu[1]=outerforceaccu[2]=0.0f; innerforceaccu[0]=innerforceaccu[1]=innerforceaccu[2]=0.0f; /* go */ - while (!BLI_ghashIterator_isDone(ihash) ) { + while (!BLI_ghashIterator_isDone(ihash) ) { ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash); ob = BLI_ghashIterator_getKey (ihash); @@ -1815,7 +1815,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], fa = (ff*outerfacethickness-outerfacethickness); fa *= fa; fa = 1.0f/fa; - avel[0]=avel[1]=avel[2]=0.0f; + avel[0]=avel[1]=avel[2]=0.0f; /* use mesh*/ while (a--) { if ( @@ -1938,7 +1938,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], VECADD(avel,avel,ve); cavel ++; } - *intrusion += facedist; + *intrusion += facedist; ci++; } @@ -1948,7 +1948,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], float dist; closest_to_line_segment_v3(ve, opco, nv1, nv2); - VECSUB(ve,opco,ve); + VECSUB(ve,opco,ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); @@ -1957,7 +1957,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } closest_to_line_segment_v3(ve, opco, nv2, nv3); - VECSUB(ve,opco,ve); + VECSUB(ve,opco,ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); @@ -1966,7 +1966,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } closest_to_line_segment_v3(ve, opco, nv3, nv1); - VECSUB(ve,opco,ve); + VECSUB(ve,opco,ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); @@ -2181,11 +2181,11 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* intitialize */ if (sb) { /* check conditions for various options */ - /* +++ could be done on object level to squeeze out the last bits of it */ + /* +++ could be done on object level to squeeze out the last bits of it */ do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); - /* --- could be done on object level to squeeze out the last bits of it */ + /* --- could be done on object level to squeeze out the last bits of it */ } else { printf("Error expected a SB here \n"); @@ -2207,14 +2207,14 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* naive ball self collision */ /* needs to be done if goal snaps or not */ if(do_selfcollision){ - int attached; + int attached; BodyPoint *obp; BodySpring *bs; int c,b; float velcenter[3],dvel[3],def[3]; float distance; float compare; - float bstune = sb->ballstiff; + float bstune = sb->ballstiff; for(c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) { compare = (obp->colball + bp->colball); @@ -2222,7 +2222,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* rather check the AABBoxes before ever calulating the real distance */ /* mathematically it is completly nuts, but performace is pretty much (3) times faster */ if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue; - distance = normalize_v3(def); + distance = normalize_v3(def); if (distance < compare ){ /* exclude body points attached with a spring */ attached = 0; @@ -2363,7 +2363,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo bp->choke = bs->cf; } - // sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float forcetime,int nl_flags) + // sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float forcetime,int nl_flags) sb_spring_force(ob,ilast-bb,bs,iks,forcetime,0); }/* loop springs */ }/* existing spring list */ @@ -2377,7 +2377,7 @@ return 0; /*done fine*/ static void *exec_softbody_calc_forces(void *data) { SB_thread_context *pctx = (SB_thread_context*)data; - _softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->do_effector,pctx->do_deflector,pctx->fieldfactor,pctx->windfactor); + _softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->do_effector,pctx->do_deflector,pctx->fieldfactor,pctx->windfactor); return 0; } @@ -2398,7 +2398,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t totthread--; } - /* printf("sb_cf_threads_run spawning %d threads \n",totthread); */ + /* printf("sb_cf_threads_run spawning %d threads \n",totthread); */ sb_threads= MEM_callocN(sizeof(SB_thread_context)*totthread, "SBThread"); memset(sb_threads, 0, sizeof(SB_thread_context)*totthread); @@ -2416,8 +2416,8 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t } else sb_threads[i].ifirst = 0; - sb_threads[i].do_effector = do_effector; - sb_threads[i].do_deflector = do_deflector; + sb_threads[i].do_effector = do_effector; + sb_threads[i].do_deflector = do_deflector; sb_threads[i].fieldfactor = fieldfactor; sb_threads[i].windfactor = windfactor; sb_threads[i].nr= i; @@ -2435,7 +2435,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t } else exec_softbody_calc_forces(&sb_threads[0]); - /* clean up */ + /* clean up */ MEM_freeN(sb_threads); } @@ -2904,12 +2904,12 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * float maxerrpos= 0.0f,maxerrvel = 0.0f; int a,fuzzy=0; - forcetime *= sb_time_scale(ob); + forcetime *= sb_time_scale(ob); - aabbmin[0]=aabbmin[1]=aabbmin[2] = 1e20f; - aabbmax[0]=aabbmax[1]=aabbmax[2] = -1e20f; + aabbmin[0]=aabbmin[1]=aabbmin[2] = 1e20f; + aabbmax[0]=aabbmax[1]=aabbmax[2] = -1e20f; - /* old one with homogenous masses */ + /* old one with homogenous masses */ /* claim a minimum mass for vertex */ /* if (sb->nodemass > 0.009999f) timeovermass = forcetime/sb->nodemass; @@ -2920,11 +2920,11 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* now we have individual masses */ /* claim a minimum mass for vertex */ if (_final_mass(ob,bp) > 0.009999f) timeovermass = forcetime/_final_mass(ob,bp); - else timeovermass = forcetime/0.009999f; + else timeovermass = forcetime/0.009999f; if(_final_goal(ob,bp) < SOFTGOALSNAP){ - /* this makes t~ = t */ + /* this makes t~ = t */ if(mid_flags & MID_PRESERVE) VECCOPY(dx,bp->vec); /* so here is (v)' = a(cceleration) = sum(F_springs)/m + gravitation + some friction forces + more forces*/ @@ -2952,7 +2952,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * } else {VECADD(bp->vec, bp->vec, bp->force);} - /* this makes t~ = t+dt */ + /* this makes t~ = t+dt */ if(!(mid_flags & MID_PRESERVE)) VECCOPY(dx,bp->vec); /* so here is (x)'= v(elocity) */ @@ -2969,7 +2969,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * bp->frozen =MIN2(bp->frozen*1.05f,1.0f); } mul_v3_fl(dx,bp->frozen); - */ + */ /* again some nasty if's to have heun in here too */ if (mode ==1){ VECCOPY(bp->prevpos,bp->pos); @@ -3102,12 +3102,12 @@ static void softbody_swap_state(Object *ob,float *ppos,float *pvel) VECCOPY(temp, bp->vec); VECCOPY(bp->vec,pv); - VECCOPY(pv,temp); + VECCOPY(pv,temp); pv+=3; VECCOPY(temp, bp->pos); VECCOPY(bp->pos,pp); - VECCOPY(pp,temp); + VECCOPY(pp,temp); pp+=3; } } @@ -3185,7 +3185,7 @@ static void interpolate_exciter(Object *ob, int timescale, int time) /* ************ convertors ********** */ /* for each object type we need; - - xxxx_to_softbody(Object *ob) : a full (new) copy, creates SB geometry + - xxxx_to_softbody(Object *ob) : a full (new) copy, creates SB geometry */ static void get_scalar_from_vertexgroup(Object *ob, int vertID, short groupindex, float *target) @@ -3294,7 +3294,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) /* this is where '2.5 every thing is animateable' goes wrong in the first place jow_go_for2_5 */ /* 1st coding action to take : move this to frame level */ /* reads: leave the bp->goal as it was read from vertex group / or default .. we will need it at per frame call */ - /* should be fixed for meshes */ + /* should be fixed for meshes */ // bp->goal= sb->mingoal + bp->goal*goalfac; /* do not do here jow_go_for2_5 */ } else{ @@ -3358,7 +3358,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) build_bps_springlist(ob); /* yes we need to do it again*/ } springs_from_mesh(ob); /* write the 'rest'-lenght of the springs */ - if (ob->softflag & OB_SB_SELF) {calculate_collision_balls(ob);} + if (ob->softflag & OB_SB_SELF) {calculate_collision_balls(ob);} } @@ -3515,7 +3515,7 @@ static void lattice_to_softbody(Scene *scene, Object *ob) if (ob->softflag & OB_SB_EDGES){ totspring = ((lt->pntsu -1) * lt->pntsv - + (lt->pntsv -1) * lt->pntsu) * lt->pntsw + + (lt->pntsv -1) * lt->pntsu) * lt->pntsw +lt->pntsu*lt->pntsv*(lt->pntsw -1); if (ob->softflag & OB_SB_QUADS){ totspring += 4*(lt->pntsu -1) * (lt->pntsv -1) * (lt->pntsw-1); @@ -4110,7 +4110,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i if(sb->totpoint==0) { return; } - if(framenr == startframe) { + if(framenr == startframe) { BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); /* first frame, no simulation to do, just set the positions */ diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index c5c3ae0f022..937351b4992 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -374,7 +374,7 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, /* face weighting */ static void calc_ss_weights(int gridFaces, - FaceVertWeight **qweight, FaceVertWeight **tweight) + FaceVertWeight **qweight, FaceVertWeight **tweight) { FaceVertWeight *qw, *tw; int x, y, j; @@ -417,7 +417,7 @@ static void calc_ss_weights(int gridFaces, } static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, - float (*vertexCos)[3], int useFlatSubdiv) + float (*vertexCos)[3], int useFlatSubdiv) { float creaseFactor = (float) ccgSubSurf_getSubdivisionLevels(ss); CCGVertHDL fVerts[4]; @@ -456,10 +456,10 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, float crease; crease = useFlatSubdiv ? creaseFactor : - me->crease * creaseFactor / 255.0f; + me->crease * creaseFactor / 255.0f; ccgSubSurf_syncEdge(ss, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(me->v1), - SET_INT_IN_POINTER(me->v2), crease, &e); + SET_INT_IN_POINTER(me->v2), crease, &e); ((int*)ccgSubSurf_getEdgeUserData(ss, e))[1] = (index)? *index++: i; } @@ -479,7 +479,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, // other parts of code significantly to handle missing faces. // since this really shouldn't even be possible we just bail. if(ccgSubSurf_syncFace(ss, SET_INT_IN_POINTER(i), fVerts[3] ? 4 : 3, - fVerts, &f) == eCCGError_InvalidValue) { + fVerts, &f) == eCCGError_InvalidValue) { static int hasGivenError = 0; if(!hasGivenError) { @@ -852,7 +852,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge) MEdge *med = &medge[i]; if(ccgdm->drawInteriorEdges) - med->flag = ME_EDGEDRAW | ME_EDGERENDER; + med->flag = ME_EDGEDRAW | ME_EDGERENDER; med->v1 = getFaceIndex(ss, f, S, x, 0, edgeSize, gridSize); med->v2 = getFaceIndex(ss, f, S, x + 1, 0, edgeSize, gridSize); i++; @@ -864,20 +864,20 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge) med = &medge[i]; if(ccgdm->drawInteriorEdges) - med->flag = ME_EDGEDRAW | ME_EDGERENDER; + med->flag = ME_EDGEDRAW | ME_EDGERENDER; med->v1 = getFaceIndex(ss, f, S, x, y, - edgeSize, gridSize); + edgeSize, gridSize); med->v2 = getFaceIndex(ss, f, S, x, y + 1, - edgeSize, gridSize); + edgeSize, gridSize); i++; med = &medge[i]; if(ccgdm->drawInteriorEdges) - med->flag = ME_EDGEDRAW | ME_EDGERENDER; + med->flag = ME_EDGEDRAW | ME_EDGERENDER; med->v1 = getFaceIndex(ss, f, S, y, x, - edgeSize, gridSize); + edgeSize, gridSize); med->v2 = getFaceIndex(ss, f, S, y + 1, x, - edgeSize, gridSize); + edgeSize, gridSize); i++; } } @@ -896,7 +896,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge) if(edgeFlags) { if(edgeIdx != -1) { flags |= (edgeFlags[index] & (ME_SEAM | ME_SHARP)) - | ME_EDGEDRAW | ME_EDGERENDER; + | ME_EDGEDRAW | ME_EDGERENDER; } } else { flags |= ME_EDGEDRAW | ME_EDGERENDER; @@ -935,13 +935,13 @@ static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface) for(x = 0; x < gridSize - 1; x++) { MFace *mf = &mface[i]; mf->v1 = getFaceIndex(ss, f, S, x + 0, y + 0, - edgeSize, gridSize); + edgeSize, gridSize); mf->v2 = getFaceIndex(ss, f, S, x + 0, y + 1, - edgeSize, gridSize); + edgeSize, gridSize); mf->v3 = getFaceIndex(ss, f, S, x + 1, y + 1, - edgeSize, gridSize); + edgeSize, gridSize); mf->v4 = getFaceIndex(ss, f, S, x + 1, y + 0, - edgeSize, gridSize); + edgeSize, gridSize); mf->mat_nr = mat_nr; mf->flag = flag; @@ -1767,8 +1767,8 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *u if (draw) { if (draw==2) { - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(stipple_quarttone); + glEnable(GL_POLYGON_STIPPLE); + glPolygonStipple(stipple_quarttone); } for (S=0; Spbvh = BLI_pbvh_new(); BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert, - me->totface, me->totvert); + me->totface, me->totvert); } return ccgdm->pbvh; } static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, - int drawInteriorEdges, - int useSubsurfUv, - DerivedMesh *dm) + int drawInteriorEdges, + int useSubsurfUv, + DerivedMesh *dm) { CCGDerivedMesh *ccgdm = MEM_callocN(sizeof(*ccgdm), "ccgdm"); CCGVertIterator *vi; @@ -2365,7 +2365,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, } DM_interp_vert_data(dm, &ccgdm->dm, vertIdx, weight[0][0], - numVerts, vertNum); + numVerts, vertNum); ++vertNum; for(S = 0; S < numVerts; S++) { @@ -2379,7 +2379,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, w[nextS] = weight[x][0][2]; w[otherS] = weight[x][0][3]; DM_interp_vert_data(dm, &ccgdm->dm, vertIdx, w, - numVerts, vertNum); + numVerts, vertNum); ++vertNum; } } @@ -2396,7 +2396,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, w[nextS] = weight[y * gridFaces + x][0][2]; w[otherS] = weight[y * gridFaces + x][0][3]; DM_interp_vert_data(dm, &ccgdm->dm, vertIdx, w, - numVerts, vertNum); + numVerts, vertNum); ++vertNum; } } @@ -2422,7 +2422,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, } DM_interp_face_data(dm, &ccgdm->dm, &origIndex, NULL, - &w, 1, faceNum); + &w, 1, faceNum); weight++; ++faceNum; @@ -2505,10 +2505,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, /***/ struct DerivedMesh *subsurf_make_derived_from_derived( - struct DerivedMesh *dm, - struct SubsurfModifierData *smd, - int useRenderParams, float (*vertCos)[3], - int isFinalCalc, int editMode) + struct DerivedMesh *dm, + struct SubsurfModifierData *smd, + int useRenderParams, float (*vertCos)[3], + int isFinalCalc, int editMode) { int useSimple = smd->subdivType == ME_SIMPLE_SUBSURF; int useAging = smd->flags & eSubsurfModifierFlag_DebugIncr; @@ -2520,12 +2520,12 @@ struct DerivedMesh *subsurf_make_derived_from_derived( int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels; smd->emCache = _getSubSurf(smd->emCache, levels, useAging, 0, - useSimple); + useSimple); ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple); result = getCCGDerivedMesh(smd->emCache, - drawInteriorEdges, - useSubsurfUv, dm); + drawInteriorEdges, + useSubsurfUv, dm); } else if(useRenderParams) { /* Do not use cache in render mode. */ CCGSubSurf *ss; @@ -2563,13 +2563,13 @@ struct DerivedMesh *subsurf_make_derived_from_derived( if(useIncremental && isFinalCalc) { smd->mCache = ss = _getSubSurf(smd->mCache, levels, - useAging, 0, useSimple); + useAging, 0, useSimple); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); result = getCCGDerivedMesh(smd->mCache, - drawInteriorEdges, - useSubsurfUv, dm); + drawInteriorEdges, + useSubsurfUv, dm); } else { if (smd->mCache && isFinalCalc) { ccgSubSurf_free(smd->mCache); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index a0908529a3a..98ff0b2da1a 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -184,7 +184,7 @@ Text *add_empty_text(char *name) ta->name= NULL; - init_undo_text(ta); + init_undo_text(ta); ta->nlines=1; ta->flags= TXT_ISDIRTY | TXT_ISMEM; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 0a3f46b617e..48f819a7091 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -643,9 +643,9 @@ void make_local_texture(Tex *tex) int a, local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(tex->id.lib==0) return; diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 0ac8b14166d..1e1e41a07e7 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -135,9 +135,9 @@ void make_local_world(World *wrld) int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(wrld->id.lib==0) return; if(wrld->id.us==1) { diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index ccef6832be8..ff6ebcc487f 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -206,7 +206,7 @@ static const char** get_file_extensions(int format) } case FFMPEG_MPEG2: { static const char * rv[] = { ".dvd", ".vob", ".mpg", ".mpeg", - NULL }; + NULL }; return rv; } case FFMPEG_MPEG4: { @@ -271,7 +271,7 @@ static int write_video_frame(RenderData *rd, AVFrame* frame, ReportList *reports } outsize = avcodec_encode_video(c, video_buffer, video_buffersize, - frame); + frame); if (outsize != 0) { AVPacket packet; av_init_packet(&packet); @@ -446,7 +446,7 @@ static void set_ffmpeg_properties(RenderData *rd, AVCodecContext *c, const char /* prepare a video stream for the output file */ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContext* of, - int rectx, int recty) + int rectx, int recty) { AVStream* st; AVCodecContext* c; @@ -552,7 +552,7 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex video_buffersize = 2000000; video_buffer = (uint8_t*)MEM_mallocN(video_buffersize, - "FFMPEG video buffer"); + "FFMPEG video buffer"); current_frame = alloc_picture(c->pix_fmt, c->width, c->height); @@ -1053,7 +1053,7 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int /* not all versions of ffmpeg include that, so here we go ... */ static const AVOption *my_av_find_opt(void *v, const char *name, - const char *unit, int mask, int flags){ + const char *unit, int mask, int flags){ AVClass *c= *(AVClass**)v; const AVOption *o= c->option; diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index d715d18877d..cf3a36419b4 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -201,7 +201,7 @@ static int handle_request(RenderData *rd, char * req) *p = 0; if (strcmp(path, "/index.html") == 0 - || strcmp(path, "/") == 0) { + || strcmp(path, "/") == 0) { safe_puts(index_page); return -1; } @@ -287,7 +287,7 @@ int frameserver_loop(RenderData *rd, ReportList *reports) tv.tv_sec = 10; tv.tv_usec = 0; - rval = select(connsock + 1, &readfds, NULL, NULL, &tv); + rval = select(connsock + 1, &readfds, NULL, NULL, &tv); if (rval > 0) { break; } else if (rval == 0) { -- cgit v1.2.3 From 09b1c681e16575ee82bcc3949728189cb968d927 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 22 Mar 2010 11:59:36 +0000 Subject: Sculpt Mode Bugfixes: * #20833: layer brush doesn't work with multires. * #20946: sculpt mode partially removes parts of the mesh in the viewport. * #20420: grab brush stops after moving some distance. * #20906: sculpt grab tool moves in wrong direction. * #21132 and #21272: undo on object with subdivision surface modifier crashes. * #21115: subsurf + multires + sculpting + undo causes crash. * #20683: sculpt + multires apply + undo crash. * #19094: wrong outline in solid mode. --- source/blender/blenkernel/BKE_DerivedMesh.h | 2 +- source/blender/blenkernel/BKE_paint.h | 7 +++-- source/blender/blenkernel/BKE_subsurf.h | 18 ++++++----- source/blender/blenkernel/intern/DerivedMesh.c | 14 +++++++-- source/blender/blenkernel/intern/cdderivedmesh.c | 20 +++++++++--- source/blender/blenkernel/intern/modifier.c | 5 +-- source/blender/blenkernel/intern/multires.c | 18 +++++++---- source/blender/blenkernel/intern/object.c | 22 +++++++------ source/blender/blenkernel/intern/subsurf_ccg.c | 39 ++++++++++++++++++++---- 9 files changed, 104 insertions(+), 41 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index cb87638af44..965bad31991 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -227,7 +227,7 @@ struct DerivedMesh { * * Also called for *final* editmode DerivedMeshes */ - void (*drawEdges)(DerivedMesh *dm, int drawLooseEdges); + void (*drawEdges)(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges); /* Draw all loose edges (edges w/ no adjoining faces) */ void (*drawLooseEdges)(DerivedMesh *dm); diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 8fd4f079ebf..81fb724b3a5 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -69,13 +69,15 @@ typedef struct SculptSession { struct MFace *mface; int totvert, totface; float *face_normals; - struct PBVH *tree; struct Object *ob; struct KeyBlock *kb, *refkb; /* Mesh connectivity */ struct ListBase *fmap; + /* PBVH acceleration structure */ + struct PBVH *pbvh; + /* Used temporarily per-stroke */ float *vertexcosnos; @@ -87,7 +89,6 @@ typedef struct SculptSession { /* Layer brush persistence between strokes */ float (*layer_co)[3]; /* Copy of the mesh vertices' locations */ - float *layer_disps; /* Displacements for each vertex */ struct SculptStroke *stroke; struct StrokeCache *cache; @@ -95,6 +96,6 @@ typedef struct SculptSession { struct GPUDrawObject *drawobject; } SculptSession; -void free_sculptsession(SculptSession **); +void free_sculptsession(struct Object *ob); #endif diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index fca7c79d96b..853fd99aa86 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -28,19 +28,21 @@ #ifndef BKE_SUBSURF_H #define BKE_SUBSURF_H -struct Mesh; -struct Object; +struct DMGridAdjacency; +struct DMGridData; struct DerivedMesh; struct EditMesh; +struct IndexNode; +struct ListBase; +struct Mesh; struct MultiresSubsurf; +struct Object; +struct PBVH; struct SubsurfModifierData; -struct _CCGSubsurf; -struct _CCGVert; struct _CCGEdge; struct _CCGFace; -struct PBVH; -struct DMGridData; -struct DMGridAdjacency; +struct _CCGSubsurf; +struct _CCGVert; /**************************** External *****************************/ @@ -70,6 +72,8 @@ typedef struct CCGDerivedMesh { char *faceFlags; struct PBVH *pbvh; + struct ListBase *fmap; + struct IndexNode *fmap_mem; struct DMGridData **gridData; struct DMGridAdjacency *gridAdjacency; diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 6908d987a36..9d15ac3f348 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -41,10 +41,11 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" // N_T -#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BLI_math.h" #include "BLI_memarena.h" +#include "BLI_pbvh.h" #include "BKE_cdderivedmesh.h" #include "BKE_displist.h" @@ -509,7 +510,7 @@ static void emDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *us glEnd(); } } -static void emDM_drawEdges(DerivedMesh *dm, int drawLooseEdges) +static void emDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges) { emDM_drawMappedEdges(dm, NULL, NULL); } @@ -2094,6 +2095,15 @@ static void clear_mesh_caches(Object *ob) ob->derivedDeform->release(ob->derivedDeform); ob->derivedDeform= NULL; } + /* we free pbvh on changes, except during sculpt since it can't deal with + changing PVBH node organization, we hope topology does not change in + the meantime .. weak */ + if(ob->sculpt && ob->sculpt->pbvh) { + if(!ob->sculpt->cache) { + BLI_pbvh_free(ob->sculpt->pbvh); + ob->sculpt->pbvh= NULL; + } + } } static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index cca554b5880..6399d55150a 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -39,12 +39,13 @@ #include "BKE_cdderivedmesh.h" #include "BKE_global.h" #include "BKE_mesh.h" +#include "BKE_paint.h" #include "BKE_utildefines.h" -#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" +#include "BLI_math.h" #include "BLI_pbvh.h" #include "DNA_meshdata_types.h" @@ -188,6 +189,16 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + if(!ob) { + cddm->pbvh= NULL; + return NULL; + } + + if(!ob->sculpt) + return NULL; + if(ob->sculpt->pbvh) + cddm->pbvh= ob->sculpt->pbvh; + if(!cddm->pbvh && ob->type == OB_MESH) { Mesh *me= ob->data; @@ -290,7 +301,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) } } -static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges) +static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; MVert *mvert = cddm->mvert; @@ -301,7 +312,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges) DEBUG_VBO( "Using legacy code. cdDM_drawEdges\n" ); glBegin(GL_LINES); for(i = 0; i < dm->numEdgeData; i++, medge++) { - if((medge->flag&ME_EDGEDRAW) + if((drawAllEdges || (medge->flag&ME_EDGEDRAW)) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) { glVertex3fv(mvert[medge->v1].co); glVertex3fv(mvert[medge->v2].co); @@ -317,7 +328,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges) GPU_edge_setup(dm); if( !GPU_buffer_legacy(dm) ) { for(i = 0; i < dm->numEdgeData; i++, medge++) { - if((medge->flag&ME_EDGEDRAW) + if((drawAllEdges || (medge->flag&ME_EDGEDRAW)) && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) { draw = 1; } @@ -1354,7 +1365,6 @@ static void cdDM_foreachMappedFaceCenter( static void cdDM_free_internal(CDDerivedMesh *cddm) { - if(cddm->pbvh) BLI_pbvh_free(cddm->pbvh); if(cddm->fmap) MEM_freeN(cddm->fmap); if(cddm->fmap_mem) MEM_freeN(cddm->fmap_mem); } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index ad1fb80801f..e0aa47eac88 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -68,6 +68,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_scene.h" @@ -9064,10 +9065,10 @@ static DerivedMesh *multiresModifier_applyModifier(ModifierData *md, Object *ob, result->release(result); result= cddm; } - else if(ob->mode & OB_MODE_SCULPT) { + else if((ob->mode & OB_MODE_SCULPT) && ob->sculpt) { /* would be created on the fly too, just nicer this way on first stroke after e.g. switching levels */ - result->getPBVH(ob, result); + ob->sculpt->pbvh= result->getPBVH(ob, result); } return result; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 0d508a4c4d1..c70d12bcb75 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -34,14 +34,15 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_math.h" #include "BLI_pbvh.h" #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_multires.h" +#include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_subsurf.h" #include "BKE_utildefines.h" @@ -109,11 +110,16 @@ void multires_mark_as_modified(Object *ob) void multires_force_update(Object *ob) { - - if(ob && ob->derivedFinal) { - ob->derivedFinal->needsFree =1; - ob->derivedFinal->release(ob->derivedFinal); - ob->derivedFinal = NULL; + if(ob) { + if(ob->derivedFinal) { + ob->derivedFinal->needsFree =1; + ob->derivedFinal->release(ob->derivedFinal); + ob->derivedFinal = NULL; + } + if(ob->sculpt && ob->sculpt->pbvh) { + BLI_pbvh_free(ob->sculpt->pbvh); + ob->sculpt->pbvh= NULL; + } } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index b1cb83c0a51..64abffa5119 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -58,8 +58,9 @@ #include "DNA_world_types.h" #include "BLI_blenlib.h" -#include "BLI_math.h" #include "BLI_editVert.h" +#include "BLI_math.h" +#include "BLI_pbvh.h" #include "BKE_utildefines.h" @@ -231,23 +232,26 @@ void object_free_display(Object *ob) freedisplist(&ob->disp); } -void free_sculptsession(SculptSession **ssp) +void free_sculptsession(Object *ob) { - if(ssp && *ssp) { - SculptSession *ss = *ssp; + if(ob && ob->sculpt) { + SculptSession *ss = ob->sculpt; + DerivedMesh *dm= ob->derivedFinal; + + if(ss->pbvh) + BLI_pbvh_free(ss->pbvh); + if(dm && dm->getPBVH) + dm->getPBVH(NULL, dm); /* signal to clear */ if(ss->texcache) MEM_freeN(ss->texcache); - if(ss->layer_disps) - MEM_freeN(ss->layer_disps); - if(ss->layer_co) MEM_freeN(ss->layer_co); MEM_freeN(ss); - *ssp = NULL; + ob->sculpt = NULL; } } @@ -306,7 +310,7 @@ void free_object(Object *ob) if(ob->bsoft) bsbFree(ob->bsoft); if(ob->gpulamp.first) GPU_lamp_free(ob); - free_sculptsession(&ob->sculpt); + free_sculptsession(ob); if(ob->pc_ids.first) BLI_freelistN(&ob->pc_ids); } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 937351b4992..0cc574984b8 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -42,11 +42,12 @@ #include "DNA_scene_types.h" #include "BKE_cdderivedmesh.h" -#include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_mesh.h" +#include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_subsurf.h" +#include "BKE_utildefines.h" #include "BLI_blenlib.h" #include "BLI_edgehash.h" @@ -1114,7 +1115,7 @@ static void ccgDM_drawVerts(DerivedMesh *dm) { ccgFaceIterator_free(fi); glEnd(); } -static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges) { +static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); @@ -1219,7 +1220,7 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d) static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm) { - if(ccgdm->pbvh) { + if(ccgdm->pbvh && ccgdm->multires.mmd) { CCGFace **faces; int totface; @@ -1935,12 +1936,13 @@ static void ccgDM_release(DerivedMesh *dm) { ccgdm->multires.update(dm); } - if(ccgdm->pbvh) BLI_pbvh_free(ccgdm->pbvh); if(ccgdm->gridFaces) MEM_freeN(ccgdm->gridFaces); if(ccgdm->gridData) MEM_freeN(ccgdm->gridData); if(ccgdm->gridAdjacency) MEM_freeN(ccgdm->gridAdjacency); if(ccgdm->gridOffset) MEM_freeN(ccgdm->gridOffset); if(ccgdm->freeSS) ccgSubSurf_free(ccgdm->ss); + if(ccgdm->fmap) MEM_freeN(ccgdm->fmap); + if(ccgdm->fmap_mem) MEM_freeN(ccgdm->fmap_mem); MEM_freeN(ccgdm->edgeFlags); MEM_freeN(ccgdm->faceFlags); MEM_freeN(ccgdm->vertMap); @@ -2185,11 +2187,35 @@ static int *ccgDM_getGridOffset(DerivedMesh *dm) return ccgdm->gridOffset; } +static ListBase *ccgDM_getFaceMap(Object *ob, DerivedMesh *dm) +{ + CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + + if(!ccgdm->multires.mmd && !ccgdm->fmap && ob->type == OB_MESH) { + Mesh *me= ob->data; + + create_vert_face_map(&ccgdm->fmap, &ccgdm->fmap_mem, me->mface, + me->totvert, me->totface); + } + + return ccgdm->fmap; +} + static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) { CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; int gridSize, numGrids; + if(!ob) { + ccgdm->pbvh= NULL; + return NULL; + } + + if(!ob->sculpt) + return NULL; + if(ob->sculpt->pbvh) + ccgdm->pbvh= ob->sculpt->pbvh; + if(ccgdm->pbvh) return ccgdm->pbvh; @@ -2199,14 +2225,14 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) gridSize = ccgDM_getGridSize(dm); numGrids = ccgDM_getNumGrids(dm); - ccgdm->pbvh = BLI_pbvh_new(); + ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, numGrids, gridSize, (void**)ccgdm->gridFaces); } else if(ob->type == OB_MESH) { Mesh *me= ob->data; - ccgdm->pbvh = BLI_pbvh_new(); + ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert, me->totface, me->totvert); } @@ -2265,6 +2291,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ccgdm->dm.getGridData = ccgDM_getGridData; ccgdm->dm.getGridAdjacency = ccgDM_getGridAdjacency; ccgdm->dm.getGridOffset = ccgDM_getGridOffset; + ccgdm->dm.getFaceMap = ccgDM_getFaceMap; ccgdm->dm.getPBVH = ccgDM_getPBVH; ccgdm->dm.getVertCos = ccgdm_getVertCos; -- cgit v1.2.3 From a3ee78b8850230f61bbcce267115bc1b37a3e642 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Mar 2010 12:09:39 +0000 Subject: Screw Modifier flip the closing edge so when applied a second time it doesnt flip the closing ring of faces. (means you can make a torus from 1 vertex and 2 modifiers) --- source/blender/blenkernel/intern/modifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index e0aa47eac88..b10456c53e0 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -6689,8 +6689,8 @@ static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, if (close) { /* last loop of edges, previous loop dosnt account for the last set of edges */ for (i=0; iv1= i+((steps-1)*totvert); - med_new->v2= i; + med_new->v1= i; + med_new->v2= i+((steps-1)*totvert); med_new->flag= ME_EDGEDRAW|ME_EDGERENDER; med_new++; } -- cgit v1.2.3 From 867cad85b7af1059b79b5ad70b046c3f68f17b69 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 22 Mar 2010 17:12:08 +0000 Subject: Fix for [#21103] Updating bugs in Particle Mode --- source/blender/blenkernel/intern/scene.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 44035afc059..0bce2d004e3 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -424,9 +424,10 @@ Scene *add_scene(char *name) pset->fade_frames= 2; pset->selectmode= SCE_SELECT_PATH; for(a=0; abrush[a].strength= 50; + pset->brush[a].strength= 0.5; pset->brush[a].size= 50; pset->brush[a].step= 10; + pset->brush[a].count= 10; } pset->brush[PE_BRUSH_CUT].strength= 100; -- cgit v1.2.3 From a2778a262b42cc6af2428cbd5196e9163d6673a9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 22 Mar 2010 17:17:36 +0000 Subject: Fix #20548: flat shading not drawing right in sculpt mode. --- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- source/blender/blenkernel/intern/subsurf_ccg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 6399d55150a..b3e702ceee9 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -426,7 +426,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, return; glShadeModel((mface->flag & ME_SMOOTH)? GL_SMOOTH: GL_FLAT); - BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors); + BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, (mface->flag & ME_SMOOTH)); glShadeModel(GL_FLAT); } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 0cc574984b8..9078566f109 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1251,7 +1251,7 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) return; glShadeModel((faceFlags[0] & ME_SMOOTH)? GL_SMOOTH: GL_FLAT); - BLI_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL); + BLI_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL, (faceFlags[0] & ME_SMOOTH)); glShadeModel(GL_FLAT); } -- cgit v1.2.3 From 371732154b39413db0b24a006ae62f5f22e1f39a Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 22 Mar 2010 19:38:40 +0000 Subject: Fix for child drawing bug reported in the comments of [#21103] Updating bugs in Particle Mode --- source/blender/blenkernel/intern/particle.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 48a5c956cc3..bd9e041dab4 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2926,7 +2926,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf ParticleCacheKey *ca, **cache= edit->pathcache; ParticleEditSettings *pset = &scene->toolsettings->particle; - PTCacheEditPoint *point = edit->points; + PTCacheEditPoint *point = NULL; PTCacheEditKey *ekey = NULL; ParticleSystem *psys = edit->psys; @@ -2941,7 +2941,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf float hairmat[4][4], rotmat[3][3], prev_tangent[3]; int k,i; int steps = (int)pow(2.0, (double)pset->draw_step); - int totpart = edit->totpoint; + int totpart = edit->totpoint, recalc_set=0; float sel_col[3]; float nosel_col[3]; @@ -2951,6 +2951,11 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* clear out old and create new empty path cache */ psys_free_path_cache(edit->psys, edit); cache= edit->pathcache= psys_alloc_path_cache_buffers(&edit->pathcachebufs, totpart, steps+1); + + /* set flag for update (child particles check this too) */ + for(i=0, point=edit->points; iflag |= PEP_EDIT_RECALC; + recalc_set = 1; } frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; @@ -2972,7 +2977,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } /*---first main loop: create all actual particles' paths---*/ - for(i=0; ipoints; itotcached && !(point->flag & PEP_EDIT_RECALC)) continue; @@ -3124,6 +3129,12 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf ParticleSimulationData sim = {scene, ob, psys, psys_get_modifier(ob, psys), NULL}; psys_cache_child_paths(&sim, cfra, 1); } + + /* clear recalc flag if set here */ + if(recalc_set) { + for(i=0, point=edit->points; iflag &= ~PEP_EDIT_RECALC; + } } /************************************************/ /* Particle Key handling */ -- cgit v1.2.3 From 4ae515a4e53096df7b0ee27ca57cd148ccbdccd9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 23 Mar 2010 11:59:34 +0000 Subject: Keying Sets: BuiltIn vs Absolute Tweaks This commit clarifies the somewhat "murky" separation between "builtin" and "absolute" KeyingSets as a result of discussions with Cessen. * "Builtin" Keying Sets are now just the Keying Sets which in the past have been known as PyKeyingSets or Relative KeyingSets. These are registered from Py Scripts at startup, and will use the context info to determine what data they should be keyframing. These are stored per Blender session, independent of files, since usually these will be coded specific to sets of rigs used at a studio. * "Absolute" Keying Sets are the ones that you can create from the Scene buttons and/or KKEY or RMB over any property. They specify the exact set of properties which should always get keyframed together. These are stored in the scene. In relation to this, I've made it possible to now set one of the builtin Keying Set types as the active Keying Set. * For now, this can only be done via the box beside the insert/delete key operator buttons on the TimeLine header (now complete with an recycled icon - HINT TO ICON DESIGNERS, to make this a bit more obvious). Later on I'll commit an operator to set this via a hotkey. * The "IKEY" menu will only show up when there is no active Keying Set. When there is one, keying will happen silently (with info notice at the top of the screen). Later on, I'll hook this menu up to a hotkey, so that that active Keying Set can be changed without inserting keyframes or clearing active Keying Set... * By default, there isn't any default Keying Set enabled. IMO, this is probably a good default, though some might like to have LocRotScale instead. * I'm not terribly impressed with the search menu for the items being SORTED (and of all things, alphabetically!) currently, since this does break muscle-memory with the menu (and jumbles up order of closely related vs not closely related). * The Scene buttons for KeyingSets still need some changes to fully cope with users setting builtin KeyingSets as active sometimes. Controls which are useless or shouldn't be used when a builtin set is shown are being shown. Builtin set registrations have been tweaked a bit: * Renamed "bl_idname" to "bl_label" for consistency with rest of API. Note that this is the identifier used by Blender internally when searching for the KeyingSet, and is also what the user sees. --- source/blender/blenkernel/intern/anim_sys.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index a2749a5a457..9fb442f8600 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -769,11 +769,11 @@ static short animsys_remap_path (AnimMapper *remap, char *path, char **dst) /* Write the given value to a setting using RNA, and return success */ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value) { - // printf("%p %s %i %f\n", ptr, path, array_index, value); - PropertyRNA *prop; PointerRNA new_ptr; + //printf("%p %s %i %f\n", ptr, path, array_index, value); + /* get property to write to */ if (RNA_path_resolve(ptr, path, &new_ptr, &prop)) { @@ -781,7 +781,7 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i if (RNA_property_animateable(&new_ptr, prop)) { int array_len= RNA_property_array_length(&new_ptr, prop); - + if(array_len && array_index >= array_len) { if (G.f & G_DEBUG) { @@ -789,10 +789,10 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "", path, array_index, array_len-1); } - + return 0; } - + switch (RNA_property_type(prop)) { case PROP_BOOLEAN: @@ -1003,7 +1003,12 @@ static void nlastrip_evaluate_controls (NlaStrip *strip, float ctime) animsys_evaluate_fcurves(&strip_ptr, &strip->fcurves, NULL, ctime); } - if (strip->flag & NLASTRIP_FLAG_USR_TIME && strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC) + /* if user can control the evaluation time (using F-Curves), consider the option which allows this time to be clamped + * to lie within extents of the action-clip, so that a steady changing rate of progress through several cycles of the clip + * can be achieved easily + */ + // NOTE: if we add any more of these special cases, we better group them up nicely... + if ((strip->flag & NLASTRIP_FLAG_USR_TIME) && (strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC)) strip->strip_time= fmod(strip->strip_time - strip->actstart, strip->actend - strip->actstart); } @@ -1740,7 +1745,7 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re */ // TODO: need to double check that this all works correctly if ((recalc & ADT_RECALC_ANIM) || (adt->recalc & ADT_RECALC_ANIM)) - { + { /* evaluate NLA data */ if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF)) { -- cgit v1.2.3 From 9ca5243df8f97907145298b357403ffa1edcac8a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 23 Mar 2010 15:34:07 +0000 Subject: workaround for compositor threading copying actions every time. (commit 27684 by Campbell from render25 branch) --- source/blender/blenkernel/intern/node.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 98db81d90d0..3ac8f565003 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2519,10 +2519,39 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) /* local tree then owns all compbufs */ bNodeTree *ntreeLocalize(bNodeTree *ntree) { - bNodeTree *ltree= ntreeCopyTree(ntree, 0); + bNodeTree *ltree; bNode *node; bNodeSocket *sock; + bAction *action_backup= NULL, *tmpact_backup= NULL; + + /* Workaround for copying an action on each render! + * set action to NULL so animdata actions dont get copied */ + AnimData *adt= BKE_animdata_from_id(&ntree->id); + + if(adt) { + action_backup= adt->action; + tmpact_backup= adt->tmpact; + + adt->action= NULL; + adt->tmpact= NULL; + } + + /* node copy func */ + ltree= ntreeCopyTree(ntree, 0); + + if(adt) { + AnimData *ladt= BKE_animdata_from_id(<ree->id); + + ladt->action = action_backup; + ladt->tmpact = tmpact_backup; + + if(action_backup) action_backup->id.us++; + if(tmpact_backup) tmpact_backup->id.us++; + + } + /* end animdata uglyness */ + /* move over the compbufs */ /* right after ntreeCopyTree() oldsock pointers are valid */ for(node= ntree->nodes.first; node; node= node->next) { -- cgit v1.2.3 From 083b11f3c378f3246758f0788d06197a0ae25ff6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 23 Mar 2010 16:17:27 +0000 Subject: fix for mistake in own recent commit. (commit 27690 by Campbell from render25 branch) --- source/blender/blenkernel/intern/node.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 3ac8f565003..5bd9694e768 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2543,8 +2543,8 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) if(adt) { AnimData *ladt= BKE_animdata_from_id(<ree->id); - ladt->action = action_backup; - ladt->tmpact = tmpact_backup; + adt->action= ladt->action= action_backup; + adt->tmpact= ladt->tmpact= tmpact_backup; if(action_backup) action_backup->id.us++; if(tmpact_backup) tmpact_backup->id.us++; -- cgit v1.2.3 From c76a069bd16fe580ebb741493918a9793718f999 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Mar 2010 20:04:05 +0000 Subject: Panorama camera support for UV project modifier --- source/blender/blenkernel/intern/modifier.c | 139 ++++++++++++++++++---------- 1 file changed, 88 insertions(+), 51 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index b10456c53e0..8739a9c8b48 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -42,6 +42,7 @@ #include "BLI_kdtree.h" #include "BLI_rand.h" +#include "BLI_uvproject.h" #include "MEM_guardedalloc.h" @@ -3673,6 +3674,7 @@ typedef struct Projector { Object *ob; /* object this projector is derived from */ float projmat[4][4]; /* projection matrix */ float normal[3]; /* projector normal in world space */ + void *uci; /* optional uv-project info (panorama projection) */ } Projector; static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, @@ -3688,9 +3690,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, int num_projectors = 0; float aspect; char uvname[32]; + float aspx= umd->aspectx ? 1.0f : umd->aspectx; + float aspy= umd->aspecty ? 1.0f : umd->aspecty; + int free_uci= 0; - if(umd->aspecty != 0) aspect = umd->aspectx / umd->aspecty; - else aspect = 1.0f; + aspect = aspx / aspy; for(i = 0; i < umd->num_projectors; ++i) if(umd->projectors[i]) @@ -3705,20 +3709,6 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* make sure we're using an existing layer */ validate_layer_name(&dm->faceData, CD_MTFACE, umd->uvlayer_name, uvname); - /* make sure we are not modifying the original UV layer */ - tface = CustomData_duplicate_referenced_layer_named(&dm->faceData, - CD_MTFACE, uvname); - - numVerts = dm->getNumVerts(dm); - - coords = MEM_callocN(sizeof(*coords) * numVerts, - "uvprojectModifier_do coords"); - dm->getVertCos(dm, coords); - - /* convert coords to world space */ - for(i = 0, co = coords; i < numVerts; ++i, ++co) - mul_m4_v3(ob->obmat, *co); - /* calculate a projection matrix and normal for each projector */ for(i = 0; i < num_projectors; ++i) { float tmpmat[4][4]; @@ -3729,7 +3719,13 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, if(projectors[i].ob->type == OB_CAMERA) { cam = (Camera *)projectors[i].ob->data; - if(cam->type == CAM_PERSP) { + projectors[i].uci= NULL; + + if(cam->flag & CAM_PANORAMA) { + projectors[i].uci= project_camera_info(projectors[i].ob, NULL, aspx, aspy); + free_uci= 1; + } + else if(cam->type == CAM_PERSP) { float perspmat[4][4]; float xmax; float xmin; @@ -3778,15 +3774,15 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, offsetmat[3][0] = offsetmat[3][1] = offsetmat[3][2] = 0.5; if (cam) { - if (umd->aspectx == umd->aspecty) { + if (aspx == aspy) { offsetmat[3][0] -= cam->shiftx; offsetmat[3][1] -= cam->shifty; - } else if (umd->aspectx < umd->aspecty) { - offsetmat[3][0] -=(cam->shiftx * umd->aspecty/umd->aspectx); + } else if (aspx < aspy) { + offsetmat[3][0] -=(cam->shiftx * aspy/aspx); offsetmat[3][1] -= cam->shifty; } else { offsetmat[3][0] -= cam->shiftx; - offsetmat[3][1] -=(cam->shifty * umd->aspectx/umd->aspecty); + offsetmat[3][1] -=(cam->shifty * aspx/aspy); } } @@ -3799,8 +3795,23 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal); } + /* make sure we are not modifying the original UV layer */ + tface = CustomData_duplicate_referenced_layer_named(&dm->faceData, + CD_MTFACE, uvname); + + + numVerts = dm->getNumVerts(dm); + + coords = MEM_callocN(sizeof(*coords) * numVerts, + "uvprojectModifier_do coords"); + dm->getVertCos(dm, coords); + + /* convert coords to world space */ + for(i = 0, co = coords; i < numVerts; ++i, ++co) + mul_m4_v3(ob->obmat, *co); + /* if only one projector, project coords to UVs */ - if(num_projectors == 1) + if(num_projectors == 1 && projectors[0].uci==NULL) for(i = 0, co = coords; i < numVerts; ++i, ++co) mul_project_m4_v4(projectors[0].projmat, *co); @@ -3810,17 +3821,26 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* apply coords as UVs, and apply image if tfaces are new */ for(i = 0, mf = mface; i < numFaces; ++i, ++mf, ++tface) { if(override_image || !image || tface->tpage == image) { - if(num_projectors == 1) { - /* apply transformed coords as UVs */ - tface->uv[0][0] = coords[mf->v1][0]; - tface->uv[0][1] = coords[mf->v1][1]; - tface->uv[1][0] = coords[mf->v2][0]; - tface->uv[1][1] = coords[mf->v2][1]; - tface->uv[2][0] = coords[mf->v3][0]; - tface->uv[2][1] = coords[mf->v3][1]; - if(mf->v4) { - tface->uv[3][0] = coords[mf->v4][0]; - tface->uv[3][1] = coords[mf->v4][1]; + if(num_projectors == 1) { + if(projectors[0].uci) { + project_from_camera(tface->uv[0], coords[mf->v1], projectors[0].uci); + project_from_camera(tface->uv[1], coords[mf->v2], projectors[0].uci); + 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); + } + else { + /* apply transformed coords as UVs */ + tface->uv[0][0] = coords[mf->v1][0]; + tface->uv[0][1] = coords[mf->v1][1]; + tface->uv[1][0] = coords[mf->v2][0]; + tface->uv[1][1] = coords[mf->v2][1]; + tface->uv[2][0] = coords[mf->v3][0]; + tface->uv[2][1] = coords[mf->v3][1]; + if(mf->v4) { + tface->uv[3][0] = coords[mf->v4][0]; + tface->uv[3][1] = coords[mf->v4][1]; + } } } else { /* multiple projectors, select the closest to face normal @@ -3858,23 +3878,32 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, best_projector = &projectors[j]; } } - - mul_project_m4_v4(best_projector->projmat, co1); - mul_project_m4_v4(best_projector->projmat, co2); - mul_project_m4_v4(best_projector->projmat, co3); - if(mf->v4) - mul_project_m4_v4(best_projector->projmat, co4); - - /* apply transformed coords as UVs */ - tface->uv[0][0] = co1[0]; - tface->uv[0][1] = co1[1]; - tface->uv[1][0] = co2[0]; - tface->uv[1][1] = co2[1]; - tface->uv[2][0] = co3[0]; - tface->uv[2][1] = co3[1]; - if(mf->v4) { - tface->uv[3][0] = co4[0]; - tface->uv[3][1] = co4[1]; + + if(best_projector->uci) { + project_from_camera(tface->uv[0], coords[mf->v1], best_projector->uci); + project_from_camera(tface->uv[1], coords[mf->v2], best_projector->uci); + project_from_camera(tface->uv[2], coords[mf->v3], best_projector->uci); + if(mf->v3) + project_from_camera(tface->uv[3], coords[mf->v4], best_projector->uci); + } + else { + mul_project_m4_v4(best_projector->projmat, co1); + mul_project_m4_v4(best_projector->projmat, co2); + mul_project_m4_v4(best_projector->projmat, co3); + if(mf->v4) + mul_project_m4_v4(best_projector->projmat, co4); + + /* apply transformed coords as UVs */ + tface->uv[0][0] = co1[0]; + tface->uv[0][1] = co1[1]; + tface->uv[1][0] = co2[0]; + tface->uv[1][1] = co2[1]; + tface->uv[2][0] = co3[0]; + tface->uv[2][1] = co3[1]; + if(mf->v4) { + tface->uv[3][0] = co4[0]; + tface->uv[3][1] = co4[1]; + } } } } @@ -3886,7 +3915,15 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } MEM_freeN(coords); - + + if(free_uci) { + int j; + for(j = 0; j < num_projectors; ++j) { + if(projectors[j].uci) { + MEM_freeN(projectors[j].uci); + } + } + } return dm; } -- cgit v1.2.3 From 8456995181a22ec0ba2a0dc55588c4646423f57b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Mar 2010 16:20:13 +0000 Subject: xaspect and yaspect were not working with uv project modifier & panorama, also removed some includes. --- source/blender/blenkernel/intern/modifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 8739a9c8b48..7be0cb3e3ed 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -3690,8 +3690,8 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, int num_projectors = 0; float aspect; char uvname[32]; - float aspx= umd->aspectx ? 1.0f : umd->aspectx; - float aspy= umd->aspecty ? 1.0f : umd->aspecty; + float aspx= umd->aspectx ? umd->aspectx : 1.0f; + float aspy= umd->aspecty ? umd->aspecty : 1.0f; int free_uci= 0; aspect = aspx / aspy; -- cgit v1.2.3 From 78e282fdf1330ebe1f980725d3e3154fa1abd5c5 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 25 Mar 2010 00:10:41 +0000 Subject: Patch from Francois Tarlier: extend colour balance node 'lift' value to 0.0-2.0 range (default 1.0), like the other controls. Thanks! --- 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 b9576c343db..6b656f1d12e 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 0 +#define BLENDER_SUBVERSION 1 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 -- cgit v1.2.3 From 33f880e8666e9bb0ed954fccb82bc23255a97868 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 25 Mar 2010 06:27:25 +0000 Subject: Restored Fluid Sim baking This commit restores fluid sim baking functionality in 2.5, it's been on the todo for a while, and was previously almost completely non-functional. The old code was quite complicated and specific to the 2.4 animation system, so I've pretty much rewritten most of it. This includes: * Animated variables work again - just key them in the UI. Non-animateable values should be already set non-animateable in RNA, hopefully I got them all. Available are: Domain Gravity / Domain Viscosity / Object loc/rot/scale / Object initial velocity / Deforming meshes / Fluid control Attract strength / Fluid control Attract radius / Fluid control Velocity strength / Fluid control Velocity radius / Object Active status (checkbox next to fluid type) The Domain time scale is still not yet implemented. * Fluid sim now use global scene units data by default - when enabled, the scene's global gravity value is used and when units are set (metric/imperial) the simulation real world size is taken from the object's actual measurements. * The baking process is now done in the background, using the nifty threaded Jobs system. It's non-blocking and your domain object will show the simulated fluid as it becomes available for that frame. A nice extra thing for the future would be to improve the visualisation of the object's state while baking, and also the jobs system/ui could do with some touchups - currently it has to share a bit from the 'render' job, and appears as 'Render' in the header. Progress bars for jobs in the header would be great too. --- source/blender/blenkernel/BKE_object.h | 2 ++ source/blender/blenkernel/intern/fluidsim.c | 2 +- source/blender/blenkernel/intern/object.c | 38 +++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 1362a191919..84995b60f4b 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -111,6 +111,8 @@ void where_is_object_simul(struct Scene *scene, struct Object *ob); struct BoundBox *unit_boundbox(void); void boundbox_set_from_min_max(struct BoundBox *bb, float min[3], float max[3]); struct BoundBox *object_get_boundbox(struct Object *ob); +void object_get_dimensions(struct Object *ob, float *value); +void object_set_dimensions(struct Object *ob, const float *value); void object_boundbox_flag(struct Object *ob, int flag, int set); void minmax_object(struct Object *ob, float *min, float *max); int minmax_object_duplis(struct Scene *scene, struct Object *ob, float *min, float *max); diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index fe0f52e9b00..118a44507c9 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -148,7 +148,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->lastgoodframe = -1; - fss->flag = 0; + fss->flag |= OB_FLUIDSIM_ACTIVE; } #endif diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 64abffa5119..e4350cfde7f 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2305,6 +2305,44 @@ void object_boundbox_flag(Object *ob, int flag, int set) } } +void object_get_dimensions(Object *ob, float *value) +{ + BoundBox *bb = NULL; + + bb= object_get_boundbox(ob); + if (bb) { + float scale[3]; + + mat4_to_size( scale,ob->obmat); + + value[0] = fabs(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]); + value[1] = fabs(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]); + value[2] = fabs(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]); + } else { + value[0] = value[1] = value[2] = 0.f; + } +} + +void object_set_dimensions(Object *ob, const float *value) +{ + BoundBox *bb = NULL; + + bb= object_get_boundbox(ob); + if (bb) { + float scale[3], len[3]; + + mat4_to_size( scale,ob->obmat); + + len[0] = bb->vec[4][0] - bb->vec[0][0]; + len[1] = bb->vec[2][1] - bb->vec[0][1]; + len[2] = bb->vec[1][2] - bb->vec[0][2]; + + if (len[0] > 0.f) ob->size[0] = value[0] / len[0]; + if (len[1] > 0.f) ob->size[1] = value[1] / len[1]; + if (len[2] > 0.f) ob->size[2] = value[2] / len[2]; + } +} + void minmax_object(Object *ob, float *min, float *max) { BoundBox bb; -- cgit v1.2.3 From 57b2ea62ab6f2f8e6dbd8cd51be0ef93b65ef34a Mon Sep 17 00:00:00 2001 From: Elia Sarti Date: Thu, 25 Mar 2010 10:43:55 +0000 Subject: Remove object type check in Cast Modifier deformation, was wrong now that Curves support modifiers. Also fixes [#21742] Crashes when adding a Cast mod after a Screw mod on a Curve Object --- source/blender/blenkernel/intern/modifier.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 7be0cb3e3ed..5cda09cad85 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -4816,11 +4816,7 @@ static void castModifier_deformVerts( DerivedMesh *dm = NULL; CastModifierData *cmd = (CastModifierData *)md; - if (ob->type == OB_MESH) { - /* DerivedMesh is used only in case object is MESH */ - /* so we could optimize modifier applying by skipping DM creation */ - dm = get_dm(md->scene, ob, NULL, derivedData, NULL, 0); - } + dm = get_dm(md->scene, ob, NULL, derivedData, NULL, 0); if (cmd->type == MOD_CAST_TYPE_CUBOID) { castModifier_cuboid_do(cmd, ob, dm, vertexCos, numVerts); -- cgit v1.2.3 From 535bce8cf1fd581ff450069a57612b3ed4ccfec2 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 25 Mar 2010 11:42:02 +0000 Subject: Adding menu entries for the new hotkeys (change keying set) --- source/blender/blenkernel/intern/nla.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 56da45ed19a..4af007a5f91 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -44,6 +44,7 @@ #include "BKE_fcurve.h" #include "BKE_nla.h" #include "BKE_library.h" +#include "BKE_utildefines.h" #include "RNA_access.h" #include "nla_private.h" -- cgit v1.2.3 From 66efe00d4d3f993e12a4188b2e1d622ea1231e74 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 25 Mar 2010 18:41:57 +0000 Subject: Fix #21761: Curve+"Fill deformed"+modifier ( not all)= not rendered Incorrect displist base was passed to curve_to_filledpoly(). --- source/blender/blenkernel/intern/displist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 8619b6ec87d..3480564e00e 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1365,7 +1365,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } } else { if (ELEM(ob->type, OB_CURVE, OB_FONT) && (cu->flag & CU_DEFORM_FILL)) { - curve_to_filledpoly(cu, nurb, &cu->disp); + curve_to_filledpoly(cu, nurb, dispbase); } dm= CDDM_from_curve_customDB(ob, dispbase); -- cgit v1.2.3 From fedabce47c193926eb0c845a305a62bc73d8d6ce Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 26 Mar 2010 01:11:03 +0000 Subject: Bugfix #21757: Crash when setting up cyclic tracking dependencies (with old tracking) Note that users should not be doing this anyway (and to some degree, I wish that they have to learn this the hard way - i.e. a crash as was before) since it is always bound to cause troubles of various sorts. Having said this, the old tracking code was previously crashing if this sort of setup was created since a stack overflow would happen while bouncing between each object being recursively recalculated. I've fixed this by commenting out that recursive recalculation (solving the cyclic problems for n >= 2, while n=1 should still be fine without this pre-depsgraph hack), and also removing such cyclic dependencies in the n=2 case. (PS: Perhaps this is just a good opportunity to just remove this old feature instead ;) --- source/blender/blenkernel/intern/object.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e4350cfde7f..2026bb3da6e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2039,8 +2039,27 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) /* Handle tracking */ if(ob->track) { - if( ctime != ob->track->ctime) where_is_object_time(scene, ob->track, ctime); - solve_tracking (ob, ob->track->obmat); + /* Try to remove this tracking relationship if we can easily detect that + * it is cyclic (i.e. direct tracking), and bound to cause us troubles. + * For the other cases (i.e. a cyclic triangle, and higher orders), we can't + * easily detect or know how to remove those relationships, safely, so just + * let them be (with warnings). + * Of course, this could also be a simple track that doesn't do anything bad either :) + */ + if (ob->track->track == ob) { + printf("Removed direct cyclic tracking between %s and %s\n", ob->id.name+2, ob->track->id.name+2); + ob->track->track = NULL; + ob->track = NULL; + } + else { + /* NOTE: disabled recursive recalc for tracking for now, since this causes crashes + * when users create cyclic dependencies (stack overflow). Really, this step ought + * not to be needed anymore with the depsgraph, though this may not be the case. + * -- Aligorith, 2010 Mar 26 + */ + //if( ctime != ob->track->ctime) where_is_object_time(scene, ob->track, ctime); + solve_tracking(ob, ob->track->obmat); + } } /* solve constraints */ -- cgit v1.2.3 From 3c872daa59774abaf3f53acaa2baf876e54308a5 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 26 Mar 2010 02:57:49 +0000 Subject: 4 Devs in Agreement - End of the Road for Old Track This commit removes the Old Track method (used to be found under Object -> Animation -> Track), with all existing instances of this being converted to Track To Constraints. In fact, while performing this removal, I found that this was supposed to have happened in version 2.27 already, but for some reason the options were left in, and this function managed to survive for a further decade. I've left the tracking axes around still, since it seems some curve tools still use that. However, that usage should probably get faded out in future too? Misc notes: * Fixed compiling error with constaints from harkyman's Maintain Volume patch. * Subversion of 2.52 now bumped up to .2 --- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenkernel/intern/action.c | 1 - source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/constraint.c | 3 +- source/blender/blenkernel/intern/depsgraph.c | 5 -- source/blender/blenkernel/intern/object.c | 71 --------------------------- 6 files changed, 3 insertions(+), 81 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 6b656f1d12e..8865757b85a 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 1 +#define BLENDER_SUBVERSION 2 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index afd0b3a0f57..52f59c1681a 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1063,7 +1063,6 @@ void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose, copy_m4_m4(workob->parentinv, ob->parentinv); copy_m4_m4(workob->constinv, ob->constinv); workob->parent= ob->parent; - workob->track= ob->track; workob->rotmode= ob->rotmode; diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index b2ac32da138..1465f4550f5 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -668,7 +668,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, if(level>MAX_DUPLI_RECUR) return; cfrao= scene->r.cfra; - if(ob->parent==NULL && ob->track==NULL && ob->ipo==NULL && ob->constraints.first==NULL) return; + if(ob->parent==NULL && ob->constraints.first==NULL) return; if(ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0; copyob= *ob; /* store transform info */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 3ab5e9442b4..7994849a469 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1867,7 +1867,7 @@ static void samevolume_new_data (void *cdata) data->volume = 1.0f; } -static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob) +static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) { bSameVolumeConstraint *data= con->data; @@ -1896,7 +1896,6 @@ static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob) } break; } - } static bConstraintTypeInfo CTI_SAMEVOL = { diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 4e0270315ad..86cafa733ff 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -468,11 +468,6 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O addtoroot = 0; } - if (ob->track) { - node2 = dag_get_node(dag,ob->track); - dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Track To"); - addtoroot = 0; - } if (ob->proxy) { node2 = dag_get_node(dag, ob->proxy); dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Proxy"); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 2026bb3da6e..b9e4894a868 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -361,11 +361,6 @@ void unlink_object(Scene *scene, Object *ob) obt->recalc |= OB_RECALC; } - if(obt->track==ob) { - obt->track= NULL; - obt->recalc |= OB_RECALC_OB; - } - modifiers_foreachObjectLink(obt, unlink_object__unlinkModifierLinks, ob); if ELEM(obt->type, OB_CURVE, OB_FONT) { @@ -2037,31 +2032,6 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) object_to_mat4(ob, ob->obmat); } - /* Handle tracking */ - if(ob->track) { - /* Try to remove this tracking relationship if we can easily detect that - * it is cyclic (i.e. direct tracking), and bound to cause us troubles. - * For the other cases (i.e. a cyclic triangle, and higher orders), we can't - * easily detect or know how to remove those relationships, safely, so just - * let them be (with warnings). - * Of course, this could also be a simple track that doesn't do anything bad either :) - */ - if (ob->track->track == ob) { - printf("Removed direct cyclic tracking between %s and %s\n", ob->id.name+2, ob->track->id.name+2); - ob->track->track = NULL; - ob->track = NULL; - } - else { - /* NOTE: disabled recursive recalc for tracking for now, since this causes crashes - * when users create cyclic dependencies (stack overflow). Really, this step ought - * not to be needed anymore with the depsgraph, though this may not be the case. - * -- Aligorith, 2010 Mar 26 - */ - //if( ctime != ob->track->ctime) where_is_object_time(scene, ob->track, ctime); - solve_tracking(ob, ob->track->obmat); - } - } - /* solve constraints */ if (ob->constraints.first && !(ob->flag & OB_NO_CONSTRAINTS)) { bConstraintOb *cob; @@ -2156,33 +2126,6 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ } } -} -void solve_tracking (Object *ob, float targetmat[][4]) -{ - float quat[4]; - float vec[3]; - float totmat[3][3]; - float tmat[4][4]; - - sub_v3_v3v3(vec, ob->obmat[3], targetmat[3]); - vec_to_quat( quat,vec, ob->trackflag, ob->upflag); - quat_to_mat3( totmat,quat); - - if(ob->parent && (ob->transflag & OB_POWERTRACK)) { - /* 'temporal' : clear parent info */ - object_to_mat4(ob, tmat); - tmat[0][3]= ob->obmat[0][3]; - tmat[1][3]= ob->obmat[1][3]; - tmat[2][3]= ob->obmat[2][3]; - tmat[3][0]= ob->obmat[3][0]; - tmat[3][1]= ob->obmat[3][1]; - tmat[3][2]= ob->obmat[3][2]; - tmat[3][3]= ob->obmat[3][3]; - } - else copy_m4_m4(tmat, ob->obmat); - - mul_m4_m3m4(ob->obmat, totmat, tmat); - } void where_is_object(struct Scene *scene, Object *ob) @@ -2204,12 +2147,6 @@ for a lamp that is the child of another object */ int a; /* NO TIMEOFFS */ - - /* no ipo! (because of dloc and realtime-ipos) */ - // XXX old animation system - //ipo= ob->ipo; - //ob->ipo= NULL; - if(ob->parent) { par= ob->parent; @@ -2231,9 +2168,6 @@ for a lamp that is the child of another object */ object_to_mat4(ob, ob->obmat); } - if(ob->track) - solve_tracking(ob, ob->track->obmat); - /* solve constraints */ if (ob->constraints.first) { bConstraintOb *cob; @@ -2242,10 +2176,6 @@ for a lamp that is the child of another object */ solve_constraints(&ob->constraints, cob, (float)scene->r.cfra); constraints_clear_evalob(cob); } - - /* WATCH IT!!! */ - // XXX old animation system - //ob->ipo= ipo; } /* for calculation of the inverse parent transform, only used for editor */ @@ -2257,7 +2187,6 @@ void what_does_parent(Scene *scene, Object *ob, Object *workob) unit_m4(workob->parentinv); unit_m4(workob->constinv); workob->parent= ob->parent; - workob->track= ob->track; workob->trackflag= ob->trackflag; workob->upflag= ob->upflag; -- cgit v1.2.3 From 386e97f73a891f7162cc578d05cf5720ef51df14 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 26 Mar 2010 03:10:58 +0000 Subject: Purging compiler warnings --- source/blender/blenkernel/intern/pointcache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 9f0c7289350..cbe294f1347 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1687,7 +1687,7 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) return 0; if(cache->flag & PTCACHE_DISK_CACHE) { - int ofra, efra = cache->endframe; + int ofra=0, efra = cache->endframe; if(cfra==0) add = 1; @@ -2871,4 +2871,5 @@ void BKE_ptcache_invalidate(PointCache *cache) cache->flag &= ~PTCACHE_SIMULATION_VALID; cache->simframe = 0; cache->last_exact = 0; -} \ No newline at end of file +} + -- cgit v1.2.3 From 40e58c85092945ca71e974ce4062d90e44f7fb66 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 26 Mar 2010 10:33:53 +0000 Subject: Optimization for pose channel name lookups using a hash, makes playback in one particular scene with 3 characters go from 10 to 13 fps. (commit 27728 by Brecht from render25 branch) --- source/blender/blenkernel/BKE_action.h | 7 +++++++ source/blender/blenkernel/intern/action.c | 29 ++++++++++++++++++++++++++++- source/blender/blenkernel/intern/armature.c | 1 + source/blender/blenkernel/intern/object.c | 5 ++++- 4 files changed, 40 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 1b38e276ca4..214b5a32cd6 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -129,6 +129,13 @@ void free_pose_channel(struct bPoseChannel *pchan); */ void free_pose_channels(struct bPose *pose); +/** + * Removes the hash for quick lookup of channels, must + * be done when adding/removing channels. + */ +void make_pose_channels_hash(struct bPose *pose); +void free_pose_channels_hash(struct bPose *pose); + /** * Removes and deallocates all data from a pose, and also frees the pose. */ diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 52f59c1681a..2d52d6061b9 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -56,8 +56,9 @@ #include "BIK_api.h" -#include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_ghash.h" +#include "BLI_math.h" #include "RNA_access.h" @@ -370,6 +371,9 @@ bPoseChannel *get_pose_channel(const bPose *pose, const char *name) if (ELEM(NULL, pose, name) || (name[0] == 0)) return NULL; + if(pose->chanhash) + return BLI_ghash_lookup(pose->chanhash, name); + return BLI_findstring(&((bPose *)pose)->chanbase, name, offsetof(bPoseChannel, name)); } @@ -405,6 +409,7 @@ bPoseChannel *verify_pose_channel(bPose *pose, const char *name) chan->protectflag = OB_LOCK_ROT4D; /* lock by components by default */ BLI_addtail(&pose->chanbase, chan); + free_pose_channels_hash(pose); return chan; } @@ -519,6 +524,26 @@ void init_pose_ikparam(bPose *pose) } } +void make_pose_channels_hash(bPose *pose) +{ + if(!pose->chanhash) { + bPoseChannel *pchan; + + pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); + for(pchan=pose->chanbase.first; pchan; pchan=pchan->next) + BLI_ghash_insert(pose->chanhash, pchan->name, pchan); + } +} + +void free_pose_channels_hash(bPose *pose) +{ + if(pose->chanhash) { + BLI_ghash_free(pose->chanhash, NULL, NULL); + pose->chanhash= NULL; + } +} + + void free_pose_channel(bPoseChannel *pchan) { // XXX this case here will need to be removed when the new motionpaths are ready @@ -550,6 +575,8 @@ void free_pose_channels(bPose *pose) BLI_freelistN(&pose->chanbase); } + + free_pose_channels_hash(pose); } void free_pose(bPose *pose) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 668ce9aadac..c1998d705ad 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1675,6 +1675,7 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) next= pchan->next; if(pchan->bone==NULL) { free_pose_channel(pchan); + free_pose_channels_hash(pose); BLI_freelinkN(&pose->chanbase, pchan); } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index b9e4894a868..bb7c77408ac 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2459,7 +2459,10 @@ void object_tfm_restore(Object *ob, void *obtfm_pt) void object_handle_update(Scene *scene, Object *ob) { if(ob->recalc & OB_RECALC) { - + /* speed optimization for animation lookups */ + if(ob->pose) + make_pose_channels_hash(ob->pose); + /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, which is only in where_is_object now */ if(ob->recalc & OB_RECALC) { -- cgit v1.2.3 From 666cca69e90bf1f5c1bfb5a6582c56c2e8311f04 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 26 Mar 2010 10:52:55 +0000 Subject: Cloth simulation can now use a group to specify which objects to collide with, in addition to the effectors group. (commit 27746 by Brecht from render25 branch) --- source/blender/blenkernel/BKE_collision.h | 13 +- source/blender/blenkernel/intern/collision.c | 261 ++++++++------------- source/blender/blenkernel/intern/effect.c | 2 +- source/blender/blenkernel/intern/implicit.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/scene.c | 1 + 6 files changed, 109 insertions(+), 172 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h index 689fa96ffa6..91c5eb4afee 100644 --- a/source/blender/blenkernel/BKE_collision.h +++ b/source/blender/blenkernel/BKE_collision.h @@ -49,12 +49,13 @@ #include "BLI_kdopbvh.h" -struct Object; -struct Scene; struct Cloth; -struct MFace; -struct DerivedMesh; struct ClothModifierData; +struct DerivedMesh; +struct Group; +struct MFace; +struct Object; +struct Scene; //////////////////////////////////////// // used for collisions in collision.c @@ -139,7 +140,7 @@ void interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float v3[3], ///////////////////////////////////////////////// // used in effect.c ///////////////////////////////////////////////// -Object **get_collisionobjects(struct Scene *scene, Object *self, int *numcollobj); +struct Object **get_collisionobjects(struct Scene *scene, struct Object *self, struct Group *group, int *numcollobj); typedef struct ColliderCache { struct ColliderCache *next, *prev; @@ -147,7 +148,7 @@ typedef struct ColliderCache { struct CollisionModifierData *collmd; } ColliderCache; -struct ListBase *get_collider_cache(struct Scene *scene, Object *self); +struct ListBase *get_collider_cache(struct Scene *scene, struct Object *self, struct Group *group); void free_collider_cache(struct ListBase **colliders); ///////////////////////////////////////////////// diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index b024ba5f4e1..c85bd2f90b3 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1299,188 +1299,122 @@ static int cloth_collision_moving ( ClothModifierData *clmd, CollisionModifierDa } #endif - -// return all collision objects in scene -// collision object will exclude self -Object **get_collisionobjects(Scene *scene, Object *self, int *numcollobj) +static void add_collision_object(Object ***objs, int *numobj, int *maxobj, Object *ob, Object *self, int level) { - Base *base=NULL; - Object **objs = NULL; - Object *coll_ob = NULL; - CollisionModifierData *collmd = NULL; - int numobj = 0, maxobj = 100; + CollisionModifierData *cmd= NULL; + + if(ob == self) + return; + + /* only get objects with collision modifier */ + if(ob->pd && ob->pd->deflect) + cmd= (CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision); - objs = MEM_callocN(sizeof(Object *)*maxobj, "CollisionObjectsArray"); - // check all collision objects - for ( base = scene->base.first; base; base = base->next ) - { - /*Only proceed for mesh object in same layer */ - if(!(base->object->type==OB_MESH && (base->lay & self->lay))) - continue; - - coll_ob = base->object; - - if(coll_ob == self) - continue; - - if(coll_ob->pd && coll_ob->pd->deflect) - { - collmd = ( CollisionModifierData * ) modifiers_findByType ( coll_ob, eModifierType_Collision ); + if(cmd) { + /* extend array */ + if(*numobj >= *maxobj) { + *maxobj *= 2; + *objs= MEM_reallocN(*objs, sizeof(Object*)*(*maxobj)); } - else - collmd = NULL; - if ( collmd ) - { - if(numobj >= maxobj) - { - // realloc - int oldmax = maxobj; - Object **tmp; - maxobj *= 2; - tmp = MEM_callocN(sizeof(Object *)*maxobj, "CollisionObjectsArray"); - memcpy(tmp, objs, sizeof(Object *)*oldmax); - MEM_freeN(objs); - objs = tmp; - - } - - objs[numobj] = coll_ob; - numobj++; - } - else - { - if ( coll_ob->dup_group ) - { - GroupObject *go; - Group *group = coll_ob->dup_group; + (*objs)[*numobj] = ob; + (*numobj)++; + } - for ( go= group->gobject.first; go; go= go->next ) - { - coll_ob = go->ob; - collmd = NULL; - - if(coll_ob == self) - continue; - - if(coll_ob->pd && coll_ob->pd->deflect) - { - collmd = ( CollisionModifierData * ) modifiers_findByType ( coll_ob, eModifierType_Collision ); - } - else - collmd = NULL; + /* objects in dupli groups, one level only for now */ + if(ob->dup_group && level == 0) { + GroupObject *go; + Group *group= ob->dup_group; - if ( !collmd ) - continue; - - if( !collmd->bvhtree) - continue; + /* add objects */ + for(go= group->gobject.first; go; go= go->next) + add_collision_object(objs, numobj, maxobj, go->ob, self, level+1); + } +} - if(numobj >= maxobj) - { - // realloc - int oldmax = maxobj; - Object **tmp; - maxobj *= 2; - tmp = MEM_callocN(sizeof(Object *)*maxobj, "CollisionObjectsArray"); - memcpy(tmp, objs, sizeof(Object *)*oldmax); - MEM_freeN(objs); - objs = tmp; - } - - objs[numobj] = coll_ob; - numobj++; - } - } - } +// return all collision objects in scene +// collision object will exclude self +Object **get_collisionobjects(Scene *scene, Object *self, Group *group, int *numcollobj) +{ + Base *base; + Object **objs; + GroupObject *go; + int numobj= 0, maxobj= 100; + + objs= MEM_callocN(sizeof(Object *)*maxobj, "CollisionObjectsArray"); + + /* gather all collision objects */ + if(group) { + /* use specified group */ + for(go= group->gobject.first; go; go= go->next) + add_collision_object(&objs, &numobj, &maxobj, go->ob, self, 0); + } + else { + /* add objects in same layer in scene */ + for(base = scene->base.first; base; base = base->next) + if(base->lay & self->lay) + add_collision_object(&objs, &numobj, &maxobj, base->object, self, 0); } - *numcollobj = numobj; + + *numcollobj= numobj; + return objs; } -ListBase *get_collider_cache(Scene *scene, Object *self) +static void add_collider_cache_object(ListBase **objs, Object *ob, Object *self, int level) { - Base *base=NULL; - ListBase *objs = NULL; - Object *coll_ob = NULL; - CollisionModifierData *collmd = NULL; + CollisionModifierData *cmd= NULL; ColliderCache *col; - - // check all collision objects - for ( base = scene->base.first; base; base = base->next ) - { - /*Only proceed for mesh object in same layer */ - if(base->object->type!=OB_MESH) - continue; - if(self && (base->lay & self->lay)==0) - continue; + if(ob == self) + return; - - coll_ob = base->object; - - if(coll_ob == self) - continue; - - if(coll_ob->pd && coll_ob->pd->deflect) - { - collmd = ( CollisionModifierData * ) modifiers_findByType ( coll_ob, eModifierType_Collision ); - } - else - collmd = NULL; - - if ( collmd ) - { - if(objs == NULL) - objs = MEM_callocN(sizeof(ListBase), "ColliderCache array"); - - col = MEM_callocN(sizeof(ColliderCache), "ColliderCache"); - col->ob = coll_ob; - col->collmd = collmd; - /* make sure collider is properly set up */ - collision_move_object(collmd, 1.0, 0.0); - BLI_addtail(objs, col); - } - else if ( coll_ob->dup_group ) - { - GroupObject *go; - Group *group = coll_ob->dup_group; + if(ob->pd && ob->pd->deflect) + cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision); + + if(cmd && cmd->bvhtree) { + if(*objs == NULL) + *objs = MEM_callocN(sizeof(ListBase), "ColliderCache array"); + + col = MEM_callocN(sizeof(ColliderCache), "ColliderCache"); + col->ob = ob; + col->collmd = cmd; + /* make sure collider is properly set up */ + collision_move_object(cmd, 1.0, 0.0); + BLI_addtail(*objs, col); + } - for ( go= group->gobject.first; go; go= go->next ) - { - coll_ob = go->ob; - collmd = NULL; - - if(coll_ob == self) - continue; - - if(coll_ob->pd && coll_ob->pd->deflect) - { - collmd = ( CollisionModifierData * ) modifiers_findByType ( coll_ob, eModifierType_Collision ); - } - else - collmd = NULL; + /* objects in dupli groups, one level only for now */ + if(ob->dup_group && level == 0) { + GroupObject *go; + Group *group= ob->dup_group; - if ( !collmd ) - continue; - - if( !collmd->bvhtree) - continue; - - if(objs == NULL) - objs = MEM_callocN(sizeof(ListBase), "ColliderCache array"); - - col = MEM_callocN(sizeof(ColliderCache), "ColliderCache"); - col->ob = coll_ob; - col->collmd = collmd; - /* make sure collider is properly set up */ - collision_move_object(collmd, 1.0, 0.0); - BLI_addtail(objs, col); - } - } + /* add objects */ + for(go= group->gobject.first; go; go= go->next) + add_collider_cache_object(objs, go->ob, self, level+1); + } +} + +ListBase *get_collider_cache(Scene *scene, Object *self, Group *group) +{ + Base *base; + GroupObject *go; + ListBase *objs= NULL; + + /* add object in same layer in scene */ + if(group) { + for(go= group->gobject.first; go; go= go->next) + add_collider_cache_object(&objs, go->ob, self, 0); + } + else { + for(base = scene->base.first; base; base = base->next) + if(self && (base->lay & self->lay)==0) + add_collider_cache_object(&objs, base->object, self, 0); } + return objs; } + void free_collider_cache(ListBase **colliders) { if(*colliders) { @@ -1489,6 +1423,7 @@ void free_collider_cache(ListBase **colliders) *colliders = NULL; } } + static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, CollisionModifierData *collmd, CollPair **collisions, CollPair **collisions_index, int numresult, BVHTreeOverlap *overlap) { int i; @@ -1574,7 +1509,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl bvhtree_update_from_cloth ( clmd, 1 ); // 0 means STATIC, 1 means MOVING (see later in this function) bvhselftree_update_from_cloth ( clmd, 0 ); // 0 means STATIC, 1 means MOVING (see later in this function) - collobjs = get_collisionobjects(clmd->scene, ob, &numcollobj); + collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj); if(!collobjs) return 0; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 66e7f805f50..118f4885af4 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -429,7 +429,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect return visibility; if(!colls) - colls = get_collider_cache(eff->scene, NULL); + colls = get_collider_cache(eff->scene, NULL, NULL); if(!colls) return visibility; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index b4fb34d8464..c625fb28840 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1422,7 +1422,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec /* 10x10x10 grid gives nice initial results */ HairGridVert grid[10][10][10]; HairGridVert colg[10][10][10]; - ListBase *colliders = get_collider_cache(clmd->scene, NULL); + ListBase *colliders = get_collider_cache(clmd->scene, NULL, NULL); ColliderCache *col = NULL; float gmin[3], gmax[3], density; /* 2.0f is an experimental value that seems to give good results */ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a99a8affbd3..a8446c0009f 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3229,7 +3229,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) psys_update_effectors(sim); if(part->type != PART_HAIR) - sim->colliders = get_collider_cache(sim->scene, NULL); + sim->colliders = get_collider_cache(sim->scene, NULL, NULL); if(part->phystype==PART_PHYS_BOIDS){ ParticleTarget *pt = psys->targets.first; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 0bce2d004e3..dd2a3143d3d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -53,6 +53,7 @@ #include "BKE_animsys.h" #include "BKE_depsgraph.h" #include "BKE_global.h" +#include "BKE_group.h" #include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_main.h" -- cgit v1.2.3 From 0912d84f2ab58a8073e5f66655260e799e1003b3 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 26 Mar 2010 15:06:30 +0000 Subject: Fixed incorrect rendering result when bevel object has got modifiers enabled only for realtime display or only for rendering --- source/blender/blenkernel/BKE_curve.h | 2 +- source/blender/blenkernel/intern/curve.c | 17 +++++++++++++---- source/blender/blenkernel/intern/displist.c | 15 ++++++++++++--- 3 files changed, 26 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 7119a725630..a3232ac91d6 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -76,7 +76,7 @@ void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride); float *make_orco_curve(struct Scene *scene, struct Object *ob); float *make_orco_surf( struct Object *ob); -void makebevelcurve(struct Scene *scene, struct Object *ob, struct ListBase *disp); +void makebevelcurve(struct Scene *scene, struct Object *ob, struct ListBase *disp, int forRender); void makeBevelList( struct Object *ob); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 4fed662b6b4..9087a7ec4f2 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1214,7 +1214,7 @@ float *make_orco_curve(Scene *scene, Object *ob) /* ***************** BEVEL ****************** */ -void makebevelcurve(Scene *scene, Object *ob, ListBase *disp) +void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) { DispList *dl, *dlnew; Curve *bevcu, *cu; @@ -1231,14 +1231,21 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp) 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]; - dl= bevcu->disp.first; - if(dl==0) { - makeDispListCurveTypes(scene, cu->bevobj, 0); + 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; + } } + while(dl) { if ELEM(dl->type, DL_POLY, DL_SEGM) { dlnew= MEM_mallocN(sizeof(DispList), "makebevelcurve1"); @@ -1260,6 +1267,8 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp) } dl= dl->next; } + + freedisplist(&bevdisp); } } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 3480564e00e..3e28dcc7acd 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1299,7 +1299,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba md = preTesselatePoint->next; } - if (*derivedFinal) { + if (derivedFinal && *derivedFinal) { (*derivedFinal)->release (*derivedFinal); } @@ -1354,6 +1354,13 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } } } else { + if (!derivedFinal) { + /* makeDisplistCurveTypes could be used for beveling, where derived mesh */ + /* is totally unnecessary, so we could stop modifiers applying */ + /* when we found constructive modifier but derived mesh is unwanted result */ + break; + } + if (dm) { if (dmDeformedVerts) { DerivedMesh *tdm = CDDM_copy(dm); @@ -1405,7 +1412,9 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba MEM_freeN(dmDeformedVerts); } - (*derivedFinal) = dm; + if (derivedFinal) { + (*derivedFinal) = dm; + } if (deformedVerts) { curve_applyVertexCos(ob->data, nurb, originalVerts); @@ -1659,7 +1668,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba makeBevelList(ob); /* If curve has no bevel will return nothing */ - makebevelcurve(scene, ob, &dlbev); + makebevelcurve(scene, ob, &dlbev, forRender); /* no bevel or extrude, and no width correction? */ if (!dlbev.first && cu->width==1.0f) { -- cgit v1.2.3 From 59d76439be0806ad76296337385dff1f20a3258a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 27 Mar 2010 12:16:24 +0000 Subject: Fix #21700: particles do not collide with linked objects. --- source/blender/blenkernel/intern/collision.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index c85bd2f90b3..ffd504f5945 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1408,7 +1408,7 @@ ListBase *get_collider_cache(Scene *scene, Object *self, Group *group) } else { for(base = scene->base.first; base; base = base->next) - if(self && (base->lay & self->lay)==0) + if(!self || (base->lay & self->lay)) add_collider_cache_object(&objs, base->object, self, 0); } -- cgit v1.2.3 From 57101c4fd26a85f4994d4d4d3f433c37f95367d0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 27 Mar 2010 15:35:34 +0000 Subject: Second attempt at committing the different render slot implementation. This has a fix that hopefully solves the problem on mac/win. Also fixes #21322, render slots not working well with FSA. --- source/blender/blenkernel/BKE_image.h | 3 + source/blender/blenkernel/intern/displist.c | 6 +- source/blender/blenkernel/intern/image.c | 90 +++++++++++++++++++++------- source/blender/blenkernel/intern/sequencer.c | 4 +- 4 files changed, 75 insertions(+), 28 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index df51d017594..915f59be01a 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -141,6 +141,9 @@ struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct Im /* for multilayer images as well as for render-viewer */ struct RenderResult *BKE_image_acquire_renderresult(struct Scene *scene, struct Image *ima); void BKE_image_release_renderresult(struct Scene *scene, struct Image *ima); + +/* for multiple slot render, call this before render */ +void BKE_image_backup_render(struct Scene *scene, struct Image *ima); /* goes over all textures that use images */ void BKE_image_free_all_textures(void); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 3e28dcc7acd..487ecb810d4 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -295,9 +295,9 @@ static Render *fastshade_get_render(Scene *scene) /* XXX ugly global still, but we can't do preview while rendering */ if(G.rendering==0) { - Render *re= RE_GetRender("_Shade View_", RE_SLOT_DEFAULT); + Render *re= RE_GetRender("_Shade View_"); if(re==NULL) { - re= RE_NewRender("_Shade View_", RE_SLOT_DEFAULT); + re= RE_NewRender("_Shade View_"); RE_Database_Baking(re, scene, 0, 0); /* 0= no faces */ } @@ -311,7 +311,7 @@ static Render *fastshade_get_render(Scene *scene) /* called on file reading */ void fastshade_free_render(void) { - Render *re= RE_GetRender("_Shade View_", RE_SLOT_DEFAULT); + Render *re= RE_GetRender("_Shade View_"); if(re) { RE_Database_Free(re); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 1a3c53e293f..f9352f1ded8 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -229,7 +229,7 @@ static void image_free_buffers(Image *ima) if(ima->anim) IMB_free_anim(ima->anim); ima->anim= NULL; - + if(ima->rr) { RE_FreeRenderResult(ima->rr); ima->rr= NULL; @@ -243,6 +243,8 @@ static void image_free_buffers(Image *ima) /* called by library too, do not free ima itself */ void free_image(Image *ima) { + int a; + image_free_buffers(ima); if (ima->packedfile) { freePackedFile(ima->packedfile); @@ -253,9 +255,11 @@ void free_image(Image *ima) if (ima->preview) { BKE_previewimg_free(&ima->preview); } - if (ima->render_text) { - MEM_freeN(ima->render_text); - ima->render_text= NULL; + for(a=0; arenders[a]) { + RE_FreeRenderResult(ima->renders[a]); + ima->renders[a]= NULL; + } } } @@ -1005,7 +1009,7 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } { - Render *re= RE_GetRender(scene->id.name, RE_SLOT_RENDERING); + Render *re= RE_GetRender(scene->id.name); RenderStats *stats= re ? RE_GetStats(re):NULL; if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) { @@ -1511,20 +1515,48 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) return rpass; } -RenderResult *BKE_image_acquire_renderresult(struct Scene *scene, Image *ima) +RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima) { - if(ima->rr) + if(ima->rr) { return ima->rr; - else if(ima->type==IMA_TYPE_R_RESULT) - return RE_AcquireResultRead(RE_GetRender(scene->id.name, RE_SLOT_VIEW)); - return NULL; + } + else if(ima->type==IMA_TYPE_R_RESULT) { + if(ima->render_slot == ima->last_render_slot) + return RE_AcquireResultRead(RE_GetRender(scene->id.name)); + else + return ima->renders[ima->render_slot]; + } + else + return NULL; } -void BKE_image_release_renderresult(struct Scene *scene, Image *ima) +void BKE_image_release_renderresult(Scene *scene, Image *ima) { if(ima->rr); - else if(ima->type==IMA_TYPE_R_RESULT) - RE_ReleaseResult(RE_GetRender(scene->id.name, RE_SLOT_VIEW)); + else if(ima->type==IMA_TYPE_R_RESULT) { + if(ima->render_slot == ima->last_render_slot) + RE_ReleaseResult(RE_GetRender(scene->id.name)); + } +} + +void BKE_image_backup_render(Scene *scene, Image *ima) +{ + /* called right before rendering, ima->renders contains render + result pointers for everything but the current render */ + Render *re= RE_GetRender(scene->id.name); + int slot= ima->render_slot, last= ima->last_render_slot; + + if(slot != last) { + if(ima->renders[slot]) { + RE_FreeRenderResult(ima->renders[slot]); + ima->renders[slot]= NULL; + } + + ima->renders[last]= NULL; + RE_SwapResult(re, &ima->renders[last]); + } + + ima->last_render_slot= slot; } /* after imbuf load, openexr type can return with a exrhandle open */ @@ -1839,6 +1871,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ float dither; int channels, layer, pass; ImBuf *ibuf; + int from_render= (ima->render_slot == ima->last_render_slot); if(!(iuser && iuser->scene)) return NULL; @@ -1847,14 +1880,29 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ if(!lock_r) return NULL; - re= RE_GetRender(iuser->scene->id.name, RE_SLOT_VIEW); + re= RE_GetRender(iuser->scene->id.name); channels= 4; layer= (iuser)? iuser->layer: 0; pass= (iuser)? iuser->pass: 0; + + if(from_render) + RE_AcquireResultImage(re, &rres); + else if(ima->renders[ima->render_slot]) + rres= *(ima->renders[ima->render_slot]); + else + memset(&rres, 0, sizeof(RenderResult)); + if(!(rres.rectx > 0 && rres.recty > 0)) { + RE_ReleaseResultImage(re); + return NULL; + } + + /* release is done in BKE_image_release_ibuf using lock_r */ + if(from_render) + *lock_r= re; + /* this gives active layer, composite or seqence result */ - RE_AcquireResultImage(re, &rres); rect= (unsigned int *)rres.rect32; rectf= rres.rectf; rectz= rres.rectz; @@ -1885,11 +1933,6 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ rectz= rpass->rect; } } - - if(!(rectf || rect)) { - RE_ReleaseResultImage(re); - return NULL; - } ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); @@ -1898,6 +1941,10 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, 0, 0); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); } + + if(!(rectf || rect)) + return ibuf; + ibuf->x= rres.rectx; ibuf->y= rres.recty; @@ -1915,9 +1962,6 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ima->ok= IMA_OK_LOADED; - /* release is done in BKE_image_release_ibuf using lock_r */ - *lock_r= re; - return ibuf; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 17f6bd10859..913ec3d4cae 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2175,9 +2175,9 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int RenderResult rres; if(rendering) - re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT); + re= RE_NewRender(" do_build_seq_ibuf"); else - re= RE_NewRender(sce->id.name, RE_SLOT_VIEW); + re= RE_NewRender(sce->id.name); RE_BlenderFrame(re, sce, NULL, sce->lay, frame); -- cgit v1.2.3 From 46895ab1f2786c2347d0d42b192197fca6d04bf5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 28 Mar 2010 13:45:19 +0000 Subject: Attempt to fix #21796: render crash on windows after slots commit. --- source/blender/blenkernel/intern/image.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index f9352f1ded8..2d582157233 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1948,8 +1948,11 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ibuf->x= rres.rectx; ibuf->y= rres.recty; - if(ibuf->rect_float!=rectf || rect) /* ensure correct redraw */ + if(ibuf->rect_float!=rectf || rect) { /* ensure correct redraw */ + BLI_lock_thread(LOCK_CUSTOM1); imb_freerectImBuf(ibuf); + BLI_unlock_thread(LOCK_CUSTOM1); + } if(rect) ibuf->rect= rect; -- cgit v1.2.3 From 8ba96eb1ae5ccfb3cc61f4f8d692dd271964c1af Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Sun, 28 Mar 2010 17:01:46 +0000 Subject: Change \n to more strict \r\n in HTTP headers (plus misc cleanups). Reported by Ralph Giles via bug 21797. --- .../blender/blenkernel/intern/writeframeserver.c | 39 ++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index cf3a36419b4..a7b6bcf3a09 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -1,4 +1,6 @@ /* + * $Id$ + * * Frameserver * Makes Blender accessible from TMPGenc directly using VFAPI (you can * use firefox too ;-) @@ -93,7 +95,7 @@ static int select_was_interrupted_by_signal() return (errno == EINTR); } -static int closesocket(int fd) +static int closesocket(int fd) { return close(fd); } @@ -140,10 +142,10 @@ int start_frameserver(struct Scene *scene, RenderData *rd, int rectx, int recty, return 1; } -static char index_page[] -= -"HTTP/1.1 200 OK\n" -"Content-Type: text/html\n\n" +static char index_page[] = +"HTTP/1.1 200 OK\r\n" +"Content-Type: text/html\r\n" +"\r\n" "Blender Frameserver\n" "
\n"
 "

Blender Frameserver

\n" @@ -156,9 +158,10 @@ static char index_page[] "\n" "
\n"; -static char good_bye[] -= "HTTP/1.1 200 OK\n" -"Content-Type: text/html\n\n" +static char good_bye[] = +"HTTP/1.1 200 OK\r\n" +"Content-Type: text/html\r\n" +"\r\n" "Blender Frameserver\n" "
\n"
 "Render stopped. Goodbye
"; @@ -216,13 +219,14 @@ static int handle_request(RenderData *rd, char * req) if (strcmp(path, "/info.txt") == 0) { char buf[4096]; - sprintf(buf, - "HTTP/1.1 200 OK\n" - "Content-Type: text/html\n\n" + sprintf(buf, + "HTTP/1.1 200 OK\r\n" + "Content-Type: text/html\r\n" + "\r\n" "start %d\n" "end %d\n" "width %d\n" - "height %d\n" + "height %d\n" "rate %d\n" "ratescale %d\n", rd->sfra, @@ -317,10 +321,11 @@ static void serve_ppm(int *pixels, int rectx, int recty) int y; char header[1024]; - sprintf(header, - "HTTP/1.1 200 OK\n" - "Content-Type: image/ppm\n" - "Connection: close\n\n" + sprintf(header, + "HTTP/1.1 200 OK\r\n" + "Content-Type: image/ppm\r\n" + "Connection: close\r\n" + "\r\n" "P6\n" "# Creator: blender frameserver v0.0.1\n" "%d %d\n" @@ -343,7 +348,7 @@ static void serve_ppm(int *pixels, int rectx, int recty) target += 3; src += 4; } - safe_write((char*)row, 3 * rectx); + safe_write((char*)row, 3 * rectx); } free(row); closesocket(connsock); -- cgit v1.2.3 From 751a9975e4c633e1ea8818c1f2f07fd6020c0ec0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 28 Mar 2010 18:41:49 +0000 Subject: [#21802] UVProject Modifier Crash fix for bug in recent addition of panorama support --- 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 5cda09cad85..96877a9ae9e 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -3717,9 +3717,10 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* calculate projection matrix */ invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat); + projectors[i].uci= NULL; + if(projectors[i].ob->type == OB_CAMERA) { cam = (Camera *)projectors[i].ob->data; - projectors[i].uci= NULL; if(cam->flag & CAM_PANORAMA) { projectors[i].uci= project_camera_info(projectors[i].ob, NULL, aspx, aspy); -- cgit v1.2.3 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 From 09489418a3c6c261dcf113c68f0e5699322d009a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 4 Apr 2010 21:57:51 +0000 Subject: [#21910] Add Current Time to Render Stamps by Harley Acheson (harley) note from the submission -snip- While in there I removed the Win32 conditionals that made "_strdate" used to get date on Windows. "localtime" works fine on Windows so the results are consistent on all platforms. --- source/blender/blenkernel/intern/image.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 63bfbc3d093..55dcc38ebcf 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -889,14 +889,9 @@ typedef struct StampData { static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) { char text[256]; - -#ifndef WIN32 struct tm *tl; time_t t; -#else - char sdate[9]; -#endif /* WIN32 */ - + if (scene->r.stamp & R_STAMP_FILENAME) { if (G.relbase_valid) { if (do_prefix) sprintf(stamp_data->file, "File %s", G.sce); @@ -917,14 +912,11 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } if (scene->r.stamp & R_STAMP_DATE) { -#ifdef WIN32 - _strdate (sdate); - sprintf (text, "%s", sdate); -#else + t = time (NULL); tl = localtime (&t); - sprintf (text, "%04d-%02d-%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday); -#endif /* WIN32 */ + sprintf (text, "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec); + if (do_prefix) sprintf(stamp_data->date, "Date %s", text); else sprintf(stamp_data->date, "%s", text); } else { -- cgit v1.2.3 From 00877ceaaecccb575f94dcd6dbec1e3f67b19547 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 5 Apr 2010 05:32:16 +0000 Subject: Fix [#21895] Incorrect calculations for measurement system 3d view grid scale text description wasn't using unit scale correctly --- source/blender/blenkernel/intern/unit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 87424dda04d..133f858e9ea 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -81,7 +81,7 @@ static struct bUnitDef buMetricLenDef[] = { {"decimetre", "decimetres", "dm", NULL, "10 Centimeters", 0.1, 0.0, B_UNIT_DEF_SUPPRESS}, {"centimeter", "centimeters", "cm", NULL, "Centimeters", 0.01, 0.0, B_UNIT_DEF_NONE}, {"millimeter", "millimeters", "mm", NULL, "Millimeters", 0.001, 0.0, B_UNIT_DEF_NONE}, - {"micrometer", "micrometers", "um", "µm", "Micrometers", 0.000001, 0.0, B_UNIT_DEF_NONE}, // micron too? + {"micrometer", "micrometers", "µm", "um", "Micrometers", 0.000001, 0.0, B_UNIT_DEF_NONE}, // micron too? /* These get displayed because of float precision problems in the transform header, * could work around, but for now probably people wont use these */ -- cgit v1.2.3 From 8b7d1775c3977f5afaa40363502f826b37266475 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 5 Apr 2010 09:46:01 +0000 Subject: Fix for [#21908] SPH fluids - crash when editing while playing --- source/blender/blenkernel/intern/particle_system.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index aa48336247c..0a202e8166e 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3732,6 +3732,8 @@ static void system_step(ParticleSimulationData *sim, float cfra) oldtotpart = psys->totpart; emit = emit_particles(sim, use_cache, cfra); + if(emit > 0) + BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, cfra); init = emit*emit + (psys->recalc & PSYS_RECALC_RESET); if(init) { -- cgit v1.2.3 From 1af9e1fb2b1acd543ba4606d5786a5d61eeda32e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 Apr 2010 11:11:15 +0000 Subject: Fix #21885: constraint with copy location/rotation from vertex group crashes. --- source/blender/blenkernel/intern/constraint.c | 4 +-- source/blender/blenkernel/intern/subsurf_ccg.c | 39 ++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 7994849a469..0441e9c9d00 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -427,8 +427,8 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f * - check if the custom data masks for derivedFinal mean that we can just use that * (this is more effficient + sufficient for most cases) */ - if (ob->lastDataMask != CD_MASK_DERIVEDMESH) { - dm = mesh_get_derived_final(scene, ob, CD_MASK_DERIVEDMESH); + if (!(ob->lastDataMask & CD_MASK_MDEFORMVERT)) { + dm = mesh_get_derived_final(scene, ob, CD_MASK_MDEFORMVERT); freeDM= 1; } else diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 9078566f109..3972355d302 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -577,6 +577,7 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; + DMGridData *vd; int i; memset(mv, 0, sizeof(*mv)); @@ -608,19 +609,25 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) offset = vertNum - ccgdm->faceMap[i].startVert; if(offset < 1) { - copy_v3_v3(mv->co, ccgSubSurf_getFaceCenterData(f)); + vd = ccgSubSurf_getFaceCenterData(f); + copy_v3_v3(mv->co, vd->co); + normal_float_to_short_v3(mv->no, vd->no); } else if(offset < gridSideEnd) { offset -= 1; grid = offset / gridSideVerts; x = offset % gridSideVerts + 1; - copy_v3_v3(mv->co, ccgSubSurf_getFaceGridEdgeData(ss, f, grid, x)); + vd = ccgSubSurf_getFaceGridEdgeData(ss, f, grid, x); + copy_v3_v3(mv->co, vd->co); + normal_float_to_short_v3(mv->no, vd->no); } else if(offset < gridInternalEnd) { offset -= gridSideEnd; grid = offset / gridInternalVerts; offset %= gridInternalVerts; y = offset / gridSideVerts + 1; x = offset % gridSideVerts + 1; - copy_v3_v3(mv->co, ccgSubSurf_getFaceGridData(ss, f, grid, x, y)); + vd = ccgSubSurf_getFaceGridData(ss, f, grid, x, y); + copy_v3_v3(mv->co, vd->co); + normal_float_to_short_v3(mv->no, vd->no); } } else if((vertNum < ccgdm->vertMap[0].startVert) && (ccgSubSurf_getNumEdges(ss) > 0)) { /* this vert comes from edge data */ @@ -635,17 +642,37 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) e = ccgdm->edgeMap[i].edge; x = vertNum - ccgdm->edgeMap[i].startVert + 1; - copy_v3_v3(mv->co, ccgSubSurf_getEdgeData(ss, e, x)); + vd = ccgSubSurf_getEdgeData(ss, e, x); + copy_v3_v3(mv->co, vd->co); + normal_float_to_short_v3(mv->no, vd->no); } else { /* this vert comes from vert data */ CCGVert *v; i = vertNum - ccgdm->vertMap[0].startVert; v = ccgdm->vertMap[i].vert; - copy_v3_v3(mv->co, ccgSubSurf_getVertData(ss, v)); + vd = ccgSubSurf_getVertData(ss, v); + copy_v3_v3(mv->co, vd->co); + normal_float_to_short_v3(mv->no, vd->no); } } +static void ccgDM_getFinalVertCo(DerivedMesh *dm, int vertNum, float co_r[3]) +{ + MVert mvert; + + ccgDM_getFinalVert(dm, vertNum, &mvert); + VECCOPY(co_r, mvert.co); +} + +static void ccgDM_getFinalVertNo(DerivedMesh *dm, int vertNum, float no_r[3]) +{ + MVert mvert; + + ccgDM_getFinalVert(dm, vertNum, &mvert); + normal_short_to_float_v3(no_r, mvert.no); +} + static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; @@ -2277,6 +2304,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ccgdm->dm.getVert = ccgDM_getFinalVert; ccgdm->dm.getEdge = ccgDM_getFinalEdge; ccgdm->dm.getFace = ccgDM_getFinalFace; + ccgdm->dm.getVertCo = ccgDM_getFinalVertCo; + ccgdm->dm.getVertNo = ccgDM_getFinalVertNo; ccgdm->dm.copyVertArray = ccgDM_copyFinalVertArray; ccgdm->dm.copyEdgeArray = ccgDM_copyFinalEdgeArray; ccgdm->dm.copyFaceArray = ccgDM_copyFinalFaceArray; -- cgit v1.2.3 From bfe248b3d629d28fed3798e9f6a42bccb5d40f9e Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 6 Apr 2010 02:05:54 +0000 Subject: Patch [#21750] Add luma waveform and vectorscope to image view by Xavier Thomas This adds the waveform monitor and vectorscope to the image editor 'scopes' region, bringing it inline (plus a bit more) with sequence editor functionality, and a big step closer to the end goal of unifying the display code for image/ comp/sequence editor. It's non-intrusive, using the same code paths as the histogram. There's still room for more tweaks - I modified the original patch, changing the openGL immediate mode drawing of the waveform display to vertex arrays for speed optimisation. Xavier can look at doing this for the vectorscope now too. Thanks very much Xavier! --- source/blender/blenkernel/BKE_colortools.h | 5 +- source/blender/blenkernel/intern/colortools.c | 249 ++++++++++++++++++++++---- 2 files changed, 221 insertions(+), 33 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index dca8ccb6dbf..f78389fe4de 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -31,7 +31,7 @@ struct CurveMapping; struct CurveMap; -struct Histogram; +struct Scopes; struct ImBuf; struct rctf; @@ -74,7 +74,8 @@ void curvemapping_initialize(struct CurveMapping *cumap); void curvemapping_table_RGBA(struct CurveMapping *cumap, float **array, int *size); void colorcorrection_do_ibuf(struct ImBuf *ibuf, const char *profile); -void histogram_update(struct Histogram *hist, struct ImBuf *ibuf); +void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, int use_color_management); +void scopes_free(struct Scopes *scopes); #endif diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 4c0c10c127a..2da527d467a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -885,6 +885,8 @@ void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size) /* ***************** Histogram **************** */ +#define INV_255 (1.f/255.f) + DO_INLINE int get_bin_float(float f) { int bin= (int)(f*255); @@ -897,59 +899,219 @@ DO_INLINE int get_bin_float(float f) return bin; } +DO_INLINE void save_sample_line(Scopes *scopes, const int idx, const float fx, float *rgb, float *ycc, float *ycc709) +{ + switch (scopes->wavefrm_mode) { + case SCOPES_WAVEFRM_RGB: + scopes->waveform_1[idx + 0] = fx; + scopes->waveform_1[idx + 1] = rgb[0]; + scopes->waveform_2[idx + 0] = fx; + scopes->waveform_2[idx + 1] = rgb[1]; + scopes->waveform_3[idx + 0] = fx; + scopes->waveform_3[idx + 1] = rgb[2]; + break; + case SCOPES_WAVEFRM_LUM: + scopes->waveform_1[idx + 0] = fx; + scopes->waveform_1[idx + 1] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]; + break; + case SCOPES_WAVEFRM_YCC_JPEG: + scopes->waveform_1[idx + 0] = fx; + scopes->waveform_1[idx + 1] = ycc[0] * INV_255; + scopes->waveform_2[idx + 0] = fx; + scopes->waveform_2[idx + 1] = ycc[1] * INV_255; + scopes->waveform_3[idx + 0] = fx; + scopes->waveform_3[idx + 1] = ycc[2] * INV_255; + break; + case SCOPES_WAVEFRM_YCC_709: + scopes->waveform_1[idx + 0] = fx; + scopes->waveform_1[idx + 1] = ycc709[0] * INV_255; + scopes->waveform_2[idx + 0] = fx; + scopes->waveform_2[idx + 1] = ycc709[1] * INV_255; + scopes->waveform_3[idx + 0] = fx; + scopes->waveform_3[idx + 1] = ycc709[2] * INV_255; + break; + case SCOPES_WAVEFRM_YCC_601: + { + float ycc601[3]; + rgb_to_ycc(rgb[0], rgb[1], rgb[2], &ycc601[0], &ycc601[1], &ycc601[2], BLI_YCC_ITU_BT601); + scopes->waveform_1[idx + 0] = fx; + scopes->waveform_1[idx + 1] = ycc601[0] * INV_255; + scopes->waveform_2[idx + 0] = fx; + scopes->waveform_2[idx + 1] = ycc601[1] * INV_255; + scopes->waveform_3[idx + 0] = fx; + scopes->waveform_3[idx + 1] = ycc601[2] * INV_255; + } + break; + } +} -void histogram_update(Histogram *hist, ImBuf *ibuf) +void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) { - int x, y, n; - double div; - float *rf; - unsigned char *rc; - unsigned int *bin_r, *bin_g, *bin_b; - - if (hist->ok == 1 ) return; - - if (hist->xmax == 0.f) hist->xmax = 1.f; - if (hist->ymax == 0.f) hist->ymax = 1.f; - + int x, y, c, n, nl; + double div, divl; + float *rf, *drf; + unsigned char *rc, *drc; + unsigned int *bin_r, *bin_g, *bin_b, *bin_lum; + int savedlines, saveline; + float rgb[3], ycc[3], ycc709[3]; + + if (scopes->ok == 1 ) return; + + if (scopes->hist.ymax == 0.f) scopes->hist.ymax = 1.f; + /* hmmmm */ if (!(ELEM(ibuf->channels, 3, 4))) return; - - hist->channels = 3; - + scopes->hist.channels = 3; + scopes->hist.x_resolution = 256; + + /* temp table to count pix value for histo */ bin_r = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); bin_g = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); bin_b = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); + bin_lum = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); + + /* convert to number of lines with logarithmic scale */ + scopes->sample_lines = (scopes->accuracy*0.01) * (scopes->accuracy*0.01) * ibuf->y; + + if (scopes->sample_full) + scopes->sample_lines = ibuf->y; + + if( scopes->samples_ibuf) { + IMB_freeImBuf(scopes->samples_ibuf); + scopes->samples_ibuf=NULL; + } + /* scan the image */ + savedlines=0; + for (c=0; c<3; c++) { + scopes->rgbminmax[c][0]=100.0f; + scopes->rgbminmax[c][1]=-100.0f; + scopes->yccminmax[c][0]=25500.0f; + scopes->yccminmax[c][1]=-25500.0f; + scopes->ycc709minmax[c][0]=25500.0f; + scopes->ycc709minmax[c][1]=-25500.0f; + } + + scopes->waveform_tot = ibuf->x*scopes->sample_lines; + + if (scopes->waveform_1) + MEM_freeN(scopes->waveform_1); + if (scopes->waveform_2) + MEM_freeN(scopes->waveform_2); + if (scopes->waveform_3) + MEM_freeN(scopes->waveform_3); + + scopes->waveform_1= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 1"); + scopes->waveform_2= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 2"); + scopes->waveform_3= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3"); if (ibuf->rect_float) { - hist->x_resolution = 256; - - /* divide into bins */ + scopes->samples_ibuf = IMB_allocImBuf(ibuf->x, scopes->sample_lines, 32, IB_rectfloat, 0 ); rf = ibuf->rect_float; + drf= scopes->samples_ibuf->rect_float; + for (y = 0; y < ibuf->y; y++) { + if (savedlinessample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) { + saveline=1; + } else saveline=0; for (x = 0; x < ibuf->x; x++) { - bin_r[ get_bin_float(rf[0]) ] += 1; - bin_g[ get_bin_float(rf[1]) ] += 1; - bin_b[ get_bin_float(rf[2]) ] += 1; + + if (use_color_management) + linearrgb_to_srgb_v3_v3(rgb, rf); + else + copy_v3_v3(rgb, rf); + + rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc[0],&ycc[1],&ycc[2],BLI_YCC_JFIF_0_255); + rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc709[0],&ycc709[1],&ycc709[2],BLI_YCC_ITU_BT709); + + /* check for min max */ + for (c=0; c<3; c++) { + if (rgb[c] < scopes->rgbminmax[c][0]) scopes->rgbminmax[c][0] = rgb[c]; + if (rgb[c] > scopes->rgbminmax[c][1]) scopes->rgbminmax[c][1] = rgb[c]; + if (ycc[c] < scopes->yccminmax[c][0]) scopes->yccminmax[c][0] = ycc[c]; + if (ycc[c] > scopes->yccminmax[c][1]) scopes->yccminmax[c][1] = ycc[c]; + if (ycc709[c] < scopes->ycc709minmax[c][0]) scopes->ycc709minmax[c][0] = ycc709[c]; + if (ycc709[c] > scopes->ycc709minmax[c][1]) scopes->ycc709minmax[c][1] = ycc709[c]; + } + /* increment count for histo*/ + bin_r[ get_bin_float(rgb[0]) ] += 1; + bin_g[ get_bin_float(rgb[1]) ] += 1; + bin_b[ get_bin_float(rgb[2]) ] += 1; + bin_lum[ get_bin_float(ycc[0] * INV_255) ] += 1; + + /* save sample if needed */ + if(saveline) { + const float fx = (float)x / (float)ibuf->x; + const int idx = 2*(ibuf->x*savedlines+x); + + save_sample_line(scopes, idx, fx, rgb, ycc, ycc709); + + drf[0]=rgb[0]; + drf[1]=rgb[1]; + drf[2]=rgb[2]; + drf+= scopes->samples_ibuf->channels; + } rf+= ibuf->channels; } + if (saveline) + savedlines +=1; } + } else if (ibuf->rect) { - hist->x_resolution = 256; - + scopes->samples_ibuf = IMB_allocImBuf(ibuf->x, scopes->sample_lines, 32, IB_rect, 0 ); rc = (unsigned char *)ibuf->rect; + drc= (unsigned char *) scopes->samples_ibuf->rect; + for (y = 0; y < ibuf->y; y++) { + if (savedlinessample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) { + saveline=1; + } else saveline=0; + for (x = 0; x < ibuf->x; x++) { + + for (c=0; c<3; c++) + rgb[c] = rc[c] * INV_255; + rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc[0],&ycc[1],&ycc[2],BLI_YCC_JFIF_0_255); + rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc709[0],&ycc709[1],&ycc709[2],BLI_YCC_ITU_BT709); + + /* check for min max */ + for (c=0; c<3; c++) { + if (rgb[c] < scopes->rgbminmax[c][0]) scopes->rgbminmax[c][0] = rgb[c]; + if (rgb[c] > scopes->rgbminmax[c][1]) scopes->rgbminmax[c][1] = rgb[c]; + if (ycc[c] < scopes->yccminmax[c][0]) scopes->yccminmax[c][0] = ycc[c]; + if (ycc[c] > scopes->yccminmax[c][1]) scopes->yccminmax[c][1] = ycc[c]; + if (ycc709[c] < scopes->ycc709minmax[c][0]) scopes->ycc709minmax[c][0] = ycc709[c]; + if (ycc709[c] > scopes->ycc709minmax[c][1]) scopes->ycc709minmax[c][1] = ycc709[c]; + } + + /* increment count for histo */ bin_r[ rc[0] ] += 1; bin_g[ rc[1] ] += 1; bin_b[ rc[2] ] += 1; + bin_lum[ get_bin_float(ycc[0] * INV_255) ] += 1; + + /* save sample if needed */ + if(saveline) { + const float fx = (float)x / (float)ibuf->x; + const int idx = 2*(ibuf->x*savedlines+x); + + save_sample_line(scopes, idx, fx, rgb, ycc, ycc709); + + drc[0]=rc[0]; + drc[1]=rc[1]; + drc[2]=rc[2]; + drc+= 4; + } rc += ibuf->channels; } + if (saveline) + savedlines +=1; } } - - /* convert to float */ + + /* convert hist data to float (proportional to max count) */ n=0; + nl=0; for (x=0; x<256; x++) { if (bin_r[x] > n) n = bin_r[x]; @@ -957,17 +1119,42 @@ void histogram_update(Histogram *hist, ImBuf *ibuf) n = bin_g[x]; if (bin_b[x] > n) n = bin_b[x]; + if (bin_lum[x] > nl) + nl = bin_lum[x]; } div = 1.f/(double)n; + divl = 1.f/(double)nl; for (x=0; x<256; x++) { - hist->data_r[x] = bin_r[x] * div; - hist->data_g[x] = bin_g[x] * div; - hist->data_b[x] = bin_b[x] * div; + scopes->hist.data_r[x] = bin_r[x] * div; + scopes->hist.data_g[x] = bin_g[x] * div; + scopes->hist.data_b[x] = bin_b[x] * div; + scopes->hist.data_luma[x] = bin_lum[x] * divl; } - MEM_freeN(bin_r); MEM_freeN(bin_g); MEM_freeN(bin_b); - - hist->ok=1; + MEM_freeN(bin_lum); + + scopes->ok = 1; } + +void scopes_free(Scopes *scopes) +{ + if (scopes->waveform_1) { + MEM_freeN(scopes->waveform_1); + scopes->waveform_1 = NULL; + } + if (scopes->waveform_2) { + MEM_freeN(scopes->waveform_2); + scopes->waveform_2 = NULL; + } + if (scopes->waveform_3) { + MEM_freeN(scopes->waveform_3); + scopes->waveform_3 = NULL; + } + + if( scopes->samples_ibuf) { + IMB_freeImBuf(scopes->samples_ibuf); + scopes->samples_ibuf=NULL; + } +} \ No newline at end of file -- cgit v1.2.3 From 12f2a752946600f6a2e77121b97a822ffd8134a9 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 6 Apr 2010 08:23:28 +0000 Subject: Fix for [#21928] Can't assign hair --- source/blender/blenkernel/intern/particle_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 0a202e8166e..54abfd8fd40 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3732,7 +3732,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) oldtotpart = psys->totpart; emit = emit_particles(sim, use_cache, cfra); - if(emit > 0) + if(use_cache && emit > 0) BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, cfra); init = emit*emit + (psys->recalc & PSYS_RECALC_RESET); -- cgit v1.2.3 From f1ac9b559e7919d82eb553c1a534d9f8de80af51 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 6 Apr 2010 08:43:52 +0000 Subject: "Fix" for [#21591] Explode modifier bug * The new default particle size is quite small, so exploded pieces didn't match the original pieces * There's now an option to use the particle size (useful for some effects), but it isn't used by default * This commit will change how some old files look (explode modifier and not 1.0 particle size), but the exact old behavior is achieved with the new "size" option --- 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 76e49c0726b..51e4ae37cd9 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -8637,7 +8637,8 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, /* apply rotation, size & location */ mul_qt_v3(state.rot,vertco); - mul_v3_fl(vertco,pa->size); + if(emd->flag & eExplodeFlag_PaSize) + mul_v3_fl(vertco,pa->size); VECADD(vertco,vertco,state.co); mul_m4_v3(imat,vertco); -- cgit v1.2.3 From 268e057e78ba95ecf97509c9fd77366b660ecafe Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 6 Apr 2010 09:36:35 +0000 Subject: Area Swap: fix memory leak and access to freed memory. --- source/blender/blenkernel/BKE_screen.h | 1 - source/blender/blenkernel/intern/screen.c | 21 --------------------- 2 files changed, 22 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index ee9a4db049f..970cdf412e5 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -227,7 +227,6 @@ void BKE_spacetypes_free(void); /* only for quitting blender */ /* spacedata */ void BKE_spacedata_freelist(ListBase *lb); void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2); -void BKE_spacedata_copyfirst(ListBase *lb1, ListBase *lb2); /* area/regions */ struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 59a8bd74910..de5f018673f 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -235,27 +235,6 @@ void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2) } } -/* lb1 should be empty */ -void BKE_spacedata_copyfirst(ListBase *lb1, ListBase *lb2) -{ - SpaceLink *sl; - - lb1->first= lb1->last= NULL; /* to be sure */ - - sl= lb2->first; - if(sl) { - SpaceType *st= BKE_spacetype_from_id(sl->spacetype); - - if(st && st->duplicate) { - SpaceLink *slnew= st->duplicate(sl); - - BLI_addtail(lb1, slnew); - - region_copylist(st, &slnew->regionbase, &sl->regionbase); - } - } -} - /* not region itself */ void BKE_area_region_free(SpaceType *st, ARegion *ar) { -- cgit v1.2.3 From 9acba540dbc3114e7d2d236684d6cd8b308e0a37 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 7 Apr 2010 09:07:06 +0000 Subject: Fix [#21756] Texture paint "quick edit" sending wrong path on unsaved scenes * Made it use the temp directory in user preferences when the .blend file hasn't been saved yet * Made bmain->name (wrapped as bpy.data.filename) contain an empty string when there's no .B25.blend and no file saved, rather than "". This is a good candidate for consistent file path api, retrieving temp dirs / project- specific temp dirs / etc... --- source/blender/blenkernel/intern/blender.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index d7f8d73e31f..48fe93af418 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -287,10 +287,14 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) if(G.main->versionfile < 250) do_versions_ipos_to_animato(G.main); // XXX fixme... complicated versionpatching - /* in case of autosave or quit.blend, use original filename instead - * use relbase_valid to make sure the file is saved, else we get in the filename */ - if(recover && bfd->filename[0] && G.relbase_valid) + if(recover && bfd->filename[0] && G.relbase_valid) { + /* in case of autosave or quit.blend, use original filename instead + * use relbase_valid to make sure the file is saved, else we get in the filename */ filename= bfd->filename; + } else if (!G.relbase_valid) { + /* otherwise, use an empty string as filename, rather than */ + filename=""; + } /* these are the same at times, should never copy to the same location */ if(G.sce != filename) -- cgit v1.2.3 From e81c198e9af75b27d95e9788cb3c70a62812fbb1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 Apr 2010 10:25:43 +0000 Subject: Disable part of commit #28064, this also clears the path on any file giving problems with file saving, proper fix will come later. --- source/blender/blenkernel/intern/blender.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 48fe93af418..fd6db3710b9 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -291,10 +291,13 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) /* in case of autosave or quit.blend, use original filename instead * use relbase_valid to make sure the file is saved, else we get in the filename */ filename= bfd->filename; - } else if (!G.relbase_valid) { + } +#if 0 + else if (!G.relbase_valid) { /* otherwise, use an empty string as filename, rather than */ filename=""; } +#endif /* these are the same at times, should never copy to the same location */ if(G.sce != filename) -- cgit v1.2.3 From 23e6ada74f649b7ed69ad1978790d53fe09c43e0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Apr 2010 11:46:52 +0000 Subject: bugfix [#21929] linking in groups into a linked in scene is possible and those groups can't be deleted - Disallow this and report a warning in the console when it happens. - File selector operators now report in the global report console. - Cleared some warnings. --- source/blender/blenkernel/intern/action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 365ac2371b8..fc7b22fa63e 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -396,7 +396,7 @@ bPoseChannel *get_pose_channel(const bPose *pose, const char *name) return NULL; if(pose->chanhash) - return BLI_ghash_lookup(pose->chanhash, name); + return BLI_ghash_lookup(pose->chanhash, (void *)name); return BLI_findstring(&((bPose *)pose)->chanbase, name, offsetof(bPoseChannel, name)); } -- cgit v1.2.3 From 39d3ff135f219d7cf8248c78ebf35fc8197ae937 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Apr 2010 16:08:06 +0000 Subject: no functional change - convert solidify edge crease values into chars once rather then for each edge. - sort vertex was checking the array all the time when it wasnt needed. --- source/blender/blenkernel/intern/modifier.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 51e4ae37cd9..7ec41aef323 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -6028,7 +6028,11 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, if(smd->flag & MOD_SOLIDIFY_RIM) { - static int edge_indices[4][4] = { + const unsigned char crease_rim= smd->crease_rim * 255.0f; + const unsigned char crease_outer= smd->crease_outer * 255.0f; + const unsigned char crease_inner= smd->crease_inner * 255.0f; + + const int edge_indices[4][4] = { {1, 0, 0, 1}, {2, 1, 1, 2}, {3, 2, 2, 3}, @@ -6041,8 +6045,8 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, ed->v2= new_vert_arr[i] + numVerts; ed->flag |= ME_EDGEDRAW; - if(smd->crease_rim) - ed->crease= smd->crease_rim * 255.0f; + if(crease_rim) + ed->crease= crease_rim; } /* faces */ @@ -6080,16 +6084,13 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, mf->v2= ed->v1; mf->v3= ed->v1 + numVerts; mf->v4= ed->v2 + numVerts; - - } - if(smd->crease_outer > 0.0f) - ed->crease= smd->crease_outer * 255.0f; + if(crease_outer) + ed->crease= crease_outer; - if(smd->crease_inner > 0.0f) { - ed= medge + (numEdges + eidx); - ed->crease= smd->crease_inner * 255.0f; + if(crease_inner) { + medge[numEdges + eidx].crease= crease_inner; } } -- cgit v1.2.3 From 77833847eee49b1810d650d3c94ebfbdb96602be Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 9 Apr 2010 00:44:35 +0000 Subject: Patch from Xavier Thomas: Use vertex arrays for drawing image editor vector scope too, making it a lot more efficient. Also fixed issue with scopes height not being stored in file properly. --- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenkernel/intern/colortools.c | 216 ++++++++++---------------- 2 files changed, 85 insertions(+), 133 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 64c5823f06f..7ac5815943a 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 4 +#define BLENDER_SUBVERSION 5 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 2da527d467a..353adf932a5 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -899,8 +899,16 @@ DO_INLINE int get_bin_float(float f) return bin; } -DO_INLINE void save_sample_line(Scopes *scopes, const int idx, const float fx, float *rgb, float *ycc, float *ycc709) +DO_INLINE void save_sample_line(Scopes *scopes, const int idx, const float fx, float *rgb, float *ycc) { + float yuv[3]; + + /* vectorscope*/ + rgb_to_yuv(rgb[0], rgb[1], rgb[2], &yuv[0], &yuv[1], &yuv[2]); + scopes->vecscope[idx + 0] = yuv[1]; + scopes->vecscope[idx + 1] = yuv[2]; + + /* waveform */ switch (scopes->wavefrm_mode) { case SCOPES_WAVEFRM_RGB: scopes->waveform_1[idx + 0] = fx; @@ -912,35 +920,17 @@ DO_INLINE void save_sample_line(Scopes *scopes, const int idx, const float fx, f break; case SCOPES_WAVEFRM_LUM: scopes->waveform_1[idx + 0] = fx; - scopes->waveform_1[idx + 1] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]; + scopes->waveform_1[idx + 1] = ycc[0]; break; case SCOPES_WAVEFRM_YCC_JPEG: - scopes->waveform_1[idx + 0] = fx; - scopes->waveform_1[idx + 1] = ycc[0] * INV_255; - scopes->waveform_2[idx + 0] = fx; - scopes->waveform_2[idx + 1] = ycc[1] * INV_255; - scopes->waveform_3[idx + 0] = fx; - scopes->waveform_3[idx + 1] = ycc[2] * INV_255; - break; case SCOPES_WAVEFRM_YCC_709: - scopes->waveform_1[idx + 0] = fx; - scopes->waveform_1[idx + 1] = ycc709[0] * INV_255; - scopes->waveform_2[idx + 0] = fx; - scopes->waveform_2[idx + 1] = ycc709[1] * INV_255; - scopes->waveform_3[idx + 0] = fx; - scopes->waveform_3[idx + 1] = ycc709[2] * INV_255; - break; case SCOPES_WAVEFRM_YCC_601: - { - float ycc601[3]; - rgb_to_ycc(rgb[0], rgb[1], rgb[2], &ycc601[0], &ycc601[1], &ycc601[2], BLI_YCC_ITU_BT601); scopes->waveform_1[idx + 0] = fx; - scopes->waveform_1[idx + 1] = ycc601[0] * INV_255; + scopes->waveform_1[idx + 1] = ycc[0]; scopes->waveform_2[idx + 0] = fx; - scopes->waveform_2[idx + 1] = ycc601[1] * INV_255; + scopes->waveform_2[idx + 1] = ycc[1]; scopes->waveform_3[idx + 0] = fx; - scopes->waveform_3[idx + 1] = ycc601[2] * INV_255; - } + scopes->waveform_3[idx + 1] = ycc[2]; break; } } @@ -949,11 +939,12 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) { int x, y, c, n, nl; double div, divl; - float *rf, *drf; - unsigned char *rc, *drc; + float *rf; + unsigned char *rc; unsigned int *bin_r, *bin_g, *bin_b, *bin_lum; int savedlines, saveline; - float rgb[3], ycc[3], ycc709[3]; + float rgb[3], ycc[3]; + int ycc_mode; if (scopes->ok == 1 ) return; @@ -964,6 +955,22 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) scopes->hist.channels = 3; scopes->hist.x_resolution = 256; + switch (scopes->wavefrm_mode) { + case SCOPES_WAVEFRM_RGB: + ycc_mode = -1; + break; + case SCOPES_WAVEFRM_LUM: + case SCOPES_WAVEFRM_YCC_JPEG: + ycc_mode = BLI_YCC_JFIF_0_255; + break; + case SCOPES_WAVEFRM_YCC_601: + ycc_mode = BLI_YCC_ITU_BT601; + break; + case SCOPES_WAVEFRM_YCC_709: + ycc_mode = BLI_YCC_ITU_BT709; + break; + } + /* temp table to count pix value for histo */ bin_r = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); bin_g = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); @@ -976,19 +983,11 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) if (scopes->sample_full) scopes->sample_lines = ibuf->y; - if( scopes->samples_ibuf) { - IMB_freeImBuf(scopes->samples_ibuf); - scopes->samples_ibuf=NULL; - } /* scan the image */ savedlines=0; for (c=0; c<3; c++) { - scopes->rgbminmax[c][0]=100.0f; - scopes->rgbminmax[c][1]=-100.0f; - scopes->yccminmax[c][0]=25500.0f; - scopes->yccminmax[c][1]=-25500.0f; - scopes->ycc709minmax[c][0]=25500.0f; - scopes->ycc709minmax[c][1]=-25500.0f; + scopes->minmax[c][0]=25500.0f; + scopes->minmax[c][1]=-25500.0f; } scopes->waveform_tot = ibuf->x*scopes->sample_lines; @@ -999,114 +998,68 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) MEM_freeN(scopes->waveform_2); if (scopes->waveform_3) MEM_freeN(scopes->waveform_3); + if (scopes->vecscope) + MEM_freeN(scopes->vecscope); scopes->waveform_1= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 1"); scopes->waveform_2= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 2"); scopes->waveform_3= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3"); + scopes->vecscope= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel"); - if (ibuf->rect_float) { - scopes->samples_ibuf = IMB_allocImBuf(ibuf->x, scopes->sample_lines, 32, IB_rectfloat, 0 ); + if (ibuf->rect_float) rf = ibuf->rect_float; - drf= scopes->samples_ibuf->rect_float; - - for (y = 0; y < ibuf->y; y++) { - if (savedlinessample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) { - saveline=1; - } else saveline=0; - for (x = 0; x < ibuf->x; x++) { - + else if (ibuf->rect) + rc = (unsigned char *)ibuf->rect; + + for (y = 0; y < ibuf->y; y++) { + if (savedlinessample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) { + saveline=1; + } else saveline=0; + for (x = 0; x < ibuf->x; x++) { + + if (ibuf->rect_float) { if (use_color_management) linearrgb_to_srgb_v3_v3(rgb, rf); else copy_v3_v3(rgb, rf); - - rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc[0],&ycc[1],&ycc[2],BLI_YCC_JFIF_0_255); - rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc709[0],&ycc709[1],&ycc709[2],BLI_YCC_ITU_BT709); - - /* check for min max */ - for (c=0; c<3; c++) { - if (rgb[c] < scopes->rgbminmax[c][0]) scopes->rgbminmax[c][0] = rgb[c]; - if (rgb[c] > scopes->rgbminmax[c][1]) scopes->rgbminmax[c][1] = rgb[c]; - if (ycc[c] < scopes->yccminmax[c][0]) scopes->yccminmax[c][0] = ycc[c]; - if (ycc[c] > scopes->yccminmax[c][1]) scopes->yccminmax[c][1] = ycc[c]; - if (ycc709[c] < scopes->ycc709minmax[c][0]) scopes->ycc709minmax[c][0] = ycc709[c]; - if (ycc709[c] > scopes->ycc709minmax[c][1]) scopes->ycc709minmax[c][1] = ycc709[c]; - } - /* increment count for histo*/ - bin_r[ get_bin_float(rgb[0]) ] += 1; - bin_g[ get_bin_float(rgb[1]) ] += 1; - bin_b[ get_bin_float(rgb[2]) ] += 1; - bin_lum[ get_bin_float(ycc[0] * INV_255) ] += 1; - - /* save sample if needed */ - if(saveline) { - const float fx = (float)x / (float)ibuf->x; - const int idx = 2*(ibuf->x*savedlines+x); - - save_sample_line(scopes, idx, fx, rgb, ycc, ycc709); - - drf[0]=rgb[0]; - drf[1]=rgb[1]; - drf[2]=rgb[2]; - drf+= scopes->samples_ibuf->channels; - } - rf+= ibuf->channels; } - if (saveline) - savedlines +=1; - } - - } - else if (ibuf->rect) { - scopes->samples_ibuf = IMB_allocImBuf(ibuf->x, scopes->sample_lines, 32, IB_rect, 0 ); - rc = (unsigned char *)ibuf->rect; - drc= (unsigned char *) scopes->samples_ibuf->rect; - - for (y = 0; y < ibuf->y; y++) { - if (savedlinessample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) { - saveline=1; - } else saveline=0; - - for (x = 0; x < ibuf->x; x++) { - + else if (ibuf->rect) { for (c=0; c<3; c++) - rgb[c] = rc[c] * INV_255; - rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc[0],&ycc[1],&ycc[2],BLI_YCC_JFIF_0_255); - rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc709[0],&ycc709[1],&ycc709[2],BLI_YCC_ITU_BT709); - - /* check for min max */ + rgb[c] = rc[c] * INV_255; + } + /* check for min max */ + if(ycc_mode == -1 ) { for (c=0; c<3; c++) { - if (rgb[c] < scopes->rgbminmax[c][0]) scopes->rgbminmax[c][0] = rgb[c]; - if (rgb[c] > scopes->rgbminmax[c][1]) scopes->rgbminmax[c][1] = rgb[c]; - if (ycc[c] < scopes->yccminmax[c][0]) scopes->yccminmax[c][0] = ycc[c]; - if (ycc[c] > scopes->yccminmax[c][1]) scopes->yccminmax[c][1] = ycc[c]; - if (ycc709[c] < scopes->ycc709minmax[c][0]) scopes->ycc709minmax[c][0] = ycc709[c]; - if (ycc709[c] > scopes->ycc709minmax[c][1]) scopes->ycc709minmax[c][1] = ycc709[c]; + if (rgb[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = rgb[c]; + if (rgb[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = rgb[c]; } - - /* increment count for histo */ - bin_r[ rc[0] ] += 1; - bin_g[ rc[1] ] += 1; - bin_b[ rc[2] ] += 1; - bin_lum[ get_bin_float(ycc[0] * INV_255) ] += 1; - - /* save sample if needed */ - if(saveline) { - const float fx = (float)x / (float)ibuf->x; - const int idx = 2*(ibuf->x*savedlines+x); - - save_sample_line(scopes, idx, fx, rgb, ycc, ycc709); - - drc[0]=rc[0]; - drc[1]=rc[1]; - drc[2]=rc[2]; - drc+= 4; + } + else { + rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc[0],&ycc[1],&ycc[2], ycc_mode); + for (c=0; c<3; c++) { + ycc[c] *=INV_255; + if (ycc[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = ycc[c]; + if (ycc[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = ycc[c]; } - rc += ibuf->channels; } - if (saveline) - savedlines +=1; + /* increment count for histo*/ + bin_r[ get_bin_float(rgb[0]) ] += 1; + bin_g[ get_bin_float(rgb[1]) ] += 1; + bin_b[ get_bin_float(rgb[2]) ] += 1; + bin_lum[ get_bin_float(ycc[0]) ] += 1; + + /* save sample if needed */ + if(saveline) { + const float fx = (float)x / (float)ibuf->x; + const int idx = 2*(ibuf->x*savedlines+x); + save_sample_line(scopes, idx, fx, rgb, ycc); + } + + rf+= ibuf->channels; + rc+= ibuf->channels; } + if (saveline) + savedlines +=1; } /* convert hist data to float (proportional to max count) */ @@ -1152,9 +1105,8 @@ void scopes_free(Scopes *scopes) MEM_freeN(scopes->waveform_3); scopes->waveform_3 = NULL; } - - if( scopes->samples_ibuf) { - IMB_freeImBuf(scopes->samples_ibuf); - scopes->samples_ibuf=NULL; + if (scopes->vecscope) { + MEM_freeN(scopes->vecscope); + scopes->vecscope = NULL; } -} \ No newline at end of file +} -- cgit v1.2.3 From 4d2f5a275d402bd732bd52887d7aed5fce7276c4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 10 Apr 2010 22:12:10 +0000 Subject: Solidify Modifier - vertex normals were not being flipped (though faces are) - rim faces didnt influence edge vertex normals apply solidify on top of solidify modifier now works correctly --- source/blender/blenkernel/BKE_DerivedMesh.h | 2 +- source/blender/blenkernel/BKE_customdata.h | 2 +- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/customdata.c | 10 ++--- source/blender/blenkernel/intern/modifier.c | 56 ++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 965bad31991..33852a1b923 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -456,7 +456,7 @@ void DM_interp_face_data(struct DerivedMesh *source, struct DerivedMesh *dest, float *weights, FaceVertWeight *vert_weights, int count, int dest_index); -void DM_swap_face_data(struct DerivedMesh *dm, int index, int *corner_indices); +void DM_swap_face_data(struct DerivedMesh *dm, int index, const int *corner_indices); /* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */ void vDM_ColorBand_store(struct ColorBand *coba); diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index c07b26fd372..7ca6bbe67a7 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -174,7 +174,7 @@ void CustomData_bmesh_interp(struct CustomData *data, void **src_blocks, /* swaps the data in the element corners, to new corners with indices as specified in corner_indices. for edges this is an array of length 2, for faces an array of length 4 */ -void CustomData_swap(struct CustomData *data, int index, int *corner_indices); +void CustomData_swap(struct CustomData *data, int index, const int *corner_indices); /* gets a pointer to the data element at index from the first layer of type * returns NULL if there is no layer of type diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index f4e3a60803e..44757a09d42 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -416,7 +416,7 @@ void DM_interp_face_data(DerivedMesh *source, DerivedMesh *dest, weights, (float*)vert_weights, count, dest_index); } -void DM_swap_face_data(DerivedMesh *dm, int index, int *corner_indices) +void DM_swap_face_data(DerivedMesh *dm, int index, const int *corner_indices) { CustomData_swap(&dm->faceData, index, corner_indices); } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 0afb9a450dd..71be2ce7b78 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -85,7 +85,7 @@ typedef struct LayerTypeInfo { int count, void *dest); /* a function to swap the data in corners of the element */ - void (*swap)(void *data, int *corner_indices); + void (*swap)(void *data, const int *corner_indices); /* a function to set a layer's data to default values. if NULL, the default is assumed to be all zeros */ @@ -273,7 +273,7 @@ static void layerInterp_tface(void **sources, float *weights, } } -static void layerSwap_tface(void *data, int *corner_indices) +static void layerSwap_tface(void *data, const int *corner_indices) { MTFace *tf = data; float uv[4][2]; @@ -368,7 +368,7 @@ static void layerInterp_origspace_face(void **sources, float *weights, } } -static void layerSwap_origspace_face(void *data, int *corner_indices) +static void layerSwap_origspace_face(void *data, const int *corner_indices) { OrigSpaceFace *osf = data; float uv[4][2]; @@ -735,7 +735,7 @@ static void layerInterp_mcol(void **sources, float *weights, } } -static void layerSwap_mcol(void *data, int *corner_indices) +static void layerSwap_mcol(void *data, const int *corner_indices) { MCol *mcol = data; MCol col[4]; @@ -1533,7 +1533,7 @@ void CustomData_interp(const CustomData *source, CustomData *dest, if(count > SOURCE_BUF_SIZE) MEM_freeN(sources); } -void CustomData_swap(struct CustomData *data, int index, int *corner_indices) +void CustomData_swap(struct CustomData *data, int index, const int *corner_indices) { const LayerTypeInfo *typeInfo; int i; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 7ec41aef323..c8f98bbac56 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5900,6 +5900,7 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, ed->v2 += numVerts; } + /* note, copied vertex layers dont have flipped normals yet. do this after applying offset */ if((smd->flag & MOD_SOLIDIFY_EVEN) == 0) { /* no even thickness, very simple */ float scalar_short; @@ -6026,8 +6027,32 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, if(vert_nors) MEM_freeN(vert_nors); + /* flip vertex normals for copied verts */ + mv= mvert + numVerts; + for(i=0; ino[0]= -mv->no[0]; + mv->no[1]= -mv->no[1]; + mv->no[2]= -mv->no[2]; + } + if(smd->flag & MOD_SOLIDIFY_RIM) { + + /* bugger, need to re-calculate the normals for the new edge faces. + * This could be done in many ways, but probably the quickest way is to calculate the average normals for side faces only. + * Then blend them with the normals of the edge verts. + * + * at the moment its easiest to allocate an entire array for every vertex, even though we only need edge verts - campbell + */ + +#define SOLIDIFY_SIDE_NORMALS + +#ifdef SOLIDIFY_SIDE_NORMALS + /* annoying to allocate these since we only need the edge verts, */ + float (*edge_vert_nos)[3]= MEM_callocN(sizeof(float) * numVerts * 3, "solidify_edge_nos"); + float nor[3]; +#endif + const unsigned char crease_rim= smd->crease_rim * 255.0f; const unsigned char crease_outer= smd->crease_outer * 255.0f; const unsigned char crease_inner= smd->crease_inner * 255.0f; @@ -6092,8 +6117,37 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, if(crease_inner) { medge[numEdges + eidx].crease= crease_inner; } + +#ifdef SOLIDIFY_SIDE_NORMALS + normal_quad_v3(nor, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); + + add_v3_v3(edge_vert_nos[ed->v1], nor); + add_v3_v3(edge_vert_nos[ed->v2], nor); +#endif + } + +#ifdef SOLIDIFY_SIDE_NORMALS + ed= medge + (numEdges * 2); + for(i=0; iv1]); + + for(j=0; j<2; j++) { /* loop over both verts of the edge */ + nor_short= mvert[*(&ed->v1 + j)].no; + normal_short_to_float_v3(nor, nor_short); + add_v3_v3(nor, nor_cpy); + normalize_v3(nor); + normal_float_to_short_v3(nor_short, nor); + } } + MEM_freeN(edge_vert_nos); +#endif + MEM_freeN(new_vert_arr); MEM_freeN(new_edge_arr); MEM_freeN(edge_users); @@ -6103,6 +6157,8 @@ static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, return result; } +#undef SOLIDIFY_SIDE_NORMALS + static DerivedMesh *solidifyModifier_applyModifierEM(ModifierData *md, Object *ob, EditMesh *editData, -- cgit v1.2.3 From ee0a217be3114d9b4f50772720312df5f74997e1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 11 Apr 2010 09:13:37 +0000 Subject: python function to remove drivers. eg: bpy.context.object.driver_remove("location") ANIM_remove_driver now accepts -1 as an index for removing all drivers from one path. --- source/blender/blenkernel/BKE_fcurve.h | 2 ++ source/blender/blenkernel/intern/fcurve.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index c4d74f86284..835e2ed80c8 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -187,6 +187,8 @@ void copy_fcurves(ListBase *dst, ListBase *src); /* find matching F-Curve in the given list of F-Curves */ struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index); +struct FCurve *iter_step_fcurve (struct FCurve *fcu_iter, const char rna_path[]); + /* high level function to get an fcurve from C without having the rna */ struct FCurve *id_data_find_fcurve(ID *id, void *data, struct StructRNA *type, char *prop_name, int index); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 5bfef86b7c6..9bbb6e7b7b6 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -234,6 +234,27 @@ FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array return NULL; } +/* quick way to loop over all fcurves of a given 'path' */ +FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[]) +{ + FCurve *fcu; + + /* sanity checks */ + if (ELEM(NULL, fcu_iter, rna_path)) + return NULL; + + /* check paths of curves, then array indices... */ + for (fcu= fcu_iter; fcu; fcu= fcu->next) { + /* simple string-compare (this assumes that they have the same root...) */ + if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) { + return fcu; + } + } + + /* return */ + return NULL; +} + /* Get list of LinkData's containing pointers to the F-Curves which control the types of data indicated * Lists... * - dst: list of LinkData's matching the criteria returned. -- cgit v1.2.3 From 978609aa44659bbf4565ad413f5242654249fb22 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 11 Apr 2010 19:26:46 +0000 Subject: == Sequencer == Made custom proxy files a lot more sensible to select (upgraded to filepath get/setters) Changed semantics, since custom files don't make much sense without custom directories... --- source/blender/blenkernel/intern/sequencer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 790087334c6..3cfbbd8ae6f 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1231,7 +1231,8 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na return FALSE; } - if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) { + if ((seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) + || (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)) { strcpy(dir, seq->strip->proxy->dir); } else { if (seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE) { -- cgit v1.2.3 From 3fdaf5cecc9c7c521c4db514f916f083b17881a6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 11 Apr 2010 22:12:30 +0000 Subject: [#14437] Modifier Stack Refactor patch by Ben Batt (artificer) Updated patch for 6 or so modifiers added since the patch was written. - tested with CMake and SCons - fixed one error were flags were being added to the fluids type. - remove BKE_simple_deform.h, simple_deform.c, move functions into MOD_simpledeform.c since there were problems with circular deps. - moved some fluid and boolean functions used by modifiers too. --- source/blender/blenkernel/BKE_booleanops.h | 16 - source/blender/blenkernel/BKE_fluidsim.h | 14 +- source/blender/blenkernel/BKE_simple_deform.h | 39 - source/blender/blenkernel/CMakeLists.txt | 3 +- source/blender/blenkernel/SConscript | 2 +- source/blender/blenkernel/intern/booleanops.c | 595 -- source/blender/blenkernel/intern/fluidsim.c | 579 +- source/blender/blenkernel/intern/modifier.c | 9896 +--------------------- source/blender/blenkernel/intern/simple_deform.c | 255 - 9 files changed, 67 insertions(+), 11332 deletions(-) delete mode 100644 source/blender/blenkernel/BKE_simple_deform.h delete mode 100644 source/blender/blenkernel/intern/simple_deform.c (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_booleanops.h b/source/blender/blenkernel/BKE_booleanops.h index dcf71645db3..a213d63cc03 100644 --- a/source/blender/blenkernel/BKE_booleanops.h +++ b/source/blender/blenkernel/BKE_booleanops.h @@ -29,21 +29,5 @@ #ifndef BKE_BOOLEANOPS_H #define BKE_BOOLEANOPS_H -struct Scene; -struct Object; -struct Base; -struct DerivedMesh; - -/* Performs a boolean between two mesh objects, it is assumed that both objects - are in fact a mesh object. On success returns 1 and creates a new mesh object - into blender data structures. On failure returns 0 and reports an error. */ -int NewBooleanMesh(struct Scene *scene, struct Base *base, struct Base *base_select, int op); - - -/* Performs a boolean between two mesh objects, it is assumed that both objects - are in fact mesh object. On success returns a DerivedMesh. On failure - returns NULL and reports an error. */ -struct DerivedMesh *NewBooleanDerivedMesh(struct DerivedMesh *dm, struct Object *ob, struct DerivedMesh *dm_select, struct Object *ob_select, - int int_op_type); #endif diff --git a/source/blender/blenkernel/BKE_fluidsim.h b/source/blender/blenkernel/BKE_fluidsim.h index d99e7b42cff..da43ae7f28b 100644 --- a/source/blender/blenkernel/BKE_fluidsim.h +++ b/source/blender/blenkernel/BKE_fluidsim.h @@ -30,6 +30,7 @@ #ifndef BKE_FLUIDSIM_H #define BKE_FLUIDSIM_H + struct Object; struct Scene; struct FluidsimModifierData; @@ -37,25 +38,12 @@ struct DerivedMesh; struct MVert; /* old interface */ -struct FluidsimSettings *fluidsimSettingsNew(struct Object *srcob); void initElbeemMesh(struct Scene *scene, struct Object *ob, int *numVertices, float **vertices, int *numTriangles, int **triangles, int useGlobalCoords, int modifierIndex); -/* new fluid-modifier interface */ -void fluidsim_init(struct FluidsimModifierData *fluidmd); -void fluidsim_free(struct FluidsimModifierData *fluidmd); - -struct DerivedMesh *fluidsim_read_cache(struct Object *ob, struct DerivedMesh *orgdm, - struct FluidsimModifierData *fluidmd, int framenr, int useRenderParams); -void fluidsim_read_vel_cache(struct FluidsimModifierData *fluidmd, struct DerivedMesh *dm, - char *filename); -struct DerivedMesh *fluidsimModifier_do(struct FluidsimModifierData *fluidmd, - struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, - int useRenderParams, int isFinalCalc); - /* bounding box & memory estimate */ void fluid_get_bb(struct MVert *mvert, int totvert, float obmat[][4], float start[3], float size[3]); diff --git a/source/blender/blenkernel/BKE_simple_deform.h b/source/blender/blenkernel/BKE_simple_deform.h deleted file mode 100644 index b5f4a2514dd..00000000000 --- a/source/blender/blenkernel/BKE_simple_deform.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * BKE_shrinkwrap.h - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef BKE_SIMPLE_DEFORM_H -#define BKE_SIMPLE_DEFORM_H - -struct Object; -struct DerivedMesh; -struct SimpleDeformModifierData; - -void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts); - -#endif - diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index da5e73bbb45..afb29fbcd62 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -27,7 +27,7 @@ FILE(GLOB SRC intern/*.c) SET(INC - . ../../../intern/guardedalloc ../../../intern/memutil ../editors/include ../blenlib ../makesdna + . ../../../intern/guardedalloc ../../../intern/memutil ../editors/include ../blenlib ../makesdna ../modifiers ../render/extern/include ../../../intern/decimation/extern ../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/opennl/extern ../../../intern/iksolver/extern ../blenloader ../ikplugin @@ -38,6 +38,7 @@ SET(INC ${ZLIB_INC} ) + ADD_DEFINITIONS(-DGLEW_STATIC) IF(WITH_BULLET) diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 37a63be6389..57d7e45d986 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -6,7 +6,7 @@ sources = env.Glob('intern/*.c') incs = '. #/intern/guardedalloc #/intern/memutil ../editors/include' incs += ' ../blenlib ../blenfont ../makesdna ../windowmanager' incs += ' ../render/extern/include #/intern/decimation/extern ../makesrna' -incs += ' ../imbuf ../ikplugin ../avi #/intern/elbeem/extern ../nodes' +incs += ' ../imbuf ../ikplugin ../avi #/intern/elbeem/extern ../nodes ../modifiers' incs += ' #/intern/iksolver/extern ../blenloader' incs += ' #/extern/bullet2/src' incs += ' #/intern/opennl/extern #/intern/bsp/extern' diff --git a/source/blender/blenkernel/intern/booleanops.c b/source/blender/blenkernel/intern/booleanops.c index 3e43dfbb4d5..e69de29bb2d 100644 --- a/source/blender/blenkernel/intern/booleanops.c +++ b/source/blender/blenkernel/intern/booleanops.c @@ -1,595 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) Blender Foundation - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * CSG operations. - */ - -#include -#include - -#include "MEM_guardedalloc.h" - -#include "BLI_math.h" -#include "BLI_ghash.h" - -#include "DNA_material_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_object_types.h" -#include "DNA_scene_types.h" - -#include "CSG_BooleanOps.h" - -#include "BKE_cdderivedmesh.h" -#include "BKE_depsgraph.h" -#include "BKE_material.h" -#include "BKE_mesh.h" -#include "BKE_object.h" - - - -/** - * Here's the vertex iterator structure used to walk through - * the blender vertex structure. - */ - -typedef struct { - DerivedMesh *dm; - Object *ob; - int pos; -} VertexIt; - -/** - * Implementations of local vertex iterator functions. - * These describe a blender mesh to the CSG module. - */ - -static void VertexIt_Destruct(CSG_VertexIteratorDescriptor * iterator) -{ - if (iterator->it) { - // deallocate memory for iterator - MEM_freeN(iterator->it); - iterator->it = 0; - } - iterator->Done = NULL; - iterator->Fill = NULL; - iterator->Reset = NULL; - iterator->Step = NULL; - iterator->num_elements = 0; - -} - -static int VertexIt_Done(CSG_IteratorPtr it) -{ - VertexIt * iterator = (VertexIt *)it; - return(iterator->pos >= iterator->dm->getNumVerts(iterator->dm)); -} - -static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert) -{ - VertexIt * iterator = (VertexIt *)it; - MVert *verts = iterator->dm->getVertArray(iterator->dm); - - float global_pos[3]; - - /* boolean happens in global space, transform both with obmat */ - mul_v3_m4v3( - global_pos, - iterator->ob->obmat, - verts[iterator->pos].co - ); - - vert->position[0] = global_pos[0]; - vert->position[1] = global_pos[1]; - vert->position[2] = global_pos[2]; -} - -static void VertexIt_Step(CSG_IteratorPtr it) -{ - VertexIt * iterator = (VertexIt *)it; - iterator->pos ++; -} - -static void VertexIt_Reset(CSG_IteratorPtr it) -{ - VertexIt * iterator = (VertexIt *)it; - iterator->pos = 0; -} - -static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, DerivedMesh *dm, Object *ob) -{ - - VertexIt *it; - if (output == 0) return; - - // allocate some memory for blender iterator - it = (VertexIt *)(MEM_mallocN(sizeof(VertexIt),"Boolean_VIt")); - if (it == 0) { - return; - } - // assign blender specific variables - it->dm = dm; - it->ob = ob; // needed for obmat transformations - - it->pos = 0; - - // assign iterator function pointers. - output->Step = VertexIt_Step; - output->Fill = VertexIt_Fill; - output->Done = VertexIt_Done; - output->Reset = VertexIt_Reset; - output->num_elements = it->dm->getNumVerts(it->dm); - output->it = it; -} - -/** - * Blender Face iterator - */ - -typedef struct { - DerivedMesh *dm; - int pos; - int offset; - int flip; -} FaceIt; - -static void FaceIt_Destruct(CSG_FaceIteratorDescriptor * iterator) -{ - MEM_freeN(iterator->it); - iterator->Done = NULL; - iterator->Fill = NULL; - iterator->Reset = NULL; - iterator->Step = NULL; - iterator->num_elements = 0; -} - -static int FaceIt_Done(CSG_IteratorPtr it) -{ - // assume CSG_IteratorPtr is of the correct type. - FaceIt * iterator = (FaceIt *)it; - return(iterator->pos >= iterator->dm->getNumFaces(iterator->dm)); -} - -static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) -{ - // assume CSG_IteratorPtr is of the correct type. - FaceIt *face_it = (FaceIt *)it; - MFace *mfaces = face_it->dm->getFaceArray(face_it->dm); - MFace *mface = &mfaces[face_it->pos]; - - /* reverse face vertices if necessary */ - face->vertex_index[1] = mface->v2; - if( face_it->flip == 0 ) { - face->vertex_index[0] = mface->v1; - face->vertex_index[2] = mface->v3; - } else { - face->vertex_index[2] = mface->v1; - face->vertex_index[0] = mface->v3; - } - if (mface->v4) { - face->vertex_index[3] = mface->v4; - face->vertex_number = 4; - } else { - face->vertex_number = 3; - } - - face->orig_face = face_it->offset + face_it->pos; -} - -static void FaceIt_Step(CSG_IteratorPtr it) -{ - FaceIt * face_it = (FaceIt *)it; - face_it->pos ++; -} - -static void FaceIt_Reset(CSG_IteratorPtr it) -{ - FaceIt * face_it = (FaceIt *)it; - face_it->pos = 0; -} - -static void FaceIt_Construct( - CSG_FaceIteratorDescriptor *output, DerivedMesh *dm, int offset, Object *ob) -{ - FaceIt *it; - if (output == 0) return; - - // allocate some memory for blender iterator - it = (FaceIt *)(MEM_mallocN(sizeof(FaceIt),"Boolean_FIt")); - if (it == 0) { - return ; - } - // assign blender specific variables - it->dm = dm; - it->offset = offset; - it->pos = 0; - - /* determine if we will need to reverse order of face vertices */ - if (ob->size[0] < 0.0f) { - if (ob->size[1] < 0.0f && ob->size[2] < 0.0f) { - it->flip = 1; - } else if (ob->size[1] >= 0.0f && ob->size[2] >= 0.0f) { - it->flip = 1; - } else { - it->flip = 0; - } - } else { - if (ob->size[1] < 0.0f && ob->size[2] < 0.0f) { - it->flip = 0; - } else if (ob->size[1] >= 0.0f && ob->size[2] >= 0.0f) { - it->flip = 0; - } else { - it->flip = 1; - } - } - - // assign iterator function pointers. - output->Step = FaceIt_Step; - output->Fill = FaceIt_Fill; - output->Done = FaceIt_Done; - output->Reset = FaceIt_Reset; - output->num_elements = it->dm->getNumFaces(it->dm); - output->it = it; -} - -static Object *AddNewBlenderMesh(Scene *scene, Base *base) -{ - // This little function adds a new mesh object to the blender object list - // It uses ob to duplicate data as this seems to be easier than creating - // a new one. This new oject contains no faces nor vertices. - Mesh *old_me; - Base *basen; - Object *ob_new; - - // now create a new blender object. - // duplicating all the settings from the previous object - // to the new one. - ob_new= copy_object(base->object); - - // Ok we don't want to use the actual data from the - // last object, the above function incremented the - // number of users, so decrement it here. - old_me= ob_new->data; - old_me->id.us--; - - // Now create a new base to add into the linked list of - // vase objects. - - basen= MEM_mallocN(sizeof(Base), "duplibase"); - *basen= *base; - BLI_addhead(&scene->base, basen); /* addhead: anders oneindige lus */ - basen->object= ob_new; - basen->flag &= ~SELECT; - - // Initialize the mesh data associated with this object. - ob_new->data= add_mesh("Mesh"); - - // Finally assign the object type. - ob_new->type= OB_MESH; - - return ob_new; -} - -static void InterpCSGFace( - DerivedMesh *dm, DerivedMesh *orig_dm, int index, int orig_index, int nr, - float mapmat[][4]) -{ - float obco[3], *co[4], *orig_co[4], w[4][4]; - MFace *mface, *orig_mface; - int j; - - mface = CDDM_get_face(dm, index); - orig_mface = orig_dm->getFaceArray(orig_dm) + orig_index; - - // get the vertex coordinates from the original mesh - orig_co[0] = (orig_dm->getVertArray(orig_dm) + orig_mface->v1)->co; - orig_co[1] = (orig_dm->getVertArray(orig_dm) + orig_mface->v2)->co; - orig_co[2] = (orig_dm->getVertArray(orig_dm) + orig_mface->v3)->co; - orig_co[3] = (orig_mface->v4)? (orig_dm->getVertArray(orig_dm) + orig_mface->v4)->co: NULL; - - // get the vertex coordinates from the new derivedmesh - co[0] = CDDM_get_vert(dm, mface->v1)->co; - co[1] = CDDM_get_vert(dm, mface->v2)->co; - co[2] = CDDM_get_vert(dm, mface->v3)->co; - co[3] = (nr == 4)? CDDM_get_vert(dm, mface->v4)->co: NULL; - - for (j = 0; j < nr; j++) { - // get coordinate into the space of the original mesh - if (mapmat) - mul_v3_m4v3(obco, mapmat, co[j]); - else - copy_v3_v3(obco, co[j]); - - interp_weights_face_v3( w[j],orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco); - } - - CustomData_interp(&orig_dm->faceData, &dm->faceData, &orig_index, NULL, (float*)w, 1, index); -} - -/* Iterate over the CSG Output Descriptors and create a new DerivedMesh - from them */ -static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( - CSG_FaceIteratorDescriptor *face_it, - CSG_VertexIteratorDescriptor *vertex_it, - float parinv[][4], - float mapmat[][4], - Material **mat, - int *totmat, - DerivedMesh *dm1, - Object *ob1, - DerivedMesh *dm2, - Object *ob2) -{ - DerivedMesh *result, *orig_dm; - GHash *material_hash = NULL; - Mesh *me1= (Mesh*)ob1->data; - Mesh *me2= (Mesh*)ob2->data; - int i; - - // create a new DerivedMesh - result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements); - CustomData_merge(&dm1->faceData, &result->faceData, CD_MASK_DERIVEDMESH, - CD_DEFAULT, face_it->num_elements); - CustomData_merge(&dm2->faceData, &result->faceData, CD_MASK_DERIVEDMESH, - CD_DEFAULT, face_it->num_elements); - - // step through the vertex iterators: - for (i = 0; !vertex_it->Done(vertex_it->it); i++) { - CSG_IVertex csgvert; - MVert *mvert = CDDM_get_vert(result, i); - - // retrieve a csg vertex from the boolean module - vertex_it->Fill(vertex_it->it, &csgvert); - vertex_it->Step(vertex_it->it); - - // we have to map the vertex coordinates back in the coordinate frame - // of the resulting object, since it was computed in world space - mul_v3_m4v3(mvert->co, parinv, csgvert.position); - } - - // a hash table to remap materials to indices - if (mat) { - material_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); - *totmat = 0; - } - - // step through the face iterators - for(i = 0; !face_it->Done(face_it->it); i++) { - Mesh *orig_me; - Object *orig_ob; - Material *orig_mat; - CSG_IFace csgface; - MFace *mface; - int orig_index, mat_nr; - - // retrieve a csg face from the boolean module - face_it->Fill(face_it->it, &csgface); - face_it->Step(face_it->it); - - // find the original mesh and data - orig_ob = (csgface.orig_face < dm1->getNumFaces(dm1))? ob1: ob2; - orig_dm = (csgface.orig_face < dm1->getNumFaces(dm1))? dm1: dm2; - orig_me = (orig_ob == ob1)? me1: me2; - orig_index = (orig_ob == ob1)? csgface.orig_face: csgface.orig_face - dm1->getNumFaces(dm1); - - // copy all face layers, including mface - CustomData_copy_data(&orig_dm->faceData, &result->faceData, orig_index, i, 1); - - // set mface - mface = CDDM_get_face(result, i); - mface->v1 = csgface.vertex_index[0]; - mface->v2 = csgface.vertex_index[1]; - mface->v3 = csgface.vertex_index[2]; - mface->v4 = (csgface.vertex_number == 4)? csgface.vertex_index[3]: 0; - - // set material, based on lookup in hash table - orig_mat= give_current_material(orig_ob, mface->mat_nr+1); - - if (mat && orig_mat) { - if (!BLI_ghash_haskey(material_hash, orig_mat)) { - mat[*totmat] = orig_mat; - mat_nr = mface->mat_nr = (*totmat)++; - BLI_ghash_insert(material_hash, orig_mat, SET_INT_IN_POINTER(mat_nr)); - } - else - mface->mat_nr = GET_INT_FROM_POINTER(BLI_ghash_lookup(material_hash, orig_mat)); - } - else - mface->mat_nr = 0; - - InterpCSGFace(result, orig_dm, i, orig_index, csgface.vertex_number, - (orig_me == me2)? mapmat: NULL); - - test_index_face(mface, &result->faceData, i, csgface.vertex_number); - } - - if (material_hash) - BLI_ghash_free(material_hash, NULL, NULL); - - CDDM_calc_edges(result); - CDDM_calc_normals(result); - - return result; -} - -static void BuildMeshDescriptors( - struct DerivedMesh *dm, - struct Object *ob, - int face_offset, - struct CSG_FaceIteratorDescriptor * face_it, - struct CSG_VertexIteratorDescriptor * vertex_it) -{ - VertexIt_Construct(vertex_it,dm, ob); - FaceIt_Construct(face_it,dm,face_offset,ob); -} - -static void FreeMeshDescriptors( - struct CSG_FaceIteratorDescriptor *face_it, - struct CSG_VertexIteratorDescriptor *vertex_it) -{ - VertexIt_Destruct(vertex_it); - FaceIt_Destruct(face_it); -} - -DerivedMesh *NewBooleanDerivedMesh_intern( - DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, - int int_op_type, Material **mat, int *totmat) -{ - - float inv_mat[4][4]; - float map_mat[4][4]; - - DerivedMesh *result = NULL; - - if (dm == NULL || dm_select == NULL) return 0; - if (!dm->getNumFaces(dm) || !dm_select->getNumFaces(dm_select)) return 0; - - // we map the final object back into ob's local coordinate space. For this - // we need to compute the inverse transform from global to ob (inv_mat), - // and the transform from ob to ob_select for use in interpolation (map_mat) - invert_m4_m4(inv_mat, ob->obmat); - mul_m4_m4m4(map_mat, ob_select->obmat, inv_mat); - invert_m4_m4(inv_mat, ob_select->obmat); - - { - // interface with the boolean module: - // - // the idea is, we pass the boolean module verts and faces using the - // provided descriptors. once the boolean operation is performed, we - // get back output descriptors, from which we then build a DerivedMesh - - CSG_VertexIteratorDescriptor vd_1, vd_2; - CSG_FaceIteratorDescriptor fd_1, fd_2; - CSG_OperationType op_type; - CSG_BooleanOperation *bool_op; - - // work out the operation they chose and pick the appropriate - // enum from the csg module. - switch (int_op_type) { - case 1 : op_type = e_csg_intersection; break; - case 2 : op_type = e_csg_union; break; - case 3 : op_type = e_csg_difference; break; - case 4 : op_type = e_csg_classify; break; - default : op_type = e_csg_intersection; - } - - BuildMeshDescriptors(dm_select, ob_select, 0, &fd_1, &vd_1); - BuildMeshDescriptors(dm, ob, dm_select->getNumFaces(dm_select) , &fd_2, &vd_2); - - bool_op = CSG_NewBooleanFunction(); - - // perform the operation - if (CSG_PerformBooleanOperation(bool_op, op_type, fd_1, vd_1, fd_2, vd_2)) { - CSG_VertexIteratorDescriptor vd_o; - CSG_FaceIteratorDescriptor fd_o; - - CSG_OutputFaceDescriptor(bool_op, &fd_o); - CSG_OutputVertexDescriptor(bool_op, &vd_o); - - // iterate through results of operation and insert - // into new object - result = ConvertCSGDescriptorsToDerivedMesh( - &fd_o, &vd_o, inv_mat, map_mat, mat, totmat, dm_select, ob_select, dm, ob); - - // free up the memory - CSG_FreeVertexDescriptor(&vd_o); - CSG_FreeFaceDescriptor(&fd_o); - } - else - printf("Unknown internal error in boolean"); - - CSG_FreeBooleanOperation(bool_op); - - FreeMeshDescriptors(&fd_1, &vd_1); - FreeMeshDescriptors(&fd_2, &vd_2); - } - - return result; -} - -int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) -{ - Mesh *me_new; - int a, maxmat, totmat= 0; - Object *ob_new, *ob, *ob_select; - Material **mat; - DerivedMesh *result; - DerivedMesh *dm_select; - DerivedMesh *dm; - - ob= base->object; - ob_select= base_select->object; - - dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - dm_select = mesh_create_derived_view(scene, ob_select, 0); // no modifiers in editmode ?? - - maxmat= ob->totcol + ob_select->totcol; - mat= (Material**)MEM_mallocN(sizeof(Material*)*maxmat, "NewBooleanMeshMat"); - - /* put some checks in for nice user feedback */ - if (dm == NULL || dm_select == NULL) return 0; - if (!dm->getNumFaces(dm) || !dm_select->getNumFaces(dm_select)) - { - MEM_freeN(mat); - return -1; - } - - result= NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, mat, &totmat); - - if (result == NULL) { - MEM_freeN(mat); - return 0; - } - - /* create a new blender mesh object - using 'base' as a template */ - ob_new= AddNewBlenderMesh(scene, base_select); - me_new= ob_new->data; - - DM_to_mesh(result, me_new); - result->release(result); - - dm->release(dm); - dm_select->release(dm_select); - - /* add materials to object */ - for (a = 0; a < totmat; a++) - assign_material(ob_new, mat[a], a+1); - - MEM_freeN(mat); - - /* update dag */ - DAG_id_flush_update(&ob_new->id, OB_RECALC_DATA); - - return 1; -} - -DerivedMesh *NewBooleanDerivedMesh(DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, - int int_op_type) -{ - return NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, NULL, NULL); -} - diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 118a44507c9..8a6f0af87d1 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -62,556 +62,15 @@ /* ************************* fluidsim bobj file handling **************************** */ -// ----------------------------------------- -// forward decleration -// ----------------------------------------- - -// ----------------------------------------- - -void fluidsim_init(FluidsimModifierData *fluidmd) -{ -#ifndef DISABLE_ELBEEM - if(fluidmd) - { - FluidsimSettings *fss = MEM_callocN(sizeof(FluidsimSettings), "fluidsimsettings"); - - fluidmd->fss = fss; - - if(!fss) - return; - - fss->fmd = fluidmd; - fss->type = OB_FLUIDSIM_ENABLE; - fss->show_advancedoptions = 0; - - fss->resolutionxyz = 65; - fss->previewresxyz = 45; - fss->realsize = 0.5; - fss->guiDisplayMode = 2; // preview - fss->renderDisplayMode = 3; // render - - fss->viscosityMode = 2; // default to water - fss->viscosityValue = 1.0; - fss->viscosityExponent = 6; - - // dg TODO: change this to [] - fss->gravx = 0.0; - fss->gravy = 0.0; - fss->gravz = -9.81; - fss->animStart = 0.0; - fss->animEnd = 4.0; - fss->gstar = 0.005; // used as normgstar - fss->maxRefine = -1; - // maxRefine is set according to resolutionxyz during bake - - // fluid/inflow settings - // fss->iniVel --> automatically set to 0 - - /* elubie: changed this to default to the same dir as the render output - to prevent saving to C:\ on Windows */ - BLI_strncpy(fss->surfdataPath, btempdir, FILE_MAX); - - // first init of bounding box - // no bounding box needed - - // todo - reuse default init from elbeem! - fss->typeFlags = OB_FSBND_PARTSLIP; - fss->domainNovecgen = 0; - fss->volumeInitType = 1; // volume - fss->partSlipValue = 0.2; - - fss->generateTracers = 0; - fss->generateParticles = 0.0; - fss->surfaceSmoothing = 1.0; - fss->surfaceSubdivs = 0.0; - fss->particleInfSize = 0.0; - fss->particleInfAlpha = 0.0; - - // init fluid control settings - fss->attractforceStrength = 0.2; - fss->attractforceRadius = 0.75; - fss->velocityforceStrength = 0.2; - fss->velocityforceRadius = 0.75; - fss->cpsTimeStart = fss->animStart; - fss->cpsTimeEnd = fss->animEnd; - fss->cpsQuality = 10.0; // 1.0 / 10.0 => means 0.1 width - - /* - BAD TODO: this is done in buttons_object.c in the moment - Mesh *mesh = ob->data; - // calculate bounding box - fluid_get_bb(mesh->mvert, mesh->totvert, ob->obmat, fss->bbStart, fss->bbSize); - */ - - // (ab)used to store velocities - fss->meshSurfNormals = NULL; - - fss->lastgoodframe = -1; - - fss->flag |= OB_FLUIDSIM_ACTIVE; - - } -#endif - return; -} - -void fluidsim_free(FluidsimModifierData *fluidmd) -{ -#ifndef DISABLE_ELBEEM - if(fluidmd) - { - if(fluidmd->fss->meshSurfNormals) - { - MEM_freeN(fluidmd->fss->meshSurfNormals); - fluidmd->fss->meshSurfNormals = NULL; - } - MEM_freeN(fluidmd->fss); - } -#endif - return; -} - -DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc) -{ -#ifndef DISABLE_ELBEEM - DerivedMesh *result = NULL; - int framenr; - FluidsimSettings *fss = NULL; - - framenr= (int)scene->r.cfra; - - // only handle fluidsim domains - if(fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN)) - return dm; - - // sanity check - if(!fluidmd || (fluidmd && !fluidmd->fss)) - return dm; - - fss = fluidmd->fss; - - // timescale not supported yet - // clmd->sim_parms->timescale= timescale; - - // support reversing of baked fluid frames here - if((fss->flag & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0)) - { - framenr = fss->lastgoodframe - framenr + 1; - CLAMP(framenr, 1, fss->lastgoodframe); - } - - /* try to read from cache */ - if(((fss->lastgoodframe >= framenr) || (fss->lastgoodframe < 0)) && (result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams))) - { - // fss->lastgoodframe = framenr; // set also in src/fluidsim.c - return result; - } - else - { - // display last known good frame - if(fss->lastgoodframe >= 0) - { - if((result = fluidsim_read_cache(ob, dm, fluidmd, fss->lastgoodframe, useRenderParams))) - { - return result; - } - - // it was supposed to be a valid frame but it isn't! - fss->lastgoodframe = framenr - 1; - - - // this could be likely the case when you load an old fluidsim - if((result = fluidsim_read_cache(ob, dm, fluidmd, fss->lastgoodframe, useRenderParams))) - { - return result; - } - } - - result = CDDM_copy(dm); - - if(result) - { - return result; - } - } - - return dm; -#else - return NULL; -#endif -} - -#ifndef DISABLE_ELBEEM -/* read .bobj.gz file into a fluidsimDerivedMesh struct */ -static DerivedMesh *fluidsim_read_obj(char *filename) -{ - int wri,i,j; - float wrf; - int gotBytes; - gzFile gzf; - int numverts = 0, numfaces = 0; - DerivedMesh *dm = NULL; - MFace *mface; - MVert *mvert; - short *normals; - - // ------------------------------------------------ - // get numverts + numfaces first - // ------------------------------------------------ - gzf = gzopen(filename, "rb"); - if (!gzf) - { - return NULL; - } - - // read numverts - gotBytes = gzread(gzf, &wri, sizeof(wri)); - numverts = wri; - - // skip verts - for(i=0; ico[j] = wrf; - } - } - - // should be the same as numverts - gotBytes = gzread(gzf, &wri, sizeof(wri)); - if(wri != numverts) - { - if(dm) - dm->release(dm); - gzclose( gzf ); - return NULL; - } - - normals = MEM_callocN(sizeof(short) * numverts * 3, "fluid_tmp_normals" ); - if(!normals) - { - if(dm) - dm->release(dm); - gzclose( gzf ); - return NULL; - } - - // read normals from file (but don't save them yet) - for(i=0; iv1 = face[0]; - mf->v2 = face[1]; - mf->v3 = face[2]; - } - else - { - mf->v1 = face[1]; - mf->v2 = face[2]; - mf->v3 = face[0]; - } - mf->v4 = face[3]; - - test_index_face(mf, NULL, 0, 3); - } - - gzclose( gzf ); - - CDDM_calc_edges(dm); - - CDDM_apply_vert_normals(dm, (short (*)[3])normals); - MEM_freeN(normals); - - // CDDM_calc_normals(result); - - return dm; -} - -DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifierData *fluidmd, int framenr, int useRenderParams) -{ - int displaymode = 0; - int curFrame = framenr - 1 /*scene->r.sfra*/; /* start with 0 at start frame */ - char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR]; - FluidsimSettings *fss = fluidmd->fss; - DerivedMesh *dm = NULL; - MFace *mface; - int numfaces; - int mat_nr, flag, i; - - if(!useRenderParams) { - displaymode = fss->guiDisplayMode; - } else { - displaymode = fss->renderDisplayMode; - } - - strncpy(targetDir, fss->surfdataPath, FILE_MAXDIR); - - // use preview or final mesh? - if(displaymode==1) - { - // just display original object - return NULL; - } - else if(displaymode==2) - { - strcat(targetDir,"fluidsurface_preview_####"); - } - else - { // 3 - strcat(targetDir,"fluidsurface_final_####"); - } - - BLI_path_abs(targetDir, G.sce); - BLI_path_frame(targetDir, curFrame, 0); // fixed #frame-no - - strcpy(targetFile,targetDir); - strcat(targetFile, ".bobj.gz"); - - dm = fluidsim_read_obj(targetFile); - - if(!dm) - { - // switch, abort background rendering when fluidsim mesh is missing - const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp - - if(G.background==1) { - if(getenv(strEnvName2)) { - int elevel = atoi(getenv(strEnvName2)); - if(elevel>0) { - printf("Env. var %s set, fluid sim mesh '%s' not found, aborting render...\n",strEnvName2, targetFile); - exit(1); - } - } - } - - // display org. object upon failure which is in dm - return NULL; - } - - // assign material + flags to new dm - mface = orgdm->getFaceArray(orgdm); - mat_nr = mface[0].mat_nr; - flag = mface[0].flag; - - mface = dm->getFaceArray(dm); - numfaces = dm->getNumFaces(dm); - for(i=0; imeshSurfNormals) - MEM_freeN(fss->meshSurfNormals); - - fss->meshSurfNormals = NULL; - } - - return dm; -} - - -/* read zipped fluidsim velocities into the co's of the fluidsimsettings normals struct */ -void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *dm, char *filename) -{ - int wri, i, j; - float wrf; - gzFile gzf; - FluidsimSettings *fss = fluidmd->fss; - int len = strlen(filename); - int totvert = dm->getNumVerts(dm); - float *velarray = NULL; - - // mesh and vverts have to be valid from loading... - - if(fss->meshSurfNormals) - MEM_freeN(fss->meshSurfNormals); - - if(len<7) - { - return; - } - - if(fss->domainNovecgen>0) return; - - // abusing pointer to hold an array of 3d-velocities - fss->meshSurfNormals = MEM_callocN(sizeof(float)*3*dm->getNumVerts(dm), "Fluidsim_velocities"); - // abusing pointer to hold an INT - fss->meshSurface = SET_INT_IN_POINTER(totvert); - - velarray = (float *)fss->meshSurfNormals; - - // .bobj.gz , correct filename - // 87654321 - filename[len-6] = 'v'; - filename[len-5] = 'e'; - filename[len-4] = 'l'; - - gzf = gzopen(filename, "rb"); - if (!gzf) - { - MEM_freeN(fss->meshSurfNormals); - fss->meshSurfNormals = NULL; - return; - } - - gzread(gzf, &wri, sizeof( wri )); - if(wri != totvert) - { - MEM_freeN(fss->meshSurfNormals); - fss->meshSurfNormals = NULL; - return; - } - - for(i=0; i bbex){ bbex= vec[0]; } - if(vec[1] > bbey){ bbey= vec[1]; } - if(vec[2] > bbez){ bbez= vec[2]; } - } - - // return values... - if(start) { - start[0] = bbsx; - start[1] = bbsy; - start[2] = bbsz; - } - if(size) { - size[0] = bbex-bbsx; - size[1] = bbey-bbsy; - size[2] = bbez-bbsz; - } -} - -//------------------------------------------------------------------------------- -// old interface -//------------------------------------------------------------------------------- - - //------------------------------------------------------------------------------- // file handling //------------------------------------------------------------------------------- -void initElbeemMesh(struct Scene *scene, struct Object *ob, - int *numVertices, float **vertices, +void initElbeemMesh(struct Scene *scene, struct Object *ob, + int *numVertices, float **vertices, int *numTriangles, int **triangles, - int useGlobalCoords, int modifierIndex) + int useGlobalCoords, int modifierIndex) { DerivedMesh *dm = NULL; MVert *mvert; @@ -650,14 +109,14 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, face[2] = mface[i].v3; face[3] = mface[i].v4; - tris[countTris*3+0] = face[0]; - tris[countTris*3+1] = face[1]; - tris[countTris*3+2] = face[2]; + tris[countTris*3+0] = face[0]; + tris[countTris*3+1] = face[1]; + tris[countTris*3+2] = face[2]; countTris++; - if(face[3]) { - tris[countTris*3+0] = face[0]; - tris[countTris*3+1] = face[2]; - tris[countTris*3+2] = face[3]; + if(face[3]) { + tris[countTris*3+0] = face[0]; + tris[countTris*3+1] = face[2]; + tris[countTris*3+2] = face[3]; countTris++; } } @@ -665,21 +124,3 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, dm->release(dm); } - -void fluid_estimate_memory(Object *ob, FluidsimSettings *fss, char *value) -{ - Mesh *mesh; - - value[0]= '\0'; - - if(ob->type == OB_MESH) { - /* use mesh bounding box and object scaling */ - mesh= ob->data; - - fluid_get_bb(mesh->mvert, mesh->totvert, ob->obmat, fss->bbStart, fss->bbSize); - elbeemEstimateMemreq(fss->resolutionxyz, fss->bbSize[0],fss->bbSize[1],fss->bbSize[2], fss->maxRefine, value); - } -} - -#endif // DISABLE_ELBEEM - diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index c8f98bbac56..d2d9d558b3c 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -81,9863 +81,73 @@ #include "depsgraph_private.h" #include "BKE_deform.h" #include "BKE_shrinkwrap.h" -#include "BKE_simple_deform.h" - -#include "LOD_decimation.h" #include "CCGSubSurf.h" #include "RE_shader_ext.h" -/* Utility */ +#include "MOD_modifiertypes.h" -static int is_last_displist(Object *ob) +ModifierTypeInfo *modifierType_getInfo(ModifierType type) { - Curve *cu = ob->data; - static int curvecount=0, totcurve=0; - - if(curvecount == 0){ - DispList *dl; - - totcurve = 0; - for(dl=cu->disp.first; dl; dl=dl->next) - totcurve++; - } - - curvecount++; - - if(curvecount == totcurve){ - curvecount = 0; - return 1; - } - - return 0; -} + static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]; + static int types_init = 1; -/* returns a derived mesh if dm == NULL, for deforming modifiers that need it */ -static DerivedMesh *get_dm(Scene *scene, Object *ob, EditMesh *em, DerivedMesh *dm, float (*vertexCos)[3], int orco) -{ - if(dm) - return dm; + if (types_init) { + memset(types, 0, sizeof(types)); - if(ob->type==OB_MESH) { - if(em) dm= CDDM_from_editmesh(em, ob->data); - else dm = CDDM_from_mesh((Mesh*)(ob->data), ob); +#define INIT_TYPE(typeName) \ + (types[eModifierType_##typeName] = &modifierType_##typeName) + + INIT_TYPE(None); + INIT_TYPE(Curve); + INIT_TYPE(Lattice); + INIT_TYPE(Subsurf); + INIT_TYPE(Build); + INIT_TYPE(Array); + INIT_TYPE(Mirror); + INIT_TYPE(EdgeSplit); + INIT_TYPE(Bevel); + INIT_TYPE(Displace); + INIT_TYPE(UVProject); + INIT_TYPE(Decimate); + INIT_TYPE(Smooth); + INIT_TYPE(Cast); + INIT_TYPE(Wave); + INIT_TYPE(Armature); + INIT_TYPE(Hook); + INIT_TYPE(Softbody); + INIT_TYPE(Cloth); + INIT_TYPE(Collision); + INIT_TYPE(Boolean); + INIT_TYPE(MeshDeform); + INIT_TYPE(ParticleSystem); + INIT_TYPE(ParticleInstance); + INIT_TYPE(Explode); + INIT_TYPE(Cloth); + INIT_TYPE(Collision); + INIT_TYPE(Bevel); + INIT_TYPE(Shrinkwrap); + INIT_TYPE(Fluidsim); + INIT_TYPE(Mask); + INIT_TYPE(SimpleDeform); + INIT_TYPE(Multires); + INIT_TYPE(Surface); + INIT_TYPE(Smoke); + INIT_TYPE(ShapeKey); + INIT_TYPE(Solidify); + INIT_TYPE(Screw); + + types_init = 0; - if(vertexCos) { - CDDM_apply_vert_coords(dm, vertexCos); - //CDDM_calc_normals(dm); - } - - if(orco) - DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob)); - } - else if(ELEM3(ob->type,OB_FONT,OB_CURVE,OB_SURF)) { - if(is_last_displist(ob)) { - dm= CDDM_from_curve(ob); - } +#undef INIT_TYPE } - return dm; -} - -/* returns a cdderivedmesh if dm == NULL or is another type of derivedmesh */ -static DerivedMesh *get_cddm(Scene *scene, Object *ob, EditMesh *em, DerivedMesh *dm, float (*vertexCos)[3]) -{ - if(dm && dm->type == DM_TYPE_CDDM) - return dm; - - if(!dm) { - dm= get_dm(scene, ob, em, dm, vertexCos, 0); + if(type >= 0 && type < NUM_MODIFIER_TYPES && + types[type]->name[0] != '\0') { + return types[type]; } else { - dm= CDDM_copy(dm); - CDDM_apply_vert_coords(dm, vertexCos); - } - - if(dm) - CDDM_calc_normals(dm); - - return dm; -} - -/***/ - -static int noneModifier_isDisabled(ModifierData *md, int userRenderParams) -{ - return 1; -} - -/* Curve */ - -static void curveModifier_initData(ModifierData *md) -{ - CurveModifierData *cmd = (CurveModifierData*) md; - - cmd->defaxis = MOD_CURVE_POSX; -} - -static void curveModifier_copyData(ModifierData *md, ModifierData *target) -{ - CurveModifierData *cmd = (CurveModifierData*) md; - CurveModifierData *tcmd = (CurveModifierData*) target; - - tcmd->defaxis = cmd->defaxis; - tcmd->object = cmd->object; - strncpy(tcmd->name, cmd->name, 32); -} - -static CustomDataMask curveModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - CurveModifierData *cmd = (CurveModifierData *)md; - CustomDataMask dataMask = 0; - - /* ask for vertexgroups if we need them */ - if(cmd->name[0]) dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static int curveModifier_isDisabled(ModifierData *md, int userRenderParams) -{ - CurveModifierData *cmd = (CurveModifierData*) md; - - return !cmd->object; -} - -static void curveModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - CurveModifierData *cmd = (CurveModifierData*) md; - - walk(userData, ob, &cmd->object); -} - -static void curveModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) -{ - CurveModifierData *cmd = (CurveModifierData*) md; - - if (cmd->object) { - DagNode *curNode = dag_get_node(forest, cmd->object); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Curve Modifier"); - } -} - -static void curveModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - CurveModifierData *cmd = (CurveModifierData*) md; - - curve_deform_verts(md->scene, cmd->object, ob, derivedData, vertexCos, numVerts, - cmd->name, cmd->defaxis); -} - -static void curveModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm = derivedData; - - if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); - - curveModifier_deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0); - - if(!derivedData) dm->release(dm); -} - -/* Lattice */ - -static void latticeModifier_copyData(ModifierData *md, ModifierData *target) -{ - LatticeModifierData *lmd = (LatticeModifierData*) md; - LatticeModifierData *tlmd = (LatticeModifierData*) target; - - tlmd->object = lmd->object; - strncpy(tlmd->name, lmd->name, 32); -} - -static CustomDataMask latticeModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - LatticeModifierData *lmd = (LatticeModifierData *)md; - CustomDataMask dataMask = 0; - - /* ask for vertexgroups if we need them */ - if(lmd->name[0]) dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static int latticeModifier_isDisabled(ModifierData *md, int userRenderParams) -{ - LatticeModifierData *lmd = (LatticeModifierData*) md; - - return !lmd->object; -} - -static void latticeModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - LatticeModifierData *lmd = (LatticeModifierData*) md; - - walk(userData, ob, &lmd->object); -} - -static void latticeModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) -{ - LatticeModifierData *lmd = (LatticeModifierData*) md; - - if(lmd->object) { - DagNode *latNode = dag_get_node(forest, lmd->object); - - dag_add_relation(forest, latNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Lattice Modifier"); - } -} - -static void modifier_vgroup_cache(ModifierData *md, float (*vertexCos)[3]) -{ - while((md=md->next) && md->type==eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; - if(amd->multi && amd->prevCos==NULL) - amd->prevCos= MEM_dupallocN(vertexCos); - else - break; - } - /* lattice/mesh modifier too */ -} - - -static void latticeModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - LatticeModifierData *lmd = (LatticeModifierData*) md; - - - modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ - - lattice_deform_verts(lmd->object, ob, derivedData, - vertexCos, numVerts, lmd->name); -} - -static void latticeModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm = derivedData; - - if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); - - latticeModifier_deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0); - - if(!derivedData) dm->release(dm); -} - -/* Subsurf */ - -static void subsurfModifier_initData(ModifierData *md) -{ - SubsurfModifierData *smd = (SubsurfModifierData*) md; - - smd->levels = 1; - smd->renderLevels = 2; - smd->flags |= eSubsurfModifierFlag_SubsurfUv; -} - -static void subsurfModifier_copyData(ModifierData *md, ModifierData *target) -{ - SubsurfModifierData *smd = (SubsurfModifierData*) md; - SubsurfModifierData *tsmd = (SubsurfModifierData*) target; - - tsmd->flags = smd->flags; - tsmd->levels = smd->levels; - tsmd->renderLevels = smd->renderLevels; - tsmd->subdivType = smd->subdivType; -} - -static void subsurfModifier_freeData(ModifierData *md) -{ - SubsurfModifierData *smd = (SubsurfModifierData*) md; - - if(smd->mCache) { - ccgSubSurf_free(smd->mCache); - } - if(smd->emCache) { - ccgSubSurf_free(smd->emCache); - } -} - -static int subsurfModifier_isDisabled(ModifierData *md, int useRenderParams) -{ - SubsurfModifierData *smd = (SubsurfModifierData*) md; - int levels= (useRenderParams)? smd->renderLevels: smd->levels; - - return get_render_subsurf_level(&md->scene->r, levels) == 0; -} - -static DerivedMesh *subsurfModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - SubsurfModifierData *smd = (SubsurfModifierData*) md; - DerivedMesh *result; - - result = subsurf_make_derived_from_derived(derivedData, smd, - useRenderParams, NULL, isFinalCalc, 0); - - if(useRenderParams || !isFinalCalc) { - DerivedMesh *cddm= CDDM_copy(result); - result->release(result); - result= cddm; - } - - return result; -} - -static DerivedMesh *subsurfModifier_applyModifierEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData) -{ - SubsurfModifierData *smd = (SubsurfModifierData*) md; - DerivedMesh *result; - - result = subsurf_make_derived_from_derived(derivedData, smd, 0, - NULL, 0, 1); - - return result; -} - -/* Build */ - -static void buildModifier_initData(ModifierData *md) -{ - BuildModifierData *bmd = (BuildModifierData*) md; - - bmd->start = 1.0; - bmd->length = 100.0; -} - -static void buildModifier_copyData(ModifierData *md, ModifierData *target) -{ - BuildModifierData *bmd = (BuildModifierData*) md; - BuildModifierData *tbmd = (BuildModifierData*) target; - - tbmd->start = bmd->start; - tbmd->length = bmd->length; - tbmd->randomize = bmd->randomize; - tbmd->seed = bmd->seed; -} - -static int buildModifier_dependsOnTime(ModifierData *md) -{ - return 1; -} - -static DerivedMesh *buildModifier_applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm = derivedData; - DerivedMesh *result; - BuildModifierData *bmd = (BuildModifierData*) md; - int i; - int numFaces, numEdges; - int maxVerts, maxEdges, maxFaces; - int *vertMap, *edgeMap, *faceMap; - float frac; - GHashIterator *hashIter; - /* maps vert indices in old mesh to indices in new mesh */ - GHash *vertHash = BLI_ghash_new(BLI_ghashutil_inthash, - BLI_ghashutil_intcmp); - /* maps edge indices in new mesh to indices in old mesh */ - GHash *edgeHash = BLI_ghash_new(BLI_ghashutil_inthash, - BLI_ghashutil_intcmp); - - maxVerts = dm->getNumVerts(dm); - vertMap = MEM_callocN(sizeof(*vertMap) * maxVerts, - "build modifier vertMap"); - for(i = 0; i < maxVerts; ++i) vertMap[i] = i; - - maxEdges = dm->getNumEdges(dm); - edgeMap = MEM_callocN(sizeof(*edgeMap) * maxEdges, - "build modifier edgeMap"); - for(i = 0; i < maxEdges; ++i) edgeMap[i] = i; - - maxFaces = dm->getNumFaces(dm); - faceMap = MEM_callocN(sizeof(*faceMap) * maxFaces, - "build modifier faceMap"); - for(i = 0; i < maxFaces; ++i) faceMap[i] = i; - - if (ob) { - frac = bsystem_time(md->scene, ob, md->scene->r.cfra, - bmd->start - 1.0f) / bmd->length; - } else { - frac = md->scene->r.cfra - bmd->start / bmd->length; - } - CLAMP(frac, 0.0, 1.0); - - numFaces = dm->getNumFaces(dm) * frac; - numEdges = dm->getNumEdges(dm) * frac; - - /* if there's at least one face, build based on faces */ - if(numFaces) { - int maxEdges; - - if(bmd->randomize) - BLI_array_randomize(faceMap, sizeof(*faceMap), - maxFaces, bmd->seed); - - /* get the set of all vert indices that will be in the final mesh, - * mapped to the new indices - */ - for(i = 0; i < numFaces; ++i) { - MFace mf; - dm->getFace(dm, faceMap[i], &mf); - - if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v1))) - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(mf.v1), - SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); - if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v2))) - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(mf.v2), - SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); - if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v3))) - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(mf.v3), - SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); - if(mf.v4 && !BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v4))) - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(mf.v4), - SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); - } - - /* get the set of edges that will be in the new mesh (i.e. all edges - * that have both verts in the new mesh) - */ - maxEdges = dm->getNumEdges(dm); - for(i = 0; i < maxEdges; ++i) { - MEdge me; - dm->getEdge(dm, i, &me); - - if(BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v1)) - && BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v2))) - BLI_ghash_insert(edgeHash, - SET_INT_IN_POINTER(BLI_ghash_size(edgeHash)), SET_INT_IN_POINTER(i)); - } - } else if(numEdges) { - if(bmd->randomize) - BLI_array_randomize(edgeMap, sizeof(*edgeMap), - maxEdges, bmd->seed); - - /* get the set of all vert indices that will be in the final mesh, - * mapped to the new indices - */ - for(i = 0; i < numEdges; ++i) { - MEdge me; - dm->getEdge(dm, edgeMap[i], &me); - - if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v1))) - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(me.v1), - SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); - if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v2))) - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(me.v2), - SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); - } - - /* get the set of edges that will be in the new mesh - */ - for(i = 0; i < numEdges; ++i) { - MEdge me; - dm->getEdge(dm, edgeMap[i], &me); - - BLI_ghash_insert(edgeHash, SET_INT_IN_POINTER(BLI_ghash_size(edgeHash)), - SET_INT_IN_POINTER(edgeMap[i])); - } - } else { - int numVerts = dm->getNumVerts(dm) * frac; - - if(bmd->randomize) - BLI_array_randomize(vertMap, sizeof(*vertMap), - maxVerts, bmd->seed); - - /* get the set of all vert indices that will be in the final mesh, - * mapped to the new indices - */ - for(i = 0; i < numVerts; ++i) - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(vertMap[i]), SET_INT_IN_POINTER(i)); - } - - /* now we know the number of verts, edges and faces, we can create - * the mesh - */ - result = CDDM_from_template(dm, BLI_ghash_size(vertHash), - BLI_ghash_size(edgeHash), numFaces); - - /* copy the vertices across */ - for(hashIter = BLI_ghashIterator_new(vertHash); - !BLI_ghashIterator_isDone(hashIter); - BLI_ghashIterator_step(hashIter)) { - MVert source; - MVert *dest; - int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); - int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); - - dm->getVert(dm, oldIndex, &source); - dest = CDDM_get_vert(result, newIndex); - - DM_copy_vert_data(dm, result, oldIndex, newIndex, 1); - *dest = source; - } - BLI_ghashIterator_free(hashIter); - - /* copy the edges across, remapping indices */ - for(i = 0; i < BLI_ghash_size(edgeHash); ++i) { - MEdge source; - MEdge *dest; - int oldIndex = GET_INT_FROM_POINTER(BLI_ghash_lookup(edgeHash, SET_INT_IN_POINTER(i))); - - dm->getEdge(dm, oldIndex, &source); - dest = CDDM_get_edge(result, i); - - source.v1 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v1))); - source.v2 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v2))); - - DM_copy_edge_data(dm, result, oldIndex, i, 1); - *dest = source; - } - - /* copy the faces across, remapping indices */ - for(i = 0; i < numFaces; ++i) { - MFace source; - MFace *dest; - int orig_v4; - - dm->getFace(dm, faceMap[i], &source); - dest = CDDM_get_face(result, i); - - orig_v4 = source.v4; - - source.v1 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v1))); - source.v2 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v2))); - source.v3 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v3))); - if(source.v4) - source.v4 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v4))); - - DM_copy_face_data(dm, result, faceMap[i], i, 1); - *dest = source; - - test_index_face(dest, &result->faceData, i, (orig_v4 ? 4 : 3)); - } - - CDDM_calc_normals(result); - - BLI_ghash_free(vertHash, NULL, NULL); - BLI_ghash_free(edgeHash, NULL, NULL); - - MEM_freeN(vertMap); - MEM_freeN(edgeMap); - MEM_freeN(faceMap); - - return result; -} - -/* Mask */ - -static void maskModifier_copyData(ModifierData *md, ModifierData *target) -{ - MaskModifierData *mmd = (MaskModifierData*) md; - MaskModifierData *tmmd = (MaskModifierData*) target; - - strcpy(tmmd->vgroup, mmd->vgroup); -} - -static CustomDataMask maskModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - return (1 << CD_MDEFORMVERT); -} - -static void maskModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - MaskModifierData *mmd = (MaskModifierData *)md; - walk(userData, ob, &mmd->ob_arm); -} - -static void maskModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) -{ - MaskModifierData *mmd = (MaskModifierData *)md; - - if (mmd->ob_arm) - { - DagNode *armNode = dag_get_node(forest, mmd->ob_arm); - - dag_add_relation(forest, armNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Mask Modifier"); - } -} - -static DerivedMesh *maskModifier_applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - MaskModifierData *mmd= (MaskModifierData *)md; - DerivedMesh *dm= derivedData, *result= NULL; - GHash *vertHash=NULL, *edgeHash, *faceHash; - GHashIterator *hashIter; - MDeformVert *dvert= NULL; - int numFaces=0, numEdges=0, numVerts=0; - int maxVerts, maxEdges, maxFaces; - int i; - - /* Overview of Method: - * 1. Get the vertices that are in the vertexgroup of interest - * 2. Filter out unwanted geometry (i.e. not in vertexgroup), by populating mappings with new vs old indices - * 3. Make a new mesh containing only the mapping data - */ - - /* get original number of verts, edges, and faces */ - maxVerts= dm->getNumVerts(dm); - maxEdges= dm->getNumEdges(dm); - maxFaces= dm->getNumFaces(dm); - - /* check if we can just return the original mesh - * - must have verts and therefore verts assigned to vgroups to do anything useful - */ - if ( !(ELEM(mmd->mode, MOD_MASK_MODE_ARM, MOD_MASK_MODE_VGROUP)) || - (maxVerts == 0) || (ob->defbase.first == NULL) ) - { - return derivedData; - } - - /* if mode is to use selected armature bones, aggregate the bone groups */ - if (mmd->mode == MOD_MASK_MODE_ARM) /* --- using selected bones --- */ - { - GHash *vgroupHash, *boneHash; - Object *oba= mmd->ob_arm; - bPoseChannel *pchan; - bDeformGroup *def; - - /* check that there is armature object with bones to use, otherwise return original mesh */ - if (ELEM(NULL, mmd->ob_arm, mmd->ob_arm->pose)) - return derivedData; - - /* hashes for finding mapping of: - * - vgroups to indicies -> vgroupHash (string, int) - * - bones to vgroup indices -> boneHash (index of vgroup, dummy) - */ - vgroupHash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); - boneHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); - - /* build mapping of names of vertex groups to indices */ - for (i = 0, def = ob->defbase.first; def; def = def->next, i++) - BLI_ghash_insert(vgroupHash, def->name, SET_INT_IN_POINTER(i)); - - /* get selected-posechannel <-> vertexgroup index mapping */ - for (pchan= oba->pose->chanbase.first; pchan; pchan= pchan->next) - { - /* check if bone is selected */ - // TODO: include checks for visibility too? - // FIXME: the depsgraph needs extensions to make this work in realtime... - if ( (pchan->bone) && (pchan->bone->flag & BONE_SELECTED) ) - { - /* check if hash has group for this bone */ - if (BLI_ghash_haskey(vgroupHash, pchan->name)) - { - int defgrp_index= GET_INT_FROM_POINTER(BLI_ghash_lookup(vgroupHash, pchan->name)); - - /* add index to hash (store under key only) */ - BLI_ghash_insert(boneHash, SET_INT_IN_POINTER(defgrp_index), pchan); - } - } - } - - /* if no bones selected, free hashes and return original mesh */ - if (BLI_ghash_size(boneHash) == 0) - { - BLI_ghash_free(vgroupHash, NULL, NULL); - BLI_ghash_free(boneHash, NULL, NULL); - - return derivedData; - } - - /* repeat the previous check, but for dverts */ - dvert= dm->getVertDataArray(dm, CD_MDEFORMVERT); - if (dvert == NULL) - { - BLI_ghash_free(vgroupHash, NULL, NULL); - BLI_ghash_free(boneHash, NULL, NULL); - - return derivedData; - } - - /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); - - /* add vertices which exist in vertexgroups into vertHash for filtering */ - for (i = 0; i < maxVerts; i++) - { - MDeformWeight *def_weight = NULL; - int j; - - for (j= 0; j < dvert[i].totweight; j++) - { - if (BLI_ghash_haskey(boneHash, SET_INT_IN_POINTER(dvert[i].dw[j].def_nr))) - { - def_weight = &dvert[i].dw[j]; - break; - } - } - - /* check if include vert in vertHash */ - if (mmd->flag & MOD_MASK_INV) { - /* if this vert is in the vgroup, don't include it in vertHash */ - if (def_weight) continue; - } - else { - /* if this vert isn't in the vgroup, don't include it in vertHash */ - if (!def_weight) continue; - } - - /* add to ghash for verts (numVerts acts as counter for mapping) */ - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(numVerts)); - numVerts++; - } - - /* free temp hashes */ - BLI_ghash_free(vgroupHash, NULL, NULL); - BLI_ghash_free(boneHash, NULL, NULL); - } - else /* --- Using Nominated VertexGroup only --- */ - { - int defgrp_index = defgroup_name_index(ob, mmd->vgroup); - - /* get dverts */ - if (defgrp_index >= 0) - dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - - /* if no vgroup (i.e. dverts) found, return the initial mesh */ - if ((defgrp_index < 0) || (dvert == NULL)) - return dm; - - /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); - - /* add vertices which exist in vertexgroup into ghash for filtering */ - for (i = 0; i < maxVerts; i++) - { - MDeformWeight *def_weight = NULL; - int j; - - for (j= 0; j < dvert[i].totweight; j++) - { - if (dvert[i].dw[j].def_nr == defgrp_index) - { - def_weight = &dvert[i].dw[j]; - break; - } - } - - /* check if include vert in vertHash */ - if (mmd->flag & MOD_MASK_INV) { - /* if this vert is in the vgroup, don't include it in vertHash */ - if (def_weight) continue; - } - else { - /* if this vert isn't in the vgroup, don't include it in vertHash */ - if (!def_weight) continue; - } - - /* add to ghash for verts (numVerts acts as counter for mapping) */ - BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(numVerts)); - numVerts++; - } - } - - /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - edgeHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); - faceHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); - - /* loop over edges and faces, and do the same thing to - * ensure that they only reference existing verts - */ - for (i = 0; i < maxEdges; i++) - { - MEdge me; - dm->getEdge(dm, i, &me); - - /* only add if both verts will be in new mesh */ - if ( BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v1)) && - BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me.v2)) ) - { - BLI_ghash_insert(edgeHash, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(numEdges)); - numEdges++; - } - } - for (i = 0; i < maxFaces; i++) - { - MFace mf; - dm->getFace(dm, i, &mf); - - /* all verts must be available */ - if ( BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v1)) && - BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v2)) && - BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v3)) && - (mf.v4==0 || BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(mf.v4))) ) - { - BLI_ghash_insert(faceHash, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(numFaces)); - numFaces++; - } - } - - - /* now we know the number of verts, edges and faces, - * we can create the new (reduced) mesh - */ - result = CDDM_from_template(dm, numVerts, numEdges, numFaces); - - - /* using ghash-iterators, map data into new mesh */ - /* vertices */ - for ( hashIter = BLI_ghashIterator_new(vertHash); - !BLI_ghashIterator_isDone(hashIter); - BLI_ghashIterator_step(hashIter) ) - { - MVert source; - MVert *dest; - int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); - int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); - - dm->getVert(dm, oldIndex, &source); - dest = CDDM_get_vert(result, newIndex); - - DM_copy_vert_data(dm, result, oldIndex, newIndex, 1); - *dest = source; - } - BLI_ghashIterator_free(hashIter); - - /* edges */ - for ( hashIter = BLI_ghashIterator_new(edgeHash); - !BLI_ghashIterator_isDone(hashIter); - BLI_ghashIterator_step(hashIter) ) - { - MEdge source; - MEdge *dest; - int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); - int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); - - dm->getEdge(dm, oldIndex, &source); - dest = CDDM_get_edge(result, newIndex); - - source.v1 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v1))); - source.v2 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v2))); - - DM_copy_edge_data(dm, result, oldIndex, newIndex, 1); - *dest = source; - } - BLI_ghashIterator_free(hashIter); - - /* faces */ - for ( hashIter = BLI_ghashIterator_new(faceHash); - !BLI_ghashIterator_isDone(hashIter); - BLI_ghashIterator_step(hashIter) ) - { - MFace source; - MFace *dest; - int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); - int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); - int orig_v4; - - dm->getFace(dm, oldIndex, &source); - dest = CDDM_get_face(result, newIndex); - - orig_v4 = source.v4; - - source.v1 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v1))); - source.v2 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v2))); - source.v3 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v3))); - if (source.v4) - source.v4 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v4))); - - DM_copy_face_data(dm, result, oldIndex, newIndex, 1); - *dest = source; - - test_index_face(dest, &result->faceData, newIndex, (orig_v4 ? 4 : 3)); - } - BLI_ghashIterator_free(hashIter); - - /* recalculate normals */ - CDDM_calc_normals(result); - - /* free hashes */ - BLI_ghash_free(vertHash, NULL, NULL); - BLI_ghash_free(edgeHash, NULL, NULL); - BLI_ghash_free(faceHash, NULL, NULL); - - /* return the new mesh */ - return result; -} - -/* Array */ -/* Array modifier: duplicates the object multiple times along an axis -*/ - -static void arrayModifier_initData(ModifierData *md) -{ - ArrayModifierData *amd = (ArrayModifierData*) md; - - /* default to 2 duplicates distributed along the x-axis by an - offset of 1 object-width - */ - amd->start_cap = amd->end_cap = amd->curve_ob = amd->offset_ob = NULL; - amd->count = 2; - amd->offset[0] = amd->offset[1] = amd->offset[2] = 0; - amd->scale[0] = 1; - amd->scale[1] = amd->scale[2] = 0; - amd->length = 0; - amd->merge_dist = 0.01; - amd->fit_type = MOD_ARR_FIXEDCOUNT; - amd->offset_type = MOD_ARR_OFF_RELATIVE; - amd->flags = 0; -} - -static void arrayModifier_copyData(ModifierData *md, ModifierData *target) -{ - ArrayModifierData *amd = (ArrayModifierData*) md; - ArrayModifierData *tamd = (ArrayModifierData*) target; - - tamd->start_cap = amd->start_cap; - tamd->end_cap = amd->end_cap; - tamd->curve_ob = amd->curve_ob; - tamd->offset_ob = amd->offset_ob; - tamd->count = amd->count; - VECCOPY(tamd->offset, amd->offset); - VECCOPY(tamd->scale, amd->scale); - tamd->length = amd->length; - tamd->merge_dist = amd->merge_dist; - tamd->fit_type = amd->fit_type; - tamd->offset_type = amd->offset_type; - tamd->flags = amd->flags; -} - -static void arrayModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - ArrayModifierData *amd = (ArrayModifierData*) md; - - walk(userData, ob, &amd->start_cap); - walk(userData, ob, &amd->end_cap); - walk(userData, ob, &amd->curve_ob); - walk(userData, ob, &amd->offset_ob); -} - -static void arrayModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) -{ - ArrayModifierData *amd = (ArrayModifierData*) md; - - if (amd->start_cap) { - DagNode *curNode = dag_get_node(forest, amd->start_cap); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Array Modifier"); - } - if (amd->end_cap) { - DagNode *curNode = dag_get_node(forest, amd->end_cap); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Array Modifier"); - } - if (amd->curve_ob) { - DagNode *curNode = dag_get_node(forest, amd->curve_ob); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Array Modifier"); - } - if (amd->offset_ob) { - DagNode *curNode = dag_get_node(forest, amd->offset_ob); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Array Modifier"); - } -} - -static float vertarray_size(MVert *mvert, int numVerts, int axis) -{ - int i; - float min_co, max_co; - - /* if there are no vertices, width is 0 */ - if(numVerts == 0) return 0; - - /* find the minimum and maximum coordinates on the desired axis */ - min_co = max_co = mvert->co[axis]; - ++mvert; - for(i = 1; i < numVerts; ++i, ++mvert) { - if(mvert->co[axis] < min_co) min_co = mvert->co[axis]; - if(mvert->co[axis] > max_co) max_co = mvert->co[axis]; - } - - return max_co - min_co; -} - -typedef struct IndexMapEntry { - /* the new vert index that this old vert index maps to */ - int new; - /* -1 if this vert isn't merged, otherwise the old vert index it - * should be replaced with - */ - int merge; - /* 1 if this vert's first copy is merged with the last copy of its - * merge target, otherwise 0 - */ - short merge_final; -} IndexMapEntry; - -/* indexMap - an array of IndexMap entries - * oldIndex - the old index to map - * copyNum - the copy number to map to (original = 0, first copy = 1, etc.) - */ -static int calc_mapping(IndexMapEntry *indexMap, int oldIndex, int copyNum) -{ - if(indexMap[oldIndex].merge < 0) { - /* vert wasn't merged, so use copy of this vert */ - return indexMap[oldIndex].new + copyNum; - } else if(indexMap[oldIndex].merge == oldIndex) { - /* vert was merged with itself */ - return indexMap[oldIndex].new; - } else { - /* vert was merged with another vert */ - /* follow the chain of merges to the end, or until we've passed - * a number of vertices equal to the copy number - */ - if(copyNum <= 0) - return indexMap[oldIndex].new; - else - return calc_mapping(indexMap, indexMap[oldIndex].merge, - copyNum - 1); - } -} - -static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, - Scene *scene, Object *ob, DerivedMesh *dm, - int initFlags) -{ - int i, j; - /* offset matrix */ - float offset[4][4]; - float final_offset[4][4]; - float tmp_mat[4][4]; - float length = amd->length; - int count = amd->count; - int numVerts, numEdges, numFaces; - int maxVerts, maxEdges, maxFaces; - int finalVerts, finalEdges, finalFaces; - DerivedMesh *result, *start_cap = NULL, *end_cap = NULL; - MVert *mvert, *src_mvert; - MEdge *medge; - MFace *mface; - - IndexMapEntry *indexMap; - - EdgeHash *edges; - - /* need to avoid infinite recursion here */ - if(amd->start_cap && amd->start_cap != ob) - start_cap = amd->start_cap->derivedFinal; - if(amd->end_cap && amd->end_cap != ob) - end_cap = amd->end_cap->derivedFinal; - - unit_m4(offset); - - indexMap = MEM_callocN(sizeof(*indexMap) * dm->getNumVerts(dm), - "indexmap"); - - src_mvert = dm->getVertArray(dm); - - maxVerts = dm->getNumVerts(dm); - - if(amd->offset_type & MOD_ARR_OFF_CONST) - add_v3_v3v3(offset[3], offset[3], amd->offset); - if(amd->offset_type & MOD_ARR_OFF_RELATIVE) { - for(j = 0; j < 3; j++) - offset[3][j] += amd->scale[j] * vertarray_size(src_mvert, - maxVerts, j); - } - - if((amd->offset_type & MOD_ARR_OFF_OBJ) && (amd->offset_ob)) { - float obinv[4][4]; - float result_mat[4][4]; - - if(ob) - invert_m4_m4(obinv, ob->obmat); - else - unit_m4(obinv); - - mul_serie_m4(result_mat, offset, - obinv, amd->offset_ob->obmat, - NULL, NULL, NULL, NULL, NULL); - copy_m4_m4(offset, result_mat); - } - - if(amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) { - Curve *cu = amd->curve_ob->data; - if(cu) { - float tmp_mat[3][3]; - float scale; - - object_to_mat3(amd->curve_ob, tmp_mat); - scale = mat3_to_scale(tmp_mat); - - if(!cu->path) { - cu->flag |= CU_PATH; // needed for path & bevlist - makeDispListCurveTypes(scene, amd->curve_ob, 0); - } - if(cu->path) - length = scale*cu->path->totdist; - } - } - - /* calculate the maximum number of copies which will fit within the - prescribed length */ - if(amd->fit_type == MOD_ARR_FITLENGTH - || amd->fit_type == MOD_ARR_FITCURVE) { - float dist = sqrt(dot_v3v3(offset[3], offset[3])); - - if(dist > 1e-6f) - /* this gives length = first copy start to last copy end - add a tiny offset for floating point rounding errors */ - count = (length + 1e-6f) / dist; - else - /* if the offset has no translation, just make one copy */ - count = 1; - } - - if(count < 1) - count = 1; - - /* allocate memory for count duplicates (including original) plus - * start and end caps - */ - finalVerts = dm->getNumVerts(dm) * count; - finalEdges = dm->getNumEdges(dm) * count; - finalFaces = dm->getNumFaces(dm) * count; - if(start_cap) { - finalVerts += start_cap->getNumVerts(start_cap); - finalEdges += start_cap->getNumEdges(start_cap); - finalFaces += start_cap->getNumFaces(start_cap); - } - if(end_cap) { - finalVerts += end_cap->getNumVerts(end_cap); - finalEdges += end_cap->getNumEdges(end_cap); - finalFaces += end_cap->getNumFaces(end_cap); - } - result = CDDM_from_template(dm, finalVerts, finalEdges, finalFaces); - - /* calculate the offset matrix of the final copy (for merging) */ - unit_m4(final_offset); - - for(j=0; j < count - 1; j++) { - mul_m4_m4m4(tmp_mat, final_offset, offset); - copy_m4_m4(final_offset, tmp_mat); - } - - numVerts = numEdges = numFaces = 0; - mvert = CDDM_get_verts(result); - - for (i = 0; i < maxVerts; i++) { - indexMap[i].merge = -1; /* default to no merge */ - indexMap[i].merge_final = 0; /* default to no merge */ - } - - for (i = 0; i < maxVerts; i++) { - MVert *inMV; - MVert *mv = &mvert[numVerts]; - MVert *mv2; - float co[3]; - - inMV = &src_mvert[i]; - - DM_copy_vert_data(dm, result, i, numVerts, 1); - *mv = *inMV; - numVerts++; - - indexMap[i].new = numVerts - 1; - - VECCOPY(co, mv->co); - - /* Attempts to merge verts from one duplicate with verts from the - * next duplicate which are closer than amd->merge_dist. - * Only the first such vert pair is merged. - * If verts are merged in the first duplicate pair, they are merged - * in all pairs. - */ - if((count > 1) && (amd->flags & MOD_ARR_MERGE)) { - float tmp_co[3]; - VECCOPY(tmp_co, mv->co); - mul_m4_v3(offset, tmp_co); - - for(j = 0; j < maxVerts; j++) { - /* if vertex already merged, don't use it */ - if( indexMap[j].merge != -1 ) continue; - - inMV = &src_mvert[j]; - /* if this vert is within merge limit, merge */ - if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) { - indexMap[i].merge = j; - - /* test for merging with final copy of merge target */ - if(amd->flags & MOD_ARR_MERGEFINAL) { - VECCOPY(tmp_co, inMV->co); - inMV = &src_mvert[i]; - mul_m4_v3(final_offset, tmp_co); - if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) - indexMap[i].merge_final = 1; - } - break; - } - } - } - - /* if no merging, generate copies of this vert */ - if(indexMap[i].merge < 0) { - for(j=0; j < count - 1; j++) { - mv2 = &mvert[numVerts]; - - DM_copy_vert_data(result, result, numVerts - 1, numVerts, 1); - *mv2 = *mv; - numVerts++; - - mul_m4_v3(offset, co); - VECCOPY(mv2->co, co); - } - } else if(indexMap[i].merge != i && indexMap[i].merge_final) { - /* if this vert is not merging with itself, and it is merging - * with the final copy of its merge target, remove the first copy - */ - numVerts--; - DM_free_vert_data(result, numVerts, 1); - } - } - - /* make a hashtable so we can avoid duplicate edges from merging */ - edges = BLI_edgehash_new(); - - maxEdges = dm->getNumEdges(dm); - medge = CDDM_get_edges(result); - for(i = 0; i < maxEdges; i++) { - MEdge inMED; - MEdge med; - MEdge *med2; - int vert1, vert2; - - dm->getEdge(dm, i, &inMED); - - med = inMED; - med.v1 = indexMap[inMED.v1].new; - med.v2 = indexMap[inMED.v2].new; - - /* if vertices are to be merged with the final copies of their - * merge targets, calculate that final copy - */ - if(indexMap[inMED.v1].merge_final) { - med.v1 = calc_mapping(indexMap, indexMap[inMED.v1].merge, - count - 1); - } - if(indexMap[inMED.v2].merge_final) { - med.v2 = calc_mapping(indexMap, indexMap[inMED.v2].merge, - count - 1); - } - - if(med.v1 == med.v2) continue; - - if (initFlags) { - med.flag |= ME_EDGEDRAW | ME_EDGERENDER; - } - - if(!BLI_edgehash_haskey(edges, med.v1, med.v2)) { - DM_copy_edge_data(dm, result, i, numEdges, 1); - medge[numEdges] = med; - numEdges++; - - BLI_edgehash_insert(edges, med.v1, med.v2, NULL); - } - - for(j = 1; j < count; j++) - { - vert1 = calc_mapping(indexMap, inMED.v1, j); - vert2 = calc_mapping(indexMap, inMED.v2, j); - /* avoid duplicate edges */ - if(!BLI_edgehash_haskey(edges, vert1, vert2)) { - med2 = &medge[numEdges]; - - DM_copy_edge_data(dm, result, i, numEdges, 1); - *med2 = med; - numEdges++; - - med2->v1 = vert1; - med2->v2 = vert2; - - BLI_edgehash_insert(edges, med2->v1, med2->v2, NULL); - } - } - } - - maxFaces = dm->getNumFaces(dm); - mface = CDDM_get_faces(result); - for (i=0; i < maxFaces; i++) { - MFace inMF; - MFace *mf = &mface[numFaces]; - - dm->getFace(dm, i, &inMF); - - DM_copy_face_data(dm, result, i, numFaces, 1); - *mf = inMF; - - mf->v1 = indexMap[inMF.v1].new; - mf->v2 = indexMap[inMF.v2].new; - mf->v3 = indexMap[inMF.v3].new; - if(inMF.v4) - mf->v4 = indexMap[inMF.v4].new; - - /* if vertices are to be merged with the final copies of their - * merge targets, calculate that final copy - */ - if(indexMap[inMF.v1].merge_final) - mf->v1 = calc_mapping(indexMap, indexMap[inMF.v1].merge, count-1); - if(indexMap[inMF.v2].merge_final) - mf->v2 = calc_mapping(indexMap, indexMap[inMF.v2].merge, count-1); - if(indexMap[inMF.v3].merge_final) - mf->v3 = calc_mapping(indexMap, indexMap[inMF.v3].merge, count-1); - if(inMF.v4 && indexMap[inMF.v4].merge_final) - mf->v4 = calc_mapping(indexMap, indexMap[inMF.v4].merge, count-1); - - if(test_index_face(mf, &result->faceData, numFaces, inMF.v4?4:3) < 3) - continue; - - numFaces++; - - /* if the face has fewer than 3 vertices, don't create it */ - if(mf->v3 == 0 || (mf->v1 && (mf->v1 == mf->v3 || mf->v1 == mf->v4))) { - numFaces--; - DM_free_face_data(result, numFaces, 1); - } - - for(j = 1; j < count; j++) - { - MFace *mf2 = &mface[numFaces]; - - DM_copy_face_data(dm, result, i, numFaces, 1); - *mf2 = *mf; - - mf2->v1 = calc_mapping(indexMap, inMF.v1, j); - mf2->v2 = calc_mapping(indexMap, inMF.v2, j); - mf2->v3 = calc_mapping(indexMap, inMF.v3, j); - if (inMF.v4) - mf2->v4 = calc_mapping(indexMap, inMF.v4, j); - - test_index_face(mf2, &result->faceData, numFaces, inMF.v4?4:3); - numFaces++; - - /* if the face has fewer than 3 vertices, don't create it */ - if(mf2->v3 == 0 || (mf2->v1 && (mf2->v1 == mf2->v3 || mf2->v1 == - mf2->v4))) { - numFaces--; - DM_free_face_data(result, numFaces, 1); - } - } - } - - /* add start and end caps */ - if(start_cap) { - float startoffset[4][4]; - MVert *cap_mvert; - MEdge *cap_medge; - MFace *cap_mface; - int *origindex; - int *vert_map; - int capVerts, capEdges, capFaces; - - capVerts = start_cap->getNumVerts(start_cap); - capEdges = start_cap->getNumEdges(start_cap); - capFaces = start_cap->getNumFaces(start_cap); - cap_mvert = start_cap->getVertArray(start_cap); - cap_medge = start_cap->getEdgeArray(start_cap); - cap_mface = start_cap->getFaceArray(start_cap); - - invert_m4_m4(startoffset, offset); - - vert_map = MEM_callocN(sizeof(*vert_map) * capVerts, - "arrayModifier_doArray vert_map"); - - origindex = result->getVertDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capVerts; i++) { - MVert *mv = &cap_mvert[i]; - short merged = 0; - - if(amd->flags & MOD_ARR_MERGE) { - float tmp_co[3]; - MVert *in_mv; - int j; - - VECCOPY(tmp_co, mv->co); - mul_m4_v3(startoffset, tmp_co); - - for(j = 0; j < maxVerts; j++) { - in_mv = &src_mvert[j]; - /* if this vert is within merge limit, merge */ - if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) { - vert_map[i] = calc_mapping(indexMap, j, 0); - merged = 1; - break; - } - } - } - - if(!merged) { - DM_copy_vert_data(start_cap, result, i, numVerts, 1); - mvert[numVerts] = *mv; - mul_m4_v3(startoffset, mvert[numVerts].co); - origindex[numVerts] = ORIGINDEX_NONE; - - vert_map[i] = numVerts; - - numVerts++; - } - } - origindex = result->getEdgeDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capEdges; i++) { - int v1, v2; - - v1 = vert_map[cap_medge[i].v1]; - v2 = vert_map[cap_medge[i].v2]; - - if(!BLI_edgehash_haskey(edges, v1, v2)) { - DM_copy_edge_data(start_cap, result, i, numEdges, 1); - medge[numEdges] = cap_medge[i]; - medge[numEdges].v1 = v1; - medge[numEdges].v2 = v2; - origindex[numEdges] = ORIGINDEX_NONE; - - numEdges++; - } - } - origindex = result->getFaceDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capFaces; i++) { - DM_copy_face_data(start_cap, result, i, numFaces, 1); - mface[numFaces] = cap_mface[i]; - mface[numFaces].v1 = vert_map[mface[numFaces].v1]; - mface[numFaces].v2 = vert_map[mface[numFaces].v2]; - mface[numFaces].v3 = vert_map[mface[numFaces].v3]; - if(mface[numFaces].v4) { - mface[numFaces].v4 = vert_map[mface[numFaces].v4]; - - test_index_face(&mface[numFaces], &result->faceData, - numFaces, 4); - } - else - { - test_index_face(&mface[numFaces], &result->faceData, - numFaces, 3); - } - - origindex[numFaces] = ORIGINDEX_NONE; - - numFaces++; - } - - MEM_freeN(vert_map); - start_cap->release(start_cap); - } - - if(end_cap) { - float endoffset[4][4]; - MVert *cap_mvert; - MEdge *cap_medge; - MFace *cap_mface; - int *origindex; - int *vert_map; - int capVerts, capEdges, capFaces; - - capVerts = end_cap->getNumVerts(end_cap); - capEdges = end_cap->getNumEdges(end_cap); - capFaces = end_cap->getNumFaces(end_cap); - cap_mvert = end_cap->getVertArray(end_cap); - cap_medge = end_cap->getEdgeArray(end_cap); - cap_mface = end_cap->getFaceArray(end_cap); - - mul_m4_m4m4(endoffset, final_offset, offset); - - vert_map = MEM_callocN(sizeof(*vert_map) * capVerts, - "arrayModifier_doArray vert_map"); - - origindex = result->getVertDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capVerts; i++) { - MVert *mv = &cap_mvert[i]; - short merged = 0; - - if(amd->flags & MOD_ARR_MERGE) { - float tmp_co[3]; - MVert *in_mv; - int j; - - VECCOPY(tmp_co, mv->co); - mul_m4_v3(offset, tmp_co); - - for(j = 0; j < maxVerts; j++) { - in_mv = &src_mvert[j]; - /* if this vert is within merge limit, merge */ - if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) { - vert_map[i] = calc_mapping(indexMap, j, count - 1); - merged = 1; - break; - } - } - } - - if(!merged) { - DM_copy_vert_data(end_cap, result, i, numVerts, 1); - mvert[numVerts] = *mv; - mul_m4_v3(endoffset, mvert[numVerts].co); - origindex[numVerts] = ORIGINDEX_NONE; - - vert_map[i] = numVerts; - - numVerts++; - } - } - origindex = result->getEdgeDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capEdges; i++) { - int v1, v2; - - v1 = vert_map[cap_medge[i].v1]; - v2 = vert_map[cap_medge[i].v2]; - - if(!BLI_edgehash_haskey(edges, v1, v2)) { - DM_copy_edge_data(end_cap, result, i, numEdges, 1); - medge[numEdges] = cap_medge[i]; - medge[numEdges].v1 = v1; - medge[numEdges].v2 = v2; - origindex[numEdges] = ORIGINDEX_NONE; - - numEdges++; - } - } - origindex = result->getFaceDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capFaces; i++) { - DM_copy_face_data(end_cap, result, i, numFaces, 1); - mface[numFaces] = cap_mface[i]; - mface[numFaces].v1 = vert_map[mface[numFaces].v1]; - mface[numFaces].v2 = vert_map[mface[numFaces].v2]; - mface[numFaces].v3 = vert_map[mface[numFaces].v3]; - if(mface[numFaces].v4) { - mface[numFaces].v4 = vert_map[mface[numFaces].v4]; - - test_index_face(&mface[numFaces], &result->faceData, - numFaces, 4); - } - else - { - test_index_face(&mface[numFaces], &result->faceData, - numFaces, 3); - } - origindex[numFaces] = ORIGINDEX_NONE; - - numFaces++; - } - - MEM_freeN(vert_map); - end_cap->release(end_cap); - } - - BLI_edgehash_free(edges, NULL); - MEM_freeN(indexMap); - - CDDM_lower_num_verts(result, numVerts); - CDDM_lower_num_edges(result, numEdges); - CDDM_lower_num_faces(result, numFaces); - - return result; -} - -static DerivedMesh *arrayModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - DerivedMesh *result; - ArrayModifierData *amd = (ArrayModifierData*) md; - - result = arrayModifier_doArray(amd, md->scene, ob, derivedData, 0); - - if(result != derivedData) - CDDM_calc_normals(result); - - return result; -} - -static DerivedMesh *arrayModifier_applyModifierEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData) -{ - return arrayModifier_applyModifier(md, ob, derivedData, 0, 1); -} - -/* Mirror */ - -static void mirrorModifier_initData(ModifierData *md) -{ - MirrorModifierData *mmd = (MirrorModifierData*) md; - - mmd->flag |= (MOD_MIR_AXIS_X | MOD_MIR_VGROUP); - mmd->tolerance = 0.001; - mmd->mirror_ob = NULL; -} - -static void mirrorModifier_copyData(ModifierData *md, ModifierData *target) -{ - MirrorModifierData *mmd = (MirrorModifierData*) md; - MirrorModifierData *tmmd = (MirrorModifierData*) target; - - tmmd->axis = mmd->axis; - tmmd->flag = mmd->flag; - tmmd->tolerance = mmd->tolerance; - tmmd->mirror_ob = mmd->mirror_ob;; -} - -static void mirrorModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - MirrorModifierData *mmd = (MirrorModifierData*) md; - - walk(userData, ob, &mmd->mirror_ob); -} - -static void mirrorModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) -{ - MirrorModifierData *mmd = (MirrorModifierData*) md; - - if(mmd->mirror_ob) { - DagNode *latNode = dag_get_node(forest, mmd->mirror_ob); - - dag_add_relation(forest, latNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Mirror Modifier"); - } -} - -static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, - Object *ob, - DerivedMesh *dm, - int initFlags, - int axis) -{ - int i; - float tolerance = mmd->tolerance; - DerivedMesh *result; - int numVerts, numEdges, numFaces; - int maxVerts = dm->getNumVerts(dm); - int maxEdges = dm->getNumEdges(dm); - int maxFaces = dm->getNumFaces(dm); - int *flip_map= NULL; - int do_vgroup_mirr= (mmd->flag & MOD_MIR_VGROUP); - int (*indexMap)[2]; - float mtx[4][4], imtx[4][4]; - - numVerts = numEdges = numFaces = 0; - - indexMap = MEM_mallocN(sizeof(*indexMap) * maxVerts, "indexmap"); - - result = CDDM_from_template(dm, maxVerts * 2, maxEdges * 2, maxFaces * 2); - - - if (do_vgroup_mirr) { - flip_map= defgroup_flip_map(ob, 0); - if(flip_map == NULL) - do_vgroup_mirr= 0; - } - - if (mmd->mirror_ob) { - float obinv[4][4]; - - invert_m4_m4(obinv, mmd->mirror_ob->obmat); - mul_m4_m4m4(mtx, ob->obmat, obinv); - invert_m4_m4(imtx, mtx); - } - - for(i = 0; i < maxVerts; i++) { - MVert inMV; - MVert *mv = CDDM_get_vert(result, numVerts); - int isShared; - float co[3]; - - dm->getVert(dm, i, &inMV); - - copy_v3_v3(co, inMV.co); - - if (mmd->mirror_ob) { - mul_v3_m4v3(co, mtx, co); - } - isShared = ABS(co[axis])<=tolerance; - - /* Because the topology result (# of vertices) must be the same if - * the mesh data is overridden by vertex cos, have to calc sharedness - * based on original coordinates. This is why we test before copy. - */ - DM_copy_vert_data(dm, result, i, numVerts, 1); - *mv = inMV; - numVerts++; - - indexMap[i][0] = numVerts - 1; - indexMap[i][1] = !isShared; - - if(isShared) { - co[axis] = 0; - if (mmd->mirror_ob) { - mul_v3_m4v3(co, imtx, co); - } - copy_v3_v3(mv->co, co); - - mv->flag |= ME_VERT_MERGED; - } else { - MVert *mv2 = CDDM_get_vert(result, numVerts); - - DM_copy_vert_data(dm, result, i, numVerts, 1); - *mv2 = *mv; - - co[axis] = -co[axis]; - if (mmd->mirror_ob) { - mul_v3_m4v3(co, imtx, co); - } - copy_v3_v3(mv2->co, co); - - if (do_vgroup_mirr) { - MDeformVert *dvert= DM_get_vert_data(result, numVerts, CD_MDEFORMVERT); - if(dvert) { - defvert_flip(dvert, flip_map); - } - } - - numVerts++; - } - } - - for(i = 0; i < maxEdges; i++) { - MEdge inMED; - MEdge *med = CDDM_get_edge(result, numEdges); - - dm->getEdge(dm, i, &inMED); - - DM_copy_edge_data(dm, result, i, numEdges, 1); - *med = inMED; - numEdges++; - - med->v1 = indexMap[inMED.v1][0]; - med->v2 = indexMap[inMED.v2][0]; - if(initFlags) - med->flag |= ME_EDGEDRAW | ME_EDGERENDER; - - if(indexMap[inMED.v1][1] || indexMap[inMED.v2][1]) { - MEdge *med2 = CDDM_get_edge(result, numEdges); - - DM_copy_edge_data(dm, result, i, numEdges, 1); - *med2 = *med; - numEdges++; - - med2->v1 += indexMap[inMED.v1][1]; - med2->v2 += indexMap[inMED.v2][1]; - } - } - - for(i = 0; i < maxFaces; i++) { - MFace inMF; - MFace *mf = CDDM_get_face(result, numFaces); - - dm->getFace(dm, i, &inMF); - - DM_copy_face_data(dm, result, i, numFaces, 1); - *mf = inMF; - numFaces++; - - mf->v1 = indexMap[inMF.v1][0]; - mf->v2 = indexMap[inMF.v2][0]; - mf->v3 = indexMap[inMF.v3][0]; - mf->v4 = indexMap[inMF.v4][0]; - - if(indexMap[inMF.v1][1] - || indexMap[inMF.v2][1] - || indexMap[inMF.v3][1] - || (mf->v4 && indexMap[inMF.v4][1])) { - MFace *mf2 = CDDM_get_face(result, numFaces); - static int corner_indices[4] = {2, 1, 0, 3}; - - DM_copy_face_data(dm, result, i, numFaces, 1); - *mf2 = *mf; - - mf2->v1 += indexMap[inMF.v1][1]; - mf2->v2 += indexMap[inMF.v2][1]; - mf2->v3 += indexMap[inMF.v3][1]; - if(inMF.v4) mf2->v4 += indexMap[inMF.v4][1]; - - /* mirror UVs if enabled */ - if(mmd->flag & (MOD_MIR_MIRROR_U | MOD_MIR_MIRROR_V)) { - MTFace *tf = result->getFaceData(result, numFaces, CD_MTFACE); - if(tf) { - int j; - for(j = 0; j < 4; ++j) { - if(mmd->flag & MOD_MIR_MIRROR_U) - tf->uv[j][0] = 1.0f - tf->uv[j][0]; - if(mmd->flag & MOD_MIR_MIRROR_V) - tf->uv[j][1] = 1.0f - tf->uv[j][1]; - } - } - } - - /* Flip face normal */ - SWAP(int, mf2->v1, mf2->v3); - DM_swap_face_data(result, numFaces, corner_indices); - - test_index_face(mf2, &result->faceData, numFaces, inMF.v4?4:3); - numFaces++; - } - } - - if (flip_map) MEM_freeN(flip_map); - - MEM_freeN(indexMap); - - CDDM_lower_num_verts(result, numVerts); - CDDM_lower_num_edges(result, numEdges); - CDDM_lower_num_faces(result, numFaces); - - return result; -} - -static DerivedMesh *mirrorModifier__doMirror(MirrorModifierData *mmd, - Object *ob, DerivedMesh *dm, - int initFlags) -{ - DerivedMesh *result = dm; - - /* check which axes have been toggled and mirror accordingly */ - if(mmd->flag & MOD_MIR_AXIS_X) { - result = doMirrorOnAxis(mmd, ob, result, initFlags, 0); - } - if(mmd->flag & MOD_MIR_AXIS_Y) { - DerivedMesh *tmp = result; - result = doMirrorOnAxis(mmd, ob, result, initFlags, 1); - if(tmp != dm) tmp->release(tmp); /* free intermediate results */ - } - if(mmd->flag & MOD_MIR_AXIS_Z) { - DerivedMesh *tmp = result; - result = doMirrorOnAxis(mmd, ob, result, initFlags, 2); - if(tmp != dm) tmp->release(tmp); /* free intermediate results */ - } - - return result; -} - -static DerivedMesh *mirrorModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - DerivedMesh *result; - MirrorModifierData *mmd = (MirrorModifierData*) md; - - result = mirrorModifier__doMirror(mmd, ob, derivedData, 0); - - if(result != derivedData) - CDDM_calc_normals(result); - - return result; -} - -static DerivedMesh *mirrorModifier_applyModifierEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData) -{ - return mirrorModifier_applyModifier(md, ob, derivedData, 0, 1); -} - -/* EdgeSplit */ -/* EdgeSplit modifier: Splits edges in the mesh according to sharpness flag - * or edge angle (can be used to achieve autosmoothing) -*/ -#if 0 -#define EDGESPLIT_DEBUG_3 -#define EDGESPLIT_DEBUG_2 -#define EDGESPLIT_DEBUG_1 -#define EDGESPLIT_DEBUG_0 -#endif - -static void edgesplitModifier_initData(ModifierData *md) -{ - EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md; - - /* default to 30-degree split angle, sharpness from both angle & flag - */ - emd->split_angle = 30; - emd->flags = MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG; -} - -static void edgesplitModifier_copyData(ModifierData *md, ModifierData *target) -{ - EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md; - EdgeSplitModifierData *temd = (EdgeSplitModifierData*) target; - - temd->split_angle = emd->split_angle; - temd->flags = emd->flags; -} - -/* Mesh data for edgesplit operation */ -typedef struct SmoothVert { - LinkNode *faces; /* all faces which use this vert */ - int oldIndex; /* the index of the original DerivedMesh vert */ - int newIndex; /* the index of the new DerivedMesh vert */ -} SmoothVert; - -#define SMOOTHEDGE_NUM_VERTS 2 - -typedef struct SmoothEdge { - SmoothVert *verts[SMOOTHEDGE_NUM_VERTS]; /* the verts used by this edge */ - LinkNode *faces; /* all faces which use this edge */ - int oldIndex; /* the index of the original DerivedMesh edge */ - int newIndex; /* the index of the new DerivedMesh edge */ - short flag; /* the flags from the original DerivedMesh edge */ -} SmoothEdge; - -#define SMOOTHFACE_MAX_EDGES 4 - -typedef struct SmoothFace { - SmoothEdge *edges[SMOOTHFACE_MAX_EDGES]; /* nonexistent edges == NULL */ - int flip[SMOOTHFACE_MAX_EDGES]; /* 1 = flip edge dir, 0 = don't flip */ - float normal[3]; /* the normal of this face */ - int oldIndex; /* the index of the original DerivedMesh face */ - int newIndex; /* the index of the new DerivedMesh face */ -} SmoothFace; - -typedef struct SmoothMesh { - SmoothVert *verts; - SmoothEdge *edges; - SmoothFace *faces; - int num_verts, num_edges, num_faces; - int max_verts, max_edges, max_faces; - DerivedMesh *dm; - float threshold; /* the cosine of the smoothing angle */ - int flags; - MemArena *arena; - ListBase propagatestack, reusestack; -} SmoothMesh; - -static SmoothVert *smoothvert_copy(SmoothVert *vert, SmoothMesh *mesh) -{ - SmoothVert *copy = &mesh->verts[mesh->num_verts]; - - if(mesh->num_verts >= mesh->max_verts) { - printf("Attempted to add a SmoothMesh vert beyond end of array\n"); - return NULL; - } - - *copy = *vert; - copy->faces = NULL; - copy->newIndex = mesh->num_verts; - ++mesh->num_verts; - -#ifdef EDGESPLIT_DEBUG_2 - printf("copied vert %4d to vert %4d\n", vert->newIndex, copy->newIndex); -#endif - return copy; -} - -static SmoothEdge *smoothedge_copy(SmoothEdge *edge, SmoothMesh *mesh) -{ - SmoothEdge *copy = &mesh->edges[mesh->num_edges]; - - if(mesh->num_edges >= mesh->max_edges) { - printf("Attempted to add a SmoothMesh edge beyond end of array\n"); - return NULL; - } - - *copy = *edge; - copy->faces = NULL; - copy->newIndex = mesh->num_edges; - ++mesh->num_edges; - -#ifdef EDGESPLIT_DEBUG_2 - printf("copied edge %4d to edge %4d\n", edge->newIndex, copy->newIndex); -#endif - return copy; -} - -static int smoothedge_has_vert(SmoothEdge *edge, SmoothVert *vert) -{ - int i; - for(i = 0; i < SMOOTHEDGE_NUM_VERTS; i++) - if(edge->verts[i] == vert) return 1; - - return 0; -} - -static SmoothMesh *smoothmesh_new(int num_verts, int num_edges, int num_faces, - int max_verts, int max_edges, int max_faces) -{ - SmoothMesh *mesh = MEM_callocN(sizeof(*mesh), "smoothmesh"); - mesh->verts = MEM_callocN(sizeof(*mesh->verts) * max_verts, - "SmoothMesh.verts"); - mesh->edges = MEM_callocN(sizeof(*mesh->edges) * max_edges, - "SmoothMesh.edges"); - mesh->faces = MEM_callocN(sizeof(*mesh->faces) * max_faces, - "SmoothMesh.faces"); - - mesh->num_verts = num_verts; - mesh->num_edges = num_edges; - mesh->num_faces = num_faces; - - mesh->max_verts = max_verts; - mesh->max_edges = max_edges; - mesh->max_faces = max_faces; - - return mesh; -} - -static void smoothmesh_free(SmoothMesh *mesh) -{ - int i; - - for(i = 0; i < mesh->num_verts; ++i) - BLI_linklist_free(mesh->verts[i].faces, NULL); - - for(i = 0; i < mesh->num_edges; ++i) - BLI_linklist_free(mesh->edges[i].faces, NULL); - - if(mesh->arena) - BLI_memarena_free(mesh->arena); - - MEM_freeN(mesh->verts); - MEM_freeN(mesh->edges); - MEM_freeN(mesh->faces); - MEM_freeN(mesh); -} - -static void smoothmesh_resize_verts(SmoothMesh *mesh, int max_verts) -{ - int i; - SmoothVert *tmp; - - if(max_verts <= mesh->max_verts) return; - - tmp = MEM_callocN(sizeof(*tmp) * max_verts, "SmoothMesh.verts"); - - memcpy(tmp, mesh->verts, sizeof(*tmp) * mesh->num_verts); - - /* remap vert pointers in edges */ - for(i = 0; i < mesh->num_edges; ++i) { - int j; - SmoothEdge *edge = &mesh->edges[i]; - - for(j = 0; j < SMOOTHEDGE_NUM_VERTS; ++j) - /* pointer arithmetic to get vert array index */ - edge->verts[j] = &tmp[edge->verts[j] - mesh->verts]; - } - - MEM_freeN(mesh->verts); - mesh->verts = tmp; - mesh->max_verts = max_verts; -} - -static void smoothmesh_resize_edges(SmoothMesh *mesh, int max_edges) -{ - int i; - SmoothEdge *tmp; - - if(max_edges <= mesh->max_edges) return; - - tmp = MEM_callocN(sizeof(*tmp) * max_edges, "SmoothMesh.edges"); - - memcpy(tmp, mesh->edges, sizeof(*tmp) * mesh->num_edges); - - /* remap edge pointers in faces */ - for(i = 0; i < mesh->num_faces; ++i) { - int j; - SmoothFace *face = &mesh->faces[i]; - - for(j = 0; j < SMOOTHFACE_MAX_EDGES; ++j) - if(face->edges[j]) - /* pointer arithmetic to get edge array index */ - face->edges[j] = &tmp[face->edges[j] - mesh->edges]; - } - - MEM_freeN(mesh->edges); - mesh->edges = tmp; - mesh->max_edges = max_edges; -} - -#ifdef EDGESPLIT_DEBUG_0 -static void smoothmesh_print(SmoothMesh *mesh) -{ - int i, j; - DerivedMesh *dm = mesh->dm; - - printf("--- SmoothMesh ---\n"); - printf("--- Vertices ---\n"); - for(i = 0; i < mesh->num_verts; i++) { - SmoothVert *vert = &mesh->verts[i]; - LinkNode *node; - MVert mv; - - dm->getVert(dm, vert->oldIndex, &mv); - - printf("%3d: ind={%3d, %3d}, pos={% 5.1f, % 5.1f, % 5.1f}", - i, vert->oldIndex, vert->newIndex, - mv.co[0], mv.co[1], mv.co[2]); - printf(", faces={"); - for(node = vert->faces; node != NULL; node = node->next) { - printf(" %d", ((SmoothFace *)node->link)->newIndex); - } - printf("}\n"); - } - - printf("\n--- Edges ---\n"); - for(i = 0; i < mesh->num_edges; i++) { - SmoothEdge *edge = &mesh->edges[i]; - LinkNode *node; - - printf("%4d: indices={%4d, %4d}, verts={%4d, %4d}", - i, - edge->oldIndex, edge->newIndex, - edge->verts[0]->newIndex, edge->verts[1]->newIndex); - if(edge->verts[0] == edge->verts[1]) printf(" <- DUPLICATE VERTEX"); - printf(", faces={"); - for(node = edge->faces; node != NULL; node = node->next) { - printf(" %d", ((SmoothFace *)node->link)->newIndex); - } - printf("}\n"); - } - - printf("\n--- Faces ---\n"); - for(i = 0; i < mesh->num_faces; i++) { - SmoothFace *face = &mesh->faces[i]; - - printf("%4d: indices={%4d, %4d}, edges={", i, - face->oldIndex, face->newIndex); - for(j = 0; j < SMOOTHFACE_MAX_EDGES && face->edges[j]; j++) { - if(face->flip[j]) - printf(" -%-2d", face->edges[j]->newIndex); - else - printf(" %-2d", face->edges[j]->newIndex); - } - printf("}, verts={"); - for(j = 0; j < SMOOTHFACE_MAX_EDGES && face->edges[j]; j++) { - printf(" %d", face->edges[j]->verts[face->flip[j]]->newIndex); - } - printf("}\n"); - } -} -#endif - -static SmoothMesh *smoothmesh_from_derivedmesh(DerivedMesh *dm) -{ - SmoothMesh *mesh; - EdgeHash *edges = BLI_edgehash_new(); - int i; - int totvert, totedge, totface; - - totvert = dm->getNumVerts(dm); - totedge = dm->getNumEdges(dm); - totface = dm->getNumFaces(dm); - - mesh = smoothmesh_new(totvert, totedge, totface, - totvert, totedge, totface); - - mesh->dm = dm; - - for(i = 0; i < totvert; i++) { - SmoothVert *vert = &mesh->verts[i]; - - vert->oldIndex = vert->newIndex = i; - } - - for(i = 0; i < totedge; i++) { - SmoothEdge *edge = &mesh->edges[i]; - MEdge med; - - dm->getEdge(dm, i, &med); - edge->verts[0] = &mesh->verts[med.v1]; - edge->verts[1] = &mesh->verts[med.v2]; - edge->oldIndex = edge->newIndex = i; - edge->flag = med.flag; - - BLI_edgehash_insert(edges, med.v1, med.v2, edge); - } - - for(i = 0; i < totface; i++) { - SmoothFace *face = &mesh->faces[i]; - MFace mf; - MVert v1, v2, v3; - int j; - - dm->getFace(dm, i, &mf); - - dm->getVert(dm, mf.v1, &v1); - dm->getVert(dm, mf.v2, &v2); - dm->getVert(dm, mf.v3, &v3); - face->edges[0] = BLI_edgehash_lookup(edges, mf.v1, mf.v2); - if(face->edges[0]->verts[1]->oldIndex == mf.v1) face->flip[0] = 1; - face->edges[1] = BLI_edgehash_lookup(edges, mf.v2, mf.v3); - if(face->edges[1]->verts[1]->oldIndex == mf.v2) face->flip[1] = 1; - if(mf.v4) { - MVert v4; - dm->getVert(dm, mf.v4, &v4); - face->edges[2] = BLI_edgehash_lookup(edges, mf.v3, mf.v4); - if(face->edges[2]->verts[1]->oldIndex == mf.v3) face->flip[2] = 1; - face->edges[3] = BLI_edgehash_lookup(edges, mf.v4, mf.v1); - if(face->edges[3]->verts[1]->oldIndex == mf.v4) face->flip[3] = 1; - normal_quad_v3( face->normal,v1.co, v2.co, v3.co, v4.co); - } else { - face->edges[2] = BLI_edgehash_lookup(edges, mf.v3, mf.v1); - if(face->edges[2]->verts[1]->oldIndex == mf.v3) face->flip[2] = 1; - face->edges[3] = NULL; - normal_tri_v3( face->normal,v1.co, v2.co, v3.co); - } - - for(j = 0; j < SMOOTHFACE_MAX_EDGES && face->edges[j]; j++) { - SmoothEdge *edge = face->edges[j]; - BLI_linklist_prepend(&edge->faces, face); - BLI_linklist_prepend(&edge->verts[face->flip[j]]->faces, face); - } - - face->oldIndex = face->newIndex = i; - } - - BLI_edgehash_free(edges, NULL); - - return mesh; -} - -static DerivedMesh *CDDM_from_smoothmesh(SmoothMesh *mesh) -{ - DerivedMesh *result = CDDM_from_template(mesh->dm, - mesh->num_verts, - mesh->num_edges, - mesh->num_faces); - MVert *new_verts = CDDM_get_verts(result); - MEdge *new_edges = CDDM_get_edges(result); - MFace *new_faces = CDDM_get_faces(result); - int i; - - for(i = 0; i < mesh->num_verts; ++i) { - SmoothVert *vert = &mesh->verts[i]; - MVert *newMV = &new_verts[vert->newIndex]; - - DM_copy_vert_data(mesh->dm, result, - vert->oldIndex, vert->newIndex, 1); - mesh->dm->getVert(mesh->dm, vert->oldIndex, newMV); - } - - for(i = 0; i < mesh->num_edges; ++i) { - SmoothEdge *edge = &mesh->edges[i]; - MEdge *newME = &new_edges[edge->newIndex]; - - DM_copy_edge_data(mesh->dm, result, - edge->oldIndex, edge->newIndex, 1); - mesh->dm->getEdge(mesh->dm, edge->oldIndex, newME); - newME->v1 = edge->verts[0]->newIndex; - newME->v2 = edge->verts[1]->newIndex; - } - - for(i = 0; i < mesh->num_faces; ++i) { - SmoothFace *face = &mesh->faces[i]; - MFace *newMF = &new_faces[face->newIndex]; - - DM_copy_face_data(mesh->dm, result, - face->oldIndex, face->newIndex, 1); - mesh->dm->getFace(mesh->dm, face->oldIndex, newMF); - - newMF->v1 = face->edges[0]->verts[face->flip[0]]->newIndex; - newMF->v2 = face->edges[1]->verts[face->flip[1]]->newIndex; - newMF->v3 = face->edges[2]->verts[face->flip[2]]->newIndex; - - if(face->edges[3]) { - newMF->v4 = face->edges[3]->verts[face->flip[3]]->newIndex; - } else { - newMF->v4 = 0; - } - } - - return result; -} - -/* returns the other vert in the given edge - */ -static SmoothVert *other_vert(SmoothEdge *edge, SmoothVert *vert) -{ - if(edge->verts[0] == vert) return edge->verts[1]; - else return edge->verts[0]; -} - -/* returns the other edge in the given face that uses the given vert - * returns NULL if no other edge in the given face uses the given vert - * (this should never happen) - */ -static SmoothEdge *other_edge(SmoothFace *face, SmoothVert *vert, - SmoothEdge *edge) -{ - int i,j; - for(i = 0; i < SMOOTHFACE_MAX_EDGES && face->edges[i]; i++) { - SmoothEdge *tmp_edge = face->edges[i]; - if(tmp_edge == edge) continue; - - for(j = 0; j < SMOOTHEDGE_NUM_VERTS; j++) - if(tmp_edge->verts[j] == vert) return tmp_edge; - } - - /* if we get to here, something's wrong (there should always be 2 edges - * which use the same vert in a face) - */ - return NULL; -} - -/* returns a face attached to the given edge which is not the given face. - * returns NULL if no other faces use this edge. - */ -static SmoothFace *other_face(SmoothEdge *edge, SmoothFace *face) -{ - LinkNode *node; - - for(node = edge->faces; node != NULL; node = node->next) - if(node->link != face) return node->link; - - return NULL; -} - -#if 0 -/* copies source list to target, overwriting target (target is not freed) - * nodes in the copy will be in the same order as in source - */ -static void linklist_copy(LinkNode **target, LinkNode *source) -{ - LinkNode *node = NULL; - *target = NULL; - - for(; source; source = source->next) { - if(node) { - node->next = MEM_mallocN(sizeof(*node->next), "nlink_copy"); - node = node->next; -} else { - node = *target = MEM_mallocN(sizeof(**target), "nlink_copy"); -} - node->link = source->link; - node->next = NULL; -} -} -#endif - - /* appends source to target if it's not already in target */ - static void linklist_append_unique(LinkNode **target, void *source) -{ - LinkNode *node; - LinkNode *prev = NULL; - - /* check if source value is already in the list */ - for(node = *target; node; prev = node, node = node->next) - if(node->link == source) return; - - node = MEM_mallocN(sizeof(*node), "nlink"); - node->next = NULL; - node->link = source; - - if(prev) prev->next = node; - else *target = node; -} - -/* appends elements of source which aren't already in target to target */ -static void linklist_append_list_unique(LinkNode **target, LinkNode *source) -{ - for(; source; source = source->next) - linklist_append_unique(target, source->link); -} - -#if 0 /* this is no longer used, it should possibly be removed */ -/* prepends prepend to list - doesn't copy nodes, just joins the lists */ -static void linklist_prepend_linklist(LinkNode **list, LinkNode *prepend) -{ - if(prepend) { - LinkNode *node = prepend; - while(node->next) node = node->next; - - node->next = *list; - *list = prepend; -} -} -#endif - -/* returns 1 if the linked list contains the given pointer, 0 otherwise - */ -static int linklist_contains(LinkNode *list, void *ptr) -{ - LinkNode *node; - - for(node = list; node; node = node->next) - if(node->link == ptr) return 1; - - return 0; -} - -/* returns 1 if the first linked list is a subset of the second (comparing - * pointer values), 0 if not - */ -static int linklist_subset(LinkNode *list1, LinkNode *list2) -{ - for(; list1; list1 = list1->next) - if(!linklist_contains(list2, list1->link)) - return 0; - - return 1; -} - -#if 0 -/* empties the linked list - * frees pointers with freefunc if freefunc is not NULL - */ -static void linklist_empty(LinkNode **list, LinkNodeFreeFP freefunc) -{ - BLI_linklist_free(*list, freefunc); - *list = NULL; -} -#endif - -/* removes the first instance of value from the linked list - * frees the pointer with freefunc if freefunc is not NULL - */ -static void linklist_remove_first(LinkNode **list, void *value, - LinkNodeFreeFP freefunc) -{ - LinkNode *node = *list; - LinkNode *prev = NULL; - - while(node && node->link != value) { - prev = node; - node = node->next; - } - - if(node) { - if(prev) - prev->next = node->next; - else - *list = node->next; - - if(freefunc) - freefunc(node->link); - - MEM_freeN(node); - } -} - -/* removes all elements in source from target */ -static void linklist_remove_list(LinkNode **target, LinkNode *source, - LinkNodeFreeFP freefunc) -{ - for(; source; source = source->next) - linklist_remove_first(target, source->link, freefunc); -} - -#ifdef EDGESPLIT_DEBUG_0 -static void print_ptr(void *ptr) -{ - printf("%p\n", ptr); -} - -static void print_edge(void *ptr) -{ - SmoothEdge *edge = ptr; - printf(" %4d", edge->newIndex); -} - -static void print_face(void *ptr) -{ - SmoothFace *face = ptr; - printf(" %4d", face->newIndex); -} -#endif - -typedef struct ReplaceData { - void *find; - void *replace; -} ReplaceData; - -static void edge_replace_vert(void *ptr, void *userdata) -{ - SmoothEdge *edge = ptr; - SmoothVert *find = ((ReplaceData *)userdata)->find; - SmoothVert *replace = ((ReplaceData *)userdata)->replace; - int i; - -#ifdef EDGESPLIT_DEBUG_3 - printf("replacing vert %4d with %4d in edge %4d", - find->newIndex, replace->newIndex, edge->newIndex); - printf(": {%4d, %4d}", edge->verts[0]->newIndex, edge->verts[1]->newIndex); -#endif - - for(i = 0; i < SMOOTHEDGE_NUM_VERTS; i++) { - if(edge->verts[i] == find) { - linklist_append_list_unique(&replace->faces, edge->faces); - linklist_remove_list(&find->faces, edge->faces, NULL); - - edge->verts[i] = replace; - } - } - -#ifdef EDGESPLIT_DEBUG_3 - printf(" -> {%4d, %4d}\n", edge->verts[0]->newIndex, edge->verts[1]->newIndex); -#endif -} - -static void face_replace_vert(void *ptr, void *userdata) -{ - SmoothFace *face = ptr; - int i; - - for(i = 0; i < SMOOTHFACE_MAX_EDGES && face->edges[i]; i++) - edge_replace_vert(face->edges[i], userdata); -} - -static void face_replace_edge(void *ptr, void *userdata) -{ - SmoothFace *face = ptr; - SmoothEdge *find = ((ReplaceData *)userdata)->find; - SmoothEdge *replace = ((ReplaceData *)userdata)->replace; - int i; - -#ifdef EDGESPLIT_DEBUG_3 - printf("replacing edge %4d with %4d in face %4d", - find->newIndex, replace->newIndex, face->newIndex); - if(face->edges[3]) - printf(": {%2d %2d %2d %2d}", - face->edges[0]->newIndex, face->edges[1]->newIndex, - face->edges[2]->newIndex, face->edges[3]->newIndex); - else - printf(": {%2d %2d %2d}", - face->edges[0]->newIndex, face->edges[1]->newIndex, - face->edges[2]->newIndex); -#endif - - for(i = 0; i < SMOOTHFACE_MAX_EDGES && face->edges[i]; i++) { - if(face->edges[i] == find) { - linklist_remove_first(&face->edges[i]->faces, face, NULL); - BLI_linklist_prepend(&replace->faces, face); - face->edges[i] = replace; - } - } - -#ifdef EDGESPLIT_DEBUG_3 - if(face->edges[3]) - printf(" -> {%2d %2d %2d %2d}\n", - face->edges[0]->newIndex, face->edges[1]->newIndex, - face->edges[2]->newIndex, face->edges[3]->newIndex); - else - printf(" -> {%2d %2d %2d}\n", - face->edges[0]->newIndex, face->edges[1]->newIndex, - face->edges[2]->newIndex); -#endif -} - -static int edge_is_loose(SmoothEdge *edge) -{ - return !(edge->faces && edge->faces->next); -} - -static int edge_is_sharp(SmoothEdge *edge, int flags, - float threshold) -{ -#ifdef EDGESPLIT_DEBUG_1 - printf("edge %d: ", edge->newIndex); -#endif - if(edge->flag & ME_SHARP) { - /* edge can only be sharp if it has at least 2 faces */ - if(!edge_is_loose(edge)) { -#ifdef EDGESPLIT_DEBUG_1 - printf("sharp\n"); -#endif - return 1; - } else { - /* edge is loose, so it can't be sharp */ - edge->flag &= ~ME_SHARP; - } - } - -#ifdef EDGESPLIT_DEBUG_1 - printf("not sharp\n"); -#endif - return 0; -} - -/* finds another sharp edge which uses vert, by traversing faces around the - * vert until it does one of the following: - * - hits a loose edge (the edge is returned) - * - hits a sharp edge (the edge is returned) - * - returns to the start edge (NULL is returned) - */ -static SmoothEdge *find_other_sharp_edge(SmoothVert *vert, SmoothEdge *edge, - LinkNode **visited_faces, float threshold, int flags) -{ - SmoothFace *face = NULL; - SmoothEdge *edge2 = NULL; - /* holds the edges we've seen so we can avoid looping indefinitely */ - LinkNode *visited_edges = NULL; -#ifdef EDGESPLIT_DEBUG_1 - printf("=== START === find_other_sharp_edge(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); -#endif - - /* get a face on which to start */ - if(edge->faces) face = edge->faces->link; - else return NULL; - - /* record this edge as visited */ - BLI_linklist_prepend(&visited_edges, edge); - - /* get the next edge */ - edge2 = other_edge(face, vert, edge); - - /* record this face as visited */ - if(visited_faces) - BLI_linklist_prepend(visited_faces, face); - - /* search until we hit a loose edge or a sharp edge or an edge we've - * seen before - */ - while(face && !edge_is_sharp(edge2, flags, threshold) - && !linklist_contains(visited_edges, edge2)) { -#ifdef EDGESPLIT_DEBUG_3 - printf("current face %4d; current edge %4d\n", face->newIndex, - edge2->newIndex); -#endif - /* get the next face */ - face = other_face(edge2, face); - - /* if face == NULL, edge2 is a loose edge */ - if(face) { - /* record this face as visited */ - if(visited_faces) - BLI_linklist_prepend(visited_faces, face); - - /* record this edge as visited */ - BLI_linklist_prepend(&visited_edges, edge2); - - /* get the next edge */ - edge2 = other_edge(face, vert, edge2); -#ifdef EDGESPLIT_DEBUG_3 - printf("next face %4d; next edge %4d\n", - face->newIndex, edge2->newIndex); - } else { - printf("loose edge: %4d\n", edge2->newIndex); -#endif - } - } - - /* either we came back to the start edge or we found a sharp/loose edge */ - if(linklist_contains(visited_edges, edge2)) - /* we came back to the start edge */ - edge2 = NULL; - - BLI_linklist_free(visited_edges, NULL); - -#ifdef EDGESPLIT_DEBUG_1 - printf("=== END === find_other_sharp_edge(edge = %4d, vert = %4d), " - "returning edge %d\n", - edge->newIndex, vert->newIndex, edge2 ? edge2->newIndex : -1); -#endif - return edge2; -} - -static void split_single_vert(SmoothVert *vert, SmoothFace *face, - SmoothMesh *mesh) -{ - SmoothVert *copy_vert; - ReplaceData repdata; - - copy_vert = smoothvert_copy(vert, mesh); - - repdata.find = vert; - repdata.replace = copy_vert; - face_replace_vert(face, &repdata); -} - -typedef struct PropagateEdge { - struct PropagateEdge *next, *prev; - SmoothEdge *edge; - SmoothVert *vert; -} PropagateEdge; - -static void push_propagate_stack(SmoothEdge *edge, SmoothVert *vert, SmoothMesh *mesh) -{ - PropagateEdge *pedge = mesh->reusestack.first; - - if(pedge) { - BLI_remlink(&mesh->reusestack, pedge); - } - else { - if(!mesh->arena) { - mesh->arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE); - BLI_memarena_use_calloc(mesh->arena); - } - - pedge = BLI_memarena_alloc(mesh->arena, sizeof(PropagateEdge)); - } - - pedge->edge = edge; - pedge->vert = vert; - BLI_addhead(&mesh->propagatestack, pedge); -} - -static void pop_propagate_stack(SmoothEdge **edge, SmoothVert **vert, SmoothMesh *mesh) -{ - PropagateEdge *pedge = mesh->propagatestack.first; - - if(pedge) { - *edge = pedge->edge; - *vert = pedge->vert; - BLI_remlink(&mesh->propagatestack, pedge); - BLI_addhead(&mesh->reusestack, pedge); - } - else { - *edge = NULL; - *vert = NULL; - } -} - -static void split_edge(SmoothEdge *edge, SmoothVert *vert, SmoothMesh *mesh); - -static void propagate_split(SmoothEdge *edge, SmoothVert *vert, - SmoothMesh *mesh) -{ - SmoothEdge *edge2; - LinkNode *visited_faces = NULL; -#ifdef EDGESPLIT_DEBUG_1 - printf("=== START === propagate_split(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); -#endif - - edge2 = find_other_sharp_edge(vert, edge, &visited_faces, - mesh->threshold, mesh->flags); - - if(!edge2) { - /* didn't find a sharp or loose edge, so we've hit a dead end */ - } else if(!edge_is_loose(edge2)) { - /* edge2 is not loose, so it must be sharp */ - if(edge_is_loose(edge)) { - /* edge is loose, so we can split edge2 at this vert */ - split_edge(edge2, vert, mesh); - } else if(edge_is_sharp(edge, mesh->flags, mesh->threshold)) { - /* both edges are sharp, so we can split the pair at vert */ - split_edge(edge, vert, mesh); - } else { - /* edge is not sharp, so try to split edge2 at its other vert */ - split_edge(edge2, other_vert(edge2, vert), mesh); - } - } else { /* edge2 is loose */ - if(edge_is_loose(edge)) { - SmoothVert *vert2; - ReplaceData repdata; - - /* can't split edge, what should we do with vert? */ - if(linklist_subset(vert->faces, visited_faces)) { - /* vert has only one fan of faces attached; don't split it */ - } else { - /* vert has more than one fan of faces attached; split it */ - vert2 = smoothvert_copy(vert, mesh); - - /* replace vert with its copy in visited_faces */ - repdata.find = vert; - repdata.replace = vert2; - BLI_linklist_apply(visited_faces, face_replace_vert, &repdata); - } - } else { - /* edge is not loose, so it must be sharp; split it */ - split_edge(edge, vert, mesh); - } - } - - BLI_linklist_free(visited_faces, NULL); -#ifdef EDGESPLIT_DEBUG_1 - printf("=== END === propagate_split(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); -#endif -} - -static void split_edge(SmoothEdge *edge, SmoothVert *vert, SmoothMesh *mesh) -{ - SmoothEdge *edge2; - SmoothVert *vert2; - ReplaceData repdata; - /* the list of faces traversed while looking for a sharp edge */ - LinkNode *visited_faces = NULL; -#ifdef EDGESPLIT_DEBUG_1 - printf("=== START === split_edge(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); -#endif - - edge2 = find_other_sharp_edge(vert, edge, &visited_faces, - mesh->threshold, mesh->flags); - - if(!edge2) { - /* didn't find a sharp or loose edge, so try the other vert */ - vert2 = other_vert(edge, vert); - push_propagate_stack(edge, vert2, mesh); - } else if(!edge_is_loose(edge2)) { - /* edge2 is not loose, so it must be sharp */ - SmoothEdge *copy_edge = smoothedge_copy(edge, mesh); - SmoothEdge *copy_edge2 = smoothedge_copy(edge2, mesh); - SmoothVert *vert2; - - /* replace edge with its copy in visited_faces */ - repdata.find = edge; - repdata.replace = copy_edge; - BLI_linklist_apply(visited_faces, face_replace_edge, &repdata); - - /* replace edge2 with its copy in visited_faces */ - repdata.find = edge2; - repdata.replace = copy_edge2; - BLI_linklist_apply(visited_faces, face_replace_edge, &repdata); - - vert2 = smoothvert_copy(vert, mesh); - - /* replace vert with its copy in visited_faces (must be done after - * edge replacement so edges have correct vertices) - */ - repdata.find = vert; - repdata.replace = vert2; - BLI_linklist_apply(visited_faces, face_replace_vert, &repdata); - - /* all copying and replacing is done; the mesh should be consistent. - * now propagate the split to the vertices at either end - */ - push_propagate_stack(copy_edge, other_vert(copy_edge, vert2), mesh); - push_propagate_stack(copy_edge2, other_vert(copy_edge2, vert2), mesh); - - if(smoothedge_has_vert(edge, vert)) - push_propagate_stack(edge, vert, mesh); - } else { - /* edge2 is loose */ - SmoothEdge *copy_edge = smoothedge_copy(edge, mesh); - SmoothVert *vert2; - - /* replace edge with its copy in visited_faces */ - repdata.find = edge; - repdata.replace = copy_edge; - BLI_linklist_apply(visited_faces, face_replace_edge, &repdata); - - vert2 = smoothvert_copy(vert, mesh); - - /* replace vert with its copy in visited_faces (must be done after - * edge replacement so edges have correct vertices) - */ - repdata.find = vert; - repdata.replace = vert2; - BLI_linklist_apply(visited_faces, face_replace_vert, &repdata); - - /* copying and replacing is done; the mesh should be consistent. - * now propagate the split to the vertex at the other end - */ - push_propagate_stack(copy_edge, other_vert(copy_edge, vert2), mesh); - - if(smoothedge_has_vert(edge, vert)) - push_propagate_stack(edge, vert, mesh); - } - - BLI_linklist_free(visited_faces, NULL); -#ifdef EDGESPLIT_DEBUG_1 - printf("=== END === split_edge(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); -#endif -} - -static void tag_and_count_extra_edges(SmoothMesh *mesh, float split_angle, - int flags, int *extra_edges) -{ - /* if normal1 dot normal2 < threshold, angle is greater, so split */ - /* FIXME not sure if this always works */ - /* 0.00001 added for floating-point rounding */ - float threshold = cos((split_angle + 0.00001) * M_PI / 180.0); - int i; - - *extra_edges = 0; - - /* loop through edges, counting potential new ones */ - for(i = 0; i < mesh->num_edges; i++) { - SmoothEdge *edge = &mesh->edges[i]; - int sharp = 0; - - /* treat all non-manifold edges (3 or more faces) as sharp */ - if(edge->faces && edge->faces->next && edge->faces->next->next) { - LinkNode *node; - - /* this edge is sharp */ - sharp = 1; - - /* add an extra edge for every face beyond the first */ - *extra_edges += 2; - for(node = edge->faces->next->next->next; node; node = node->next) - (*extra_edges)++; - } else if((flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG)) - && !edge_is_loose(edge)) { - /* (the edge can only be sharp if we're checking angle or flag, - * and it has at least 2 faces) */ - - /* if we're checking the sharp flag and it's set, good */ - if((flags & MOD_EDGESPLIT_FROMFLAG) && (edge->flag & ME_SHARP)) { - /* this edge is sharp */ - sharp = 1; - - (*extra_edges)++; - } else if(flags & MOD_EDGESPLIT_FROMANGLE) { - /* we know the edge has 2 faces, so check the angle */ - SmoothFace *face1 = edge->faces->link; - SmoothFace *face2 = edge->faces->next->link; - float edge_angle_cos = dot_v3v3(face1->normal, - face2->normal); - - if(edge_angle_cos < threshold) { - /* this edge is sharp */ - sharp = 1; - - (*extra_edges)++; - } - } - } - - /* set/clear sharp flag appropriately */ - if(sharp) edge->flag |= ME_SHARP; - else edge->flag &= ~ME_SHARP; - } -} - -static void split_sharp_edges(SmoothMesh *mesh, float split_angle, int flags) -{ - SmoothVert *vert; - int i; - /* if normal1 dot normal2 < threshold, angle is greater, so split */ - /* FIXME not sure if this always works */ - /* 0.00001 added for floating-point rounding */ - mesh->threshold = cos((split_angle + 0.00001) * M_PI / 180.0); - mesh->flags = flags; - - /* loop through edges, splitting sharp ones */ - /* can't use an iterator here, because we'll be adding edges */ - for(i = 0; i < mesh->num_edges; i++) { - SmoothEdge *edge = &mesh->edges[i]; - - if(edge_is_sharp(edge, flags, mesh->threshold)) { - split_edge(edge, edge->verts[0], mesh); - - do { - pop_propagate_stack(&edge, &vert, mesh); - if(edge && smoothedge_has_vert(edge, vert)) - propagate_split(edge, vert, mesh); - } while(edge); - } - } -} - -static int count_bridge_verts(SmoothMesh *mesh) -{ - int i, j, count = 0; - - for(i = 0; i < mesh->num_faces; i++) { - SmoothFace *face = &mesh->faces[i]; - - for(j = 0; j < SMOOTHFACE_MAX_EDGES && face->edges[j]; j++) { - SmoothEdge *edge = face->edges[j]; - SmoothEdge *next_edge; - SmoothVert *vert = edge->verts[1 - face->flip[j]]; - int next = (j + 1) % SMOOTHFACE_MAX_EDGES; - - /* wrap next around if at last edge */ - if(!face->edges[next]) next = 0; - - next_edge = face->edges[next]; - - /* if there are other faces sharing this vertex but not - * these edges, the vertex will be split, so count it - */ - /* vert has to have at least one face (this one), so faces != 0 */ - if(!edge->faces->next && !next_edge->faces->next - && vert->faces->next) { - count++; - } - } - } - - /* each bridge vert will be counted once per face that uses it, - * so count is too high, but it's ok for now - */ - return count; -} - -static void split_bridge_verts(SmoothMesh *mesh) -{ - int i,j; - - for(i = 0; i < mesh->num_faces; i++) { - SmoothFace *face = &mesh->faces[i]; - - for(j = 0; j < SMOOTHFACE_MAX_EDGES && face->edges[j]; j++) { - SmoothEdge *edge = face->edges[j]; - SmoothEdge *next_edge; - SmoothVert *vert = edge->verts[1 - face->flip[j]]; - int next = (j + 1) % SMOOTHFACE_MAX_EDGES; - - /* wrap next around if at last edge */ - if(!face->edges[next]) next = 0; - - next_edge = face->edges[next]; - - /* if there are other faces sharing this vertex but not - * these edges, split the vertex - */ - /* vert has to have at least one face (this one), so faces != 0 */ - if(!edge->faces->next && !next_edge->faces->next - && vert->faces->next) - /* FIXME this needs to find all faces that share edges with - * this one and split off together - */ - split_single_vert(vert, face, mesh); - } - } -} - -static DerivedMesh *edgesplitModifier_do(EdgeSplitModifierData *emd, - Object *ob, DerivedMesh *dm) -{ - SmoothMesh *mesh; - DerivedMesh *result; - int max_verts, max_edges; - - if(!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG))) - return dm; - - /* 1. make smoothmesh with initial number of elements */ - mesh = smoothmesh_from_derivedmesh(dm); - - /* 2. count max number of elements to add */ - tag_and_count_extra_edges(mesh, emd->split_angle, emd->flags, &max_edges); - max_verts = max_edges * 2 + mesh->max_verts; - max_verts += count_bridge_verts(mesh); - max_edges += mesh->max_edges; - - /* 3. reallocate smoothmesh arrays & copy elements across */ - /* 4. remap copied elements' pointers to point into the new arrays */ - smoothmesh_resize_verts(mesh, max_verts); - smoothmesh_resize_edges(mesh, max_edges); - -#ifdef EDGESPLIT_DEBUG_1 - printf("********** Pre-split **********\n"); - smoothmesh_print(mesh); -#endif - - split_sharp_edges(mesh, emd->split_angle, emd->flags); -#ifdef EDGESPLIT_DEBUG_1 - printf("********** Post-edge-split **********\n"); - smoothmesh_print(mesh); -#endif - - split_bridge_verts(mesh); - -#ifdef EDGESPLIT_DEBUG_1 - printf("********** Post-vert-split **********\n"); - smoothmesh_print(mesh); -#endif - -#ifdef EDGESPLIT_DEBUG_0 - printf("Edgesplit: Estimated %d verts & %d edges, " - "found %d verts & %d edges\n", max_verts, max_edges, - mesh->num_verts, mesh->num_edges); -#endif - - result = CDDM_from_smoothmesh(mesh); - smoothmesh_free(mesh); - - return result; -} - -static DerivedMesh *edgesplitModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - DerivedMesh *result; - EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md; - - result = edgesplitModifier_do(emd, ob, derivedData); - - if(result != derivedData) - CDDM_calc_normals(result); - - return result; -} - -static DerivedMesh *edgesplitModifier_applyModifierEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData) -{ - return edgesplitModifier_applyModifier(md, ob, derivedData, 0, 1); -} - -/* Bevel */ - -static void bevelModifier_initData(ModifierData *md) -{ - BevelModifierData *bmd = (BevelModifierData*) md; - - bmd->value = 0.1f; - bmd->res = 1; - bmd->flags = 0; - bmd->val_flags = 0; - bmd->lim_flags = 0; - bmd->e_flags = 0; - bmd->bevel_angle = 30; - bmd->defgrp_name[0] = '\0'; -} - -static void bevelModifier_copyData(ModifierData *md, ModifierData *target) -{ - BevelModifierData *bmd = (BevelModifierData*) md; - BevelModifierData *tbmd = (BevelModifierData*) target; - - tbmd->value = bmd->value; - tbmd->res = bmd->res; - tbmd->flags = bmd->flags; - tbmd->val_flags = bmd->val_flags; - tbmd->lim_flags = bmd->lim_flags; - tbmd->e_flags = bmd->e_flags; - tbmd->bevel_angle = bmd->bevel_angle; - strncpy(tbmd->defgrp_name, bmd->defgrp_name, 32); -} - -static CustomDataMask bevelModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - BevelModifierData *bmd = (BevelModifierData *)md; - CustomDataMask dataMask = 0; - - /* ask for vertexgroups if we need them */ - if(bmd->defgrp_name[0]) dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static DerivedMesh *bevelModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - DerivedMesh *result; - BME_Mesh *bm; - - /*bDeformGroup *def;*/ - int /*i,*/ options, defgrp_index = -1; - BevelModifierData *bmd = (BevelModifierData*) md; - - options = bmd->flags|bmd->val_flags|bmd->lim_flags|bmd->e_flags; - - /*if ((options & BME_BEVEL_VWEIGHT) && bmd->defgrp_name[0]) { - defgrp_index = defgroup_name_index(ob, bmd->defgrp_name); - if (defgrp_index < 0) { - options &= ~BME_BEVEL_VWEIGHT; - } - }*/ - - bm = BME_derivedmesh_to_bmesh(derivedData); - BME_bevel(bm,bmd->value,bmd->res,options,defgrp_index,bmd->bevel_angle,NULL); - result = BME_bmesh_to_derivedmesh(bm,derivedData); - BME_free_mesh(bm); - - CDDM_calc_normals(result); - - return result; -} - -static DerivedMesh *bevelModifier_applyModifierEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData) -{ - return bevelModifier_applyModifier(md, ob, derivedData, 0, 1); -} - -/* Displace */ - -static void displaceModifier_initData(ModifierData *md) -{ - DisplaceModifierData *dmd = (DisplaceModifierData*) md; - - dmd->texture = NULL; - dmd->strength = 1; - dmd->direction = MOD_DISP_DIR_NOR; - dmd->midlevel = 0.5; -} - -static void displaceModifier_copyData(ModifierData *md, ModifierData *target) -{ - DisplaceModifierData *dmd = (DisplaceModifierData*) md; - DisplaceModifierData *tdmd = (DisplaceModifierData*) target; - - tdmd->texture = dmd->texture; - tdmd->strength = dmd->strength; - tdmd->direction = dmd->direction; - strncpy(tdmd->defgrp_name, dmd->defgrp_name, 32); - tdmd->midlevel = dmd->midlevel; - tdmd->texmapping = dmd->texmapping; - tdmd->map_object = dmd->map_object; - strncpy(tdmd->uvlayer_name, dmd->uvlayer_name, 32); -} - -static CustomDataMask displaceModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - DisplaceModifierData *dmd = (DisplaceModifierData *)md; - CustomDataMask dataMask = 0; - - /* ask for vertexgroups if we need them */ - if(dmd->defgrp_name[0]) dataMask |= (1 << CD_MDEFORMVERT); - - /* ask for UV coordinates if we need them */ - if(dmd->texmapping == MOD_DISP_MAP_UV) dataMask |= (1 << CD_MTFACE); - - return dataMask; -} - -static int displaceModifier_dependsOnTime(ModifierData *md) -{ - DisplaceModifierData *dmd = (DisplaceModifierData *)md; - - if(dmd->texture) - { - return BKE_texture_dependsOnTime(dmd->texture); - } - else - { - return 0; - } -} - -static void displaceModifier_foreachObjectLink(ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) -{ - DisplaceModifierData *dmd = (DisplaceModifierData*) md; - - walk(userData, ob, &dmd->map_object); -} - -static void displaceModifier_foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) -{ - DisplaceModifierData *dmd = (DisplaceModifierData*) md; - - walk(userData, ob, (ID **)&dmd->texture); - - displaceModifier_foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); -} - -static int displaceModifier_isDisabled(ModifierData *md, int useRenderParams) -{ - DisplaceModifierData *dmd = (DisplaceModifierData*) md; - - return !dmd->texture; -} - -static void displaceModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) -{ - DisplaceModifierData *dmd = (DisplaceModifierData*) md; - - if(dmd->map_object) { - DagNode *curNode = dag_get_node(forest, dmd->map_object); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Displace Modifier"); - } -} - -static void validate_layer_name(const CustomData *data, int type, char *name, char *outname) -{ - int index = -1; - - /* if a layer name was given, try to find that layer */ - if(name[0]) - index = CustomData_get_named_layer_index(data, CD_MTFACE, name); - - if(index < 0) { - /* either no layer was specified, or the layer we want has been - * deleted, so assign the active layer to name - */ - index = CustomData_get_active_layer_index(data, CD_MTFACE); - strcpy(outname, data->layers[index].name); - } - else - strcpy(outname, name); -} - -static void get_texture_coords(DisplaceModifierData *dmd, Object *ob, - DerivedMesh *dm, - float (*co)[3], float (*texco)[3], - int numVerts) -{ - int i; - int texmapping = dmd->texmapping; - float mapob_imat[4][4]; - - if(texmapping == MOD_DISP_MAP_OBJECT) { - if(dmd->map_object) - invert_m4_m4(mapob_imat, dmd->map_object->obmat); - else /* if there is no map object, default to local */ - texmapping = MOD_DISP_MAP_LOCAL; - } - - /* UVs need special handling, since they come from faces */ - if(texmapping == MOD_DISP_MAP_UV) { - if(CustomData_has_layer(&dm->faceData, CD_MTFACE)) { - MFace *mface = dm->getFaceArray(dm); - MFace *mf; - char *done = MEM_callocN(sizeof(*done) * numVerts, - "get_texture_coords done"); - int numFaces = dm->getNumFaces(dm); - char uvname[32]; - MTFace *tf; - - validate_layer_name(&dm->faceData, CD_MTFACE, dmd->uvlayer_name, uvname); - tf = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname); - - /* verts are given the UV from the first face that uses them */ - for(i = 0, mf = mface; i < numFaces; ++i, ++mf, ++tf) { - if(!done[mf->v1]) { - texco[mf->v1][0] = tf->uv[0][0]; - texco[mf->v1][1] = tf->uv[0][1]; - texco[mf->v1][2] = 0; - done[mf->v1] = 1; - } - if(!done[mf->v2]) { - texco[mf->v2][0] = tf->uv[1][0]; - texco[mf->v2][1] = tf->uv[1][1]; - texco[mf->v2][2] = 0; - done[mf->v2] = 1; - } - if(!done[mf->v3]) { - texco[mf->v3][0] = tf->uv[2][0]; - texco[mf->v3][1] = tf->uv[2][1]; - texco[mf->v3][2] = 0; - done[mf->v3] = 1; - } - if(!done[mf->v4]) { - texco[mf->v4][0] = tf->uv[3][0]; - texco[mf->v4][1] = tf->uv[3][1]; - texco[mf->v4][2] = 0; - done[mf->v4] = 1; - } - } - - /* remap UVs from [0, 1] to [-1, 1] */ - for(i = 0; i < numVerts; ++i) { - texco[i][0] = texco[i][0] * 2 - 1; - texco[i][1] = texco[i][1] * 2 - 1; - } - - MEM_freeN(done); - return; - } else /* if there are no UVs, default to local */ - texmapping = MOD_DISP_MAP_LOCAL; - } - - for(i = 0; i < numVerts; ++i, ++co, ++texco) { - switch(texmapping) { - case MOD_DISP_MAP_LOCAL: - VECCOPY(*texco, *co); - break; - case MOD_DISP_MAP_GLOBAL: - VECCOPY(*texco, *co); - mul_m4_v3(ob->obmat, *texco); - break; - case MOD_DISP_MAP_OBJECT: - VECCOPY(*texco, *co); - mul_m4_v3(ob->obmat, *texco); - mul_m4_v3(mapob_imat, *texco); - break; - } - } -} - -static void get_texture_value(Tex *texture, float *tex_co, TexResult *texres) -{ - int result_type; - - result_type = multitex_ext(texture, tex_co, NULL, NULL, 0, texres); - - /* if the texture gave an RGB value, we assume it didn't give a valid - * intensity, so calculate one (formula from do_material_tex). - * if the texture didn't give an RGB value, copy the intensity across - */ - if(result_type & TEX_RGB) - texres->tin = (0.35f * texres->tr + 0.45f * texres->tg - + 0.2f * texres->tb); - else - texres->tr = texres->tg = texres->tb = texres->tin; -} - -/* dm must be a CDDerivedMesh */ -static void displaceModifier_do( - DisplaceModifierData *dmd, Object *ob, - DerivedMesh *dm, float (*vertexCos)[3], int numVerts) -{ - int i; - MVert *mvert; - MDeformVert *dvert = NULL; - int defgrp_index; - float (*tex_co)[3]; - - if(!dmd->texture) return; - - defgrp_index = defgroup_name_index(ob, dmd->defgrp_name); - - mvert = CDDM_get_verts(dm); - if(defgrp_index >= 0) - dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - - tex_co = MEM_callocN(sizeof(*tex_co) * numVerts, - "displaceModifier_do tex_co"); - get_texture_coords(dmd, ob, dm, vertexCos, tex_co, numVerts); - - for(i = 0; i < numVerts; ++i) { - TexResult texres; - float delta = 0, strength = dmd->strength; - MDeformWeight *def_weight = NULL; - - if(dvert) { - int j; - for(j = 0; j < dvert[i].totweight; ++j) { - if(dvert[i].dw[j].def_nr == defgrp_index) { - def_weight = &dvert[i].dw[j]; - break; - } - } - if(!def_weight) continue; - } - - texres.nor = NULL; - get_texture_value(dmd->texture, tex_co[i], &texres); - - delta = texres.tin - dmd->midlevel; - - if(def_weight) strength *= def_weight->weight; - - delta *= strength; - - switch(dmd->direction) { - case MOD_DISP_DIR_X: - vertexCos[i][0] += delta; - break; - case MOD_DISP_DIR_Y: - vertexCos[i][1] += delta; - break; - case MOD_DISP_DIR_Z: - vertexCos[i][2] += delta; - break; - case MOD_DISP_DIR_RGB_XYZ: - vertexCos[i][0] += (texres.tr - dmd->midlevel) * strength; - vertexCos[i][1] += (texres.tg - dmd->midlevel) * strength; - vertexCos[i][2] += (texres.tb - dmd->midlevel) * strength; - break; - case MOD_DISP_DIR_NOR: - vertexCos[i][0] += delta * mvert[i].no[0] / 32767.0f; - vertexCos[i][1] += delta * mvert[i].no[1] / 32767.0f; - vertexCos[i][2] += delta * mvert[i].no[2] / 32767.0f; - break; - } - } - - MEM_freeN(tex_co); -} - -static void displaceModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm= get_cddm(md->scene, ob, NULL, derivedData, vertexCos); - - displaceModifier_do((DisplaceModifierData *)md, ob, dm, - vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -static void displaceModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm= get_cddm(md->scene, ob, editData, derivedData, vertexCos); - - displaceModifier_do((DisplaceModifierData *)md, ob, dm, - vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -/* UVProject */ -/* UV Project modifier: Generates UVs projected from an object -*/ - -static void uvprojectModifier_initData(ModifierData *md) -{ - UVProjectModifierData *umd = (UVProjectModifierData*) md; - int i; - - for(i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) - umd->projectors[i] = NULL; - umd->image = NULL; - 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) -{ - UVProjectModifierData *umd = (UVProjectModifierData*) md; - UVProjectModifierData *tumd = (UVProjectModifierData*) target; - int i; - - for(i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) - tumd->projectors[i] = umd->projectors[i]; - tumd->image = umd->image; - tumd->flags = umd->flags; - 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) -{ - CustomDataMask dataMask = 0; - - /* ask for UV coordinates */ - dataMask |= (1 << CD_MTFACE); - - return dataMask; -} - -static void uvprojectModifier_foreachObjectLink(ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) -{ - UVProjectModifierData *umd = (UVProjectModifierData*) md; - int i; - - for(i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) - walk(userData, ob, &umd->projectors[i]); -} - -static void uvprojectModifier_foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) -{ - UVProjectModifierData *umd = (UVProjectModifierData*) md; - - walk(userData, ob, (ID **)&umd->image); - - uvprojectModifier_foreachObjectLink(md, ob, (ObjectWalkFunc)walk, - userData); -} - -static void uvprojectModifier_updateDepgraph(ModifierData *md, - DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) -{ - UVProjectModifierData *umd = (UVProjectModifierData*) md; - int i; - - for(i = 0; i < umd->num_projectors; ++i) { - if(umd->projectors[i]) { - DagNode *curNode = dag_get_node(forest, umd->projectors[i]); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "UV Project Modifier"); - } - } -} - -typedef struct Projector { - Object *ob; /* object this projector is derived from */ - float projmat[4][4]; /* projection matrix */ - float normal[3]; /* projector normal in world space */ - void *uci; /* optional uv-project info (panorama projection) */ -} Projector; - -static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, - Object *ob, DerivedMesh *dm) -{ - float (*coords)[3], (*co)[3]; - MTFace *tface; - int i, numVerts, numFaces; - Image *image = umd->image; - MFace *mface, *mf; - int override_image = ((umd->flags & MOD_UVPROJECT_OVERRIDEIMAGE) != 0); - Projector projectors[MOD_UVPROJECT_MAXPROJECTORS]; - int num_projectors = 0; - float aspect; - 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; - - for(i = 0; i < umd->num_projectors; ++i) - if(umd->projectors[i]) - projectors[num_projectors++].ob = umd->projectors[i]; - - if(num_projectors == 0) return dm; - - /* make sure there are UV layers available */ - - if(!CustomData_has_layer(&dm->faceData, CD_MTFACE)) return dm; - - /* make sure we're using an existing layer */ - validate_layer_name(&dm->faceData, CD_MTFACE, umd->uvlayer_name, uvname); - - /* calculate a projection matrix and normal for each projector */ - for(i = 0; i < num_projectors; ++i) { - float tmpmat[4][4]; - float offsetmat[4][4]; - Camera *cam = NULL; - /* calculate projection matrix */ - invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat); - - projectors[i].uci= NULL; - - if(projectors[i].ob->type == OB_CAMERA) { - cam = (Camera *)projectors[i].ob->data; - - if(cam->flag & CAM_PANORAMA) { - projectors[i].uci= project_camera_info(projectors[i].ob, NULL, aspx, aspy); - free_uci= 1; - } - else if(cam->type == CAM_PERSP) { - float perspmat[4][4]; - float xmax; - float xmin; - float ymax; - float ymin; - float pixsize = cam->clipsta * 32.0 / cam->lens; - - if(aspect > 1.0f) { - xmax = 0.5f * pixsize; - ymax = xmax / aspect; - } else { - ymax = 0.5f * pixsize; - xmax = ymax * aspect; - } - xmin = -xmax; - ymin = -ymax; - - perspective_m4( perspmat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend); - mul_m4_m4m4(tmpmat, projectors[i].projmat, perspmat); - } else if(cam->type == CAM_ORTHO) { - float orthomat[4][4]; - float xmax; - float xmin; - float ymax; - float ymin; - - if(aspect > 1.0f) { - xmax = 0.5f * cam->ortho_scale; - ymax = xmax / aspect; - } else { - ymax = 0.5f * cam->ortho_scale; - xmax = ymax * aspect; - } - xmin = -xmax; - ymin = -ymax; - - orthographic_m4( orthomat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend); - mul_m4_m4m4(tmpmat, projectors[i].projmat, orthomat); - } - } else { - copy_m4_m4(tmpmat, projectors[i].projmat); - } - - unit_m4(offsetmat); - mul_mat3_m4_fl(offsetmat, 0.5); - offsetmat[3][0] = offsetmat[3][1] = offsetmat[3][2] = 0.5; - - if (cam) { - if (aspx == aspy) { - offsetmat[3][0] -= cam->shiftx; - offsetmat[3][1] -= cam->shifty; - } else if (aspx < aspy) { - offsetmat[3][0] -=(cam->shiftx * aspy/aspx); - offsetmat[3][1] -= cam->shifty; - } else { - offsetmat[3][0] -= cam->shiftx; - offsetmat[3][1] -=(cam->shifty * aspx/aspy); - } - } - - mul_m4_m4m4(projectors[i].projmat, tmpmat, offsetmat); - - /* calculate worldspace projector normal (for best projector test) */ - projectors[i].normal[0] = 0; - projectors[i].normal[1] = 0; - projectors[i].normal[2] = 1; - mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal); - } - - /* make sure we are not modifying the original UV layer */ - tface = CustomData_duplicate_referenced_layer_named(&dm->faceData, - CD_MTFACE, uvname); - - - numVerts = dm->getNumVerts(dm); - - coords = MEM_callocN(sizeof(*coords) * numVerts, - "uvprojectModifier_do coords"); - dm->getVertCos(dm, coords); - - /* convert coords to world space */ - for(i = 0, co = coords; i < numVerts; ++i, ++co) - mul_m4_v3(ob->obmat, *co); - - /* if only one projector, project coords to UVs */ - if(num_projectors == 1 && projectors[0].uci==NULL) - for(i = 0, co = coords; i < numVerts; ++i, ++co) - mul_project_m4_v4(projectors[0].projmat, *co); - - mface = dm->getFaceArray(dm); - numFaces = dm->getNumFaces(dm); - - /* apply coords as UVs, and apply image if tfaces are new */ - for(i = 0, mf = mface; i < numFaces; ++i, ++mf, ++tface) { - if(override_image || !image || tface->tpage == image) { - if(num_projectors == 1) { - if(projectors[0].uci) { - project_from_camera(tface->uv[0], coords[mf->v1], projectors[0].uci); - project_from_camera(tface->uv[1], coords[mf->v2], projectors[0].uci); - 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 */ - tface->uv[0][0] = coords[mf->v1][0]; - tface->uv[0][1] = coords[mf->v1][1]; - tface->uv[1][0] = coords[mf->v2][0]; - tface->uv[1][1] = coords[mf->v2][1]; - tface->uv[2][0] = coords[mf->v3][0]; - tface->uv[2][1] = coords[mf->v3][1]; - if(mf->v4) { - tface->uv[3][0] = coords[mf->v4][0]; - tface->uv[3][1] = coords[mf->v4][1]; - } - } - } else { - /* multiple projectors, select the closest to face normal - * direction - */ - float co1[3], co2[3], co3[3], co4[3]; - float face_no[3]; - int j; - Projector *best_projector; - float best_dot; - - VECCOPY(co1, coords[mf->v1]); - VECCOPY(co2, coords[mf->v2]); - VECCOPY(co3, coords[mf->v3]); - - /* get the untransformed face normal */ - if(mf->v4) { - VECCOPY(co4, coords[mf->v4]); - normal_quad_v3( face_no,co1, co2, co3, co4); - } else { - normal_tri_v3( face_no,co1, co2, co3); - } - - /* find the projector which the face points at most directly - * (projector normal with largest dot product is best) - */ - best_dot = dot_v3v3(projectors[0].normal, face_no); - best_projector = &projectors[0]; - - for(j = 1; j < num_projectors; ++j) { - float tmp_dot = dot_v3v3(projectors[j].normal, - face_no); - if(tmp_dot > best_dot) { - best_dot = tmp_dot; - best_projector = &projectors[j]; - } - } - - if(best_projector->uci) { - project_from_camera(tface->uv[0], coords[mf->v1], best_projector->uci); - project_from_camera(tface->uv[1], coords[mf->v2], best_projector->uci); - project_from_camera(tface->uv[2], coords[mf->v3], best_projector->uci); - if(mf->v3) - project_from_camera(tface->uv[3], coords[mf->v4], best_projector->uci); - } - else { - mul_project_m4_v4(best_projector->projmat, co1); - mul_project_m4_v4(best_projector->projmat, co2); - mul_project_m4_v4(best_projector->projmat, co3); - if(mf->v4) - mul_project_m4_v4(best_projector->projmat, co4); - - /* apply transformed coords as UVs */ - tface->uv[0][0] = co1[0]; - tface->uv[0][1] = co1[1]; - tface->uv[1][0] = co2[0]; - tface->uv[1][1] = co2[1]; - tface->uv[2][0] = co3[0]; - tface->uv[2][1] = co3[1]; - if(mf->v4) { - tface->uv[3][0] = co4[0]; - tface->uv[3][1] = co4[1]; - } - } - } - } - - if(override_image) { - tface->mode = TF_TEX; - tface->tpage = image; - } - } - - MEM_freeN(coords); - - if(free_uci) { - int j; - for(j = 0; j < num_projectors; ++j) { - if(projectors[j].uci) { - MEM_freeN(projectors[j].uci); - } - } - } - return dm; -} - -static DerivedMesh *uvprojectModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - DerivedMesh *result; - UVProjectModifierData *umd = (UVProjectModifierData*) md; - - result = uvprojectModifier_do(umd, ob, derivedData); - - return result; -} - -static DerivedMesh *uvprojectModifier_applyModifierEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData) -{ - return uvprojectModifier_applyModifier(md, ob, derivedData, 0, 1); -} - -/* Decimate */ - -static void decimateModifier_initData(ModifierData *md) -{ - DecimateModifierData *dmd = (DecimateModifierData*) md; - - dmd->percent = 1.0; -} - -static void decimateModifier_copyData(ModifierData *md, ModifierData *target) -{ - DecimateModifierData *dmd = (DecimateModifierData*) md; - DecimateModifierData *tdmd = (DecimateModifierData*) target; - - tdmd->percent = dmd->percent; -} - -static DerivedMesh *decimateModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - DecimateModifierData *dmd = (DecimateModifierData*) md; - DerivedMesh *dm = derivedData, *result = NULL; - MVert *mvert; - MFace *mface; - LOD_Decimation_Info lod; - int totvert, totface; - int a, numTris; - - mvert = dm->getVertArray(dm); - mface = dm->getFaceArray(dm); - totvert = dm->getNumVerts(dm); - totface = dm->getNumFaces(dm); - - numTris = 0; - for (a=0; av4) numTris++; - } - - if(numTris<3) { - modifier_setError(md, - "Modifier requires more than 3 input faces (triangles)."); - goto exit; - } - - lod.vertex_buffer= MEM_mallocN(3*sizeof(float)*totvert, "vertices"); - lod.vertex_normal_buffer= MEM_mallocN(3*sizeof(float)*totvert, "normals"); - lod.triangle_index_buffer= MEM_mallocN(3*sizeof(int)*numTris, "trias"); - lod.vertex_num= totvert; - lod.face_num= numTris; - - for(a=0; aco); - - vbNo[0] = mv->no[0]/32767.0f; - vbNo[1] = mv->no[1]/32767.0f; - vbNo[2] = mv->no[2]/32767.0f; - } - - numTris = 0; - for(a=0; av1; - tri[1]= mf->v2; - tri[2]= mf->v3; - - if(mf->v4) { - tri = &lod.triangle_index_buffer[3*numTris++]; - tri[0]= mf->v1; - tri[1]= mf->v3; - tri[2]= mf->v4; - } - } - - dmd->faceCount = 0; - if(LOD_LoadMesh(&lod) ) { - if( LOD_PreprocessMesh(&lod) ) { - /* we assume the decim_faces tells how much to reduce */ - - while(lod.face_num > numTris*dmd->percent) { - if( LOD_CollapseEdge(&lod)==0) break; - } - - if(lod.vertex_num>2) { - result = CDDM_new(lod.vertex_num, 0, lod.face_num); - dmd->faceCount = lod.face_num; - } - else - result = CDDM_new(lod.vertex_num, 0, 0); - - mvert = CDDM_get_verts(result); - for(a=0; aco, vbCo); - } - - if(lod.vertex_num>2) { - mface = CDDM_get_faces(result); - for(a=0; av1 = tri[0]; - mf->v2 = tri[1]; - mf->v3 = tri[2]; - test_index_face(mf, NULL, 0, 3); - } - } - - CDDM_calc_edges(result); - CDDM_calc_normals(result); - } - else - modifier_setError(md, "Out of memory."); - - LOD_FreeDecimationData(&lod); - } - else - modifier_setError(md, "Non-manifold mesh as input."); - - MEM_freeN(lod.vertex_buffer); - MEM_freeN(lod.vertex_normal_buffer); - MEM_freeN(lod.triangle_index_buffer); - -exit: - return result; -} - -/* Smooth */ - -static void smoothModifier_initData(ModifierData *md) -{ - SmoothModifierData *smd = (SmoothModifierData*) md; - - smd->fac = 0.5f; - smd->repeat = 1; - smd->flag = MOD_SMOOTH_X | MOD_SMOOTH_Y | MOD_SMOOTH_Z; - smd->defgrp_name[0] = '\0'; -} - -static void smoothModifier_copyData(ModifierData *md, ModifierData *target) -{ - SmoothModifierData *smd = (SmoothModifierData*) md; - SmoothModifierData *tsmd = (SmoothModifierData*) target; - - tsmd->fac = smd->fac; - tsmd->repeat = smd->repeat; - tsmd->flag = smd->flag; - strncpy(tsmd->defgrp_name, smd->defgrp_name, 32); -} - -static int smoothModifier_isDisabled(ModifierData *md, int useRenderParams) -{ - SmoothModifierData *smd = (SmoothModifierData*) md; - short flag; - - flag = smd->flag & (MOD_SMOOTH_X|MOD_SMOOTH_Y|MOD_SMOOTH_Z); - - /* disable if modifier is off for X, Y and Z or if factor is 0 */ - if((smd->fac == 0.0f) || flag == 0) return 1; - - return 0; -} - -static CustomDataMask smoothModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - SmoothModifierData *smd = (SmoothModifierData *)md; - CustomDataMask dataMask = 0; - - /* ask for vertexgroups if we need them */ - if(smd->defgrp_name[0]) dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static void smoothModifier_do( - SmoothModifierData *smd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) -{ - MDeformVert *dvert = NULL; - MEdge *medges = NULL; - - int i, j, numDMEdges, defgrp_index; - unsigned char *uctmp; - float *ftmp, fac, facm; - - ftmp = (float*)MEM_callocN(3*sizeof(float)*numVerts, - "smoothmodifier_f"); - if (!ftmp) return; - uctmp = (unsigned char*)MEM_callocN(sizeof(unsigned char)*numVerts, - "smoothmodifier_uc"); - if (!uctmp) { - if (ftmp) MEM_freeN(ftmp); - return; - } - - fac = smd->fac; - facm = 1 - fac; - - medges = dm->getEdgeArray(dm); - numDMEdges = dm->getNumEdges(dm); - - defgrp_index = defgroup_name_index(ob, smd->defgrp_name); - - if (defgrp_index >= 0) - dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - - /* NOTICE: this can be optimized a little bit by moving the - * if (dvert) out of the loop, if needed */ - for (j = 0; j < smd->repeat; j++) { - for (i = 0; i < numDMEdges; i++) { - float fvec[3]; - float *v1, *v2; - unsigned int idx1, idx2; - - idx1 = medges[i].v1; - idx2 = medges[i].v2; - - v1 = vertexCos[idx1]; - v2 = vertexCos[idx2]; - - fvec[0] = (v1[0] + v2[0]) / 2.0; - fvec[1] = (v1[1] + v2[1]) / 2.0; - fvec[2] = (v1[2] + v2[2]) / 2.0; - - v1 = &ftmp[idx1*3]; - v2 = &ftmp[idx2*3]; - - if (uctmp[idx1] < 255) { - uctmp[idx1]++; - add_v3_v3v3(v1, v1, fvec); - } - if (uctmp[idx2] < 255) { - uctmp[idx2]++; - add_v3_v3v3(v2, v2, fvec); - } - } - - if (dvert) { - for (i = 0; i < numVerts; i++) { - MDeformWeight *dw = NULL; - float f, fm, facw, *fp, *v; - int k; - short flag = smd->flag; - - v = vertexCos[i]; - fp = &ftmp[i*3]; - - for (k = 0; k < dvert[i].totweight; ++k) { - if(dvert[i].dw[k].def_nr == defgrp_index) { - dw = &dvert[i].dw[k]; - break; - } - } - if (!dw) continue; - - f = fac * dw->weight; - fm = 1.0f - f; - - /* fp is the sum of uctmp[i] verts, so must be averaged */ - facw = 0.0f; - if (uctmp[i]) - facw = f / (float)uctmp[i]; - - if (flag & MOD_SMOOTH_X) - v[0] = fm * v[0] + facw * fp[0]; - if (flag & MOD_SMOOTH_Y) - v[1] = fm * v[1] + facw * fp[1]; - if (flag & MOD_SMOOTH_Z) - v[2] = fm * v[2] + facw * fp[2]; - } - } - else { /* no vertex group */ - for (i = 0; i < numVerts; i++) { - float facw, *fp, *v; - short flag = smd->flag; - - v = vertexCos[i]; - fp = &ftmp[i*3]; - - /* fp is the sum of uctmp[i] verts, so must be averaged */ - facw = 0.0f; - if (uctmp[i]) - facw = fac / (float)uctmp[i]; - - if (flag & MOD_SMOOTH_X) - v[0] = facm * v[0] + facw * fp[0]; - if (flag & MOD_SMOOTH_Y) - v[1] = facm * v[1] + facw * fp[1]; - if (flag & MOD_SMOOTH_Z) - v[2] = facm * v[2] + facw * fp[2]; - } - - } - - memset(ftmp, 0, 3*sizeof(float)*numVerts); - memset(uctmp, 0, sizeof(unsigned char)*numVerts); - } - - MEM_freeN(ftmp); - MEM_freeN(uctmp); -} - -static void smoothModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm= get_dm(md->scene, ob, NULL, derivedData, NULL, 0); - - smoothModifier_do((SmoothModifierData *)md, ob, dm, - vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -static void smoothModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm= get_dm(md->scene, ob, editData, derivedData, NULL, 0); - - smoothModifier_do((SmoothModifierData *)md, ob, dm, - vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -/* Cast */ - -static void castModifier_initData(ModifierData *md) -{ - CastModifierData *cmd = (CastModifierData*) md; - - cmd->fac = 0.5f; - cmd->radius = 0.0f; - cmd->size = 0.0f; - cmd->flag = MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z - | MOD_CAST_SIZE_FROM_RADIUS; - cmd->type = MOD_CAST_TYPE_SPHERE; - cmd->defgrp_name[0] = '\0'; - cmd->object = NULL; -} - - -static void castModifier_copyData(ModifierData *md, ModifierData *target) -{ - CastModifierData *cmd = (CastModifierData*) md; - CastModifierData *tcmd = (CastModifierData*) target; - - tcmd->fac = cmd->fac; - tcmd->radius = cmd->radius; - tcmd->size = cmd->size; - tcmd->flag = cmd->flag; - tcmd->type = cmd->type; - tcmd->object = cmd->object; - strncpy(tcmd->defgrp_name, cmd->defgrp_name, 32); -} - -static int castModifier_isDisabled(ModifierData *md, int useRenderParams) -{ - CastModifierData *cmd = (CastModifierData*) md; - short flag; - - flag = cmd->flag & (MOD_CAST_X|MOD_CAST_Y|MOD_CAST_Z); - - if((cmd->fac == 0.0f) || flag == 0) return 1; - - return 0; -} - -static CustomDataMask castModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - CastModifierData *cmd = (CastModifierData *)md; - CustomDataMask dataMask = 0; - - /* ask for vertexgroups if we need them */ - if(cmd->defgrp_name[0]) dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static void castModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - CastModifierData *cmd = (CastModifierData*) md; - - walk (userData, ob, &cmd->object); -} - -static void castModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) -{ - CastModifierData *cmd = (CastModifierData*) md; - - if (cmd->object) { - DagNode *curNode = dag_get_node(forest, cmd->object); - - dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, - "Cast Modifier"); - } -} - -static void castModifier_sphere_do( - CastModifierData *cmd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) -{ - MDeformVert *dvert = NULL; - - Object *ctrl_ob = NULL; - - int i, defgrp_index; - int has_radius = 0; - short flag, type; - float fac, facm, len = 0.0f; - float vec[3], center[3] = {0.0f, 0.0f, 0.0f}; - float mat[4][4], imat[4][4]; - - fac = cmd->fac; - facm = 1.0f - fac; - - flag = cmd->flag; - type = cmd->type; /* projection type: sphere or cylinder */ - - if (type == MOD_CAST_TYPE_CYLINDER) - flag &= ~MOD_CAST_Z; - - ctrl_ob = cmd->object; - - /* spherify's center is {0, 0, 0} (the ob's own center in its local - * space), by default, but if the user defined a control object, - * we use its location, transformed to ob's local space */ - if (ctrl_ob) { - if(flag & MOD_CAST_USE_OB_TRANSFORM) { - invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat); - mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat); - invert_m4_m4(imat, mat); - } - - invert_m4_m4(ob->imat, ob->obmat); - VECCOPY(center, ctrl_ob->obmat[3]); - mul_m4_v3(ob->imat, center); - } - - /* now we check which options the user wants */ - - /* 1) (flag was checked in the "if (ctrl_ob)" block above) */ - /* 2) cmd->radius > 0.0f: only the vertices within this radius from - * the center of the effect should be deformed */ - if (cmd->radius > FLT_EPSILON) has_radius = 1; - - /* 3) if we were given a vertex group name, - * only those vertices should be affected */ - defgrp_index = defgroup_name_index(ob, cmd->defgrp_name); - - if ((ob->type == OB_MESH) && dm && defgrp_index >= 0) - dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - - if(flag & MOD_CAST_SIZE_FROM_RADIUS) { - len = cmd->radius; - } - else { - len = cmd->size; - } - - if(len <= 0) { - for (i = 0; i < numVerts; i++) { - len += len_v3v3(center, vertexCos[i]); - } - len /= numVerts; - - if (len == 0.0f) len = 10.0f; - } - - /* ready to apply the effect, one vertex at a time; - * tiny optimization: the code is separated (with parts repeated) - * in two possible cases: - * with or w/o a vgroup. With lots of if's in the code below, - * further optimizations are possible, if needed */ - if (dvert) { /* with a vgroup */ - float fac_orig = fac; - for (i = 0; i < numVerts; i++) { - MDeformWeight *dw = NULL; - int j; - float tmp_co[3]; - - VECCOPY(tmp_co, vertexCos[i]); - if(ctrl_ob) { - if(flag & MOD_CAST_USE_OB_TRANSFORM) { - mul_m4_v3(mat, tmp_co); - } else { - sub_v3_v3v3(tmp_co, tmp_co, center); - } - } - - VECCOPY(vec, tmp_co); - - if (type == MOD_CAST_TYPE_CYLINDER) - vec[2] = 0.0f; - - if (has_radius) { - if (len_v3(vec) > cmd->radius) continue; - } - - for (j = 0; j < dvert[i].totweight; ++j) { - if(dvert[i].dw[j].def_nr == defgrp_index) { - dw = &dvert[i].dw[j]; - break; - } - } - if (!dw) continue; - - fac = fac_orig * dw->weight; - facm = 1.0f - fac; - - normalize_v3(vec); - - if (flag & MOD_CAST_X) - tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0]; - if (flag & MOD_CAST_Y) - tmp_co[1] = fac*vec[1]*len + facm*tmp_co[1]; - if (flag & MOD_CAST_Z) - tmp_co[2] = fac*vec[2]*len + facm*tmp_co[2]; - - if(ctrl_ob) { - if(flag & MOD_CAST_USE_OB_TRANSFORM) { - mul_m4_v3(imat, tmp_co); - } else { - add_v3_v3v3(tmp_co, tmp_co, center); - } - } - - VECCOPY(vertexCos[i], tmp_co); - } - return; - } - - /* no vgroup */ - for (i = 0; i < numVerts; i++) { - float tmp_co[3]; - - VECCOPY(tmp_co, vertexCos[i]); - if(ctrl_ob) { - if(flag & MOD_CAST_USE_OB_TRANSFORM) { - mul_m4_v3(mat, tmp_co); - } else { - sub_v3_v3v3(tmp_co, tmp_co, center); - } - } - - VECCOPY(vec, tmp_co); - - if (type == MOD_CAST_TYPE_CYLINDER) - vec[2] = 0.0f; - - if (has_radius) { - if (len_v3(vec) > cmd->radius) continue; - } - - normalize_v3(vec); - - if (flag & MOD_CAST_X) - tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0]; - if (flag & MOD_CAST_Y) - tmp_co[1] = fac*vec[1]*len + facm*tmp_co[1]; - if (flag & MOD_CAST_Z) - tmp_co[2] = fac*vec[2]*len + facm*tmp_co[2]; - - if(ctrl_ob) { - if(flag & MOD_CAST_USE_OB_TRANSFORM) { - mul_m4_v3(imat, tmp_co); - } else { - add_v3_v3v3(tmp_co, tmp_co, center); - } - } - - VECCOPY(vertexCos[i], tmp_co); - } -} - -static void castModifier_cuboid_do( - CastModifierData *cmd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) -{ - MDeformVert *dvert = NULL; - Object *ctrl_ob = NULL; - - int i, defgrp_index; - int has_radius = 0; - short flag; - float fac, facm; - float min[3], max[3], bb[8][3]; - float center[3] = {0.0f, 0.0f, 0.0f}; - float mat[4][4], imat[4][4]; - - fac = cmd->fac; - facm = 1.0f - fac; - - flag = cmd->flag; - - ctrl_ob = cmd->object; - - /* now we check which options the user wants */ - - /* 1) (flag was checked in the "if (ctrl_ob)" block above) */ - /* 2) cmd->radius > 0.0f: only the vertices within this radius from - * the center of the effect should be deformed */ - if (cmd->radius > FLT_EPSILON) has_radius = 1; - - /* 3) if we were given a vertex group name, - * only those vertices should be affected */ - defgrp_index = defgroup_name_index(ob, cmd->defgrp_name); - - if ((ob->type == OB_MESH) && dm && defgrp_index >= 0) - dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - - if (ctrl_ob) { - if(flag & MOD_CAST_USE_OB_TRANSFORM) { - invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat); - mul_m4_m4m4(mat, ob->obmat, ctrl_ob->imat); - invert_m4_m4(imat, mat); - } - - invert_m4_m4(ob->imat, ob->obmat); - VECCOPY(center, ctrl_ob->obmat[3]); - mul_m4_v3(ob->imat, center); - } - - if((flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) { - for(i = 0; i < 3; i++) { - min[i] = -cmd->radius; - max[i] = cmd->radius; - } - } else if(!(flag & MOD_CAST_SIZE_FROM_RADIUS) && cmd->size > 0) { - for(i = 0; i < 3; i++) { - min[i] = -cmd->size; - max[i] = cmd->size; - } - } else { - /* get bound box */ - /* We can't use the object's bound box because other modifiers - * may have changed the vertex data. */ - INIT_MINMAX(min, max); - - /* Cast's center is the ob's own center in its local space, - * by default, but if the user defined a control object, we use - * its location, transformed to ob's local space. */ - if (ctrl_ob) { - float vec[3]; - - /* let the center of the ctrl_ob be part of the bound box: */ - DO_MINMAX(center, min, max); - - for (i = 0; i < numVerts; i++) { - sub_v3_v3v3(vec, vertexCos[i], center); - DO_MINMAX(vec, min, max); - } - } - else { - for (i = 0; i < numVerts; i++) { - DO_MINMAX(vertexCos[i], min, max); - } - } - - /* we want a symmetric bound box around the origin */ - if (fabs(min[0]) > fabs(max[0])) max[0] = fabs(min[0]); - if (fabs(min[1]) > fabs(max[1])) max[1] = fabs(min[1]); - if (fabs(min[2]) > fabs(max[2])) max[2] = fabs(min[2]); - min[0] = -max[0]; - min[1] = -max[1]; - min[2] = -max[2]; - } - - /* building our custom bounding box */ - bb[0][0] = bb[2][0] = bb[4][0] = bb[6][0] = min[0]; - bb[1][0] = bb[3][0] = bb[5][0] = bb[7][0] = max[0]; - bb[0][1] = bb[1][1] = bb[4][1] = bb[5][1] = min[1]; - bb[2][1] = bb[3][1] = bb[6][1] = bb[7][1] = max[1]; - bb[0][2] = bb[1][2] = bb[2][2] = bb[3][2] = min[2]; - bb[4][2] = bb[5][2] = bb[6][2] = bb[7][2] = max[2]; - - /* ready to apply the effect, one vertex at a time; - * tiny optimization: the code is separated (with parts repeated) - * in two possible cases: - * with or w/o a vgroup. With lots of if's in the code below, - * further optimizations are possible, if needed */ - if (dvert) { /* with a vgroup */ - float fac_orig = fac; - for (i = 0; i < numVerts; i++) { - MDeformWeight *dw = NULL; - int j, octant, coord; - float d[3], dmax, apex[3], fbb; - float tmp_co[3]; - - VECCOPY(tmp_co, vertexCos[i]); - if(ctrl_ob) { - if(flag & MOD_CAST_USE_OB_TRANSFORM) { - mul_m4_v3(mat, tmp_co); - } else { - sub_v3_v3v3(tmp_co, tmp_co, center); - } - } - - if (has_radius) { - if (fabs(tmp_co[0]) > cmd->radius || - fabs(tmp_co[1]) > cmd->radius || - fabs(tmp_co[2]) > cmd->radius) continue; - } - - for (j = 0; j < dvert[i].totweight; ++j) { - if(dvert[i].dw[j].def_nr == defgrp_index) { - dw = &dvert[i].dw[j]; - break; - } - } - if (!dw) continue; - - fac = fac_orig * dw->weight; - facm = 1.0f - fac; - - /* The algo used to project the vertices to their - * bounding box (bb) is pretty simple: - * for each vertex v: - * 1) find in which octant v is in; - * 2) find which outer "wall" of that octant is closer to v; - * 3) calculate factor (var fbb) to project v to that wall; - * 4) project. */ - - /* find in which octant this vertex is in */ - octant = 0; - if (tmp_co[0] > 0.0f) octant += 1; - if (tmp_co[1] > 0.0f) octant += 2; - if (tmp_co[2] > 0.0f) octant += 4; - - /* apex is the bb's vertex at the chosen octant */ - copy_v3_v3(apex, bb[octant]); - - /* find which bb plane is closest to this vertex ... */ - d[0] = tmp_co[0] / apex[0]; - d[1] = tmp_co[1] / apex[1]; - d[2] = tmp_co[2] / apex[2]; - - /* ... (the closest has the higher (closer to 1) d value) */ - dmax = d[0]; - coord = 0; - if (d[1] > dmax) { - dmax = d[1]; - coord = 1; - } - if (d[2] > dmax) { - /* dmax = d[2]; */ /* commented, we don't need it */ - coord = 2; - } - - /* ok, now we know which coordinate of the vertex to use */ - - if (fabs(tmp_co[coord]) < FLT_EPSILON) /* avoid division by zero */ - continue; - - /* finally, this is the factor we wanted, to project the vertex - * to its bounding box (bb) */ - fbb = apex[coord] / tmp_co[coord]; - - /* calculate the new vertex position */ - if (flag & MOD_CAST_X) - tmp_co[0] = facm * tmp_co[0] + fac * tmp_co[0] * fbb; - if (flag & MOD_CAST_Y) - tmp_co[1] = facm * tmp_co[1] + fac * tmp_co[1] * fbb; - if (flag & MOD_CAST_Z) - tmp_co[2] = facm * tmp_co[2] + fac * tmp_co[2] * fbb; - - if(ctrl_ob) { - if(flag & MOD_CAST_USE_OB_TRANSFORM) { - mul_m4_v3(imat, tmp_co); - } else { - add_v3_v3v3(tmp_co, tmp_co, center); - } - } - - VECCOPY(vertexCos[i], tmp_co); - } - return; - } - - /* no vgroup (check previous case for comments about the code) */ - for (i = 0; i < numVerts; i++) { - int octant, coord; - float d[3], dmax, fbb, apex[3]; - float tmp_co[3]; - - VECCOPY(tmp_co, vertexCos[i]); - if(ctrl_ob) { - if(flag & MOD_CAST_USE_OB_TRANSFORM) { - mul_m4_v3(mat, tmp_co); - } else { - sub_v3_v3v3(tmp_co, tmp_co, center); - } - } - - if (has_radius) { - if (fabs(tmp_co[0]) > cmd->radius || - fabs(tmp_co[1]) > cmd->radius || - fabs(tmp_co[2]) > cmd->radius) continue; - } - - octant = 0; - if (tmp_co[0] > 0.0f) octant += 1; - if (tmp_co[1] > 0.0f) octant += 2; - if (tmp_co[2] > 0.0f) octant += 4; - - copy_v3_v3(apex, bb[octant]); - - d[0] = tmp_co[0] / apex[0]; - d[1] = tmp_co[1] / apex[1]; - d[2] = tmp_co[2] / apex[2]; - - dmax = d[0]; - coord = 0; - if (d[1] > dmax) { - dmax = d[1]; - coord = 1; - } - if (d[2] > dmax) { - /* dmax = d[2]; */ /* commented, we don't need it */ - coord = 2; - } - - if (fabs(tmp_co[coord]) < FLT_EPSILON) - continue; - - fbb = apex[coord] / tmp_co[coord]; - - if (flag & MOD_CAST_X) - tmp_co[0] = facm * tmp_co[0] + fac * tmp_co[0] * fbb; - if (flag & MOD_CAST_Y) - tmp_co[1] = facm * tmp_co[1] + fac * tmp_co[1] * fbb; - if (flag & MOD_CAST_Z) - tmp_co[2] = facm * tmp_co[2] + fac * tmp_co[2] * fbb; - - if(ctrl_ob) { - if(flag & MOD_CAST_USE_OB_TRANSFORM) { - mul_m4_v3(imat, tmp_co); - } else { - add_v3_v3v3(tmp_co, tmp_co, center); - } - } - - VECCOPY(vertexCos[i], tmp_co); - } -} - -static void castModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm = NULL; - CastModifierData *cmd = (CastModifierData *)md; - - dm = get_dm(md->scene, ob, NULL, derivedData, NULL, 0); - - if (cmd->type == MOD_CAST_TYPE_CUBOID) { - castModifier_cuboid_do(cmd, ob, dm, vertexCos, numVerts); - } else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */ - castModifier_sphere_do(cmd, ob, dm, vertexCos, numVerts); - } - - if(dm != derivedData) - dm->release(dm); -} - -static void castModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm = get_dm(md->scene, ob, editData, derivedData, NULL, 0); - CastModifierData *cmd = (CastModifierData *)md; - - if (cmd->type == MOD_CAST_TYPE_CUBOID) { - castModifier_cuboid_do(cmd, ob, dm, vertexCos, numVerts); - } else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */ - castModifier_sphere_do(cmd, ob, dm, vertexCos, numVerts); - } - - if(dm != derivedData) - dm->release(dm); -} - -/* Wave */ - -static void waveModifier_initData(ModifierData *md) -{ - WaveModifierData *wmd = (WaveModifierData*) md; // whadya know, moved here from Iraq - - wmd->flag |= (MOD_WAVE_X | MOD_WAVE_Y | MOD_WAVE_CYCL - | MOD_WAVE_NORM_X | MOD_WAVE_NORM_Y | MOD_WAVE_NORM_Z); - - wmd->objectcenter = NULL; - wmd->texture = NULL; - wmd->map_object = NULL; - wmd->height= 0.5f; - wmd->width= 1.5f; - wmd->speed= 0.25f; - wmd->narrow= 1.5f; - wmd->lifetime= 0.0f; - wmd->damp= 10.0f; - wmd->falloff= 0.0f; - wmd->texmapping = MOD_WAV_MAP_LOCAL; - wmd->defgrp_name[0] = 0; -} - -static void waveModifier_copyData(ModifierData *md, ModifierData *target) -{ - WaveModifierData *wmd = (WaveModifierData*) md; - WaveModifierData *twmd = (WaveModifierData*) target; - - twmd->damp = wmd->damp; - twmd->flag = wmd->flag; - twmd->height = wmd->height; - twmd->lifetime = wmd->lifetime; - twmd->narrow = wmd->narrow; - twmd->speed = wmd->speed; - twmd->startx = wmd->startx; - twmd->starty = wmd->starty; - twmd->timeoffs = wmd->timeoffs; - twmd->width = wmd->width; - twmd->falloff = wmd->falloff; - twmd->objectcenter = wmd->objectcenter; - twmd->texture = wmd->texture; - twmd->map_object = wmd->map_object; - twmd->texmapping = wmd->texmapping; - strncpy(twmd->defgrp_name, wmd->defgrp_name, 32); -} - -static int waveModifier_dependsOnTime(ModifierData *md) -{ - return 1; -} - -static void waveModifier_foreachObjectLink( - ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) -{ - WaveModifierData *wmd = (WaveModifierData*) md; - - walk(userData, ob, &wmd->objectcenter); - walk(userData, ob, &wmd->map_object); -} - -static void waveModifier_foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) -{ - WaveModifierData *wmd = (WaveModifierData*) md; - - walk(userData, ob, (ID **)&wmd->texture); - - waveModifier_foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); -} - -static void waveModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) -{ - WaveModifierData *wmd = (WaveModifierData*) md; - - if(wmd->objectcenter) { - DagNode *curNode = dag_get_node(forest, wmd->objectcenter); - - dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, - "Wave Modifier"); - } - - if(wmd->map_object) { - DagNode *curNode = dag_get_node(forest, wmd->map_object); - - dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, - "Wave Modifer"); - } -} - -static CustomDataMask waveModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - WaveModifierData *wmd = (WaveModifierData *)md; - CustomDataMask dataMask = 0; - - - /* ask for UV coordinates if we need them */ - if(wmd->texture && wmd->texmapping == MOD_WAV_MAP_UV) - dataMask |= (1 << CD_MTFACE); - - /* ask for vertexgroups if we need them */ - if(wmd->defgrp_name[0]) - dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob, - DerivedMesh *dm, - float (*co)[3], float (*texco)[3], - int numVerts) -{ - int i; - int texmapping = wmd->texmapping; - - if(texmapping == MOD_WAV_MAP_OBJECT) { - if(wmd->map_object) - invert_m4_m4(wmd->map_object->imat, wmd->map_object->obmat); - else /* if there is no map object, default to local */ - texmapping = MOD_WAV_MAP_LOCAL; - } - - /* UVs need special handling, since they come from faces */ - if(texmapping == MOD_WAV_MAP_UV) { - if(CustomData_has_layer(&dm->faceData, CD_MTFACE)) { - MFace *mface = dm->getFaceArray(dm); - MFace *mf; - char *done = MEM_callocN(sizeof(*done) * numVerts, - "get_texture_coords done"); - int numFaces = dm->getNumFaces(dm); - char uvname[32]; - MTFace *tf; - - validate_layer_name(&dm->faceData, CD_MTFACE, wmd->uvlayer_name, uvname); - tf = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname); - - /* verts are given the UV from the first face that uses them */ - for(i = 0, mf = mface; i < numFaces; ++i, ++mf, ++tf) { - if(!done[mf->v1]) { - texco[mf->v1][0] = tf->uv[0][0]; - texco[mf->v1][1] = tf->uv[0][1]; - texco[mf->v1][2] = 0; - done[mf->v1] = 1; - } - if(!done[mf->v2]) { - texco[mf->v2][0] = tf->uv[1][0]; - texco[mf->v2][1] = tf->uv[1][1]; - texco[mf->v2][2] = 0; - done[mf->v2] = 1; - } - if(!done[mf->v3]) { - texco[mf->v3][0] = tf->uv[2][0]; - texco[mf->v3][1] = tf->uv[2][1]; - texco[mf->v3][2] = 0; - done[mf->v3] = 1; - } - if(!done[mf->v4]) { - texco[mf->v4][0] = tf->uv[3][0]; - texco[mf->v4][1] = tf->uv[3][1]; - texco[mf->v4][2] = 0; - done[mf->v4] = 1; - } - } - - /* remap UVs from [0, 1] to [-1, 1] */ - for(i = 0; i < numVerts; ++i) { - texco[i][0] = texco[i][0] * 2 - 1; - texco[i][1] = texco[i][1] * 2 - 1; - } - - MEM_freeN(done); - return; - } else /* if there are no UVs, default to local */ - texmapping = MOD_WAV_MAP_LOCAL; - } - - for(i = 0; i < numVerts; ++i, ++co, ++texco) { - switch(texmapping) { - case MOD_WAV_MAP_LOCAL: - VECCOPY(*texco, *co); - break; - case MOD_WAV_MAP_GLOBAL: - VECCOPY(*texco, *co); - mul_m4_v3(ob->obmat, *texco); - break; - case MOD_WAV_MAP_OBJECT: - VECCOPY(*texco, *co); - mul_m4_v3(ob->obmat, *texco); - mul_m4_v3(wmd->map_object->imat, *texco); - break; - } - } -} - -static void waveModifier_do(WaveModifierData *md, - Scene *scene, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) -{ - WaveModifierData *wmd = (WaveModifierData*) md; - MVert *mvert = NULL; - MDeformVert *dvert = NULL; - int defgrp_index; - float ctime = bsystem_time(scene, ob, (float)scene->r.cfra, 0.0); - float minfac = - (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow)); - float lifefac = wmd->height; - float (*tex_co)[3] = NULL; - - if(wmd->flag & MOD_WAVE_NORM && ob->type == OB_MESH) - mvert = dm->getVertArray(dm); - - if(wmd->objectcenter){ - float mat[4][4]; - /* get the control object's location in local coordinates */ - invert_m4_m4(ob->imat, ob->obmat); - mul_m4_m4m4(mat, wmd->objectcenter->obmat, ob->imat); - - wmd->startx = mat[3][0]; - wmd->starty = mat[3][1]; - } - - /* get the index of the deform group */ - defgrp_index = defgroup_name_index(ob, wmd->defgrp_name); - - if(defgrp_index >= 0){ - dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - } - - if(wmd->damp == 0) wmd->damp = 10.0f; - - if(wmd->lifetime != 0.0) { - float x = ctime - wmd->timeoffs; - - if(x > wmd->lifetime) { - lifefac = x - wmd->lifetime; - - if(lifefac > wmd->damp) lifefac = 0.0; - else lifefac = - (float)(wmd->height * (1.0 - sqrt(lifefac / wmd->damp))); - } - } - - if(wmd->texture) { - tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts, - "waveModifier_do tex_co"); - wavemod_get_texture_coords(wmd, ob, dm, vertexCos, tex_co, numVerts); - } - - if(lifefac != 0.0) { - int i; - - for(i = 0; i < numVerts; i++) { - float *co = vertexCos[i]; - float x = co[0] - wmd->startx; - float y = co[1] - wmd->starty; - float amplit= 0.0f; - float dist = 0.0f; - float falloff_fac = 0.0f; - TexResult texres; - MDeformWeight *def_weight = NULL; - - /* get weights */ - if(dvert) { - int j; - for(j = 0; j < dvert[i].totweight; ++j) { - if(dvert[i].dw[j].def_nr == defgrp_index) { - def_weight = &dvert[i].dw[j]; - break; - } - } - - /* if this vert isn't in the vgroup, don't deform it */ - if(!def_weight) continue; - } - - if(wmd->texture) { - texres.nor = NULL; - get_texture_value(wmd->texture, tex_co[i], &texres); - } - - /*get dist*/ - if(wmd->flag & MOD_WAVE_X) { - if(wmd->flag & MOD_WAVE_Y){ - dist = (float)sqrt(x*x + y*y); - } - else{ - dist = fabs(x); - } - } - else if(wmd->flag & MOD_WAVE_Y) { - dist = fabs(y); - } - - falloff_fac = (1.0-(dist / wmd->falloff)); - CLAMP(falloff_fac,0,1); - - if(wmd->flag & MOD_WAVE_X) { - if(wmd->flag & MOD_WAVE_Y) amplit = (float)sqrt(x*x + y*y); - else amplit = x; - } - else if(wmd->flag & MOD_WAVE_Y) - amplit= y; - - /* this way it makes nice circles */ - amplit -= (ctime - wmd->timeoffs) * wmd->speed; - - if(wmd->flag & MOD_WAVE_CYCL) { - amplit = (float)fmod(amplit - wmd->width, 2.0 * wmd->width) - + wmd->width; - } - - /* GAUSSIAN */ - if(amplit > -wmd->width && amplit < wmd->width) { - amplit = amplit * wmd->narrow; - amplit = (float)(1.0 / exp(amplit * amplit) - minfac); - - /*apply texture*/ - if(wmd->texture) - amplit = amplit * texres.tin; - - /*apply weight*/ - if(def_weight) - amplit = amplit * def_weight->weight; - - /*apply falloff*/ - if (wmd->falloff > 0) - amplit = amplit * falloff_fac; - - if(mvert) { - /* move along normals */ - if(wmd->flag & MOD_WAVE_NORM_X) { - co[0] += (lifefac * amplit) * mvert[i].no[0] / 32767.0f; - } - if(wmd->flag & MOD_WAVE_NORM_Y) { - co[1] += (lifefac * amplit) * mvert[i].no[1] / 32767.0f; - } - if(wmd->flag & MOD_WAVE_NORM_Z) { - co[2] += (lifefac * amplit) * mvert[i].no[2] / 32767.0f; - } - } - else { - /* move along local z axis */ - co[2] += lifefac * amplit; - } - } - } - } - - if(wmd->texture) MEM_freeN(tex_co); -} - -static void waveModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm= derivedData; - WaveModifierData *wmd = (WaveModifierData *)md; - - if(wmd->flag & MOD_WAVE_NORM) - dm= get_cddm(md->scene, ob, NULL, dm, vertexCos); - else if(wmd->texture || wmd->defgrp_name[0]) - dm= get_dm(md->scene, ob, NULL, dm, NULL, 0); - - waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -static void waveModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm= derivedData; - WaveModifierData *wmd = (WaveModifierData *)md; - - if(wmd->flag & MOD_WAVE_NORM) - dm= get_cddm(md->scene, ob, editData, dm, vertexCos); - else if(wmd->texture || wmd->defgrp_name[0]) - dm= get_dm(md->scene, ob, editData, dm, NULL, 0); - - waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -/* Armature */ - -static void armatureModifier_initData(ModifierData *md) -{ - ArmatureModifierData *amd = (ArmatureModifierData*) md; - - amd->deformflag = ARM_DEF_ENVELOPE | ARM_DEF_VGROUP; -} - -static void armatureModifier_copyData(ModifierData *md, ModifierData *target) -{ - ArmatureModifierData *amd = (ArmatureModifierData*) md; - ArmatureModifierData *tamd = (ArmatureModifierData*) target; - - tamd->object = amd->object; - tamd->deformflag = amd->deformflag; - strncpy(tamd->defgrp_name, amd->defgrp_name, 32); -} - -static CustomDataMask armatureModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - CustomDataMask dataMask = 0; - - /* ask for vertexgroups */ - dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static int armatureModifier_isDisabled(ModifierData *md, int useRenderParams) -{ - ArmatureModifierData *amd = (ArmatureModifierData*) md; - - return !amd->object; -} - -static void armatureModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - ArmatureModifierData *amd = (ArmatureModifierData*) md; - - walk(userData, ob, &amd->object); -} - -static void armatureModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) -{ - ArmatureModifierData *amd = (ArmatureModifierData*) md; - - if (amd->object) { - DagNode *curNode = dag_get_node(forest, amd->object); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Armature Modifier"); - } -} - -static void armatureModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - ArmatureModifierData *amd = (ArmatureModifierData*) md; - - modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ - - armature_deform_verts(amd->object, ob, derivedData, vertexCos, NULL, - numVerts, amd->deformflag, - (float(*)[3])amd->prevCos, amd->defgrp_name); - /* free cache */ - if(amd->prevCos) { - MEM_freeN(amd->prevCos); - amd->prevCos= NULL; - } -} - -static void armatureModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - ArmatureModifierData *amd = (ArmatureModifierData*) md; - DerivedMesh *dm = derivedData; - - if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); - - armature_deform_verts(amd->object, ob, dm, vertexCos, NULL, numVerts, - amd->deformflag, NULL, amd->defgrp_name); - - if(!derivedData) dm->release(dm); -} - -static void armatureModifier_deformMatricesEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], - float (*defMats)[3][3], int numVerts) -{ - ArmatureModifierData *amd = (ArmatureModifierData*) md; - DerivedMesh *dm = derivedData; - - if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); - - armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts, - amd->deformflag, NULL, amd->defgrp_name); - - if(!derivedData) dm->release(dm); -} - -/* Hook */ - -static void hookModifier_initData(ModifierData *md) -{ - HookModifierData *hmd = (HookModifierData*) md; - - hmd->force= 1.0; -} - -static void hookModifier_copyData(ModifierData *md, ModifierData *target) -{ - HookModifierData *hmd = (HookModifierData*) md; - HookModifierData *thmd = (HookModifierData*) target; - - VECCOPY(thmd->cent, hmd->cent); - thmd->falloff = hmd->falloff; - thmd->force = hmd->force; - thmd->object = hmd->object; - thmd->totindex = hmd->totindex; - thmd->indexar = MEM_dupallocN(hmd->indexar); - memcpy(thmd->parentinv, hmd->parentinv, sizeof(hmd->parentinv)); - strncpy(thmd->name, hmd->name, 32); - strncpy(thmd->subtarget, hmd->subtarget, 32); -} - -static CustomDataMask hookModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - HookModifierData *hmd = (HookModifierData *)md; - CustomDataMask dataMask = 0; - - /* ask for vertexgroups if we need them */ - if(!hmd->indexar && hmd->name[0]) dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static void hookModifier_freeData(ModifierData *md) -{ - HookModifierData *hmd = (HookModifierData*) md; - - if (hmd->indexar) MEM_freeN(hmd->indexar); -} - -static int hookModifier_isDisabled(ModifierData *md, int useRenderParams) -{ - HookModifierData *hmd = (HookModifierData*) md; - - return !hmd->object; -} - -static void hookModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - HookModifierData *hmd = (HookModifierData*) md; - - walk(userData, ob, &hmd->object); -} - -static void hookModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) -{ - HookModifierData *hmd = (HookModifierData*) md; - - if (hmd->object) { - DagNode *curNode = dag_get_node(forest, hmd->object); - - if (hmd->subtarget[0]) - dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, "Hook Modifier"); - else - dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, "Hook Modifier"); - } -} - -static void hookModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - HookModifierData *hmd = (HookModifierData*) md; - bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); - float vec[3], mat[4][4], dmat[4][4]; - int i; - DerivedMesh *dm = derivedData; - - /* get world-space matrix of target, corrected for the space the verts are in */ - if (hmd->subtarget[0] && pchan) { - /* bone target if there's a matching pose-channel */ - mul_m4_m4m4(dmat, pchan->pose_mat, hmd->object->obmat); - } - else { - /* just object target */ - copy_m4_m4(dmat, hmd->object->obmat); - } - invert_m4_m4(ob->imat, ob->obmat); - mul_serie_m4(mat, ob->imat, dmat, hmd->parentinv, - NULL, NULL, NULL, NULL, NULL); - - /* vertex indices? */ - if(hmd->indexar) { - for(i = 0; i < hmd->totindex; i++) { - int index = hmd->indexar[i]; - - /* This should always be true and I don't generally like - * "paranoid" style code like this, but old files can have - * indices that are out of range because old blender did - * not correct them on exit editmode. - zr - */ - if(index < numVerts) { - float *co = vertexCos[index]; - float fac = hmd->force; - - /* if DerivedMesh is present and has original index data, - * use it - */ - if(dm && dm->getVertDataArray(dm, CD_ORIGINDEX)) { - int j; - int orig_index; - for(j = 0; j < numVerts; ++j) { - fac = hmd->force; - orig_index = *(int *)dm->getVertData(dm, j, - CD_ORIGINDEX); - if(orig_index == index) { - co = vertexCos[j]; - if(hmd->falloff != 0.0) { - float len = len_v3v3(co, hmd->cent); - if(len > hmd->falloff) fac = 0.0; - else if(len > 0.0) - fac *= sqrt(1.0 - len / hmd->falloff); - } - - if(fac != 0.0) { - mul_v3_m4v3(vec, mat, co); - interp_v3_v3v3(co, co, vec, fac); - } - } - } - } else { - if(hmd->falloff != 0.0) { - float len = len_v3v3(co, hmd->cent); - if(len > hmd->falloff) fac = 0.0; - else if(len > 0.0) - fac *= sqrt(1.0 - len / hmd->falloff); - } - - if(fac != 0.0) { - mul_v3_m4v3(vec, mat, co); - interp_v3_v3v3(co, co, vec, fac); - } - } - } - } - } - else if(hmd->name[0]) { /* vertex group hook */ - Mesh *me = ob->data; - int use_dverts = 0; - int maxVerts = 0; - int defgrp_index = defgroup_name_index(ob, hmd->name); - - if(dm) { - if(dm->getVertData(dm, 0, CD_MDEFORMVERT)) { - maxVerts = dm->getNumVerts(dm); - use_dverts = 1; - } - } - else if(me->dvert) { - maxVerts = me->totvert; - use_dverts = 1; - } - - if(defgrp_index >= 0 && use_dverts) { - MDeformVert *dvert = me->dvert; - int i, j; - - for(i = 0; i < maxVerts; i++, dvert++) { - if(dm) dvert = dm->getVertData(dm, i, CD_MDEFORMVERT); - for(j = 0; j < dvert->totweight; j++) { - if(dvert->dw[j].def_nr == defgrp_index) { - float fac = hmd->force*dvert->dw[j].weight; - float *co = vertexCos[i]; - - if(hmd->falloff != 0.0) { - float len = len_v3v3(co, hmd->cent); - if(len > hmd->falloff) fac = 0.0; - else if(len > 0.0) - fac *= sqrt(1.0 - len / hmd->falloff); - } - - mul_v3_m4v3(vec, mat, co); - interp_v3_v3v3(co, co, vec, fac); - } - } - } - } - } -} - -static void hookModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm = derivedData; - - if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); - - hookModifier_deformVerts(md, ob, derivedData, vertexCos, numVerts, 0, 0); - - if(!derivedData) dm->release(dm); -} - -/* Softbody */ - -static void softbodyModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - sbObjectStep(md->scene, ob, (float)md->scene->r.cfra, vertexCos, numVerts); -} - -static int softbodyModifier_dependsOnTime(ModifierData *md) -{ - return 1; -} - -/* Solidify */ - - -typedef struct EdgeFaceRef { - int f1; /* init as -1 */ - int f2; -} EdgeFaceRef; - -static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3]) -{ - int i, numVerts, numEdges, numFaces; - MFace *mface, *mf; - MVert *mvert, *mv; - - float (*face_nors)[3]; - float *f_no; - int calc_face_nors= 0; - - numVerts = dm->getNumVerts(dm); - numEdges = dm->getNumEdges(dm); - numFaces = dm->getNumFaces(dm); - mface = dm->getFaceArray(dm); - mvert = dm->getVertArray(dm); - - /* we don't want to overwrite any referenced layers */ - - /* - Dosnt work here! - mv = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT); - cddm->mvert = mv; - */ - - face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL); - if(!face_nors) { - calc_face_nors = 1; - face_nors = CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_CALLOC, NULL, numFaces); - } - - mv = mvert; - mf = mface; - - { - EdgeHash *edge_hash = BLI_edgehash_new(); - EdgeHashIterator *edge_iter; - int edge_ref_count = 0; - int ed_v1, ed_v2; /* use when getting the key */ - EdgeFaceRef *edge_ref_array = MEM_callocN(numEdges * sizeof(EdgeFaceRef), "Edge Connectivity"); - EdgeFaceRef *edge_ref; - float edge_normal[3]; - - /* This function adds an edge hash if its not there, and adds the face index */ -#define NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(EDV1, EDV2); \ - edge_ref = (EdgeFaceRef *)BLI_edgehash_lookup(edge_hash, EDV1, EDV2); \ - if (!edge_ref) { \ - edge_ref = &edge_ref_array[edge_ref_count]; edge_ref_count++; \ - edge_ref->f1=i; \ - edge_ref->f2=-1; \ - BLI_edgehash_insert(edge_hash, EDV1, EDV2, edge_ref); \ - } else { \ - edge_ref->f2=i; \ - } - - for(i = 0; i < numFaces; i++, mf++) { - f_no = face_nors[i]; - - if(mf->v4) { - if(calc_face_nors) - normal_quad_v3(f_no, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); - - NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v1, mf->v2); - NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v2, mf->v3); - NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v3, mf->v4); - NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v4, mf->v1); - } else { - if(calc_face_nors) - normal_tri_v3(f_no, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); - - NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v1, mf->v2); - NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v2, mf->v3); - NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v3, mf->v1); - } - } - - for(edge_iter = BLI_edgehashIterator_new(edge_hash); !BLI_edgehashIterator_isDone(edge_iter); BLI_edgehashIterator_step(edge_iter)) { - /* Get the edge vert indicies, and edge value (the face indicies that use it)*/ - BLI_edgehashIterator_getKey(edge_iter, (int*)&ed_v1, (int*)&ed_v2); - edge_ref = BLI_edgehashIterator_getValue(edge_iter); - - if (edge_ref->f2 != -1) { - /* We have 2 faces using this edge, calculate the edges normal - * using the angle between the 2 faces as a weighting */ - add_v3_v3v3(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]); - normalize_v3(edge_normal); - mul_v3_fl(edge_normal, angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2])); - } else { - /* only one face attached to that edge */ - /* an edge without another attached- the weight on this is - * undefined, M_PI/2 is 90d in radians and that seems good enough */ - VECCOPY(edge_normal, face_nors[edge_ref->f1]) - mul_v3_fl(edge_normal, M_PI/2); - } - add_v3_v3(temp_nors[ed_v1], edge_normal); - add_v3_v3(temp_nors[ed_v2], edge_normal); - } - BLI_edgehashIterator_free(edge_iter); - BLI_edgehash_free(edge_hash, NULL); - MEM_freeN(edge_ref_array); - } - - /* normalize vertex normals and assign */ - for(i = 0; i < numVerts; i++, mv++) { - if(normalize_v3(temp_nors[i]) == 0.0f) { - normal_short_to_float_v3(temp_nors[i], mv->no); - } - } -} - -static void solidifyModifier_initData(ModifierData *md) -{ - SolidifyModifierData *smd = (SolidifyModifierData*) md; - smd->offset = 0.01f; - smd->flag = MOD_SOLIDIFY_RIM; -} - -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; - tsmd->flag = smd->flag; - strcpy(tsmd->defgrp_name, smd->defgrp_name); -} - -static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md, - Object *ob, - DerivedMesh *dm, - int useRenderParams, - int isFinalCalc) -{ - int i; - DerivedMesh *result; - SolidifyModifierData *smd = (SolidifyModifierData*) md; - - MFace *mf, *mface, *orig_mface; - MEdge *ed, *medge, *orig_medge; - MVert *mv, *mvert, *orig_mvert; - - int numVerts = dm->getNumVerts(dm); - int numEdges = dm->getNumEdges(dm); - int numFaces = dm->getNumFaces(dm); - - /* use for edges */ - int *new_vert_arr= NULL; - int newFaces = 0; - - int *new_edge_arr= NULL; - int newEdges = 0; - - int *edge_users= NULL; - char *edge_order= NULL; - - 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); - - if(smd->flag & MOD_SOLIDIFY_RIM) { - EdgeHash *edgehash = BLI_edgehash_new(); - EdgeHashIterator *ehi; - int v1, v2; - int eidx; - - for(i=0, mv=orig_mvert; iflag &= ~ME_VERT_TMP_TAG; - } - - for(i=0, ed=orig_medge; iv1, ed->v2, SET_INT_IN_POINTER(i)); - } - -#define INVALID_UNUSED -1 -#define INVALID_PAIR -2 - -#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) { \ - 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; \ - } \ - - - edge_users= MEM_mallocN(sizeof(int) * numEdges, "solid_mod edges"); - edge_order= MEM_mallocN(sizeof(char) * numEdges, "solid_mod eorder"); - memset(edge_users, INVALID_UNUSED, sizeof(int) * numEdges); - - for(i=0, mf=orig_mface; iv4) { - ADD_EDGE_USER(mf->v1, mf->v2, 0); - ADD_EDGE_USER(mf->v2, mf->v3, 1); - ADD_EDGE_USER(mf->v3, mf->v4, 2); - ADD_EDGE_USER(mf->v4, mf->v1, 3); - } - else { - ADD_EDGE_USER(mf->v1, mf->v2, 0); - ADD_EDGE_USER(mf->v2, mf->v3, 1); - ADD_EDGE_USER(mf->v3, mf->v1, 2); - } - } - -#undef ADD_EDGE_USER -#undef INVALID_UNUSED -#undef INVALID_PAIR - - - new_edge_arr= MEM_callocN(sizeof(int) * numEdges, "solid_mod arr"); - - ehi= BLI_edgehashIterator_new(edgehash); - for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { - int eidx= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); - if(edge_users[eidx] >= 0) { - BLI_edgehashIterator_getKey(ehi, &v1, &v2); - orig_mvert[v1].flag |= ME_VERT_TMP_TAG; - orig_mvert[v2].flag |= ME_VERT_TMP_TAG; - new_edge_arr[newFaces]= eidx; - newFaces++; - } - } - BLI_edgehashIterator_free(ehi); - - - - new_vert_arr= MEM_callocN(sizeof(int) * numVerts, "solid_mod new_varr"); - for(i=0, mv=orig_mvert; iflag & ME_VERT_TMP_TAG) { - new_vert_arr[newEdges] = i; - newEdges++; - - mv->flag &= ~ME_VERT_TMP_TAG; - } - } - - BLI_edgehash_free(edgehash, NULL); - } - - if(smd->flag & MOD_SOLIDIFY_NORMAL_CALC) { - vert_nors= MEM_callocN(sizeof(float) * numVerts * 3, "mod_solid_vno_hq"); - dm_calc_normal(dm, vert_nors); - } - - result = CDDM_from_template(dm, numVerts * 2, (numEdges * 2) + newEdges, (numFaces * 2) + newFaces); - - mface = result->getFaceArray(result); - medge = result->getEdgeArray(result); - mvert = result->getVertArray(result); - - DM_copy_face_data(dm, result, 0, 0, numFaces); - DM_copy_face_data(dm, result, 0, numFaces, numFaces); - - DM_copy_edge_data(dm, result, 0, 0, numEdges); - DM_copy_edge_data(dm, result, 0, numEdges, numEdges); - - DM_copy_vert_data(dm, result, 0, 0, numVerts); - DM_copy_vert_data(dm, result, 0, numVerts, numVerts); - - { - static int corner_indices[4] = {2, 1, 0, 3}; - int is_quad; - - for(i=0, mf=mface+numFaces; iv1 += numVerts; - mf->v2 += numVerts; - mf->v3 += numVerts; - if(mf->v4) - mf->v4 += numVerts; - - /* Flip face normal */ - { - is_quad = mf->v4; - SWAP(int, mf->v1, mf->v3); - DM_swap_face_data(result, i+numFaces, corner_indices); - test_index_face(mf, &result->faceData, numFaces, is_quad ? 4:3); - } - } - } - - for(i=0, ed=medge+numEdges; iv1 += numVerts; - ed->v2 += numVerts; - } - - /* note, copied vertex layers dont have flipped normals yet. do this after applying offset */ - if((smd->flag & MOD_SOLIDIFY_EVEN) == 0) { - /* no even thickness, very simple */ - 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); - } - } - - 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 */ - float (*face_nors)[3]; - int face_nors_calc= 0; - - /* same as EM_solidify() in editmesh_lib.c */ - float *vert_angles= MEM_callocN(sizeof(float) * numVerts * 2, "mod_solid_pair"); /* 2 in 1 */ - float *vert_accum= vert_angles + numVerts; - float face_angles[4]; - int i, j, vidx; - - face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL); - if(!face_nors) { - face_nors = CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_CALLOC, NULL, dm->numFaceData); - face_nors_calc= 1; - } - - if(vert_nors==NULL) { - vert_nors= MEM_mallocN(sizeof(float) * numVerts * 3, "mod_solid_vno"); - for(i=0, mv=mvert; ino); - } - } - - for(i=0, mf=mface; iv4) - normal_quad_v3(face_nors[i], mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); - else - normal_tri_v3(face_nors[i] , mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co); - } - - if(mf->v4) { - angle_quad_v3(face_angles, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); - j= 3; - } - else { - angle_tri_v3(face_angles, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co); - j= 2; - } - - for(; j>=0; j--) { - vidx = *(&mf->v1 + j); - vert_accum[vidx] += face_angles[j]; - vert_angles[vidx]+= shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * face_angles[j]; - } - } - - /* 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], 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])); - } - } - } - - MEM_freeN(vert_angles); - } - - if(vert_nors) - MEM_freeN(vert_nors); - - /* flip vertex normals for copied verts */ - mv= mvert + numVerts; - for(i=0; ino[0]= -mv->no[0]; - mv->no[1]= -mv->no[1]; - mv->no[2]= -mv->no[2]; - } - - if(smd->flag & MOD_SOLIDIFY_RIM) { - - - /* bugger, need to re-calculate the normals for the new edge faces. - * This could be done in many ways, but probably the quickest way is to calculate the average normals for side faces only. - * Then blend them with the normals of the edge verts. - * - * at the moment its easiest to allocate an entire array for every vertex, even though we only need edge verts - campbell - */ - -#define SOLIDIFY_SIDE_NORMALS - -#ifdef SOLIDIFY_SIDE_NORMALS - /* annoying to allocate these since we only need the edge verts, */ - float (*edge_vert_nos)[3]= MEM_callocN(sizeof(float) * numVerts * 3, "solidify_edge_nos"); - float nor[3]; -#endif - - const unsigned char crease_rim= smd->crease_rim * 255.0f; - const unsigned char crease_outer= smd->crease_outer * 255.0f; - const unsigned char crease_inner= smd->crease_inner * 255.0f; - - const int edge_indices[4][4] = { - {1, 0, 0, 1}, - {2, 1, 1, 2}, - {3, 2, 2, 3}, - {0, 3, 3, 0}}; - - /* add faces & edges */ - ed= medge + (numEdges * 2); - for(i=0; iv1= new_vert_arr[i]; - ed->v2= new_vert_arr[i] + numVerts; - ed->flag |= ME_EDGEDRAW; - - if(crease_rim) - ed->crease= crease_rim; - } - - /* faces */ - mf= mface + (numFaces * 2); - for(i=0; i= numFaces) { - fidx -= numFaces; - flip= 1; - } - else { - flip= 0; - } - - ed= medge + eidx; - - /* copy most of the face settings */ - DM_copy_face_data(dm, result, fidx, (numFaces * 2) + i, 1); - - if(flip) { - DM_swap_face_data(result, (numFaces * 2) + i, edge_indices[edge_order[eidx]]); - - mf->v1= ed->v1; - mf->v2= ed->v2; - mf->v3= ed->v2 + numVerts; - mf->v4= ed->v1 + numVerts; - } - else { - DM_swap_face_data(result, (numFaces * 2) + i, edge_indices[edge_order[eidx]]); - - mf->v1= ed->v2; - mf->v2= ed->v1; - mf->v3= ed->v1 + numVerts; - mf->v4= ed->v2 + numVerts; - } - - if(crease_outer) - ed->crease= crease_outer; - - if(crease_inner) { - medge[numEdges + eidx].crease= crease_inner; - } - -#ifdef SOLIDIFY_SIDE_NORMALS - normal_quad_v3(nor, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); - - add_v3_v3(edge_vert_nos[ed->v1], nor); - add_v3_v3(edge_vert_nos[ed->v2], nor); -#endif - } - -#ifdef SOLIDIFY_SIDE_NORMALS - ed= medge + (numEdges * 2); - for(i=0; iv1]); - - for(j=0; j<2; j++) { /* loop over both verts of the edge */ - nor_short= mvert[*(&ed->v1 + j)].no; - normal_short_to_float_v3(nor, nor_short); - add_v3_v3(nor, nor_cpy); - normalize_v3(nor); - normal_float_to_short_v3(nor_short, nor); - } - } - - MEM_freeN(edge_vert_nos); -#endif - - MEM_freeN(new_vert_arr); - MEM_freeN(new_edge_arr); - MEM_freeN(edge_users); - MEM_freeN(edge_order); - } - - return result; -} - -#undef SOLIDIFY_SIDE_NORMALS - -static DerivedMesh *solidifyModifier_applyModifierEM(ModifierData *md, - Object *ob, - EditMesh *editData, - DerivedMesh *derivedData) -{ - return solidifyModifier_applyModifier(md, ob, derivedData, 0, 1); -} - -/* Screw */ - -/* Screw modifier: revolves the edges about an axis -*/ - -/* used for gathering edge connectivity */ -typedef struct ScrewVertConnect { - float dist; /* distance from the center axis */ - float co[3]; /* loaction relative to the transformed axis */ - float no[3]; /* calc normal of the vertex */ - int v[2]; /* 2 verts on either side of this one */ - MEdge *e[2]; /* edges on either side, a bit of a waste since each edge ref's 2 edges */ - char flag; -} ScrewVertConnect; - -typedef struct ScrewVertIter { - ScrewVertConnect * v_array; - ScrewVertConnect * v_poin; - int v; - int v_other; - MEdge *e; -} ScrewVertIter; - -#define ScrewVertIter_INIT(iter, array, v_init, dir)\ - iter.v_array = array;\ - iter.v = v_init;\ - if (v_init>=0) {\ - iter.v_poin = &array[v_init];\ - iter.v_other = iter.v_poin->v[dir];\ - if (dir)\ - iter.e = iter.v_poin->e[0];\ - else\ - iter.e = iter.v_poin->e[1];\ - } else {\ - iter.v_poin= NULL;\ - iter.e= NULL;\ - } - - -#define ScrewVertIter_NEXT(iter)\ - if (iter.v_poin->v[0] == iter.v_other) {\ - iter.v_other= iter.v;\ - iter.v= iter.v_poin->v[1];\ - } else if (iter.v_poin->v[1] == iter.v_other) {\ - iter.v_other= iter.v;\ - iter.v= iter.v_poin->v[0];\ - }\ - if (iter.v >=0) {\ - iter.v_poin= &iter.v_array[iter.v];\ - if ( iter.v_poin->e[0] != iter.e ) iter.e= iter.v_poin->e[0];\ - else iter.e= iter.v_poin->e[1];\ - } else {\ - iter.e= NULL;\ - iter.v_poin= NULL;\ - } - -static void screwModifier_initData(ModifierData *md) -{ - ScrewModifierData *ltmd= (ScrewModifierData*) md; - ltmd->ob_axis= NULL; - ltmd->angle= M_PI * 2.0; - ltmd->axis= 2; - ltmd->flag= 0; - ltmd->steps= 16; - ltmd->render_steps= 16; - ltmd->iter= 1; -} - -static void screwModifier_copyData(ModifierData *md, ModifierData *target) -{ - ScrewModifierData *sltmd= (ScrewModifierData*) md; - ScrewModifierData *tltmd= (ScrewModifierData*) target; - - tltmd->ob_axis= sltmd->ob_axis; - tltmd->angle= sltmd->angle; - tltmd->axis= sltmd->axis; - tltmd->flag= sltmd->flag; - tltmd->steps= sltmd->steps; - tltmd->render_steps= sltmd->render_steps; - tltmd->screw_ofs= sltmd->screw_ofs; - tltmd->iter= sltmd->iter; -} - -static DerivedMesh *screwModifier_applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm= derivedData; - DerivedMesh *result; - ScrewModifierData *ltmd= (ScrewModifierData*) md; - - int *origindex; - int mface_index=0; - int i, j; - int i1,i2; - int steps= ltmd->steps; - int maxVerts=0, maxEdges=0, maxFaces=0; - int totvert= dm->getNumVerts(dm); - int totedge= dm->getNumEdges(dm); - - char axis_char, close; - float angle= ltmd->angle; - float screw_ofs= ltmd->screw_ofs; - float axis_vec[3]= {0.0f, 0.0f, 0.0f}; - float tmp_vec1[3], tmp_vec2[3]; - float mat3[3][3]; - float mtx_tx[4][4]; /* transform the coords by an object relative to this objects transformation */ - float mtx_tx_inv[4][4]; /* inverted */ - float mtx_tmp_a[4][4]; - - int vc_tot_linked= 0; - short other_axis_1, other_axis_2; - float *tmpf1, *tmpf2; - - MFace *mface_new, *mf_new; - MEdge *medge_orig, *med_orig, *med_new, *med_new_firstloop, *medge_new; - MVert *mvert_new, *mvert_orig, *mv_orig, *mv_new, *mv_new_base; - - ScrewVertConnect *vc, *vc_tmp, *vert_connect= NULL; - - float mat[4][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, 0.0f, 1.0f}}; - - /* dont do anything? */ - if (!totvert) - return CDDM_from_template(dm, 0, 0, 0); - - steps= useRenderParams ? ltmd->render_steps : ltmd->steps; - - switch(ltmd->axis) { - case 0: - other_axis_1=1; - other_axis_2=2; - break; - case 1: - other_axis_1=0; - other_axis_2=2; - break; - case 2: - other_axis_1=0; - other_axis_2=1; - break; - } - - axis_vec[ltmd->axis]= 1.0f; - - if (ltmd->ob_axis) { - float mtx3_tx[3][3]; - /* calc the matrix relative to the axis object */ - invert_m4_m4(mtx_tmp_a, ob->obmat); - copy_m4_m4(mtx_tx_inv, ltmd->ob_axis->obmat); - mul_m4_m4m4(mtx_tx, mtx_tx_inv, mtx_tmp_a); - - copy_m3_m4(mtx3_tx, mtx_tx); - - /* calc the axis vec */ - mul_m3_v3(mtx3_tx, axis_vec); - normalize_v3(axis_vec); - - /* screw */ - if(ltmd->flag & MOD_SCREW_OBJECT_OFFSET) { - /* find the offset along this axis relative to this objects matrix */ - float totlen = len_v3(mtx_tx[3]); - - if(totlen != 0.0f) { - float zero[3]={0.0f, 0.0f, 0.0f}; - float cp[3]; - screw_ofs= closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec); - } - else { - screw_ofs= 0.0f; - } - } - - /* angle */ - -#if 0 // cant incluide this, not pradictable enough, though quite fun,. - if(ltmd->flag & MOD_SCREW_OBJECT_ANGLE) { - - - float vec[3] = {0,1,0}; - float cross1[3]; - float cross2[3]; - cross_v3_v3v3(cross1, vec, axis_vec); - - mul_v3_m3v3(cross2, mtx3_tx, cross1); - { - float c1[3]; - float c2[3]; - float axis_tmp[3]; - - cross_v3_v3v3(c1, cross2, axis_vec); - cross_v3_v3v3(c2, axis_vec, c1); - - - angle= angle_v3v3(cross1, c2); - - cross_v3_v3v3(axis_tmp, cross1, c2); - normalize_v3(axis_tmp); - - if(len_v3v3(axis_tmp, axis_vec) > 1.0f) - angle= -angle; - - } - } -#endif - } - else { - /* exis char is used by i_rotate*/ - axis_char= 'X' + ltmd->axis; - - /* useful to be able to use the axis vec in some cases still */ - zero_v3(axis_vec); - axis_vec[ltmd->axis]= 1.0f; - } - - /* apply the multiplier */ - angle *= ltmd->iter; - screw_ofs *= ltmd->iter; - - /* multiplying the steps is a bit tricky, this works best */ - steps = ((steps + 1) * ltmd->iter) - (ltmd->iter - 1); - - /* will the screw be closed? - * Note! smaller then FLT_EPSILON*100 gives problems with float precission so its never closed. */ - if (fabs(screw_ofs) <= (FLT_EPSILON*100) && fabs(fabs(angle) - (M_PI * 2)) <= (FLT_EPSILON*100)) { - close= 1; - steps--; - if(steps < 2) steps= 2; - - maxVerts = totvert * steps; /* -1 because we're joining back up */ - maxEdges = (totvert * steps) + /* these are the edges between new verts */ - (totedge * steps); /* -1 because vert edges join */ - maxFaces = totedge * steps; - - screw_ofs= 0.0f; - } - else { - close= 0; - if(steps < 2) steps= 2; - - maxVerts = totvert * steps; /* -1 because we're joining back up */ - maxEdges = (totvert * (steps-1)) + /* these are the edges between new verts */ - (totedge * steps); /* -1 because vert edges join */ - maxFaces = totedge * (steps-1); - } - - result= CDDM_from_template(dm, maxVerts, maxEdges, maxFaces); - - /* copy verts from mesh */ - mvert_orig = dm->getVertArray(dm); - medge_orig = dm->getEdgeArray(dm); - - mvert_new = result->getVertArray(result); - mface_new = result->getFaceArray(result); - medge_new = result->getEdgeArray(result); - - origindex= result->getFaceDataArray(result, CD_ORIGINDEX); - - /* Set the locations of the first set of verts */ - - mv_new= mvert_new; - mv_orig= mvert_orig; - - /* Copy the first set of edges */ - med_orig= medge_orig; - med_new= medge_new; - for (i=0; i < totedge; i++, med_orig++, med_new++) { - med_new->v1= med_orig->v1; - med_new->v2= med_orig->v2; - med_new->crease= med_orig->crease; - med_new->flag= med_orig->flag & ~ME_LOOSEEDGE; - } - - if(ltmd->flag & MOD_SCREW_NORMAL_CALC) { - /* - * Normal Calculation (for face flipping) - * Sort edge verts for correct face flipping - * NOT REALLY NEEDED but face flipping is nice. - * - * */ - - - /* Notice! - * - * Since we are only ordering the edges here it can avoid mallocing the - * extra space by abusing the vert array berfore its filled with new verts. - * The new array for vert_connect must be at least sizeof(ScrewVertConnect) * totvert - * and the size of our resulting meshes array is sizeof(MVert) * totvert * 3 - * so its safe to use the second 2 thrids of MVert the array for vert_connect, - * just make sure ScrewVertConnect struct is no more then twice as big as MVert, - * at the moment there is no chance of that being a problem, - * unless MVert becomes half its current size. - * - * once the edges are ordered, vert_connect is not needed and it can be used for verts - * - * This makes the modifier faster with one less alloc. - */ - - vert_connect= MEM_mallocN(sizeof(ScrewVertConnect) * totvert, "ScrewVertConnect"); - //vert_connect= (ScrewVertConnect *) &medge_new[totvert]; /* skip the first slice of verts */ - vc= vert_connect; - - /* Copy Vert Locations */ - /* - We can do this in a later loop - only do here if no normal calc */ - if (!totedge) { - for (i=0; i < totvert; i++, mv_orig++, mv_new++) { - copy_v3_v3(mv_new->co, mv_orig->co); - normalize_v3_v3(vc->no, mv_new->co); /* no edges- this is realy a dummy normal */ - } - } - else { - /*printf("\n\n\n\n\nStarting Modifier\n");*/ - /* set edge users */ - med_new= medge_new; - mv_new= mvert_new; - - if (ltmd->ob_axis) { - /*mtx_tx is initialized early on */ - for (i=0; i < totvert; i++, mv_new++, mv_orig++, vc++) { - vc->co[0]= mv_new->co[0]= mv_orig->co[0]; - vc->co[1]= mv_new->co[1]= mv_orig->co[1]; - vc->co[2]= mv_new->co[2]= mv_orig->co[2]; - - vc->flag= 0; - vc->e[0]= vc->e[1]= NULL; - vc->v[0]= vc->v[1]= -1; - - mul_m4_v3(mtx_tx, vc->co); - /* length in 2d, dont sqrt because this is only for comparison */ - vc->dist = vc->co[other_axis_1]*vc->co[other_axis_1] + - vc->co[other_axis_2]*vc->co[other_axis_2]; - - /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ - } - } - else { - for (i=0; i < totvert; i++, mv_new++, mv_orig++, vc++) { - vc->co[0]= mv_new->co[0]= mv_orig->co[0]; - vc->co[1]= mv_new->co[1]= mv_orig->co[1]; - vc->co[2]= mv_new->co[2]= mv_orig->co[2]; - - vc->flag= 0; - vc->e[0]= vc->e[1]= NULL; - vc->v[0]= vc->v[1]= -1; - - /* length in 2d, dont sqrt because this is only for comparison */ - vc->dist = vc->co[other_axis_1]*vc->co[other_axis_1] + - vc->co[other_axis_2]*vc->co[other_axis_2]; - - /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ - } - } - - /* this loop builds connectivity info for verts */ - for (i=0; iv1]; - - if (vc->v[0]==-1) { /* unused */ - vc->v[0]= med_new->v2; - vc->e[0]= med_new; - } - else if (vc->v[1]==-1) { - vc->v[1]= med_new->v2; - vc->e[1]= med_new; - } - else { - vc->v[0]= vc->v[1]= -2; /* erro value - dont use, 3 edges on vert */ - } - - vc= &vert_connect[med_new->v2]; - - /* same as above but swap v1/2 */ - if (vc->v[0]==-1) { /* unused */ - vc->v[0]= med_new->v1; - vc->e[0]= med_new; - } - else if (vc->v[1]==-1) { - vc->v[1]= med_new->v1; - vc->e[1]= med_new; - } - else { - vc->v[0]= vc->v[1]= -2; /* erro value - dont use, 3 edges on vert */ - } - } - - /* find the first vert */ - vc= vert_connect; - for (i=0; i < totvert; i++, vc++) { - int VBEST=-1, ed_loop_closed=0; /* vert and vert new */ - int ed_loop_flip; - float fl= -1.0f; - ScrewVertIter lt_iter; - - /* Now do search for connected verts, order all edges and flip them - * so resulting faces are flipped the right way */ - vc_tot_linked= 0; /* count the number of linked verts for this loop */ - if (vc->flag==0) { - /*printf("Loop on connected vert: %i\n", i);*/ - - for(j=0; j<2; j++) { - /*printf("\tSide: %i\n", j);*/ - ScrewVertIter_INIT(lt_iter, vert_connect, i, j); - if (j==1) { - ScrewVertIter_NEXT(lt_iter); - } - while (lt_iter.v_poin) { - /*printf("\t\tVERT: %i\n", lt_iter.v);*/ - if (lt_iter.v_poin->flag) { - /*printf("\t\t\tBreaking Found end\n");*/ - //endpoints[0]= endpoints[1]= -1; - ed_loop_closed= 1; /* circle */ - break; - } - lt_iter.v_poin->flag= 1; - vc_tot_linked++; - /*printf("Testing 2 floats %f : %f\n", fl, lt_iter.v_poin->dist);*/ - if (fl <= lt_iter.v_poin->dist) { - fl= lt_iter.v_poin->dist; - VBEST= lt_iter.v; - /*printf("\t\t\tVERT BEST: %i\n", VBEST);*/ - } - ScrewVertIter_NEXT(lt_iter); - if (!lt_iter.v_poin) { - /*printf("\t\t\tFound End Also Num %i\n", j);*/ - /*endpoints[j]= lt_iter.v_other;*/ /* other is still valid */ - break; - } - } - } - - /* now we have a collection of used edges. flip their edges the right way*/ - /*if (VBEST !=-1) - */ - - /*printf("Done Looking - vc_tot_linked: %i\n", vc_tot_linked);*/ - - if (vc_tot_linked>1) { - float vf_1, vf_2, vf_best; - - vc_tmp= &vert_connect[VBEST]; - - tmpf1= vert_connect[vc_tmp->v[0]].co; - tmpf2= vert_connect[vc_tmp->v[1]].co; - - - /* edge connects on each side! */ - if ((vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) { - /*printf("Verts on each side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ - /* find out which is higher */ - - vf_1= tmpf1[ltmd->axis]; - vf_2= tmpf2[ltmd->axis]; - vf_best= vc_tmp->co[ltmd->axis]; - - if (vf_1 < vf_best && vf_best < vf_2) { - ed_loop_flip= 0; - } - else if (vf_1 > vf_best && vf_best > vf_2) { - ed_loop_flip= 1; - } - else { - /* 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); - normalize_v3(tmp_vec2); - - if (tmp_vec1[ltmd->axis] < tmp_vec2[ltmd->axis]) { - ed_loop_flip= 1; - } - else { - ed_loop_flip= 0; - } - } - } - else if (vc_tmp->v[0] >= 0) { /*vertex only connected on 1 side */ - /*printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ - if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */ - ed_loop_flip= 1; - } - else { /* best is below or even... in even case we cant know whet to do. */ - ed_loop_flip= 0; - } - - }/* else { - printf("No Connected ___\n"); - }*/ - - /*printf("flip direction %i\n", ed_loop_flip);*/ - - - /* switch the flip option if set */ - if (ltmd->flag & MOD_SCREW_NORMAL_FLIP) - ed_loop_flip= !ed_loop_flip; - - if (angle < 0.0f) - ed_loop_flip= !ed_loop_flip; - - /* if its closed, we only need 1 loop */ - for(j=ed_loop_closed; j<2; j++) { - /*printf("Ordering Side J %i\n", j);*/ - - ScrewVertIter_INIT(lt_iter, vert_connect, VBEST, j); - /*printf("\n\nStarting - Loop\n");*/ - lt_iter.v_poin->flag= 1; /* so a non loop will traverse the other side */ - - - /* If this is the vert off the best vert and - * the best vert has 2 edges connected too it - * then swap the flip direction */ - if (j==1 && (vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) - ed_loop_flip= !ed_loop_flip; - - while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) { - /*printf("\tOrdering Vert V %i\n", lt_iter.v);*/ - - lt_iter.v_poin->flag= 2; - if (lt_iter.e) { - if (lt_iter.v == lt_iter.e->v1) { - if (ed_loop_flip==0) { - /*printf("\t\t\tFlipping 0\n");*/ - SWAP(int, lt_iter.e->v1, lt_iter.e->v2); - }/* else { - printf("\t\t\tFlipping Not 0\n"); - }*/ - } - else if (lt_iter.v == lt_iter.e->v2) { - if (ed_loop_flip==1) { - /*printf("\t\t\tFlipping 1\n");*/ - SWAP(int, lt_iter.e->v1, lt_iter.e->v2); - }/* else { - printf("\t\t\tFlipping Not 1\n"); - }*/ - }/* else { - printf("\t\tIncorrect edge topology"); - }*/ - }/* else { - printf("\t\tNo Edge at this point\n"); - }*/ - ScrewVertIter_NEXT(lt_iter); - } - } - } - } - - /* *VERTEX NORMALS* - * we know the surrounding edges are ordered correctly now - * so its safe to create vertex normals. - * - * calculate vertex normals that can be propodated on lathing - * use edge connectivity work this out */ - if (vc->v[0]>=0) { - if (vc->v[1]>=0) { - /* 2 edges connedted */ - /* make 2 connecting vert locations relative to the middle vert */ - sub_v3_v3v3(tmp_vec1, mvert_new[vc->v[0]].co, mvert_new[i].co); - sub_v3_v3v3(tmp_vec2, mvert_new[vc->v[1]].co, mvert_new[i].co); - /* normalize so both edges have the same influence, no matter their length */ - normalize_v3(tmp_vec1); - normalize_v3(tmp_vec2); - - /* vc_no_tmp1 - this line is the average direction of both connecting edges - * - * Use the edge order to make the subtraction, flip the normal the right way - * edge should be there but check just in case... */ - if (vc->e && vc->e[0]->v1 == i) { - sub_v3_v3v3(tmp_vec1, tmp_vec1, tmp_vec2); - } - else { - sub_v3_v3v3(tmp_vec1, tmp_vec2, tmp_vec1); - } - } - else { - /* only 1 edge connected - same as above except - * dont need to average edge direction */ - if (vc->e && vc->e[0]->v2 == i) { - sub_v3_v3v3(tmp_vec1, mvert_new[i].co, mvert_new[vc->v[0]].co); - } - else { - sub_v3_v3v3(tmp_vec1, mvert_new[vc->v[0]].co, mvert_new[i].co); - } - } - - /* vc_no_tmp2 - is a line 90d from the pivot to the vec - * This is used so the resulting normal points directly away from the middle */ - cross_v3_v3v3(tmp_vec2, axis_vec, vc->co); - - /* edge average vector and right angle to the pivot make the normal */ - cross_v3_v3v3(vc->no, tmp_vec1, tmp_vec2); - - } - else { - copy_v3_v3(vc->no, vc->co); - } - - /* we wont be looping on this data again so copy normals here */ - if (angle < 0.0f) - negate_v3(vc->no); - - normalize_v3(vc->no); - normal_float_to_short_v3(mvert_new[i].no, vc->no); - - /* Done with normals */ - } - } - } - else { - - if (ltmd->flag & MOD_SCREW_NORMAL_FLIP) { - mv_orig= mvert_orig; - mv_new= mvert_new + (totvert-1); - - for (i=0; i < totvert; i++, mv_new--, mv_orig++) { - copy_v3_v3(mv_new->co, mv_orig->co); - } - } - else { - mv_orig= mvert_orig; - mv_new= mvert_new; - - for (i=0; i < totvert; i++, mv_new++, mv_orig++) { - copy_v3_v3(mv_new->co, mv_orig->co); - } - } - } - /* done with edge connectivity based normal flipping */ - - - /* Add Faces */ - for (i=1; i < steps; i++) { - float step_angle; - float no_tx[3]; - /* Rotation Matrix */ - if (close) step_angle= (angle / steps) * i; - else step_angle= (angle / (steps-1)) * i; - - if (ltmd->ob_axis) { - axis_angle_to_mat3(mat3, axis_vec, step_angle); - copy_m4_m3(mat, mat3); - } - else { - unit_m4(mat); - rotate_m4(mat, axis_char, step_angle); - copy_m3_m4(mat3, mat); - } - - if(screw_ofs) - madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)i / (float)(steps-1))); - - mv_new_base= mvert_new; - mv_new= &mvert_new[totvert*i]; /* advance to the next slice */ - - for (j=0; jno, no_tx); - } - - /* set location */ - copy_v3_v3(mv_new->co, mv_new_base->co); - - /* only need to set these if using non cleared memory */ - /*mv_new->mat_nr= mv_new->flag= 0;*/ - - if (ltmd->ob_axis) { - sub_v3_v3(mv_new->co, mtx_tx[3]); - - mul_m4_v3(mat, mv_new->co); - - add_v3_v3(mv_new->co, mtx_tx[3]); - } - else { - mul_m4_v3(mat, mv_new->co); - } - - /* add the new edge */ - med_new->v1= j+(i*totvert); - med_new->v2= med_new->v1 - totvert; - med_new->flag= ME_EDGEDRAW|ME_EDGERENDER; - med_new++; - } - } - - /* we can avoid if using vert alloc trick */ - if(vert_connect) { - MEM_freeN(vert_connect); - vert_connect= NULL; - } - - if (close) { - /* last loop of edges, previous loop dosnt account for the last set of edges */ - for (i=0; iv1= i; - med_new->v2= i+((steps-1)*totvert); - med_new->flag= ME_EDGEDRAW|ME_EDGERENDER; - med_new++; - } - } - - mf_new= mface_new; - med_new_firstloop= medge_new; - - for (i=0; i < totedge; i++, med_new_firstloop++) { - /* for each edge, make a cylinder of quads */ - i1= med_new_firstloop->v1; - i2= med_new_firstloop->v2; - - for (j=0; j < steps-1; j++) { - - /* new face */ - mf_new->v1= i1; - mf_new->v2= i2; - mf_new->v3= i2 + totvert; - mf_new->v4= i1 + totvert; - - if( !mf_new->v3 || !mf_new->v4 ) { - SWAP(int, mf_new->v1, mf_new->v3); - SWAP(int, mf_new->v2, mf_new->v4); - } - mf_new->flag= ME_SMOOTH; - origindex[mface_index]= ORIGINDEX_NONE; - mf_new++; - mface_index++; - - /* new vertical edge */ - if (j) { /* The first set is alredy dome */ - med_new->v1= i1; - med_new->v2= i2; - med_new->flag= med_new_firstloop->flag; - med_new->crease= med_new_firstloop->crease; - med_new++; - } - i1 += totvert; - i2 += totvert; - } - - /* close the loop*/ - if (close) { - mf_new->v1= i1; - mf_new->v2= i2; - mf_new->v3= med_new_firstloop->v2; - mf_new->v4= med_new_firstloop->v1; - - if( !mf_new->v3 || !mf_new->v4 ) { - SWAP(int, mf_new->v1, mf_new->v3); - SWAP(int, mf_new->v2, mf_new->v4); - } - mf_new->flag= ME_SMOOTH; - origindex[mface_index]= ORIGINDEX_NONE; - mf_new++; - mface_index++; - } - - /* new vertical edge */ - med_new->v1= i1; - med_new->v2= i2; - med_new->flag= med_new_firstloop->flag & ~ME_LOOSEEDGE; - med_new->crease= med_new_firstloop->crease; - med_new++; - } - - if((ltmd->flag & MOD_SCREW_NORMAL_CALC)==0) { - CDDM_calc_normals(result); - } - - return result; -} - - -static void screwModifier_updateDepgraph( - ModifierData *md, DagForest *forest, - Scene *scene, Object *ob, DagNode *obNode) -{ - ScrewModifierData *ltmd= (ScrewModifierData*) md; - - if(ltmd->ob_axis) { - DagNode *curNode= dag_get_node(forest, ltmd->ob_axis); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, - "Screw Modifier"); - } -} - -static void screwModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - ScrewModifierData *ltmd= (ScrewModifierData*) md; - - walk(userData, ob, <md->ob_axis); -} - -/* This dosnt work with material*/ -static DerivedMesh *screwModifier_applyModifierEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData) -{ - return screwModifier_applyModifier(md, ob, derivedData, 0, 1); -} - -static int screwModifier_dependsOnTime(ModifierData *md) -{ - return 0; -} - - -/* Smoke */ - -static void smokeModifier_initData(ModifierData *md) -{ - SmokeModifierData *smd = (SmokeModifierData*) md; - - smd->domain = NULL; - smd->flow = NULL; - smd->coll = NULL; - smd->type = 0; - smd->time = -1; -} - -static void smokeModifier_freeData(ModifierData *md) -{ - SmokeModifierData *smd = (SmokeModifierData*) md; - - smokeModifier_free (smd); -} - -static void smokeModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - SmokeModifierData *smd = (SmokeModifierData*) md; - DerivedMesh *dm = dm= get_cddm(md->scene, ob, NULL, derivedData, vertexCos); - - smokeModifier_do(smd, md->scene, ob, dm, useRenderParams, isFinalCalc); - - if(dm != derivedData) - dm->release(dm); -} - -static int smokeModifier_dependsOnTime(ModifierData *md) -{ - return 1; -} - -static void smokeModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) -{ - /*SmokeModifierData *smd = (SmokeModifierData *) md; - if(smd && (smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) - { - if(smd->domain->fluid_group) - { - GroupObject *go = NULL; - - for(go = smd->domain->fluid_group->gobject.first; go; go = go->next) - { - if(go->ob) - { - SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - - // check for initialized smoke object - if(smd2 && (smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) - { - DagNode *curNode = dag_get_node(forest, go->ob); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Smoke Flow"); - } - } - } - } - } - */ -} - -/* Cloth */ - -static void clothModifier_initData(ModifierData *md) -{ - ClothModifierData *clmd = (ClothModifierData*) md; - - clmd->sim_parms = MEM_callocN(sizeof(ClothSimSettings), "cloth sim parms"); - clmd->coll_parms = MEM_callocN(sizeof(ClothCollSettings), "cloth coll parms"); - clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches); - - /* check for alloc failing */ - if(!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache) - return; - - cloth_init (clmd); -} - -static DerivedMesh *clothModifier_applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, int useRenderParams, int isFinalCalc) -{ - ClothModifierData *clmd = (ClothModifierData*) md; - DerivedMesh *result=NULL; - - /* check for alloc failing */ - if(!clmd->sim_parms || !clmd->coll_parms) - { - clothModifier_initData(md); - - if(!clmd->sim_parms || !clmd->coll_parms) - return derivedData; - } - - result = clothModifier_do(clmd, md->scene, ob, derivedData, useRenderParams, isFinalCalc); - - if(result) - { - CDDM_calc_normals(result); - return result; - } - return derivedData; -} - -static void clothModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) -{ - ClothModifierData *clmd = (ClothModifierData*) md; - - Base *base; - - if(clmd) - { - for(base = scene->base.first; base; base= base->next) - { - Object *ob1= base->object; - if(ob1 != ob) - { - CollisionModifierData *coll_clmd = (CollisionModifierData *)modifiers_findByType(ob1, eModifierType_Collision); - if(coll_clmd) - { - DagNode *curNode = dag_get_node(forest, ob1); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Cloth Collision"); - } - } - } - } -} - -static CustomDataMask clothModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - CustomDataMask dataMask = 0; - ClothModifierData *clmd = (ClothModifierData*)md; - - if(cloth_uses_vgroup(clmd)) - dataMask |= (1 << CD_MDEFORMVERT); - - if(clmd->sim_parms->shapekey_rest != 0) - dataMask |= (1 << CD_CLOTH_ORCO); - - return dataMask; -} - -static void clothModifier_copyData(ModifierData *md, ModifierData *target) -{ - ClothModifierData *clmd = (ClothModifierData*) md; - ClothModifierData *tclmd = (ClothModifierData*) target; - - if(tclmd->sim_parms) - MEM_freeN(tclmd->sim_parms); - if(tclmd->coll_parms) - MEM_freeN(tclmd->coll_parms); - - BKE_ptcache_free_list(&tclmd->ptcaches); - tclmd->point_cache = NULL; - - tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms); - if(clmd->sim_parms->effector_weights) - tclmd->sim_parms->effector_weights = MEM_dupallocN(clmd->sim_parms->effector_weights); - tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms); - tclmd->point_cache = BKE_ptcache_copy_list(&tclmd->ptcaches, &clmd->ptcaches); - tclmd->clothObject = NULL; -} - -static int clothModifier_dependsOnTime(ModifierData *md) -{ - return 1; -} - -static void clothModifier_freeData(ModifierData *md) -{ - ClothModifierData *clmd = (ClothModifierData*) md; - - if (clmd) - { - if(G.rt > 0) - printf("clothModifier_freeData\n"); - - cloth_free_modifier_extern (clmd); - - if(clmd->sim_parms) { - if(clmd->sim_parms->effector_weights) - MEM_freeN(clmd->sim_parms->effector_weights); - MEM_freeN(clmd->sim_parms); - } - if(clmd->coll_parms) - MEM_freeN(clmd->coll_parms); - - BKE_ptcache_free_list(&clmd->ptcaches); - clmd->point_cache = NULL; - } -} - -/* Collision */ - -static void collisionModifier_initData(ModifierData *md) -{ - CollisionModifierData *collmd = (CollisionModifierData*) md; - - collmd->x = NULL; - collmd->xnew = NULL; - collmd->current_x = NULL; - collmd->current_xnew = NULL; - collmd->current_v = NULL; - collmd->time = -1000; - collmd->numverts = 0; - collmd->bvhtree = NULL; -} - -static void collisionModifier_freeData(ModifierData *md) -{ - CollisionModifierData *collmd = (CollisionModifierData*) md; - - if (collmd) - { - if(collmd->bvhtree) - BLI_bvhtree_free(collmd->bvhtree); - if(collmd->x) - MEM_freeN(collmd->x); - if(collmd->xnew) - MEM_freeN(collmd->xnew); - if(collmd->current_x) - MEM_freeN(collmd->current_x); - if(collmd->current_xnew) - MEM_freeN(collmd->current_xnew); - if(collmd->current_v) - MEM_freeN(collmd->current_v); - if(collmd->mfaces) - MEM_freeN(collmd->mfaces); - - collmd->x = NULL; - collmd->xnew = NULL; - collmd->current_x = NULL; - collmd->current_xnew = NULL; - collmd->current_v = NULL; - collmd->time = -1000; - collmd->numverts = 0; - collmd->bvhtree = NULL; - collmd->mfaces = NULL; - } -} - -static int collisionModifier_dependsOnTime(ModifierData *md) -{ - return 1; -} - -static void collisionModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - CollisionModifierData *collmd = (CollisionModifierData*) md; - DerivedMesh *dm = NULL; - float current_time = 0; - unsigned int numverts = 0, i = 0; - MVert *tempVert = NULL; - - /* if possible use/create DerivedMesh */ - if(derivedData) dm = CDDM_copy(derivedData); - else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob); - - if(!ob->pd) - { - printf("collisionModifier_deformVerts: Should not happen!\n"); - return; - } - - if(dm) - { - CDDM_apply_vert_coords(dm, vertexCos); - CDDM_calc_normals(dm); - - current_time = bsystem_time (md->scene, ob, ( float ) md->scene->r.cfra, 0.0 ); - - if(G.rt > 0) - printf("current_time %f, collmd->time %f\n", current_time, collmd->time); - - numverts = dm->getNumVerts ( dm ); - - if((current_time > collmd->time)|| (BKE_ptcache_get_continue_physics())) - { - // check if mesh has changed - if(collmd->x && (numverts != collmd->numverts)) - collisionModifier_freeData((ModifierData *)collmd); - - if(collmd->time == -1000) // first time - { - collmd->x = dm->dupVertArray(dm); // frame start position - - for ( i = 0; i < numverts; i++ ) - { - // we save global positions - mul_m4_v3( ob->obmat, collmd->x[i].co ); - } - - collmd->xnew = MEM_dupallocN(collmd->x); // frame end position - collmd->current_x = MEM_dupallocN(collmd->x); // inter-frame - collmd->current_xnew = MEM_dupallocN(collmd->x); // inter-frame - collmd->current_v = MEM_dupallocN(collmd->x); // inter-frame - - collmd->numverts = numverts; - - collmd->mfaces = dm->dupFaceArray(dm); - collmd->numfaces = dm->getNumFaces(dm); - - // create bounding box hierarchy - collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sboft); - - collmd->time = current_time; - } - else if(numverts == collmd->numverts) - { - // put positions to old positions - tempVert = collmd->x; - collmd->x = collmd->xnew; - collmd->xnew = tempVert; - - memcpy(collmd->xnew, dm->getVertArray(dm), numverts*sizeof(MVert)); - - for ( i = 0; i < numverts; i++ ) - { - // we save global positions - mul_m4_v3( ob->obmat, collmd->xnew[i].co ); - } - - memcpy(collmd->current_xnew, collmd->x, numverts*sizeof(MVert)); - memcpy(collmd->current_x, collmd->x, numverts*sizeof(MVert)); - - /* check if GUI setting has changed for bvh */ - if(collmd->bvhtree) - { - if(ob->pd->pdef_sboft != BLI_bvhtree_getepsilon(collmd->bvhtree)) - { - BLI_bvhtree_free(collmd->bvhtree); - collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sboft); - } - - } - - /* happens on file load (ONLY when i decomment changes in readfile.c) */ - if(!collmd->bvhtree) - { - collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sboft); - } - else - { - // recalc static bounding boxes - bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 ); - } - - collmd->time = current_time; - } - else if(numverts != collmd->numverts) - { - collisionModifier_freeData((ModifierData *)collmd); - } - - } - else if(current_time < collmd->time) - { - collisionModifier_freeData((ModifierData *)collmd); - } - else - { - if(numverts != collmd->numverts) - { - collisionModifier_freeData((ModifierData *)collmd); - } - } - } - - if(dm) - dm->release(dm); -} - - - -/* Surface */ - -static void surfaceModifier_initData(ModifierData *md) -{ - SurfaceModifierData *surmd = (SurfaceModifierData*) md; - - surmd->bvhtree = NULL; -} - -static void surfaceModifier_freeData(ModifierData *md) -{ - SurfaceModifierData *surmd = (SurfaceModifierData*) md; - - if (surmd) - { - if(surmd->bvhtree) { - free_bvhtree_from_mesh(surmd->bvhtree); - MEM_freeN(surmd->bvhtree); - } - - if(surmd->dm) - surmd->dm->release(surmd->dm); - - if(surmd->x) - MEM_freeN(surmd->x); - - if(surmd->v) - MEM_freeN(surmd->v); - - surmd->bvhtree = NULL; - surmd->dm = NULL; - } -} - -static int surfaceModifier_dependsOnTime(ModifierData *md) -{ - return 1; -} - -static void surfaceModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - SurfaceModifierData *surmd = (SurfaceModifierData*) md; - unsigned int numverts = 0, i = 0; - - if(surmd->dm) - surmd->dm->release(surmd->dm); - - /* if possible use/create DerivedMesh */ - if(derivedData) surmd->dm = CDDM_copy(derivedData); - else surmd->dm = get_dm(md->scene, ob, NULL, NULL, NULL, 0); - - if(!ob->pd) - { - printf("surfaceModifier_deformVerts: Should not happen!\n"); - return; - } - - if(surmd->dm) - { - int init = 0; - float *vec; - MVert *x, *v; - - CDDM_apply_vert_coords(surmd->dm, vertexCos); - CDDM_calc_normals(surmd->dm); - - numverts = surmd->dm->getNumVerts ( surmd->dm ); - - if(numverts != surmd->numverts || surmd->x == NULL || surmd->v == NULL || md->scene->r.cfra != surmd->cfra+1) { - if(surmd->x) { - MEM_freeN(surmd->x); - surmd->x = NULL; - } - if(surmd->v) { - MEM_freeN(surmd->v); - surmd->v = NULL; - } - - surmd->x = MEM_callocN(numverts * sizeof(MVert), "MVert"); - surmd->v = MEM_callocN(numverts * sizeof(MVert), "MVert"); - - surmd->numverts = numverts; - - init = 1; - } - - /* convert to global coordinates and calculate velocity */ - for(i = 0, x = surmd->x, v = surmd->v; idm, i)->co; - mul_m4_v3(ob->obmat, vec); - - if(init) - v->co[0] = v->co[1] = v->co[2] = 0.0f; - else - sub_v3_v3v3(v->co, vec, x->co); - - copy_v3_v3(x->co, vec); - } - - surmd->cfra = md->scene->r.cfra; - - if(surmd->bvhtree) - free_bvhtree_from_mesh(surmd->bvhtree); - else - surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh"); - - if(surmd->dm->getNumFaces(surmd->dm)) - bvhtree_from_mesh_faces(surmd->bvhtree, surmd->dm, 0.0, 2, 6); - else - bvhtree_from_mesh_edges(surmd->bvhtree, surmd->dm, 0.0, 2, 6); - } -} - - -/* Boolean */ - -static void booleanModifier_copyData(ModifierData *md, ModifierData *target) -{ - BooleanModifierData *bmd = (BooleanModifierData*) md; - BooleanModifierData *tbmd = (BooleanModifierData*) target; - - tbmd->object = bmd->object; - tbmd->operation = bmd->operation; -} - -static int booleanModifier_isDisabled(ModifierData *md, int useRenderParams) -{ - BooleanModifierData *bmd = (BooleanModifierData*) md; - - return !bmd->object; -} - -static void booleanModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - BooleanModifierData *bmd = (BooleanModifierData*) md; - - walk(userData, ob, &bmd->object); -} - -static void booleanModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) -{ - BooleanModifierData *bmd = (BooleanModifierData*) md; - - if(bmd->object) { - DagNode *curNode = dag_get_node(forest, bmd->object); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Boolean Modifier"); - } -} - -static DerivedMesh *booleanModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - BooleanModifierData *bmd = (BooleanModifierData*) md; - DerivedMesh *dm = bmd->object->derivedFinal; - - /* we do a quick sanity check */ - if(dm && (derivedData->getNumFaces(derivedData) > 3) - && bmd->object && dm->getNumFaces(dm) > 3) { - DerivedMesh *result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob, - 1 + bmd->operation); - - /* if new mesh returned, return it; otherwise there was - * an error, so delete the modifier object */ - if(result) - return result; - else - modifier_setError(md, "Can't execute boolean operation."); - } - - return derivedData; -} - -static CustomDataMask booleanModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - CustomDataMask dataMask = (1 << CD_MTFACE) + (1 << CD_MEDGE); - - dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -/* Particles */ -static void particleSystemModifier_initData(ModifierData *md) -{ - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - psmd->psys= 0; - psmd->dm=0; - psmd->totdmvert= psmd->totdmedge= psmd->totdmface= 0; -} -static void particleSystemModifier_freeData(ModifierData *md) -{ - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - - if(psmd->dm){ - psmd->dm->needsFree = 1; - psmd->dm->release(psmd->dm); - psmd->dm=0; - } - - /* ED_object_modifier_remove may have freed this first before calling - * modifier_free (which calls this function) */ - if(psmd->psys) - psmd->psys->flag |= PSYS_DELETE; -} -static void particleSystemModifier_copyData(ModifierData *md, ModifierData *target) -{ - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - ParticleSystemModifierData *tpsmd= (ParticleSystemModifierData*) target; - - tpsmd->dm = 0; - tpsmd->totdmvert = tpsmd->totdmedge = tpsmd->totdmface = 0; - //tpsmd->facepa = 0; - tpsmd->flag = psmd->flag; - /* need to keep this to recognise a bit later in copy_object */ - tpsmd->psys = psmd->psys; -} - -static CustomDataMask particleSystemModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - CustomDataMask dataMask = 0; - Material *ma; - MTex *mtex; - int i; - - if(!psmd->psys->part) - return 0; - - ma= give_current_material(ob, psmd->psys->part->omat); - if(ma) { - for(i=0; imtex[i]; - if(mtex && (ma->septex & (1<pmapto && (mtex->texco & TEXCO_UV)) - dataMask |= (1 << CD_MTFACE); - } - } - - if(psmd->psys->part->tanfac!=0.0) - dataMask |= (1 << CD_MTFACE); - - /* ask for vertexgroups if we need them */ - for(i=0; ipsys->vgroup[i]){ - dataMask |= (1 << CD_MDEFORMVERT); - break; - } - } - - /* particles only need this if they are after a non deform modifier, and - * the modifier stack will only create them in that case. */ - dataMask |= CD_MASK_ORIGSPACE; - - dataMask |= CD_MASK_ORCO; - - return dataMask; -} - -/* saves the current emitter state for a particle system and calculates particles */ -static void particleSystemModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm = derivedData; - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - ParticleSystem * psys=0; - int needsFree=0; - - if(ob->particlesystem.first) - psys=psmd->psys; - else - return; - - if(!psys_check_enabled(ob, psys)) - return; - - if(dm==0) { - dm= get_dm(md->scene, ob, NULL, NULL, vertexCos, 1); - - if(!dm) - return; - - needsFree= 1; - } - - /* clear old dm */ - if(psmd->dm){ - psmd->dm->needsFree = 1; - psmd->dm->release(psmd->dm); - } - - /* make new dm */ - psmd->dm=CDDM_copy(dm); - CDDM_apply_vert_coords(psmd->dm, vertexCos); - CDDM_calc_normals(psmd->dm); - - if(needsFree){ - dm->needsFree = 1; - dm->release(dm); - } - - /* protect dm */ - psmd->dm->needsFree = 0; - - /* report change in mesh structure */ - if(psmd->dm->getNumVerts(psmd->dm)!=psmd->totdmvert || - psmd->dm->getNumEdges(psmd->dm)!=psmd->totdmedge || - psmd->dm->getNumFaces(psmd->dm)!=psmd->totdmface){ - /* in file read dm hasn't really changed but just wasn't saved in file */ - - psys->recalc |= PSYS_RECALC_RESET; - psmd->flag |= eParticleSystemFlag_DM_changed; - - psmd->totdmvert= psmd->dm->getNumVerts(psmd->dm); - psmd->totdmedge= psmd->dm->getNumEdges(psmd->dm); - psmd->totdmface= psmd->dm->getNumFaces(psmd->dm); - } - - if(psys) { - psmd->flag &= ~eParticleSystemFlag_psys_updated; - particle_system_update(md->scene, ob, psys); - psmd->flag |= eParticleSystemFlag_psys_updated; - psmd->flag &= ~eParticleSystemFlag_DM_changed; - } -} - -/* disabled particles in editmode for now, until support for proper derivedmesh - * updates is coded */ -#if 0 -static void particleSystemModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm = derivedData; - - if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); - - particleSystemModifier_deformVerts(md, ob, dm, vertexCos, numVerts); - - if(!derivedData) dm->release(dm); -} -#endif - -/* Particle Instance */ -static void particleInstanceModifier_initData(ModifierData *md) -{ - ParticleInstanceModifierData *pimd= (ParticleInstanceModifierData*) md; - - pimd->flag = eParticleInstanceFlag_Parents|eParticleInstanceFlag_Unborn| - eParticleInstanceFlag_Alive|eParticleInstanceFlag_Dead; - pimd->psys = 1; - pimd->position = 1.0f; - pimd->axis = 2; - -} -static void particleInstanceModifier_copyData(ModifierData *md, ModifierData *target) -{ - ParticleInstanceModifierData *pimd= (ParticleInstanceModifierData*) md; - ParticleInstanceModifierData *tpimd= (ParticleInstanceModifierData*) target; - - tpimd->ob = pimd->ob; - tpimd->psys = pimd->psys; - tpimd->flag = pimd->flag; - tpimd->axis = pimd->axis; - tpimd->position = pimd->position; - tpimd->random_position = pimd->random_position; -} - -static int particleInstanceModifier_dependsOnTime(ModifierData *md) -{ - return 0; -} -static void particleInstanceModifier_updateDepgraph(ModifierData *md, DagForest *forest, - Scene *scene,Object *ob, DagNode *obNode) -{ - ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData*) md; - - if (pimd->ob) { - DagNode *curNode = dag_get_node(forest, pimd->ob); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, - "Particle Instance Modifier"); - } -} - -static void particleInstanceModifier_foreachObjectLink(ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) -{ - ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData*) md; - - walk(userData, ob, &pimd->ob); -} - -static DerivedMesh * particleInstanceModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm = derivedData, *result; - ParticleInstanceModifierData *pimd= (ParticleInstanceModifierData*) md; - ParticleSimulationData sim; - ParticleSystem * psys=0; - ParticleData *pa=0, *pars=0; - MFace *mface, *orig_mface; - MVert *mvert, *orig_mvert; - int i,totvert, totpart=0, totface, maxvert, maxface, first_particle=0; - short track=ob->trackflag%3, trackneg, axis = pimd->axis; - float max_co=0.0, min_co=0.0, temp_co[3], cross[3]; - float *size=NULL; - - trackneg=((ob->trackflag>2)?1:0); - - if(pimd->ob==ob){ - pimd->ob=0; - return derivedData; - } - - if(pimd->ob){ - psys = BLI_findlink(&pimd->ob->particlesystem,pimd->psys-1); - if(psys==0 || psys->totpart==0) - return derivedData; - } - else return derivedData; - - if(pimd->flag & eParticleInstanceFlag_Parents) - totpart+=psys->totpart; - if(pimd->flag & eParticleInstanceFlag_Children){ - if(totpart==0) - first_particle=psys->totpart; - totpart+=psys->totchild; - } - - if(totpart==0) - return derivedData; - - sim.scene = md->scene; - sim.ob = pimd->ob; - sim.psys = psys; - sim.psmd = psys_get_modifier(pimd->ob, psys); - - if(pimd->flag & eParticleInstanceFlag_UseSize) { - int p; - float *si; - si = size = MEM_callocN(totpart * sizeof(float), "particle size array"); - - if(pimd->flag & eParticleInstanceFlag_Parents) { - for(p=0, pa= psys->particles; ptotpart; p++, pa++, si++) - *si = pa->size; - } - - if(pimd->flag & eParticleInstanceFlag_Children) { - ChildParticle *cpa = psys->child; - - for(p=0; ptotchild; p++, cpa++, si++) { - *si = psys_get_child_size(psys, cpa, 0.0f, NULL); - } - } - } - - pars=psys->particles; - - totvert=dm->getNumVerts(dm); - totface=dm->getNumFaces(dm); - - maxvert=totvert*totpart; - maxface=totface*totpart; - - psys->lattice=psys_get_lattice(&sim); - - if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED){ - - float min_r[3], max_r[3]; - INIT_MINMAX(min_r, max_r); - dm->getMinMax(dm, min_r, max_r); - min_co=min_r[track]; - max_co=max_r[track]; - } - - result = CDDM_from_template(dm, maxvert,dm->getNumEdges(dm)*totpart,maxface); - - mvert=result->getVertArray(result); - orig_mvert=dm->getVertArray(dm); - - for(i=0; ico); - mv->co[axis]=temp_co[track]; - mv->co[(axis+1)%3]=temp_co[(track+1)%3]; - mv->co[(axis+2)%3]=temp_co[(track+2)%3]; - - if((psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && pimd->flag & eParticleInstanceFlag_Path){ - float ran = 0.0f; - if(pimd->random_position != 0.0f) { - BLI_srandom(psys->seed + (i/totvert)%totpart); - ran = pimd->random_position * BLI_frand(); - } - - if(pimd->flag & eParticleInstanceFlag_KeepShape) { - state.time = pimd->position * (1.0f - ran); - } - else { - state.time=(mv->co[axis]-min_co)/(max_co-min_co) * pimd->position * (1.0f - ran); - - if(trackneg) - state.time=1.0f-state.time; - - mv->co[axis] = 0.0; - } - - psys_get_particle_on_path(&sim, first_particle + i/totvert, &state,1); - - normalize_v3(state.vel); - - /* TODO: incremental rotations somehow */ - if(state.vel[axis] < -0.9999 || state.vel[axis] > 0.9999) { - state.rot[0] = 1; - state.rot[1] = state.rot[2] = state.rot[3] = 0.0f; - } - else { - float temp[3] = {0.0f,0.0f,0.0f}; - temp[axis] = 1.0f; - - cross_v3_v3v3(cross, temp, state.vel); - - /* state.vel[axis] is the only component surviving from a dot product with the axis */ - axis_angle_to_quat(state.rot,cross,saacos(state.vel[axis])); - } - - } - else{ - state.time=-1.0; - psys_get_particle_state(&sim, first_particle + i/totvert, &state,1); - } - - mul_qt_v3(state.rot,mv->co); - if(pimd->flag & eParticleInstanceFlag_UseSize) - mul_v3_fl(mv->co, size[i/totvert]); - VECADD(mv->co,mv->co,state.co); - } - - mface=result->getFaceArray(result); - orig_mface=dm->getFaceArray(dm); - - for(i=0; iflag & eParticleInstanceFlag_Parents){ - if(i/totface>=psys->totpart){ - if(psys->part->childtype==PART_CHILD_PARTICLES) - pa=psys->particles+(psys->child+i/totface-psys->totpart)->parent; - else - pa=0; - } - else - pa=pars+i/totface; - } - else{ - if(psys->part->childtype==PART_CHILD_PARTICLES) - pa=psys->particles+(psys->child+i/totface)->parent; - else - pa=0; - } - - if(pa){ - if(pa->alive==PARS_UNBORN && (pimd->flag&eParticleInstanceFlag_Unborn)==0) continue; - if(pa->alive==PARS_ALIVE && (pimd->flag&eParticleInstanceFlag_Alive)==0) continue; - if(pa->alive==PARS_DEAD && (pimd->flag&eParticleInstanceFlag_Dead)==0) continue; - } - - inMF = orig_mface + i%totface; - DM_copy_face_data(dm, result, i%totface, i, 1); - *mf = *inMF; - - mf->v1+=(i/totface)*totvert; - mf->v2+=(i/totface)*totvert; - mf->v3+=(i/totface)*totvert; - if(mf->v4) - mf->v4+=(i/totface)*totvert; - } - - CDDM_calc_edges(result); - CDDM_calc_normals(result); - - if(psys->lattice){ - end_latt_deform(psys->lattice); - psys->lattice= NULL; - } - - if(size) - MEM_freeN(size); - - return result; -} -static DerivedMesh *particleInstanceModifier_applyModifierEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData) -{ - return particleInstanceModifier_applyModifier(md, ob, derivedData, 0, 1); -} - -/* Explode */ -static void explodeModifier_initData(ModifierData *md) -{ - ExplodeModifierData *emd= (ExplodeModifierData*) md; - - emd->facepa=0; - emd->flag |= eExplodeFlag_Unborn+eExplodeFlag_Alive+eExplodeFlag_Dead; -} -static void explodeModifier_freeData(ModifierData *md) -{ - ExplodeModifierData *emd= (ExplodeModifierData*) md; - - if(emd->facepa) MEM_freeN(emd->facepa); -} -static void explodeModifier_copyData(ModifierData *md, ModifierData *target) -{ - ExplodeModifierData *emd= (ExplodeModifierData*) md; - ExplodeModifierData *temd= (ExplodeModifierData*) target; - - temd->facepa = 0; - temd->flag = emd->flag; - temd->protect = emd->protect; - temd->vgroup = emd->vgroup; -} -static int explodeModifier_dependsOnTime(ModifierData *md) -{ - return 1; -} -static CustomDataMask explodeModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - ExplodeModifierData *emd= (ExplodeModifierData*) md; - CustomDataMask dataMask = 0; - - if(emd->vgroup) - dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static void explodeModifier_createFacepa(ExplodeModifierData *emd, - ParticleSystemModifierData *psmd, - Object *ob, DerivedMesh *dm) -{ - ParticleSystem *psys=psmd->psys; - MFace *fa=0, *mface=0; - MVert *mvert = 0; - ParticleData *pa; - KDTree *tree; - float center[3], co[3]; - int *facepa=0,*vertpa=0,totvert=0,totface=0,totpart=0; - int i,p,v1,v2,v3,v4=0; - - mvert = dm->getVertArray(dm); - mface = dm->getFaceArray(dm); - totface= dm->getNumFaces(dm); - totvert= dm->getNumVerts(dm); - totpart= psmd->psys->totpart; - - BLI_srandom(psys->seed); - - if(emd->facepa) - MEM_freeN(emd->facepa); - - facepa = emd->facepa = MEM_callocN(sizeof(int)*totface, "explode_facepa"); - - vertpa = MEM_callocN(sizeof(int)*totvert, "explode_vertpa"); - - /* initialize all faces & verts to no particle */ - for(i=0; ivgroup){ - MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - float val; - if(dvert){ - int defgrp_index= emd->vgroup-1; - for(i=0; iprotect)*val + emd->protect*0.5f; - if(val < defvert_find_weight(dvert, defgrp_index)) - vertpa[i] = -1; - } - } - } - - /* make tree of emitter locations */ - tree=BLI_kdtree_new(totpart); - for(p=0,pa=psys->particles; pdm,psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,0,0); - BLI_kdtree_insert(tree, p, co, NULL); - } - BLI_kdtree_balance(tree); - - /* set face-particle-indexes to nearest particle to face center */ - for(i=0,fa=mface; iv1].co,mvert[fa->v2].co); - add_v3_v3v3(center,center,mvert[fa->v3].co); - if(fa->v4){ - add_v3_v3v3(center,center,mvert[fa->v4].co); - mul_v3_fl(center,0.25); - } - else - mul_v3_fl(center,0.3333f); - - p= BLI_kdtree_find_nearest(tree,center,NULL,NULL); - - v1=vertpa[fa->v1]; - v2=vertpa[fa->v2]; - v3=vertpa[fa->v3]; - if(fa->v4) - v4=vertpa[fa->v4]; - - if(v1>=0 && v2>=0 && v3>=0 && (fa->v4==0 || v4>=0)) - facepa[i]=p; - - if(v1>=0) vertpa[fa->v1]=p; - if(v2>=0) vertpa[fa->v2]=p; - if(v3>=0) vertpa[fa->v3]=p; - if(fa->v4 && v4>=0) vertpa[fa->v4]=p; - } - - if(vertpa) MEM_freeN(vertpa); - BLI_kdtree_free(tree); -} - -static int edgesplit_get(EdgeHash *edgehash, int v1, int v2) -{ - return GET_INT_FROM_POINTER(BLI_edgehash_lookup(edgehash, v1, v2)); -} - -static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, DerivedMesh *dm){ - DerivedMesh *splitdm; - MFace *mf=0,*df1=0,*df2=0,*df3=0; - MFace *mface=CDDM_get_faces(dm); - MVert *dupve, *mv; - EdgeHash *edgehash; - EdgeHashIterator *ehi; - int totvert=dm->getNumVerts(dm); - int totface=dm->getNumFaces(dm); - - int *facesplit = MEM_callocN(sizeof(int)*totface,"explode_facesplit"); - int *vertpa = MEM_callocN(sizeof(int)*totvert,"explode_vertpa2"); - int *facepa = emd->facepa; - int *fs, totesplit=0,totfsplit=0,totin=0,curdupvert=0,curdupface=0,curdupin=0; - int i,j,v1,v2,v3,v4,esplit; - - edgehash= BLI_edgehash_new(); - - /* recreate vertpa from facepa calculation */ - for (i=0,mf=mface; iv1]=facepa[i]; - vertpa[mf->v2]=facepa[i]; - vertpa[mf->v3]=facepa[i]; - if(mf->v4) - vertpa[mf->v4]=facepa[i]; - } - - /* mark edges for splitting and how to split faces */ - for (i=0,mf=mface,fs=facesplit; iv4){ - v1=vertpa[mf->v1]; - v2=vertpa[mf->v2]; - v3=vertpa[mf->v3]; - v4=vertpa[mf->v4]; - - if(v1!=v2){ - BLI_edgehash_insert(edgehash, mf->v1, mf->v2, NULL); - (*fs)++; - } - - if(v2!=v3){ - BLI_edgehash_insert(edgehash, mf->v2, mf->v3, NULL); - (*fs)++; - } - - if(v3!=v4){ - BLI_edgehash_insert(edgehash, mf->v3, mf->v4, NULL); - (*fs)++; - } - - if(v1!=v4){ - BLI_edgehash_insert(edgehash, mf->v1, mf->v4, NULL); - (*fs)++; - } - - if(*fs==2){ - if((v1==v2 && v3==v4) || (v1==v4 && v2==v3)) - *fs=1; - else if(v1!=v2){ - if(v1!=v4) - BLI_edgehash_insert(edgehash, mf->v2, mf->v3, NULL); - else - BLI_edgehash_insert(edgehash, mf->v3, mf->v4, NULL); - } - else{ - if(v1!=v4) - BLI_edgehash_insert(edgehash, mf->v1, mf->v2, NULL); - else - BLI_edgehash_insert(edgehash, mf->v1, mf->v4, NULL); - } - } - } - } - - /* count splits & reindex */ - ehi= BLI_edgehashIterator_new(edgehash); - totesplit=totvert; - for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { - BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(totesplit)); - totesplit++; - } - BLI_edgehashIterator_free(ehi); - - /* count new faces due to splitting */ - for(i=0,fs=facesplit; igetFaceData(dm,i,CD_MFACE);//CDDM_get_face(dm,i); - - if(vertpa[mf->v1]!=vertpa[mf->v2] && vertpa[mf->v2]!=vertpa[mf->v3]) - totin++; - } - } - - splitdm= CDDM_from_template(dm, totesplit+totin, dm->getNumEdges(dm),totface+totfsplit); - - /* copy new faces & verts (is it really this painful with custom data??) */ - for(i=0; igetVert(dm, i, &source); - dest = CDDM_get_vert(splitdm, i); - - DM_copy_vert_data(dm, splitdm, i, i, 1); - *dest = source; - } - for(i=0; igetFace(dm, i, &source); - dest = CDDM_get_face(splitdm, i); - - DM_copy_face_data(dm, splitdm, i, i, 1); - *dest = source; - } - - /* override original facepa (original pointer is saved in caller function) */ - facepa= MEM_callocN(sizeof(int)*(totface+totfsplit),"explode_facepa"); - memcpy(facepa,emd->facepa,totface*sizeof(int)); - emd->facepa=facepa; - - /* create new verts */ - curdupvert=totvert; - ehi= BLI_edgehashIterator_new(edgehash); - for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { - BLI_edgehashIterator_getKey(ehi, &i, &j); - esplit= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); - mv=CDDM_get_vert(splitdm,j); - dupve=CDDM_get_vert(splitdm,esplit); - - DM_copy_vert_data(splitdm,splitdm,j,esplit,1); - - *dupve=*mv; - - mv=CDDM_get_vert(splitdm,i); - - VECADD(dupve->co,dupve->co,mv->co); - mul_v3_fl(dupve->co,0.5); - } - BLI_edgehashIterator_free(ehi); - - /* create new faces */ - curdupface=totface; - curdupin=totesplit; - for(i=0,fs=facesplit; iv1]; - v2=vertpa[mf->v2]; - v3=vertpa[mf->v3]; - v4=vertpa[mf->v4]; - /* ouch! creating new faces & remapping them to new verts is no fun */ - if(*fs==1){ - df1=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df1=*mf; - curdupface++; - - if(v1==v2){ - df1->v1=edgesplit_get(edgehash, mf->v1, mf->v4); - df1->v2=edgesplit_get(edgehash, mf->v2, mf->v3); - mf->v3=df1->v2; - mf->v4=df1->v1; - } - else{ - df1->v1=edgesplit_get(edgehash, mf->v1, mf->v2); - df1->v4=edgesplit_get(edgehash, mf->v3, mf->v4); - mf->v2=df1->v1; - mf->v3=df1->v4; - } - - facepa[i]=v1; - facepa[curdupface-1]=v3; - - test_index_face(df1, &splitdm->faceData, curdupface, (df1->v4 ? 4 : 3)); - } - if(*fs==2){ - df1=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df1=*mf; - curdupface++; - - df2=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df2=*mf; - curdupface++; - - if(v1!=v2){ - if(v1!=v4){ - df1->v1=edgesplit_get(edgehash, mf->v1, mf->v4); - df1->v2=edgesplit_get(edgehash, mf->v1, mf->v2); - df2->v1=df1->v3=mf->v2; - df2->v3=df1->v4=mf->v4; - df2->v2=mf->v3; - - mf->v2=df1->v2; - mf->v3=df1->v1; - - df2->v4=mf->v4=0; - - facepa[i]=v1; - } - else{ - df1->v2=edgesplit_get(edgehash, mf->v1, mf->v2); - df1->v3=edgesplit_get(edgehash, mf->v2, mf->v3); - df1->v4=mf->v3; - df2->v2=mf->v3; - df2->v3=mf->v4; - - mf->v1=df1->v2; - mf->v3=df1->v3; - - df2->v4=mf->v4=0; - - facepa[i]=v2; - } - facepa[curdupface-1]=facepa[curdupface-2]=v3; - } - else{ - if(v1!=v4){ - df1->v3=edgesplit_get(edgehash, mf->v3, mf->v4); - df1->v4=edgesplit_get(edgehash, mf->v1, mf->v4); - df1->v2=mf->v3; - - mf->v1=df1->v4; - mf->v2=df1->v3; - mf->v3=mf->v4; - - df2->v4=mf->v4=0; - - facepa[i]=v4; - } - else{ - df1->v3=edgesplit_get(edgehash, mf->v2, mf->v3); - df1->v4=edgesplit_get(edgehash, mf->v3, mf->v4); - df1->v1=mf->v4; - df1->v2=mf->v2; - df2->v3=mf->v4; - - mf->v1=df1->v4; - mf->v2=df1->v3; - - df2->v4=mf->v4=0; - - facepa[i]=v3; - } - - facepa[curdupface-1]=facepa[curdupface-2]=v1; - } - - test_index_face(df1, &splitdm->faceData, curdupface-2, (df1->v4 ? 4 : 3)); - test_index_face(df1, &splitdm->faceData, curdupface-1, (df1->v4 ? 4 : 3)); - } - else if(*fs==3){ - df1=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df1=*mf; - curdupface++; - - df2=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df2=*mf; - curdupface++; - - df3=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df3=*mf; - curdupface++; - - if(v1==v2){ - df2->v1=df1->v1=edgesplit_get(edgehash, mf->v1, mf->v4); - df3->v1=df1->v2=edgesplit_get(edgehash, mf->v2, mf->v3); - df3->v3=df2->v2=df1->v3=edgesplit_get(edgehash, mf->v3, mf->v4); - df3->v2=mf->v3; - df2->v3=mf->v4; - df1->v4=df2->v4=df3->v4=0; - - mf->v3=df1->v2; - mf->v4=df1->v1; - - facepa[i]=facepa[curdupface-3]=v1; - facepa[curdupface-1]=v3; - facepa[curdupface-2]=v4; - } - else if(v2==v3){ - df3->v1=df2->v3=df1->v1=edgesplit_get(edgehash, mf->v1, mf->v4); - df2->v2=df1->v2=edgesplit_get(edgehash, mf->v1, mf->v2); - df3->v2=df1->v3=edgesplit_get(edgehash, mf->v3, mf->v4); - - df3->v3=mf->v4; - df2->v1=mf->v1; - df1->v4=df2->v4=df3->v4=0; - - mf->v1=df1->v2; - mf->v4=df1->v3; - - facepa[i]=facepa[curdupface-3]=v2; - facepa[curdupface-1]=v4; - facepa[curdupface-2]=v1; - } - else if(v3==v4){ - df3->v2=df2->v1=df1->v1=edgesplit_get(edgehash, mf->v1, mf->v2); - df2->v3=df1->v2=edgesplit_get(edgehash, mf->v2, mf->v3); - df3->v3=df1->v3=edgesplit_get(edgehash, mf->v1, mf->v4); - - df3->v1=mf->v1; - df2->v2=mf->v2; - df1->v4=df2->v4=df3->v4=0; - - mf->v1=df1->v3; - mf->v2=df1->v2; - - facepa[i]=facepa[curdupface-3]=v3; - facepa[curdupface-1]=v1; - facepa[curdupface-2]=v2; - } - else{ - df3->v1=df1->v1=edgesplit_get(edgehash, mf->v1, mf->v2); - df3->v3=df2->v1=df1->v2=edgesplit_get(edgehash, mf->v2, mf->v3); - df2->v3=df1->v3=edgesplit_get(edgehash, mf->v3, mf->v4); - - df3->v2=mf->v2; - df2->v2=mf->v3; - df1->v4=df2->v4=df3->v4=0; - - mf->v2=df1->v1; - mf->v3=df1->v3; - - facepa[i]=facepa[curdupface-3]=v1; - facepa[curdupface-1]=v2; - facepa[curdupface-2]=v3; - } - - test_index_face(df1, &splitdm->faceData, curdupface-3, (df1->v4 ? 4 : 3)); - test_index_face(df1, &splitdm->faceData, curdupface-2, (df1->v4 ? 4 : 3)); - test_index_face(df1, &splitdm->faceData, curdupface-1, (df1->v4 ? 4 : 3)); - } - else if(*fs==4){ - if(v1!=v2 && v2!=v3){ - - /* set new vert to face center */ - mv=CDDM_get_vert(splitdm,mf->v1); - dupve=CDDM_get_vert(splitdm,curdupin); - DM_copy_vert_data(splitdm,splitdm,mf->v1,curdupin,1); - *dupve=*mv; - - mv=CDDM_get_vert(splitdm,mf->v2); - VECADD(dupve->co,dupve->co,mv->co); - mv=CDDM_get_vert(splitdm,mf->v3); - VECADD(dupve->co,dupve->co,mv->co); - mv=CDDM_get_vert(splitdm,mf->v4); - VECADD(dupve->co,dupve->co,mv->co); - mul_v3_fl(dupve->co,0.25); - - - df1=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df1=*mf; - curdupface++; - - df2=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df2=*mf; - curdupface++; - - df3=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df3=*mf; - curdupface++; - - df1->v1=edgesplit_get(edgehash, mf->v1, mf->v2); - df3->v2=df1->v3=edgesplit_get(edgehash, mf->v2, mf->v3); - - df2->v1=edgesplit_get(edgehash, mf->v1, mf->v4); - df3->v4=df2->v3=edgesplit_get(edgehash, mf->v3, mf->v4); - - df3->v1=df2->v2=df1->v4=curdupin; - - mf->v2=df1->v1; - mf->v3=curdupin; - mf->v4=df2->v1; - - curdupin++; - - facepa[i]=v1; - facepa[curdupface-3]=v2; - facepa[curdupface-2]=v3; - facepa[curdupface-1]=v4; - - test_index_face(df1, &splitdm->faceData, curdupface-3, (df1->v4 ? 4 : 3)); - - test_index_face(df1, &splitdm->faceData, curdupface-2, (df1->v4 ? 4 : 3)); - test_index_face(df1, &splitdm->faceData, curdupface-1, (df1->v4 ? 4 : 3)); - } - else{ - df1=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df1=*mf; - curdupface++; - - df2=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df2=*mf; - curdupface++; - - df3=CDDM_get_face(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); - *df3=*mf; - curdupface++; - - if(v2==v3){ - df1->v1=edgesplit_get(edgehash, mf->v1, mf->v2); - df3->v1=df1->v2=df1->v3=edgesplit_get(edgehash, mf->v2, mf->v3); - df2->v1=df1->v4=edgesplit_get(edgehash, mf->v1, mf->v4); - - df3->v3=df2->v3=edgesplit_get(edgehash, mf->v3, mf->v4); - - df3->v2=mf->v3; - df3->v4=0; - - mf->v2=df1->v1; - mf->v3=df1->v4; - mf->v4=0; - - facepa[i]=v1; - facepa[curdupface-3]=facepa[curdupface-2]=v2; - facepa[curdupface-1]=v3; - } - else{ - df3->v1=df2->v1=df1->v2=edgesplit_get(edgehash, mf->v1, mf->v2); - df2->v4=df1->v3=edgesplit_get(edgehash, mf->v3, mf->v4); - df1->v4=edgesplit_get(edgehash, mf->v1, mf->v4); - - df3->v3=df2->v2=edgesplit_get(edgehash, mf->v2, mf->v3); - - df3->v4=0; - - mf->v1=df1->v4; - mf->v2=df1->v3; - mf->v3=mf->v4; - mf->v4=0; - - facepa[i]=v4; - facepa[curdupface-3]=facepa[curdupface-2]=v1; - facepa[curdupface-1]=v2; - } - - test_index_face(df1, &splitdm->faceData, curdupface-3, (df1->v4 ? 4 : 3)); - test_index_face(df1, &splitdm->faceData, curdupface-2, (df1->v4 ? 4 : 3)); - test_index_face(df1, &splitdm->faceData, curdupface-1, (df1->v4 ? 4 : 3)); - } - } - - test_index_face(df1, &splitdm->faceData, i, (df1->v4 ? 4 : 3)); - } - } - - BLI_edgehash_free(edgehash, NULL); - MEM_freeN(facesplit); - MEM_freeN(vertpa); - - return splitdm; - -} -static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, - ParticleSystemModifierData *psmd, Scene *scene, Object *ob, - DerivedMesh *to_explode) -{ - DerivedMesh *explode, *dm=to_explode; - MFace *mf=0, *mface; - ParticleSettings *part=psmd->psys->part; - ParticleSimulationData sim = {scene, ob, psmd->psys, psmd}; - ParticleData *pa=NULL, *pars=psmd->psys->particles; - ParticleKey state; - EdgeHash *vertpahash; - EdgeHashIterator *ehi; - float *vertco=0, imat[4][4]; - float loc0[3], nor[3]; - float timestep, cfra; - int *facepa=emd->facepa; - int totdup=0,totvert=0,totface=0,totpart=0; - int i, j, v, mindex=0; - - totface= dm->getNumFaces(dm); - totvert= dm->getNumVerts(dm); - mface= dm->getFaceArray(dm); - totpart= psmd->psys->totpart; - - timestep= psys_get_timestep(&sim); - - //if(part->flag & PART_GLOB_TIME) - cfra=bsystem_time(scene, 0,(float)scene->r.cfra,0.0); - //else - // cfra=bsystem_time(scene, ob,(float)scene->r.cfra,0.0); - - /* hash table for vertice <-> particle relations */ - vertpahash= BLI_edgehash_new(); - - for (i=0; itime) - mindex = totvert+totpart; - else - mindex = totvert+facepa[i]; - - mf= &mface[i]; - - /* set face vertices to exist in particle group */ - BLI_edgehash_insert(vertpahash, mf->v1, mindex, NULL); - BLI_edgehash_insert(vertpahash, mf->v2, mindex, NULL); - BLI_edgehash_insert(vertpahash, mf->v3, mindex, NULL); - if(mf->v4) - BLI_edgehash_insert(vertpahash, mf->v4, mindex, NULL); - } - - /* make new vertice indexes & count total vertices after duplication */ - ehi= BLI_edgehashIterator_new(vertpahash); - for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { - BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(totdup)); - totdup++; - } - BLI_edgehashIterator_free(ehi); - - /* the final duplicated vertices */ - explode= CDDM_from_template(dm, totdup, 0,totface); - /*dupvert= CDDM_get_verts(explode);*/ - - /* getting back to object space */ - invert_m4_m4(imat,ob->obmat); - - psmd->psys->lattice = psys_get_lattice(&sim); - - /* duplicate & displace vertices */ - ehi= BLI_edgehashIterator_new(vertpahash); - for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { - MVert source; - MVert *dest; - - /* get particle + vertex from hash */ - BLI_edgehashIterator_getKey(ehi, &j, &i); - i -= totvert; - v= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); - - dm->getVert(dm, j, &source); - dest = CDDM_get_vert(explode,v); - - DM_copy_vert_data(dm,explode,j,v,1); - *dest = source; - - if(i!=totpart) { - /* get particle */ - pa= pars+i; - - /* get particle state */ - psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc0,nor,0,0,0,0); - mul_m4_v3(ob->obmat,loc0); - - state.time=cfra; - psys_get_particle_state(&sim, i, &state, 1); - - vertco=CDDM_get_vert(explode,v)->co; - - mul_m4_v3(ob->obmat,vertco); - - VECSUB(vertco,vertco,loc0); - - /* apply rotation, size & location */ - mul_qt_v3(state.rot,vertco); - if(emd->flag & eExplodeFlag_PaSize) - mul_v3_fl(vertco,pa->size); - VECADD(vertco,vertco,state.co); - - mul_m4_v3(imat,vertco); - } - } - BLI_edgehashIterator_free(ehi); - - /*map new vertices to faces*/ - for (i=0; ialive==PARS_UNBORN && (emd->flag&eExplodeFlag_Unborn)==0) continue; - if(pa->alive==PARS_ALIVE && (emd->flag&eExplodeFlag_Alive)==0) continue; - if(pa->alive==PARS_DEAD && (emd->flag&eExplodeFlag_Dead)==0) continue; - } - - dm->getFace(dm,i,&source); - mf=CDDM_get_face(explode,i); - - orig_v4 = source.v4; - - if(facepa[i]!=totpart && cfra <= pa->time) - mindex = totvert+totpart; - else - mindex = totvert+facepa[i]; - - source.v1 = edgesplit_get(vertpahash, source.v1, mindex); - source.v2 = edgesplit_get(vertpahash, source.v2, mindex); - source.v3 = edgesplit_get(vertpahash, source.v3, mindex); - if(source.v4) - source.v4 = edgesplit_get(vertpahash, source.v4, mindex); - - DM_copy_face_data(dm,explode,i,i,1); - - *mf = source; - - test_index_face(mf, &explode->faceData, i, (orig_v4 ? 4 : 3)); - } - - /* cleanup */ - BLI_edgehash_free(vertpahash, NULL); - - /* finalization */ - CDDM_calc_edges(explode); - CDDM_calc_normals(explode); - - if(psmd->psys->lattice){ - end_latt_deform(psmd->psys->lattice); - psmd->psys->lattice= NULL; - } - - return explode; -} - -static ParticleSystemModifierData * explodeModifier_findPrecedingParticlesystem(Object *ob, ModifierData *emd) -{ - ModifierData *md; - ParticleSystemModifierData *psmd=0; - - for (md=ob->modifiers.first; emd!=md; md=md->next){ - if(md->type==eModifierType_ParticleSystem) - psmd= (ParticleSystemModifierData*) md; - } - return psmd; -} -static DerivedMesh * explodeModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm = derivedData; - ExplodeModifierData *emd= (ExplodeModifierData*) md; - ParticleSystemModifierData *psmd=explodeModifier_findPrecedingParticlesystem(ob,md); - - if(psmd){ - ParticleSystem * psys=psmd->psys; - - if(psys==0 || psys->totpart==0) return derivedData; - if(psys->part==0 || psys->particles==0) return derivedData; - if(psmd->dm==0) return derivedData; - - /* 1. find faces to be exploded if needed */ - if(emd->facepa==0 - || psmd->flag&eParticleSystemFlag_Pars - || emd->flag&eExplodeFlag_CalcFaces - || MEM_allocN_len(emd->facepa)/sizeof(int) != dm->getNumFaces(dm)){ - if(psmd->flag & eParticleSystemFlag_Pars) - psmd->flag &= ~eParticleSystemFlag_Pars; - - if(emd->flag & eExplodeFlag_CalcFaces) - emd->flag &= ~eExplodeFlag_CalcFaces; - - explodeModifier_createFacepa(emd,psmd,ob,derivedData); - } - - /* 2. create new mesh */ - if(emd->flag & eExplodeFlag_EdgeSplit){ - int *facepa = emd->facepa; - DerivedMesh *splitdm=explodeModifier_splitEdges(emd,dm); - DerivedMesh *explode=explodeModifier_explodeMesh(emd, psmd, md->scene, ob, splitdm); - - MEM_freeN(emd->facepa); - emd->facepa=facepa; - splitdm->release(splitdm); - return explode; - } - else - return explodeModifier_explodeMesh(emd, psmd, md->scene, ob, derivedData); - } - return derivedData; -} - -/* Fluidsim */ -static void fluidsimModifier_initData(ModifierData *md) -{ - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; - - fluidsim_init(fluidmd); -} -static void fluidsimModifier_freeData(ModifierData *md) -{ - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; - - fluidsim_free(fluidmd); -} - -static void fluidsimModifier_copyData(ModifierData *md, ModifierData *target) -{ - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; - FluidsimModifierData *tfluidmd= (FluidsimModifierData*) target; - - if(tfluidmd->fss) - MEM_freeN(tfluidmd->fss); - - tfluidmd->fss = MEM_dupallocN(fluidmd->fss); -} - -static DerivedMesh * fluidsimModifier_applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc) -{ - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; - DerivedMesh *result = NULL; - - /* check for alloc failing */ - if(!fluidmd->fss) - { - fluidsimModifier_initData(md); - - if(!fluidmd->fss) - return derivedData; - } - - result = fluidsimModifier_do(fluidmd, md->scene, ob, derivedData, useRenderParams, isFinalCalc); - - if(result) - { - return result; - } - - return derivedData; -} - -static void fluidsimModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) -{ - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; - Base *base; - - if(fluidmd && fluidmd->fss) - { - if(fluidmd->fss->type == OB_FLUIDSIM_DOMAIN) - { - for(base = scene->base.first; base; base= base->next) - { - Object *ob1= base->object; - if(ob1 != ob) - { - FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob1, eModifierType_Fluidsim); - - // only put dependancies from NON-DOMAIN fluids in here - if(fluidmdtmp && fluidmdtmp->fss && (fluidmdtmp->fss->type!=OB_FLUIDSIM_DOMAIN)) - { - DagNode *curNode = dag_get_node(forest, ob1); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Fluidsim Object"); - } - } - } - } - } -} - -static int fluidsimModifier_dependsOnTime(ModifierData *md) -{ - return 1; -} - -/* MeshDeform */ - -static void meshdeformModifier_initData(ModifierData *md) -{ - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - - mmd->gridsize= 5; -} - -static void meshdeformModifier_freeData(ModifierData *md) -{ - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - - if(mmd->bindweights) MEM_freeN(mmd->bindweights); - if(mmd->bindcos) MEM_freeN(mmd->bindcos); - if(mmd->dyngrid) MEM_freeN(mmd->dyngrid); - if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences); - if(mmd->dynverts) MEM_freeN(mmd->dynverts); -} - -static void meshdeformModifier_copyData(ModifierData *md, ModifierData *target) -{ - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - MeshDeformModifierData *tmmd = (MeshDeformModifierData*) target; - - tmmd->gridsize = mmd->gridsize; - tmmd->object = mmd->object; -} - -static CustomDataMask meshdeformModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; - CustomDataMask dataMask = 0; - - /* ask for vertexgroups if we need them */ - if(mmd->defgrp_name[0]) dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static int meshdeformModifier_isDisabled(ModifierData *md, int useRenderParams) -{ - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - - return !mmd->object; -} - -static void meshdeformModifier_foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) -{ - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - - walk(userData, ob, &mmd->object); -} - -static void meshdeformModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) -{ - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - - if (mmd->object) { - DagNode *curNode = dag_get_node(forest, mmd->object); - - dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA|DAG_RL_OB_DATA|DAG_RL_DATA_OB|DAG_RL_OB_OB, - "Mesh Deform Modifier"); - } -} - -static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3], float *vec) -{ - MDefCell *cell; - MDefInfluence *inf; - float gridvec[3], dvec[3], ivec[3], co[3], wx, wy, wz; - float weight, cageweight, totweight, *cageco; - int i, j, a, x, y, z, size; - - co[0]= co[1]= co[2]= 0.0f; - totweight= 0.0f; - size= mmd->dyngridsize; - - for(i=0; i<3; i++) { - gridvec[i]= (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth*0.5f)/mmd->dyncellwidth; - ivec[i]= (int)gridvec[i]; - dvec[i]= gridvec[i] - ivec[i]; - } - - for(i=0; i<8; i++) { - if(i & 1) { x= ivec[0]+1; wx= dvec[0]; } - else { x= ivec[0]; wx= 1.0f-dvec[0]; } - - if(i & 2) { y= ivec[1]+1; wy= dvec[1]; } - else { y= ivec[1]; wy= 1.0f-dvec[1]; } - - if(i & 4) { z= ivec[2]+1; wz= dvec[2]; } - else { z= ivec[2]; wz= 1.0f-dvec[2]; } - - CLAMP(x, 0, size-1); - CLAMP(y, 0, size-1); - CLAMP(z, 0, size-1); - - a= x + y*size + z*size*size; - weight= wx*wy*wz; - - cell= &mmd->dyngrid[a]; - inf= mmd->dyninfluences + cell->offset; - for(j=0; jtotinfluence; j++, inf++) { - cageco= dco[inf->vertex]; - cageweight= weight*inf->weight; - co[0] += cageweight*cageco[0]; - co[1] += cageweight*cageco[1]; - co[2] += cageweight*cageco[2]; - totweight += cageweight; - } - } - - VECCOPY(vec, co); - - return totweight; -} - -static void meshdeformModifier_do( - ModifierData *md, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) -{ - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - Mesh *me= (mmd->object)? mmd->object->data: NULL; - EditMesh *em = (me)? BKE_mesh_get_editmesh(me): NULL; - DerivedMesh *tmpdm, *cagedm; - MDeformVert *dvert = NULL; - MDeformWeight *dw; - MVert *cagemvert; - float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4]; - float weight, totweight, fac, co[3], *weights, (*dco)[3], (*bindcos)[3]; - int a, b, totvert, totcagevert, defgrp_index; - - if(!mmd->object || (!mmd->bindcos && !mmd->bindfunc)) - return; - - /* get cage derivedmesh */ - if(em) { - tmpdm= editmesh_get_derived_cage_and_final(md->scene, ob, em, &cagedm, 0); - if(tmpdm) - tmpdm->release(tmpdm); - BKE_mesh_end_editmesh(me, em); - } - else - cagedm= mmd->object->derivedFinal; - - /* if we don't have one computed, use derivedmesh from data - * without any modifiers */ - if(!cagedm) { - cagedm= get_dm(md->scene, mmd->object, NULL, NULL, NULL, 0); - if(cagedm) - cagedm->needsFree= 1; - } - - if(!cagedm) - return; - - /* compute matrices to go in and out of cage object space */ - invert_m4_m4(imat, mmd->object->obmat); - mul_m4_m4m4(cagemat, ob->obmat, imat); - mul_m4_m4m4(cmat, cagemat, mmd->bindmat); - invert_m4_m4(iobmat, cmat); - copy_m3_m4(icagemat, iobmat); - - /* bind weights if needed */ - if(!mmd->bindcos) { - static int recursive = 0; - - /* progress bar redraw can make this recursive .. */ - if(!recursive) { - recursive = 1; - mmd->bindfunc(md->scene, dm, mmd, (float*)vertexCos, numVerts, cagemat); - recursive = 0; - } - } - - /* verify we have compatible weights */ - totvert= numVerts; - totcagevert= cagedm->getNumVerts(cagedm); - - if(mmd->totvert!=totvert || mmd->totcagevert!=totcagevert || !mmd->bindcos) { - cagedm->release(cagedm); - return; - } - - /* setup deformation data */ - cagemvert= cagedm->getVertArray(cagedm); - weights= mmd->bindweights; - bindcos= (float(*)[3])mmd->bindcos; - - dco= MEM_callocN(sizeof(*dco)*totcagevert, "MDefDco"); - for(a=0; abindmat, co); - /* compute difference with world space bind coord */ - VECSUB(dco[a], co, bindcos[a]); - } - else - VECCOPY(dco[a], co) - } - - defgrp_index = defgroup_name_index(ob, mmd->defgrp_name); - - if (defgrp_index >= 0) - dvert= dm->getVertDataArray(dm, CD_MDEFORMVERT); - - /* do deformation */ - fac= 1.0f; - - for(b=0; bflag & MOD_MDEF_DYNAMIC_BIND) - if(!mmd->dynverts[b]) - continue; - - if(dvert) { - for(dw=NULL, a=0; aflag & MOD_MDEF_INVERT_VGROUP) { - if(!dw) fac= 1.0f; - else if(dw->weight == 1.0f) continue; - else fac=1.0f-dw->weight; - } - else { - if(!dw) continue; - else fac= dw->weight; - } - } - - if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) { - /* transform coordinate into cage's local space */ - VECCOPY(co, vertexCos[b]); - mul_m4_v3(cagemat, co); - totweight= meshdeform_dynamic_bind(mmd, dco, co); - } - else { - totweight= 0.0f; - co[0]= co[1]= co[2]= 0.0f; - - for(a=0; a 0.0f) { - mul_v3_fl(co, fac/totweight); - mul_m3_v3(icagemat, co); - if(G.rt != 527) - VECADD(vertexCos[b], vertexCos[b], co) - else - VECCOPY(vertexCos[b], co) - } - } - - /* release cage derivedmesh */ - MEM_freeN(dco); - cagedm->release(cagedm); -} - -static void meshdeformModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm= get_dm(md->scene, ob, NULL, derivedData, NULL, 0);; - - if(!dm) - return; - - modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ - - meshdeformModifier_do(md, ob, dm, vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -static void meshdeformModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm; - - if(!derivedData && ob->type == OB_MESH) - dm = CDDM_from_editmesh(editData, ob->data); - else - dm = derivedData; - - meshdeformModifier_do(md, ob, dm, vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -/* Multires */ -static void multiresModifier_initData(ModifierData *md) -{ - MultiresModifierData *mmd = (MultiresModifierData*)md; - - mmd->lvl = 0; - mmd->sculptlvl = 0; - mmd->renderlvl = 0; - mmd->totlvl = 0; -} - -static void multiresModifier_copyData(ModifierData *md, ModifierData *target) -{ - MultiresModifierData *mmd = (MultiresModifierData*) md; - MultiresModifierData *tmmd = (MultiresModifierData*) target; - - tmmd->lvl = mmd->lvl; - tmmd->sculptlvl = mmd->sculptlvl; - tmmd->renderlvl = mmd->renderlvl; - tmmd->totlvl = mmd->totlvl; -} - -static DerivedMesh *multiresModifier_applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, - int useRenderParams, int isFinalCalc) -{ - MultiresModifierData *mmd = (MultiresModifierData*)md; - DerivedMesh *result; - - result = multires_dm_create_from_derived(mmd, 0, dm, ob, useRenderParams, isFinalCalc); - - if(result == dm) - return dm; - - if(useRenderParams || !isFinalCalc) { - DerivedMesh *cddm= CDDM_copy(result); - result->release(result); - result= cddm; - } - else if((ob->mode & OB_MODE_SCULPT) && ob->sculpt) { - /* would be created on the fly too, just nicer this - way on first stroke after e.g. switching levels */ - ob->sculpt->pbvh= result->getPBVH(ob, result); - } - - return result; -} - -/* Shrinkwrap */ - -static void shrinkwrapModifier_initData(ModifierData *md) -{ - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; - smd->shrinkType = MOD_SHRINKWRAP_NEAREST_SURFACE; - smd->shrinkOpts = MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR; - smd->keepDist = 0.0f; - - smd->target = NULL; - smd->auxTarget = NULL; -} - -static void shrinkwrapModifier_copyData(ModifierData *md, ModifierData *target) -{ - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*)md; - ShrinkwrapModifierData *tsmd = (ShrinkwrapModifierData*)target; - - tsmd->target = smd->target; - tsmd->auxTarget = smd->auxTarget; - - strcpy(tsmd->vgroup_name, smd->vgroup_name); - - tsmd->keepDist = smd->keepDist; - tsmd->shrinkType= smd->shrinkType; - tsmd->shrinkOpts= smd->shrinkOpts; - tsmd->projAxis = smd->projAxis; - tsmd->subsurfLevels = smd->subsurfLevels; -} - -static CustomDataMask shrinkwrapModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md; - CustomDataMask dataMask = 0; - - /* ask for vertexgroups if we need them */ - if(smd->vgroup_name[0]) - dataMask |= (1 << CD_MDEFORMVERT); - - if(smd->shrinkType == MOD_SHRINKWRAP_PROJECT - && smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) - dataMask |= (1 << CD_MVERT); - - return dataMask; -} - -static int shrinkwrapModifier_isDisabled(ModifierData *md, int useRenderParams) -{ - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; - return !smd->target; -} - - -static void shrinkwrapModifier_foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, void *userData) -{ - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; - - walk(userData, ob, &smd->target); - walk(userData, ob, &smd->auxTarget); -} - -static void shrinkwrapModifier_deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm = derivedData; - CustomDataMask dataMask = shrinkwrapModifier_requiredDataMask(ob, md); - - /* ensure we get a CDDM with applied vertex coords */ - if(dataMask) - dm= get_cddm(md->scene, ob, NULL, dm, vertexCos); - - shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, md->scene, ob, dm, vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -static void shrinkwrapModifier_deformVertsEM(ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm = derivedData; - CustomDataMask dataMask = shrinkwrapModifier_requiredDataMask(ob, md); - - /* ensure we get a CDDM with applied vertex coords */ - if(dataMask) - dm= get_cddm(md->scene, ob, editData, dm, vertexCos); - - shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, md->scene, ob, dm, vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -static void shrinkwrapModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) -{ - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; - - if (smd->target) - dag_add_relation(forest, dag_get_node(forest, smd->target), obNode, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Shrinkwrap Modifier"); - - if (smd->auxTarget) - dag_add_relation(forest, dag_get_node(forest, smd->auxTarget), obNode, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Shrinkwrap Modifier"); -} - -/* SimpleDeform */ -static void simpledeformModifier_initData(ModifierData *md) -{ - SimpleDeformModifierData *smd = (SimpleDeformModifierData*) md; - - smd->mode = MOD_SIMPLEDEFORM_MODE_TWIST; - smd->axis = 0; - - smd->origin = NULL; - smd->factor = 0.35f; - smd->limit[0] = 0.0f; - smd->limit[1] = 1.0f; -} - -static void simpledeformModifier_copyData(ModifierData *md, ModifierData *target) -{ - SimpleDeformModifierData *smd = (SimpleDeformModifierData*)md; - SimpleDeformModifierData *tsmd = (SimpleDeformModifierData*)target; - - tsmd->mode = smd->mode; - tsmd->axis = smd->axis; - tsmd->origin= smd->origin; - tsmd->factor= smd->factor; - memcpy(tsmd->limit, smd->limit, sizeof(tsmd->limit)); -} - -static CustomDataMask simpledeformModifier_requiredDataMask(Object *ob, ModifierData *md) -{ - SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; - CustomDataMask dataMask = 0; - - /* ask for vertexgroups if we need them */ - if(smd->vgroup_name[0]) - dataMask |= (1 << CD_MDEFORMVERT); - - return dataMask; -} - -static void simpledeformModifier_foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) -{ - SimpleDeformModifierData *smd = (SimpleDeformModifierData*)md; - walk(userData, ob, &smd->origin); -} - -static void simpledeformModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) -{ - SimpleDeformModifierData *smd = (SimpleDeformModifierData*)md; - - if (smd->origin) - dag_add_relation(forest, dag_get_node(forest, smd->origin), obNode, DAG_RL_OB_DATA, "SimpleDeform Modifier"); -} - -static void simpledeformModifier_deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - DerivedMesh *dm = derivedData; - CustomDataMask dataMask = simpledeformModifier_requiredDataMask(ob, md); - - /* we implement requiredDataMask but thats not really usefull since - mesh_calc_modifiers pass a NULL derivedData */ - if(dataMask) - dm= get_dm(md->scene, ob, NULL, dm, NULL, 0); - - SimpleDeformModifier_do((SimpleDeformModifierData*)md, ob, dm, vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -static void simpledeformModifier_deformVertsEM(ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - DerivedMesh *dm = derivedData; - CustomDataMask dataMask = simpledeformModifier_requiredDataMask(ob, md); - - /* we implement requiredDataMask but thats not really usefull since - mesh_calc_modifiers pass a NULL derivedData */ - if(dataMask) - dm= get_dm(md->scene, ob, editData, dm, NULL, 0); - - SimpleDeformModifier_do((SimpleDeformModifierData*)md, ob, dm, vertexCos, numVerts); - - if(dm != derivedData) - dm->release(dm); -} - -/* Shape Key */ - -static void shapekeyModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - KeyBlock *kb= ob_get_keyblock(ob); - float (*deformedVerts)[3]; - - if(kb && kb->totelem == numVerts) { - deformedVerts= (float(*)[3])do_ob_key(md->scene, ob); - if(deformedVerts) { - memcpy(vertexCos, deformedVerts, sizeof(float)*3*numVerts); - MEM_freeN(deformedVerts); - } - } -} - -static void shapekeyModifier_deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) -{ - Key *key= ob_get_key(ob); - - if(key && key->type == KEY_RELATIVE) - shapekeyModifier_deformVerts(md, ob, derivedData, vertexCos, numVerts, 0, 0); -} - -static void shapekeyModifier_deformMatricesEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], - float (*defMats)[3][3], int numVerts) -{ - Key *key= ob_get_key(ob); - KeyBlock *kb= ob_get_keyblock(ob); - float scale[3][3]; - int a; - - if(kb && kb->totelem==numVerts && kb!=key->refkey) { - scale_m3_fl(scale, kb->curval); - - for(a=0; aname, "None"); - strcpy(mti->structName, "ModifierData"); - mti->structSize = sizeof(ModifierData); - mti->type = eModifierType_None; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs; - mti->isDisabled = noneModifier_isDisabled; - - mti = INIT_TYPE(Curve); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode; - mti->initData = curveModifier_initData; - mti->copyData = curveModifier_copyData; - mti->requiredDataMask = curveModifier_requiredDataMask; - mti->isDisabled = curveModifier_isDisabled; - mti->foreachObjectLink = curveModifier_foreachObjectLink; - mti->updateDepgraph = curveModifier_updateDepgraph; - mti->deformVerts = curveModifier_deformVerts; - mti->deformVertsEM = curveModifier_deformVertsEM; - - mti = INIT_TYPE(Lattice); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode; - mti->copyData = latticeModifier_copyData; - mti->requiredDataMask = latticeModifier_requiredDataMask; - mti->isDisabled = latticeModifier_isDisabled; - mti->foreachObjectLink = latticeModifier_foreachObjectLink; - mti->updateDepgraph = latticeModifier_updateDepgraph; - mti->deformVerts = latticeModifier_deformVerts; - mti->deformVertsEM = latticeModifier_deformVertsEM; - - mti = INIT_TYPE(Subsurf); - mti->type = eModifierTypeType_Constructive; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode - | eModifierTypeFlag_AcceptsCVs; - mti->initData = subsurfModifier_initData; - mti->copyData = subsurfModifier_copyData; - mti->freeData = subsurfModifier_freeData; - mti->isDisabled = subsurfModifier_isDisabled; - mti->applyModifier = subsurfModifier_applyModifier; - mti->applyModifierEM = subsurfModifier_applyModifierEM; - - mti = INIT_TYPE(Build); - mti->type = eModifierTypeType_Nonconstructive; - mti->flags = eModifierTypeFlag_AcceptsMesh | - eModifierTypeFlag_AcceptsCVs; - mti->initData = buildModifier_initData; - mti->copyData = buildModifier_copyData; - mti->dependsOnTime = buildModifier_dependsOnTime; - mti->applyModifier = buildModifier_applyModifier; - - mti = INIT_TYPE(Mask); - mti->type = eModifierTypeType_Nonconstructive; - mti->flags = eModifierTypeFlag_AcceptsMesh; - mti->copyData = maskModifier_copyData; - mti->requiredDataMask= maskModifier_requiredDataMask; - mti->foreachObjectLink = maskModifier_foreachObjectLink; - mti->updateDepgraph = maskModifier_updateDepgraph; - mti->applyModifier = maskModifier_applyModifier; - - mti = INIT_TYPE(Array); - mti->type = eModifierTypeType_Constructive; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode - | eModifierTypeFlag_AcceptsCVs; - mti->initData = arrayModifier_initData; - mti->copyData = arrayModifier_copyData; - mti->foreachObjectLink = arrayModifier_foreachObjectLink; - mti->updateDepgraph = arrayModifier_updateDepgraph; - mti->applyModifier = arrayModifier_applyModifier; - mti->applyModifierEM = arrayModifier_applyModifierEM; - - mti = INIT_TYPE(Mirror); - mti->type = eModifierTypeType_Constructive; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode - | eModifierTypeFlag_AcceptsCVs; - mti->initData = mirrorModifier_initData; - mti->copyData = mirrorModifier_copyData; - mti->foreachObjectLink = mirrorModifier_foreachObjectLink; - mti->updateDepgraph = mirrorModifier_updateDepgraph; - mti->applyModifier = mirrorModifier_applyModifier; - mti->applyModifierEM = mirrorModifier_applyModifierEM; - - mti = INIT_TYPE(EdgeSplit); - mti->type = eModifierTypeType_Constructive; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode; - mti->initData = edgesplitModifier_initData; - mti->copyData = edgesplitModifier_copyData; - mti->applyModifier = edgesplitModifier_applyModifier; - mti->applyModifierEM = edgesplitModifier_applyModifierEM; - - mti = INIT_TYPE(Bevel); - mti->type = eModifierTypeType_Constructive; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode; - mti->initData = bevelModifier_initData; - mti->copyData = bevelModifier_copyData; - mti->requiredDataMask = bevelModifier_requiredDataMask; - mti->applyModifier = bevelModifier_applyModifier; - mti->applyModifierEM = bevelModifier_applyModifierEM; - - mti = INIT_TYPE(Displace); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsMesh|eModifierTypeFlag_SupportsEditmode; - mti->initData = displaceModifier_initData; - mti->copyData = displaceModifier_copyData; - mti->requiredDataMask = displaceModifier_requiredDataMask; - mti->dependsOnTime = displaceModifier_dependsOnTime; - mti->foreachObjectLink = displaceModifier_foreachObjectLink; - mti->foreachIDLink = displaceModifier_foreachIDLink; - mti->updateDepgraph = displaceModifier_updateDepgraph; - mti->isDisabled = displaceModifier_isDisabled; - mti->deformVerts = displaceModifier_deformVerts; - mti->deformVertsEM = displaceModifier_deformVertsEM; - - mti = INIT_TYPE(UVProject); - mti->type = eModifierTypeType_Nonconstructive; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode; - mti->initData = uvprojectModifier_initData; - mti->copyData = uvprojectModifier_copyData; - mti->requiredDataMask = uvprojectModifier_requiredDataMask; - mti->foreachObjectLink = uvprojectModifier_foreachObjectLink; - mti->foreachIDLink = uvprojectModifier_foreachIDLink; - mti->updateDepgraph = uvprojectModifier_updateDepgraph; - mti->applyModifier = uvprojectModifier_applyModifier; - mti->applyModifierEM = uvprojectModifier_applyModifierEM; - - mti = INIT_TYPE(Decimate); - mti->type = eModifierTypeType_Nonconstructive; - mti->flags = eModifierTypeFlag_AcceptsMesh; - mti->initData = decimateModifier_initData; - mti->copyData = decimateModifier_copyData; - mti->applyModifier = decimateModifier_applyModifier; - - mti = INIT_TYPE(Smooth); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode; - mti->initData = smoothModifier_initData; - mti->copyData = smoothModifier_copyData; - mti->requiredDataMask = smoothModifier_requiredDataMask; - mti->isDisabled = smoothModifier_isDisabled; - mti->deformVerts = smoothModifier_deformVerts; - mti->deformVertsEM = smoothModifier_deformVertsEM; - - mti = INIT_TYPE(Cast); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode; - mti->initData = castModifier_initData; - mti->copyData = castModifier_copyData; - mti->requiredDataMask = castModifier_requiredDataMask; - mti->isDisabled = castModifier_isDisabled; - mti->foreachObjectLink = castModifier_foreachObjectLink; - mti->updateDepgraph = castModifier_updateDepgraph; - mti->deformVerts = castModifier_deformVerts; - mti->deformVertsEM = castModifier_deformVertsEM; - - mti = INIT_TYPE(Wave); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode; - mti->initData = waveModifier_initData; - mti->copyData = waveModifier_copyData; - mti->dependsOnTime = waveModifier_dependsOnTime; - mti->requiredDataMask = waveModifier_requiredDataMask; - mti->foreachObjectLink = waveModifier_foreachObjectLink; - mti->foreachIDLink = waveModifier_foreachIDLink; - mti->updateDepgraph = waveModifier_updateDepgraph; - mti->deformVerts = waveModifier_deformVerts; - mti->deformVertsEM = waveModifier_deformVertsEM; - - mti = INIT_TYPE(Armature); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode; - mti->initData = armatureModifier_initData; - mti->copyData = armatureModifier_copyData; - mti->requiredDataMask = armatureModifier_requiredDataMask; - mti->isDisabled = armatureModifier_isDisabled; - mti->foreachObjectLink = armatureModifier_foreachObjectLink; - mti->updateDepgraph = armatureModifier_updateDepgraph; - mti->deformVerts = armatureModifier_deformVerts; - mti->deformVertsEM = armatureModifier_deformVertsEM; - mti->deformMatricesEM = armatureModifier_deformMatricesEM; - - mti = INIT_TYPE(Hook); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode; - mti->initData = hookModifier_initData; - mti->copyData = hookModifier_copyData; - mti->requiredDataMask = hookModifier_requiredDataMask; - mti->freeData = hookModifier_freeData; - mti->isDisabled = hookModifier_isDisabled; - mti->foreachObjectLink = hookModifier_foreachObjectLink; - mti->updateDepgraph = hookModifier_updateDepgraph; - mti->deformVerts = hookModifier_deformVerts; - mti->deformVertsEM = hookModifier_deformVertsEM; - - mti = INIT_TYPE(Softbody); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_RequiresOriginalData - | eModifierTypeFlag_Single; - mti->deformVerts = softbodyModifier_deformVerts; - mti->dependsOnTime = softbodyModifier_dependsOnTime; - - mti = INIT_TYPE(Smoke); - mti->type = eModifierTypeType_OnlyDeform; - mti->initData = smokeModifier_initData; - mti->freeData = smokeModifier_freeData; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache - | eModifierTypeFlag_Single; - mti->deformVerts = smokeModifier_deformVerts; - mti->dependsOnTime = smokeModifier_dependsOnTime; - mti->updateDepgraph = smokeModifier_updateDepgraph; - - mti = INIT_TYPE(Cloth); - mti->type = eModifierTypeType_Nonconstructive; - mti->initData = clothModifier_initData; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache - | eModifierTypeFlag_Single; - mti->dependsOnTime = clothModifier_dependsOnTime; - mti->freeData = clothModifier_freeData; - mti->requiredDataMask = clothModifier_requiredDataMask; - mti->copyData = clothModifier_copyData; - mti->applyModifier = clothModifier_applyModifier; - mti->updateDepgraph = clothModifier_updateDepgraph; - - mti = INIT_TYPE(Collision); - mti->type = eModifierTypeType_OnlyDeform; - mti->initData = collisionModifier_initData; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_Single; - mti->dependsOnTime = collisionModifier_dependsOnTime; - mti->freeData = collisionModifier_freeData; - mti->deformVerts = collisionModifier_deformVerts; - // mti->copyData = collisionModifier_copyData; - - mti = INIT_TYPE(Surface); - mti->type = eModifierTypeType_OnlyDeform; - mti->initData = surfaceModifier_initData; - mti->flags = eModifierTypeFlag_AcceptsMesh|eModifierTypeFlag_NoUserAdd; - mti->dependsOnTime = surfaceModifier_dependsOnTime; - mti->freeData = surfaceModifier_freeData; - mti->deformVerts = surfaceModifier_deformVerts; - - mti = INIT_TYPE(Boolean); - mti->type = eModifierTypeType_Nonconstructive; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache; - mti->copyData = booleanModifier_copyData; - mti->isDisabled = booleanModifier_isDisabled; - mti->applyModifier = booleanModifier_applyModifier; - mti->foreachObjectLink = booleanModifier_foreachObjectLink; - mti->updateDepgraph = booleanModifier_updateDepgraph; - mti->requiredDataMask = booleanModifier_requiredDataMask; - - mti = INIT_TYPE(MeshDeform); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode; - mti->initData = meshdeformModifier_initData; - mti->freeData = meshdeformModifier_freeData; - mti->copyData = meshdeformModifier_copyData; - mti->requiredDataMask = meshdeformModifier_requiredDataMask; - mti->isDisabled = meshdeformModifier_isDisabled; - mti->foreachObjectLink = meshdeformModifier_foreachObjectLink; - mti->updateDepgraph = meshdeformModifier_updateDepgraph; - mti->deformVerts = meshdeformModifier_deformVerts; - mti->deformVertsEM = meshdeformModifier_deformVertsEM; - - mti = INIT_TYPE(ParticleSystem); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_UsesPointCache; -#if 0 - | eModifierTypeFlag_SupportsEditmode; - |eModifierTypeFlag_EnableInEditmode; -#endif - mti->initData = particleSystemModifier_initData; - mti->freeData = particleSystemModifier_freeData; - mti->copyData = particleSystemModifier_copyData; - mti->deformVerts = particleSystemModifier_deformVerts; -#if 0 - mti->deformVertsEM = particleSystemModifier_deformVertsEM; -#endif - mti->requiredDataMask = particleSystemModifier_requiredDataMask; - - mti = INIT_TYPE(ParticleInstance); - mti->type = eModifierTypeType_Constructive; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode; - mti->initData = particleInstanceModifier_initData; - mti->copyData = particleInstanceModifier_copyData; - mti->dependsOnTime = particleInstanceModifier_dependsOnTime; - mti->foreachObjectLink = particleInstanceModifier_foreachObjectLink; - mti->applyModifier = particleInstanceModifier_applyModifier; - mti->applyModifierEM = particleInstanceModifier_applyModifierEM; - mti->updateDepgraph = particleInstanceModifier_updateDepgraph; - - mti = INIT_TYPE(Explode); - mti->type = eModifierTypeType_Nonconstructive; - mti->flags = eModifierTypeFlag_AcceptsMesh; - mti->initData = explodeModifier_initData; - mti->freeData = explodeModifier_freeData; - mti->copyData = explodeModifier_copyData; - mti->dependsOnTime = explodeModifier_dependsOnTime; - mti->requiredDataMask = explodeModifier_requiredDataMask; - mti->applyModifier = explodeModifier_applyModifier; - - mti = INIT_TYPE(Fluidsim); - mti->type = eModifierTypeType_Nonconstructive - | eModifierTypeFlag_RequiresOriginalData - | eModifierTypeFlag_Single; - mti->flags = eModifierTypeFlag_AcceptsMesh; - mti->initData = fluidsimModifier_initData; - mti->freeData = fluidsimModifier_freeData; - mti->copyData = fluidsimModifier_copyData; - mti->dependsOnTime = fluidsimModifier_dependsOnTime; - mti->applyModifier = fluidsimModifier_applyModifier; - mti->updateDepgraph = fluidsimModifier_updateDepgraph; - - mti = INIT_TYPE(Shrinkwrap); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode; - mti->initData = shrinkwrapModifier_initData; - mti->copyData = shrinkwrapModifier_copyData; - mti->requiredDataMask = shrinkwrapModifier_requiredDataMask; - mti->isDisabled = shrinkwrapModifier_isDisabled; - mti->foreachObjectLink = shrinkwrapModifier_foreachObjectLink; - mti->deformVerts = shrinkwrapModifier_deformVerts; - mti->deformVertsEM = shrinkwrapModifier_deformVertsEM; - mti->updateDepgraph = shrinkwrapModifier_updateDepgraph; - - mti = INIT_TYPE(SimpleDeform); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode; - mti->initData = simpledeformModifier_initData; - mti->copyData = simpledeformModifier_copyData; - mti->requiredDataMask = simpledeformModifier_requiredDataMask; - mti->deformVerts = simpledeformModifier_deformVerts; - mti->deformVertsEM = simpledeformModifier_deformVertsEM; - mti->foreachObjectLink = simpledeformModifier_foreachObjectLink; - mti->updateDepgraph = simpledeformModifier_updateDepgraph; - - mti = INIT_TYPE(Multires); - mti->type = eModifierTypeType_Constructive; - mti->flags = eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_RequiresOriginalData; - mti->initData = multiresModifier_initData; - mti->copyData = multiresModifier_copyData; - mti->applyModifier = multiresModifier_applyModifier; - - mti = INIT_TYPE(ShapeKey); - mti->type = eModifierTypeType_OnlyDeform; - mti->flags = eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode; - mti->deformVerts = shapekeyModifier_deformVerts; - mti->deformVertsEM = shapekeyModifier_deformVertsEM; - mti->deformMatricesEM = shapekeyModifier_deformMatricesEM; - - mti = INIT_TYPE(Solidify); - mti->type = eModifierTypeType_Constructive; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode; - mti->initData = solidifyModifier_initData; - mti->copyData = solidifyModifier_copyData; - mti->applyModifier = solidifyModifier_applyModifier; - mti->applyModifierEM = solidifyModifier_applyModifierEM; - typeArrInit = 0; - - mti = INIT_TYPE(Screw); - mti->type = eModifierTypeType_Constructive; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode - | eModifierTypeFlag_AcceptsCVs; - - mti->initData = screwModifier_initData; - mti->copyData = screwModifier_copyData; - mti->foreachObjectLink = screwModifier_foreachObjectLink; - mti->dependsOnTime = screwModifier_dependsOnTime; - mti->updateDepgraph = screwModifier_updateDepgraph; - mti->applyModifier = screwModifier_applyModifier; - mti->applyModifierEM = screwModifier_applyModifierEM; - -#undef INIT_TYPE - } - - if (type>=0 && type -#include - - -//Clamps/Limits the given coordinate to: limits[0] <= co[axis] <= limits[1] -//The ammount of clamp is saved on dcut -static void axis_limit(int axis, const float limits[2], float co[3], float dcut[3]) -{ - float val = co[axis]; - if(limits[0] > val) val = limits[0]; - if(limits[1] < val) val = limits[1]; - - dcut[axis] = co[axis] - val; - co[axis] = val; -} - -static void simpleDeform_taper(const float factor, const float dcut[3], float *co) -{ - float x = co[0], y = co[1], z = co[2]; - float scale = z*factor; - - co[0] = x + x*scale; - co[1] = y + y*scale; - co[2] = z; - - if(dcut) - { - co[0] += dcut[0]; - co[1] += dcut[1]; - co[2] += dcut[2]; - } -} - -static void simpleDeform_stretch(const float factor, const float dcut[3], float *co) -{ - float x = co[0], y = co[1], z = co[2]; - float scale; - - scale = (z*z*factor-factor + 1.0); - - co[0] = x*scale; - co[1] = y*scale; - co[2] = z*(1.0+factor); - - - if(dcut) - { - co[0] += dcut[0]; - co[1] += dcut[1]; - co[2] += dcut[2]; - } -} - -static void simpleDeform_twist(const float factor, const float *dcut, float *co) -{ - float x = co[0], y = co[1], z = co[2]; - float theta, sint, cost; - - theta = z*factor; - sint = sin(theta); - cost = cos(theta); - - co[0] = x*cost - y*sint; - co[1] = x*sint + y*cost; - co[2] = z; - - if(dcut) - { - co[0] += dcut[0]; - co[1] += dcut[1]; - co[2] += dcut[2]; - } -} - -static void simpleDeform_bend(const float factor, const float dcut[3], float *co) -{ - float x = co[0], y = co[1], z = co[2]; - float theta, sint, cost; - - theta = x*factor; - sint = sin(theta); - cost = cos(theta); - - if(fabs(factor) > 1e-7f) - { - co[0] = -(y-1.0f/factor)*sint; - co[1] = (y-1.0f/factor)*cost + 1.0f/factor; - co[2] = z; - } - - - if(dcut) - { - co[0] += cost*dcut[0]; - co[1] += sint*dcut[0]; - co[2] += dcut[2]; - } - -} - - -/* simple deform modifier */ -void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts) -{ - static const float lock_axis[2] = {0.0f, 0.0f}; - - int i; - int limit_axis = 0; - float smd_limit[2], smd_factor; - SpaceTransform *transf = NULL, tmp_transf; - void (*simpleDeform_callback)(const float factor, const float dcut[3], float *co) = NULL; //Mode callback - int vgroup = defgroup_name_index(ob, smd->vgroup_name); - MDeformVert *dvert = NULL; - - //Safe-check - if(smd->origin == ob) smd->origin = NULL; //No self references - - if(smd->limit[0] < 0.0) smd->limit[0] = 0.0f; - if(smd->limit[0] > 1.0) smd->limit[0] = 1.0f; - - smd->limit[0] = MIN2(smd->limit[0], smd->limit[1]); //Upper limit >= than lower limit - - //Calculate matrixs do convert between coordinate spaces - if(smd->origin) - { - transf = &tmp_transf; - - if(smd->originOpts & MOD_SIMPLEDEFORM_ORIGIN_LOCAL) - { - space_transform_from_matrixs(transf, ob->obmat, smd->origin->obmat); - } - else - { - copy_m4_m4(transf->local2target, smd->origin->obmat); - invert_m4_m4(transf->target2local, transf->local2target); - } - } - - //Setup vars - limit_axis = (smd->mode == MOD_SIMPLEDEFORM_MODE_BEND) ? 0 : 2; //Bend limits on X.. all other modes limit on Z - - //Update limits if needed - { - float lower = FLT_MAX; - float upper = -FLT_MAX; - - for(i=0; ilimit[1]; - smd_limit[0] = lower + (upper-lower)*smd->limit[0]; - - smd_factor = smd->factor / MAX2(FLT_EPSILON, smd_limit[1]-smd_limit[0]); - } - - - if(dm) - { - dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - } - else if(ob->type == OB_LATTICE) - { - dvert = lattice_get_deform_verts(ob); - } - - - - switch(smd->mode) - { - case MOD_SIMPLEDEFORM_MODE_TWIST: simpleDeform_callback = simpleDeform_twist; break; - case MOD_SIMPLEDEFORM_MODE_BEND: simpleDeform_callback = simpleDeform_bend; break; - case MOD_SIMPLEDEFORM_MODE_TAPER: simpleDeform_callback = simpleDeform_taper; break; - case MOD_SIMPLEDEFORM_MODE_STRETCH: simpleDeform_callback = simpleDeform_stretch; break; - default: - return; //No simpledeform mode? - } - - for(i=0; imode != MOD_SIMPLEDEFORM_MODE_BEND) //Bend mode shoulnt have any lock axis - { - if(smd->axis & MOD_SIMPLEDEFORM_LOCK_AXIS_X) axis_limit(0, lock_axis, co, dcut); - if(smd->axis & MOD_SIMPLEDEFORM_LOCK_AXIS_Y) axis_limit(1, lock_axis, co, dcut); - } - axis_limit(limit_axis, smd_limit, co, dcut); - - simpleDeform_callback(smd_factor, dcut, co); //Apply deform - interp_v3_v3v3(vertexCos[i], vertexCos[i], co, weight); //Use vertex weight has coef of linear interpolation - - if(transf) space_transform_invert(transf, vertexCos[i]); - } - } -} - - -- cgit v1.2.3 From 909493eac93330122d80499aa2da5e1cf89dbcb3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 11 Apr 2010 22:20:02 +0000 Subject: booleanops.c was moved to MOD_boolean_util.c, remove empty file. --- source/blender/blenkernel/BKE_booleanops.h | 33 --------------------------- source/blender/blenkernel/intern/booleanops.c | 0 source/blender/blenkernel/intern/modifier.c | 1 - 3 files changed, 34 deletions(-) delete mode 100644 source/blender/blenkernel/BKE_booleanops.h delete mode 100644 source/blender/blenkernel/intern/booleanops.c (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_booleanops.h b/source/blender/blenkernel/BKE_booleanops.h deleted file mode 100644 index a213d63cc03..00000000000 --- a/source/blender/blenkernel/BKE_booleanops.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef BKE_BOOLEANOPS_H -#define BKE_BOOLEANOPS_H - -#endif - diff --git a/source/blender/blenkernel/intern/booleanops.c b/source/blender/blenkernel/intern/booleanops.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index d2d9d558b3c..eb8775edc9e 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -56,7 +56,6 @@ #include "BKE_action.h" #include "BKE_bmesh.h" -#include "BKE_booleanops.h" #include "BKE_cloth.h" #include "BKE_cdderivedmesh.h" #include "BKE_displist.h" -- cgit v1.2.3 From 8c3ab1c2a40c17901546575adda3eba5d76b25ba Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 12 Apr 2010 00:36:50 +0000 Subject: - use more inline math funcitons where possible - swapped in less verbose math functons - modifier include cleanup --- source/blender/blenkernel/BKE_fluidsim.h | 1 + source/blender/blenkernel/BKE_object.h | 1 + source/blender/blenkernel/BKE_shrinkwrap.h | 2 +- source/blender/blenkernel/BKE_subsurf.h | 4 ++-- source/blender/blenkernel/intern/constraint.c | 6 ++++-- 5 files changed, 9 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_fluidsim.h b/source/blender/blenkernel/BKE_fluidsim.h index da43ae7f28b..e730f4ec34c 100644 --- a/source/blender/blenkernel/BKE_fluidsim.h +++ b/source/blender/blenkernel/BKE_fluidsim.h @@ -34,6 +34,7 @@ struct Object; struct Scene; struct FluidsimModifierData; +struct FluidsimSettings; struct DerivedMesh; struct MVert; diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 84995b60f4b..065d747a959 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -46,6 +46,7 @@ struct BulletSoftBody; struct Group; struct bAction; struct RenderData; +struct rctf; void clear_workob(struct Object *workob); void what_does_parent(struct Scene *scene, struct Object *ob, struct Object *workob); diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h index 4b6c5ba5459..47fb5049278 100644 --- a/source/blender/blenkernel/BKE_shrinkwrap.h +++ b/source/blender/blenkernel/BKE_shrinkwrap.h @@ -107,7 +107,7 @@ typedef struct ShrinkwrapCalcData struct Object *ob; //object we are applying shrinkwrap to - MVert *vert; //Array of verts being projected (to fetch normals or other data) + struct MVert *vert; //Array of verts being projected (to fetch normals or other data) float (*vertexCos)[3]; //vertexs being shrinkwraped int numVerts; diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index 853fd99aa86..ef3ad3ad2e9 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -52,7 +52,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( int useRenderParams, float (*vertCos)[3], int isFinalCalc, int editMode); -void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]); +void subsurf_calculate_limit_positions(struct Mesh *me, float (*positions_r)[3]); /**************************** Internal *****************************/ @@ -87,7 +87,7 @@ typedef struct CCGDerivedMesh { int lvl, totlvl; float (*orco)[3]; - Object *ob; + struct Object *ob; int modified; void (*update)(DerivedMesh*); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 0441e9c9d00..af0b462c349 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1983,8 +1983,10 @@ static void pycon_id_looper (bConstraint *con, ConstraintIDFunc func, void *user /* Whether this approach is maintained remains to be seen (aligorith) */ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) { +#ifndef DISABLE_PYTHON bPythonConstraint *data= con->data; - +#endif + if (VALID_CONS_TARGET(ct)) { /* special exception for curves - depsgraph issues */ if (ct->tar->type == OB_CURVE) { @@ -3573,7 +3575,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr } /* co is in local object coordinates, change it to global and update target position */ - mul_v3_m4v3(co, cob->matrix, co); + mul_m4_v3(cob->matrix, co); VECCOPY(ct->matrix[3], co); } } -- cgit v1.2.3 From 9563a8524261b04b021abec27319857b2df001ba Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 12 Apr 2010 01:09:59 +0000 Subject: more header cleanups --- source/blender/blenkernel/intern/modifier.c | 39 ----------------------------- 1 file changed, 39 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index eb8775edc9e..cf065bb3467 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -40,50 +40,11 @@ #include "math.h" #include "float.h" -#include "BLI_kdtree.h" -#include "BLI_rand.h" -#include "BLI_uvproject.h" - -#include "MEM_guardedalloc.h" - #include "DNA_armature_types.h" -#include "DNA_camera_types.h" -#include "DNA_curve_types.h" -#include "DNA_key_types.h" -#include "DNA_material_types.h" -#include "DNA_object_fluidsim.h" - -#include "BKE_action.h" #include "BKE_bmesh.h" #include "BKE_cloth.h" -#include "BKE_cdderivedmesh.h" -#include "BKE_displist.h" -#include "BKE_fluidsim.h" -#include "BKE_global.h" -#include "BKE_multires.h" #include "BKE_key.h" -#include "BKE_lattice.h" -#include "BKE_material.h" -#include "BKE_mesh.h" -#include "BKE_modifier.h" -#include "BKE_object.h" -#include "BKE_paint.h" -#include "BKE_particle.h" -#include "BKE_pointcache.h" -#include "BKE_scene.h" -#include "BKE_smoke.h" -#include "BKE_softbody.h" -#include "BKE_subsurf.h" -#include "BKE_texture.h" - -#include "depsgraph_private.h" -#include "BKE_deform.h" -#include "BKE_shrinkwrap.h" - -#include "CCGSubSurf.h" - -#include "RE_shader_ext.h" #include "MOD_modifiertypes.h" -- cgit v1.2.3 From 8e4cbaa0c7dea891b0f9f3ae345abe78e521bf91 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Mon, 12 Apr 2010 01:23:55 +0000 Subject: Modifiers moved, adjust accordingly. --- source/blender/blenkernel/intern/Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile index 70e1a785787..4e365f363c3 100644 --- a/source/blender/blenkernel/intern/Makefile +++ b/source/blender/blenkernel/intern/Makefile @@ -85,6 +85,9 @@ CPPFLAGS += -I../../nodes #path to gpu CPPFLAGS += -I../../gpu +#modifiers got moved +CPPFLAGS += -I../../modifiers + # path to our own external headerfiles CPPFLAGS += -I.. -- cgit v1.2.3 From 919565f196b66026f0adf23ed1ee2214e5a517f7 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 12 Apr 2010 17:34:06 +0000 Subject: Subframe calculations for particles, original patch by Raul Fernandez Hernandez * Increasing subframe count increases stability for SPH fluid and Newtonian particles * Also small tweaks into physics ui panel to better fit new subframes value * This commit also fixes the moving fluid emitter problem as described by Raul in the mailinglist --- source/blender/blenkernel/intern/particle_system.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 54abfd8fd40..389b31a20c7 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2308,8 +2308,7 @@ void particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings VECCOPY(start, pa->prev_state.co); VECCOPY(end, pa->state.co); - sub_v3_v3v3(v, end, start); - mul_v3_fl(v, 1.f/dtime); + VECCOPY(v, pa->state.vel); neighbours = BLI_kdtree_range_search(tree, radius, start, NULL, &ptn); @@ -3790,18 +3789,23 @@ static void system_step(ParticleSimulationData *sim, float cfra) } if(psys->totpart) { - int dframe, totframesback = 0; - + int dframe, subframe = 0, totframesback = 0, totsubframe = part->subframes+1; + float fraction; + /* handle negative frame start at the first frame by doing * all the steps before the first frame */ if(framenr == startframe && part->sta < startframe) totframesback = (startframe - (int)part->sta); - + for(dframe=-totframesback; dframe<=0; dframe++) { /* ok now we're all set so let's go */ - dynamics_step(sim, cfra+dframe); - psys->cfra = cfra+dframe; + for (subframe = 1; subframe <= totsubframe; subframe++) { + fraction = (float)subframe/(float)totsubframe; + dynamics_step(sim, cfra+dframe+fraction - 1.f); + psys->cfra = cfra+dframe+fraction - 1.f; + } } + } /* 4. only write cache starting from second frame */ -- cgit v1.2.3 From 403c1e2a8ea1bf5780ac6b290d9099a8bd279dea Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 13 Apr 2010 06:06:49 +0000 Subject: Todo #21831: Deform modifier is applied to base mesh instead of multires modifier if both are in the stack (patch #21965) This patch also removes limitation of multires reshaping when destination object has got modifiers after multires modifier. --- source/blender/blenkernel/BKE_multires.h | 4 ++ source/blender/blenkernel/intern/multires.c | 66 ++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 22f70d079ca..e5c7745f637 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -35,6 +35,7 @@ struct Mesh; struct MFace; struct Multires; struct MultiresModifierData; +struct ModifierData; struct Object; void multires_mark_as_modified(struct Object *ob); @@ -46,11 +47,14 @@ struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData* int local_mmd, struct DerivedMesh*, struct Object *, int, int); struct MultiresModifierData *find_multires_modifier(struct Object *ob); +struct DerivedMesh *get_multires_dm(struct Object *ob); void multiresModifier_join(struct Object *); void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple); int multiresModifier_reshape(struct MultiresModifierData *mmd, struct Object *dst, struct Object *src); +int multiresModifier_reshapeFromDM(struct MultiresModifierData *mmd, struct Object *ob, struct DerivedMesh *srcdm); +int multiresModifier_reshapeFromDeformMod(struct MultiresModifierData *mmd, struct Object *ob, struct ModifierData *md); void multires_stitch_grids(struct Object *); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index c70d12bcb75..9e95581b211 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -60,6 +60,22 @@ static const int multires_side_tot[] = {0, 2, 3, 5, 9, 17, 33, 65, 129, static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert); static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int add, DMGridData **oldGridData, int totlvl); +DerivedMesh *get_multires_dm(Object *ob) +{ + Mesh *me= ob->data; + ModifierData *md= (ModifierData *)find_multires_modifier(ob); + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + DerivedMesh *tdm = CDDM_from_mesh(me, ob); + DerivedMesh *dm; + + CDDM_calc_normals(tdm); + dm = mti->applyModifier(md, ob, tdm, 0, 1); + + if(tdm != dm) tdm->release(tdm); + + return dm; +} + MultiresModifierData *find_multires_modifier(Object *ob) { ModifierData *md; @@ -191,24 +207,64 @@ void multiresModifier_join(Object *ob) } #endif -/* Returns 1 on success, 0 if the src's totvert doesn't match */ -int multiresModifier_reshape(MultiresModifierData *mmd, Object *dst, Object *src) +int multiresModifier_reshapeFromDM(MultiresModifierData *mmd, Object *ob, DerivedMesh *srcdm) { - DerivedMesh *srcdm = src->derivedFinal; - DerivedMesh *mrdm = dst->derivedFinal; + DerivedMesh *mrdm = get_multires_dm (ob); if(mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) { multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm)); multires_dm_mark_as_modified(mrdm); - multires_force_update(dst); + multires_force_update(ob); + + mrdm->release(mrdm); return 1; } + mrdm->release(mrdm); + return 0; } +/* Returns 1 on success, 0 if the src's totvert doesn't match */ +int multiresModifier_reshape(MultiresModifierData *mmd, Object *dst, Object *src) +{ + DerivedMesh *srcdm = src->derivedFinal; + return multiresModifier_reshapeFromDM(mmd, dst, srcdm); +} + +int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob, ModifierData *md) +{ + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + DerivedMesh *dm, *ndm; + int numVerts, result; + float (*deformedVerts)[3]; + + /* Create DerivedMesh for deformation modifier */ + dm = get_multires_dm(ob); + numVerts= dm->getNumVerts(dm); + deformedVerts= MEM_callocN(sizeof(float)*numVerts*3, "multiresReshape_deformVerts"); + + dm->getVertCos(dm, deformedVerts); + mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0); + + ndm= CDDM_copy(dm); + CDDM_apply_vert_coords(ndm, deformedVerts); + + MEM_freeN(deformedVerts); + dm->release(dm); + + /* Reshaping */ + result= multiresModifier_reshapeFromDM(mmd, ob, ndm); + + /* Cleanup */ + ndm->release(ndm); + + return result; +} + + static void column_vectors_to_mat3(float mat[][3], float v1[3], float v2[3], float v3[3]) { copy_v3_v3(mat[0], v1); -- cgit v1.2.3 From 18fb3aa5bfc2d5cdf0f5319bf59e3c6a82ea33dd Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 13 Apr 2010 19:44:16 +0000 Subject: Fix for [#21983] Entering Particle Edit mode crash --- source/blender/blenkernel/BKE_pointcache.h | 1 + source/blender/blenkernel/intern/pointcache.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 170965a223a..03a86b6566a 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -258,6 +258,7 @@ int BKE_ptcache_data_size(int data_type); /* Memory cache read/write helpers. */ void BKE_ptcache_mem_init_pointers(struct PTCacheMem *pm); void BKE_ptcache_mem_incr_pointers(struct PTCacheMem *pm); +int BKE_ptcache_mem_seek_pointers(int point_index, struct PTCacheMem *pm); /* Copy a specific data type from cache data to point data. */ void BKE_ptcache_data_get(void **data, int type, int index, void *to); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 807e25955a7..6b8d5b3b70f 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1328,7 +1328,7 @@ void BKE_ptcache_mem_incr_pointers(PTCacheMem *pm) pm->cur[i] = (char*)pm->cur[i] + ptcache_data_size[i]; } } -static int BKE_ptcache_mem_seek_pointers(int point_index, PTCacheMem *pm) +int BKE_ptcache_mem_seek_pointers(int point_index, PTCacheMem *pm) { int data_types = pm->data_types; int i, index = pm->index_array ? pm->index_array[point_index] - 1 : point_index; -- cgit v1.2.3 From 953d938ad19bc1dd81267ceb97e418fd84957532 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 13 Apr 2010 20:06:55 +0000 Subject: Testing for the need to quick cache was causing slowdowns on files with many duplis. * The test is now only done when some object that uses cache has actually changed. * The added scene->physics_settings->quick_cache_step is only an internal counter, not a user changeable value. --- source/blender/blenkernel/intern/object.c | 20 +++++++++++++++ source/blender/blenkernel/intern/pointcache.c | 37 ++------------------------- source/blender/blenkernel/intern/scene.c | 6 +++-- 3 files changed, 26 insertions(+), 37 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ac679adb9c1..ef630a18ab4 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2489,6 +2489,8 @@ void object_handle_update(Scene *scene, Object *ob) ID *data_id= (ID *)ob->data; AnimData *adt= BKE_animdata_from_id(data_id); float ctime= (float)scene->r.cfra; // XXX this is bad... + ListBase pidlist; + PTCacheID *pid; if (G.f & G_DEBUG) printf("recalcdata %s\n", ob->id.name+2); @@ -2577,6 +2579,24 @@ void object_handle_update(Scene *scene, Object *ob) psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated; } } + + /* check if quick cache is needed */ + BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); + + for(pid=pidlist.first; pid; pid=pid->next) { + if((pid->cache->flag & PTCACHE_BAKED) + || (pid->cache->flag & PTCACHE_QUICK_CACHE)==0) + continue; + + if(pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) { + scene->physics_settings.quick_cache_step = + scene->physics_settings.quick_cache_step ? + MIN2(scene->physics_settings.quick_cache_step, pid->cache->step) : + pid->cache->step; + } + } + + BLI_freelistN(&pidlist); } /* the no-group proxy case, we call update */ diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 6b8d5b3b70f..515d1f820aa 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2325,39 +2325,6 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old /* Baking */ -static int count_quick_cache(Scene *scene, int *quick_step) -{ - Base *base; - PTCacheID *pid; - ListBase pidlist; - int autocache_count= 0; - Scene *sce; /* for macro only */ - - for(SETLOOPER(scene, base)) { - if(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) - || (pid->cache->flag & PTCACHE_QUICK_CACHE)==0) - continue; - - if(pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) { - if(!autocache_count) - *quick_step = pid->cache->step; - else - *quick_step = MIN2(*quick_step, pid->cache->step); - - autocache_count++; - } - } - - BLI_freelistN(&pidlist); - } - } - - return autocache_count; -} void BKE_ptcache_quick_cache_all(Scene *scene) { PTCacheBaker baker; @@ -2372,9 +2339,9 @@ void BKE_ptcache_quick_cache_all(Scene *scene) baker.render=0; baker.anim_init = 0; baker.scene=scene; + baker.quick_step=scene->physics_settings.quick_cache_step; - if(count_quick_cache(scene, &baker.quick_step)) - BKE_ptcache_make_cache(&baker); + BKE_ptcache_make_cache(&baker); } /* Simulation thread, no need for interlocks as data written in both threads diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index fc6b7e7d789..e5d9686a18d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -924,6 +924,8 @@ void scene_update_tagged(Scene *scene) Object *ob; float ctime = frame_to_float(scene, scene->r.cfra); + scene->physics_settings.quick_cache_step= 0; + /* update all objects: drivers, matrices, displists, etc. flags set by depgraph or manual, no layer check here, gets correct flushed */ @@ -957,8 +959,8 @@ 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); + if(scene->physics_settings.quick_cache_step) + BKE_ptcache_quick_cache_all(scene); /* in the future this should handle updates for all datablocks, not only objects and scenes. - brecht */ -- cgit v1.2.3 From 582f1621e53de507c679af1b6460bf8466ac817e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 13 Apr 2010 22:11:01 +0000 Subject: there were duplicate modifier init's, harmless but better remove. --- source/blender/blenkernel/intern/modifier.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index cf065bb3467..6b46fbe575b 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -83,10 +83,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) INIT_TYPE(MeshDeform); INIT_TYPE(ParticleSystem); INIT_TYPE(ParticleInstance); - INIT_TYPE(Explode); - INIT_TYPE(Cloth); - INIT_TYPE(Collision); - INIT_TYPE(Bevel); + INIT_TYPE(Explode); INIT_TYPE(Shrinkwrap); INIT_TYPE(Fluidsim); INIT_TYPE(Mask); -- cgit v1.2.3 From 43500c9e140ed44aa2e5c29208bb87196a9dad75 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 14 Apr 2010 07:47:04 +0000 Subject: Fix [#22005] Duplicated Point Density textures remain somewhat linked --- source/blender/blenkernel/intern/texture.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 48f819a7091..c13e48e8f01 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -620,6 +620,8 @@ Tex *copy_texture(Tex *tex) if(texn->coba) texn->coba= MEM_dupallocN(texn->coba); if(texn->env) texn->env= BKE_copy_envmap(texn->env); + if(texn->pd) texn->pd= MEM_dupallocN(texn->pd); + if(texn->vd) texn->vd= MEM_dupallocN(texn->vd); if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); -- cgit v1.2.3 From b47c91f87c2bd924910b39c77da15407a2c081c5 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Wed, 14 Apr 2010 15:50:56 +0000 Subject: SVN maintenance. --- source/blender/blenkernel/BKE_utildefines.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 43ae66a0bfc..51d915cca18 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -1,6 +1,5 @@ /* - $Id$ - + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * -- cgit v1.2.3 From 2b018673509fe7a38a6332fae00bd605335bd286 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 15 Apr 2010 04:56:44 +0000 Subject: Fix [#22029] Camera in degree mode doesn't update Removed the camera->angle from DNA, now it just uses RNA to handle the conversions. Really need to convert this to physical units at some point... :/ --- source/blender/blenkernel/BKE_object.h | 3 +++ source/blender/blenkernel/intern/object.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 065d747a959..9930ad175a7 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -77,6 +77,9 @@ void *add_camera(char *name); struct Camera *copy_camera(struct Camera *cam); void make_local_camera(struct Camera *cam); float dof_camera(struct Object *ob); +float camera_get_angle(struct Camera *cam); +void camera_set_angle(struct Camera *cam, float angle); + void *add_lamp(char *name); struct Lamp *copy_lamp(struct Lamp *la); void make_local_lamp(struct Lamp *la); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ef630a18ab4..f05239057b9 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -679,7 +679,6 @@ void *add_camera(char *name) cam= alloc_libblock(&G.main->camera, ID_CA, name); cam->lens= 35.0f; - cam->angle= 49.14f; cam->clipsta= 0.1f; cam->clipend= 100.0f; cam->drawsize= 0.5f; @@ -774,6 +773,17 @@ float dof_camera(Object *ob) return cam->YF_dofdist; } +/* angle in radians */ +float camera_get_angle(Camera *cam) +{ + return 2.f * atan(16.0f/cam->lens); +} + +void camera_set_angle(Camera *cam, float angle) +{ + cam->lens = 16.0f / tan(angle * 0.5f); +} + void *add_lamp(char *name) { Lamp *la; -- cgit v1.2.3 From 9a85013692322f8a821b8228ad552f84d2a215e9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 15 Apr 2010 10:28:32 +0000 Subject: Merge various small changes from render branch: * Division by zero fix for TNT SVD code. * Sound fix, in case ffmpeg decode fails, don't use the samples. * Fix for incorrect bounds of transformed objects in new raytracing code. * Gave memory arena's a name used for allocations for easier memory usage debugging. * Dupligroup no_draw option was using layers but not restrict view/render setting. (not a bugfix exactly but would do display list context switching while drawing for no reason). * Fix objects instanced on hair particles not giving consistent results when the object is transformed. * New math functions: madd_v4_v4fl, len_squared_v3v3, interp_v4_v4v4v4, mul_v4_m4v4, SH and form factor functions, box_minmax_bounds_m4. * mul_m4_m4m4 and mul_m3_m3m3 now accept the same pointers for multiple arguments. * endjob callback for WM jobs system. * Geometry node uv/color layer now has search list/autocomplete. * Various small buildsystem tweaks, not strictly needed yet in trunk. --- source/blender/blenkernel/BKE_group.h | 1 + source/blender/blenkernel/intern/BME_tools.c | 2 +- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/anim.c | 16 +++++++++++++--- source/blender/blenkernel/intern/depsgraph.c | 2 ++ source/blender/blenkernel/intern/image.c | 2 +- source/blender/blenkernel/intern/particle.c | 20 ++++++++++++-------- source/blender/blenkernel/intern/subsurf_ccg.c | 2 +- 8 files changed, 32 insertions(+), 15 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index d1491cc1616..e63e3c93f1e 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -31,6 +31,7 @@ #ifndef BKE_GROUP_H #define BKE_GROUP_H +struct Base; struct Group; struct GroupObject; struct Object; diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 9753ad47488..b4919dd8cf3 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -50,7 +50,7 @@ BME_TransData_Head *BME_init_transdata(int bufsize) { td = MEM_callocN(sizeof(BME_TransData_Head), "BMesh transdata header"); td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp); - td->ma = BLI_memarena_new(bufsize); + td->ma = BLI_memarena_new(bufsize, "BME_TransData arena"); BLI_memarena_use_calloc(td->ma); return td; diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 44757a09d42..aa9974a7e20 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2489,7 +2489,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) tangent= DM_get_face_data_layer(dm, CD_TANGENT); /* allocate some space */ - arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE); + arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "tangent layer arena"); BLI_memarena_use_calloc(arena); vtangents= MEM_callocN(sizeof(VertexTangent*)*totvert, "VertexTangent"); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index b687062fe15..77b6f5b481f 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -646,8 +646,18 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i } dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated); - dob->no_draw= (dob->origlay & group->layer)==0; - + + /* check the group instance and object layers match, also that the object visible flags are ok. */ + if( (dob->origlay & group->layer)==0 || + (G.rendering==0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) || + (G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER) + ) { + dob->no_draw= 1; + } + else { + dob->no_draw= 0; + } + if(go->ob->transflag & OB_DUPLI) { copy_m4_m4(dob->ob->obmat, dob->mat); object_duplilist_recursive((ID *)group, scene, go->ob, lb, ob->obmat, level+1, animated); @@ -1003,7 +1013,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa copy_m4_m4(tmat, obmat); mul_m4_m4m3(obmat, tmat, mat); - dob= new_dupli_object(lb, ob, obmat, lay, a, OB_DUPLIFACES, animated); + dob= new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIFACES, animated); if(G.rendering) { w= (mv4)? 0.25f: 1.0f/3.0f; diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 86cafa733ff..f63e28fb464 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2237,6 +2237,8 @@ void DAG_on_load_update(void) for(go= group->gobject.first; go; go= go->next) { if(ELEM5(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) go->ob->recalc |= OB_RECALC_DATA; + if(go->ob->proxy_from) + go->ob->recalc |= OB_RECALC_OB; } group->id.flag &= ~LIB_DOIT; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 55dcc38ebcf..7d194461c78 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1,4 +1,4 @@ -/* image.c +/* image.c * * $Id$ * diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 7ad65820bbe..d41ede22006 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4215,18 +4215,11 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa ParticleSystem *psys = sim->psys; ParticleSystemModifierData *psmd = sim->psmd; float loc[3], nor[3], vec[3], side[3], len, obrotmat[4][4], qmat[4][4]; - float xvec[3] = {-1.0, 0.0, 0.0}, q[4]; + float xvec[3] = {-1.0, 0.0, 0.0}, q[4], nmat[3][3]; sub_v3_v3v3(vec, (cache+cache->steps-1)->co, cache->co); len= normalize_v3(vec); - if(pa) - psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0); - else - psys_particle_on_emitter(psmd, - (psys->part->childtype == PART_CHILD_FACES)? PART_FROM_FACE: PART_FROM_PARTICLE, - cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0); - if(psys->part->rotmode) { if(!pa) pa= psys->particles+cpa->pa[0]; @@ -4239,6 +4232,17 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa mul_m4_m4m4(mat, obrotmat, qmat); } else { + if(pa) + psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0); + else + psys_particle_on_emitter(psmd, + (psys->part->childtype == PART_CHILD_FACES)? PART_FROM_FACE: PART_FROM_PARTICLE, + cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0); + + copy_m3_m4(nmat, ob->imat); + transpose_m3(nmat); + mul_m3_v3(nmat, nor); + /* make sure that we get a proper side vector */ if(fabs(dot_v3v3(nor,vec))>0.999999) { if(fabs(dot_v3v3(nor,xvec))>0.999999) { diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 3972355d302..16cb671f2d0 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -117,7 +117,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAgin if (useArena) { CCGAllocatorIFC allocatorIFC; - CCGAllocatorHDL allocator = BLI_memarena_new((1<<16)); + CCGAllocatorHDL allocator = BLI_memarena_new((1<<16), "subsurf arena"); allocatorIFC.alloc = arena_alloc; allocatorIFC.realloc = arena_realloc; -- cgit v1.2.3 From 7c7d93e664762e0ee4756c464e0e9c5cf6073957 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 15 Apr 2010 21:58:49 +0000 Subject: fix for own mistake, from r27961. --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 515d1f820aa..ab4750a28d2 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2434,7 +2434,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache->flag &= ~PTCACHE_BAKED; } } - for(SETLOOPER(scene, base)) { + else for(SETLOOPER(scene, base)) { /* cache/bake everything in the scene */ BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); -- cgit v1.2.3 From 3afd8d6cc859255d0b52081fbee91b6c6a012b4c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Apr 2010 08:55:31 +0000 Subject: move camera lens/angle conversion to BLI_math --- source/blender/blenkernel/BKE_object.h | 2 -- source/blender/blenkernel/intern/object.c | 11 ----------- 2 files changed, 13 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 9930ad175a7..07c3da48792 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -77,8 +77,6 @@ void *add_camera(char *name); struct Camera *copy_camera(struct Camera *cam); void make_local_camera(struct Camera *cam); float dof_camera(struct Object *ob); -float camera_get_angle(struct Camera *cam); -void camera_set_angle(struct Camera *cam, float angle); void *add_lamp(char *name); struct Lamp *copy_lamp(struct Lamp *la); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f05239057b9..6939ff02a47 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -773,17 +773,6 @@ float dof_camera(Object *ob) return cam->YF_dofdist; } -/* angle in radians */ -float camera_get_angle(Camera *cam) -{ - return 2.f * atan(16.0f/cam->lens); -} - -void camera_set_angle(Camera *cam, float angle) -{ - cam->lens = 16.0f / tan(angle * 0.5f); -} - void *add_lamp(char *name) { Lamp *la; -- cgit v1.2.3 From 392e1da1790d252f0f156379c1d5507959a4e17a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Apr 2010 15:47:00 +0000 Subject: bugfix and cleanup - BGE Shader.setSampler(name, index): index range check was wrong. - Compositor check for an invalid channel was incorrect. - getting the center of selected verts used an uninitalized z axis. - do_init_render_material() used && rather then & when testing for MA_TRANSP. - weight paint activate flipped bone used && rather then & for flag checking. --- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 71be2ce7b78..a973c33ca54 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -445,7 +445,7 @@ static int mdisp_corners(MDisps *s) return (s->totdisp % (3*3) == 0)? 3: 4; } -static void layerSwap_mdisps(void *data, int *ci) +static void layerSwap_mdisps(void *data, const int *ci) { MDisps *s = data; float (*d)[3] = NULL; diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 3b17ac1db1a..f3096cdf8f2 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -730,7 +730,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) /* since the raytracer doesnt recalc O structs for each ray, we have to preset them all */ if(r_mode & R_RAYTRACE) { - if((ma->mode & (MA_RAYMIRROR|MA_SHADOW_TRA)) || ((ma->mode && MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) { + if((ma->mode & (MA_RAYMIRROR|MA_SHADOW_TRA)) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) { ma->texco |= NEED_UV|TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM; if(r_mode & R_OSA) ma->texco |= TEXCO_OSA; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index d41ede22006..c4888dedf48 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -396,7 +396,7 @@ void free_hair(Object *ob, ParticleSystem *psys, int dynamics) if(dynamics) { BKE_ptcache_free_list(&psys->ptcaches); psys->clmd->point_cache = psys->pointcache = NULL; - psys->clmd->ptcaches.first = psys->clmd->ptcaches.first = NULL; + psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL; modifier_free((ModifierData*)psys->clmd); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 389b31a20c7..720bf3b2a47 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2385,7 +2385,7 @@ void particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings 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 dtime = dfra*psys_get_timestep(sim); float particle_mass = part->mass; particle_fluidsim(psys, pa, part, sim, dfra, cfra, particle_mass); @@ -3688,7 +3688,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) PARTICLE_P; int oldtotpart; float disp, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; - int init= 0, emit= 0, only_children_changed= 0; + int init= 0, emit= 0; //, only_children_changed= 0; int framenr, framedelta, startframe = 0, endframe = 100; framenr= (int)sim->scene->r.cfra; -- cgit v1.2.3 From 45441c07d4609493aecf265b64ad0c108722e9db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Apr 2010 09:12:18 +0000 Subject: various minor fixes - collada export would run MEM_freeN on an un-initialized pointer in some cases. - makesrna was missing a call to close a file. - text cursor update function was missing a NULL check for st->text. - possible (unlikely) un-initialized return value for bge python lamp.type, set error instead. - possible (unlikely) missing NULL terminator with strncpy for ffmpeg. --- source/blender/blenkernel/intern/writeffmpeg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index ff6ebcc487f..a1cdced9074 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -382,7 +382,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop) fprintf(stderr, "FFMPEG expert option: %s: ", prop->name); - strncpy(name, prop->name, 128); + BLI_strncpy(name, prop->name, sizeof(name)); param = strchr(name, ':'); @@ -1078,7 +1078,7 @@ int ffmpeg_property_add_string(RenderData *rd, const char * type, const char * s avcodec_get_context_defaults(&c); - strncpy(name_, str, 128); + strncpy(name_, str, sizeof(name_)); name = name_; while (*name == ' ') name++; -- cgit v1.2.3 From 8f1500da005e4f84fd593492822c6d99e768c354 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Apr 2010 10:28:37 +0000 Subject: remove config.h references, was added for automake build system rev around 124-126 but isnt used by any build systems now. --- source/blender/blenkernel/intern/DerivedMesh.c | 4 ---- source/blender/blenkernel/intern/action.c | 4 ---- source/blender/blenkernel/intern/anim.c | 4 ---- source/blender/blenkernel/intern/armature.c | 4 ---- source/blender/blenkernel/intern/bmfont.c | 4 ---- source/blender/blenkernel/intern/constraint.c | 4 ---- source/blender/blenkernel/intern/curve.c | 4 ---- source/blender/blenkernel/intern/deform.c | 4 ---- source/blender/blenkernel/intern/fcurve.c | 4 ---- source/blender/blenkernel/intern/fmodifier.c | 4 ---- source/blender/blenkernel/intern/font.c | 4 ---- source/blender/blenkernel/intern/group.c | 4 ---- source/blender/blenkernel/intern/icons.c | 4 ---- source/blender/blenkernel/intern/ipo.c | 4 ---- source/blender/blenkernel/intern/key.c | 4 ---- source/blender/blenkernel/intern/library.c | 4 ---- source/blender/blenkernel/intern/mball.c | 4 ---- source/blender/blenkernel/intern/mesh.c | 4 ---- source/blender/blenkernel/intern/nla.c | 4 ---- source/blender/blenkernel/intern/object.c | 4 ---- source/blender/blenkernel/intern/packedFile.c | 4 ---- source/blender/blenkernel/intern/property.c | 4 ---- source/blender/blenkernel/intern/sca.c | 4 ---- source/blender/blenkernel/intern/scene.c | 4 ---- source/blender/blenkernel/intern/sound.c | 4 ---- source/blender/blenkernel/intern/text.c | 4 ---- source/blender/blenkernel/intern/world.c | 4 ---- source/blender/blenkernel/intern/writeffmpeg.c | 4 ---- source/blender/blenkernel/intern/writeframeserver.c | 4 ---- 29 files changed, 116 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index aa9974a7e20..36cf19364ef 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -29,10 +29,6 @@ #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index fc7b22fa63e..1040784284f 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -26,10 +26,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 77b6f5b481f..10608dc676c 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -64,10 +64,6 @@ #include "BKE_scene.h" #include "BKE_utildefines.h" -#ifdef HAVE_CONFIG_H -#include -#endif - // XXX bad level call... /* --------------------- */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index c1998d705ad..aec6ab6a139 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -65,10 +65,6 @@ #include "BIK_api.h" #include "BKE_sketch.h" -#ifdef HAVE_CONFIG_H -#include -#endif - /* **************** Generic Functions, data level *************** */ bArmature *add_armature(char *name) diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index 5f6a4278549..1b053b45859 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -56,10 +56,6 @@ #include "BKE_bmfont_types.h" -#ifdef HAVE_CONFIG_H -#include -#endif - void printfGlyph(bmGlyph * glyph) { printf("unicode: %d '%c'\n", glyph->unicode, glyph->unicode); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index af0b462c349..9566fa82861 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -73,10 +73,6 @@ #include "BPY_extern.h" #endif -#ifdef HAVE_CONFIG_H -#include -#endif - #ifndef M_PI #define M_PI 3.14159265358979323846 #endif diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index c87495d499e..dff936deaec 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -34,10 +34,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_math.h" diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 0ae8169cc67..d9ba6cd6a9d 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -45,10 +45,6 @@ #include "BLI_blenlib.h" -#ifdef HAVE_CONFIG_H -#include -#endif - void defgroup_copy_list (ListBase *outbase, ListBase *inbase) { diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 9bbb6e7b7b6..619bb1a58f9 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -34,10 +34,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index d4a5b5b2531..868b06f2348 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -32,10 +32,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 9b8c05ac88c..907c848ebd5 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -35,10 +35,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" #include "BLI_math.h" diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 5f35ab87cb2..6a807abc396 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -48,10 +48,6 @@ #include "BKE_object.h" #include "BKE_scene.h" /* object_in_scene */ -#ifdef HAVE_CONFIG_H -#include -#endif - static void free_group_object(GroupObject *go) { MEM_freeN(go); diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 5580c73099e..a9582506cee 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -32,10 +32,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" #include "DNA_lamp_types.h" diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index cd3326857c7..50574f1ef7b 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -41,10 +41,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 31b0a809ebe..f604d307551 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -60,10 +60,6 @@ #include "RNA_access.h" -#ifdef HAVE_CONFIG_H -#include -#endif - #define KEY_BPOINT 1 #define KEY_BEZTRIPLE 2 diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 8605cf51b68..cfee7dd9f61 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -40,10 +40,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" /* all types are needed here, in order to do memory operations */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 98578312766..3acc46967be 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -62,10 +62,6 @@ #include "BKE_mball.h" #include "BKE_object.h" -#ifdef HAVE_CONFIG_H -#include -#endif - /* Global variables */ static float thresh= 0.6f; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 9e8767406b1..fd4a8a00216 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -29,10 +29,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index ab2a6f713cb..902d6b8e9bf 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -52,10 +52,6 @@ #include "nla_private.h" -#ifdef HAVE_CONFIG_H -#include -#endif - /* *************************************************** */ /* Data Management */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6939ff02a47..cd86ac04337 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -33,10 +33,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index b62f856e1f3..0c50cea075d 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -33,10 +33,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #ifndef WIN32 #include #else diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index 1129cc9d736..a2ba7c69b93 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -35,10 +35,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" #include "DNA_property_types.h" diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index e32f5aac517..060c9312f99 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -29,10 +29,6 @@ * all data is 'direct data', not Blender lib data. */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index e5d9686a18d..faabaf4f91f 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -33,10 +33,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include -#endif - #ifndef WIN32 #include #else diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 7308146ef92..fc003b12959 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -30,10 +30,6 @@ #include "BKE_animsys.h" -#ifdef HAVE_CONFIG_H -#include -#endif - static int force_device = -1; #ifdef WITH_JACK diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 98ff0b2da1a..f1036b66f69 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -55,10 +55,6 @@ #include "BPY_extern.h" #endif -#ifdef HAVE_CONFIG_H -#include -#endif - /***************/ /* How Texts should work diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 1e1e41a07e7..fa8c8188f54 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -47,10 +47,6 @@ #include "BPY_extern.h" #endif -#ifdef HAVE_CONFIG_H -#include -#endif - void free_world(World *wrld) { MTex *mtex; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index a1cdced9074..57d6c91c3dd 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -69,10 +69,6 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#ifdef HAVE_CONFIG_H -#include -#endif - extern void do_init_ffmpeg(); static int ffmpeg_type = 0; diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index a7b6bcf3a09..0ec8837c0e7 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -54,10 +54,6 @@ #include "DNA_scene_types.h" -#ifdef HAVE_CONFIG_H -#include -#endif - static int sock; static int connsock; static int write_ppm; -- cgit v1.2.3 From 153081accdc6c8d5779b1d13e1d25555682b9e44 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 18 Apr 2010 13:25:51 +0000 Subject: Applied: [#21390] Sequencer: Shifted frames on Time Flip/Flip Backwards thanks to Koen Ribus(kori) for the patch. --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 3cfbbd8ae6f..15549c83691 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1024,7 +1024,7 @@ static int give_stripelem_index(Sequence *seq, int cfra) /*reverse frame in this sequence */ if(cfra <= seq->start) nr= seq->len-1; else if(cfra >= seq->start+seq->len-1) nr= 0; - else nr= (seq->start + seq->len) - cfra; + else nr= (seq->start + seq->len - 1) - cfra; } else { if(cfra <= seq->start) nr= 0; else if(cfra >= seq->start+seq->len-1) nr= seq->len-1; -- cgit v1.2.3 From 4fde9823fdfe323de4c8d3b76aa75d98ef9362a6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Apr 2010 14:47:45 +0000 Subject: possible fix for [#22057] Autoname L/R in bones names center bones as .R Bone would get a '.' added even when there was no extension. (center limit would still be useful) - name flipping function used sizeof() incorrectly. - ED_lorem should be extern. --- source/blender/blenkernel/BKE_armature.h | 2 +- source/blender/blenkernel/intern/armature.c | 10 ++++++++-- source/blender/blenkernel/intern/deform.c | 8 ++++---- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 7e3d7f2a2ce..2c661a74573 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -81,7 +81,7 @@ void make_local_armature(struct bArmature *arm); struct bArmature *copy_armature(struct bArmature *arm); void bone_flip_name (char *name, int strip_number); -void bone_autoside_name (char *name, int strip_number, short axis, float head, float tail); +int bone_autoside_name (char *name, int strip_number, short axis, float head, float tail); struct Bone *get_named_bone (struct bArmature *arm, const char *name); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index aec6ab6a139..04d5acb11cc 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -361,7 +361,7 @@ void bone_flip_name (char *name, int strip_number) * axis: the axis to name on * head/tail: the head/tail co-ordinate of the bone on the specified axis */ -void bone_autoside_name (char *name, int strip_number, short axis, float head, float tail) +int bone_autoside_name (char *name, int strip_number, short axis, float head, float tail) { unsigned int len; char basename[32]={""}; @@ -462,9 +462,15 @@ void bone_autoside_name (char *name, int strip_number, short axis, float head, f if ((32 - len) < strlen(extension) + 1) { /* add 1 for the '.' */ strncpy(name, basename, len-strlen(extension)); } + + sprintf(name, "%s.%s", basename, extension); + + return 1; } - sprintf(name, "%s.%s", basename, extension); + else { + return 0; + } } /* ************* B-Bone support ******************* */ diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index d9ba6cd6a9d..fecafc701a6 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -364,10 +364,10 @@ void defgroup_unique_name (bDeformGroup *dg, Object *ob) void flip_side_name (char *name, const char *from_name, int strip_number) { int len; - char prefix[sizeof((bDeformGroup *)NULL)->name]={""}; /* The part before the facing */ - char suffix[sizeof((bDeformGroup *)NULL)->name]={""}; /* The part after the facing */ - char replace[sizeof((bDeformGroup *)NULL)->name]={""}; /* The replacement string */ - char number[sizeof((bDeformGroup *)NULL)->name]={""}; /* The number extension string */ + char prefix[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The part before the facing */ + char suffix[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The part after the facing */ + char replace[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The replacement string */ + char number[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The number extension string */ char *index=NULL; len= strlen(from_name); -- cgit v1.2.3 From f1eab048d3e79dc7d855b8c495e595ff3d9ffd04 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 18 Apr 2010 14:48:53 +0000 Subject: == Sequencer == Removed seqrectx and seqrecty global variables. --- source/blender/blenkernel/intern/sequencer.c | 131 +++++++++++++++------------ 1 file changed, 72 insertions(+), 59 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 15549c83691..d6bb5cc3745 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -69,8 +69,6 @@ #endif /* **** XXX ******** */ -static int seqrectx= 0; /* bad bad global! */ -static int seqrecty= 0; //static void waitcursor(int val) {} //static int blender_test_break() {return 0;} @@ -1328,7 +1326,7 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, int build_proxy_run, int render_size); -static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int render_size) +static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int render_size, int seqrectx, int seqrecty) { char name[PROXY_MAXFILE]; int quality; @@ -1365,7 +1363,8 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re se->ibuf = 0; } - do_build_seq_ibuf(scene, seq, se, cfra, TRUE, render_size); + do_build_seq_ibuf(scene, seq, se, cfra, TRUE, render_size, + seqrectx, seqrecty); if (!se->ibuf) { return; @@ -1399,7 +1398,8 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re se->ibuf = 0; } -static void seq_proxy_rebuild(Scene *scene, Sequence * seq) +static void seq_proxy_rebuild(Scene *scene, Sequence * seq, int seqrectx, + int seqrecty) { int cfra; float rsize = seq->strip->proxy->size; @@ -1431,7 +1431,8 @@ static void seq_proxy_rebuild(Scene *scene, Sequence * seq) if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) { //XXX set_timecursor(cfra); - seq_proxy_build_frame(scene, seq, cfra, rsize); + seq_proxy_build_frame(scene, seq, cfra, rsize, + seqrectx, seqrecty); tse->flag |= STRIPELEM_PREVIEW_DONE; } if (blender_test_break()) { @@ -1445,7 +1446,8 @@ static void seq_proxy_rebuild(Scene *scene, Sequence * seq) if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) { //XXX set_timecursor(cfra); - seq_proxy_build_frame(scene, seq, cfra, rsize); + seq_proxy_build_frame(scene, seq, cfra, rsize, + seqrectx, seqrecty); tse->flag |= STRIPELEM_PREVIEW_DONE; } if (blender_test_break()) { @@ -1638,7 +1640,7 @@ static void color_balance(Sequence * seq, TStripElem* se, float mul) */ -static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se, int cfra) +static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se, int cfra, int seqrectx, int seqrecty) { float mul; @@ -1667,7 +1669,7 @@ static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se return FALSE; } -static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cfra) +static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cfra, int seqrectx, int seqrecty) { float mul; @@ -1790,7 +1792,8 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf /* test if image too small or discarded from cache: reload */ -static void test_and_auto_discard_ibuf(TStripElem * se) +static void test_and_auto_discard_ibuf(TStripElem * se, + int seqrectx, int seqrecty) { if (se->ibuf) { if(se->ibuf->x != seqrectx || se->ibuf->y != seqrecty @@ -1931,16 +1934,18 @@ static void check_limiter_refcount_comp(const char * func, TStripElem *se) } } -static TStripElem* do_build_seq_array_recursively(Scene *scene, - ListBase *seqbasep, int cfra, int chanshown, int render_size); +static TStripElem* do_build_seq_array_recursively( + Scene *scene, + ListBase *seqbasep, int cfra, int chanshown, int render_size, + int seqrectx, int seqrecty); static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, - int build_proxy_run, int render_size) + int build_proxy_run, int render_size, int seqrectx, int seqrecty) { char name[FILE_MAXDIR+FILE_MAXFILE]; int use_limiter = TRUE; - test_and_auto_discard_ibuf(se); + test_and_auto_discard_ibuf(se, seqrectx, seqrecty); test_and_auto_discard_ibuf_stills(seq->strip); if(seq->type == SEQ_META) { @@ -1959,7 +1964,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if(!se->ibuf && seq->seqbase.first) { meta_se = do_build_seq_array_recursively(scene, &seq->seqbase, seq->start + se->nr, 0, - render_size); + render_size, seqrectx, seqrecty); check_limiter_refcount("do_build_seq_ibuf: for META", meta_se); } @@ -1969,7 +1974,8 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if(!se->ibuf && meta_se) { se->ibuf = meta_se->ibuf_comp; if(se->ibuf && - (!input_have_to_preprocess(scene, seq, se, cfra) || + (!input_have_to_preprocess(scene, seq, se, cfra, + seqrectx, seqrecty) || build_proxy_run)) { IMB_refImBuf(se->ibuf); if (build_proxy_run) { @@ -1994,7 +2000,8 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int } if (use_preprocess) { - input_preprocess(scene, seq, se, cfra); + input_preprocess(scene, seq, se, cfra, seqrectx, + seqrecty); } } else if(seq->type & SEQ_EFFECT) { int use_preprocess = FALSE; @@ -2017,7 +2024,8 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect, 0); do_effect(scene, cfra, seq, se); - if (input_have_to_preprocess(scene, seq, se, cfra) && + if (input_have_to_preprocess(scene, seq, se, cfra, + seqrectx, seqrecty) && !build_proxy_run) { if ((se->se1 && (se->ibuf == se->se1->ibuf)) || (se->se2 && (se->ibuf == se->se2->ibuf))) { @@ -2032,7 +2040,8 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int } } if (use_preprocess) { - input_preprocess(scene, seq, se, cfra); + input_preprocess(scene, seq, se, cfra, seqrectx, + seqrecty); } } else if(seq->type == SEQ_IMAGE) { if(se->ok == STRIPELEM_OK && se->ibuf == 0) { @@ -2059,7 +2068,8 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if(se->ibuf == 0) { se->ok = STRIPELEM_FAILED; } else if (!build_proxy_run) { - input_preprocess(scene, seq, se, cfra); + input_preprocess(scene, seq, se, cfra, + seqrectx, seqrecty); } } } else if(seq->type == SEQ_MOVIE) { @@ -2096,7 +2106,8 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if(se->ibuf == 0) { se->ok = STRIPELEM_FAILED; } else if (!build_proxy_run) { - input_preprocess(scene, seq, se, cfra); + input_preprocess(scene, seq, se, cfra, + seqrectx, seqrecty); } } } else if(seq->type == SEQ_SCENE) { // scene can be NULL after deletions @@ -2112,14 +2123,16 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if (se->ibuf == NULL && sce_valid && !build_proxy_run) { se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); if (se->ibuf) { - input_preprocess(scene, seq, se, cfra); + input_preprocess(scene, seq, se, cfra, + seqrectx, seqrecty); } } if (se->ibuf == NULL && sce_valid) { copy_from_ibuf_still(seq, se); if (se->ibuf) { - input_preprocess(scene, seq, se, cfra); + input_preprocess(scene, seq, se, cfra, + seqrectx, seqrecty); } } @@ -2214,7 +2227,8 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if(se->ibuf == NULL) { se->ok = STRIPELEM_FAILED; } else { - input_preprocess(scene, seq, se, cfra); + input_preprocess(scene, seq, se, cfra, + seqrectx, seqrecty); } } @@ -2229,9 +2243,9 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int } } -static TStripElem* do_build_seq_recursively(Scene *scene, Sequence *seq, int cfra, int render_size); +static TStripElem* do_build_seq_recursively(Scene *scene, Sequence *seq, int cfra, int render_size, int seqrectx, int seqrecty); -static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *se, int cfra, int render_size) +static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *se, int cfra, int render_size, int seqrectx, int seqrecty) { float fac, facf; struct SeqEffectHandle sh = get_sequence_effect(seq); @@ -2264,22 +2278,22 @@ static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *s /* no input needed */ break; case 0: - se->se1 = do_build_seq_recursively(scene, seq->seq1, cfra, render_size); - se->se2 = do_build_seq_recursively(scene, seq->seq2, cfra, render_size); + se->se1 = do_build_seq_recursively(scene, seq->seq1, cfra, render_size, seqrectx, seqrecty); + se->se2 = do_build_seq_recursively(scene, seq->seq2, cfra, render_size, seqrectx, seqrecty); if (seq->seq3) { - se->se3 = do_build_seq_recursively(scene, seq->seq3, cfra, render_size); + se->se3 = do_build_seq_recursively(scene, seq->seq3, cfra, render_size, seqrectx, seqrecty); } break; case 1: - se->se1 = do_build_seq_recursively(scene, seq->seq1, cfra, render_size); + se->se1 = do_build_seq_recursively(scene, seq->seq1, cfra, render_size, seqrectx, seqrecty); break; case 2: - se->se2 = do_build_seq_recursively(scene, seq->seq2, cfra, render_size); + se->se2 = do_build_seq_recursively(scene, seq->seq2, cfra, render_size, seqrectx, seqrecty); break; } - do_build_seq_ibuf(scene, seq, se, cfra, FALSE, render_size); + do_build_seq_ibuf(scene, seq, se, cfra, FALSE, render_size, seqrectx, seqrecty); /* children are not needed anymore ... */ @@ -2295,7 +2309,7 @@ static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *s check_limiter_refcount("do_effect_seq_recursively", se); } -static TStripElem* do_build_seq_recursively_impl(Scene *scene, Sequence * seq, int cfra, int render_size) +static TStripElem* do_build_seq_recursively_impl(Scene *scene, Sequence * seq, int cfra, int render_size, int seqrectx, int seqrecty) { TStripElem *se; @@ -2303,9 +2317,9 @@ static TStripElem* do_build_seq_recursively_impl(Scene *scene, Sequence * seq, i if(se) { if (seq->type & SEQ_EFFECT) { - do_effect_seq_recursively(scene, seq, se, cfra, render_size); + do_effect_seq_recursively(scene, seq, se, cfra, render_size, seqrectx, seqrecty); } else { - do_build_seq_ibuf(scene, seq, se, cfra, FALSE, render_size); + do_build_seq_ibuf(scene, seq, se, cfra, FALSE, render_size, seqrectx, seqrecty); } } return se; @@ -2319,7 +2333,7 @@ instead of faking using the blend code below... */ -static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra, int render_size) +static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra, int render_size, int seqrectx, int seqrecty) { SpeedControlVars * s = (SpeedControlVars *)seq->effectdata; int nr = cfra - seq->start; @@ -2345,10 +2359,10 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra if (cfra_left == cfra_right || (s->flags & SEQ_SPEED_BLEND) == 0) { - test_and_auto_discard_ibuf(se); + test_and_auto_discard_ibuf(se, seqrectx, seqrecty); if (se->ibuf == NULL) { - se1 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_left, render_size); + se1 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_left, render_size, seqrectx, seqrecty); if((se1 && se1->ibuf && se1->ibuf->rect_float)) se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); @@ -2380,8 +2394,8 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra } if (se->ibuf == NULL) { - se1 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_left, render_size); - se2 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_right, render_size); + se1 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_left, render_size, seqrectx, seqrecty); + se2 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_right, render_size, seqrectx, seqrecty); if((se1 && se1->ibuf && se1->ibuf->rect_float)) se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); @@ -2433,13 +2447,13 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra * */ -static TStripElem* do_build_seq_recursively(Scene *scene, Sequence * seq, int cfra, int render_size) +static TStripElem* do_build_seq_recursively(Scene *scene, Sequence * seq, int cfra, int render_size, int seqrectx, int seqrecty) { TStripElem *se; if (seq->type == SEQ_SPEED) { - se = do_handle_speed_effect(scene, seq, cfra, render_size); + se = do_handle_speed_effect(scene, seq, cfra, render_size, seqrectx, seqrecty); } else { - se = do_build_seq_recursively_impl(scene, seq, cfra, render_size); + se = do_build_seq_recursively_impl(scene, seq, cfra, render_size, seqrectx, seqrecty); } check_limiter_refcount("do_build_seq_recursively", se); @@ -2483,8 +2497,9 @@ static int seq_get_early_out_for_blend_mode(Sequence * seq) return early_out; } -static TStripElem* do_build_seq_array_recursively(Scene *scene, - ListBase *seqbasep, int cfra, int chanshown, int render_size) +static TStripElem* do_build_seq_array_recursively( + Scene *scene, ListBase *seqbasep, int cfra, int chanshown, + int render_size, int seqrectx, int seqrecty) { Sequence* seq_arr[MAXSEQ+1]; int count; @@ -2504,7 +2519,7 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, return 0; } - test_and_auto_discard_ibuf(se); + test_and_auto_discard_ibuf(se, seqrectx, seqrecty); if (se->ibuf_comp != 0) { IMB_cache_limiter_insert(se->ibuf_comp); @@ -2516,7 +2531,8 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, if(count == 1) { se = do_build_seq_recursively(scene, seq_arr[0], - cfra, render_size); + cfra, render_size, + seqrectx, seqrecty); if (se->ibuf) { se->ibuf_comp = se->ibuf; IMB_refImBuf(se->ibuf_comp); @@ -2531,14 +2547,15 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, se = give_tstripelem(seq, cfra); - test_and_auto_discard_ibuf(se); + test_and_auto_discard_ibuf(se, seqrectx, seqrecty); if (se->ibuf_comp != 0) { break; } if (seq->blend_mode == SEQ_BLEND_REPLACE) { do_build_seq_recursively( - scene, seq, cfra, render_size); + scene, seq, cfra, render_size, + seqrectx, seqrecty); if (se->ibuf) { se->ibuf_comp = se->ibuf; @@ -2560,7 +2577,8 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, case -1: case 2: do_build_seq_recursively( - scene, seq, cfra, render_size); + scene, seq, cfra, render_size, + seqrectx, seqrecty); if (se->ibuf) { se->ibuf_comp = se->ibuf; @@ -2586,7 +2604,8 @@ static TStripElem* do_build_seq_array_recursively(Scene *scene, break; case 0: do_build_seq_recursively( - scene, seq, cfra, render_size); + scene, seq, cfra, render_size, + seqrectx, seqrecty); if (!se->ibuf) { se->ibuf = IMB_allocImBuf( @@ -2716,10 +2735,7 @@ static ImBuf *give_ibuf_seq_impl(Scene *scene, int rectx, int recty, int cfra, i seqbasep= ed->seqbasep; } - seqrectx= rectx; /* bad bad global! */ - seqrecty= recty; - - se = do_build_seq_array_recursively(scene, seqbasep, cfra, chanshown, render_size); + se = do_build_seq_array_recursively(scene, seqbasep, cfra, chanshown, render_size, rectx, recty); if(!se) { return 0; @@ -2734,10 +2750,7 @@ ImBuf *give_ibuf_seq_direct(Scene *scene, int rectx, int recty, int cfra, int re { TStripElem* se; - seqrectx= rectx; /* bad bad global! */ - seqrecty= recty; - - se = do_build_seq_recursively(scene, seq, cfra, render_size); + se = do_build_seq_recursively(scene, seq, cfra, render_size, rectx, recty); if(!se) { return 0; -- cgit v1.2.3 From 37542017209bf831235fb1645d31b0275642da87 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Apr 2010 16:12:39 +0000 Subject: fix for crash getting the current material & more verbose library errors --- source/blender/blenkernel/intern/material.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index f3096cdf8f2..3b6a10c0872 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -451,7 +451,7 @@ Material *give_current_material(Object *ob, int act) if(act>ob->totcol) act= ob->totcol; else if(act<=0) act= 1; - if(ob->matbits[act-1]) { /* in object */ + if(ob->matbits && ob->matbits[act-1]) { /* in object */ ma= ob->mat[act-1]; } else { /* in data */ -- cgit v1.2.3 From 24eedb2175896dd5d7e145486f3f3c6455511fca Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Apr 2010 21:38:55 +0000 Subject: vertex group option for lattice, needed for applying a lattice to a beard/moustache without moving the roots about. --- source/blender/blenkernel/intern/armature.c | 9 ++-- source/blender/blenkernel/intern/lattice.c | 74 ++++++++++++++++++----------- 2 files changed, 49 insertions(+), 34 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 04d5acb11cc..47f3530dd07 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -54,6 +54,7 @@ #include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" +#include "BKE_deform.h" #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_idprop.h" @@ -368,7 +369,7 @@ int bone_autoside_name (char *name, int strip_number, short axis, float head, fl char extension[5]={""}; len= strlen(name); - if (len == 0) return; + if (len == 0) return 0; strcpy(basename, name); /* Figure out extension to append: @@ -924,7 +925,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, int numGroups = 0; /* safety for vertexgroup index overflow */ int i, target_totvert = 0; /* safety for vertexgroup overflow */ int use_dverts = 0; - int armature_def_nr = -1; + int armature_def_nr; int totchan; if(arm->edbo) return; @@ -956,9 +957,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, } /* get the def_nr for the overall armature vertex group if present */ - for(i = 0, dg = target->defbase.first; dg; i++, dg = dg->next) - if(defgrp_name && strcmp(defgrp_name, dg->name) == 0) - armature_def_nr = i; + armature_def_nr= defgroup_name_index(target, defgrp_name); /* get a vertex-deform-index to posechannel array */ if(deformflag & ARM_DEF_VGROUP) { diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index b7003f45626..8b1ff05cc2a 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -59,6 +59,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_utildefines.h" +#include "BKE_deform.h" //XXX #include "BIF_editdeform.h" @@ -338,19 +339,29 @@ void calc_latt_deform(Object *ob, float *co, float weight) { Lattice *lt= ob->data; float u, v, w, tu[4], tv[4], tw[4]; - float *fpw, *fpv, *fpu, vec[3]; + float vec[3]; + int idx_w, idx_v, idx_u; int ui, vi, wi, uu, vv, ww; - + + /* vgroup influence */ + int defgroup_nr= -1; + float co_prev[3], weight_blend= 0.0f; + MDeformVert *dvert= lattice_get_deform_verts(ob); + + if(lt->editlatt) lt= lt->editlatt; if(lt->latticedata==NULL) return; - + + if(lt->vgroup[0] && dvert) { + defgroup_nr= defgroup_name_index(ob, lt->vgroup); + copy_v3_v3(co_prev, co); + } + /* co is in local coords, treat with latmat */ - - VECCOPY(vec, co); - mul_m4_v3(lt->latmat, vec); - + mul_v3_m4v3(vec, lt->latmat, co); + /* u v w coords */ - + if(lt->pntsu>1) { u= (vec[0]-lt->fu)/lt->du; ui= (int)floor(u); @@ -361,7 +372,7 @@ void calc_latt_deform(Object *ob, float *co, float weight) tu[0]= tu[2]= tu[3]= 0.0; tu[1]= 1.0; ui= 0; } - + if(lt->pntsv>1) { v= (vec[1]-lt->fv)/lt->dv; vi= (int)floor(v); @@ -372,7 +383,7 @@ void calc_latt_deform(Object *ob, float *co, float weight) tv[0]= tv[2]= tv[3]= 0.0; tv[1]= 1.0; vi= 0; } - + if(lt->pntsw>1) { w= (vec[2]-lt->fw)/lt->dw; wi= (int)floor(w); @@ -383,46 +394,51 @@ void calc_latt_deform(Object *ob, float *co, float weight) tw[0]= tw[2]= tw[3]= 0.0; tw[1]= 1.0; wi= 0; } - + for(ww= wi-1; ww<=wi+2; ww++) { w= tw[ww-wi+1]; - + if(w!=0.0) { if(ww>0) { - if(wwpntsw) fpw= lt->latticedata + 3*ww*lt->pntsu*lt->pntsv; - else fpw= lt->latticedata + 3*(lt->pntsw-1)*lt->pntsu*lt->pntsv; + if(wwpntsw) idx_w= ww*lt->pntsu*lt->pntsv; + else idx_w= (lt->pntsw-1)*lt->pntsu*lt->pntsv; } - else fpw= lt->latticedata; - + else idx_w= 0; + for(vv= vi-1; vv<=vi+2; vv++) { v= w*tv[vv-vi+1]; - + if(v!=0.0) { if(vv>0) { - if(vvpntsv) fpv= fpw + 3*vv*lt->pntsu; - else fpv= fpw + 3*(lt->pntsv-1)*lt->pntsu; + if(vvpntsv) idx_v= idx_w + vv*lt->pntsu; + else idx_v= idx_w + (lt->pntsv-1)*lt->pntsu; } - else fpv= fpw; - + else idx_v= idx_w; + for(uu= ui-1; uu<=ui+2; uu++) { u= weight*v*tu[uu-ui+1]; - + if(u!=0.0) { if(uu>0) { - if(uupntsu) fpu= fpv + 3*uu; - else fpu= fpv + 3*(lt->pntsu-1); + if(uupntsu) idx_u= idx_v + uu; + else idx_u= idx_v + (lt->pntsu-1); } - else fpu= fpv; - - co[0]+= u*fpu[0]; - co[1]+= u*fpu[1]; - co[2]+= u*fpu[2]; + else idx_u= idx_v; + + madd_v3_v3fl(co, <->latticedata[idx_u * 3], u); + + if(defgroup_nr != -1) + weight_blend += (u * defvert_find_weight(dvert + idx_u, defgroup_nr)); } } } } } } + + if(defgroup_nr != -1) + interp_v3_v3v3(co, co_prev, co, weight_blend); + } void end_latt_deform(Object *ob) -- cgit v1.2.3 From f7717b2e80907a974b472d0ee786f63b06efa40c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Apr 2010 11:59:47 +0000 Subject: option to use curve point weights to influence particle effectors. --- source/blender/blenkernel/BKE_anim.h | 2 +- source/blender/blenkernel/BKE_curve.h | 2 +- source/blender/blenkernel/intern/anim.c | 6 +++++- source/blender/blenkernel/intern/armature.c | 4 ++-- source/blender/blenkernel/intern/constraint.c | 4 ++-- source/blender/blenkernel/intern/curve.c | 25 ++++++++++++++++++---- source/blender/blenkernel/intern/displist.c | 4 ++-- source/blender/blenkernel/intern/effect.c | 2 +- source/blender/blenkernel/intern/font.c | 4 ++-- source/blender/blenkernel/intern/lattice.c | 3 ++- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenkernel/intern/particle.c | 10 ++++++--- source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 4 +++- 14 files changed, 51 insertions(+), 23 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h index 79b4d50586a..aae2be14f1f 100644 --- a/source/blender/blenkernel/BKE_anim.h +++ b/source/blender/blenkernel/BKE_anim.h @@ -63,7 +63,7 @@ void animviz_calc_motionpaths(struct Scene *scene, ListBase *targets); void free_path(struct Path *path); void calc_curvepath(struct Object *ob); int interval_test(int min, int max, int p1, int cycl); -int where_on_path(struct Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius); +int where_on_path(struct Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius, float *weight); /* ---------------------------------------------------- */ /* Dupli-Geometry */ diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index a3232ac91d6..ca45c2f318c 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -72,7 +72,7 @@ void minmaxNurb( struct Nurb *nu, float *min, float *max); void makeknots( struct Nurb *nu, short uv); void makeNurbfaces(struct Nurb *nu, float *coord_array, int rowstride); -void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu, int stride); +void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride); void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride); float *make_orco_curve(struct Scene *scene, struct Object *ob); float *make_orco_surf( struct Object *ob); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 10608dc676c..c6120ace850 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -460,6 +460,7 @@ void calc_curvepath(Object *ob) interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2); pp->vec[3]= fac1*bevp->alfa + fac2*bevpn->alfa; pp->radius= fac1*bevp->radius + fac2*bevpn->radius; + pp->weight= fac1*bevp->weight + fac2*bevpn->weight; interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2); normalize_qt(pp->quat); @@ -491,7 +492,7 @@ int interval_test(int min, int max, int p1, int cycl) * - *vec needs FOUR items! * - ctime is normalized range <0-1> */ -int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius) /* returns OK */ +int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius, float *weight) /* returns OK */ { Curve *cu; Nurb *nu; @@ -587,6 +588,9 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, if(radius) *radius= data[0]*p0->radius + data[1]*p1->radius + data[2]*p2->radius + data[3]*p3->radius; + if(weight) + *weight= data[0]*p0->weight + data[1]*p1->weight + data[2]*p2->weight + data[3]*p3->weight; + return 1; } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 47f3530dd07..b5b554789fb 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1941,7 +1941,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o } /* tail endpoint */ - if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad) ) { + if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad, NULL) ) { /* apply curve's object-mode transforms to the position * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root) */ @@ -1957,7 +1957,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o } /* head endpoint */ - if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad) ) { + if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad, NULL) ) { /* apply curve's object-mode transforms to the position * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root) */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 9566fa82861..c23f34e919a 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1242,7 +1242,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr curvetime= data->offset_fac; } - if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius) ) { + if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius, NULL) ) { if (data->followflag & FOLLOWPATH_FOLLOW) { vec_to_quat(quat, dir, (short)data->trackflag, (short)data->upflag); @@ -3261,7 +3261,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta } /* 3. position on curve */ - if (where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL) ) { + if (where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL, NULL) ) { unit_m4(totmat); VECCOPY(totmat[3], vec); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index dff936deaec..a01ee15dde1 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -887,14 +887,14 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride) MEM_freeN(jend); } -void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu, int stride) +void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride) /* coord_array has to be 3*4*pntsu*resolu in size and zero-ed * tilt_array and radius_array will be written to if valid */ { BPoint *bp; float u, ustart, uend, ustep, sumdiv; float *basisu, *sum, *fp; - float *coord_fp= coord_array, *tilt_fp= tilt_array, *radius_fp= radius_array; + float *coord_fp= coord_array, *tilt_fp= tilt_array, *radius_fp= radius_array, *weight_fp= weight_array; int i, len, istart, iend, cycl; if(nu->knotsu==NULL) return; @@ -967,6 +967,9 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu if (radius_fp) (*radius_fp) += (*fp) * bp->radius; + + if (weight_fp) + (*weight_fp) += (*fp) * bp->weight; } } @@ -975,6 +978,7 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu if (tilt_fp) tilt_fp = (float *)(((char *)tilt_fp) + stride); if (radius_fp) radius_fp = (float *)(((char *)radius_fp) + stride); + if (weight_fp) weight_fp = (float *)(((char *)weight_fp) + stride); u+= ustep; } @@ -1538,7 +1542,7 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si } -static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *tilt_array, float *radius_array, int resolu, int stride) +static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride) { BezTriple *pprev, *next, *last; float fac, dfac, t[4]; @@ -1595,6 +1599,13 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float * radius_array = (float *)(((char *)radius_array) + stride); } + + if(weight_array) { + /* basic interpolation for now, could copy tilt interp too */ + *weight_array = prevbezt->weight + (bezt->weight - prevbezt->weight)*(3.0f*fac*fac - 2.0f*fac*fac*fac); + + weight_array = (float *)(((char *)weight_array) + stride); + } } } @@ -1980,7 +1991,7 @@ void makeBevelList(Object *ob) float min, inp, x1, x2, y1, y2; struct bevelsort *sortdata, *sd, *sd1; int a, b, nr, poly, resolu = 0, len = 0; - int do_tilt, do_radius; + int do_tilt, do_radius, do_weight; /* this function needs an object, because of tflag and upflag */ cu= ob->data; @@ -1999,6 +2010,7 @@ void makeBevelList(Object *ob) /* check if we will calculate tilt data */ do_tilt = CU_DO_TILT(cu, nu); do_radius = CU_DO_RADIUS(cu, nu); /* normal display uses the radius, better just to calculate them */ + do_weight = 1; /* check we are a single point? also check we are not a surface and that the orderu is sane, * enforced in the UI but can go wrong possibly */ @@ -2028,6 +2040,7 @@ void makeBevelList(Object *ob) VECCOPY(bevp->vec, bp->vec); bevp->alfa= bp->alfa; bevp->radius= bp->radius; + bevp->weight= bp->weight; bevp->split_tag= TRUE; bevp++; bp++; @@ -2060,6 +2073,7 @@ void makeBevelList(Object *ob) VECCOPY(bevp->vec, prevbezt->vec[1]); bevp->alfa= prevbezt->alfa; bevp->radius= prevbezt->radius; + bevp->weight= prevbezt->weight; bevp->split_tag= TRUE; bevp->dupe_tag= FALSE; bevp++; @@ -2081,6 +2095,7 @@ void makeBevelList(Object *ob) alfa_bezpart( prevbezt, bezt, nu, do_tilt ? &bevp->alfa : NULL, do_radius ? &bevp->radius : NULL, + do_weight ? &bevp->weight : NULL, resolu, sizeof(BevPoint)); @@ -2110,6 +2125,7 @@ void makeBevelList(Object *ob) VECCOPY(bevp->vec, prevbezt->vec[1]); bevp->alfa= prevbezt->alfa; bevp->radius= prevbezt->radius; + bevp->weight= prevbezt->weight; bl->nr++; } } @@ -2128,6 +2144,7 @@ void makeBevelList(Object *ob) makeNurbcurve( nu, &bevp->vec[0], do_tilt ? &bevp->alfa : NULL, do_radius ? &bevp->radius : NULL, + do_weight ? &bevp->weight : NULL, resolu, sizeof(BevPoint)); } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index c65fac7d474..ac635e5f45a 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -895,7 +895,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) data= dl->verts; if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; else dl->type= DL_SEGM; - makeNurbcurve(nu, data, NULL, NULL, resolu, 3*sizeof(float)); + makeNurbcurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float)); } else if(nu->type == CU_POLY) { len= nu->pntsu; @@ -1598,7 +1598,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, 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)); + makeNurbcurve(nu, data, NULL, NULL, NULL, nu->resolu, 3*sizeof(float)); } else { len= (nu->pntsu*nu->resolu) * (nu->pntsv*nu->resolv); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 118f4885af4..00659b2be9e 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -222,7 +222,7 @@ static void precalculate_effector(EffectorCache *eff) makeDispListCurveTypes(eff->scene, eff->ob, 0); if(cu->path && cu->path->data) { - where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius); + where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL); mul_m4_v3(eff->ob->obmat, eff->guide_loc); mul_mat3_m4_v3(eff->ob->obmat, eff->guide_dir); } diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 907c848ebd5..01f2b57de71 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1037,8 +1037,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) /* calc the right loc AND the right rot separately */ /* vec, tvec need 4 items */ - where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL); - where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec, NULL, NULL); + where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL, NULL); + where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec, NULL, NULL, NULL); mul_v3_fl(vec, sizefac); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 8b1ff05cc2a..53fa7c14730 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -497,7 +497,7 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir, else ctime1= ctime; /* vec needs 4 items */ - if(where_on_path(ob, ctime1, vec, dir, quat, radius)) { + if(where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) { if(cycl==0) { Path *path= cu->path; @@ -516,6 +516,7 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir, VECADD(vec, vec, dvec); if(quat) QUATCOPY(quat, path->data[path->len-1].quat); if(radius) *radius= path->data[path->len-1].radius; + /* weight - not used but could be added */ } } return 1; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index cd86ac04337..bad1ebc6305 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1760,7 +1760,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) /* vec: 4 items! */ - if( where_on_path(par, ctime, vec, dir, NULL, &radius) ) { + if( where_on_path(par, ctime, vec, dir, NULL, &radius, NULL) ) { if(cu->flag & CU_FOLLOW) { vec_to_quat( quat,dir, ob->trackflag, ob->upflag); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index c4888dedf48..e1b91b7cc5a 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1985,7 +1985,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) float effect[3] = {0.0f, 0.0f, 0.0f}, veffect[3] = {0.0f, 0.0f, 0.0f}; float guidevec[4], guidedir[3], rot2[4], temp[3]; - float guidetime, radius, angle, totstrength = 0.0f; + float guidetime, radius, weight, angle, totstrength = 0.0f; float vec_to_point[3]; if(effectors) for(eff = effectors->first; eff; eff=eff->next) { @@ -2007,11 +2007,11 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) cu = (Curve*)eff->ob->data; if(pd->flag & PFIELD_GUIDE_PATH_ADD) { - if(where_on_path(eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius)==0) + if(where_on_path(eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius, &weight)==0) return 0; } else { - if(where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius)==0) + if(where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight)==0) return 0; } @@ -2051,10 +2051,14 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) VECCOPY(vec_to_point, key.co); VECADD(vec_to_point, vec_to_point, guidevec); + //VECSUB(pa_loc,pa_loc,pa_zero); VECADDFAC(effect, effect, vec_to_point, data->strength); VECADDFAC(veffect, veffect, guidedir, data->strength); totstrength += data->strength; + + if(pd->flag & PFIELD_GUIDE_PATH_WEIGHT) + totstrength *= weight; } if(totstrength != 0.0){ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 720bf3b2a47..621850f75c7 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3687,7 +3687,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) PTCacheID pid, *use_cache = NULL; PARTICLE_P; int oldtotpart; - float disp, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; + float disp; /*, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; */ int init= 0, emit= 0; //, only_children_changed= 0; int framenr, framedelta, startframe = 0, endframe = 100; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index ab4750a28d2..8001ba6bcb9 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -802,10 +802,12 @@ static int ptcache_compress_read(PTCacheFile *pf, unsigned char *result, unsigne int r = 0; unsigned char compressed = 0; unsigned int in_len; +#ifdef WITH_LZO unsigned int out_len = len; + size_t sizeOfIt = 5; +#endif unsigned char *in; unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); - size_t sizeOfIt = 5; ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char)); if(compressed) { -- cgit v1.2.3 From fba7ebcbea35d3b14f535f7f7a50c61074ae7092 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Apr 2010 12:27:48 +0000 Subject: replace add_v3_v3v3() --> add_v3_v3() where possible --- source/blender/blenkernel/intern/DerivedMesh.c | 20 ++++++++--------- source/blender/blenkernel/intern/action.c | 6 ++--- source/blender/blenkernel/intern/anim.c | 4 ++-- source/blender/blenkernel/intern/armature.c | 10 ++++----- source/blender/blenkernel/intern/boids.c | 28 ++++++++++++------------ source/blender/blenkernel/intern/cdderivedmesh.c | 14 ++++++------ source/blender/blenkernel/intern/constraint.c | 6 ++--- source/blender/blenkernel/intern/displist.c | 8 +++---- source/blender/blenkernel/intern/effect.c | 16 +++++++------- source/blender/blenkernel/intern/mesh.c | 8 +++---- source/blender/blenkernel/intern/object.c | 8 +++---- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/blenkernel/intern/sketch.c | 4 ++-- source/blender/blenkernel/intern/softbody.c | 10 ++++----- source/blender/blenkernel/intern/subsurf_ccg.c | 2 +- 15 files changed, 73 insertions(+), 73 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 36cf19364ef..8a74ba1be53 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -583,14 +583,14 @@ static void emDM__calcFaceCent(EditFace *efa, float cent[3], float (*vertexCos)[ { if (vertexCos) { VECCOPY(cent, vertexCos[(int) efa->v1->tmp.l]); - add_v3_v3v3(cent, cent, vertexCos[(int) efa->v2->tmp.l]); - add_v3_v3v3(cent, cent, vertexCos[(int) efa->v3->tmp.l]); - if (efa->v4) add_v3_v3v3(cent, cent, vertexCos[(int) efa->v4->tmp.l]); + add_v3_v3(cent, vertexCos[(int) efa->v2->tmp.l]); + add_v3_v3(cent, vertexCos[(int) efa->v3->tmp.l]); + if (efa->v4) add_v3_v3(cent, vertexCos[(int) efa->v4->tmp.l]); } else { VECCOPY(cent, efa->v1->co); - add_v3_v3v3(cent, cent, efa->v2->co); - add_v3_v3v3(cent, cent, efa->v3->co); - if (efa->v4) add_v3_v3v3(cent, cent, efa->v4->co); + add_v3_v3(cent, efa->v2->co); + add_v3_v3(cent, efa->v3->co); + if (efa->v4) add_v3_v3(cent, efa->v4->co); } if (efa->v4) { @@ -1369,15 +1369,15 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob, float *v4 = vertexCos[(int) efa->v4->tmp.l]; normal_quad_v3( no,v1, v2, v3, v4); - add_v3_v3v3(emdm->vertexNos[(int) efa->v4->tmp.l], emdm->vertexNos[(int) efa->v4->tmp.l], no); + add_v3_v3(emdm->vertexNos[(int) efa->v4->tmp.l], no); } else { normal_tri_v3( no,v1, v2, v3); } - add_v3_v3v3(emdm->vertexNos[(int) efa->v1->tmp.l], emdm->vertexNos[(int) efa->v1->tmp.l], no); - add_v3_v3v3(emdm->vertexNos[(int) efa->v2->tmp.l], emdm->vertexNos[(int) efa->v2->tmp.l], no); - add_v3_v3v3(emdm->vertexNos[(int) efa->v3->tmp.l], emdm->vertexNos[(int) efa->v3->tmp.l], no); + add_v3_v3(emdm->vertexNos[(int) efa->v1->tmp.l], no); + add_v3_v3(emdm->vertexNos[(int) efa->v2->tmp.l], no); + add_v3_v3(emdm->vertexNos[(int) efa->v3->tmp.l], no); } for(i=0, eve= em->verts.first; eve; i++, eve=eve->next) { diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 1040784284f..253da25b871 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1251,12 +1251,12 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, /* if blending, we only add with factor scrweight */ mul_v3_fl(vec, srcweight); - add_v3_v3v3(dst->cyclic_offset, dst->cyclic_offset, vec); + add_v3_v3(dst->cyclic_offset, vec); } } } - add_v3_v3v3(dst->cyclic_offset, dst->cyclic_offset, src->cyclic_offset); + add_v3_v3(dst->cyclic_offset, src->cyclic_offset); } /* added "sizecorr" here, to allow armatures to be scaled and still have striding. @@ -1616,7 +1616,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) } else if(blocktype==ID_AR) { /* apply stride offset to object */ - add_v3_v3v3(ob->obmat[3], ob->obmat[3], ob->pose->stride_offset); + add_v3_v3(ob->obmat[3], ob->pose->stride_offset); } /* free */ diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index c6120ace850..34dcf41d441 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -730,7 +730,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n VECCOPY(vec, co); mul_m4_v3(vdd->pmat, vec); sub_v3_v3v3(vec, vec, vdd->pmat[3]); - add_v3_v3v3(vec, vec, vdd->obmat[3]); + add_v3_v3(vec, vdd->obmat[3]); copy_m4_m4(obmat, vdd->obmat); VECCOPY(obmat[3], vec); @@ -990,7 +990,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa mul_m4_v3(pmat, cent); sub_v3_v3v3(cent, cent, pmat[3]); - add_v3_v3v3(cent, cent, ob__obmat[3]); + add_v3_v3(cent, ob__obmat[3]); copy_m4_m4(obmat, ob__obmat); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b5b554789fb..dbc03176b8f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -852,7 +852,7 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo // Make this a delta from the base position sub_v3_v3v3(cop, cop, co); cop[0]*=fac; cop[1]*=fac; cop[2]*=fac; - add_v3_v3v3(vec, vec, cop); + add_v3_v3(vec, cop); if(mat) pchan_deform_mat_add(pchan, fac, bbonemat, mat); @@ -1108,7 +1108,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, mul_v3m3_dq( dco, (defMats)? summat: NULL,dq); sub_v3_v3v3(dco, dco, co); mul_v3_fl(dco, armature_weight); - add_v3_v3v3(co, co, dco); + add_v3_v3(co, dco); } else mul_v3m3_dq( co, (defMats)? summat: NULL,dq); @@ -2262,7 +2262,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha nor[0] = BLI_gNoise(amod->noisesize, size[0]+ofs, size[1], size[2], 0, 0) - ofs; nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1]+ofs, size[2], 0, 0) - ofs; nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2]+ofs, 0, 0) - ofs; - add_v3_v3v3(size, size, nor); + add_v3_v3(size, nor); if (sizeo[0] != 0) mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]); @@ -2278,7 +2278,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2]+ofs, 0, 0) - ofs; compatible_eul(nor, eulo); - add_v3_v3v3(eul, eul, nor); + add_v3_v3(eul, nor); compatible_eul(eul, eulo); loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size); @@ -2381,7 +2381,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti /* only rootbones get the cyclic offset (unless user doesn't want that) */ if ((bone->flag & BONE_NO_CYCLICOFFSET) == 0) - add_v3_v3v3(pchan->pose_mat[3], pchan->pose_mat[3], ob->pose->cyclic_offset); + add_v3_v3(pchan->pose_mat[3], ob->pose->cyclic_offset); } if(do_extra) { diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 25c42dfbf49..b18ab8767e3 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -141,7 +141,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, get_effector_data(eff, &efd, &epoint, 1); mul_v3_fl(efd.vel, efd.distance / (val->max_speed * bbd->timestep)); - add_v3_v3v3(efd.loc, efd.loc, efd.vel); + add_v3_v3(efd.loc, efd.vel); sub_v3_v3v3(efd.vec_to_point, pa->prev_state.co, efd.loc); efd.distance = len_v3(efd.vec_to_point); } @@ -355,7 +355,7 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa if(neighbors > 1 && ptn[1].dist!=0.0f) { sub_v3_v3v3(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co); mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist); - add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); + add_v3_v3(bbd->wanted_co, vec); bbd->wanted_speed = val->max_speed; len = ptn[1].dist; ret = 1; @@ -372,7 +372,7 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa if(neighbors > 0 && ptn[0].dist < len) { sub_v3_v3v3(vec, pa->prev_state.co, ptn[0].co); mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist); - add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); + add_v3_v3(bbd->wanted_co, vec); bbd->wanted_speed = val->max_speed; len = ptn[0].dist; ret = 1; @@ -393,8 +393,8 @@ static int rule_flock(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti if(neighbors > 1) { for(n=1; nsim->psys->particles[ptn[n].index].prev_state.co); - add_v3_v3v3(vec, vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel); + add_v3_v3(loc, bbd->sim->psys->particles[ptn[n].index].prev_state.co); + add_v3_v3(vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel); } mul_v3_fl(loc, 1.0f/((float)neighbors - 1.0f)); @@ -403,8 +403,8 @@ static int rule_flock(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti sub_v3_v3v3(loc, loc, pa->prev_state.co); sub_v3_v3v3(vec, vec, pa->prev_state.vel); - add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); - add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, loc); + add_v3_v3(bbd->wanted_co, vec); + add_v3_v3(bbd->wanted_co, loc); bbd->wanted_speed = len_v3(bbd->wanted_co); ret = 1; @@ -567,7 +567,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va mul_v3_fl(bbd->wanted_co, 1.1f); - add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); + add_v3_v3(bbd->wanted_co, vec); /* leveling */ if(asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) { @@ -748,7 +748,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro /* take surface velocity into account */ closest_point_on_surface(surmd, pa->state.co, x, NULL, v); - add_v3_v3v3(x, x, v); + add_v3_v3(x, v); /* get actual position on surface */ closest_point_on_surface(surmd, x, ground_co, ground_nor, NULL); @@ -767,7 +767,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro VECCOPY(col.co1, pa->state.co); VECCOPY(col.co2, pa->state.co); - add_v3_v3v3(col.co1, col.co1, zvec); + add_v3_v3(col.co1, zvec); sub_v3_v3v3(col.co2, col.co2, zvec); sub_v3_v3v3(ray_dir, col.co2, col.co1); col.t = 0.0f; @@ -956,7 +956,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) int n = 0; for(rule = state->rules.first; rule; rule=rule->next) { if(apply_boid_rule(bbd, rule, &val, pa, -1.0f)) { - add_v3_v3v3(wanted_co, wanted_co, bbd->wanted_co); + add_v3_v3(wanted_co, bbd->wanted_co); wanted_speed += bbd->wanted_speed; n++; bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f; @@ -1205,7 +1205,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) mul_v3_fl(force, length); } - add_v3_v3v3(acc, acc, force); + add_v3_v3(acc, force); /* store smoothed acceleration for nice banking etc. */ VECADDFAC(bpa->data.acc, bpa->data.acc, acc, dtime); @@ -1222,8 +1222,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) VECCOPY(bvec, pa->prev_state.vel); mul_v3_fl(bvec, dtime); - add_v3_v3v3(dvec, dvec, bvec); - add_v3_v3v3(pa->state.co, pa->state.co, dvec); + add_v3_v3(dvec, bvec); + add_v3_v3(pa->state.co, dvec); VECADDFAC(pa->state.vel, pa->state.vel, acc, dtime); diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index b3e702ceee9..204ff2a0369 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1347,12 +1347,12 @@ static void cdDM_foreachMappedFaceCenter( orig = i; VECCOPY(cent, mv[mf->v1].co); - add_v3_v3v3(cent, cent, mv[mf->v2].co); - add_v3_v3v3(cent, cent, mv[mf->v3].co); + add_v3_v3(cent, mv[mf->v2].co); + add_v3_v3(cent, mv[mf->v3].co); if (mf->v4) { normal_quad_v3( no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); - add_v3_v3v3(cent, cent, mv[mf->v4].co); + add_v3_v3(cent, mv[mf->v4].co); mul_v3_fl(cent, 0.25f); } else { normal_tri_v3( no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); @@ -1750,11 +1750,11 @@ void CDDM_calc_normals(DerivedMesh *dm) else normal_tri_v3( f_no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); - add_v3_v3v3(temp_nors[mf->v1], temp_nors[mf->v1], f_no); - add_v3_v3v3(temp_nors[mf->v2], temp_nors[mf->v2], f_no); - add_v3_v3v3(temp_nors[mf->v3], temp_nors[mf->v3], f_no); + add_v3_v3(temp_nors[mf->v1], f_no); + add_v3_v3(temp_nors[mf->v2], f_no); + add_v3_v3(temp_nors[mf->v3], f_no); if(mf->v4) - add_v3_v3v3(temp_nors[mf->v4], temp_nors[mf->v4], f_no); + add_v3_v3(temp_nors[mf->v4], f_no); } /* normalize vertex normals and assign */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index c23f34e919a..a07fc4ada39 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -447,8 +447,8 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f if (dvert[i].dw[j].def_nr == dgroup) { dm->getVertCo(dm, i, co); dm->getVertNo(dm, i, nor); - add_v3_v3v3(vec, vec, co); - add_v3_v3v3(normal, normal, nor); + add_v3_v3(vec, co); + add_v3_v3(normal, nor); count++; break; } @@ -535,7 +535,7 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][ else memcpy(tvec, bp->vec, 3*sizeof(float)); - add_v3_v3v3(vec, vec, tvec); + add_v3_v3(vec, tvec); grouped++; break; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index ac635e5f45a..d744baac84a 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -196,10 +196,10 @@ void addnormalsDispList(Object *ob, ListBase *lb) normal_quad_v3( nor,v1, v3, v4, v2); - add_v3_v3v3(n1, n1, nor); - add_v3_v3v3(n2, n2, nor); - add_v3_v3v3(n3, n3, nor); - add_v3_v3v3(n4, n4, nor); + add_v3_v3(n1, nor); + add_v3_v3(n2, nor); + add_v3_v3(n3, nor); + add_v3_v3(n4, nor); v2= v1; v1+= 3; v4= v3; v3+= 3; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 00659b2be9e..a0416bc2b34 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -576,10 +576,10 @@ int closest_point_on_surface(SurfaceModifierData *surmd, float *co, float *surfa MFace *mface = CDDM_get_face(surmd->dm, nearest.index); VECCOPY(surface_vel, surmd->v[mface->v1].co); - add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v2].co); - add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v3].co); + add_v3_v3(surface_vel, surmd->v[mface->v2].co); + add_v3_v3(surface_vel, surmd->v[mface->v3].co); if(mface->v4) - add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v4].co); + add_v3_v3(surface_vel, surmd->v[mface->v4].co); mul_v3_fl(surface_vel, mface->v4 ? 0.25f : 0.333f); } @@ -600,7 +600,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin /* using velocity corrected location allows for easier sliding over effector surface */ copy_v3_v3(vec, point->vel); mul_v3_fl(vec, point->vel_to_frame); - add_v3_v3v3(vec, vec, point->loc); + add_v3_v3(vec, point->loc); ret = closest_point_on_surface(eff->surmd, vec, efd->loc, efd->nor, real_velocity ? efd->vel : NULL); @@ -827,7 +827,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP VECADDFAC(force, force, efd->nor, fac); } - add_v3_v3v3(total_force, total_force, force); + add_v3_v3(total_force, force); } void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force) { @@ -874,7 +874,7 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * mul_v3_fl(force, strength * efd->falloff); VECADDFAC(temp, temp, point->vel, -point->vel_to_sec); - add_v3_v3v3(force, force, temp); + add_v3_v3(force, temp); } break; case PFIELD_MAGNET: @@ -893,7 +893,7 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * mul_v3_fl(force, -strength * efd->falloff); copy_v3_v3(temp, point->vel); mul_v3_fl(temp, -damp * 2.0f * (float)sqrt(fabs(strength)) * point->vel_to_sec); - add_v3_v3v3(force, force, temp); + add_v3_v3(force, temp); break; case PFIELD_CHARGE: mul_v3_fl(force, point->charge * strength * efd->falloff); @@ -950,7 +950,7 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint * if(pd->f_flow != 0.0f) { VECADDFAC(dave, dave, point->ave, -pd->f_flow * efd->falloff); } - add_v3_v3v3(point->ave, point->ave, dave); + add_v3_v3(point->ave, dave); } } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index fd4a8a00216..6ddc4b8bb16 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1233,11 +1233,11 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, else normal_tri_v3( f_no,mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co); - add_v3_v3v3(tnorms[mf->v1], tnorms[mf->v1], f_no); - add_v3_v3v3(tnorms[mf->v2], tnorms[mf->v2], f_no); - add_v3_v3v3(tnorms[mf->v3], tnorms[mf->v3], f_no); + add_v3_v3(tnorms[mf->v1], f_no); + add_v3_v3(tnorms[mf->v2], f_no); + add_v3_v3(tnorms[mf->v3], f_no); if (mf->v4) - add_v3_v3v3(tnorms[mf->v4], tnorms[mf->v4], f_no); + add_v3_v3(tnorms[mf->v4], f_no); } for (i=0; ibone->length); - add_v3_v3v3(mat[3], mat[3], vec); + add_v3_v3(mat[3], vec); } static void give_parvert(Object *par, int nr, float *vec) @@ -1851,7 +1851,7 @@ static void give_parvert(Object *par, int nr, float *vec) vindex= (index)? index[i]: i; if(vindex == nr) { - add_v3_v3v3(vec, vec, mvert[i].co); + add_v3_v3(vec, mvert[i].co); count++; } } @@ -1960,7 +1960,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4]) } else { add_v3_v3v3(mat[3], v1, v2); - add_v3_v3v3(mat[3], mat[3], v3); + add_v3_v3(mat[3], v3); mul_v3_fl(mat[3], 0.3333333f); } } @@ -2342,7 +2342,7 @@ void minmax_object(Object *ob, float *min, float *max) DO_MINMAX(ob->obmat[3], min, max); VECCOPY(vec, ob->obmat[3]); - add_v3_v3v3(vec, vec, ob->size); + add_v3_v3(vec, ob->size); DO_MINMAX(vec, min, max); VECCOPY(vec, ob->obmat[3]); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index e1b91b7cc5a..31378e3a80a 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2126,7 +2126,7 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK mul_v3_fl(force, effector*pow((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); - add_v3_v3v3(force, force, vec); + add_v3_v3(force, vec); normalize_v3(force); diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index ecafd0881ad..6032a0eea3d 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -260,7 +260,7 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f VECCOPY(p, delta_p); mul_v3_fl(p, delta); - add_v3_v3v3(p, p, p_start); + add_v3_v3(p, p_start); } } @@ -337,7 +337,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) mul_v3_fl(offset, d); sub_v3_v3v3(p, p, distance); - add_v3_v3v3(p, p, offset); + add_v3_v3(p, offset); } } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index e6f500aab15..b8274940318 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1580,7 +1580,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, if (ob->softflag & OB_SB_EDGECOLL){ if ( sb_detect_edge_collisionCached (sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos, &damp,feedback,ob->lay,ob,timenow)){ - add_v3_v3v3(bs->ext_force,bs->ext_force,feedback); + add_v3_v3(bs->ext_force, feedback); bs->flag |= BSF_INTERSECT; //bs->cf=damp; bs->cf=sb->choke*0.01f; @@ -1605,7 +1605,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); mul_v3_fl(speed,windfactor); - add_v3_v3v3(vel,vel,speed); + add_v3_v3(vel, speed); } /* media in rest */ else{ @@ -2291,7 +2291,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo float gravity[3]; VECCOPY(gravity, scene->physics_settings.gravity); mul_v3_fl(gravity, sb_grav_force_scale(ob)*_final_mass(ob,bp)*sb->effector_weights->global_gravity); /* individual mass of node here */ - add_v3_v3v3(bp->force, bp->force, gravity); + add_v3_v3(bp->force, gravity); } /* particle field & vortex */ @@ -2358,7 +2358,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo for(b=bp->nofsprings;b>0;b--){ bs = sb->bspring + bp->springs[b-1]; if (do_springcollision || do_aero){ - add_v3_v3v3(bp->force,bp->force,bs->ext_force); + add_v3_v3(bp->force, bs->ext_force); if (bs->flag & BSF_INTERSECT) bp->choke = bs->cf; @@ -2799,7 +2799,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa for(b=bp->nofsprings;b>0;b--){ bs = sb->bspring + bp->springs[b-1]; if (do_springcollision || do_aero){ - add_v3_v3v3(bp->force,bp->force,bs->ext_force); + add_v3_v3(bp->force, bs->ext_force); if (bs->flag & BSF_INTERSECT) bp->choke = bs->cf; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 16cb671f2d0..db63f094160 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2679,7 +2679,7 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) } for (i=0; i Date: Thu, 22 Apr 2010 01:55:10 +0000 Subject: Fix [#22078] Cannot apply modifier in python (context error) Previously all modifier operators relied on the buttons layout data context pointer to decide which modifier to work on. This meant that these operators would only work from from the properties panel, and not from scripting/macros or for operator redo. This commit makes all modifier operators take the modifier name as an operator property, so the operators can be re-done or executed outside of the modifier panel. When invoking the operators from the modifier panel, they automatically fill in the operator property from context. This isn't a perfect API design, but it does bring these operators in line with the design of being able to access all UI functionality via other means like scripts. --- source/blender/blenkernel/BKE_modifier.h | 1 + source/blender/blenkernel/intern/modifier.c | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 6db610f4d8d..ae6f1f5ed85 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -292,6 +292,7 @@ void modifiers_foreachIDLink(struct Object *ob, IDWalkFunc walk, void *userData); struct ModifierData *modifiers_findByType(struct Object *ob, ModifierType type); +struct ModifierData *modifiers_findByName(struct Object *ob, const char *name); void modifiers_clearErrors(struct Object *ob); int modifiers_getCageIndex(struct Scene *scene, struct Object *ob, int *lastPossibleCageIndex_r, int virtual_); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 6b46fbe575b..0ecc8166d72 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -176,6 +176,17 @@ ModifierData *modifiers_findByType(Object *ob, ModifierType type) return md; } +ModifierData *modifiers_findByName(Object *ob, const char *name) +{ + ModifierData *md = ob->modifiers.first; + + for (; md; md=md->next) + if (strcmp(md->name, name)==0) + break; + + return md; +} + void modifiers_clearErrors(Object *ob) { ModifierData *md = ob->modifiers.first; -- cgit v1.2.3 From a2b6abeee15f359ddeafdea7a2f3a965da0bf410 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 22 Apr 2010 06:59:41 +0000 Subject: Fix [#22097] missing panels in texture tab Made texture/texture slot context a bit less flaky when dealing with active material and texture nodes inside a node material in the node editor. Now if the active material has nodes enabled, and there are no active material/texture nodes inside it, nothing will be shown in the texture properties (similar to 2.49). --- source/blender/blenkernel/intern/texture.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index c13e48e8f01..99370610479 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -879,9 +879,15 @@ Tex *give_current_material_texture(Material *ma) } else { node= nodeGetActiveID(ma->nodetree, ID_MA); - if(node) + if(node) { ma= (Material*)node->id; + if(ma) { + mtex= ma->mtex[(int)(ma->texact)]; + if(mtex) tex= mtex->tex; + } + } } + return tex; } if(ma) { -- cgit v1.2.3 From c8c22d2cf65504443574961cea0ec1773c18735e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Apr 2010 08:25:05 +0000 Subject: rna: added lib.parent access and made filename editable. --- source/blender/blenkernel/intern/modifier.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 0ecc8166d72..e483ae0e6a8 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -178,13 +178,7 @@ ModifierData *modifiers_findByType(Object *ob, ModifierType type) ModifierData *modifiers_findByName(Object *ob, const char *name) { - ModifierData *md = ob->modifiers.first; - - for (; md; md=md->next) - if (strcmp(md->name, name)==0) - break; - - return md; + return BLI_findstring(&(ob->modifiers), name, offsetof(ModifierData, name)); } void modifiers_clearErrors(Object *ob) -- cgit v1.2.3 From a56b72fd82e5de17ad0f688857c31cf3a9623ea1 Mon Sep 17 00:00:00 2001 From: Diego Borghetti Date: Thu, 22 Apr 2010 10:56:45 +0000 Subject: BugFix: [#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this. --- source/blender/blenkernel/intern/image.c | 85 ++++++++++++++-------------- source/blender/blenkernel/intern/image_gen.c | 56 +++++++++--------- 2 files changed, 70 insertions(+), 71 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 7d194461c78..66e6171d9ee 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1019,17 +1019,17 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) extern int datatoc_bmonofont_ttf_size; extern char datatoc_bmonofont_ttf[]; -// XXX - copied from text_font_begin -void stamp_font_begin(int size) -{ - static int mono= -1; +// XXX - copied from text_font_begin ! Change all the BLF_* here +static int mono= -1; +int stamp_font_begin(int size) +{ if (mono == -1) - mono= BLF_load_mem("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); + mono= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); - BLF_set(mono); - BLF_aspect(1.0); - BLF_size(size, 72); + BLF_aspect(mono, 1.0); + BLF_size(mono, size, 72); + return(mono); // XXX This is for image_gen.c!! } void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels) @@ -1049,24 +1049,24 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i stamp_font_begin(scene->r.stamp_font_id); - BLF_buffer(rectf, rect, width, height, channels); - BLF_buffer_col(scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); - pad= BLF_width("--"); + BLF_buffer(mono, rectf, rect, width, height, channels); + BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); + pad= BLF_width(mono, "--"); x= 0; y= height; if (stamp_data.file[0]) { /* Top left corner */ - BLF_width_and_height(stamp_data.file, &w, &h); + BLF_width_and_height(mono, stamp_data.file, &w, &h); y -= h; /* also a little of space to the background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, w+3, y+h+3); /* and draw the text. */ - BLF_position(x, y, 0.0); - BLF_draw_buffer(stamp_data.file); + BLF_position(mono, x, y, 0.0); + BLF_draw_buffer(mono, stamp_data.file); /* the extra pixel for background. */ y -= 4; @@ -1074,14 +1074,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Top left corner, below File */ if (stamp_data.note[0]) { - BLF_width_and_height(stamp_data.note, &w, &h); + BLF_width_and_height(mono, stamp_data.note, &w, &h); y -= h; /* and space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-2, w+3, y+h+2); - BLF_position(x, y+1, 0.0); - BLF_draw_buffer(stamp_data.note); + BLF_position(mono, x, y+1, 0.0); + BLF_draw_buffer(mono, stamp_data.note); /* the extra pixel for background. */ y -= 4; @@ -1089,14 +1089,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Top left corner, below File (or Note) */ if (stamp_data.date[0]) { - BLF_width_and_height(stamp_data.date, &w, &h); + BLF_width_and_height(mono, stamp_data.date, &w, &h); y -= h; /* and space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3); - BLF_position(x, y, 0.0); - BLF_draw_buffer(stamp_data.date); + BLF_position(mono, x, y, 0.0); + BLF_draw_buffer(mono, stamp_data.date); /* the extra pixel for background. */ y -= 4; @@ -1104,14 +1104,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Top left corner, below File, Date or Note */ if (stamp_data.rendertime[0]) { - BLF_width_and_height(stamp_data.rendertime, &w, &h); + BLF_width_and_height(mono, stamp_data.rendertime, &w, &h); y -= h; /* and space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3); - BLF_position(x, y, 0.0); - BLF_draw_buffer(stamp_data.rendertime); + BLF_position(mono, x, y, 0.0); + BLF_draw_buffer(mono, stamp_data.rendertime); } x= 0; @@ -1119,14 +1119,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Bottom left corner, leaving space for timing */ if (stamp_data.marker[0]) { - BLF_width_and_height(stamp_data.marker, &w, &h); + BLF_width_and_height(mono, stamp_data.marker, &w, &h); /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, w+2, y+h+3); /* and pad the text. */ - BLF_position(x, y+3, 0.0); - BLF_draw_buffer(stamp_data.marker); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.marker); /* space width. */ x += w + pad; @@ -1134,45 +1134,44 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Left bottom corner */ if (stamp_data.time[0]) { - BLF_width_and_height(stamp_data.time, &w, &h); + BLF_width_and_height(mono, stamp_data.time, &w, &h); /* extra space for background */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); /* and pad the text. */ - BLF_position(x, y+3, 0.0); - BLF_draw_buffer(stamp_data.time); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.time); /* space width. */ x += w + pad; } if (stamp_data.frame[0]) { - BLF_width_and_height(stamp_data.frame, &w, &h); + BLF_width_and_height(mono, stamp_data.frame, &w, &h); /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); /* and pad the text. */ - BLF_position(x, y+3, 0.0); - - BLF_draw_buffer(stamp_data.frame); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.frame); /* space width. */ x += w + pad; } if (stamp_data.camera[0]) { - BLF_width_and_height(stamp_data.camera, &w, &h); + BLF_width_and_height(mono, stamp_data.camera, &w, &h); /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); - BLF_position(x, y+3, 0.0); - BLF_draw_buffer(stamp_data.camera); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.camera); } if (stamp_data.scene[0]) { - BLF_width_and_height(stamp_data.scene, &w, &h); + BLF_width_and_height(mono, stamp_data.scene, &w, &h); /* Bottom right corner, with an extra space because blenfont is too strict! */ x= width - w - 2; @@ -1181,12 +1180,12 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+3, y+h+3); /* and pad the text. */ - BLF_position(x, y+3, 0.0); - BLF_draw_buffer(stamp_data.scene); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.scene); } if (stamp_data.strip[0]) { - BLF_width_and_height(stamp_data.scene, &w, &h); + BLF_width_and_height(mono, stamp_data.scene, &w, &h); /* Top right corner, with an extra space because blenfont is too strict! */ x= width - w - pad; @@ -1195,12 +1194,12 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, x+w+pad, y+h+3); - BLF_position(x, y, 0.0); - BLF_draw_buffer(stamp_data.strip); + BLF_position(mono, x, y, 0.0); + BLF_draw_buffer(mono, stamp_data.strip); } /* cleanup the buffer. */ - BLF_buffer(NULL, NULL, 0, 0, 0); + BLF_buffer(mono, NULL, NULL, 0, 0, 0); } void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index eb256e3775b..9248ce69280 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -24,6 +24,7 @@ */ #include +#include #include "BLI_math_color.h" #include "BLF_api.h" @@ -297,17 +298,17 @@ static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int } /* defined in image.c */ -extern void stamp_font_begin(int size); +extern int stamp_font_begin(int size); static void checker_board_text(unsigned char *rect, float *rect_float, int width, int height, int step, int outline) { - int x, y; + int x, y, mono; int pen_x, pen_y; char text[3]= {'A', '1', '\0'}; /* hard coded size! */ - stamp_font_begin(54); - BLF_buffer(rect_float, rect, width, height, 4); + mono= stamp_font_begin(54); + BLF_buffer(mono, rect_float, rect, width, height, 4); for(y= 0; y < height; y+=step) { @@ -320,29 +321,29 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width pen_y = y + 44; /* terribly crappy outline font! */ - BLF_buffer_col(1.0, 1.0, 1.0, 1.0); - - BLF_position(pen_x-outline, pen_y, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x+outline, pen_y, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x, pen_y-outline, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x, pen_y+outline, 0.0); - BLF_draw_buffer(text); + BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0); + + BLF_position(mono, pen_x-outline, pen_y, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x+outline, pen_y, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x, pen_y-outline, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x, pen_y+outline, 0.0); + BLF_draw_buffer(mono, text); - BLF_position(pen_x-outline, pen_y-outline, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x+outline, pen_y+outline, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x-outline, pen_y+outline, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x+outline, pen_y-outline, 0.0); - BLF_draw_buffer(text); - - BLF_buffer_col(0.0, 0.0, 0.0, 1.0); - BLF_position(pen_x, pen_y, 0.0); - BLF_draw_buffer(text); + BLF_position(mono, pen_x-outline, pen_y-outline, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x+outline, pen_y+outline, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x-outline, pen_y+outline, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x+outline, pen_y-outline, 0.0); + BLF_draw_buffer(mono, text); + + BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0); + BLF_position(mono, pen_x, pen_y, 0.0); + BLF_draw_buffer(mono, text); text[1]++; } @@ -350,8 +351,7 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width } /* cleanup the buffer. */ - BLF_buffer(0, 0, 0, 0, 0); - + BLF_buffer(mono, NULL, NULL, 0, 0, 0); } void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, int width, int height) -- cgit v1.2.3 From 33acae1a15694d73490444a5f3e90fb6e9454841 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Apr 2010 16:23:44 +0000 Subject: only override start and end frames with particle's if the partices are emitters. Was very confusing for hair baking. --- source/blender/blenkernel/intern/pointcache.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 8001ba6bcb9..e14c46fd82a 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2397,8 +2397,13 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) /* cache/bake a single object */ cache = pid->cache; if((cache->flag & PTCACHE_BAKED)==0) { - if(pid->type==PTCACHE_TYPE_PARTICLES) - psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe); + if(pid->type==PTCACHE_TYPE_PARTICLES) { + ParticleSystem *psys= pid->calldata; + + /* a bit confusing, could make this work better in the UI */ + if(psys->part->type == PART_EMITTER) + psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe); + } else if(pid->type == PTCACHE_TYPE_SMOKE_HIGHRES) { /* get all pids from the object and search for smoke low res */ ListBase pidlist2; -- cgit v1.2.3 From 230eec99173f186065c176d2d0e8ffed18e40495 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 22 Apr 2010 19:57:18 +0000 Subject: chaning the camera from the scene buttons didnt update the views. moved some scene/view functions from view3d_view.c into BKE_screen since they need to be accessed when changing cameras from outside the view. --- source/blender/blenkernel/BKE_screen.h | 5 +++ source/blender/blenkernel/intern/screen.c | 64 +++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 970cdf412e5..125486625bb 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -235,6 +235,11 @@ void BKE_screen_area_free(struct ScrArea *sa); struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type); +void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene); +void BKE_screen_view3d_scene_sync(struct bScreen *sc); +void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene); + + /* screen */ void free_screen(struct bScreen *sc); unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index de5f018673f..a8140cb815d 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -330,3 +330,67 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type) } return NULL; } + +void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene) +{ + int bit; + + if(v3d->scenelock && v3d->localvd==NULL) { + v3d->lay= scene->lay; + v3d->camera= scene->camera; + + if(v3d->camera==NULL) { + ARegion *ar; + + for(ar=v3d->regionbase.first; ar; ar= ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d= ar->regiondata; + if(rv3d->persp==RV3D_CAMOB) + rv3d->persp= RV3D_PERSP; + } + } + } + + if((v3d->lay & v3d->layact) == 0) { + for(bit= 0; bit<32; bit++) { + if(v3d->lay & (1<layact= 1<areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for(sl= sa->spacedata.first; sl; sl= sl->next) { + if(sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D*) sl; + BKE_screen_view3d_sync(v3d, sc->scene); + } + } + } +} + +void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene) +{ + bScreen *sc; + ScrArea *sa; + SpaceLink *sl; + + /* from scene copy to the other views */ + for(sc=screen_lb->first; sc; sc=sc->id.next) { + if(sc->scene!=scene) + continue; + + for(sa=sc->areabase.first; sa; sa=sa->next) + for(sl=sa->spacedata.first; sl; sl=sl->next) + if(sl->spacetype==SPACE_VIEW3D) + BKE_screen_view3d_sync((View3D*)sl, scene); + } +} -- cgit v1.2.3 From ce9d5c43e265c1976a7eb5f8476453116327eace Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 23 Apr 2010 05:14:00 +0000 Subject: Spline IK - Influence Control Made the 'Influence' slider work for Spline IK too, and made that setting visible now that it works. Note that there is still some popping that can occur when going to/from influence = 0.0. I'm not sure exactly what's causing this yet, but hopefully it won't be too noticeable in practice. --- source/blender/blenkernel/intern/armature.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index dbc03176b8f..381ecd5150b 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2006,6 +2006,11 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o rangle= dot_v3v3(rmat[1], splineVec); rangle= acos( MAX2(-1.0f, MIN2(1.0f, rangle)) ); + /* multiply the magnitude of the angle by the influence of the constraint to + * control the influence of the SplineIK effect + */ + rangle *= tree->con->enforce; + /* construct rotation matrix from the axis-angle rotation found above * - this call takes care to make sure that the axis provided is a unit vector first */ @@ -2073,13 +2078,26 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o } } - /* step 5: set the location of the bone in the matrix - * - when the 'no-root' option is affected, the chain can retain - * the shape but be moved elsewhere - */ + /* step 5: set the location of the bone in the matrix */ if (ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) { + /* when the 'no-root' option is affected, the chain can retain + * the shape but be moved elsewhere + */ VECCOPY(poseHead, pchan->pose_head); } + else if (tree->con->enforce < 1.0f) { + /* when the influence is too low + * - blend the positions for the 'root' bone + * - stick to the parent for any other + */ + if (pchan->parent) { + VECCOPY(poseHead, pchan->pose_head); + } + else { + // FIXME: this introduces popping artifacts when we reach 0.0 + interp_v3_v3v3(poseHead, pchan->pose_head, poseHead, tree->con->enforce); + } + } VECCOPY(poseMat[3], poseHead); /* finally, store the new transform */ -- cgit v1.2.3 From 08775e8f145a863938c982d18191d1d55a517f98 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 23 Apr 2010 11:19:06 +0000 Subject: Mesh Deform Modifier: compress static binding weights better, threshold is still set very low so in many cases it could be even smaller, but being a bit conservative here to try to avoid breaking rigs. This is not forward-compatible, i.e. loading new files in older blender versions will loose the binding. --- source/blender/blenkernel/BKE_modifier.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index ae6f1f5ed85..d6ab99d6534 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -321,5 +321,8 @@ struct LinkNode *modifiers_calcDataMasks(struct Scene *scene, int required_mode); struct ModifierData *modifiers_getVirtualModifierList(struct Object *ob); +/* here for do_versions */ +void modifier_mdef_compact_influences(struct ModifierData *md); + #endif -- cgit v1.2.3 From 4a51b140cd61bae73de632e3593a05c536456159 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Apr 2010 11:48:17 +0000 Subject: always print reports immediately when running in background mode. --- source/blender/blenkernel/intern/report.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index a7800ddc12a..da8b018d3f8 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -31,6 +31,7 @@ #include "BLI_dynstr.h" #include "BKE_report.h" +#include "BKE_global.h" /* G.background only */ #include #include @@ -93,6 +94,10 @@ void BKE_report(ReportList *reports, ReportType type, const char *message) Report *report; int len; + /* exception, print and return in background, no reason to store a list */ + if(G.background) + reports= NULL; + if(!reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) { printf("%s: %s\n", report_type_str(type), message); fflush(stdout); /* this ensures the message is printed before a crash */ -- cgit v1.2.3 From 6a56b0d844d56d17a4f6a543830932ce838b9578 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 23 Apr 2010 12:11:56 +0000 Subject: Bugfix #22101: Envelopes dont respect armature modifier vertex group mask Changed the point where the vertex groups are retrieved. Hopefully this commit doesn't break any cases I haven't thought of... --- source/blender/blenkernel/intern/armature.c | 31 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 381ecd5150b..6d1d90cb363 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -958,23 +958,26 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, /* get the def_nr for the overall armature vertex group if present */ armature_def_nr= defgroup_name_index(target, defgrp_name); - + + if(ELEM(target->type, OB_MESH, OB_LATTICE)) { + numGroups = BLI_countlist(&target->defbase); + + if(target->type==OB_MESH) { + Mesh *me= target->data; + dverts = me->dvert; + target_totvert = me->totvert; + } + else { + Lattice *lt= target->data; + dverts = lt->dvert; + if(dverts) + target_totvert = lt->pntsu*lt->pntsv*lt->pntsw; + } + } + /* get a vertex-deform-index to posechannel array */ if(deformflag & ARM_DEF_VGROUP) { if(ELEM(target->type, OB_MESH, OB_LATTICE)) { - numGroups = BLI_countlist(&target->defbase); - - if(target->type==OB_MESH) { - Mesh *me= target->data; - dverts = me->dvert; - target_totvert = me->totvert; - } - else { - Lattice *lt= target->data; - dverts = lt->dvert; - if(dverts) - target_totvert = lt->pntsu*lt->pntsv*lt->pntsw; - } /* if we have a DerivedMesh, only use dverts if it has them */ if(dm) if(dm->getVertData(dm, 0, CD_MDEFORMVERT)) -- cgit v1.2.3 From 877e855ca51a015bc363f317d7a5f4c6c372275b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 23 Apr 2010 12:15:50 +0000 Subject: Quick fix, just in case the mesh has no vertex groups, there won't be a crash! --- source/blender/blenkernel/intern/armature.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 6d1d90cb363..3f89fc4f226 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -965,7 +965,8 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, if(target->type==OB_MESH) { Mesh *me= target->data; dverts = me->dvert; - target_totvert = me->totvert; + if(dverts) + target_totvert = me->totvert; } else { Lattice *lt= target->data; -- cgit v1.2.3 From 23ad9588ad21c153cfc4427bc0189285b64411b2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 23 Apr 2010 18:02:50 +0000 Subject: Some fixes from the render branch: * Take border render into account when drawing grid before for render result becomes visible. * Use antialiasing for rendering icon previews. * Fix Full Sample not drawing render result while rendering. * Mesh Deform Modifier: also forgot to commit this file. --- source/blender/blenkernel/intern/image.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 66e6171d9ee..7b727244dcb 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1928,9 +1928,6 @@ 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 */ @@ -1948,11 +1945,17 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ if(rect) ibuf->rect= rect; - ibuf->rect_float= rectf; - ibuf->flags |= IB_rectfloat; - ibuf->channels= channels; - ibuf->zbuf_float= rectz; - ibuf->flags |= IB_zbuffloat; + if(rectf) { + ibuf->rect_float= rectf; + ibuf->flags |= IB_rectfloat; + ibuf->channels= channels; + } + + if(rectz) { + ibuf->zbuf_float= rectz; + ibuf->flags |= IB_zbuffloat; + } + ibuf->dither= dither; ima->ok= IMA_OK_LOADED; -- cgit v1.2.3 From 28e8c04795e40af2a0b2fbc2885e6ab97d4daace Mon Sep 17 00:00:00 2001 From: Tom Musgrove Date: Fri, 23 Apr 2010 20:05:16 +0000 Subject: patch by by xat "Partial fix for bug #22142" --- source/blender/blenkernel/intern/deform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index fecafc701a6..ccb6ebe1f1e 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -201,7 +201,7 @@ int defgroup_name_index (Object *ob, const char *name) bDeformGroup *curdef; int def_nr; - if(name[0] != '\0') { + if(name && name[0] != '\0') { for (curdef=ob->defbase.first, def_nr=0; curdef; curdef=curdef->next, def_nr++) { if (!strcmp(curdef->name, name)) return def_nr; -- cgit v1.2.3 From 39c0e690d3ad350195c8c68b7a8d317d056ff6a0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Apr 2010 23:57:00 +0000 Subject: sub_v3_v3v3 --> sub_v3_v3 (where possible) --- source/blender/blenkernel/intern/anim.c | 5 ++--- source/blender/blenkernel/intern/armature.c | 7 +++---- source/blender/blenkernel/intern/boids.c | 14 +++++++------- source/blender/blenkernel/intern/colortools.c | 4 ++-- source/blender/blenkernel/intern/object.c | 6 +++--- source/blender/blenkernel/intern/sketch.c | 2 +- 6 files changed, 18 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 34dcf41d441..8619ab1eb1c 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -727,9 +727,8 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n vertexDupliData *vdd= userData; float vec[3], q2[4], mat[3][3], tmat[4][4], obmat[4][4]; - VECCOPY(vec, co); - mul_m4_v3(vdd->pmat, vec); - sub_v3_v3v3(vec, vec, vdd->pmat[3]); + mul_v3_m4v3(vec, vdd->pmat, co); + sub_v3_v3(vec, vdd->pmat[3]); add_v3_v3(vec, vdd->obmat[3]); copy_m4_m4(obmat, vdd->obmat); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 3f89fc4f226..ba295d4b09a 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -850,9 +850,8 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo mul_m4_v3(pchan->chan_mat, cop); // Make this a delta from the base position - sub_v3_v3v3(cop, cop, co); - cop[0]*=fac; cop[1]*=fac; cop[2]*=fac; - add_v3_v3(vec, cop); + sub_v3_v3(cop, co); + madd_v3_v3fl(vec, cop, fac); if(mat) pchan_deform_mat_add(pchan, fac, bbonemat, mat); @@ -1110,7 +1109,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, if(armature_weight != 1.0f) { VECCOPY(dco, co); mul_v3m3_dq( dco, (defMats)? summat: NULL,dq); - sub_v3_v3v3(dco, dco, co); + sub_v3_v3(dco, co); mul_v3_fl(dco, armature_weight); add_v3_v3(co, dco); } diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index b18ab8767e3..82602a6951d 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -400,8 +400,8 @@ static int rule_flock(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti mul_v3_fl(loc, 1.0f/((float)neighbors - 1.0f)); mul_v3_fl(vec, 1.0f/((float)neighbors - 1.0f)); - sub_v3_v3v3(loc, loc, pa->prev_state.co); - sub_v3_v3v3(vec, vec, pa->prev_state.vel); + sub_v3_v3(loc, pa->prev_state.co); + sub_v3_v3(vec, pa->prev_state.vel); add_v3_v3(bbd->wanted_co, vec); add_v3_v3(bbd->wanted_co, loc); @@ -573,7 +573,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va if(asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) { project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->scene->physics_settings.gravity); mul_v3_fl(vec, asbr->level); - sub_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); + sub_v3_v3(bbd->wanted_co, vec); } } else { @@ -590,7 +590,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va if(asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) { project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->scene->physics_settings.gravity); mul_v3_fl(vec, asbr->level); - sub_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec); + sub_v3_v3(bbd->wanted_co, vec); } } @@ -765,10 +765,10 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro if(!bbd->sim->colliders) return NULL; - VECCOPY(col.co1, pa->state.co); - VECCOPY(col.co2, pa->state.co); + copy_v3_v3(col.co1, pa->state.co); + copy_v3_v3(col.co2, pa->state.co); add_v3_v3(col.co1, zvec); - sub_v3_v3v3(col.co2, col.co2, zvec); + sub_v3_v3(col.co2, zvec); sub_v3_v3v3(ray_dir, col.co2, col.co1); col.t = 0.0f; hit.index = -1; diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 353adf932a5..44a52964f2a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -467,7 +467,7 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr) if(vec[0] < bezt[0].vec[1][0]) vec[0]= bezt[0].vec[1][0]; - sub_v3_v3v3(vec, vec, bezt[0].vec[1]); + sub_v3_v3(vec, bezt[0].vec[1]); nlen= len_v3(vec); if(nlen>FLT_EPSILON) { mul_v3_fl(vec, hlen/nlen); @@ -484,7 +484,7 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr) if(vec[0] > bezt[a].vec[1][0]) vec[0]= bezt[a].vec[1][0]; - sub_v3_v3v3(vec, vec, bezt[a].vec[1]); + sub_v3_v3(vec, bezt[a].vec[1]); nlen= len_v3(vec); if(nlen>FLT_EPSILON) { mul_v3_fl(vec, hlen/nlen); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c1baced8f05..6206696e109 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2341,12 +2341,12 @@ void minmax_object(Object *ob, float *min, float *max) default: DO_MINMAX(ob->obmat[3], min, max); - VECCOPY(vec, ob->obmat[3]); + copy_v3_v3(vec, ob->obmat[3]); add_v3_v3(vec, ob->size); DO_MINMAX(vec, min, max); - VECCOPY(vec, ob->obmat[3]); - sub_v3_v3v3(vec, vec, ob->size); + copy_v3_v3(vec, ob->obmat[3]); + sub_v3_v3(vec, ob->size); DO_MINMAX(vec, min, max); break; } diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 6032a0eea3d..33871f78864 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -336,7 +336,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) VECCOPY(offset, normal); mul_v3_fl(offset, d); - sub_v3_v3v3(p, p, distance); + sub_v3_v3(p, distance); add_v3_v3(p, offset); } } -- cgit v1.2.3 From ace1c998c42263712bccbce5e2942aecdc8c592e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Apr 2010 10:08:07 +0000 Subject: warning cleanup, also made voxel.c and volumetric.c use BM_INLINE define rather then having their own ifdefs in each file. --- source/blender/blenkernel/intern/packedFile.c | 4 ++-- source/blender/blenkernel/intern/seqeffects.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 0c50cea075d..fb973febf04 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -264,7 +264,7 @@ int writePackedFile(ReportList *reports, char *filename, PackedFile *pf, int gui char tempname[FILE_MAXDIR + FILE_MAXFILE]; /* void *data; */ - if (guimode); //XXX waitcursor(1); + if (guimode) {} //XXX waitcursor(1); strcpy(name, filename); BLI_path_abs(name, G.sce); @@ -308,7 +308,7 @@ int writePackedFile(ReportList *reports, char *filename, PackedFile *pf, int gui } } - if(guimode); //XXX waitcursor(0); + if(guimode) {} //XXX waitcursor(0); return (ret_value); } diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 33c90d1a94e..3c9227fd2a6 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -52,7 +52,7 @@ #include "RNA_access.h" /* **** XXX **** */ -static void error() {} +static void error(const char *error, ...) {} #define INT 96 #define FLO 128 -- cgit v1.2.3 From 5b4e62a977ba1cbe0f2b66a28c5a228da3b9faa6 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 24 Apr 2010 16:35:16 +0000 Subject: Fix for #22135, loading ffmpeg now before .B25.blend is loaded. --- source/blender/blenkernel/BKE_sound.h | 2 ++ source/blender/blenkernel/intern/sound.c | 5 +++++ 2 files changed, 7 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index b89767d2586..50c86e80b08 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -38,6 +38,8 @@ struct ListBase; struct Main; struct Sequence; +void sound_init_once(); + void sound_init(struct Main *main); void sound_exit(); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index fc003b12959..24e5014a741 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -73,6 +73,11 @@ void sound_force_device(int device) force_device = device; } +void sound_init_once() +{ + AUD_initOnce(); +} + void sound_init(struct Main *bmain) { AUD_DeviceSpecs specs; -- cgit v1.2.3 From 4bd3163ea6399311d33f1c6c280d0d23c3a4e370 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Apr 2010 19:26:05 +0000 Subject: py api: fix for context returning None for an empty list such as 'context.selected_objects', now returns [] --- source/blender/blenkernel/BKE_context.h | 11 ++++++++++- source/blender/blenkernel/intern/context.c | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 48e2dbf4fec..f6d41190c5a 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -170,11 +170,17 @@ void CTX_wm_menu_set(bContext *C, struct ARegion *menu); freed with BLI_freelistN! - the dir listbase consits of LinkData items */ +/* data type, needed so we can tell between a NULL pointer and an empty list */ +enum { + CTX_DATA_TYPE_POINTER = 0, + CTX_DATA_TYPE_COLLECTION +}; + PointerRNA CTX_data_pointer_get(const bContext *C, const char *member); PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type); ListBase CTX_data_collection_get(const bContext *C, const char *member); ListBase CTX_data_dir_get(const bContext *C); -int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb); +int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type); void CTX_data_id_pointer_set(bContextDataResult *result, struct ID *id); void CTX_data_pointer_set(bContextDataResult *result, struct ID *id, StructRNA *type, void *data); @@ -184,6 +190,9 @@ void CTX_data_list_add(bContextDataResult *result, struct ID *id, StructRNA *typ void CTX_data_dir_set(bContextDataResult *result, const char **member); +void CTX_data_type_set(struct bContextDataResult *result, short type); +short CTX_data_type_get(struct bContextDataResult *result); + int CTX_data_equals(const char *member, const char *str); int CTX_data_dir(const char *member); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index e8f73a92ad5..9520df71b60 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -404,6 +404,7 @@ struct bContextDataResult { PointerRNA ptr; ListBase list; const char **dir; + short type; /* 0: normal, 1: seq */ }; static int ctx_data_get(bContext *C, const char *member, bContextDataResult *result) @@ -548,7 +549,7 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member) } /* 1:found, -1:found but not set, 0:not found */ -int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb) +int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type) { bContextDataResult result; int ret= ctx_data_get((bContext*)C, member, &result); @@ -556,10 +557,12 @@ int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListB if(ret==1) { *r_ptr= result.ptr; *r_lb= result.list; + *r_type= result.type; } else { memset(r_ptr, 0, sizeof(*r_ptr)); memset(r_lb, 0, sizeof(*r_lb)); + *r_type= 0; } return ret; @@ -682,6 +685,16 @@ void CTX_data_dir_set(bContextDataResult *result, const char **dir) result->dir= dir; } +void CTX_data_type_set(bContextDataResult *result, short type) +{ + result->type= type; +} + +short CTX_data_type_get(bContextDataResult *result) +{ + return result->type; +} + /* data context */ Main *CTX_data_main(const bContext *C) -- cgit v1.2.3 From 2cec60e2ebd243e3bf3216c70f465a717b9de29a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 25 Apr 2010 00:19:10 +0000 Subject: fix for a library linking problem where a proxy object linked into a blend would cause the proxy, driver's ID to be directly linked as well. eg. character.blend -> anim.blend -> comp.blend ... Would link the character.blend directly into comp.blend because on driver ID's. In this case id_lib_extern doenst need to be called because the object its linked from is a library. --- source/blender/blenkernel/intern/object.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6206696e109..ce064a78cff 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1469,10 +1469,16 @@ void object_copy_proxy_drivers(Object *ob, Object *target) /* all drivers */ DRIVER_TARGETS_LOOPER(dvar) { - if ((Object *)dtar->id == target) - dtar->id= (ID *)ob; - else - id_lib_extern((ID *)dtar->id); + if(dtar->id) { + if ((Object *)dtar->id == target) + dtar->id= (ID *)ob; + else { + /* only on local objects because this causes indirect links a -> b -> c,blend to point directly to a.blend + * when a.blend has a proxy thats linked into c.blend */ + if(ob->id.lib==NULL) + id_lib_extern((ID *)dtar->id); + } + } } DRIVER_TARGETS_LOOPER_END } -- cgit v1.2.3 From b37ae4a3754bf0640de32b6a7e2be970d359d822 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 25 Apr 2010 01:10:03 +0000 Subject: re-arrange modifier and blenkernel to overcome some linking problems that stopped modifiers being able to build when using some blender-kernel defined stuff --- source/blender/blenkernel/intern/modifier.c | 46 ++--------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index e483ae0e6a8..858e9d6c6d9 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -54,50 +54,8 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) static int types_init = 1; if (types_init) { - memset(types, 0, sizeof(types)); - -#define INIT_TYPE(typeName) \ - (types[eModifierType_##typeName] = &modifierType_##typeName) - - INIT_TYPE(None); - INIT_TYPE(Curve); - INIT_TYPE(Lattice); - INIT_TYPE(Subsurf); - INIT_TYPE(Build); - INIT_TYPE(Array); - INIT_TYPE(Mirror); - INIT_TYPE(EdgeSplit); - INIT_TYPE(Bevel); - INIT_TYPE(Displace); - INIT_TYPE(UVProject); - INIT_TYPE(Decimate); - INIT_TYPE(Smooth); - INIT_TYPE(Cast); - INIT_TYPE(Wave); - INIT_TYPE(Armature); - INIT_TYPE(Hook); - INIT_TYPE(Softbody); - INIT_TYPE(Cloth); - INIT_TYPE(Collision); - INIT_TYPE(Boolean); - INIT_TYPE(MeshDeform); - INIT_TYPE(ParticleSystem); - INIT_TYPE(ParticleInstance); - INIT_TYPE(Explode); - INIT_TYPE(Shrinkwrap); - INIT_TYPE(Fluidsim); - INIT_TYPE(Mask); - INIT_TYPE(SimpleDeform); - INIT_TYPE(Multires); - INIT_TYPE(Surface); - INIT_TYPE(Smoke); - INIT_TYPE(ShapeKey); - INIT_TYPE(Solidify); - INIT_TYPE(Screw); - - types_init = 0; - -#undef INIT_TYPE + modifier_type_init(types, type); /* MOD_utils.c */ + types_init= 0; } if(type >= 0 && type < NUM_MODIFIER_TYPES && -- cgit v1.2.3 From 708667c6f6695b04f613566c4ff1b6c2788ab50c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 25 Apr 2010 03:34:16 +0000 Subject: minor mathutils update - docstring for Euler.rotate - rotate_eul, use upper case in Py and C. - use less verbose repr method. --- source/blender/blenkernel/intern/constraint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index a07fc4ada39..79fa5e6a2a2 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1647,7 +1647,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[0] = obeul[0]; else { if (data->flag & ROTLIKE_OFFSET) - rotate_eulO(eul, cob->rotOrder, 'x', obeul[0]); + rotate_eulO(eul, cob->rotOrder, 'X', obeul[0]); if (data->flag & ROTLIKE_X_INVERT) eul[0] *= -1; @@ -1657,7 +1657,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[1] = obeul[1]; else { if (data->flag & ROTLIKE_OFFSET) - rotate_eulO(eul, cob->rotOrder, 'y', obeul[1]); + rotate_eulO(eul, cob->rotOrder, 'Y', obeul[1]); if (data->flag & ROTLIKE_Y_INVERT) eul[1] *= -1; @@ -1667,7 +1667,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[2] = obeul[2]; else { if (data->flag & ROTLIKE_OFFSET) - rotate_eulO(eul, cob->rotOrder, 'z', obeul[2]); + rotate_eulO(eul, cob->rotOrder, 'Z', obeul[2]); if (data->flag & ROTLIKE_Z_INVERT) eul[2] *= -1; -- cgit v1.2.3 From a92b8b7ff6fae4a5d11baebb062b83e7b1b61dcc Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 25 Apr 2010 12:53:39 +0000 Subject: == Sequencer == This adds MULTICAM-editing support for blender. (Well, the beginning of.) There is now a new effect track, named MULTICAM, which just selects one of the lower tracks. Doesn't sound that exciting, but if you combine this with A/B-Trim (moving split points of two directly connected tracks around, while magically resizing both strips, something to be added), you just do: * add several tracks for your camera angles * (optionally) sync those tracks * add one multicam track on top Use that multicam-track to edit your movie. (Either using fcurves on the multicam source selector or using knife-tool and A/B-Trim.) Compare that to: * add several tracks * add cross fades between them * do some python scripting to add several fcurves to make that beast somewhat work. * cry out loud, using it, if you have to move cut points around Alternatively, even harder: * just edit the old way and put strip after strip You might think, that this isn't really helpfull for animators, but consider using scene-strips (in OpenGL-mode) for input, that are set for different camera angles and can now be intercut a lot more easily... Also: small fix on the way: the speed effect can now be used in cascade. (Don't know, if anyone used it that way, but now it works.) --- source/blender/blenkernel/BKE_sequencer.h | 19 +-- source/blender/blenkernel/intern/seqeffects.c | 160 +++++++++++++++++++------- source/blender/blenkernel/intern/sequencer.c | 46 ++++++-- 3 files changed, 167 insertions(+), 58 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 40168882dcb..2bf6eee5e6b 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -112,22 +112,22 @@ struct SeqEffectHandle { /* stores the y-range of the effect IPO */ void (*store_icu_yrange)(struct Sequence * seq, - short adrcode, float *ymin, float *ymax); + short adrcode, float *ymin, float *ymax); /* stores the default facf0 and facf1 if no IPO is present */ void (*get_default_fac)(struct Sequence *seq, int cfra, - float * facf0, float * facf1); + float * facf0, float * facf1); /* execute the effect - sequence effects are only required to either support - float-rects or byte-rects - (mixed cases are handled one layer up...) */ + sequence effects are only required to either support + float-rects or byte-rects + (mixed cases are handled one layer up...) */ void (*execute)(struct Scene *scene, struct Sequence *seq, int cfra, - float facf0, float facf1, - int x, int y, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out); + float facf0, float facf1, + int x, int y, int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3, struct ImBuf *out); }; /* ********************* prototypes *************** */ @@ -149,6 +149,7 @@ char *give_seqname(struct Sequence *seq); struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size); struct ImBuf *give_ibuf_seq_threaded(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size); struct ImBuf *give_ibuf_seq_direct(struct Scene *scene, int rectx, int recty, int cfra, int render_size, struct Sequence *seq); +struct ImBuf *give_ibuf_seqbase(struct Scene *scene, int rectx, int recty, int cfra, int chan_shown, int render_size, struct ListBase *seqbasep); void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int render_size); void calc_sequence(struct Scene *scene, struct Sequence *seq); void calc_sequence_disp(struct Scene *scene, struct Sequence *seq); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 3c9227fd2a6..b5f9c8fe542 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -230,9 +230,10 @@ static ImBuf * IMB_cast_away_list(ImBuf * i) } static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3, struct ImBuf *out) { char *cp; int float_rendering; @@ -477,6 +478,7 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, static void do_alphaover_effect(Scene *scene, Sequence *seq, int cfra, float facf0, float facf1, int x, int y, + int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, struct ImBuf *out) { @@ -644,6 +646,7 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, static void do_alphaunder_effect(Scene *scene, Sequence *seq, int cfra, float facf0, float facf1, int x, int y, + int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, struct ImBuf *out) { @@ -763,9 +766,10 @@ void do_cross_effect_float(float facf0, float facf1, int x, int y, /* carefull: also used by speed effect! */ static void do_cross_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3, struct ImBuf *out) { if (out->rect_float) { do_cross_effect_float( @@ -1026,6 +1030,7 @@ static void do_gammacross_effect_float(float facf0, float facf1, static void do_gammacross_effect(Scene *scene, Sequence *seq, int cfra, float facf0, float facf1, int x, int y, + int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, struct ImBuf *out) { @@ -1140,6 +1145,7 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, static void do_add_effect(Scene *scene, Sequence *seq, int cfra, float facf0, float facf1, int x, int y, + int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, struct ImBuf *out) { @@ -1251,7 +1257,8 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y, } static void do_sub_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, + float facf0, float facf1, int x, int y, + int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, struct ImBuf *out) { @@ -1360,6 +1367,7 @@ static void do_drop_effect_float(float facf0, float facf1, int x, int y, static void do_drop_effect(Scene *scene, Sequence *seq, int cfra, float facf0, float facf1, int x, int y, + int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf * ibuf3, struct ImBuf *out) @@ -1481,6 +1489,7 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, static void do_mul_effect(Scene *scene, Sequence *seq, int cfra, float facf0, float facf1, int x, int y, + int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, struct ImBuf *out) { @@ -1931,6 +1940,7 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float facf1, static void do_wipe_effect(Scene *scene, Sequence *seq, int cfra, float facf0, float facf1, int x, int y, + int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, struct ImBuf *out) { @@ -2075,9 +2085,10 @@ static void do_transform(Scene *scene, Sequence *seq, float facf0, int x, int y, static void do_transform_effect(Scene *scene, Sequence *seq,int cfra, - float facf0, float facf1, int x, int y, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3, struct ImBuf *out) { do_transform(scene, seq, facf0, x, y, ibuf1, out); } @@ -2588,6 +2599,7 @@ static void do_glow_effect_float(Sequence *seq, float facf0, float facf1, static void do_glow_effect(Scene *scene, Sequence *seq, int cfra, float facf0, float facf1, int x, int y, + int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, struct ImBuf *out) { @@ -2643,6 +2655,7 @@ static int early_out_color(struct Sequence *seq, static void do_solid_color(Scene *scene, Sequence *seq, int cfra, float facf0, float facf1, int x, int y, + int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, struct ImBuf *out) { @@ -2717,6 +2730,64 @@ static void do_solid_color(Scene *scene, Sequence *seq, int cfra, } } +/* ********************************************************************** + MULTICAM + ********************************************************************** */ + +/* no effect inputs for multicam, we use give_ibuf_seq */ +static int num_inputs_multicam() +{ + return 0; +} + +static int early_out_multicam(struct Sequence *seq, float facf0, float facf1) +{ + return -1; +} + +static void do_multicam(Scene *scene, Sequence *seq, int cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3, struct ImBuf *out) +{ + struct ImBuf * i; + Editing * ed; + ListBase * seqbasep; + + if (seq->multicam_source == 0 || seq->multicam_source >= seq->machine) { + return; + } + + ed = scene->ed; + if (!ed) { + return; + } + seqbasep = seq_seqbase(&ed->seqbase, seq); + if (!seqbasep) { + return; + } + + i = give_ibuf_seqbase(scene, + out->x, out->y, cfra, seq->multicam_source, + preview_render_size, seqbasep); + if (!i) { + return; + } + + if (out->rect && i->rect) { + memcpy(out->rect, i->rect, out->x * out->y * 4); + } else if (out->rect_float && i->rect_float) { + memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float)); + } else if (out->rect && i->rect_float) { + IMB_rect_from_float(i); + memcpy(out->rect, i->rect, out->x * out->y * 4); + } else if (out->rect_float && i->rect) { + IMB_float_from_rect(i); + memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float)); + } +} + /* ********************************************************************** SPEED ********************************************************************** */ @@ -2854,16 +2925,16 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) for (cfra = 1; cfra < v->length; cfra++) { if(fcu) { - if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) { - ctime = seq->startdisp + cfra; - div = 1.0; - } else { - ctime= cfra; - div= v->length / 100.0f; - if(div==0.0) return; - } - - facf = evaluate_fcurve(fcu, ctime/div); + if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) { + ctime = seq->startdisp + cfra; + div = 1.0; + } else { + ctime= cfra; + div= v->length / 100.0f; + if(div==0.0) return; + } + + facf = evaluate_fcurve(fcu, ctime/div); } else { facf = fallback_fac; } @@ -2885,19 +2956,19 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) for (cfra = 0; cfra < v->length; cfra++) { if(fcu) { - if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) { - ctime = seq->startdisp + cfra; - div = 1.0; - } else { - ctime= cfra; - div= v->length / 100.0f; - if(div==0.0) return; - } - - facf = evaluate_fcurve(fcu, ctime / div); - if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) { - facf *= v->length; - } + if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) { + ctime = seq->startdisp + cfra; + div = 1.0; + } else { + ctime= cfra; + div= v->length / 100.0f; + if(div==0.0) return; + } + + facf = evaluate_fcurve(fcu, ctime / div); + if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) { + facf *= v->length; + } } if (!fcu) { @@ -3005,16 +3076,20 @@ static void get_default_fac_fade(struct Sequence *seq, int cfra, } static void do_overdrop_effect(Scene *scene, Sequence *seq, int cfra, - float fac, float facf, - int x, int y, struct ImBuf * ibuf1, - struct ImBuf * ibuf2, - struct ImBuf * ibuf3, - struct ImBuf * out) + float fac, float facf, + int x, int y, + int preview_render_size, + struct ImBuf * ibuf1, + struct ImBuf * ibuf2, + struct ImBuf * ibuf3, + struct ImBuf * out) { do_drop_effect(scene, seq, cfra, fac, facf, x, y, - ibuf1, ibuf2, ibuf3, out); + preview_render_size, + ibuf1, ibuf2, ibuf3, out); do_alphaover_effect(scene, seq, cfra, fac, facf, x, y, - ibuf1, ibuf2, ibuf3, out); + preview_render_size, + ibuf1, ibuf2, ibuf3, out); } static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) @@ -3121,6 +3196,11 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) rval.early_out = do_plugin_early_out; rval.get_default_fac = get_default_fac_fade; break; + case SEQ_MULTICAM: + rval.num_inputs = num_inputs_multicam; + rval.early_out = early_out_multicam; + rval.execute = do_multicam; + break; } return rval; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d6bb5cc3745..8de093cd845 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -886,7 +886,8 @@ static void multibuf(ImBuf *ibuf, float fmul) } } -static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se) +static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se, + int render_size) { TStripElem *se1, *se2, *se3; float fac, facf; @@ -920,7 +921,7 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se) if (early_out == -1) { /* no input needed */ sh.execute(scene, seq, cfra, fac, facf, - se->ibuf->x, se->ibuf->y, + se->ibuf->x, se->ibuf->y, render_size, 0, 0, 0, se->ibuf); return; } @@ -1008,7 +1009,8 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se) IMB_rect_from_float(se3->ibuf); } - sh.execute(scene, seq, cfra, fac, facf, x, y, se1->ibuf, se2->ibuf, se3->ibuf, + sh.execute(scene, seq, cfra, fac, facf, x, y, render_size, + se1->ibuf, se2->ibuf, se3->ibuf, se->ibuf); } @@ -2023,7 +2025,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int else se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect, 0); - do_effect(scene, cfra, seq, se); + do_effect(scene, cfra, seq, se, render_size); if (input_have_to_preprocess(scene, seq, se, cfra, seqrectx, seqrecty) && !build_proxy_run) { @@ -2362,7 +2364,7 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra test_and_auto_discard_ibuf(se, seqrectx, seqrecty); if (se->ibuf == NULL) { - se1 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_left, render_size, seqrectx, seqrecty); + se1 = do_build_seq_recursively(scene, seq->seq1, cfra_left, render_size, seqrectx, seqrecty); if((se1 && se1->ibuf && se1->ibuf->rect_float)) se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); @@ -2394,8 +2396,8 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra } if (se->ibuf == NULL) { - se1 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_left, render_size, seqrectx, seqrecty); - se2 = do_build_seq_recursively_impl(scene, seq->seq1, cfra_right, render_size, seqrectx, seqrecty); + se1 = do_build_seq_recursively(scene, seq->seq1, cfra_left, render_size, seqrectx, seqrecty); + se2 = do_build_seq_recursively(scene, seq->seq1, cfra_right, render_size, seqrectx, seqrecty); if((se1 && se1->ibuf && se1->ibuf->rect_float)) se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); @@ -2411,6 +2413,7 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra f_cfra - (float) cfra_left, f_cfra - (float) cfra_left, se->ibuf->x, se->ibuf->y, + render_size, se1->ibuf, se2->ibuf, 0, se->ibuf); } } @@ -2450,6 +2453,11 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra static TStripElem* do_build_seq_recursively(Scene *scene, Sequence * seq, int cfra, int render_size, int seqrectx, int seqrecty) { TStripElem *se; + + /* BAD HACK! Seperate handling for speed effects needed, since + a) you can't just fetch a different cfra within an effect strip + b) we have to blend two frames, and CFRA is not float... + */ if (seq->type == SEQ_SPEED) { se = do_handle_speed_effect(scene, seq, cfra, render_size, seqrectx, seqrecty); } else { @@ -2679,12 +2687,12 @@ static TStripElem* do_build_seq_array_recursively( if (swap_input) { sh.execute(scene, seq, cfra, - facf, facf, x, y, + facf, facf, x, y, render_size, se2->ibuf, se1->ibuf_comp, 0, se2->ibuf_comp); } else { sh.execute(scene, seq, cfra, - facf, facf, x, y, + facf, facf, x, y, render_size, se1->ibuf_comp, se2->ibuf, 0, se2->ibuf_comp); } @@ -2746,6 +2754,26 @@ static ImBuf *give_ibuf_seq_impl(Scene *scene, int rectx, int recty, int cfra, i return se->ibuf_comp; } +ImBuf *give_ibuf_seqbase(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size, ListBase *seqbasep) +{ + TStripElem *se; + + se = do_build_seq_array_recursively(scene, seqbasep, cfra, chanshown, render_size, rectx, recty); + + if(!se) { + return 0; + } + + check_limiter_refcount_comp("give_ibuf_seqbase", se); + + if (se->ibuf_comp) { + IMB_cache_limiter_unref(se->ibuf_comp); + } + + return se->ibuf_comp; +} + + ImBuf *give_ibuf_seq_direct(Scene *scene, int rectx, int recty, int cfra, int render_size, Sequence *seq) { TStripElem* se; -- cgit v1.2.3 From cacd2477c0daae08e1602d65419cbc645b628c38 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 25 Apr 2010 13:27:52 +0000 Subject: bugfix [#22117] Memory Error messages with Spline IK chainlen was initialized as 0 --- source/blender/blenkernel/intern/armature.c | 9 +-------- source/blender/blenkernel/intern/constraint.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index ba295d4b09a..a2dbaa9d666 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1773,20 +1773,13 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *ob, bPoseChannel /* find the root bone and the chain of bones from the root to the tip * NOTE: this assumes that the bones are connected, but that may not be true... */ - for (pchan= pchan_tip; pchan; pchan= pchan->parent) { + for (pchan= pchan_tip; pchan && (segcount < ikData->chainlen); pchan= pchan->parent, segcount++) { /* store this segment in the chain */ pchanChain[segcount]= pchan; /* if performing rebinding, calculate the length of the bone */ boneLengths[segcount]= pchan->bone->length; totLength += boneLengths[segcount]; - - /* check if we've gotten the number of bones required yet (after incrementing the count first) - * NOTE: the 255 limit here is rather ugly, but the standard IK does this too! - */ - segcount++; - if ((segcount == ikData->chainlen) || (segcount > 255)) - break; } if (segcount == 0) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 79fa5e6a2a2..6941742a0c9 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3750,6 +3750,17 @@ static void splineik_copy (bConstraint *con, bConstraint *srccon) /* copy the binding array */ dst->points= MEM_dupallocN(src->points); + dst->numpoints= src->numpoints; + dst->chainlen= src->chainlen; + dst->flag= src->flag; + dst->xzScaleMode= src->xzScaleMode; +} + +static void splineik_new_data (void *cdata) +{ + bSplineIKConstraint *data= (bSplineIKConstraint *)cdata; + + data->chainlen= 1; } static void splineik_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) @@ -3816,7 +3827,7 @@ static bConstraintTypeInfo CTI_SPLINEIK = { NULL, /* relink data */ splineik_id_looper, /* id looper */ splineik_copy, /* copy data */ - NULL, /* new data */ + splineik_new_data, /* new data */ splineik_get_tars, /* get constraint targets */ splineik_flush_tars, /* flush constraint targets */ splineik_get_tarmat, /* get target matrix */ -- cgit v1.2.3 From 4f6e3dad47946490facbb8121a35d7ac727d2416 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 25 Apr 2010 15:39:04 +0000 Subject: == Sequencer == Forgot some changes for multicam support. --- source/blender/blenkernel/intern/sequencer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 8de093cd845..9b3c613aef2 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -795,6 +795,7 @@ static char *give_seqname_by_type(int type) case SEQ_GLOW: return "Glow"; case SEQ_TRANSFORM: return "Transform"; case SEQ_COLOR: return "Color"; + case SEQ_MULTICAM: return "Multicam"; case SEQ_SPEED: return "Speed"; default: return 0; @@ -3449,7 +3450,8 @@ void seq_tx_set_final_right(Sequence *seq, int val) since they work a bit differently to normal image seq's (during transform) */ int seq_single_check(Sequence *seq) { - if ( seq->len==1 && (seq->type == SEQ_IMAGE || seq->type == SEQ_COLOR)) + if ( seq->len==1 && (seq->type == SEQ_IMAGE || seq->type == SEQ_COLOR + || seq->type == SEQ_MULTICAM)) return 1; else return 0; -- cgit v1.2.3 From 47e1f253c59c3108159732c30da89a7ad154261b Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 26 Apr 2010 02:23:13 +0000 Subject: Fix [#22160] blender 2.5 alpha2 can't open file grass.blend from blenderguru Textures were being called with multitex_ext with osatex enabled, but NULL derivates. Fixed this for texture effectors and a couple of other places. --- source/blender/blenkernel/intern/brush.c | 2 +- source/blender/blenkernel/intern/effect.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 4b8c3a2a0f4..dedf82b6dcc 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -930,7 +930,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side) co[2]= 0.0f; /* This is copied from displace modifier code */ - hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 1, &texres); + hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 0, &texres); /* if the texture gave an RGB value, we assume it didn't give a valid * intensity, so calculate one (formula from do_material_tex). diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index a0416bc2b34..c780971c3fa 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -780,7 +780,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP mul_mat3_m4_v3(eff->ob->obmat, tex_co); } - hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 1, result); + hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 0, result); if(hasrgb && mode==PFIELD_TEX_RGB) { force[0] = (0.5f - result->tr) * strength; @@ -791,15 +791,15 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP strength/=nabla; tex_co[0] += nabla; - multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 1, result+1); + multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+1); tex_co[0] -= nabla; tex_co[1] += nabla; - multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 1, result+2); + multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+2); tex_co[1] -= nabla; tex_co[2] += nabla; - multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 1, result+3); + multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3); if(mode == PFIELD_TEX_GRAD || !hasrgb) { /* if we dont have rgb fall back to grad */ force[0] = (result[0].tin - result[1].tin) * strength; -- cgit v1.2.3 From f85fe4d633a565106048f1e9511894d2539e78a6 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 26 Apr 2010 03:42:38 +0000 Subject: Pass constraint names as operator properties in constraint operators This is similar to commit revision 22078, but for constraint operators rather than modifiers, making it possible to use them from scripting. --- source/blender/blenkernel/BKE_constraint.h | 3 ++- source/blender/blenkernel/intern/constraint.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index 9c5e89bff76..94863e15e46 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -130,7 +130,8 @@ void free_constraint_data(struct bConstraint *con); /* Constraint API function prototypes */ struct bConstraint *constraints_get_active(struct ListBase *list); void constraints_set_active(ListBase *list, struct bConstraint *con); - +struct bConstraint *constraints_findByName(struct ListBase *list, const char *name); + struct bConstraint *add_ob_constraint(struct Object *ob, const char *name, short type); struct bConstraint *add_pose_constraint(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 6941742a0c9..9dab2c1c07e 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_editVert.h" @@ -4162,6 +4163,11 @@ void copy_constraints (ListBase *dst, const ListBase *src) /* ......... */ +bConstraint *constraints_findByName(ListBase *list, const char *name) +{ + return BLI_findstring(list, name, offsetof(bConstraint, name)); +} + /* finds the 'active' constraint in a constraint stack */ bConstraint *constraints_get_active (ListBase *list) { -- cgit v1.2.3 From b5d28306d029acbeecc48afcabff7fdb321abdd8 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 26 Apr 2010 06:33:04 +0000 Subject: Bugfix [#22069] Speed-Ipos are not imported correctly from 2.49 to 2.5 - IPO-blocks for curves were not getting handled correctly (i.e. no conversion and relinking was taking place) when converting from 2.4x to 2.5 - Old 'speed' IPO's now have their values multiplied by the path length when they are loaded from old 2.4x files so that they work correctly in 2.5. Also... - Cleaned up a few instances of scruffy code formatted in some weird ad-hoc way. - Debug prints for the start/end of the file conversion process are now all hidden behind debug-only checks. Unless the way the conversions are done is significantly changed at some point, this should be sufficient... --- source/blender/blenkernel/intern/ipo.c | 113 +++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 41 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 50574f1ef7b..f96100bad06 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -849,19 +849,19 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co case ID_WO: /* world */ propname= world_adrcodes_to_paths(adrcode, &dummy_index); break; - + case ID_PA: /* particle */ propname= particle_adrcodes_to_paths(adrcode, &dummy_index); break; - /* XXX problematic blocktypes */ case ID_CU: /* curve */ /* this used to be a 'dummy' curve which got evaluated on the fly... * now we've got real var for this! */ propname= "eval_time"; break; - + + /* XXX problematic blocktypes */ case ID_SEQ: /* sequencer strip */ //SEQ_FAC1: switch (adrcode) { @@ -1112,7 +1112,7 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c * actname: name of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to * constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to */ -static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, int muteipo) +static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, int muteipo) { AdrBit2Path *abp; FCurve *fcu; @@ -1277,6 +1277,20 @@ static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, cha dst->vec[2][1] *= fac; } + /* correct values for path speed curves + * - their values were 0-1 + * - we now need as 'frames' + */ + if ( (id) && (icu->blocktype == GS(id->name)) && + (fcu->rna_path && strcmp(fcu->rna_path, "eval_time")==0) ) + { + Curve *cu = (Curve *)id; + + dst->vec[0][1] *= cu->pathlen; + dst->vec[1][1] *= cu->pathlen; + dst->vec[2][1] *= cu->pathlen; + } + /* correct times for rotation drivers * - need to go from degrees to radians... * - there's only really 1 target to worry about @@ -1312,7 +1326,7 @@ static void icu_to_fcurves (ListBase *groups, ListBase *list, IpoCurve *icu, cha * This does not assume that any ID or AnimData uses it, but does assume that * it is given two lists, which it will perform driver/animation-data separation. */ -static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase *animgroups, ListBase *anim, ListBase *drivers) +static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], ListBase *animgroups, ListBase *anim, ListBase *drivers) { IpoCurve *icu; @@ -1343,7 +1357,7 @@ static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase if (icu->driver) { /* Blender 2.4x allowed empty drivers, but we don't now, since they cause more trouble than they're worth */ if ((icu->driver->ob) || (icu->driver->type == IPO_DRIVER_TYPE_PYTHON)) { - icu_to_fcurves(NULL, drivers, icu, actname, constname, ipo->muteipo); + icu_to_fcurves(id, NULL, drivers, icu, actname, constname, ipo->muteipo); } else { MEM_freeN(icu->driver); @@ -1351,7 +1365,7 @@ static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase } } else - icu_to_fcurves(animgroups, anim, icu, actname, constname, ipo->muteipo); + icu_to_fcurves(id, animgroups, anim, icu, actname, constname, ipo->muteipo); } /* if this IPO block doesn't have any users after this one, free... */ @@ -1382,7 +1396,7 @@ static void ipo_to_animato (Ipo *ipo, char actname[], char constname[], ListBase * to Objects, where ob->ipo and ob->action need to be combined). * NOTE: we need to be careful here, as same data-structs are used for new system too! */ -static void action_to_animato (bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers) +static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers) { bActionChannel *achan, *achann; bConstraintChannel *conchan, *conchann; @@ -1403,7 +1417,7 @@ static void action_to_animato (bAction *act, ListBase *groups, ListBase *curves, /* convert Action Channel's IPO data */ if (achan->ipo) { - ipo_to_animato(achan->ipo, achan->name, NULL, groups, curves, drivers); + ipo_to_animato(id, achan->ipo, achan->name, NULL, groups, curves, drivers); achan->ipo->id.us--; achan->ipo= NULL; } @@ -1415,7 +1429,7 @@ static void action_to_animato (bAction *act, ListBase *groups, ListBase *curves, /* convert Constraint Channel's IPO data */ if (conchan->ipo) { - ipo_to_animato(conchan->ipo, achan->name, conchan->name, groups, curves, drivers); + ipo_to_animato(id, conchan->ipo, achan->name, conchan->name, groups, curves, drivers); conchan->ipo->id.us--; conchan->ipo= NULL; } @@ -1460,7 +1474,7 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[]) * and the try to put these lists in the right places, but do not free the lists here */ // XXX there shouldn't be any need for the groups, so don't supply pointer for that now... - ipo_to_animato(ipo, actname, constname, NULL, &anim, &drivers); + ipo_to_animato(id, ipo, actname, constname, NULL, &anim, &drivers); /* deal with animation first */ if (anim.first) { @@ -1502,7 +1516,7 @@ static void action_to_animdata (ID *id, bAction *act) } /* convert Action data */ - action_to_animato(act, &adt->action->groups, &adt->action->curves, &adt->drivers); + action_to_animato(id, act, &adt->action->groups, &adt->action->curves, &adt->drivers); } /* ------------------------- */ @@ -1526,7 +1540,7 @@ static void nlastrips_to_animdata (ID *id, ListBase *strips) /* this old strip is only worth something if it had an action... */ if (as->act) { /* convert Action data (if not yet converted), storing the results in the same Action */ - action_to_animato(as->act, &as->act->groups, &as->act->curves, &adt->drivers); + action_to_animato(id, as->act, &as->act->groups, &as->act->curves, &adt->drivers); /* create a new-style NLA-strip which references this Action, then copy over relevant settings */ { @@ -1605,7 +1619,6 @@ void do_versions_ipos_to_animato(Main *main) ListBase drivers = {NULL, NULL}; ID *id; AnimData *adt; - Scene *scene; if (main == NULL) { printf("Argh! Main is NULL in do_versions_ipos_to_animato() \n"); @@ -1613,13 +1626,12 @@ void do_versions_ipos_to_animato(Main *main) } /* only convert if version is right */ - // XXX??? if (main->versionfile >= 250) { printf("WARNING: Animation data too new to convert (Version %d) \n", main->versionfile); return; } - else - printf("INFO: Converting to Animato... \n"); // xxx debug + else if (G.f & G_DEBUG) + printf("INFO: Converting to Animato... \n"); /* ----------- Animation Attached to Data -------------- */ @@ -1802,20 +1814,20 @@ void do_versions_ipos_to_animato(Main *main) } /* sequence strips */ - for(scene = main->scene.first; scene; scene = scene->id.next) { - if(scene->ed && scene->ed->seqbasep) { + for (id= main->scene.first; id; id= id->next) { + Scene *scene = (Scene *)id; + if (scene->ed && scene->ed->seqbasep) { Sequence * seq; - for(seq = scene->ed->seqbasep->first; - seq; seq = seq->next) { + for(seq = scene->ed->seqbasep->first; seq; seq = seq->next) { + IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL; short adrcode = SEQ_FAC1; if (G.f & G_DEBUG) printf("\tconverting sequence strip %s \n", seq->name+2); - if (!seq->ipo || !seq->ipo->curve.first) { - seq->flag |= - SEQ_USE_EFFECT_DEFAULT_FADE; + if (ELEM(NULL, seq->ipo, icu)) { + seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; continue; } @@ -1824,21 +1836,21 @@ void do_versions_ipos_to_animato(Main *main) (semi-hack (tm) ) */ switch(seq->type) { - case SEQ_IMAGE: - case SEQ_META: - case SEQ_SCENE: - case SEQ_MOVIE: - case SEQ_COLOR: - adrcode = SEQ_FAC_OPACITY; - break; - case SEQ_SPEED: - adrcode = SEQ_FAC_SPEED; - break; + case SEQ_IMAGE: + case SEQ_META: + case SEQ_SCENE: + case SEQ_MOVIE: + case SEQ_COLOR: + adrcode = SEQ_FAC_OPACITY; + break; + case SEQ_SPEED: + adrcode = SEQ_FAC_SPEED; + break; } - ((IpoCurve*) seq->ipo->curve.first) - ->adrcode = adrcode; - ipo_to_animdata((ID*) seq, seq->ipo, - NULL, NULL); + icu->adrcode = adrcode; + + /* convert IPO */ + ipo_to_animdata((ID *)seq, seq->ipo, NULL, NULL); seq->ipo->id.us--; seq->ipo = NULL; } @@ -1900,6 +1912,24 @@ void do_versions_ipos_to_animato(Main *main) } } + /* curves */ + for (id= main->curve.first; id; id= id->next) { + Curve *cu= (Curve *)id; + + if (G.f & G_DEBUG) printf("\tconverting curve %s \n", id->name+2); + + /* we're only interested in the IPO */ + if (cu->ipo) { + /* Add AnimData block */ + adt= BKE_id_add_animdata(id); + + /* Convert Curve data... */ + ipo_to_animdata(id, cu->ipo, NULL, NULL); + cu->ipo->id.us--; + cu->ipo= NULL; + } + } + /* --------- Unconverted Animation Data ------------------ */ /* For Animation data which may not be directly connected (i.e. not linked) to any other * data, we need to perform a separate pass to make sure that they are converted to standalone @@ -1918,7 +1948,7 @@ void do_versions_ipos_to_animato(Main *main) if (G.f & G_DEBUG) printf("\tconverting action %s \n", id->name+2); /* be careful! some of the actions we encounter will be converted ones... */ - action_to_animato(act, &act->groups, &act->curves, &drivers); + action_to_animato(NULL, act, &act->groups, &act->curves, &drivers); } /* ipo's */ @@ -1933,7 +1963,7 @@ void do_versions_ipos_to_animato(Main *main) /* add a new action for this, and convert all data into that action */ new_act= add_empty_action("ConvIPO_Action"); // XXX need a better name... - ipo_to_animato(ipo, NULL, NULL, NULL, &new_act->curves, &drivers); + ipo_to_animato(NULL, ipo, NULL, NULL, NULL, &new_act->curves, &drivers); } /* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */ @@ -1944,6 +1974,7 @@ void do_versions_ipos_to_animato(Main *main) /* free unused drivers from actions + ipos */ free_fcurves(&drivers); - printf("INFO: Animato convert done \n"); // xxx debug + if (G.f & G_DEBUG) + printf("INFO: Animato convert done \n"); } -- cgit v1.2.3 From 4980e43dd13677d21c870b6c5cce7f1e2af3d164 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 26 Apr 2010 06:35:25 +0000 Subject: Assorted code cleanups: * Removed some un-needed armature code stubs * Manually copying over the values of constraints in the constraint copy() callbacks should NOT be needed. Removed this from the Spline IK constraint. The manual process is only a hacky aspect of the modifier stack only! --- source/blender/blenkernel/intern/constraint.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 9dab2c1c07e..18504bab59b 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3751,10 +3751,6 @@ static void splineik_copy (bConstraint *con, bConstraint *srccon) /* copy the binding array */ dst->points= MEM_dupallocN(src->points); - dst->numpoints= src->numpoints; - dst->chainlen= src->chainlen; - dst->flag= src->flag; - dst->xzScaleMode= src->xzScaleMode; } static void splineik_new_data (void *cdata) -- cgit v1.2.3 From a547e91d41c566f15d0aeb15841414f56723f6e5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 26 Apr 2010 12:50:48 +0000 Subject: Two bugfixes from the render branch: * Fix for FSA update while rendering fix, should set float rect to NULL. * Fix for irradiance cache mutex unlock that got lost in code changes. --- source/blender/blenkernel/intern/image.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 7b727244dcb..2c71cc9310a 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1950,11 +1950,19 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ibuf->flags |= IB_rectfloat; ibuf->channels= channels; } + else { + ibuf->rect_float= NULL; + ibuf->flags &= ~IB_rectfloat; + } if(rectz) { ibuf->zbuf_float= rectz; ibuf->flags |= IB_zbuffloat; } + else { + ibuf->zbuf_float= NULL; + ibuf->flags &= ~IB_zbuffloat; + } ibuf->dither= dither; -- cgit v1.2.3 From 2d4d820b976b16c536af520378bdbd33d70b95b6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 28 Apr 2010 07:25:39 +0000 Subject: 3dview --> view3d, patch by Jonathan Smith with small corrections and changes. --- source/blender/blenkernel/intern/smoke.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index aa513ab0fb7..ccb83c760f0 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -717,7 +717,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd) smd->domain->strength = 2.0; smd->domain->noise = MOD_SMOKE_NOISEWAVE; smd->domain->diss_speed = 5; - // init 3dview buffer + // init view3d buffer smd->domain->viewsettings = 0; smd->domain->effector_weights = BKE_add_effector_weights(NULL); } -- cgit v1.2.3 From 5982662e231c17d9779b4fb67c48beb8aea2baab Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 28 Apr 2010 08:02:51 +0000 Subject: add option -Y to enable python script execution. --- source/blender/blenkernel/intern/blender.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index fd6db3710b9..3ccf068d6c8 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -276,6 +276,8 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) else bfd->globalf &= ~G_DEBUG; if (G.f & G_SWAP_EXCHANGE) bfd->globalf |= G_SWAP_EXCHANGE; else bfd->globalf &= ~G_SWAP_EXCHANGE; + if (G.f & G_SCRIPT_AUTOEXEC) bfd->globalf |= G_SCRIPT_AUTOEXEC; + else bfd->globalf &= ~G_SCRIPT_AUTOEXEC; G.f= bfd->globalf; -- cgit v1.2.3 From 9db7f4122d016943cfb7bb1aace2094663321cbb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 28 Apr 2010 18:13:03 +0000 Subject: fix for crash on loading some nodes. --- source/blender/blenkernel/intern/node.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 9ff7f1f2982..3d49548cba7 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -114,7 +114,8 @@ void ntreeInitTypes(bNodeTree *ntree) } } node->typeinfo= stype; - node->typeinfo->initfunc(node); + if(node->typeinfo) + node->typeinfo->initfunc(node); } else { node->typeinfo= node_get_type(ntree, node->type, (bNodeTree *)node->id, NULL); } -- cgit v1.2.3 From 58cb999253c1f78272fe677b6a99d46f3561e2f4 Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Thu, 29 Apr 2010 05:20:24 +0000 Subject: Newly created brushes will have a lower spacing. Still need to fix some of the default brushes --- source/blender/blenkernel/intern/brush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index dedf82b6dcc..538012ccc41 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -75,7 +75,7 @@ Brush *add_brush(const char *name) brush->rgb[2]= 1.0f; brush->alpha= 0.2f; brush->size= 25; - brush->spacing= 7.5f; + brush->spacing= 3.5f; brush->smooth_stroke_radius= 75; brush->smooth_stroke_factor= 0.9; brush->rate= 0.1f; -- cgit v1.2.3 From 610c4befd4ea1d2798c4196785570ddce76f324a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Apr 2010 15:31:53 +0000 Subject: option to copy constraints without making their ID references direct links. needed because proxies are causing libs to be linked directly when they should be kept indirect (likely slowing load times though I didnt time this) --- source/blender/blenkernel/BKE_constraint.h | 2 +- source/blender/blenkernel/intern/action.c | 4 ++-- source/blender/blenkernel/intern/armature.c | 4 +++- source/blender/blenkernel/intern/constraint.c | 13 ++++++++----- source/blender/blenkernel/intern/object.c | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index 94863e15e46..64e9636cae7 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -122,7 +122,7 @@ bConstraintTypeInfo *get_constraint_typeinfo(int type); void unique_constraint_name(struct bConstraint *con, struct ListBase *list); void free_constraints(struct ListBase *list); -void copy_constraints(struct ListBase *dst, const struct ListBase *src); +void copy_constraints(struct ListBase *dst, const struct ListBase *src, int do_extern); void relink_constraints(struct ListBase *list); void id_loop_constraints(struct ListBase *list, ConstraintIDFunc func, void *userdata); void free_constraint_data(struct bConstraint *con); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 253da25b871..c5705a0f619 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -493,7 +493,7 @@ void copy_pose (bPose **dst, bPose *src, int copycon) for (pchan=outPose->chanbase.first; pchan; pchan=pchan->next) { // TODO: rename this argument... if (copycon) { - copy_constraints(&listb, &pchan->constraints); // copy_constraints NULLs listb + copy_constraints(&listb, &pchan->constraints, TRUE); // copy_constraints NULLs listb pchan->constraints= listb; pchan->path= NULL; // XXX remove this line when the new motionpaths are ready... (depreceated code) pchan->mpath= NULL; /* motion paths should not get copied yet... */ @@ -667,7 +667,7 @@ void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_ pchan->iklinweight= pchan_from->iklinweight; /* constraints */ - copy_constraints(&pchan->constraints, &pchan_from->constraints); + copy_constraints(&pchan->constraints, &pchan_from->constraints, TRUE); /* id-properties */ if(pchan->prop) { diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index a2dbaa9d666..4f9b9435a80 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1568,9 +1568,11 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected * 1. extract constraints not from proxy (CONSTRAINT_PROXY_LOCAL) from pchan's constraints * 2. copy proxy-pchan's constraints on-to new * 3. add extracted local constraints back on top + * + * note for copy_constraints: when copying constraints, disable 'do_extern' otherwise we get the libs direct linked in this blend. */ extract_proxylocal_constraints(&proxylocal_constraints, &pchan->constraints); - copy_constraints(&pchanw.constraints, &pchanp->constraints); + copy_constraints(&pchanw.constraints, &pchanp->constraints, FALSE); addlisttolist(&pchanw.constraints, &proxylocal_constraints); /* constraints - set target ob pointer to own object */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 18504bab59b..a3f1cb0cb0c 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -4131,7 +4131,7 @@ static void con_extern_cb(bConstraint *con, ID **idpoin, void *userdata) } /* duplicate all of the constraints in a constraint stack */ -void copy_constraints (ListBase *dst, const ListBase *src) +void copy_constraints (ListBase *dst, const ListBase *src, int do_extern) { bConstraint *con, *srccon; @@ -4149,10 +4149,13 @@ void copy_constraints (ListBase *dst, const ListBase *src) /* perform custom copying operations if needed */ if (cti->copy_data) cti->copy_data(con, srccon); - - /* go over used ID-links for this constraint to ensure that they are valid for proxies */ - if (cti->id_looper) - cti->id_looper(con, con_extern_cb, NULL); + + /* for proxies we dont want to make extern */ + if(do_extern) { + /* go over used ID-links for this constraint to ensure that they are valid for proxies */ + if (cti->id_looper) + cti->id_looper(con, con_extern_cb, NULL); + } } } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ce064a78cff..baa1caee49b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1282,7 +1282,7 @@ Object *copy_object(Object *ob) armature_rebuild_pose(obn, obn->data); } defgroup_copy_list(&obn->defbase, &ob->defbase); - copy_constraints(&obn->constraints, &ob->constraints); + copy_constraints(&obn->constraints, &ob->constraints, TRUE); obn->mode = 0; obn->sculpt = NULL; -- cgit v1.2.3 From 08c3bfdfaf725e3ed59923d82042fc4c553d982e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Apr 2010 17:57:17 +0000 Subject: NULL check for pointcache. not sure this should be fixed elsewhere, commented this needs further checking. --- source/blender/blenkernel/intern/pointcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index e14c46fd82a..3d02f175174 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1379,7 +1379,9 @@ static void ptcache_copy_data(void *from[], void *to[]) { int i; for(i=0; i Date: Thu, 29 Apr 2010 21:46:25 +0000 Subject: use size_t for MEM_allocN_len as well as some of its callers --- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index cfee7dd9f61..1381a3b19dd 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -650,7 +650,7 @@ void *copy_libblock(void *rt) ID *idn, *id; ListBase *lb; char *cp, *cpn; - int idn_len; + size_t idn_len; id= rt; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9b3c613aef2..22cdf7d7f2b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -586,7 +586,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) if (seq->type == SEQ_IMAGE) { /* Hack? */ - int olen = MEM_allocN_len(seq->strip->stripdata)/sizeof(struct StripElem); + size_t olen = MEM_allocN_len(seq->strip->stripdata)/sizeof(struct StripElem); seq->len = olen; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; -- cgit v1.2.3 From 92dfb98ff62a817712c24ee5fad0527fd040c4ab Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Thu, 29 Apr 2010 23:15:03 +0000 Subject: Suggestion by Florian Meyer (testscreenings) to change default ramp to RGBA 0000 - RGBA 1111 (no more cyan) --- source/blender/blenkernel/intern/texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 99370610479..873a4103e3e 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -245,7 +245,7 @@ void init_colorband(ColorBand *coba, int rangetype) coba->data[0].b= 0.0; coba->data[0].a= 0.0; - coba->data[1].r= 0.0; + coba->data[1].r= 1.0; coba->data[1].g= 1.0; coba->data[1].b= 1.0; coba->data[1].a= 1.0; -- cgit v1.2.3 From bff3ec4ccce520a636b8cf02f9d6af6f45e66eac Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sat, 1 May 2010 11:51:56 +0000 Subject: == Sequencer == Since prefetch rendering in sequencer is currently disabled, seq_thread_shutdown should be always TRUE for now. --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 22cdf7d7f2b..307e8d77f26 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2832,7 +2832,7 @@ static pthread_cond_t wakeup_cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t frame_done_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t frame_done_cond = PTHREAD_COND_INITIALIZER; -static volatile int seq_thread_shutdown = FALSE; +static volatile int seq_thread_shutdown = TRUE; static volatile int seq_last_given_monoton_cfra = 0; static int monoton_cfra = 0; -- cgit v1.2.3 From d5939c03d1424bfb427a3143a1d3ea997af8d52b Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sat, 1 May 2010 14:09:45 +0000 Subject: First round of importing old sequencer IPOs to new animation system: * Frame locked IPOs work now TODO: non-frame-locked ones :) --- source/blender/blenkernel/intern/ipo.c | 72 +++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 31 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index f96100bad06..a9dd358d813 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -67,7 +67,7 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_nla.h" - +#include "BKE_sequencer.h" /* *************************************************** */ @@ -792,12 +792,12 @@ static char *particle_adrcodes_to_paths (int adrcode, int *array_index) /* Allocate memory for RNA-path for some property given a blocktype, adrcode, and 'root' parts of path * Input: * - blocktype, adrcode - determines setting to get - * - actname, constname - used to build path + * - actname, constname,seqname - used to build path * Output: * - array_index - index in property's array (if applicable) to use * - return - the allocated path... */ -static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], int *array_index) +static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], char seqname[], int *array_index) { DynStr *path= BLI_dynstr_new(); char *propname=NULL, *rpath=NULL; @@ -919,6 +919,10 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co /* Constraint in Object */ sprintf(buf, "constraints[\"%s\"]", constname); } + else if (seqname && seqname[0]) { + /* Sequence names in Scene */ + sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", seqname); + } else strcpy(buf, ""); /* empty string */ BLI_dynstr_append(path, buf); @@ -1111,8 +1115,9 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c * is not relevant, BUT do not free the IPO-Curve itself... * actname: name of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to * constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to + * seqname: name of sequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to */ -static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, int muteipo) +static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, char * seqname, int muteipo) { AdrBit2Path *abp; FCurve *fcu; @@ -1235,7 +1240,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* get rna-path * - we will need to set the 'disabled' flag if no path is able to be made (for now) */ - fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, &fcu->array_index); + fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, seqname, &fcu->array_index); if (fcu->rna_path == NULL) fcu->flag |= FCURVE_DISABLED; @@ -1326,7 +1331,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * This does not assume that any ID or AnimData uses it, but does assume that * it is given two lists, which it will perform driver/animation-data separation. */ -static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], ListBase *animgroups, ListBase *anim, ListBase *drivers) +static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], char seqname[], ListBase *animgroups, ListBase *anim, ListBase *drivers) { IpoCurve *icu; @@ -1357,7 +1362,7 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], if (icu->driver) { /* Blender 2.4x allowed empty drivers, but we don't now, since they cause more trouble than they're worth */ if ((icu->driver->ob) || (icu->driver->type == IPO_DRIVER_TYPE_PYTHON)) { - icu_to_fcurves(id, NULL, drivers, icu, actname, constname, ipo->muteipo); + icu_to_fcurves(id, NULL, drivers, icu, actname, constname, seqname, ipo->muteipo); } else { MEM_freeN(icu->driver); @@ -1365,7 +1370,7 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], } } else - icu_to_fcurves(id, animgroups, anim, icu, actname, constname, ipo->muteipo); + icu_to_fcurves(id, animgroups, anim, icu, actname, constname, seqname, ipo->muteipo); } /* if this IPO block doesn't have any users after this one, free... */ @@ -1417,7 +1422,7 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase /* convert Action Channel's IPO data */ if (achan->ipo) { - ipo_to_animato(id, achan->ipo, achan->name, NULL, groups, curves, drivers); + ipo_to_animato(id, achan->ipo, achan->name, NULL, NULL, groups, curves, drivers); achan->ipo->id.us--; achan->ipo= NULL; } @@ -1429,7 +1434,7 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase /* convert Constraint Channel's IPO data */ if (conchan->ipo) { - ipo_to_animato(id, conchan->ipo, achan->name, conchan->name, groups, curves, drivers); + ipo_to_animato(id, conchan->ipo, achan->name, conchan->name, NULL, groups, curves, drivers); conchan->ipo->id.us--; conchan->ipo= NULL; } @@ -1450,7 +1455,7 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase * This assumes that AnimData has been added already. Separation of drivers * from animation data is accomplished here too... */ -static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[]) +static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], char seqname[]) { AnimData *adt= BKE_animdata_from_id(id); ListBase anim = {NULL, NULL}; @@ -1465,8 +1470,8 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[]) } if (G.f & G_DEBUG) { - printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s curves:%d \n", - id->name+2, ipo->id.name+2, (actname)?actname:"", (constname)?constname:"", + printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s seqname:%s curves:%d \n", + id->name+2, ipo->id.name+2, (actname)?actname:"", (constname)?constname:"", (seqname)?seqname:"", BLI_countlist(&ipo->curve)); } @@ -1474,7 +1479,7 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[]) * and the try to put these lists in the right places, but do not free the lists here */ // XXX there shouldn't be any need for the groups, so don't supply pointer for that now... - ipo_to_animato(id, ipo, actname, constname, NULL, &anim, &drivers); + ipo_to_animato(id, ipo, actname, constname, seqname, NULL, &anim, &drivers); /* deal with animation first */ if (anim.first) { @@ -1651,7 +1656,7 @@ void do_versions_ipos_to_animato(Main *main) /* IPO first to take into any non-NLA'd Object Animation */ if (ob->ipo) { - ipo_to_animdata(id, ob->ipo, NULL, NULL); + ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); ob->ipo->id.us--; ob->ipo= NULL; @@ -1685,7 +1690,7 @@ void do_versions_ipos_to_animato(Main *main) /* IPO second... */ if (ob->ipo) { - ipo_to_animdata(id, ob->ipo, NULL, NULL); + ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); ob->ipo->id.us--; ob->ipo= NULL; } @@ -1705,7 +1710,7 @@ void do_versions_ipos_to_animato(Main *main) /* although this was the constraint's local IPO, we still need to provide pchan + con * so that drivers can be added properly... */ - ipo_to_animdata(id, con->ipo, pchan->name, con->name); + ipo_to_animdata(id, con->ipo, pchan->name, con->name, NULL); con->ipo->id.us--; con->ipo= NULL; } @@ -1725,7 +1730,7 @@ void do_versions_ipos_to_animato(Main *main) /* although this was the constraint's local IPO, we still need to provide con * so that drivers can be added properly... */ - ipo_to_animdata(id, con->ipo, NULL, con->name); + ipo_to_animdata(id, con->ipo, NULL, con->name, NULL); con->ipo->id.us--; con->ipo= NULL; } @@ -1745,7 +1750,7 @@ void do_versions_ipos_to_animato(Main *main) /* convert Constraint Channel's IPO data */ if (conchan->ipo) { - ipo_to_animdata(id, conchan->ipo, NULL, conchan->name); + ipo_to_animdata(id, conchan->ipo, NULL, conchan->name, NULL); conchan->ipo->id.us--; conchan->ipo= NULL; } @@ -1771,7 +1776,7 @@ void do_versions_ipos_to_animato(Main *main) adt= BKE_id_add_animdata(id); /* Convert Shapekey data... */ - ipo_to_animdata(id, key->ipo, NULL, NULL); + ipo_to_animdata(id, key->ipo, NULL, NULL, NULL); key->ipo->id.us--; key->ipo= NULL; } @@ -1789,7 +1794,7 @@ void do_versions_ipos_to_animato(Main *main) adt= BKE_id_add_animdata(id); /* Convert Material data... */ - ipo_to_animdata(id, ma->ipo, NULL, NULL); + ipo_to_animdata(id, ma->ipo, NULL, NULL, NULL); ma->ipo->id.us--; ma->ipo= NULL; } @@ -1807,7 +1812,7 @@ void do_versions_ipos_to_animato(Main *main) adt= BKE_id_add_animdata(id); /* Convert World data... */ - ipo_to_animdata(id, wo->ipo, NULL, NULL); + ipo_to_animdata(id, wo->ipo, NULL, NULL, NULL); wo->ipo->id.us--; wo->ipo= NULL; } @@ -1816,10 +1821,13 @@ void do_versions_ipos_to_animato(Main *main) /* sequence strips */ for (id= main->scene.first; id; id= id->next) { Scene *scene = (Scene *)id; - if (scene->ed && scene->ed->seqbasep) { + Editing * ed = scene->ed; + if (ed && ed->seqbasep) { Sequence * seq; - - for(seq = scene->ed->seqbasep->first; seq; seq = seq->next) { + + adt= BKE_id_add_animdata(id); + + SEQ_BEGIN(ed, seq) { IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL; short adrcode = SEQ_FAC1; @@ -1850,10 +1858,12 @@ void do_versions_ipos_to_animato(Main *main) icu->adrcode = adrcode; /* convert IPO */ - ipo_to_animdata((ID *)seq, seq->ipo, NULL, NULL); + ipo_to_animdata((ID *)scene, seq->ipo, + NULL, NULL, seq->name+2); seq->ipo->id.us--; seq->ipo = NULL; } + SEQ_END } } @@ -1870,7 +1880,7 @@ void do_versions_ipos_to_animato(Main *main) adt= BKE_id_add_animdata(id); /* Convert Texture data... */ - ipo_to_animdata(id, te->ipo, NULL, NULL); + ipo_to_animdata(id, te->ipo, NULL, NULL, NULL); te->ipo->id.us--; te->ipo= NULL; } @@ -1888,7 +1898,7 @@ void do_versions_ipos_to_animato(Main *main) adt= BKE_id_add_animdata(id); /* Convert Camera data... */ - ipo_to_animdata(id, ca->ipo, NULL, NULL); + ipo_to_animdata(id, ca->ipo, NULL, NULL, NULL); ca->ipo->id.us--; ca->ipo= NULL; } @@ -1906,7 +1916,7 @@ void do_versions_ipos_to_animato(Main *main) adt= BKE_id_add_animdata(id); /* Convert Lamp data... */ - ipo_to_animdata(id, la->ipo, NULL, NULL); + ipo_to_animdata(id, la->ipo, NULL, NULL, NULL); la->ipo->id.us--; la->ipo= NULL; } @@ -1924,7 +1934,7 @@ void do_versions_ipos_to_animato(Main *main) adt= BKE_id_add_animdata(id); /* Convert Curve data... */ - ipo_to_animdata(id, cu->ipo, NULL, NULL); + ipo_to_animdata(id, cu->ipo, NULL, NULL, NULL); cu->ipo->id.us--; cu->ipo= NULL; } @@ -1963,7 +1973,7 @@ void do_versions_ipos_to_animato(Main *main) /* add a new action for this, and convert all data into that action */ new_act= add_empty_action("ConvIPO_Action"); // XXX need a better name... - ipo_to_animato(NULL, ipo, NULL, NULL, NULL, &new_act->curves, &drivers); + ipo_to_animato(NULL, ipo, NULL, NULL, NULL, NULL, &new_act->curves, &drivers); } /* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */ -- cgit v1.2.3 From 93a7f0ef65df2def26188f08a6a2cae35a330d75 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sat, 1 May 2010 15:17:30 +0000 Subject: Second round of sequencer IPO-conversion to new animation system: * now non-frame-locked IPOs work, too. --- source/blender/blenkernel/intern/ipo.c | 47 ++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index a9dd358d813..7f2ac50acd5 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -792,12 +792,12 @@ static char *particle_adrcodes_to_paths (int adrcode, int *array_index) /* Allocate memory for RNA-path for some property given a blocktype, adrcode, and 'root' parts of path * Input: * - blocktype, adrcode - determines setting to get - * - actname, constname,seqname - used to build path + * - actname, constname,seq - used to build path * Output: * - array_index - index in property's array (if applicable) to use * - return - the allocated path... */ -static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], char seqname[], int *array_index) +static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence * seq, int *array_index) { DynStr *path= BLI_dynstr_new(); char *propname=NULL, *rpath=NULL; @@ -919,9 +919,10 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co /* Constraint in Object */ sprintf(buf, "constraints[\"%s\"]", constname); } - else if (seqname && seqname[0]) { + else if (seq) { /* Sequence names in Scene */ - sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", seqname); + sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", + seq->name+2); } else strcpy(buf, ""); /* empty string */ @@ -1115,9 +1116,9 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c * is not relevant, BUT do not free the IPO-Curve itself... * actname: name of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to * constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to - * seqname: name of sequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to + * seq: sequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to */ -static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, char * seqname, int muteipo) +static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, Sequence * seq, int muteipo) { AdrBit2Path *abp; FCurve *fcu; @@ -1240,7 +1241,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* get rna-path * - we will need to set the 'disabled' flag if no path is able to be made (for now) */ - fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, seqname, &fcu->array_index); + fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, seq, &fcu->array_index); if (fcu->rna_path == NULL) fcu->flag |= FCURVE_DISABLED; @@ -1312,6 +1313,24 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * dst->vec[2][0] *= fac; } } + + /* correct values for sequencer curves, + that were not locked to frame */ + + if (seq && + (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { + double mul= (seq->enddisp-seq->startdisp)/100.0f; + double offset= seq->startdisp; + + dst->vec[0][0] *= mul; + dst->vec[0][0] += offset; + + dst->vec[1][0] *= mul; + dst->vec[1][0] += offset; + + dst->vec[2][0] *= mul; + dst->vec[2][0] += offset; + } } } else if (icu->bp) { @@ -1331,7 +1350,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * This does not assume that any ID or AnimData uses it, but does assume that * it is given two lists, which it will perform driver/animation-data separation. */ -static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], char seqname[], ListBase *animgroups, ListBase *anim, ListBase *drivers) +static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], Sequence * seq, ListBase *animgroups, ListBase *anim, ListBase *drivers) { IpoCurve *icu; @@ -1362,7 +1381,7 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], if (icu->driver) { /* Blender 2.4x allowed empty drivers, but we don't now, since they cause more trouble than they're worth */ if ((icu->driver->ob) || (icu->driver->type == IPO_DRIVER_TYPE_PYTHON)) { - icu_to_fcurves(id, NULL, drivers, icu, actname, constname, seqname, ipo->muteipo); + icu_to_fcurves(id, NULL, drivers, icu, actname, constname, seq, ipo->muteipo); } else { MEM_freeN(icu->driver); @@ -1370,7 +1389,7 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], } } else - icu_to_fcurves(id, animgroups, anim, icu, actname, constname, seqname, ipo->muteipo); + icu_to_fcurves(id, animgroups, anim, icu, actname, constname, seq, ipo->muteipo); } /* if this IPO block doesn't have any users after this one, free... */ @@ -1455,7 +1474,7 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase * This assumes that AnimData has been added already. Separation of drivers * from animation data is accomplished here too... */ -static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], char seqname[]) +static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence * seq) { AnimData *adt= BKE_animdata_from_id(id); ListBase anim = {NULL, NULL}; @@ -1471,7 +1490,7 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], if (G.f & G_DEBUG) { printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s seqname:%s curves:%d \n", - id->name+2, ipo->id.name+2, (actname)?actname:"", (constname)?constname:"", (seqname)?seqname:"", + id->name+2, ipo->id.name+2, (actname)?actname:"", (constname)?constname:"", (seq)?(seq->name+2):"", BLI_countlist(&ipo->curve)); } @@ -1479,7 +1498,7 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], * and the try to put these lists in the right places, but do not free the lists here */ // XXX there shouldn't be any need for the groups, so don't supply pointer for that now... - ipo_to_animato(id, ipo, actname, constname, seqname, NULL, &anim, &drivers); + ipo_to_animato(id, ipo, actname, constname, seq, NULL, &anim, &drivers); /* deal with animation first */ if (anim.first) { @@ -1859,7 +1878,7 @@ void do_versions_ipos_to_animato(Main *main) /* convert IPO */ ipo_to_animdata((ID *)scene, seq->ipo, - NULL, NULL, seq->name+2); + NULL, NULL, seq); seq->ipo->id.us--; seq->ipo = NULL; } -- cgit v1.2.3 From 540bf6d7c88e60c467c179c45d5c0db8144e92f7 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sat, 1 May 2010 16:02:59 +0000 Subject: should make problems mentioned in [#19221] Sequencer animation curves not converted correctly from 2.4 go away. --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 307e8d77f26..e48c4ea718c 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2160,7 +2160,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int and since G.rendering is uhm, gone... (Peter) */ - int rendering = 1; + int rendering = G.rendering; int doseq; int doseq_gl= G.rendering ? (scene->r.seq_flag & R_SEQ_GL_REND) : (scene->r.seq_flag & R_SEQ_GL_PREV); -- cgit v1.2.3 From 23ccac18cdf285bce72c60bd15cd6b0249954379 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 3 May 2010 03:02:27 +0000 Subject: Fix [#22199] Cloth Cache Panel > Disk Cache doesn't work Condition for this to work (.blend file must be saved) was poorly communicated in the UI (printfs are no good for this - ideally should use reports). Tweaked this a bit. --- source/blender/blenkernel/intern/pointcache.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 3d02f175174..25f8dc9bd56 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2652,7 +2652,8 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid) ptcache_file_init_pointers(pf); if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) { - printf("Error writing to disk cache\n"); + if (G.f & G_DEBUG) + printf("Error writing to disk cache\n"); cache->flag &= ~PTCACHE_DISK_CACHE; ptcache_file_close(pf); @@ -2662,7 +2663,8 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid) for(i=0; itotpoint; i++) { ptcache_copy_data(pm->cur, pf->cur); if(!ptcache_file_write_data(pf)) { - printf("Error writing to disk cache\n"); + if (G.f & G_DEBUG) + printf("Error writing to disk cache\n"); cache->flag &= ~PTCACHE_DISK_CACHE; ptcache_file_close(pf); @@ -2678,7 +2680,8 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid) BKE_ptcache_write_cache(pid, 0); } else - printf("Error creating disk cache file\n"); + if (G.f & G_DEBUG) + printf("Error creating disk cache file\n"); } } void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) @@ -2688,7 +2691,8 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) if (!G.relbase_valid){ cache->flag &= ~PTCACHE_DISK_CACHE; - printf("File must be saved before using disk cache!\n"); + if (G.f & G_DEBUG) + printf("File must be saved before using disk cache!\n"); return; } -- cgit v1.2.3 From 88c3b68207c0d3961a36b0a78563221a9f351c70 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Mon, 3 May 2010 10:09:26 +0000 Subject: mask modifier properly works in weightpaint and edit modes now. note that modifiers should not have to provide a applyModifierEM function, there's really no reason to not pull the result from applyModifier if applyModifierEM doesn't exist, it's not like we don't have a dozen *EM functions that do just that, anyway. fixes 22192. {merged 28543 into trunk} --- source/blender/blenkernel/intern/DerivedMesh.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 8a74ba1be53..9d6086edb8c 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2017,7 +2017,9 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri } } - mti->deformVertsEM(md, ob, em, dm, deformedVerts, numVerts); + if (mti->deformVertsEM) + mti->deformVertsEM(md, ob, em, dm, deformedVerts, numVerts); + else mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0); } else { DerivedMesh *ndm; @@ -2053,7 +2055,11 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri mask &= ~CD_MASK_ORCO; DM_set_only_copy(orcodm, mask); - ndm = mti->applyModifierEM(md, ob, em, orcodm); + + if (mti->applyModifierEM) + ndm = mti->applyModifierEM(md, ob, em, orcodm); + else + ndm = mti->applyModifier(md, ob, orcodm, 0, 0); if(ndm) { /* if the modifier returned a new dm, release the old one */ @@ -2069,7 +2075,10 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri if(!CustomData_has_layer(&dm->faceData, CD_ORIGSPACE)) DM_add_face_layer(dm, CD_ORIGSPACE, CD_DEFAULT, NULL); - ndm = mti->applyModifierEM(md, ob, em, dm); + if (mti->applyModifierEM) + ndm = mti->applyModifierEM(md, ob, em, dm); + else + ndm = mti->applyModifier(md, ob, dm, 0, 0); if (ndm) { if(dm && dm != ndm) -- cgit v1.2.3 From 0fdd003d9aa9c61bfd34feaaf86598632cfc3390 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 3 May 2010 15:56:44 +0000 Subject: have timeoffset use (int)floor(timeoffset+0.5f) when converting to an int to avoid problems with nagative values. --- source/blender/blenkernel/intern/group.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 6a807abc396..2a4d3f6d301 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -333,7 +333,7 @@ void group_handle_recalc_and_update(Scene *scene, Object *parent, Group *group) /* switch to local time */ cfrao= scene->r.cfra; - scene->r.cfra -= (int)give_timeoffset(parent); + scene->r.cfra -= (int)floor(give_timeoffset(parent) + 0.5f); /* we need a DAG per group... */ for(go= group->gobject.first; go; go= go->next) { -- cgit v1.2.3 From afa872200c452adaed6d57d6b3c1f79fa86185c0 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Mon, 3 May 2010 16:06:36 +0000 Subject: merge multires changes into trunk --- source/blender/blenkernel/intern/DerivedMesh.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 9d6086edb8c..85791d5024d 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1741,7 +1741,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos */ if(mti->type == eModifierTypeType_OnlyDeform) { - /* No existing verts to deform, need to build them. */ if(!deformedVerts) { if(dm) { @@ -1867,10 +1866,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } } } - + /* grab modifiers until index i */ if((index >= 0) && (modifiers_indexInObject(ob, md) >= index)) break; + + /*don't allow other modifiers past multires if in sculpt mode*/ + if (!useRenderParams && ((ob->mode & OB_MODE_SCULPT) && ob->sculpt)) + break; } for(md=firstmd; md; md=md->next) -- cgit v1.2.3 From a253d2d0f3bda2a0db2f7ca8c06c166566435c94 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 3 May 2010 21:07:57 +0000 Subject: add missing include from recent commit --- source/blender/blenkernel/intern/group.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 2a4d3f6d301..c8848572643 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -29,6 +29,7 @@ #include #include +#include #include "MEM_guardedalloc.h" -- cgit v1.2.3 From 850a4b508bcf3db4c010bd1395671b26a8a51d29 Mon Sep 17 00:00:00 2001 From: Xavier Thomas Date: Tue, 4 May 2010 00:28:41 +0000 Subject: Fix [#21353] Rendering h264 reports broken settings and fail. Also silenced a warning. --- source/blender/blenkernel/intern/writeffmpeg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 57d6c91c3dd..8ebf98ef930 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -362,7 +362,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports) } if (c->pix_fmt != PIX_FMT_BGR32) { - sws_scale(img_convert_ctx, rgb_frame->data, + sws_scale(img_convert_ctx, (const uint8_t * const*) rgb_frame->data, rgb_frame->linesize, 0, c->height, current_frame->data, current_frame->linesize); delete_picture(rgb_frame); @@ -516,6 +516,12 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex /* arghhhh ... */ c->pix_fmt = PIX_FMT_YUV420P; } + + if (codec_id == CODEC_ID_H264) { + /* correct wrong default ffmpeg param which crash x264 */ + c->qmin=10; + c->qmax=51; + } if ((of->oformat->flags & AVFMT_GLOBALHEADER) // || !strcmp(of->oformat->name, "mp4") -- cgit v1.2.3 From a7cbd5008e830224e73e2e55f89d0783ded422e5 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Tue, 4 May 2010 12:31:24 +0000 Subject: merging revisions 28564-28569 from render branch into trunk --- source/blender/blenkernel/intern/particle.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 31378e3a80a..3ac1ada58cb 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2950,7 +2950,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf float birthtime = 0.0, dietime = 0.0; float t, time = 0.0, keytime = 0.0, frs_sec; float hairmat[4][4], rotmat[3][3], prev_tangent[3]; - int k,i; + int k, i; int steps = (int)pow(2.0, (double)pset->draw_step); int totpart = edit->totpoint, recalc_set=0; float sel_col[3]; @@ -3097,17 +3097,26 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* selection coloring in edit mode */ if(pset->brushtype==PE_BRUSH_WEIGHT){ - if(k==0) + float t2; + + if(k==0) { weight_to_rgb(pind.hkey[1]->weight, ca->col, ca->col+1, ca->col+2); - else if(k >= steps - 1) - weight_to_rgb(pind.hkey[0]->weight, ca->col, ca->col+1, ca->col+2); - else - weight_to_rgb((1.0f - keytime) * pind.hkey[0]->weight + keytime * pind.hkey[1]->weight, ca->col, ca->col+1, ca->col+2); + } else { + float w1[3], w2[3]; + keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + + weight_to_rgb(pind.hkey[0]->weight, w1, w1+1, w1+2); + weight_to_rgb(pind.hkey[1]->weight, w2, w2+1, w2+2); + + interp_v3_v3v3(ca->col, w1, w2, keytime); + } /* at the moment this is only used for weight painting. * will need to move out of this check if its used elsewhere. */ - pind.hkey[0] = pind.hkey[1]; - pind.hkey[1]++; + t2 = birthtime + ((float)(k+1)/(float)steps) * (dietime - birthtime); + + while (pind.hkey[1]->time < t2) pind.hkey[1]++; + pind.hkey[0] = pind.hkey[1] - 1; } else { if((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT){ -- cgit v1.2.3 From f721447f229c31a6103a30e7340810fc0809e0c6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 4 May 2010 21:10:26 +0000 Subject: billboards were using un-initialized memory and avoid divide by zero in some cases. --- source/blender/blenkernel/intern/particle.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 3ac1ada58cb..85898d5a2e8 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1137,6 +1137,9 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData int point_vel = (point && point->keys->vel); float real_t, dfra, keytime; + /* billboards wont fill in all of these, so start cleared */ + memset(keys, 0, sizeof(keys)); + /* interpret timing and find keys */ if(point) { if(result->time < 0.0f) -- cgit v1.2.3 From 41ed305cb2117860e5a68ecab706d5868ec7c836 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 4 May 2010 21:43:43 +0000 Subject: make a dummy billboard if its velocity or vector are nan/inf was causing crashes in the raytracer. --- source/blender/blenkernel/intern/particle.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 85898d5a2e8..fffbd31aa02 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4292,6 +4292,23 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] xvec[0] = 1.0f; xvec[1] = 0.0f; xvec[2] = 0.0f; yvec[0] = 0.0f; yvec[1] = 1.0f; yvec[2] = 0.0f; + /* can happen with bad pointcache or physics calculation + * since this becomes geometry, nan's and inf's crash raytrace code. + * better not allow this. */ + if( !finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) || + !finite(bb->vel[0]) || !finite(bb->vel[1]) || !finite(bb->vel[2]) ) + { + zero_v3(bb->vec); + zero_v3(bb->vel); + + zero_v3(xvec); + zero_v3(yvec); + zero_v3(zvec); + zero_v3(center); + + return; + } + if(bb->align < PART_BB_VIEW) onevec[bb->align]=1.0f; -- cgit v1.2.3 From 12cf8ac1d6cfc640a4dae4377aa97609ee568f04 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 5 May 2010 15:41:38 +0000 Subject: - split objet group add/link into 2 operators - link now brings up a search box so when there are 100's of groups its less annoying. - utility functions for id-enums so only local objects can be displayed in a search list (used for group_link) - renamed operator properties from typle to scene, group, action etc. --- source/blender/blenkernel/intern/subsurf_ccg.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index db63f094160..72236a76032 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -844,6 +844,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) for(x = 1; x < edgeSize - 1; x++, i++) { vd= ccgSubSurf_getEdgeData(ss, e, x); copy_v3_v3(mvert[i].co, vd->co); + /* XXX, This gives errors with -fpe, the normals dont seem to be unit length - campbell */ normal_float_to_short_v3(mvert[i].no, vd->no); } } -- cgit v1.2.3 From c8a05922882f7638b91ebcb1cd7a4e89cdf16222 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 17:12:44 +0000 Subject: option to use the linked path or the local path for pointcache. needed for sintels hair to be baked locally. --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 25f8dc9bd56..b42ac6fdf49 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1076,7 +1076,7 @@ static int ptcache_path(PTCacheID *pid, char *filename) char file[MAX_PTCACHE_PATH]; /* we dont want the dir, only the file */ char *blendfilename; - blendfilename= (lib)? lib->filename: G.sce; + blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filename: G.sce; BLI_split_dirfile(blendfilename, NULL, file); i = strlen(file); -- cgit v1.2.3 From 730ca20c6324b0761846fbd623ecd39bc5573412 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 May 2010 21:31:16 +0000 Subject: fix for duplicating cloth which could crash on freeing - effector list wasnt NULL'd on copying a particle system - copying an object would initialize the cloth modifier, then copy it, witout freeing its effector weights created in cloth_init(). --- source/blender/blenkernel/intern/object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index baa1caee49b..24c23e5ea41 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1140,12 +1140,13 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys) } BLI_duplicatelist(&psysn->targets, &psys->targets); - + psysn->pathcache= NULL; psysn->childcache= NULL; psysn->edit= NULL; psysn->frand= NULL; psysn->pdd= NULL; + psysn->effectors= NULL; psysn->pathcachebufs.first = psysn->pathcachebufs.last = NULL; psysn->childcachebufs.first = psysn->childcachebufs.last = NULL; -- cgit v1.2.3 From 9084df418d1bbd1fd3cf8f1bf118cbef4d50a4c7 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 7 May 2010 03:44:34 +0000 Subject: Warning cleanup While I was looking in outliner.c, made some changes to let extra passes display there such as environment (commented out before due to a previous limitation). Also changed outliner object visbility/selectability/renderability toggles to use RNA buttons so you can insert keyframes with RMB menu etc. --- source/blender/blenkernel/intern/colortools.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 44a52964f2a..66ebac2e25e 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -939,12 +939,12 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) { int x, y, c, n, nl; double div, divl; - float *rf; - unsigned char *rc; + float *rf=NULL; + unsigned char *rc=NULL; unsigned int *bin_r, *bin_g, *bin_b, *bin_lum; int savedlines, saveline; float rgb[3], ycc[3]; - int ycc_mode; + int ycc_mode=-1; if (scopes->ok == 1 ) return; -- cgit v1.2.3 From 389e590460527ee497fe6426c48fba234490ff74 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 May 2010 07:54:25 +0000 Subject: ghash alloc string from render branch svn merge https://svn.blender.org/svnroot/bf-blender/branches/render25 -r28571:28573 svn merge https://svn.blender.org/svnroot/bf-blender/branches/render25 -r28575:28576 --- source/blender/blenkernel/intern/BME_tools.c | 2 +- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/icons.c | 2 +- source/blender/blenkernel/intern/nla.c | 2 +- source/blender/blenkernel/intern/softbody.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index b4919dd8cf3..7d9c9a431f8 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -49,7 +49,7 @@ BME_TransData_Head *BME_init_transdata(int bufsize) { BME_TransData_Head *td; td = MEM_callocN(sizeof(BME_TransData_Head), "BMesh transdata header"); - td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp); + td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp, "BME_init_transdata gh"); td->ma = BLI_memarena_new(bufsize, "BME_TransData arena"); BLI_memarena_use_calloc(td->ma); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index c5705a0f619..50552d33c41 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -549,7 +549,7 @@ void make_pose_channels_hash(bPose *pose) if(!pose->chanhash) { bPoseChannel *pchan; - pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); + pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh"); for(pchan=pose->chanbase.first; pchan; pchan=pchan->next) BLI_ghash_insert(pose->chanhash, pchan->name, pchan); } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index f63e28fb464..1e5f276ba95 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -803,7 +803,7 @@ DagNode * dag_add_node (DagForest *forest, void * fob) } if(!forest->nodeHash) - forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh"); BLI_ghash_insert(forest->nodeHash, fob, node); } diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index a9582506cee..29314fb4865 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -101,7 +101,7 @@ void BKE_icons_init(int first_dyn_id) gFirstIconId = first_dyn_id; if (!gIcons) - gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); + gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "icons_init gh"); } void BKE_icons_free() diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 902d6b8e9bf..8d2ad49e7bf 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1243,7 +1243,7 @@ void BKE_nlastrip_validate_name (AnimData *adt, NlaStrip *strip) * - this is easier than iterating over all the tracks+strips hierarchy everytime * (and probably faster) */ - gh= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); + gh= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nlastrip_validate_name gh"); for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { for (tstrip= nlt->strips.first; tstrip; tstrip= tstrip->next) { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index b8274940318..c06e0679a7d 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3663,7 +3663,7 @@ static void sb_new_scratch(SoftBody *sb) { if (!sb) return; sb->scratch = MEM_callocN(sizeof(SBScratch), "SBScratch"); - sb->scratch->colliderhash = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp); + sb->scratch->colliderhash = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp, "sb_new_scratch gh"); sb->scratch->bodyface = NULL; sb->scratch->totface = 0; sb->scratch->aabbmax[0]=sb->scratch->aabbmax[1]=sb->scratch->aabbmax[2] = 1.0e30f; -- cgit v1.2.3 From 70a96a1089899f4f1e8541a56303742e1c192845 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 May 2010 09:41:26 +0000 Subject: saving multires data didnt get the new filename when the external struct was alredy allocated (making save external fail) --- source/blender/blenkernel/intern/customdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index a973c33ca54..9ae1c7f05ab 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2487,9 +2487,9 @@ void CustomData_external_add(CustomData *data, ID *id, int type, int totelem, co if(!external) { external= MEM_callocN(sizeof(CustomDataExternal), "CustomDataExternal"); - BLI_strncpy(external->filename, filename, sizeof(external->filename)); data->external= external; } + BLI_strncpy(external->filename, filename, sizeof(external->filename)); layer->flag |= CD_FLAG_EXTERNAL|CD_FLAG_IN_MEMORY; } -- cgit v1.2.3 From 9bd3f08b65fe19757029e594dea52f1132dbb48c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 7 May 2010 09:48:40 +0000 Subject: Multires: fix for "failed to read" error message with external displacements. --- source/blender/blenkernel/intern/customdata.c | 4 +- source/blender/blenkernel/intern/multires.c | 53 ++++++++++++++++++--------- 2 files changed, 37 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 9ae1c7f05ab..69327eccfaf 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -559,7 +559,7 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count) d[i].disps = MEM_callocN(sizeof(float)*3*d[i].totdisp, "mdisps read"); if(!cdf_read_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) { - printf("failed to read %d/%d %d\n", i, count, d[i].totdisp); + printf("failed to read multires displacement %d/%d %d\n", i, count, d[i].totdisp); return 0; } } @@ -574,7 +574,7 @@ static int layerWrite_mdisps(CDataFile *cdf, void *data, int count) for(i = 0; i < count; ++i) { if(!cdf_write_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) { - printf("failed to write %d/%d %d\n", i, count, d[i].totdisp); + printf("failed to write multires displacement %d/%d %d\n", i, count, d[i].totdisp); return 0; } } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 9e95581b211..52c6f9355a3 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -264,6 +264,38 @@ int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob, return result; } +static void multires_set_tot_mdisps(Mesh *me, int lvl) +{ + MDisps *mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); + int i; + + if(mdisps) { + for(i = 0; i < me->totface; i++) { + if(mdisps[i].totdisp == 0) { + int nvert = (me->mface[i].v4)? 4: 3; + mdisps[i].totdisp = multires_grid_tot[lvl]*nvert; + } + } + } +} + +static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) +{ + int i; + + /* reallocate displacements to be filled in */ + for(i = 0; i < me->totface; ++i) { + int nvert = (me->mface[i].v4)? 4: 3; + int totdisp = multires_grid_tot[lvl]*nvert; + float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); + + if(mdisps[i].disps) + MEM_freeN(mdisps[i].disps); + + mdisps[i].disps = disps; + mdisps[i].totdisp = totdisp; + } +} static void column_vectors_to_mat3(float mat[][3], float v1[3], float v2[3], float v3[3]) { @@ -320,6 +352,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire int levels = mmd->totlvl - lvl; MDisps *mdisps; + multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -393,24 +426,6 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0); } -static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) -{ - int i; - - /* reallocate displacements to be filled in */ - for(i = 0; i < me->totface; ++i) { - int nvert = (me->mface[i].v4)? 4: 3; - int totdisp = multires_grid_tot[lvl]*nvert; - float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); - - if(mdisps[i].disps) - MEM_freeN(mdisps[i].disps); - - mdisps[i].disps = disps; - mdisps[i].totdisp = totdisp; - } -} - void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) { Mesh *me = ob->data; @@ -615,6 +630,7 @@ static void multiresModifier_update(DerivedMesh *dm) ob = ccgdm->multires.ob; me = ccgdm->multires.ob->data; mmd = ccgdm->multires.mmd; + multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -750,6 +766,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize); } + multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); multiresModifier_disp_run(result, ob->data, 0, 0, subGridData, mmd->totlvl); -- cgit v1.2.3 From 008863daec1249d1f17bc69e1105e336db690d63 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 7 May 2010 15:18:04 +0000 Subject: Merge image related changes from the render branch. This includes the image tile cache code in imbuf, but it is not hooked up to the render engine. Imbuf module: some small refactoring and removing a lot of unused or old code (about 6.5k lines). * Added a ImFileType struct with callbacks to make adding an file format type, or making changes to the API easier. * Move imbuf init/exit code into IMB_init()/IMB_exit() functions. * Increased mipmap levels from 10 to 20, you run into this limit already with a 2k image. * Removed hamx, amiga, anim5 format support. * Removed colormap saving, only simple colormap code now for reading tga. * Removed gen_dynlibtiff.py, editing this is almost as much work as just editing the code directly. * Functions removed that were only used for sequencer plugin API: IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp, IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace, IMB_dit0, IMB_dit2, IMB_cspace * Write metadata info into OpenEXR images. Can be viewed with the command line utility 'exrheader' For the image tile cache code, see this page: http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache --- source/blender/blenkernel/BKE_image.h | 1 - source/blender/blenkernel/intern/blender.c | 2 +- source/blender/blenkernel/intern/bmfont.c | 2 +- source/blender/blenkernel/intern/image.c | 110 +++++++-------------------- source/blender/blenkernel/intern/multires.c | 53 +++++-------- source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/writeavi.c | 5 -- 7 files changed, 47 insertions(+), 128 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 915f59be01a..7bdb9aaf709 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -55,7 +55,6 @@ int BKE_imtype_is_movie(int imtype); struct anim *openanim(char * name, int flags); -void converttopremul(struct ImBuf *ibuf); void image_de_interlace(struct Image *ima, int odd); void tag_image_time(struct Image *ima); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 3ccf068d6c8..42c492d3237 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -100,7 +100,7 @@ void free_blender(void) BKE_spacetypes_free(); /* after free main, it uses space callbacks */ - IMB_freeImBufdata(); /* imbuf lib */ + IMB_exit(); free_nodesystem(); } diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index 1b053b45859..e2a6c04450b 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -174,7 +174,7 @@ void detectBitmapFont(ImBuf *ibuf) unsigned short version; int i; - if (ibuf != NULL) { + if (ibuf != NULL && ibuf->rect != NULL) { // bitmap must have an x size that is a power of two if (is_power_of_two(ibuf->x)) { rect = (unsigned char *) (ibuf->rect + (ibuf->x * (ibuf->y - 1))); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 2c71cc9310a..a377bbed24c 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -92,58 +92,6 @@ /* ******** IMAGE PROCESSING ************* */ -/* used by sequencer and image premul option - IMA_DO_PREMUL */ -void converttopremul(struct ImBuf *ibuf) -{ - int x, y; - - if(ibuf==0) return; - if (ibuf->rect) { - int val; - char *cp; - if(ibuf->depth==24) { /* put alpha at 255 */ - cp= (char *)(ibuf->rect); - for(y=0; yy; y++) { - for(x=0; xx; x++, cp+=4) { - cp[3]= 255; - } - } - } else { - cp= (char *)(ibuf->rect); - for(y=0; yy; y++) { - for(x=0; xx; x++, cp+=4) { - val= cp[3]; - cp[0]= (cp[0]*val)>>8; - cp[1]= (cp[1]*val)>>8; - cp[2]= (cp[2]*val)>>8; - } - } - } - } - if (ibuf->rect_float) { - float val; - float *cp; - if(ibuf->depth==24) { /* put alpha at 1.0 */ - cp= ibuf->rect_float;; - for(y=0; yy; y++) { - for(x=0; xx; x++, cp+=4) { - cp[3]= 1.0; - } - } - } else { - cp= ibuf->rect_float; - for(y=0; yy; y++) { - for(x=0; xx; x++, cp+=4) { - val= cp[3]; - cp[0]= cp[0]*val; - cp[1]= cp[1]*val; - cp[2]= cp[2]*val; - } - } - } - } -} - static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ { struct ImBuf * tbuf1, * tbuf2; @@ -735,8 +683,6 @@ int BKE_imtype_to_ftype(int imtype) return TGA; else if(imtype==R_RAWTGA) return RAWTGA; - else if(imtype==R_HAMX) - return AN_hamx; #ifdef WITH_OPENJPEG else if(imtype==R_JP2) return JP2; @@ -773,8 +719,6 @@ int BKE_ftype_to_imtype(int ftype) return R_TARGA; else if(ftype & RAWTGA) return R_RAWTGA; - else if(ftype == AN_hamx) - return R_HAMX; #ifdef WITH_OPENJPEG else if(ftype & JP2) return R_JP2; @@ -787,7 +731,6 @@ int BKE_ftype_to_imtype(int ftype) int BKE_imtype_is_movie(int imtype) { switch(imtype) { - case R_MOVIE: case R_AVIRAW: case R_AVIJPEG: case R_AVICODEC: @@ -864,7 +807,7 @@ void BKE_add_image_extension(char *string, int imtype) extension= ".jp2"; } #endif - else { // R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc + else { // R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc if(!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg"))) extension= ".jpg"; } @@ -1211,15 +1154,15 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) /* fill all the data values, no prefix */ stampdata(scene, &stamp_data, 0); - if (stamp_data.file[0]) IMB_imginfo_change_field (ibuf, "File", stamp_data.file); - if (stamp_data.note[0]) IMB_imginfo_change_field (ibuf, "Note", stamp_data.note); - if (stamp_data.date[0]) IMB_imginfo_change_field (ibuf, "Date", stamp_data.date); - if (stamp_data.marker[0]) IMB_imginfo_change_field (ibuf, "Marker", stamp_data.marker); - if (stamp_data.time[0]) IMB_imginfo_change_field (ibuf, "Time", stamp_data.time); - if (stamp_data.frame[0]) IMB_imginfo_change_field (ibuf, "Frame", stamp_data.frame); - if (stamp_data.camera[0]) IMB_imginfo_change_field (ibuf, "Camera", stamp_data.camera); - if (stamp_data.scene[0]) IMB_imginfo_change_field (ibuf, "Scene", stamp_data.scene); - if (stamp_data.strip[0]) IMB_imginfo_change_field (ibuf, "Strip", stamp_data.strip); + if (stamp_data.file[0]) IMB_metadata_change_field (ibuf, "File", stamp_data.file); + if (stamp_data.note[0]) IMB_metadata_change_field (ibuf, "Note", stamp_data.note); + if (stamp_data.date[0]) IMB_metadata_change_field (ibuf, "Date", stamp_data.date); + if (stamp_data.marker[0]) IMB_metadata_change_field (ibuf, "Marker", stamp_data.marker); + if (stamp_data.time[0]) IMB_metadata_change_field (ibuf, "Time", stamp_data.time); + if (stamp_data.frame[0]) IMB_metadata_change_field (ibuf, "Frame", stamp_data.frame); + if (stamp_data.camera[0]) IMB_metadata_change_field (ibuf, "Camera", stamp_data.camera); + if (stamp_data.scene[0]) IMB_metadata_change_field (ibuf, "Scene", stamp_data.scene); + if (stamp_data.strip[0]) IMB_metadata_change_field (ibuf, "Strip", stamp_data.strip); } int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimtype, int quality) @@ -1273,9 +1216,6 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt else if(imtype==R_RAWTGA) { ibuf->ftype= RAWTGA; } - else if(imtype==R_HAMX) { - ibuf->ftype= AN_hamx; - } #ifdef WITH_OPENJPEG else if(imtype==R_JP2) { if(quality < 10) quality= 90; @@ -1299,7 +1239,7 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt } #endif else { - /* R_JPEG90, R_MOVIE, etc. default we save jpegs */ + /* R_JPEG90, etc. default we save jpegs */ if(quality < 10) quality= 90; ibuf->ftype= JPG|quality; if(ibuf->depth==32) ibuf->depth= 24; /* unsupported feature only confuses other s/w */ @@ -1595,6 +1535,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) struct ImBuf *ibuf; unsigned short numlen; char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX]; + int flag; /* XXX temp stuff? */ if(ima->lastframe != frame) @@ -1611,8 +1552,12 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) else BLI_path_abs(name, G.sce); + flag= IB_rect|IB_multilayer; + if(ima->flag & IMA_DO_PREMUL) + flag |= IB_premul; + /* read ibuf */ - ibuf = IMB_loadiffname(name, IB_rect|IB_multilayer); + ibuf = IMB_loadiffname(name, flag); if(G.f & G_DEBUG) printf("loaded %s\n", name); if (ibuf) { @@ -1632,10 +1577,6 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, 0, frame); #endif - - if(ima->flag & IMA_DO_PREMUL) - converttopremul(ibuf); - } else ima->ok= 0; @@ -1718,7 +1659,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) else BLI_path_abs(str, G.sce); - ima->anim = openanim(str, IB_cmap | IB_rect); + ima->anim = openanim(str, IB_rect); /* let's initialize this user */ if(ima->anim && iuser && iuser->frames==0) @@ -1749,21 +1690,25 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) return ibuf; } -/* cfra used for # code, Image can only have this # for all its users */ +/* cfra used for # code, Image can only have this # for all its users + * warning, 'iuser' can be NULL */ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) { struct ImBuf *ibuf; char str[FILE_MAX]; - int assign = 0; + int assign = 0, flag; /* always ensure clean ima */ image_free_buffers(ima); /* is there a PackedFile with this image ? */ if (ima->packedfile) { - ibuf = IMB_ibImageFromMemory((int *) ima->packedfile->data, ima->packedfile->size, IB_rect|IB_multilayer); + ibuf = IMB_ibImageFromMemory((unsigned char*)ima->packedfile->data, ima->packedfile->size, IB_rect|IB_multilayer); } else { + flag= IB_rect|IB_multilayer|IB_metadata; + if(ima->flag & IMA_DO_PREMUL) + flag |= IB_premul; /* get the right string */ BLI_strncpy(str, ima->name, sizeof(str)); @@ -1775,7 +1720,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) BLI_path_frame(str, cfra, 0); /* read ibuf */ - ibuf = IMB_loadiffname(str, IB_rect|IB_multilayer|IB_imginfo); + ibuf = IMB_loadiffname(str, flag); } if (ibuf) { @@ -1797,9 +1742,6 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) if ((ima->packedfile == NULL) && (G.fileflags & G_AUTOPACK)) ima->packedfile = newPackedFile(NULL, str); } - - if(ima->flag & IMA_DO_PREMUL) - converttopremul(ibuf); } else ima->ok= 0; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 52c6f9355a3..9e95581b211 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -264,38 +264,6 @@ int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob, return result; } -static void multires_set_tot_mdisps(Mesh *me, int lvl) -{ - MDisps *mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); - int i; - - if(mdisps) { - for(i = 0; i < me->totface; i++) { - if(mdisps[i].totdisp == 0) { - int nvert = (me->mface[i].v4)? 4: 3; - mdisps[i].totdisp = multires_grid_tot[lvl]*nvert; - } - } - } -} - -static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) -{ - int i; - - /* reallocate displacements to be filled in */ - for(i = 0; i < me->totface; ++i) { - int nvert = (me->mface[i].v4)? 4: 3; - int totdisp = multires_grid_tot[lvl]*nvert; - float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); - - if(mdisps[i].disps) - MEM_freeN(mdisps[i].disps); - - mdisps[i].disps = disps; - mdisps[i].totdisp = totdisp; - } -} static void column_vectors_to_mat3(float mat[][3], float v1[3], float v2[3], float v3[3]) { @@ -352,7 +320,6 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire int levels = mmd->totlvl - lvl; MDisps *mdisps; - multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -426,6 +393,24 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0); } +static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) +{ + int i; + + /* reallocate displacements to be filled in */ + for(i = 0; i < me->totface; ++i) { + int nvert = (me->mface[i].v4)? 4: 3; + int totdisp = multires_grid_tot[lvl]*nvert; + float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); + + if(mdisps[i].disps) + MEM_freeN(mdisps[i].disps); + + mdisps[i].disps = disps; + mdisps[i].totdisp = totdisp; + } +} + void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) { Mesh *me = ob->data; @@ -630,7 +615,6 @@ static void multiresModifier_update(DerivedMesh *dm) ob = ccgdm->multires.ob; me = ccgdm->multires.ob->data; mmd = ccgdm->multires.mmd; - multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -766,7 +750,6 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize); } - multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); multiresModifier_disp_run(result, ob->data, 0, 0, subGridData, mmd->totlvl); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index e48c4ea718c..4a9624036ff 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1777,7 +1777,7 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf if(seq->flag & SEQ_MAKE_PREMUL) { if(se->ibuf->depth == 32 && se->ibuf->zbuf == 0) { - converttopremul(se->ibuf); + IMB_premultiply_alpha(se->ibuf); } } diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index f4bcb6d412f..00614ef0f4f 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -75,11 +75,6 @@ bMovieHandle *BKE_get_movie_handle(int imtype) mh.get_movie_path = filepath_avi; /* do the platform specific handles */ -#ifdef __sgi - if (imtype == R_MOVIE) { - - } -#endif #if defined(_WIN32) && !defined(FREE_WINDOWS) if (imtype == R_AVICODEC) { //XXX mh.start_movie= start_avi_codec; -- cgit v1.2.3 From 22978ebfdc8a4506431492ac39d0ffd5d975093f Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 7 May 2010 18:53:28 +0000 Subject: Logic UI - fixing missing rna default values there are some cases (i.e. Constraint Actuator) where the same DNA property is being used by different RNAs with different ranges. It's easy to change (reset the values to their default in the set func of the constrant type rna). Not sure it's necessary though. --- source/blender/blenkernel/intern/sca.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 060c9312f99..5a06c251b88 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -98,6 +98,8 @@ void init_sensor(bSensor *sens) /* also use when sensor changes type */ bNearSensor *ns; bMouseSensor *ms; + bJoystickSensor *js; + bRaySensor *rs; if(sens->data) MEM_freeN(sens->data); sens->data= NULL; @@ -145,12 +147,18 @@ void init_sensor(bSensor *sens) break; case SENS_RAY: sens->data= MEM_callocN(sizeof(bRaySensor), "raysens"); + rs = sens->data; + rs->range = 0.01f; break; case SENS_MESSAGE: sens->data= MEM_callocN(sizeof(bMessageSensor), "messagesens"); break; case SENS_JOYSTICK: sens->data= MEM_callocN(sizeof(bJoystickSensor), "joysticksens"); + js= sens->data; + js->hatf = SENS_JOY_HAT_UP; + js->axis = 1; + js->hat = 1; break; default: ; /* this is very severe... I cannot make any memory for this */ @@ -383,7 +391,9 @@ void copy_actuators(ListBase *lbn, ListBase *lbo) void init_actuator(bActuator *act) { /* also use when actuator changes type */ + bCameraActuator *ca; bObjectActuator *oa; + bRandomActuator *ra; bSoundActuator *sa; if(act->data) MEM_freeN(act->data); @@ -417,6 +427,8 @@ void init_actuator(bActuator *act) break; case ACT_CAMERA: act->data= MEM_callocN(sizeof(bCameraActuator), "camact"); + ca = act->data; + ca->axis = ACT_CAMERA_X; break; case ACT_EDIT_OBJECT: act->data= MEM_callocN(sizeof(bEditObjectActuator), "editobact"); @@ -432,6 +444,8 @@ void init_actuator(bActuator *act) break; case ACT_RANDOM: act->data= MEM_callocN(sizeof(bRandomActuator), "random act"); + ra=act->data; + ra->float_arg_1 = 0.1f; break; case ACT_MESSAGE: act->data= MEM_callocN(sizeof(bMessageActuator), "message act"); -- cgit v1.2.3 From 5371c54a4cc9043fc300834c57855117f5553ad3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 16:36:28 +0000 Subject: bugfix [#21085] Sequencer file selector for movies is strange elubie fixed the first part, this fixes the internal data updating while keeping the frame range. --- source/blender/blenkernel/BKE_sequencer.h | 2 +- source/blender/blenkernel/intern/sequencer.c | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 2bf6eee5e6b..354638013ec 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -154,7 +154,7 @@ void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, i void calc_sequence(struct Scene *scene, struct Sequence *seq); void calc_sequence_disp(struct Scene *scene, struct Sequence *seq); void new_tstripdata(struct Sequence *seq); -void reload_sequence_new_file(struct Scene *scene, struct Sequence * seq); +void reload_sequence_new_file(struct Scene *scene, struct Sequence * seq, int lock_range); void sort_seq(struct Scene *scene); void build_seqar_cb(struct ListBase *seqbase, struct Sequence ***seqar, int *totseq, int (*test_func)(struct Sequence * seq)); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4a9624036ff..245de6213d5 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -566,9 +566,12 @@ void calc_sequence(Scene *scene, Sequence *seq) } } -void reload_sequence_new_file(Scene *scene, Sequence * seq) +/* note: caller should run calc_sequence(scene, seq) */ +void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) { char str[FILE_MAXDIR+FILE_MAXFILE]; + int prev_startdisp, prev_enddisp; + /* note: dont rename the strip, will break animation curves */ if (!(seq->type == SEQ_MOVIE || seq->type == SEQ_IMAGE || seq->type == SEQ_SOUND || @@ -576,6 +579,14 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) return; } + if(lock_range) { + /* keep so we dont have to move the actual start and end points (only the data) */ + calc_sequence_disp(scene, seq); + prev_startdisp= seq->startdisp; + prev_enddisp= seq->enddisp; + } + + new_tstripdata(seq); if (seq->type != SEQ_SCENE && seq->type != SEQ_META && @@ -587,6 +598,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) if (seq->type == SEQ_IMAGE) { /* Hack? */ size_t olen = MEM_allocN_len(seq->strip->stripdata)/sizeof(struct StripElem); + seq->len = olen; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; @@ -621,6 +633,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) } seq->strip->len = seq->len; } else if (seq->type == SEQ_SCENE) { + /* 'seq->scenenr' should be replaced with something more reliable */ Scene * sce = G.main->scene.first; int nr = 1; @@ -637,9 +650,6 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) } else { sce = seq->scene; } - - BLI_strncpy(seq->name+2, sce->id.name + 2, SEQ_NAME_MAXSTR-2); - seqbase_unique_name_recursive(&scene->ed->seqbase, seq); seq->len= seq->scene->r.efra - seq->scene->r.sfra + 1; seq->len -= seq->anim_startofs; @@ -652,6 +662,12 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) free_proxy_seq(seq); + if(lock_range) { + seq_tx_set_final_left(seq, prev_startdisp); + seq_tx_set_final_right(seq, prev_enddisp); + seq_single_fix(seq); + } + calc_sequence(scene, seq); } -- cgit v1.2.3 From d58a591072059f0cb0af905790045aabc5a2b614 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 19:08:33 +0000 Subject: Sequencer crashes with clips that have OpenGl render enabled (rev 28658) disabling for now, opengl write rendering isnt drivial to solve. --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 245de6213d5..f1e60ee2cfd 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2178,7 +2178,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int int rendering = G.rendering; int doseq; - int doseq_gl= G.rendering ? (scene->r.seq_flag & R_SEQ_GL_REND) : (scene->r.seq_flag & R_SEQ_GL_PREV); + int doseq_gl= G.rendering ? /*(scene->r.seq_flag & R_SEQ_GL_REND)*/ 0 : (scene->r.seq_flag & R_SEQ_GL_PREV); /* prevent eternal loop */ doseq= scene->r.scemode & R_DOSEQ; -- cgit v1.2.3 From 5741dbf6e48e71f4a30e496e948d04a44941adda Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 May 2010 20:07:29 +0000 Subject: render time wasnt being written to the metadata of images. --- source/blender/blenkernel/intern/image.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a377bbed24c..eb478eaddf5 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1163,6 +1163,7 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) if (stamp_data.camera[0]) IMB_metadata_change_field (ibuf, "Camera", stamp_data.camera); if (stamp_data.scene[0]) IMB_metadata_change_field (ibuf, "Scene", stamp_data.scene); if (stamp_data.strip[0]) IMB_metadata_change_field (ibuf, "Strip", stamp_data.strip); + if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime); } int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimtype, int quality) -- cgit v1.2.3 From 29ba391a164d432c5710a1fba1b4e70ea06acde7 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 10 May 2010 01:44:55 +0000 Subject: Turned on auto-execute python scripts by default, as agreed in recent meeting. Also added notice to download page: http://www.blender.org/download/get-25-alpha/ Which links to here, too: http://wiki.blender.org/index.php/Doc:2.5/Manual/Introduction/Installing_Blender/Security --- source/blender/blenkernel/intern/blender.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 42c492d3237..5d12675952c 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -130,6 +130,8 @@ void initglobals(void) G.charstart = 0x0000; G.charmin = 0x0000; G.charmax = 0xffff; + + G.f |= G_SCRIPT_AUTOEXEC; } /***/ -- cgit v1.2.3 From d384174b455c58f4f38a29dc518ce0b3d8fa696d Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 10 May 2010 01:46:44 +0000 Subject: Tweaks to image editor scopes, while testing a bug --- source/blender/blenkernel/BKE_colortools.h | 1 + source/blender/blenkernel/intern/colortools.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index f78389fe4de..1f2dee6dcfc 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -76,6 +76,7 @@ void colorcorrection_do_ibuf(struct ImBuf *ibuf, const char *profile); void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, int use_color_management); void scopes_free(struct Scopes *scopes); +void scopes_new(struct Scopes *scopes); #endif diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 66ebac2e25e..2856a333a5f 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -1110,3 +1110,19 @@ void scopes_free(Scopes *scopes) scopes->vecscope = NULL; } } + +void scopes_new(Scopes *scopes) +{ + scopes->accuracy=30.0; + scopes->hist.mode=HISTO_MODE_RGB; + scopes->wavefrm_alpha=0.3; + scopes->vecscope_alpha=0.3; + scopes->wavefrm_height= 100; + scopes->vecscope_height= 100; + scopes->hist.height= 100; + scopes->ok= 0; + scopes->waveform_1 = NULL; + scopes->waveform_2 = NULL; + scopes->waveform_3 = NULL; + scopes->vecscope = NULL; +} -- cgit v1.2.3 From bd4fe1b71dea85947f4d670ea749d7e07a2ed83c Mon Sep 17 00:00:00 2001 From: Xavier Thomas Date: Mon, 10 May 2010 03:42:22 +0000 Subject: Fix for histogram Luma mode not working when waveform is in RGB mode. Also unified the scope vocabulary. --- source/blender/blenkernel/intern/colortools.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 2856a333a5f..c8a01b1c12f 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -918,7 +918,7 @@ DO_INLINE void save_sample_line(Scopes *scopes, const int idx, const float fx, f scopes->waveform_3[idx + 0] = fx; scopes->waveform_3[idx + 1] = rgb[2]; break; - case SCOPES_WAVEFRM_LUM: + case SCOPES_WAVEFRM_LUMA: scopes->waveform_1[idx + 0] = fx; scopes->waveform_1[idx + 1] = ycc[0]; break; @@ -943,7 +943,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) unsigned char *rc=NULL; unsigned int *bin_r, *bin_g, *bin_b, *bin_lum; int savedlines, saveline; - float rgb[3], ycc[3]; + float rgb[3], ycc[3], luma; int ycc_mode=-1; if (scopes->ok == 1 ) return; @@ -959,7 +959,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) case SCOPES_WAVEFRM_RGB: ycc_mode = -1; break; - case SCOPES_WAVEFRM_LUM: + case SCOPES_WAVEFRM_LUMA: case SCOPES_WAVEFRM_YCC_JPEG: ycc_mode = BLI_YCC_JFIF_0_255; break; @@ -1027,6 +1027,10 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) for (c=0; c<3; c++) rgb[c] = rc[c] * INV_255; } + + /* we still need luma for histogram */ + luma = 0.299*rgb[0] + 0.587*rgb[1] + 0.114 * rgb[2]; + /* check for min max */ if(ycc_mode == -1 ) { for (c=0; c<3; c++) { @@ -1046,7 +1050,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) bin_r[ get_bin_float(rgb[0]) ] += 1; bin_g[ get_bin_float(rgb[1]) ] += 1; bin_b[ get_bin_float(rgb[2]) ] += 1; - bin_lum[ get_bin_float(ycc[0]) ] += 1; + bin_lum[ get_bin_float(luma) ] += 1; /* save sample if needed */ if(saveline) { -- cgit v1.2.3 From 50b412939836b3033841fb82918c67ddbcf5c399 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 10 May 2010 15:02:37 +0000 Subject: Recommit fix that I seem to have uncommitted accidentally, had the fix still in my source tree but svn wasn't showing any diffs.. weird. --- source/blender/blenkernel/intern/multires.c | 53 +++++++++++++++++++---------- 1 file changed, 35 insertions(+), 18 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 9e95581b211..52c6f9355a3 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -264,6 +264,38 @@ int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob, return result; } +static void multires_set_tot_mdisps(Mesh *me, int lvl) +{ + MDisps *mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); + int i; + + if(mdisps) { + for(i = 0; i < me->totface; i++) { + if(mdisps[i].totdisp == 0) { + int nvert = (me->mface[i].v4)? 4: 3; + mdisps[i].totdisp = multires_grid_tot[lvl]*nvert; + } + } + } +} + +static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) +{ + int i; + + /* reallocate displacements to be filled in */ + for(i = 0; i < me->totface; ++i) { + int nvert = (me->mface[i].v4)? 4: 3; + int totdisp = multires_grid_tot[lvl]*nvert; + float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); + + if(mdisps[i].disps) + MEM_freeN(mdisps[i].disps); + + mdisps[i].disps = disps; + mdisps[i].totdisp = totdisp; + } +} static void column_vectors_to_mat3(float mat[][3], float v1[3], float v2[3], float v3[3]) { @@ -320,6 +352,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire int levels = mmd->totlvl - lvl; MDisps *mdisps; + multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -393,24 +426,6 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0); } -static void multires_reallocate_mdisps(Mesh *me, MDisps *mdisps, int lvl) -{ - int i; - - /* reallocate displacements to be filled in */ - for(i = 0; i < me->totface; ++i) { - int nvert = (me->mface[i].v4)? 4: 3; - int totdisp = multires_grid_tot[lvl]*nvert; - float (*disps)[3] = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps"); - - if(mdisps[i].disps) - MEM_freeN(mdisps[i].disps); - - mdisps[i].disps = disps; - mdisps[i].totdisp = totdisp; - } -} - void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) { Mesh *me = ob->data; @@ -615,6 +630,7 @@ static void multiresModifier_update(DerivedMesh *dm) ob = ccgdm->multires.ob; me = ccgdm->multires.ob->data; mmd = ccgdm->multires.mmd; + multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -750,6 +766,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize); } + multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); multiresModifier_disp_run(result, ob->data, 0, 0, subGridData, mmd->totlvl); -- cgit v1.2.3 From 3409eb429ead652c0955ee06af09de31af379276 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 May 2010 19:37:17 +0000 Subject: fix for crash reading pointcache, was reading over the buffer size, use lzo1x_decompress_safe rather then lzo1x_decompress --- source/blender/blenkernel/intern/pointcache.c | 30 +++++++++++++++------------ 1 file changed, 17 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 b42ac6fdf49..557c1fe0d46 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -812,23 +812,27 @@ static int ptcache_compress_read(PTCacheFile *pf, unsigned char *result, unsigne ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char)); if(compressed) { ptcache_file_read(pf, &in_len, 1, sizeof(unsigned int)); - in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer"); - ptcache_file_read(pf, in, in_len, sizeof(unsigned char)); - + if(in_len==0) { + /* do nothing */ + } + else { + in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer"); + ptcache_file_read(pf, in, in_len, sizeof(unsigned char)); #ifdef WITH_LZO - if(compressed == 1) - r = lzo1x_decompress(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL); + if(compressed == 1) + r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL); #endif #ifdef WITH_LZMA - if(compressed == 2) - { - size_t leni = in_len, leno = out_len; - ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int)); - ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char)); - r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt); - } + if(compressed == 2) + { + size_t leni = in_len, leno = out_len; + ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int)); + ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char)); + r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt); + } #endif - MEM_freeN(in); + MEM_freeN(in); + } } else { ptcache_file_read(pf, result, len, sizeof(unsigned char)); -- cgit v1.2.3 From aaa7c493e40c460a90a1f9bfced5ce7b67e3d81a Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Tue, 11 May 2010 20:06:20 +0000 Subject: merge of last commit to trunk --- source/blender/blenkernel/intern/pointcache.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 557c1fe0d46..160f8a35520 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1712,14 +1712,13 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) int totpoint = pid->totpoint(pid->calldata, cfra); int add = 0, overwrite = 0; - if(totpoint == 0 || cfra < 0 - || (cfra ? pid->data_types == 0 : pid->info_types == 0)) + if(totpoint == 0 || (cfra ? pid->data_types == 0 : pid->info_types == 0)) return 0; if(cache->flag & PTCACHE_DISK_CACHE) { int ofra=0, efra = cache->endframe; - if(cfra==0) + if(cfra==0 && cache->startframe > 0) add = 1; /* allways start from scratch on the first frame */ else if(cfra == cache->startframe) { @@ -1931,7 +1930,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */ if (mode == PTCACHE_CLEAR_ALL) { - pid->cache->last_exact = 0; + pid->cache->last_exact = MIN2(pid->cache->startframe, 0); BLI_join_dirfile(path_full, path, de->d_name); BLI_delete(path_full, 0, 0); } else { @@ -1963,7 +1962,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) pm= pid->cache->mem_cache.first; if(mode == PTCACHE_CLEAR_ALL) { - pid->cache->last_exact = 0; + /*we want startframe if the cache starts before zero*/ + pid->cache->last_exact = MIN2(pid->cache->startframe, 0); for(; pm; pm=pm->next) ptcache_free_data(pm); BLI_freelistN(&pid->cache->mem_cache); @@ -2880,6 +2880,6 @@ void BKE_ptcache_invalidate(PointCache *cache) { cache->flag &= ~PTCACHE_SIMULATION_VALID; cache->simframe = 0; - cache->last_exact = 0; + cache->last_exact = MIN2(cache->startframe, 0); } -- cgit v1.2.3 From dffa42e636124032fcbadabc912a55b03afca973 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 13 May 2010 09:22:05 +0000 Subject: use ID_REAL_USERS macro --- source/blender/blenkernel/intern/anim_sys.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 9fb442f8600..a7a4d789610 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1805,9 +1805,10 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) */ #define EVAL_ANIM_IDS(first, aflag) \ for (id= first; id; id= id->next) { \ - AnimData *adt= BKE_animdata_from_id(id); \ - if ( (id->us > 1) || (id->us && !(id->flag & LIB_FAKEUSER)) ) \ + if (ID_REAL_USERS(id) > 0) { \ + AnimData *adt= BKE_animdata_from_id(id); \ BKE_animsys_evaluate_animdata(id, adt, ctime, aflag); \ + } \ } /* optimisation: -- cgit v1.2.3 From d8856352164d1118f46eae59a60bf1c0abb36516 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 13 May 2010 19:23:52 +0000 Subject: Fix #22137: Shrink wrap modifer with curves, projection bug Always pack DispList into one block for deformation modifiers and create DerivedMesh for all curve objects passed to get_dm. This would fix problems with modifiers when they're creating dm for additional information (as it's made in shrinkwrap for normals). Small additional code cleanup in curve_calc_modifiers_post(). --- source/blender/blenkernel/intern/displist.c | 129 +++++++++++++++------------- 1 file changed, 71 insertions(+), 58 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index d744baac84a..24f996fbb31 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1274,6 +1274,40 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl *numVerts_r = numVerts; } +static float (*displist_get_allverts (ListBase *dispbase, int *totvert))[3] +{ + DispList *dl; + float (*allverts)[3], *fp; + + *totvert= 0; + + for (dl=dispbase->first; dl; dl=dl->next) + *totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr; + + allverts= MEM_mallocN((*totvert)*sizeof(float)*3, "displist_get_allverts allverts"); + fp= (float*)allverts; + for (dl=dispbase->first; dl; dl=dl->next) { + int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + memcpy(fp, dl->verts, sizeof(float) * offs); + fp+= offs; + } + + return allverts; +} + +static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3]) +{ + DispList *dl; + float *fp; + + fp= (float*)allverts; + for (dl=dispbase->first; dl; dl=dl->next) { + int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + memcpy(dl->verts, fp, sizeof(float) * offs); + fp+= offs; + } +} + static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, DerivedMesh **derivedFinal, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) { @@ -1281,12 +1315,10 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba ModifierData *preTesselatePoint; Curve *cu= ob->data; ListBase *nurb= cu->editnurb?cu->editnurb:&cu->nurb; - DispList *dl; - int required_mode; + int required_mode, totvert; int editmode = (!forRender && cu->editnurb); DerivedMesh *dm= NULL, *ndm; - float (*dmDeformedVerts)[3] = NULL; - int numVerts; + float (*vertCos)[3] = NULL; if(forRender) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; @@ -1311,47 +1343,22 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba if ((md->mode & required_mode) != required_mode) continue; if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if(md->type==eModifierType_Curve && !dm) { - /* need to put all verts in 1 block for curve deform */ - float *allverts = NULL, *fp; - int totvert= 0; - - for (dl=dispbase->first; dl; dl=dl->next) - totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr; - - fp= allverts= MEM_mallocN(totvert*sizeof(float)*3, "temp vert"); - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); - memcpy(fp, dl->verts, sizeof(float) * offs); - fp+= offs; - } - - mti->deformVerts(md, ob, NULL, (float(*)[3]) allverts, totvert, forRender, editmode); - - if (allverts) { - fp= allverts; - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); - memcpy(dl->verts, fp, sizeof(float) * offs); - fp+= offs; - } - MEM_freeN(allverts); - } - } else if (mti->type == eModifierTypeType_OnlyDeform || + if (mti->type == eModifierTypeType_OnlyDeform || (mti->type == eModifierTypeType_DeformOrConstruct && !dm)) { if (dm) { - if (!dmDeformedVerts) { - numVerts = dm->getNumVerts(dm); - dmDeformedVerts = - MEM_mallocN(sizeof(*dmDeformedVerts) * numVerts, "dfmv"); - dm->getVertCos(dm, dmDeformedVerts); + if (!vertCos) { + totvert = dm->getNumVerts(dm); + vertCos = MEM_mallocN(sizeof(*vertCos) * totvert, "dfmv"); + dm->getVertCos(dm, vertCos); } - mti->deformVerts(md, ob, dm, dmDeformedVerts, numVerts, forRender, editmode); + mti->deformVerts(md, ob, dm, vertCos, totvert, forRender, editmode); } else { - for (dl=dispbase->first; dl; dl=dl->next) { - mti->deformVerts(md, ob, dm, (float(*)[3]) dl->verts, (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr, forRender, editmode); + if (!vertCos) { + vertCos= displist_get_allverts(dispbase, &totvert); } + + mti->deformVerts(md, ob, NULL, vertCos, totvert, forRender, editmode); } } else { if (!derivedFinal) { @@ -1362,29 +1369,34 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } if (dm) { - if (dmDeformedVerts) { + if (vertCos) { DerivedMesh *tdm = CDDM_copy(dm); dm->release(dm); dm = tdm; - CDDM_apply_vert_coords(dm, dmDeformedVerts); + CDDM_apply_vert_coords(dm, vertCos); CDDM_calc_normals(dm); } } else { + if (vertCos) { + displist_apply_allverts(dispbase, vertCos); + } + if (ELEM(ob->type, OB_CURVE, OB_FONT) && (cu->flag & CU_DEFORM_FILL)) { curve_to_filledpoly(cu, nurb, dispbase); } dm= CDDM_from_curve_customDB(ob, dispbase); - if(dmDeformedVerts) { - CDDM_apply_vert_coords(dm, dmDeformedVerts); - CDDM_calc_normals(dm); - } - CDDM_calc_normals(dm); } + if (vertCos) { + /* Vertex coordinates were applied to necessary data, could free it */ + MEM_freeN(vertCos); + vertCos= NULL; + } + ndm = mti->applyModifier(md, ob, dm, forRender, editmode); if (ndm) { @@ -1393,23 +1405,24 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba if (dm && dm != ndm) /* Modifier */ dm->release (dm); dm = ndm; - - if (dmDeformedVerts) { - MEM_freeN(dmDeformedVerts); - dmDeformedVerts= NULL; - } } } } - if(dm && dmDeformedVerts) { - DerivedMesh *tdm = CDDM_copy(dm); - dm->release(dm); - dm = tdm; + if (vertCos) { + if (dm) { + DerivedMesh *tdm = CDDM_copy(dm); + dm->release(dm); + dm = tdm; - CDDM_apply_vert_coords(dm, dmDeformedVerts); - CDDM_calc_normals(dm); - MEM_freeN(dmDeformedVerts); + CDDM_apply_vert_coords(dm, vertCos); + CDDM_calc_normals(dm); + MEM_freeN(vertCos); + } else { + displist_apply_allverts(dispbase, vertCos); + MEM_freeN(vertCos); + vertCos= NULL; + } } if (derivedFinal) { -- cgit v1.2.3 From 279885290367b8ddb7570452b664ce4df796c192 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 14 May 2010 07:09:15 +0000 Subject: Fix: [#22310] Duplicate Does Not Propogate SimpleDeform's VGroup [#22321] duplicating object with smoke settings doesnt duplicate smoke settings ^ Genscher, you may want to check that but I thought it was pretty straightforward. --- source/blender/blenkernel/BKE_smoke.h | 1 + source/blender/blenkernel/intern/smoke.c | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_smoke.h b/source/blender/blenkernel/BKE_smoke.h index 4547f869439..088d61061b2 100644 --- a/source/blender/blenkernel/BKE_smoke.h +++ b/source/blender/blenkernel/BKE_smoke.h @@ -40,6 +40,7 @@ void smokeModifier_free (struct SmokeModifierData *smd); void smokeModifier_reset(struct SmokeModifierData *smd); void smokeModifier_reset_turbulence(struct SmokeModifierData *smd); void smokeModifier_createType(struct SmokeModifierData *smd); +void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData *tsmd); long long smoke_get_mem_req(int xres, int yres, int zres, int amplify); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index ccb83c760f0..7424026354a 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -753,6 +753,41 @@ void smokeModifier_createType(struct SmokeModifierData *smd) } } +void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData *tsmd) +{ + tsmd->type = smd->type; + tsmd->time = smd->time; + + smokeModifier_createType(tsmd); + + if (tsmd->domain) { + tsmd->domain->maxres = smd->domain->maxres; + tsmd->domain->amplify = smd->domain->amplify; + tsmd->domain->omega = smd->domain->omega; + tsmd->domain->alpha = smd->domain->alpha; + tsmd->domain->beta = smd->domain->beta; + tsmd->domain->flags = smd->domain->flags; + tsmd->domain->strength = smd->domain->strength; + tsmd->domain->noise = smd->domain->noise; + tsmd->domain->diss_speed = smd->domain->diss_speed; + tsmd->domain->viewsettings = smd->domain->viewsettings; + tsmd->domain->fluid_group = smd->domain->fluid_group; + tsmd->domain->coll_group = smd->domain->coll_group; + + MEM_freeN(tsmd->domain->effector_weights); + tsmd->domain->effector_weights = MEM_dupallocN(smd->domain->effector_weights); + } else if (tsmd->flow) { + tsmd->flow->density = smd->flow->density; + tsmd->flow->temp = smd->flow->temp; + tsmd->flow->psys = smd->flow->psys; + tsmd->flow->type = smd->flow->type; + } else if (tsmd->coll) { + ; + /* leave it as initialised, collision settings is mostly caches */ + } +} + + // forward decleration static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct); static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct); -- cgit v1.2.3 From 0790df09b7a436067cce01bdc560cc3f56eb5886 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 14 May 2010 18:09:59 +0000 Subject: fix for hair distrobution changing when rendered with a different number of threads (manifested flickering hair back from renderfarm) --- source/blender/blenkernel/intern/particle_system.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 621850f75c7..25328a06328 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -617,6 +617,10 @@ static int binary_search_distribution(float *sum, int n, float value) return low; } +/* the max number if calls to rng_* funcs within psys_thread_distribute_particle + * be sure to keep up to date if this changes */ +#define PSYS_RND_DIST_SKIP 2 + /* note: this function must be thread safe, for from == PART_FROM_CHILD */ #define ONLY_WORKING_WITH_PA_VERTS 0 static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, ChildParticle *cpa, int p) @@ -632,6 +636,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData int cfrom= ctx->cfrom; int distr= ctx->distr; int i, intersect, tot; + int rng_skip_tot= PSYS_RND_DIST_SKIP; /* count how many rng_* calls wont need skipping */ if(from == PART_FROM_VERT) { /* TODO_PARTICLE - use original index */ @@ -669,6 +674,8 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData case PART_DISTR_RAND: randu= rng_getFloat(thread->rng); randv= rng_getFloat(thread->rng); + rng_skip_tot -= 2; + psys_uv_to_w(randu, randv, mface->v4, pa->fuv); break; } @@ -751,6 +758,8 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData randu= rng_getFloat(thread->rng); randv= rng_getFloat(thread->rng); + rng_skip_tot -= 2; + psys_uv_to_w(randu, randv, mf->v4, cpa->fuv); cpa->num = ctx->index[p]; @@ -859,6 +868,9 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData cpa->parent=cpa->pa[0]; } } + + if(rng_skip_tot > 0) /* should never be below zero */ + rng_skip(thread->rng, rng_skip_tot); } static void *exec_distribution(void *data) @@ -875,12 +887,12 @@ static void *exec_distribution(void *data) for(p=0; pctx->skip) /* simplification skip */ - rng_skip(thread->rng, 5*thread->ctx->skip[p]); + rng_skip(thread->rng, PSYS_RND_DIST_SKIP * thread->ctx->skip[p]); if((p+thread->num) % thread->tot == 0) psys_thread_distribute_particle(thread, NULL, cpa, p); else /* thread skip */ - rng_skip(thread->rng, 5); + rng_skip(thread->rng, PSYS_RND_DIST_SKIP); } } else { -- cgit v1.2.3 From dc0edfd6652a4b237c71225fb7550bc4c7adf6c2 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 17 May 2010 04:22:41 +0000 Subject: Drivers Bugfix: Renaming bones now correctly fixes drivers referencing those bones. This includes driver paths and driver variables. --- source/blender/blenkernel/intern/anim_sys.c | 35 ++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index a7a4d789610..10c2c1801cb 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -339,6 +339,19 @@ static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, /* firstly, handle the F-Curve's own path */ if (fcu->rna_path) fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldName, newName, fcu->rna_path, verify_paths); + } +} + +/* Check RNA-Paths for a list of Drivers */ +static void drivers_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, char *oldKey, char *newKey, ListBase *curves, int verify_paths) +{ + FCurve *fcu; + + /* we need to check every curve - drivers are F-Curves too! */ + for (fcu= curves->first; fcu; fcu= fcu->next) { + /* firstly, handle the F-Curve's own path */ + if (fcu->rna_path) + fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths); /* driver? */ if (fcu->driver) { @@ -352,15 +365,16 @@ static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, { /* rename RNA path */ if (dtar->rna_path) - dtar->rna_path= rna_path_rename_fix(dtar->id, prefix, oldName, newName, dtar->rna_path, verify_paths); + dtar->rna_path= rna_path_rename_fix(dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths); /* also fix the bone-name (if applicable) */ - // XXX this has been disabled because the old/new names have padding which means this check will fail - //if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB)) && - // (dtar->pchan_name[0]) && (strcmp(oldName, dtar->pchan_name)==0) ) - //{ - // BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name)); - //} + if (strstr(prefix, "bones")) { + if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB)) && + (dtar->pchan_name[0]) && (strcmp(oldName, dtar->pchan_name)==0) ) + { + BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name)); + } + } } DRIVER_TARGETS_LOOPER_END } @@ -398,11 +412,12 @@ void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, c if (ELEM(NULL, owner_id, adt)) return; - if (oldName != NULL && newName != NULL) { + if ((oldName != NULL) && (newName != NULL)) { /* pad the names with [" "] so that only exact matches are made */ oldN= BLI_sprintfN("[\"%s\"]", oldName); newN= BLI_sprintfN("[\"%s\"]", newName); - } else { + } + else { oldN= BLI_sprintfN("[%d]", oldSubscript); newN= BLI_sprintfN("[%d]", newSubscript); } @@ -414,7 +429,7 @@ void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, c fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->tmpact->curves, verify_paths); /* Drivers - Drivers are really F-Curves */ - fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->drivers, verify_paths); + drivers_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &adt->drivers, verify_paths); /* NLA Data - Animation Data for Strips */ for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) -- cgit v1.2.3 From e3587f9e9fb245b168feb7d20ec367486201fd8f Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 18 May 2010 07:28:44 +0000 Subject: Fix [#22304] Tiff 16bit gives darker images Also fixed similar issue for jpeg2000 --- source/blender/blenkernel/BKE_utildefines.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 51d915cca18..0b3fce9408c 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -105,6 +105,7 @@ #define AVG2(x, y) ( 0.5 * ((x) + (y)) ) #define FTOCHAR(val) ((val)<=0.0f)? 0 : (((val)>(1.0f-0.5f/255.0f))? 255 : (char)((255.0f*(val))+0.5f)) +#define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f)) #define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);} #define VECCOPY2D(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1);} -- cgit v1.2.3 From a6826584efe66a18f7c9a7e68bdbf6f548442aa1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 18 May 2010 13:18:37 +0000 Subject: make pack all not back library data, dont attempt to pack image viewers or generated images. --- source/blender/blenkernel/intern/packedFile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index fb973febf04..dc4a9ee3bdc 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -186,7 +186,7 @@ PackedFile *newPackedFile(ReportList *reports, char *filename) file= open(name, O_BINARY|O_RDONLY); if (file <= 0) { - BKE_reportf(reports, RPT_ERROR, "Can't open file: \"%s\"", name); + BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name); } else { filelen = BLI_filesize(file); @@ -216,15 +216,15 @@ void packAll(Main *bmain, ReportList *reports) bSound *sound; for(ima=bmain->image.first; ima; ima=ima->id.next) - if(ima->packedfile == NULL) + if(ima->packedfile == NULL && ima->id.lib==NULL && ELEM3(ima->type, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) ima->packedfile = newPackedFile(reports, ima->name); for(vf=bmain->vfont.first; vf; vf=vf->id.next) - if(vf->packedfile == NULL) + if(vf->packedfile == NULL && vf->id.lib==NULL) vf->packedfile = newPackedFile(reports, vf->name); for(sound=bmain->sound.first; sound; sound=sound->id.next) - if(sound->packedfile == NULL) + if(sound->packedfile == NULL && vf->id.lib==NULL) sound->packedfile = newPackedFile(reports, sound->name); } -- cgit v1.2.3 From 88743740b8d0506501e2183a97e357a5f05b2b92 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 18 May 2010 14:38:25 +0000 Subject: dont use a thread for baking in background mode, its not really any advantage since it starts a single thread that runs a loop. --- source/blender/blenkernel/intern/pointcache.c | 58 +++++++++++++++------------ 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 160f8a35520..cb596622431 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2366,8 +2366,12 @@ typedef struct { static void *ptcache_make_cache_thread(void *ptr) { ptcache_make_cache_data *data = (ptcache_make_cache_data*)ptr; - for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) + for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) { scene_update_for_newframe(data->scene, data->scene->lay); + if(G.background) { + printf("bake: frame %d :: %d\n", (int)*data->cfra_ptr, data->endframe); + } + } data->thread_ended = TRUE; return NULL; @@ -2489,36 +2493,40 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) thread_data.thread_ended = FALSE; old_progress = -1; - BLI_init_threads(&threads, ptcache_make_cache_thread, 1); - BLI_insert_thread(&threads, (void*)&thread_data); - - while (thread_data.thread_ended == FALSE) { + if(G.background) { + ptcache_make_cache_thread((void*)&thread_data); + } + else { + BLI_init_threads(&threads, ptcache_make_cache_thread, 1); + BLI_insert_thread(&threads, (void*)&thread_data); - if(bake) - progress = (int)(100.0f * (float)(CFRA - startframe)/(float)(thread_data.endframe-startframe)); - else - progress = CFRA; + while (thread_data.thread_ended == FALSE) { - /* NOTE: baking should not redraw whole ui as this slows things down */ - if ((baker->progressbar) && (progress != old_progress)) { - baker->progressbar(baker->progresscontext, progress); - old_progress = progress; - } - - /* Delay to lessen CPU load from UI thread */ - PIL_sleep_ms(200); + if(bake) + progress = (int)(100.0f * (float)(CFRA - startframe)/(float)(thread_data.endframe-startframe)); + else + progress = CFRA; + + /* NOTE: baking should not redraw whole ui as this slows things down */ + if ((baker->progressbar) && (progress != old_progress)) { + baker->progressbar(baker->progresscontext, progress); + old_progress = progress; + } + + /* Delay to lessen CPU load from UI thread */ + PIL_sleep_ms(200); - /* NOTE: breaking baking should leave calculated frames in cache, not clear it */ - if(blender_test_break() && !thread_data.break_operation) { - thread_data.break_operation = TRUE; - if (baker->progressend) - baker->progressend(baker->progresscontext); - WM_cursor_wait(1); + /* NOTE: breaking baking should leave calculated frames in cache, not clear it */ + if(blender_test_break() && !thread_data.break_operation) { + thread_data.break_operation = TRUE; + if (baker->progressend) + baker->progressend(baker->progresscontext); + WM_cursor_wait(1); + } } - } BLI_end_threads(&threads); - + } /* clear baking flag */ if(pid) { cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED); -- cgit v1.2.3 From 86f71fad8bd32dfdc4d299d71235fc30a969858d Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 20 May 2010 11:04:15 +0000 Subject: Bugfix #22374: index=-1 not work for keyingset.paths.add() function Simple typo which meant that paths with 'Entire array' set could not be reimported properly. --- source/blender/blenkernel/intern/armature.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 4f9b9435a80..557f3900d7b 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2055,7 +2055,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o /* we need to clamp this within sensible values */ // NOTE: these should be fine for now, but should get sanitised in future - scale= MIN2( MAX2(scale, 0.0001) , 100000); + scale= MIN2(MAX2(scale, 0.0001) , 100000); } else scale= 1.0f; @@ -2127,8 +2127,6 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_ splineik_evaluate_bone(tree, scene, ob, pchan, i, ctime); } - // TODO: if another pass is needed to ensure the validity of the chain after blending, it should go here - /* free the tree info specific to SplineIK trees now */ if (tree->chain) MEM_freeN(tree->chain); if (tree->free_points) MEM_freeN(tree->points); -- cgit v1.2.3 From 768c0a4fa014d10300891d72bd218f316af2b893 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 20 May 2010 12:34:32 +0000 Subject: Quicky untested fix for MotionPath baking bug - heads/tails doesn't work (as reported by William). Hopefully this improves/fixes the problem. --- source/blender/blenkernel/intern/anim.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 8619ab1eb1c..e2ee4c27c31 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -187,6 +187,8 @@ bMotionPath *animviz_verify_motionpaths(Scene *scene, Object *ob, bPoseChannel * if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS) mpath->flag |= MOTIONPATH_FLAG_BHEAD; + else + mpath->flag &= ~MOTIONPATH_FLAG_BHEAD; /* allocate a cache */ mpath->points= MEM_callocN(sizeof(bMotionPathVert)*mpath->length, "bMotionPathVerts"); -- cgit v1.2.3 From 2be851c9665caab9e858f4c06ec59e7bb4201e17 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 21 May 2010 03:25:38 +0000 Subject: Blender TIFF support * Removed dynamic linking libTIFF code and change it to static linking (built into the blender executable). Dynamic linking made things a fair bit more complicated and wasn't working at all before on OS X - the dylib didn't exist and wasn't being copied. Since TIFF is more heavily depended upon now in Blender, it makes sense to make it less 'optional' and more in line with other libraries. I've updated both CMake and scons, and CMake on OS X/64bit works fine. It's now up to other platform/build system maintainers to enable this for their respective platforms (Campbell will check it for linux). For windows, and non-64bit osx, we need static libtiff libraries in /lib. I've added options WITH_TIFF for CMake and WITH_BF_TIFF for scons, so if blender won't build because of this, you should be able to disable these options until your build system has been updated. * Bonus feature: while doing this, I added support for loading 16bit and 32bit per channel TIFFs - they get converted to Blender's float buffers. Handy for zbrush displacement maps! --- source/blender/blenkernel/BKE_global.h | 3 --- source/blender/blenkernel/CMakeLists.txt | 4 ++++ source/blender/blenkernel/SConscript | 3 +++ source/blender/blenkernel/intern/image.c | 8 ++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 291deb5ea70..6a602339e11 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -83,9 +83,6 @@ typedef struct Global { struct VFont *selfont; struct ListBase ttfdata; - /* libtiff flag used to determine if shared library loaded for libtiff*/ - int have_libtiff; - /* this variable is written to / read from FileGlobal->fileflags */ int fileflags; diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index afb29fbcd62..68684bcc0a1 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -50,6 +50,10 @@ IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) +IF(WITH_TIFF) + ADD_DEFINITIONS(-DWITH_TIFF) +ENDIF(WITH_TIFF) + IF(WITH_OPENJPEG) ADD_DEFINITIONS(-DWITH_OPENJPEG) ENDIF(WITH_OPENJPEG) diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 57d7e45d986..6198520c853 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -38,6 +38,9 @@ else: if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') +if env['WITH_BF_TIFF']: + defs.append('WITH_TIFF') + if env['WITH_BF_OPENJPEG']: defs.append('WITH_OPENJPEG') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index eb478eaddf5..5588c8df161 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -779,10 +779,12 @@ void BKE_add_image_extension(char *string, int imtype) if(!BLI_testextensie(string, ".bmp")) extension= ".bmp"; } - else if(G.have_libtiff && (imtype==R_TIFF)) { +#ifdef WITH_TIFF + else if(imtype==R_TIFF) { if(!BLI_testextensie(string, ".tif") && !BLI_testextensie(string, ".tiff")) extension= ".tif"; } +#endif #ifdef WITH_OPENEXR else if( ELEM(imtype, R_OPENEXR, R_MULTILAYER)) { if(!BLI_testextensie(string, ".exr")) @@ -1187,12 +1189,14 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt else if ((imtype==R_BMP)) { ibuf->ftype= BMP; } - else if ((G.have_libtiff) && (imtype==R_TIFF)) { +#ifdef WITH_TIFF + else if (imtype==R_TIFF) { ibuf->ftype= TIF; if(subimtype & R_TIFF_16BIT) ibuf->ftype |= TIF_16BIT; } +#endif #ifdef WITH_OPENEXR else if (imtype==R_OPENEXR || imtype==R_MULTILAYER) { ibuf->ftype= OPENEXR; -- cgit v1.2.3 From 391c5fba71a2bbb68598c168dcb6e0651924a001 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 21 May 2010 12:17:34 +0000 Subject: Motion Paths: Experimental optimisations from joeedh for speeding up the calculation process This works by tricking the depsgraph into giving us a smaller list of objects to evaluate, with all the necessary objects + their dependencies at the start of the list. On any complicated setup where non-object parameters need to be referred to (i.e. by drivers) to affect an object's transform, these optimisations will fail and the old (slower) method is still the best way (modify the ifdef and comment out the optimise depsgraph call to do so). However, we'll assume that these aren't too common in real productions, so things should be fine with these fixes. If there really is a need for both, then global options to control these things could follow. --- source/blender/blenkernel/intern/anim.c | 92 ++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index e2ee4c27c31..9ef52c24e8b 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -252,6 +252,82 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets) /* ........ */ +/* Note on evaluation optimisations: + * Optimisations currently used here play tricks with the depsgraph in order to try and + * evaluate as few objects as strictly necessary to get nicer performance under standard + * production conditions. For those people who really need the accurate version, + */ + +/* tweak the object ordering to trick depsgraph into making MotionPath calculations run faster */ +static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets) +{ + Base *base, *baseNext; + MPathTarget *mpt; + + /* make sure our temp-tag isn't already in use */ + for (base= scene->base.first; base; base= base->next) + base->object->flag &= ~BA_TEMP_TAG; + + /* for each target, dump its object to the start of the list if it wasn't moved already */ + for (mpt= targets->first; mpt; mpt= mpt->next) { + for (base=scene->base.first; base; base=baseNext) { + baseNext = base->next; + + if ((base->object == mpt->ob) && !(mpt->ob->flag & BA_TEMP_TAG)) { + BLI_remlink(&scene->base, base); + BLI_addhead(&scene->base, base); + + mpt->ob->flag |= BA_TEMP_TAG; + break; // we really don't need to continue anymore once this happens, but this line might really 'break' + } + } + } + + /* "brew me a list that's sorted a bit faster now depsy" */ + DAG_scene_sort(scene); +} + +/* update scene for current frame */ +static void motionpaths_calc_update_scene(Scene *scene) +{ +#if 1 // 'production' optimisations always on + Base *base, *last=NULL; + + /* only stuff that moves or needs display still */ + DAG_scene_update_flags(scene, scene->lay); + + /* find the last object with the tag + * - all those afterwards are assumed to not be relevant for our calculations + */ + // optimise further by moving out... + for (base=scene->base.first; base; base=base->next) { + if (base->object->flag & BA_TEMP_TAG) + last = base; + } + + /* perform updates for tagged objects */ + // XXX: this will break if rigs depend on scene or other data that + // is animated but not attached to/updatable from objects + for (base=scene->base.first; base; base=base->next) { + /* update this object */ + object_handle_update(scene, base->object); + + /* if this is the last one we need to update, let's stop to save some time */ + if (base == last) + break; + } +#else // original, 'always correct' version + /* do all updates + * - if this is too slow, resort to using a more efficient way + * that doesn't force complete update, but for now, this is the + * most accurate way! + */ + scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving +#endif +} + +/* ........ */ + /* perform baking for the targets on the current frame */ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) { @@ -313,7 +389,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) // TODO: this method could be improved... // 1) max range for standard baking - // 2) minimum range for recalc baking (i.e. between keyfames, but how?) + // 2) minimum range for recalc baking (i.e. between keyframes, but how?) for (mpt= targets->first; mpt; mpt= mpt->next) { /* try to increase area to do (only as much as needed) */ sfra= MIN2(sfra, mpt->mpath->start_frame); @@ -321,14 +397,14 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) } if (efra <= sfra) return; + /* optimise the depsgraph for faster updates */ + // TODO: whether this is used should depend on some setting for the level of optimisations used + motionpaths_calc_optimise_depsgraph(scene, targets); + /* calculate path over requested range */ for (CFRA=sfra; CFRA<=efra; CFRA++) { - /* do all updates - * - if this is too slow, resort to using a more efficient way - * that doesn't force complete update, but for now, this is the - * most accurate way! - */ - scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving + /* update relevant data for new frame */ + motionpaths_calc_update_scene(scene); /* perform baking for targets */ motionpaths_calc_bake_targets(scene, targets); @@ -336,7 +412,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) /* reset original environment */ CFRA= cfra; - scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving + motionpaths_calc_update_scene(scene); /* clear recalc flags from targets */ for (mpt= targets->first; mpt; mpt= mpt->next) { -- cgit v1.2.3 From 64d057e8878acc7baf470fe2c01fe283eb8c65e1 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 21 May 2010 13:01:18 +0000 Subject: Bugfix: #22385: Shift-click in NLA does not do 'extend' select Caused by typo in selection flags code. --- source/blender/blenkernel/intern/anim.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 9ef52c24e8b..313d79cf3b9 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -256,6 +256,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets) * Optimisations currently used here play tricks with the depsgraph in order to try and * evaluate as few objects as strictly necessary to get nicer performance under standard * production conditions. For those people who really need the accurate version, + * disable the ifdef (i.e. 1 -> 0) and comment out the call to motionpaths_calc_optimise_depsgraph() */ /* tweak the object ordering to trick depsgraph into making MotionPath calculations run faster */ -- cgit v1.2.3 From 9f7c04944a6146c7ca2e8083595a6e9eb6fea47d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 21 May 2010 14:18:07 +0000 Subject: Removed unused argument mmd from multires reshape functions. --- source/blender/blenkernel/BKE_multires.h | 6 +++--- source/blender/blenkernel/intern/multires.c | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index e5c7745f637..258fb6f1b3f 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -52,9 +52,9 @@ void multiresModifier_join(struct Object *); void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple); -int multiresModifier_reshape(struct MultiresModifierData *mmd, struct Object *dst, struct Object *src); -int multiresModifier_reshapeFromDM(struct MultiresModifierData *mmd, struct Object *ob, struct DerivedMesh *srcdm); -int multiresModifier_reshapeFromDeformMod(struct MultiresModifierData *mmd, struct Object *ob, struct ModifierData *md); +int multiresModifier_reshape(struct Object *dst, struct Object *src); +int multiresModifier_reshapeFromDM(struct Object *ob, struct DerivedMesh *srcdm); +int multiresModifier_reshapeFromDeformMod(struct Object *ob, struct ModifierData *md); void multires_stitch_grids(struct Object *); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 52c6f9355a3..d8c39abc44a 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -207,7 +207,7 @@ void multiresModifier_join(Object *ob) } #endif -int multiresModifier_reshapeFromDM(MultiresModifierData *mmd, Object *ob, DerivedMesh *srcdm) +int multiresModifier_reshapeFromDM(Object *ob, DerivedMesh *srcdm) { DerivedMesh *mrdm = get_multires_dm (ob); @@ -228,13 +228,13 @@ int multiresModifier_reshapeFromDM(MultiresModifierData *mmd, Object *ob, Derive } /* Returns 1 on success, 0 if the src's totvert doesn't match */ -int multiresModifier_reshape(MultiresModifierData *mmd, Object *dst, Object *src) +int multiresModifier_reshape(Object *dst, Object *src) { DerivedMesh *srcdm = src->derivedFinal; - return multiresModifier_reshapeFromDM(mmd, dst, srcdm); + return multiresModifier_reshapeFromDM(dst, srcdm); } -int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob, ModifierData *md) +int multiresModifier_reshapeFromDeformMod(Object *ob, ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); DerivedMesh *dm, *ndm; @@ -256,7 +256,7 @@ int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob, dm->release(dm); /* Reshaping */ - result= multiresModifier_reshapeFromDM(mmd, ob, ndm); + result= multiresModifier_reshapeFromDM(ob, ndm); /* Cleanup */ ndm->release(ndm); -- cgit v1.2.3 From bb852842283f4a42db0e3214a697b98e779d0a00 Mon Sep 17 00:00:00 2001 From: Stefan Gartner Date: Fri, 21 May 2010 21:06:00 +0000 Subject: Makefiles: statically link tiff libs when WITH_TIFF is set to true, which is the default for all platforms --- source/blender/blenkernel/intern/Makefile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile index 4e365f363c3..ea06cb79781 100644 --- a/source/blender/blenkernel/intern/Makefile +++ b/source/blender/blenkernel/intern/Makefile @@ -132,6 +132,10 @@ ifeq ($(WITH_QUICKTIME), true) CPPFLAGS += -DWITH_QUICKTIME endif +ifeq ($(WITH_TIFF), true + CPPFLAGS += -DWITH_TIFF +endif + ifeq ($(OS), darwin) ifeq ($(WITH_BF_OPENMP), true) CPPFLAGS += -DPARALLEL=1 -- cgit v1.2.3 From c0a0f2c43e934e2054eefe5bf90889cf67b736f9 Mon Sep 17 00:00:00 2001 From: Stefan Gartner Date: Fri, 21 May 2010 21:26:03 +0000 Subject: Makefiles: make sure syntax is correct... --- source/blender/blenkernel/intern/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile index ea06cb79781..15c022592f9 100644 --- a/source/blender/blenkernel/intern/Makefile +++ b/source/blender/blenkernel/intern/Makefile @@ -132,7 +132,7 @@ ifeq ($(WITH_QUICKTIME), true) CPPFLAGS += -DWITH_QUICKTIME endif -ifeq ($(WITH_TIFF), true +ifeq ($(WITH_TIFF), true) CPPFLAGS += -DWITH_TIFF endif -- cgit v1.2.3 From 9777072c0e42931848ea82dc606d155717fc3adf Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 24 May 2010 07:30:50 +0000 Subject: Fix [#21521] Displacement modifier does not update when modifing texture Depgraph now handles texture dependencies - textures can affect objects/data via modifiers. --- source/blender/blenkernel/intern/depsgraph.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 1e5f276ba95..0568050950f 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2250,6 +2250,16 @@ void DAG_on_load_update(void) } } +static void dag_id_flush_update__isDependentTexture(void *userData, Object *ob, ID **idpoin) +{ + struct { ID *id; int is_dependent; } *data = userData; + + if(*idpoin && GS((*idpoin)->name)==ID_TE) { + if (data->id == (*idpoin)) + data->is_dependent = 1; + } +} + void DAG_id_flush_update(ID *id, short flag) { Main *bmain= G.main; @@ -2304,6 +2314,17 @@ void DAG_id_flush_update(ID *id, short flag) } } + /* set flags based on textures - can influence depgraph via modifiers */ + if(idtype == ID_TE) { + for(obt=bmain->object.first; obt; obt= obt->id.next) { + struct { ID *id; int is_dependent; } data = {id, 0}; + + modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data); + if (data.is_dependent) + obt->recalc |= OB_RECALC_DATA; + } + } + /* set flags based on ShapeKey */ if(idtype == ID_KE) { for(obt=bmain->object.first; obt; obt= obt->id.next) { -- cgit v1.2.3 From bd15f5122dabec7cdfebb8564f3e3529f4991bba Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Mon, 24 May 2010 18:53:45 +0000 Subject: BLI_args cleanup Adding documentation strings in argument data. --help is auto generated (options not manually categorized end up in the "others" section at the bottom) --- source/blender/blenkernel/BKE_utildefines.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 0b3fce9408c..73323c5a960 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -38,6 +38,9 @@ #define TRUE 1 #endif +/* Macro to convert a value to string in the preprocessor */ +#define QUOTE(x) #x + /* these values need to be hardcoded in structs, dna does not recognize defines */ /* also defined in DNA_space_types.h */ #ifndef FILE_MAXDIR -- cgit v1.2.3 From c61e25e6ac37296c13c0949b8363cc168125d750 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 24 May 2010 21:52:18 +0000 Subject: blend file thumbnailing - uses same thumbnail system as image browser - blend files show thumbnails in ubuntu/gnome (freedesktop spec) - 128x128 images are embedded into the blend file header, a simple loader avoids reading the entire blend file to extract it when generating thumbnails in the file selector. When the image browser reads a directory it loads images and creates thumbnails, blend files embedded images are treated just like loading an image. - the thumbnail is created from the camera view in solid mode. (no camera == no thumbnal). - readfile/writefile.c: had to use the 'TEST' code name to save thumbnails, anything else would segfault older blender versions on load. (its not used elsewhere). --- source/blender/blenkernel/BKE_utildefines.h | 2 +- source/blender/blenkernel/intern/blender.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 73323c5a960..925b1d7171a 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -166,7 +166,7 @@ #define IMAG MAKE_ID('I','M','A','G') #define DNA1 MAKE_ID('D','N','A','1') -#define TEST MAKE_ID('T','E','S','T') +#define TEST MAKE_ID('T','E','S','T') /* used as preview between 'REND' and 'GLOB' */ #define REND MAKE_ID('R','E','N','D') #define USER MAKE_ID('U','S','E','R') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 5d12675952c..046b8de2431 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -534,7 +534,7 @@ void BKE_write_undo(bContext *C, char *name) sprintf(numstr, "%d.blend", counter); BLI_make_file_string("/", tstr, btempdir, numstr); - success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL); + success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL, NULL); strcpy(curundo->str, tstr); } -- cgit v1.2.3 From c9ac1cc9862730f6e20563fc034d825c9a6aff04 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 25 May 2010 05:56:31 +0000 Subject: fix for 2 warnings & better error checking for the thumbnail loading. --- source/blender/blenkernel/intern/anim.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 313d79cf3b9..1c86bd57e2e 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -63,6 +63,7 @@ #include "BKE_particle.h" #include "BKE_scene.h" #include "BKE_utildefines.h" +#include "BKE_depsgraph.h" // XXX bad level call... -- cgit v1.2.3 From f7c4dd6d56be173cc1a63be9d72d212e3dca4c7c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 25 May 2010 13:33:59 +0000 Subject: Merge back a few cloth solver fixes from the render branch: * Disable openmp for dot product, this gives different results each time due to non-commutative floating point add. * Disable openmp with few vertices, the extra thread overhead only slows things down then. * Replace the hack that would divide stepsPerFrame and then set it back, now it simply uses the timescale in the collision function. This was incorrect because stepsPerFrame is an int, but we don't want this to be rounded. * Extra out of bounds check for hair velocity smoothing grid. --- source/blender/blenkernel/intern/cloth.c | 7 +-- source/blender/blenkernel/intern/collision.c | 32 +++++++------- source/blender/blenkernel/intern/implicit.c | 65 +++++++++++++++------------- 3 files changed, 51 insertions(+), 53 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 2b11c4bdfa0..ce5bca1da56 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -27,16 +27,13 @@ #include "MEM_guardedalloc.h" -#include "BKE_cloth.h" - #include "BKE_cdderivedmesh.h" +#include "BKE_cloth.h" #include "BKE_effect.h" #include "BKE_global.h" #include "BKE_modifier.h" -#include "BKE_utildefines.h" - #include "BKE_pointcache.h" - +#include "BKE_utildefines.h" #ifdef _WIN32 void tstart ( void ) diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index ffd504f5945..a77ac9b8e24 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -59,7 +59,7 @@ Collision modifier code start /* step is limited from 0 (frame start position) to 1 (frame end position) */ void collision_move_object ( CollisionModifierData *collmd, float step, float prevstep ) { - float tv[3] = {0,0,0}; + float tv[3] = {0, 0, 0}; unsigned int i = 0; for ( i = 0; i < collmd->numverts; i++ ) @@ -69,6 +69,7 @@ void collision_move_object ( CollisionModifierData *collmd, float step, float pr VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step ); VECSUB ( collmd->current_v[i].co, collmd->current_xnew[i].co, collmd->current_x[i].co ); } + bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 ); } @@ -527,7 +528,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier float magtangent = 0, repulse = 0, d = 0; double impulse = 0.0; float vrel_t_pre[3]; - float temp[3]; + float temp[3], spf; // calculate tangential velocity VECCOPY ( temp, collpair->normal ); @@ -565,10 +566,12 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier // Apply repulse impulse if distance too short // I_r = -min(dt*kd, m(0,1d/dt - v_n)) + spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; + d = clmd->coll_parms->epsilon*8.0/9.0 + epsilon2*8.0/9.0 - collpair->distance; - if ( ( magrelVel < 0.1*d*clmd->sim_parms->stepsPerFrame ) && ( d > ALMOST_ZERO ) ) + if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) { - repulse = MIN2 ( d*1.0/clmd->sim_parms->stepsPerFrame, 0.1*d*clmd->sim_parms->stepsPerFrame - magrelVel ); + repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel ); // stay on the safe side and clamp repulse if ( impulse > ALMOST_ZERO ) @@ -1541,20 +1544,15 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl overlap = BLI_bvhtree_overlap ( cloth_bvh, collmd->bvhtree, &result ); // go to next object if no overlap is there - if(!result || !overlap) - { - if ( overlap ) - MEM_freeN ( overlap ); - continue; - } - - /* check if collisions really happen (costly near check) */ - cloth_bvh_objcollisions_nearcheck ( clmd, collmd, &collisions[i], &collisions_index[i], result, overlap); - - // resolve nearby collisions - ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i], collisions_index[i]); - ret2 += ret; + if( result && overlap ) { + /* check if collisions really happen (costly near check) */ + cloth_bvh_objcollisions_nearcheck ( clmd, collmd, &collisions[i], &collisions_index[i], result, overlap); + // resolve nearby collisions + ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i], collisions_index[i]); + ret2 += ret; + } + if ( overlap ) MEM_freeN ( overlap ); } diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index c625fb28840..902965bd2f6 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -37,6 +37,10 @@ #include "BKE_global.h" #include "BKE_utildefines.h" +#include "BLI_threads.h" + +#define CLOTH_OPENMP_LIMIT 25 + #ifdef _WIN32 #include static LARGE_INTEGER _itstart, _itend; @@ -230,8 +234,11 @@ DO_INLINE float dot_lfvector(float (*fLongVectorA)[3], float (*fLongVectorB)[3], { long i = 0; float temp = 0.0; +// XXX brecht, disabled this for now (first schedule line was already disabled), +// due to non-commutative nature of floating point ops this makes the sim give +// different results each time you run it! // schedule(guided, 2) -#pragma omp parallel for reduction(+: temp) +//#pragma omp parallel for reduction(+: temp) if(verts > CLOTH_OPENMP_LIMIT) for(i = 0; i < (long)verts; i++) { temp += INPR(fLongVectorA[i], fLongVectorB[i]); @@ -577,11 +584,12 @@ DO_INLINE void mul_bfmatrix_S(fmatrix3x3 *matrix, float scalar) DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector *fLongVector) { unsigned int i = 0; - lfVector *temp = create_lfvector(from[0].vcount); + unsigned int vcount = from[0].vcount; + lfVector *temp = create_lfvector(vcount); - zero_lfvector(to, from[0].vcount); + zero_lfvector(to, vcount); -#pragma omp parallel sections private(i) +#pragma omp parallel sections private(i) if(vcount > CLOTH_OPENMP_LIMIT) { #pragma omp section { @@ -962,7 +970,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv) unsigned int i = 0; // Take only the diagonal blocks of A -// #pragma omp parallel for private(i) +// #pragma omp parallel for private(i) if(lA[0].vcount > CLOTH_OPENMP_LIMIT) for(i = 0; i 10 || j >= 10 || k >= 10) + continue; grid[i][j][k].velocity[0] += lV[v][0]; grid[i][j][k].velocity[1] += lV[v][1]; @@ -1523,6 +1533,8 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec i = HAIR_GRID_INDEX(lX[v], gmin, gmax, 0); j = HAIR_GRID_INDEX(lX[v], gmin, gmax, 1); k = HAIR_GRID_INDEX(lX[v], gmin, gmax, 2); + if (i < 0 || j < 0 || k < 0 || i > 10 || j >= 10 || k >= 10) + continue; lF[v][0] += smoothfac * (grid[i][j][k].velocity[0] - lV[v][0]); lF[v][1] += smoothfac * (grid[i][j][k].velocity[1] - lV[v][1]); @@ -1537,6 +1549,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec free_collider_cache(&colliders); } + static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, lfVector *lX, lfVector *lV, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, ListBase *effectors, float time, fmatrix3x3 *M) { /* Collect forces and derivatives: F,dFdX,dFdV */ @@ -1731,9 +1744,10 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase ClothVertex *verts = cloth->verts; unsigned int numverts = cloth->numverts; float dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame; + float spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; Implicit_Data *id = cloth->implicit; - int result = 0; - + int do_extra_solve; + if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */ { for(i = 0; i < numverts; i++) @@ -1778,60 +1792,50 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase if(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree) { - float temp = clmd->sim_parms->stepsPerFrame; - /* not too nice hack, but collisions need this correction -jahka */ - clmd->sim_parms->stepsPerFrame /= clmd->sim_parms->timescale; - // collisions // itstart(); // update verts to current positions for(i = 0; i < numverts; i++) - { + { VECCOPY(verts[i].tx, id->Xnew[i]); - + VECSUB(verts[i].tv, verts[i].tx, verts[i].txold); VECCOPY(verts[i].v, verts[i].tv); } - + // call collision function // TODO: check if "step" or "step+dt" is correct - dg - result = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale); - - // correct velocity again, just to be sure we had to change it due to adaptive collisions - for(i = 0; i < numverts; i++) - { - VECSUB(verts[i].tv, verts[i].tx, id->X[i]); - } + do_extra_solve = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale); // copy corrected positions back to simulation for(i = 0; i < numverts; i++) { - if(result) + // correct velocity again, just to be sure we had to change it due to adaptive collisions + VECSUB(verts[i].tv, verts[i].tx, id->X[i]); + + if(do_extra_solve) { if((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) continue; - + VECCOPY(id->Xnew[i], verts[i].tx); VECCOPY(id->Vnew[i], verts[i].tv); - mul_v3_fl(id->Vnew[i], clmd->sim_parms->stepsPerFrame); + mul_v3_fl(id->Vnew[i], spf); } } - /* restore original stepsPerFrame */ - clmd->sim_parms->stepsPerFrame = temp; - // X = Xnew; cp_lfvector(id->X, id->Xnew, numverts); - + // if there were collisions, advance the velocity from v_n+1/2 to v_n+1 - if(result) + if(do_extra_solve) { // V = Vnew; cp_lfvector(id->V, id->Vnew, numverts); - + // calculate cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step+dt, id->M); @@ -1851,7 +1855,6 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase cp_lfvector(id->V, id->Vnew, numverts); step += dt; - } for(i = 0; i < numverts; i++) -- cgit v1.2.3 From 1bd58bdbf4fb6e5723adea04ebb6eb5ad2918297 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 25 May 2010 17:04:32 +0000 Subject: = misc small stuff = - own mistake in scene help text. - rename properties to have users as the prefix for better ordering. - use fixed height for stamp, gives better aligned text. --- source/blender/blenkernel/intern/image.c | 49 +++++++++++++++++++------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 5588c8df161..39efd9fe72e 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -982,6 +982,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i struct StampData stamp_data; float w, h, pad; int x, y; + float h_fixed; if (!rect && !rectf) return; @@ -998,16 +999,24 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); pad= BLF_width(mono, "--"); + /* use 'h_fixed' rather then 'h', aligns better */ + // BLF_width_and_height(mono, "^|/_AgPpJjlYy", &w, &h_fixed); + { + rctf box; + BLF_boundbox(mono, "^|/_AgPpJjlYy", &box); + h_fixed= box.ymax - box.ymin; + } + x= 0; y= height; if (stamp_data.file[0]) { /* Top left corner */ - BLF_width_and_height(mono, stamp_data.file, &w, &h); + BLF_width_and_height(mono, stamp_data.file, &w, &h); h= h_fixed; y -= h; /* also a little of space to the background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, w+3, y+h+3); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, w+3, y+h+2); /* and draw the text. */ BLF_position(mono, x, y, 0.0); @@ -1019,11 +1028,11 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Top left corner, below File */ if (stamp_data.note[0]) { - BLF_width_and_height(mono, stamp_data.note, &w, &h); + BLF_width_and_height(mono, stamp_data.note, &w, &h); h= h_fixed; y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-2, w+3, y+h+2); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+2); BLF_position(mono, x, y+1, 0.0); BLF_draw_buffer(mono, stamp_data.note); @@ -1034,11 +1043,11 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Top left corner, below File (or Note) */ if (stamp_data.date[0]) { - BLF_width_and_height(mono, stamp_data.date, &w, &h); + BLF_width_and_height(mono, stamp_data.date, &w, &h); h= h_fixed; y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+2); BLF_position(mono, x, y, 0.0); BLF_draw_buffer(mono, stamp_data.date); @@ -1049,11 +1058,11 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Top left corner, below File, Date or Note */ if (stamp_data.rendertime[0]) { - BLF_width_and_height(mono, stamp_data.rendertime, &w, &h); + BLF_width_and_height(mono, stamp_data.rendertime, &w, &h); h= h_fixed; y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+2); BLF_position(mono, x, y, 0.0); BLF_draw_buffer(mono, stamp_data.rendertime); @@ -1064,10 +1073,10 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Bottom left corner, leaving space for timing */ if (stamp_data.marker[0]) { - BLF_width_and_height(mono, stamp_data.marker, &w, &h); + BLF_width_and_height(mono, stamp_data.marker, &w, &h); h= h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, w+2, y+h+3); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, w+2, y+h+2); /* and pad the text. */ BLF_position(mono, x, y+3, 0.0); @@ -1079,10 +1088,10 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Left bottom corner */ if (stamp_data.time[0]) { - BLF_width_and_height(mono, stamp_data.time, &w, &h); + BLF_width_and_height(mono, stamp_data.time, &w, &h); h= h_fixed; /* extra space for background */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2); /* and pad the text. */ BLF_position(mono, x, y+3, 0.0); @@ -1093,10 +1102,10 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i } if (stamp_data.frame[0]) { - BLF_width_and_height(mono, stamp_data.frame, &w, &h); + BLF_width_and_height(mono, stamp_data.frame, &w, &h); h= h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2); /* and pad the text. */ BLF_position(mono, x, y+3, 0.0); @@ -1107,22 +1116,22 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i } if (stamp_data.camera[0]) { - BLF_width_and_height(mono, stamp_data.camera, &w, &h); + BLF_width_and_height(mono, stamp_data.camera, &w, &h); h= h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2); BLF_position(mono, x, y+3, 0.0); BLF_draw_buffer(mono, stamp_data.camera); } if (stamp_data.scene[0]) { - BLF_width_and_height(mono, stamp_data.scene, &w, &h); + BLF_width_and_height(mono, stamp_data.scene, &w, &h); h= h_fixed; /* Bottom right corner, with an extra space because blenfont is too strict! */ x= width - w - 2; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+3, y+h+3); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+3, y+h+2); /* and pad the text. */ BLF_position(mono, x, y+3, 0.0); @@ -1130,14 +1139,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i } if (stamp_data.strip[0]) { - BLF_width_and_height(mono, stamp_data.scene, &w, &h); + BLF_width_and_height(mono, stamp_data.scene, &w, &h); h= h_fixed; /* Top right corner, with an extra space because blenfont is too strict! */ x= width - w - pad; y= height - h; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, x+w+pad, y+h+3); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, x+w+pad, y+h+2); BLF_position(mono, x, y, 0.0); BLF_draw_buffer(mono, stamp_data.strip); -- cgit v1.2.3 From f05e79c2ae77f8ec0e3270fdb5ab9871f9726f5e Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 27 May 2010 04:54:53 +0000 Subject: Warning fixes --- source/blender/blenkernel/intern/anim.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 1c86bd57e2e..82168fddd8f 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -52,6 +52,7 @@ #include "BKE_anim.h" #include "BKE_curve.h" #include "BKE_DerivedMesh.h" +#include "BKE_depsgraph.h" #include "BKE_font.h" #include "BKE_group.h" #include "BKE_global.h" -- cgit v1.2.3 From 6e92ddf8b37dbfae733a9738a20777917610b4a0 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 27 May 2010 08:22:16 +0000 Subject: Progress indicators for threaded jobs Now, rather than the bit-too-alarming stop sign, threaded wmJobs display a progress indicator in the header. This is an optional feature for each job type and still uses the same hardcoded ui template (could use further work here...). Currently implemented for: Render - parts completed, then nodes comped Compositor - nodes comped Fluid Sim - frames simulated Texture Bake - faces baked Example: http://mke3.net/blender/devel/2.5/progress.mov --- source/blender/blenkernel/intern/node.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 3d49548cba7..13ea55ebf0f 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2434,7 +2434,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) bNode *node; ListBase threads; ThreadData thdata; - int totnode, rendering= 1; + int totnode, curnode, rendering= 1; if(ntree==NULL) return; @@ -2455,7 +2455,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) BLI_srandom(rd->cfra); /* sets need_exec tags in nodes */ - totnode= setExecutableNodes(ntree, &thdata); + curnode = totnode= setExecutableNodes(ntree, &thdata); BLI_init_threads(&threads, exec_composite_node, rd->threads); @@ -2465,14 +2465,14 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) node= getExecutableNode(ntree); if(node) { - if(ntree->timecursor) - ntree->timecursor(ntree->tch, totnode); + if(ntree->progress) + ntree->progress(ntree->prh, (1.0 - curnode/(float)totnode)); if(ntree->stats_draw) { char str[64]; - sprintf(str, "Compositing %d %s", totnode, node->name); + sprintf(str, "Compositing %d %s", curnode, node->name); ntree->stats_draw(ntree->sdh, str); } - totnode--; + curnode--; node->threaddata = &thdata; node->exec= NODE_PROCESSING; -- cgit v1.2.3 From e4530c47f04556bb0387eebc7acf0652eedde342 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 27 May 2010 08:34:32 +0000 Subject: Logic Editor: fix for datablock counting when copying/deleting sound actuator ("bug" from 2.49) --- source/blender/blenkernel/intern/sca.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 5a06c251b88..3102d4b054b 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -44,6 +44,7 @@ #include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_library.h" /* ******************* SENSORS ************************ */ @@ -348,7 +349,19 @@ void unlink_actuators(ListBase *lb) void free_actuator(bActuator *act) { - if(act->data) MEM_freeN(act->data); + bSoundActuator *sa; + + if(act->data) { + switch (act->type) { + case ACT_SOUND: + sa = (bSoundActuator *) act->data; + if(sa->sound) + id_us_min((ID *) sa->sound); + break; + } + + MEM_freeN(act->data); + } MEM_freeN(act); } @@ -365,6 +378,7 @@ void free_actuators(ListBase *lb) bActuator *copy_actuator(bActuator *act) { bActuator *actn; + bSoundActuator *sa; act->mynew=actn= MEM_dupallocN(act); actn->flag |= ACT_NEW; @@ -372,6 +386,13 @@ bActuator *copy_actuator(bActuator *act) actn->data= MEM_dupallocN(act->data); } + switch (act->type) { + case ACT_SOUND: + sa= (bSoundActuator *)act->data; + if(sa->sound) + id_us_plus((ID *) sa->sound); + break; + } return actn; } -- cgit v1.2.3 From 135f8be2c7933bb06b817ae204f867aff96040cc Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 27 May 2010 08:42:59 +0000 Subject: Small bug fix: The array of string names for CD layers was missing a few. Added them back and organized a bit for clarity. --- source/blender/blenkernel/intern/customdata.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 69327eccfaf..361e6f3fd22 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -798,10 +798,12 @@ const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { }; 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", "CDClothOrco"}; + /* 0-4 */ "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace", + /* 5-9 */ "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags", + /* 10-14 */ "CDMFloatProperty", "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco", + /* 15-19 */ "CDMTexPoly", "CDMLoopUV", "CDMloopCol", "CDTangent", "CDMDisps", + /* 20-23 */"CDWeightMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco" +}; const CustomDataMask CD_MASK_BAREMESH = CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE; -- cgit v1.2.3 From 4ebc634168e0349c07c74fdf61defaad05db70f9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 27 May 2010 10:50:06 +0000 Subject: == Pivot Constraint == This constraint allows an object or bone to have their rotations applied as if their origin/pivot-point was located elsewhere. The most obvious uses include foot-roll, see-saws, but could also include more complicated rolling-box examples. == Usage Examples == === Foot Roll === 1. Add 'Pivot' Constraint to the bone without any target. 2. Set the 'Y' value of the offset to the length of the bone. Usually this should be negative (if you rig with feet facing 'forwards' along -Y axis). This gives you a pivot point relative to the bone's (preconstraint) location, which should be at the tip of the bone here. Disabling the 'Use Relative Offset' would make this offset be relative to 0,0,0 instead of to the owner/bone-head. 3. Ensure that the 'Pivot When' setting is set to '-X Rot', (default) which means that the pivot will only used when the rotation on the X-Axis is negative to get tip-toe 'roll'. === See Saw === 1. Add a 'Pivot' constraint too see-saw plank object, this time with a target that you wish to have as the pivot-point. It's possible to do this without too (as before), but is less intuitive. 2. Optionally, if you want the plank slightly raised, set the z-offset value, which should make the pivot-point used to be relative to the target with the z-offset applied. 3. Ensure that 'Pivot When' is set to 'Always', which means that the pivot will always be used, irrespective of the rotation. == Notes == * The 'Pivot When' setting has been integrated in the constraint, since this is something that will often be required for these setups. Having to set up additional drivers to drive the constraint to do this kindof beats the purpose of providing this. * The 'Offset' functionality is probably not presented as clearly as it could be. We may need to go over this again. * For foot-roll - if any scaling of the foot is required, simply set up a driver on the y-offset to make this dynamically respond to the "scale" RNA property of the bones (don't use the "Transform Channel" vartype since that won't work correct here). However, this shouldn't be common enough to warrant special treatment. --- source/blender/blenkernel/intern/constraint.c | 113 ++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index a3f1cb0cb0c..1a8d665a91d 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3831,6 +3831,118 @@ static bConstraintTypeInfo CTI_SPLINEIK = { NULL /* evaluate - solved as separate loop */ }; +/* ----------- Pivot ------------- */ + +static void pivotcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +{ + bPivotConstraint *data= con->data; + + /* target only */ + func(con, (ID**)&data->tar, userdata); +} + +static int pivotcon_get_tars (bConstraint *con, ListBase *list) +{ + if (con && list) { + bPivotConstraint *data= con->data; + bConstraintTarget *ct; + + /* standard target-getting macro for single-target constraints */ + SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list) + + return 1; + } + + return 0; +} + +static void pivotcon_flush_tars (bConstraint *con, ListBase *list, short nocopy) +{ + if (con && list) { + bPivotConstraint *data= con->data; + bConstraintTarget *ct= list->first; + + /* the following macro is used for all standard single-target constraints */ + SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) + } +} + +static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +{ + bPivotConstraint *data= con->data; + bConstraintTarget *ct= targets->first; + + float pivot[3], vec[3]; + float rotMat[3][3]; + + /* firstly, check if pivoting should take place based on the current rotation */ + if (data->rotAxis != PIVOTCON_AXIS_NONE) { + float rot[3]; + + /* extract euler-rotation of target */ + mat4_to_eulO(rot, cob->rotOrder, cob->matrix); + + /* check which range might be violated */ + if (data->rotAxis < PIVOTCON_AXIS_X) { + /* negative rotations (data->rotAxis = 0 -> 2) */ + if (rot[data->rotAxis] > 0.0f) + return; + } + else { + /* positive rotations (data->rotAxis = 3 -> 5 */ + if (rot[data->rotAxis - PIVOTCON_AXIS_X] < 0.0f) + return; + } + } + + /* find the pivot-point to use */ + if (VALID_CONS_TARGET(ct)) { + /* apply offset to target location */ + add_v3_v3v3(pivot, ct->matrix[3], data->offset); + } + else { + /* no targets to worry about... */ + if ((data->flag & PIVOTCON_FLAG_OFFSET_ABS) == 0) { + /* offset is relative to owner */ + add_v3_v3v3(pivot, cob->matrix[3], data->offset); + } + else { + /* directly use the 'offset' specified as an absolute position instead */ + VECCOPY(pivot, data->offset); + } + } + + /* get rotation matrix representing the rotation of the owner */ + // TODO: perhaps we might want to include scaling based on the pivot too? + copy_m3_m4(rotMat, cob->matrix); + normalize_m3(rotMat); + + /* perform the pivoting... */ + /* 1. take the vector from owner to the pivot */ + sub_v3_v3v3(vec, pivot, cob->matrix[3]); + /* 2. rotate this vector by the rotation of the object... */ + mul_m3_v3(rotMat, vec); + /* 3. make the rotation in terms of the pivot now */ + add_v3_v3v3(cob->matrix[3], pivot, vec); +} + + +static bConstraintTypeInfo CTI_PIVOT = { + CONSTRAINT_TYPE_PIVOT, /* type */ + sizeof(bPivotConstraint), /* size */ + "Pivot", /* name */ + "bPivotConstraint", /* struct name */ + NULL, /* free data */ + NULL, /* relink data */ + pivotcon_id_looper, /* id looper */ + NULL, /* copy data */ + NULL, /* new data */ // XXX: might be needed to get 'normal' pivot behaviour... + pivotcon_get_tars, /* get constraint targets */ + pivotcon_flush_tars, /* flush constraint targets */ + default_get_tarmat, /* get target matrix */ + pivotcon_evaluate /* evaluate */ +}; + /* ************************* Constraints Type-Info *************************** */ /* All of the constraints api functions use bConstraintTypeInfo structs to carry out * and operations that involve constraint specific code. @@ -3867,6 +3979,7 @@ static void constraints_init_typeinfo () { constraintsTypeInfo[22]= &CTI_SPLINEIK; /* Spline IK Constraint */ constraintsTypeInfo[23]= &CTI_TRANSLIKE; /* Copy Transforms Constraint */ constraintsTypeInfo[24]= &CTI_SAMEVOL; /* Maintain Volume Constraint */ + constraintsTypeInfo[25]= &CTI_PIVOT; /* Pivot Constraint */ } /* This function should be used for getting the appropriate type-info when only -- cgit v1.2.3 From 5d6bdd7c2ea0413b707dd08d3b3b67154ccd9a55 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 27 May 2010 11:56:31 +0000 Subject: Various constraint code cleanups: 1) Fixed some weird formatting introduced during math-lib cleanups, and some other inconsistencies 2) Optimised the Maintain Volume constraint by taking the value calculations out Copy All Constraints Operators: * Added one for bones too * These are now included in the menus * Removed some weird/extra code copying/changing/bleh the actcol/totcol stuff... --- source/blender/blenkernel/intern/constraint.c | 106 +++++++++++++------------- 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 1a8d665a91d..171276d118e 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -820,12 +820,12 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* extract components of both matrices */ VECCOPY(loc, ct->matrix[3]); - mat4_to_eulO( eul, ct->rotOrder,ct->matrix); - mat4_to_size( size,ct->matrix); + mat4_to_eulO(eul, ct->rotOrder, ct->matrix); + mat4_to_size(size, ct->matrix); VECCOPY(loco, invmat[3]); - mat4_to_eulO( eulo, cob->rotOrder,invmat); - mat4_to_size( sizo,invmat); + mat4_to_eulO(eulo, cob->rotOrder, invmat); + mat4_to_size(sizo, invmat); /* disable channels not enabled */ if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f; @@ -1017,7 +1017,7 @@ static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float tmat[4][4]; /* Get size property, since ob->size is only the object's own relative size, not its global one */ - mat4_to_size( size,cob->matrix); + mat4_to_size(size, cob->matrix); /* Clear the object's rotation */ cob->matrix[0][0]=size[0]; @@ -1385,9 +1385,9 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t float size[3]; VECCOPY(loc, cob->matrix[3]); - mat4_to_size( size,cob->matrix); + mat4_to_size(size, cob->matrix); - mat4_to_eulO( eul, cob->rotOrder,cob->matrix); + mat4_to_eulO(eul, cob->rotOrder, cob->matrix); /* constraint data uses radians internally */ @@ -1638,11 +1638,11 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float size[3]; VECCOPY(loc, cob->matrix[3]); - mat4_to_size( size,cob->matrix); + mat4_to_size(size, cob->matrix); /* to allow compatible rotations, must get both rotations in the order of the owner... */ - mat4_to_eulO( eul, cob->rotOrder,ct->matrix); - mat4_to_eulO( obeul, cob->rotOrder,cob->matrix); + mat4_to_eulO(eul, cob->rotOrder, ct->matrix); + mat4_to_eulO(obeul, cob->rotOrder, cob->matrix); if ((data->flag & ROTLIKE_X)==0) eul[0] = obeul[0]; @@ -1868,29 +1868,29 @@ static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob, ListBase { bSameVolumeConstraint *data= con->data; + float volume = data->volume; + float fac = 1.0f; float obsize[3]; - float volume=data->volume; mat4_to_size(obsize, cob->matrix); - + + /* calculate normalising scale factor for non-essential values */ + if (obsize[data->flag] != 0) + fac = sqrt(volume / obsize[data->flag]) / obsize[data->flag]; + + /* apply scaling factor to the channels not being kept */ switch (data->flag) { case SAMEVOL_X: - if (obsize[0]!=0) { - mul_v3_fl(cob->matrix[1], sqrt(volume/obsize[0])/obsize[0]); - mul_v3_fl(cob->matrix[2], sqrt(volume/obsize[0])/obsize[0]); - } + mul_v3_fl(cob->matrix[1], fac); + mul_v3_fl(cob->matrix[2], fac); break; case SAMEVOL_Y: - if (obsize[1]!=0) { - mul_v3_fl(cob->matrix[0], sqrt(volume/obsize[1])/obsize[1]); - mul_v3_fl(cob->matrix[2], sqrt(volume/obsize[1])/obsize[1]); - } + mul_v3_fl(cob->matrix[0], fac); + mul_v3_fl(cob->matrix[2], fac); break; case SAMEVOL_Z: - if (obsize[2]!=0) { - mul_v3_fl(cob->matrix[0], sqrt(volume/obsize[2])/obsize[2]); - mul_v3_fl(cob->matrix[1], sqrt(volume/obsize[2])/obsize[2]); - } + mul_v3_fl(cob->matrix[0], fac); + mul_v3_fl(cob->matrix[1], fac); break; } } @@ -2770,7 +2770,7 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * float dist; /* store scaling before destroying obmat */ - mat4_to_size( size,cob->matrix); + mat4_to_size(size, cob->matrix); /* store X orientation before destroying obmat */ xx[0] = cob->matrix[0][0]; @@ -3353,7 +3353,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * mat4_to_size( dvec,ct->matrix); break; case 1: /* rotation (convert to degrees first) */ - mat4_to_eulO( dvec, cob->rotOrder,ct->matrix); + mat4_to_eulO(dvec, cob->rotOrder, ct->matrix); for (i=0; i<3; i++) dvec[i] = (float)(dvec[i] / M_PI * 180); break; @@ -3364,8 +3364,8 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* extract components of owner's matrix */ VECCOPY(loc, cob->matrix[3]); - mat4_to_eulO( eul, cob->rotOrder,cob->matrix); - mat4_to_size( size,cob->matrix); + mat4_to_eulO(eul, cob->rotOrder, cob->matrix); + mat4_to_size(size, cob->matrix); /* determine where in range current transforms lie */ if (data->expo) { @@ -3485,73 +3485,73 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr float co[3] = {0.0f, 0.0f, 0.0f}; float no[3] = {0.0f, 0.0f, 0.0f}; float dist; - + SpaceTransform transform; DerivedMesh *target = object_get_derived_final(cob->scene, ct->tar, CD_MASK_BAREMESH); BVHTreeRayHit hit; BVHTreeNearest nearest; - + BVHTreeFromMesh treeData; - memset( &treeData, 0, sizeof(treeData) ); - + memset(&treeData, 0, sizeof(treeData)); + nearest.index = -1; nearest.dist = FLT_MAX; - + hit.index = -1; hit.dist = 100000.0f; //TODO should use FLT_MAX.. but normal projection doenst yet supports it - + unit_m4(ct->matrix); - + if(target != NULL) { space_transform_from_matrixs(&transform, cob->matrix, ct->tar->obmat); - + switch(scon->shrinkType) { case MOD_SHRINKWRAP_NEAREST_SURFACE: case MOD_SHRINKWRAP_NEAREST_VERTEX: - + if(scon->shrinkType == MOD_SHRINKWRAP_NEAREST_VERTEX) bvhtree_from_mesh_verts(&treeData, target, 0.0, 2, 6); else bvhtree_from_mesh_faces(&treeData, target, 0.0, 2, 6); - + if(treeData.tree == NULL) { fail = TRUE; break; } - + space_transform_apply(&transform, co); - + BLI_bvhtree_find_nearest(treeData.tree, co, &nearest, treeData.nearest_callback, &treeData); dist = len_v3v3(co, nearest.co); interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */ space_transform_invert(&transform, co); break; - + case MOD_SHRINKWRAP_PROJECT: if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) no[0] = 1.0f; if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) no[1] = 1.0f; if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) no[2] = 1.0f; - + if(INPR(no,no) < FLT_EPSILON) { fail = TRUE; break; } - + normalize_v3(no); - - + + bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6); if(treeData.tree == NULL) { fail = TRUE; break; } - + if(normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE) { fail = TRUE; @@ -3560,17 +3560,17 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr VECCOPY(co, hit.co); break; } - + free_bvhtree_from_mesh(&treeData); - + target->release(target); - + if(fail == TRUE) { /* Don't move the point */ co[0] = co[1] = co[2] = 0.0f; } - + /* co is in local object coordinates, change it to global and update target position */ mul_m4_v3(cob->matrix, co); VECCOPY(ct->matrix[3], co); @@ -3704,7 +3704,7 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* construct rotation matrix from the axis-angle rotation found above * - this call takes care to make sure that the axis provided is a unit vector first */ - axis_angle_to_mat3( rmat,raxis, rangle); + axis_angle_to_mat3(rmat, raxis, rangle); /* rotate the owner in the way defined by this rotation matrix, then reapply the location since * we may have destroyed that in the process of multiplying the matrix @@ -4262,9 +4262,9 @@ void copy_constraints (ListBase *dst, const ListBase *src, int do_extern) /* perform custom copying operations if needed */ if (cti->copy_data) cti->copy_data(con, srccon); - + /* for proxies we dont want to make extern */ - if(do_extern) { + if (do_extern) { /* go over used ID-links for this constraint to ensure that they are valid for proxies */ if (cti->id_looper) cti->id_looper(con, con_extern_cb, NULL); -- cgit v1.2.3 From 717701ed0f785f6452c37f412f43e08382694bc2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 27 May 2010 14:00:32 +0000 Subject: Fix #22422: Adding a new shape key with unchecked 'Relative' checkbox crashes blender Reorder callning of add_keyblock and do_ob_key in insert_*key. do_ob_key shouldn't be called for object with uninitialized key blocks. NOTE: this commit not fixing problems with slurph --- source/blender/blenkernel/intern/object.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 24c23e5ea41..576b3481d07 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2879,15 +2879,18 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, char *name, int from_m newkey= 1; } - kb= add_keyblock(key, name); - if(newkey || from_mix==FALSE) { /* create from mesh */ + kb= add_keyblock(key, name); mesh_to_key(me, kb); } else { /* copy from current values */ - kb->data= do_ob_key(scene, ob); + float *data= do_ob_key(scene, ob); + + /* create new block with prepared data */ + kb= add_keyblock(key, name); + kb->data= data; kb->totelem= me->totvert; } @@ -2907,16 +2910,20 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, char *name, int from_m newkey= 1; } - kb= add_keyblock(key, name); - if(newkey || from_mix==FALSE) { + kb= add_keyblock(key, name); + /* create from lattice */ latt_to_key(lt, kb); } else { /* copy from current values */ + float *data= do_ob_key(scene, ob); + + /* create new block with prepared data */ + kb= add_keyblock(key, name); kb->totelem= lt->pntsu*lt->pntsv*lt->pntsw; - kb->data= do_ob_key(scene, ob); + kb->data= data; } return kb; @@ -2936,16 +2943,19 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_ newkey= 1; } - kb= add_keyblock(key, name); - if(newkey || from_mix==FALSE) { /* create from curve */ + kb= add_keyblock(key, name); curve_to_key(cu, kb, lb); } else { /* copy from current values */ + float *data= do_ob_key(scene, ob); + + /* create new block with prepared data */ + kb= add_keyblock(key, name); kb->totelem= count_curveverts(lb); - kb->data= do_ob_key(scene, ob); + kb->data= data; } return kb; -- cgit v1.2.3 From a6689154047b4a838276170f48bd39372149af71 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 30 May 2010 14:05:24 +0000 Subject: Fix #22446: "Delayed" modifier preview with linked curves Since curve objects could have constructive modifiers, we can't always avoid setting OB_RECALC_DATA to linked objects (displist recalculation wouldn't enough for curves with such modifiers) --- source/blender/blenkernel/intern/depsgraph.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 0568050950f..bdeacdf6946 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2286,11 +2286,7 @@ void DAG_id_flush_update(ID *id, short flag) /* no point in trying in this cases */ if(!id || id->us <= 1) id= NULL; - /* curves and surfaces only need to mark one object, since - otherwise cu->displist would be computed multiple times */ - else if(ob->type==OB_CURVE || ob->type==OB_SURF) - id= NULL; - /* also for locked shape keys we make an exception */ + /* for locked shape keys we make an exception */ else if(ob_get_key(ob) && (ob->shapeflag & OB_SHAPE_LOCK)) id= NULL; } @@ -2301,15 +2297,23 @@ void DAG_id_flush_update(ID *id, short flag) idtype= GS(id->name); if(ELEM7(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR)) { + int first_ob= 1; for(obt=bmain->object.first; obt; obt= obt->id.next) { if(!(ob && obt == ob) && obt->data == id) { + + /* try to avoid displist recalculation for linked curves */ + if (!first_ob && ELEM(obt->type, OB_CURVE, OB_SURF)) { + /* if curve object has got derivedFinal it means this + object has got constructive modifiers and object + should be recalculated anyhow */ + if (!obt->derivedFinal) + continue; + } + obt->recalc |= OB_RECALC_DATA; BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); - /* for these we only flag one object, otherwise cu->displist - would be computed multiple times */ - if(obt->type==OB_CURVE || obt->type==OB_SURF) - break; + first_ob= 0; } } } -- cgit v1.2.3 From 1658a28a58ebd5fe58ab33875b10aaabb3458b79 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 30 May 2010 14:05:58 +0000 Subject: - Python console argument '--python-console', option so you can start blender and drop into a python console, (useful for debugging some problems on a renderfarm over ssh) - Also made it so sys.stdin isnt overwritten anymore, instead the interactive consoel overwrites while it executes and restores after. - removed hope folder from sphinx patch path --- source/blender/blenkernel/intern/fcurve.c | 2 +- source/blender/blenkernel/intern/fmodifier.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 619bb1a58f9..43f01199b69 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1418,7 +1418,7 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime) /* this evaluates the expression using Python,and returns its result: * - on errors it reports, then returns 0.0f */ - driver->curval= BPY_pydriver_eval(driver); + driver->curval= BPY_eval_driver(driver); } #endif /* DISABLE_PYTHON*/ } diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 868b06f2348..6fcc49f9ec1 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -44,7 +44,7 @@ #include "BKE_utildefines.h" #ifndef DISABLE_PYTHON -#include "BPY_extern.h" /* for BPY_pydriver_eval() */ +#include "BPY_extern.h" /* for BPY_eval_driver() */ #endif #define SMALL -1.0e-10 -- cgit v1.2.3 From f8ecc3fd2fd11a40f5cea3a23b3c83b9861762cc Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 30 May 2010 14:53:26 +0000 Subject: Some cleanup of particle path drawing logic: * Path drawing now works for non hair particles. * Should fix the following bugs too: [#21316] Hair weight drawing is wrong [#21923] Consistent Crash When Rendering Particle Scene. [#21950] Path rendering option for particles causes crash --- source/blender/blenkernel/BKE_particle.h | 2 + source/blender/blenkernel/intern/particle.c | 91 +++++++++++++++++----- source/blender/blenkernel/intern/particle_system.c | 90 ++++++--------------- 3 files changed, 95 insertions(+), 88 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index fcef00ae9b3..33a41821fe2 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -255,9 +255,11 @@ void psys_threads_free(ParticleThread *threads); void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]); /* particle_system.c */ +void psys_update_path_cache(struct ParticleSimulationData *sim, float cfra); struct ParticleSystem *psys_get_target_system(struct Object *ob, struct ParticleTarget *pt); void psys_count_keyed_targets(struct ParticleSimulationData *sim); void psys_update_particle_tree(struct ParticleSystem *psys, float cfra); +void psys_update_children(struct ParticleSimulationData *sim); void psys_make_temp_pointcache(struct Object *ob, struct ParticleSystem *psys); void psys_get_pointcache_start_end(struct Scene *scene, ParticleSystem *psys, int *sfra, int *efra); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index fffbd31aa02..0c55cc2aaac 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -433,7 +433,7 @@ void free_keyed_keys(ParticleSystem *psys) } } } -static void free_child_path_cache(ParticleSystem *psys) +void psys_free_child_path_cache(ParticleSystem *psys) { psys_free_path_cache_buffers(psys->childcache, &psys->childcachebufs); psys->childcache = NULL; @@ -451,7 +451,7 @@ void psys_free_path_cache(ParticleSystem *psys, PTCacheEdit *edit) psys->pathcache= NULL; psys->totcached= 0; - free_child_path_cache(psys); + psys_free_child_path_cache(psys); } } void psys_free_children(ParticleSystem *psys) @@ -462,7 +462,7 @@ void psys_free_children(ParticleSystem *psys) psys->totchild=0; } - free_child_path_cache(psys); + psys_free_child_path_cache(psys); } void psys_free_particles(ParticleSystem *psys) { @@ -1037,6 +1037,7 @@ typedef struct ParticleInterpolationData { ParticleKey *kkey[2]; PointCache *cache; + PTCacheMem *pm; PTCacheEditPoint *epoint; PTCacheEditKey *ekey[2]; @@ -1045,31 +1046,74 @@ typedef struct ParticleInterpolationData { int bspline; } ParticleInterpolationData; /* Assumes pointcache->mem_cache exists, so for disk cached particles call psys_make_temp_pointcache() before use */ -static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, int index, float t, ParticleKey *key1, ParticleKey *key2) +/* It uses ParticleInterpolationData->pm to store the current memory cache frame so it's thread safe. */ +static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2) { - static PTCacheMem *pm = NULL; /* not thread safe */ + static PTCacheMem *pm = NULL; if(index < 0) { /* initialize */ - pm = cache->mem_cache.first; + *cur = cache->mem_cache.first; - if(pm) - pm = pm->next; + if(*cur) + *cur = (*cur)->next; } else { - if(pm) { - while(pm && pm->next && (float)pm->frame < t) - pm = pm->next; + if(*cur) { + while(*cur && (*cur)->next && (float)(*cur)->frame < t) + *cur = (*cur)->next; + + pm = *cur; BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame); - BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame); + if(pm->prev->index_array && pm->prev->index_array[index] == 0) + copy_particle_key(key1, key2, 1); + else + BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame); } else if(cache->mem_cache.first) { - PTCacheMem *pm2 = cache->mem_cache.first; - BKE_ptcache_make_particle_key(key2, pm2->index_array ? pm2->index_array[index] - 1 : index, pm2->data, (float)pm2->frame); + pm = cache->mem_cache.first; + BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame); copy_particle_key(key1, key2, 1); } } } +static int get_pointcache_times_for_particle(PointCache *cache, int index, float *start, float *end) +{ + PTCacheMem *pm; + int ret = 0; + + for(pm=cache->mem_cache.first; pm; pm=pm->next) { + if(pm->index_array) { + if(pm->index_array[index]) { + *start = pm->frame; + ret++; + break; + } + } + else { + *start = pm->frame; + ret++; + break; + } + } + + for(pm=cache->mem_cache.last; pm; pm=pm->prev) { + if(pm->index_array) { + if(pm->index_array[index]) { + *end = pm->frame; + ret++; + break; + } + } + else { + *end = pm->frame; + ret++; + break; + } + } + + return ret == 2; +} static void init_particle_interpolation(Object *ob, ParticleSystem *psys, ParticleData *pa, ParticleInterpolationData *pind) { @@ -1091,10 +1135,15 @@ static void init_particle_interpolation(Object *ob, ParticleSystem *psys, Partic pind->dietime = (key + pa->totkey - 1)->time; } else if(pind->cache) { - get_pointcache_keys_for_time(ob, pind->cache, -1, 0.0f, NULL, NULL); - + float start, end; + get_pointcache_keys_for_time(ob, pind->cache, &pind->pm, -1, 0.0f, NULL, NULL); pind->birthtime = pa ? pa->time : pind->cache->startframe; pind->dietime = pa ? pa->dietime : pind->cache->endframe; + + if(get_pointcache_times_for_particle(pind->cache, pa - psys->particles, &start, &end)) { + pind->birthtime = MAX2(pind->birthtime, start); + pind->dietime = MIN2(pind->dietime, end); + } } else { HairKey *key = pa->hair; @@ -1224,7 +1273,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData memcpy(keys + 2, pind->kkey[1], sizeof(ParticleKey)); } else if(pind->cache) { - get_pointcache_keys_for_time(NULL, pind->cache, p, real_t, keys+1, keys+2); + get_pointcache_keys_for_time(NULL, pind->cache, &pind->pm, p, real_t, keys+1, keys+2); } else { hair_to_particle(keys + 1, pind->hkey[0]); @@ -2672,7 +2721,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd } else { /* clear out old and create new empty path cache */ - free_child_path_cache(sim->psys); + psys_free_child_path_cache(sim->psys); sim->psys->childcache= psys_alloc_path_cache_buffers(&sim->psys->childcachebufs, totchild, ctx->steps+1); sim->psys->totchildcache = totchild; } @@ -2743,7 +2792,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) int keyed, baked; /* we don't have anything valid to create paths from so let's quit here */ - if((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED)==0) + if((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache)==0) return; if(psys_in_edit_mode(sim->scene, psys)) @@ -2753,7 +2802,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) BLI_srandom(psys->seed); keyed = psys->flag & PSYS_KEYED; - baked = !hair_dm && psys->pointcache->flag & PTCACHE_BAKED; + baked = !hair_dm && psys->pointcache->mem_cache.first; /* clear out old and create new empty path cache */ psys_free_path_cache(psys, psys->edit); @@ -3148,7 +3197,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf edit->totcached = totpart; - if(psys && psys->part->type == PART_HAIR) { + if(psys) { ParticleSimulationData sim = {scene, ob, psys, psys_get_modifier(ob, psys), NULL}; psys_cache_child_paths(&sim, cfra, 1); } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 25328a06328..ce84ee96d01 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3075,66 +3075,18 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* Hair */ /************************************************/ /* check if path cache or children need updating and do it if needed */ -static void psys_update_path_cache(ParticleSimulationData *sim, float cfra) +void psys_update_path_cache(ParticleSimulationData *sim, float cfra) { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; - ParticleEditSettings *pset = &sim->scene->toolsettings->particle; - int distr=0, alloc=0, skip=0; - - if((psys->part->childtype && psys->totchild != get_psys_tot_child(sim->scene, psys)) || psys->recalc&PSYS_RECALC_RESET) - alloc=1; - - if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT))) - distr=1; - - if(distr){ - if(alloc) - realloc_particles(sim, sim->psys->totpart); - - if(get_psys_tot_child(sim->scene, psys)) { - /* don't generate children while computing the hair keys */ - if(!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) { - distribute_particles(sim, PART_FROM_CHILD); - - if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES && part->parents!=0.0) - psys_find_parents(sim); - } - } - else - psys_free_children(psys); - } - - if((part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED)==0) - skip = 1; /* only hair, keyed and baked stuff can have paths */ - else if(part->ren_as != PART_DRAW_PATH && !(part->type==PART_HAIR && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR))) - skip = 1; /* particle visualization must be set as path */ - else if(!psys->renderdata) { - if(part->draw_as != PART_DRAW_REND) - skip = 1; /* draw visualization */ - else if(psys->pointcache->flag & PTCACHE_BAKING) - skip = 1; /* no need to cache paths while baking dynamics */ - else if(psys_in_edit_mode(sim->scene, psys)) { - if((pset->flag & PE_DRAW_PART)==0) - skip = 1; - else if(part->childtype==0 && (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED)==0) - skip = 1; /* in edit mode paths are needed for child particles and dynamic hair */ - } - } - - if(!skip) { + + /* only hair, keyed and baked stuff can have paths */ + if(part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->mem_cache.first) { psys_cache_paths(sim, cfra); /* for render, child particle paths are computed on the fly */ - if(part->childtype) { - if(!psys->totchild) - skip = 1; - else if((psys->part->type == PART_HAIR && psys->flag & PSYS_HAIR_DONE)==0) - skip = 1; - - if(!skip) - psys_cache_child_paths(sim, cfra, 0); - } + if(part->childtype && psys->totchild) + psys_cache_child_paths(sim, cfra, 0); } else if(psys->pathcache) psys_free_path_cache(psys, NULL); @@ -3249,6 +3201,8 @@ static void do_hair_dynamics(ParticleSimulationData *sim) psys->hair_out_dm = clothModifier_do(psys->clmd, sim->scene, sim->ob, dm, 0, 0); psys->clmd->sim_parms->effector_weights = NULL; + + psys_free_path_cache(psys, NULL); } static void hair_step(ParticleSimulationData *sim, float cfra) { @@ -3278,10 +3232,6 @@ static void hair_step(ParticleSimulationData *sim, float cfra) if(psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) do_hair_dynamics(sim); - psys_update_effectors(sim); - - psys_update_path_cache(sim, cfra); - psys->flag |= PSYS_HAIR_UPDATED; } @@ -3500,14 +3450,19 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) } free_collider_cache(&sim->colliders); + + if(psys->pathcache) + psys_free_path_cache(psys, NULL); } -static void update_children(ParticleSimulationData *sim) +void psys_update_children(ParticleSimulationData *sim) { if((sim->psys->part->type == PART_HAIR) && (sim->psys->flag & PSYS_HAIR_DONE)==0) /* don't generate children while growing hair - waste of time */ psys_free_children(sim->psys); - else if(sim->psys->part->childtype && sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys)) - distribute_particles(sim, PART_FROM_CHILD); + else if(sim->psys->part->childtype) { + if(sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys)) + distribute_particles(sim, PART_FROM_CHILD); + } else psys_free_children(sim->psys); } @@ -3762,8 +3717,6 @@ static void system_step(ParticleSimulationData *sim, float cfra) if(ELEM(cache_result, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED)) { cached_step(sim, cfra); - update_children(sim); - psys_update_path_cache(sim, cfra); BKE_ptcache_validate(cache, framenr); @@ -3827,9 +3780,6 @@ static void system_step(ParticleSimulationData *sim, float cfra) BKE_ptcache_write_cache(use_cache, framenr); } - if(init) - update_children(sim); - /* cleanup */ if(psys->lattice){ end_latt_deform(psys->lattice); @@ -3992,6 +3942,13 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) /* execute drivers only, as animation has already been done */ BKE_animsys_evaluate_animdata(&part->id, part->adt, cfra, ADT_RECALC_DRIVERS); + /* TODO: only free child paths in case of PSYS_RECALC_CHILD */ + if(psys->recalc & PSYS_RECALC) + psys_free_path_cache(psys, NULL); + + if(psys->recalc & PSYS_RECALC_CHILD) + psys_free_children(psys); + if(psys->recalc & PSYS_RECALC_TYPE) psys_changed_type(&sim); else if(psys->recalc & PSYS_RECALC_PHYS) @@ -4048,7 +4005,6 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if(part->phystype == PART_PHYS_KEYED) { psys_count_keyed_targets(&sim); set_keyed_keys(&sim); - psys_update_path_cache(&sim,(int)cfra); } break; } -- cgit v1.2.3 From 0882438832bb9a3d9a3b4b8341a6095b2357d5bc Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 30 May 2010 16:09:16 +0000 Subject: Disable using own emitter object (self) as dupliobject/group for particles, fixes bugs: [#21994] hair particle system with dupli object set to particle system object itself results in 100% cpu usage [#22023] [Rev 28117]Can't bake particles? [#22065] in a particle system, setting the emitter as the dupli object crashes blender after pressing alt+a to animate --- source/blender/blenkernel/intern/anim.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 82168fddd8f..20afc715c77 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1188,11 +1188,21 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p BLI_srandom(31415926 + psys->seed); lay= scene->lay; - if((psys->renderdata || part->draw_as==PART_DRAW_REND) && - ((part->ren_as == PART_DRAW_OB && part->dup_ob) || - (part->ren_as == PART_DRAW_GR && part->dup_group && part->dup_group->gobject.first))) { + if((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { - psys_check_group_weights(part); + /* first check for loops (particle system object used as dupli object) */ + if(part->ren_as == PART_DRAW_OB) { + if(ELEM(part->dup_ob, NULL, par)) + return; + } + else { /*PART_DRAW_GR */ + if(part->dup_group == NULL || part->dup_group->gobject.first == NULL) + return; + + for(go=part->dup_group->gobject.first; go; go=go->next) + if(go->ob == par) + return; + } /* if we have a hair particle system, use the path cache */ if(part->type == PART_HAIR) { @@ -1206,6 +1216,8 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p totpart = psys->totcached; } + psys_check_group_weights(part); + psys->lattice = psys_get_lattice(&sim); /* gather list of objects or single object */ -- cgit v1.2.3 From eab7f6d3c2f1a2ecfce6976f2b6d50a5ea5d2fcb Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 1 Jun 2010 06:07:22 +0000 Subject: Fix [#22469] Crashes with "segmentation fault" when opening an image for Voxel Data texture of type Image sequence Cleaned up the code here, made it more efficient and more reliable with threaded render. --- source/blender/blenkernel/intern/texture.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 873a4103e3e..6d8c339d2b9 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1149,7 +1149,8 @@ void BKE_free_pointdensity(PointDensity *pd) void BKE_free_voxeldatadata(struct VoxelData *vd) { if (vd->dataset) { - MEM_freeN(vd->dataset); + if(vd->file_format != TEX_VD_SMOKE) + MEM_freeN(vd->dataset); vd->dataset = NULL; } @@ -1173,6 +1174,8 @@ struct VoxelData *BKE_add_voxeldata(void) vd->int_multiplier = 1.0; vd->extend = TEX_CLIP; vd->object = NULL; + vd->cachedframe = -1; + vd->ok = 0; return vd; } -- cgit v1.2.3 From db96d4972f201445451f4f12bd6424cc96b93d52 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 1 Jun 2010 19:01:54 +0000 Subject: Workaround #20467: disabled OpenMP multithreading on subsurf/multires/sculpt for now, it's too fine grained and so becomes a performance bottleneck on some platforms, while only providing a modest speedup on others. Couldn't find a simple enough solution to solve this, so for now no multithreading here. --- source/blender/blenkernel/intern/CCGSubSurf.c | 18 +++++++++--------- source/blender/blenkernel/intern/multires.c | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 6778c9eb8ad..8fad398f00a 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1159,7 +1159,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, int normalDataOffset = ss->normalDataOffset; int vertDataSize = ss->meshIFC.vertDataSize; - #pragma omp parallel for private(ptrIdx) schedule(static) + //#pragma omp parallel for private(ptrIdx) schedule(static) for (ptrIdx=0; ptrIdxmeshIFC.vertDataSize; void *q = ss->q, *r = ss->r; - #pragma omp parallel for private(ptrIdx) schedule(static) + //#pragma omp parallel for private(ptrIdx) schedule(static) for (ptrIdx=0; ptrIdxmeshIFC.vertDataSize, "CCGSubsurf q"); r = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf r"); } - #pragma omp for schedule(static) + //#pragma omp for schedule(static) for (ptrIdx=0; ptrIdxv0, nextLvl)); VertDataCopy(EDGE_getCo(e, nextLvl, edgeSize-1), VERT_getCo(e->v1, nextLvl)); } - #pragma omp parallel for private(i) schedule(static) + //#pragma omp parallel for private(i) schedule(static) for (i=0; itotface; ++i) { const int numVerts = mface[i].v4 ? 4 : 3; MDisps *mdisp = &mdisps[i]; @@ -560,7 +560,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int /* when adding new faces in edit mode, need to allocate disps */ if(!mdisp->disps) - #pragma omp critical + //#pragma omp critical { multires_reallocate_mdisps(me, mdisps, totlvl); } -- cgit v1.2.3 From 39617932927383cf2f49142ee3a476282172e8c9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 1 Jun 2010 19:26:35 +0000 Subject: Fix #22239: external btx won't load. --- source/blender/blenkernel/BKE_customdata.h | 2 ++ source/blender/blenkernel/BKE_multires.h | 1 + source/blender/blenkernel/intern/customdata.c | 19 +++++++++++++++++++ source/blender/blenkernel/intern/multires.c | 8 ++++++++ 4 files changed, 30 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 7ca6bbe67a7..ce4286f01c8 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -292,6 +292,8 @@ void CustomData_external_write(struct CustomData *data, struct ID *id, CustomDataMask mask, int totelem, int free); void CustomData_external_read(struct CustomData *data, struct ID *id, CustomDataMask mask, int totelem); +void CustomData_external_reload(struct CustomData *data, + struct ID *id, CustomDataMask mask, int totelem); #endif diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 258fb6f1b3f..8716794bbd4 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -42,6 +42,7 @@ void multires_mark_as_modified(struct Object *ob); void multires_force_update(struct Object *ob); void multires_force_render_update(struct Object *ob); +void multires_force_external_reload(struct Object *ob); struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, int local_mmd, struct DerivedMesh*, struct Object *, int, int); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 361e6f3fd22..e2909bf0904 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2322,6 +2322,25 @@ static void customdata_external_filename(char filename[FILE_MAX], ID *id, Custom BLI_path_abs(filename, path); } +void CustomData_external_reload(CustomData *data, ID *id, CustomDataMask mask, int totelem) +{ + CustomDataLayer *layer; + const LayerTypeInfo *typeInfo; + int i; + + for(i=0; itotlayer; i++) { + layer = &data->layers[i]; + typeInfo = layerType_getInfo(layer->type); + + if(!(mask & (1<type))); + else if((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) { + if(typeInfo->free) + typeInfo->free(layer->data, totelem, typeInfo->size); + layer->flag &= ~CD_FLAG_IN_MEMORY; + } + } +} + void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int totelem) { CustomDataExternal *external= data->external; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 1e310c1c3d0..ad069be50f5 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -139,6 +139,14 @@ void multires_force_update(Object *ob) } } +void multires_force_external_reload(Object *ob) +{ + Mesh *me = get_mesh(ob); + + CustomData_external_reload(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); + multires_force_update(ob); +} + void multires_force_render_update(Object *ob) { if(ob && (ob->mode & OB_MODE_SCULPT) && modifiers_findByType(ob, eModifierType_Multires)) -- cgit v1.2.3 From 9cbbc9d3afd8742a36969736f648743d4f943393 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 2 Jun 2010 17:58:28 +0000 Subject: rename some rna properties filename --> filepath * filename == "foo.ext" * filepath == "/path/to/and/including/foo.ext" this was alredy followed in some places not not everywhere. --- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/blenkernel/intern/image.c | 6 +++--- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/sound.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index e2909bf0904..dcc0a0b876f 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2316,7 +2316,7 @@ int CustomData_verify_versions(struct CustomData *data, int index) static void customdata_external_filename(char filename[FILE_MAX], ID *id, CustomDataExternal *external) { - char *path = (id->lib)? id->lib->filename: G.sce; + char *path = (id->lib)? id->lib->filepath: G.sce; BLI_strncpy(filename, external->filename, FILE_MAX); BLI_path_abs(filename, path); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 39efd9fe72e..f860f579930 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1562,7 +1562,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) BLI_strncpy(name, ima->name, sizeof(name)); if(ima->id.lib) - BLI_path_abs(name, ima->id.lib->filename); + BLI_path_abs(name, ima->id.lib->filepath); else BLI_path_abs(name, G.sce); @@ -1669,7 +1669,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) BLI_strncpy(str, ima->name, FILE_MAX); if(ima->id.lib) - BLI_path_abs(str, ima->id.lib->filename); + BLI_path_abs(str, ima->id.lib->filepath); else BLI_path_abs(str, G.sce); @@ -1727,7 +1727,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) /* get the right string */ BLI_strncpy(str, ima->name, sizeof(str)); if(ima->id.lib) - BLI_path_abs(str, ima->id.lib->filename); + BLI_path_abs(str, ima->id.lib->filepath); else BLI_path_abs(str, G.sce); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 1381a3b19dd..5931bf973af 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1225,7 +1225,7 @@ static void image_fix_relative_path(Image *ima) { if(ima->id.lib==NULL) return; if(strncmp(ima->name, "//", 2)==0) { - BLI_path_abs(ima->name, ima->id.lib->filename); + BLI_path_abs(ima->name, ima->id.lib->filepath); BLI_path_rel(ima->name, G.sce); } } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index cb596622431..e14828d0f20 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1080,7 +1080,7 @@ static int ptcache_path(PTCacheID *pid, char *filename) char file[MAX_PTCACHE_PATH]; /* we dont want the dir, only the file */ char *blendfilename; - blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filename: G.sce; + blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.sce; BLI_split_dirfile(blendfilename, NULL, file); i = strlen(file); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 24e5014a741..6402f908422 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -256,7 +256,7 @@ void sound_load(struct Main *bmain, struct bSound* sound) BLI_strncpy(fullpath, sound->name, sizeof(fullpath)); if(sound->id.lib) - path = sound->id.lib->filename; + path = sound->id.lib->filepath; else path = bmain ? bmain->name : G.sce; -- cgit v1.2.3 From 89320c911eef0968f2c9c642da14a48f6a1bd5ae Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 2 Jun 2010 18:04:31 +0000 Subject: Sculpt & modifiers: patch by Sergey Sharybin, with modifications by me. Fixes various crashes and redraw problems, most noticeable new feature is that you can now sculpt on a multires mesh with deforming modifiers preceding it. I've left out support for sculpting on multires with enabled modifiers following it, in this case only the base mesh can be sculpted now. The code changes needed to do this are just too ugly in my opinion, would need a more torough redesign which I don't think we should try now. In my opinion this is also not really an important case, since it's going to be incredibly slow anyway to run a modifier on a high res mesh while sculpting. So, to summarize current state: * Fastest sculpting: base mesh with no modifiers or multires with only modifiers preceding it. * Slower sculpting: base mesh with modifiers, depends on the speed of the modifiers. * Not supported: multires mesh with modifiers following it. --- source/blender/blenkernel/BKE_subsurf.h | 1 + source/blender/blenkernel/intern/DerivedMesh.c | 4 --- source/blender/blenkernel/intern/cdderivedmesh.c | 14 +++++--- source/blender/blenkernel/intern/multires.c | 8 +++-- source/blender/blenkernel/intern/subsurf_ccg.c | 46 +++++++++++++++++++++--- 5 files changed, 59 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index ef3ad3ad2e9..940a0027d0b 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -72,6 +72,7 @@ typedef struct CCGDerivedMesh { char *faceFlags; struct PBVH *pbvh; + int pbvh_draw; struct ListBase *fmap; struct IndexNode *fmap_mem; diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 85791d5024d..9d649edd81a 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1870,10 +1870,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos /* grab modifiers until index i */ if((index >= 0) && (modifiers_indexInObject(ob, md) >= index)) break; - - /*don't allow other modifiers past multires if in sculpt mode*/ - if (!useRenderParams && ((ob->mode & OB_MODE_SCULPT) && ob->sculpt)) - break; } for(md=firstmd; md; md=md->next) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 204ff2a0369..e15e5bc9b45 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -74,6 +74,7 @@ typedef struct { /* Cached */ struct PBVH *pbvh; + int pbvh_draw; /* Mesh connectivity */ struct ListBase *fmap; struct IndexNode *fmap_mem; @@ -188,6 +189,7 @@ static ListBase *cdDM_getFaceMap(Object *ob, DerivedMesh *dm) static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + Mesh *me= (ob)? ob->data: NULL; if(!ob) { cddm->pbvh= NULL; @@ -196,13 +198,17 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) if(!ob->sculpt) return NULL; - if(ob->sculpt->pbvh) + if(ob->sculpt->pbvh) { cddm->pbvh= ob->sculpt->pbvh; + cddm->pbvh_draw = (cddm->mvert == me->mvert); + } + /* always build pbvh from original mesh, and only use it for drawing if + this derivedmesh is just original mesh. it's the multires subsurf dm + that this is actually for, to support a pbvh on a modified mesh */ if(!cddm->pbvh && ob->type == OB_MESH) { - Mesh *me= ob->data; - cddm->pbvh = BLI_pbvh_new(); + cddm->pbvh_draw = (cddm->mvert == me->mvert); BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert, me->totface, me->totvert); } @@ -417,7 +423,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, glVertex3fv(mvert[index].co); \ } - if(cddm->pbvh) { + if(cddm->pbvh && cddm->pbvh_draw) { if(dm->numFaceData) { float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index ad069be50f5..ee8a74d6fbb 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -654,7 +654,9 @@ static void multiresModifier_update(DerivedMesh *dm) int i, j, numGrids, highGridSize, lowGridSize; /* create subsurf DM from original mesh at high level */ - cddm = CDDM_from_mesh(me, NULL); + if (ob->derivedDeform) cddm = CDDM_copy(ob->derivedDeform); + else cddm = CDDM_from_mesh(me, NULL); + highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0); /* create multires DM from original mesh and displacements */ @@ -705,7 +707,9 @@ static void multiresModifier_update(DerivedMesh *dm) else { DerivedMesh *cddm, *subdm; - cddm = CDDM_from_mesh(me, NULL); + if (ob->derivedDeform) cddm = CDDM_copy(ob->derivedDeform); + else cddm = CDDM_from_mesh(me, NULL); + subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0); cddm->release(cddm); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 72236a76032..53206bb3970 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -44,6 +44,7 @@ #include "BKE_cdderivedmesh.h" #include "BKE_global.h" #include "BKE_mesh.h" +#include "BKE_modifier.h" #include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_subsurf.h" @@ -2229,10 +2230,28 @@ static ListBase *ccgDM_getFaceMap(Object *ob, DerivedMesh *dm) return ccgdm->fmap; } +static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm) +{ + ModifierData *md; + MultiresModifierData *mmd= ccgdm->multires.mmd; + + /* in sync with sculpt mode, only use multires grid pbvh if we are + the last enabled modifier in the stack, otherwise we use the base + mesh */ + if(!mmd) + return 0; + + for(md=mmd->modifier.next; md; md= md->next) + if(modifier_isEnabled(mmd->modifier.scene, md, eModifierMode_Realtime)) + return 0; + + return 1; +} + static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) { CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; - int gridSize, numGrids; + int gridSize, numGrids, grid_pbvh; if(!ob) { ccgdm->pbvh= NULL; @@ -2241,13 +2260,30 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) if(!ob->sculpt) return NULL; - if(ob->sculpt->pbvh) - ccgdm->pbvh= ob->sculpt->pbvh; + + grid_pbvh = ccgDM_use_grid_pbvh(ccgdm); + + if(ob->sculpt->pbvh) { + if(grid_pbvh) { + /* pbvh's grids, gridadj and gridfaces points to data inside ccgdm + but this can be freed on ccgdm release, this updates the pointers + when the ccgdm gets remade, the assumption is that the topology + does not change. */ + ccgdm_create_grids(dm); + BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void**)ccgdm->gridFaces); + } + + ccgdm->pbvh = ob->sculpt->pbvh; + ccgdm->pbvh_draw = grid_pbvh; + } if(ccgdm->pbvh) return ccgdm->pbvh; - if(ccgdm->multires.mmd) { + /* no pbvh exists yet, we need to create one. only in case of multires + we build a pbvh over the modified mesh, in other cases the base mesh + is being sculpted, so we build a pbvh from that. */ + if(grid_pbvh) { ccgdm_create_grids(dm); gridSize = ccgDM_getGridSize(dm); @@ -2256,6 +2292,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, numGrids, gridSize, (void**)ccgdm->gridFaces); + ccgdm->pbvh_draw = 1; } else if(ob->type == OB_MESH) { Mesh *me= ob->data; @@ -2263,6 +2300,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert, me->totface, me->totvert); + ccgdm->pbvh_draw = 0; } return ccgdm->pbvh; -- cgit v1.2.3 From 21d112c36f661f3ce8648f4eadfe1325929e9184 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 3 Jun 2010 07:27:55 +0000 Subject: Reworked the non-blocking reports display in the info header: * Now it displays the last report from the global list, not just from operators * Rather than disappearing when a new operator is run, it stays until it times out or a new report is added * Fun animated transitions ;) http://mke3.net/blender/devel/2.5/reports_header.mov Now need to investigate report usage with popups. Ideally we can have most reports non-blocking, so they're less intrusive, only popping up for dire errors. Problem is many things in Blender right now are marked as RPT_ERROR when probably RPT_WARNING is more appropriate. Should probably keep RPT_ERROR for things that demand immediate attention. --- source/blender/blenkernel/BKE_report.h | 2 ++ source/blender/blenkernel/intern/report.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_report.h b/source/blender/blenkernel/BKE_report.h index 62381bbc1f5..d7b7801d697 100644 --- a/source/blender/blenkernel/BKE_report.h +++ b/source/blender/blenkernel/BKE_report.h @@ -59,6 +59,8 @@ void BKE_report_store_level_set(ReportList *reports, ReportType level); char *BKE_reports_string(ReportList *reports, ReportType level); void BKE_reports_print(ReportList *reports, ReportType level); +Report *BKE_reports_last_displayable(ReportList *reports); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index da8b018d3f8..d5990ce81ec 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -32,6 +32,7 @@ #include "BKE_report.h" #include "BKE_global.h" /* G.background only */ +#include "BKE_utildefines.h" #include #include @@ -262,3 +263,14 @@ void BKE_reports_print(ReportList *reports, ReportType level) MEM_freeN(cstring); } +Report *BKE_reports_last_displayable(ReportList *reports) +{ + Report *report=NULL; + + for (report= (Report *)reports->list.last; report; report=report->prev) { + if (ELEM3(report->type, RPT_ERROR, RPT_WARNING, RPT_INFO)) + return report; + } + + return NULL; +} \ No newline at end of file -- cgit v1.2.3 From eff8c83a1d693e0949f0eb27e7b88873b3dae540 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sat, 5 Jun 2010 00:21:26 +0000 Subject: Fix [#22503] Can't create any objects in new scenes. --- source/blender/blenkernel/intern/scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index faabaf4f91f..dcd305ef87e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -310,7 +310,7 @@ Scene *add_scene(char *name) int a; sce= alloc_libblock(&G.main->scene, ID_SCE, name); - sce->lay= 1; + sce->lay= sce->layact= 1; sce->r.mode= R_GAMMA|R_OSA|R_SHADOW|R_SSS|R_ENVMAP|R_RAYTRACE; sce->r.cfra= 1; -- cgit v1.2.3 From 556b57febf9191210474678537322e86f3ef8cd9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 Jun 2010 15:31:55 +0000 Subject: get rid of some warnings, removed NG_LoopBackNetworkDeviceInterface::GetNetworkVersion(), wasnt used anywhere. --- source/blender/blenkernel/intern/writeffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 8ebf98ef930..a67bad44fdb 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -362,7 +362,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports) } if (c->pix_fmt != PIX_FMT_BGR32) { - sws_scale(img_convert_ctx, (const uint8_t * const*) rgb_frame->data, + sws_scale(img_convert_ctx, (uint8_t **) rgb_frame->data, rgb_frame->linesize, 0, c->height, current_frame->data, current_frame->linesize); delete_picture(rgb_frame); -- cgit v1.2.3 From c12068920391c006cf5e72c1fafb4ebf8f807a55 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 Jun 2010 16:52:19 +0000 Subject: revert changes in own commit to fix warnings, was giving warnings with a newer swscale --- source/blender/blenkernel/intern/writeffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index a67bad44fdb..8ebf98ef930 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -362,7 +362,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports) } if (c->pix_fmt != PIX_FMT_BGR32) { - sws_scale(img_convert_ctx, (uint8_t **) rgb_frame->data, + sws_scale(img_convert_ctx, (const uint8_t * const*) rgb_frame->data, rgb_frame->linesize, 0, c->height, current_frame->data, current_frame->linesize); delete_picture(rgb_frame); -- cgit v1.2.3 From 4da179749eb8d6b53f5c2eba4b3e4132656c3d4f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 Jun 2010 21:19:59 +0000 Subject: - [#22492] [29159] commit breaks importing of script file that has a reload to self in it broke when including the blend path in the modules filename. - new function BLI_path_basename(), matches pythons os.path.basename(). replace a number of cases where BLI_split_dirfile was being used to get the filename only. --- source/blender/blenkernel/intern/image.c | 4 +--- source/blender/blenkernel/intern/text.c | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index f860f579930..ef95139abda 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -440,10 +440,8 @@ Image *BKE_add_image_imbuf(ImBuf *ibuf) { /* on save, type is changed to FILE in editsima.c */ Image *ima; - char filename[sizeof(ibuf->name)]; - BLI_split_dirfile(ibuf->name, NULL, filename); - ima= image_alloc(filename, IMA_SRC_FILE, IMA_TYPE_IMAGE); + ima= image_alloc(BLI_path_basename(ibuf->name), IMA_SRC_FILE, IMA_TYPE_IMAGE); if (ima) { BLI_strncpy(ima->name, ibuf->name, FILE_MAX); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index f1036b66f69..e8328d0e622 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -232,7 +232,6 @@ int reopen_text(Text *text) int i, llen, len, res; unsigned char *buffer; TextLine *tmp; - char sfile[FILE_MAXFILE]; char str[FILE_MAXDIR+FILE_MAXFILE]; struct stat st; @@ -240,7 +239,6 @@ int reopen_text(Text *text) BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE); BLI_path_abs(str, G.sce); - BLI_split_dirfile(str, NULL, sfile); fp= fopen(str, "r"); if(fp==NULL) return 0; @@ -331,19 +329,17 @@ Text *add_text(char *file, const char *relpath) unsigned char *buffer; TextLine *tmp; Text *ta; - char sfile[FILE_MAXFILE]; char str[FILE_MAXDIR+FILE_MAXFILE]; struct stat st; BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE); if (relpath) /* can be NULL (bg mode) */ BLI_path_abs(str, relpath); - BLI_split_dirfile(str, NULL, sfile); fp= fopen(str, "r"); if(fp==NULL) return NULL; - ta= alloc_libblock(&G.main->text, ID_TXT, sfile); + ta= alloc_libblock(&G.main->text, ID_TXT, BLI_path_basename(str)); ta->id.us= 1; ta->lines.first= ta->lines.last= NULL; -- cgit v1.2.3 From d153c765bcfcdda8686e42dd044e63e832974709 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 Jun 2010 13:32:58 +0000 Subject: CMake: - WITH_LCMS added option, was supported in scons. - commented web plugin option since its not maintained. - some formatting changes and removed includes that are not needed for source/creator/CMakeLists.txt. --- source/blender/blenkernel/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 68684bcc0a1..bcd60154379 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -72,6 +72,11 @@ IF(WITH_FFMPEG) ADD_DEFINITIONS(-DWITH_FFMPEG) ENDIF(WITH_FFMPEG) +IF(WITH_LCMS) + SET(INC ${INC} ${LCMS_INCLUDE_DIR}) + ADD_DEFINITIONS(-DWITH_LCMS) +ENDIF(WITH_LCMS) + IF(WITH_PYTHON) SET(INC ${INC} ../python ${PYTHON_INC}) ELSE(WITH_PYTHON) -- cgit v1.2.3 From 640fb84bed74e5b63e3e3186a4239cccd021cb05 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 6 Jun 2010 15:22:27 +0000 Subject: - Added checking if modifier is active in find_multires_modifier - Pass MultiresModifierData to reshape functions --- source/blender/blenkernel/BKE_multires.h | 14 ++++++---- source/blender/blenkernel/intern/multires.c | 40 ++++++++++++++--------------- 2 files changed, 29 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 8716794bbd4..e8bbb58a895 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -47,15 +47,19 @@ void multires_force_external_reload(struct Object *ob); struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, int local_mmd, struct DerivedMesh*, struct Object *, int, int); -struct MultiresModifierData *find_multires_modifier(struct Object *ob); -struct DerivedMesh *get_multires_dm(struct Object *ob); +struct MultiresModifierData *find_multires_modifier(struct Scene *scene, struct Object *ob); +struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd, + struct Object *ob); void multiresModifier_join(struct Object *); void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple); -int multiresModifier_reshape(struct Object *dst, struct Object *src); -int multiresModifier_reshapeFromDM(struct Object *ob, struct DerivedMesh *srcdm); -int multiresModifier_reshapeFromDeformMod(struct Object *ob, struct ModifierData *md); +int multiresModifier_reshape(struct Scene *scene, struct MultiresModifierData *mmd, + struct Object *dst, struct Object *src); +int multiresModifier_reshapeFromDM(struct Scene *scene, struct MultiresModifierData *mmd, + struct Object *ob, struct DerivedMesh *srcdm); +int multiresModifier_reshapeFromDeformMod(struct Scene *scene, struct MultiresModifierData *mmd, + struct Object *ob, struct ModifierData *md); void multires_stitch_grids(struct Object *); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index ee8a74d6fbb..87557ea7f2e 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -60,35 +60,33 @@ static const int multires_side_tot[] = {0, 2, 3, 5, 9, 17, 33, 65, 129, static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert); static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int add, DMGridData **oldGridData, int totlvl); -DerivedMesh *get_multires_dm(Object *ob) +DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob) { - Mesh *me= ob->data; - ModifierData *md= (ModifierData *)find_multires_modifier(ob); + ModifierData *md= (ModifierData *)mmd; ModifierTypeInfo *mti = modifierType_getInfo(md->type); - DerivedMesh *tdm = CDDM_from_mesh(me, ob); + DerivedMesh *tdm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); DerivedMesh *dm; - CDDM_calc_normals(tdm); dm = mti->applyModifier(md, ob, tdm, 0, 1); - - if(tdm != dm) tdm->release(tdm); + if (dm == tdm) { + dm = CDDM_copy(tdm); + } return dm; } -MultiresModifierData *find_multires_modifier(Object *ob) +MultiresModifierData *find_multires_modifier(Scene *scene, Object *ob) { ModifierData *md; - MultiresModifierData *mmd = NULL; for(md = ob->modifiers.first; md; md = md->next) { if(md->type == eModifierType_Multires) { - mmd = (MultiresModifierData*)md; - break; + if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) + return (MultiresModifierData*)md; } } - return mmd; + return NULL; } static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render) @@ -215,9 +213,10 @@ void multiresModifier_join(Object *ob) } #endif -int multiresModifier_reshapeFromDM(Object *ob, DerivedMesh *srcdm) +int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd, + Object *ob, DerivedMesh *srcdm) { - DerivedMesh *mrdm = get_multires_dm (ob); + DerivedMesh *mrdm = get_multires_dm (scene, mmd, ob); if(mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) { multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm)); @@ -236,13 +235,14 @@ int multiresModifier_reshapeFromDM(Object *ob, DerivedMesh *srcdm) } /* Returns 1 on success, 0 if the src's totvert doesn't match */ -int multiresModifier_reshape(Object *dst, Object *src) +int multiresModifier_reshape(Scene *scene, MultiresModifierData *mmd, Object *dst, Object *src) { - DerivedMesh *srcdm = src->derivedFinal; - return multiresModifier_reshapeFromDM(dst, srcdm); + DerivedMesh *srcdm = mesh_get_derived_final(scene, src, CD_MASK_BAREMESH); + return multiresModifier_reshapeFromDM(scene, mmd, dst, srcdm); } -int multiresModifier_reshapeFromDeformMod(Object *ob, ModifierData *md) +int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mmd, + Object *ob, ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); DerivedMesh *dm, *ndm; @@ -250,7 +250,7 @@ int multiresModifier_reshapeFromDeformMod(Object *ob, ModifierData *md) float (*deformedVerts)[3]; /* Create DerivedMesh for deformation modifier */ - dm = get_multires_dm(ob); + dm = get_multires_dm(scene, mmd, ob); numVerts= dm->getNumVerts(dm); deformedVerts= MEM_callocN(sizeof(float)*numVerts*3, "multiresReshape_deformVerts"); @@ -264,7 +264,7 @@ int multiresModifier_reshapeFromDeformMod(Object *ob, ModifierData *md) dm->release(dm); /* Reshaping */ - result= multiresModifier_reshapeFromDM(ob, ndm); + result= multiresModifier_reshapeFromDM(scene, mmd, ob, ndm); /* Cleanup */ ndm->release(ndm); -- cgit v1.2.3 From 3efcdf5d475d52f4a53db2683940ba50e23163b9 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Mon, 7 Jun 2010 03:48:41 +0000 Subject: Fixed bug #22361, missing graphics when sculpting with pinned shape keys * Problem was that the sculpt PBVH was only used for redrawing if the derived mesh's vertices were equal the base mesh's vertices, which isn't the case when sculpting on shape keys. --- source/blender/blenkernel/intern/cdderivedmesh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index e15e5bc9b45..cadf5f375b5 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -200,7 +200,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) return NULL; if(ob->sculpt->pbvh) { cddm->pbvh= ob->sculpt->pbvh; - cddm->pbvh_draw = (cddm->mvert == me->mvert); + cddm->pbvh_draw = (cddm->mvert == me->mvert) || ob->sculpt->kb; } /* always build pbvh from original mesh, and only use it for drawing if @@ -208,7 +208,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) that this is actually for, to support a pbvh on a modified mesh */ if(!cddm->pbvh && ob->type == OB_MESH) { cddm->pbvh = BLI_pbvh_new(); - cddm->pbvh_draw = (cddm->mvert == me->mvert); + cddm->pbvh_draw = (cddm->mvert == me->mvert) || ob->sculpt->kb; BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert, me->totface, me->totvert); } -- cgit v1.2.3 From 0a7d036f324e9bcf9285ff292890c940d90fbc06 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Mon, 7 Jun 2010 04:48:22 +0000 Subject: Fixed bug #22293, v2.49b to v2.5alpha2 incompatibility * UV data on multires meshes wasn't getting imported properly. Fixed by separately loading in all "first-level" data from the old multires data type into mesh. Note that an "incorrect" data layers might still be loaded and be active on the mesh, but the correct layers should now also show up in the UV layer selector. --- source/blender/blenkernel/intern/multires.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 87557ea7f2e..d567e0f0408 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1286,6 +1286,7 @@ void multires_load_old(Object *ob, Mesh *me) ModifierData *md; MultiresModifierData *mmd; DerivedMesh *dm, *orig; + CustomDataLayer *l; int i; /* Load original level into the mesh */ @@ -1331,6 +1332,14 @@ void multires_load_old(Object *ob, Mesh *me) dm->release(dm); orig->release(orig); + /* Copy the first-level data to the mesh */ + for(i = 0, l = me->mr->vdata.layers; i < me->mr->vdata.totlayer; ++i, ++l) + CustomData_add_layer(&me->vdata, l->type, CD_REFERENCE, l->data, me->totvert); + for(i = 0, l = me->mr->fdata.layers; i < me->mr->fdata.totlayer; ++i, ++l) + CustomData_add_layer(&me->fdata, l->type, CD_REFERENCE, l->data, me->totface); + memset(&me->mr->vdata, 0, sizeof(CustomData)); + memset(&me->mr->fdata, 0, sizeof(CustomData)); + /* Remove the old multires */ multires_free(me->mr); me->mr= NULL; -- cgit v1.2.3 From ae8bba216596d58bc72f85b7c3bf5b61a9c87e8a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 Jun 2010 14:38:59 +0000 Subject: Fix #22331: mesh deform modifier not caculate all shape keys when using 'apply shape keys in edit mode' This modifier used undeformed coordinates from emDM. Added method getVertCos to emDM, so meshdeform now could use it to get deformed coordinates form any derived mesh. --- source/blender/blenkernel/intern/DerivedMesh.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 9d649edd81a..339326f75d5 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1077,6 +1077,21 @@ static int emDM_getNumFaces(DerivedMesh *dm) return BLI_countlist(&emdm->em->faces); } +static void emDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3]) +{ + EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; + EditVert *eve; + int i; + + for (i=0,eve= emdm->em->verts.first; eve; i++,eve=eve->next) { + if (emdm->vertexCos) { + copy_v3_v3(cos_r[i], emdm->vertexCos[i]); + } else { + copy_v3_v3(cos_r[i], eve->co); + } + } +} + static void emDM_getVert(DerivedMesh *dm, int index, MVert *vert_r) { EditVert *ev = ((EditMeshDerivedMesh *)dm)->em->verts.first; @@ -1309,6 +1324,8 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob, emdm->dm.getNumEdges = emDM_getNumEdges; emdm->dm.getNumFaces = emDM_getNumFaces; + emdm->dm.getVertCos = emDM_getVertCos; + emdm->dm.getVert = emDM_getVert; emdm->dm.getEdge = emDM_getEdge; emdm->dm.getFace = emDM_getFace; -- cgit v1.2.3 From e012fc8107e11d3bdbdc395ad399d4145cc27639 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 Jun 2010 17:38:52 +0000 Subject: Fix #22487: Shrinkwrap ignores preceding deform modifiers ShrinkwrapCalcData->vert contains verts from derivedMesh this coordinated are deformed by vertexCos only for normal projection (to get correct normals) for other cases this field contains undeformed dm's coordinates and vertexCos should be used --- source/blender/blenkernel/intern/shrinkwrap.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 574ec848291..bddfeb049a8 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -355,11 +355,16 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S if(calc->vert) { - VECCOPY(tmp_co, calc->vert[i].co); - if(calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) + /* calc->vert contains verts from derivedMesh */ + /* this coordinated are deformed by vertexCos only for normal projection (to get correct normals) */ + /* for other cases calc->varts contains undeformed coordinates and vertexCos should be used */ + if(calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) { + VECCOPY(tmp_co, calc->vert[i].co); normal_short_to_float_v3(tmp_no, calc->vert[i].no); - else + } else { + VECCOPY(tmp_co, co); VECCOPY(tmp_no, proj_axis); + } } else { -- cgit v1.2.3 From 740897a69e97275758cce605b5227e6036cdcb95 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 Jun 2010 20:08:03 +0000 Subject: set the default options for new cameras to be the same as the default blend file --- source/blender/blenkernel/intern/object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 576b3481d07..179e83fdc66 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -679,8 +679,8 @@ void *add_camera(char *name) cam->clipend= 100.0f; cam->drawsize= 0.5f; cam->ortho_scale= 6.0; - cam->flag |= CAM_SHOWTITLESAFE; - cam->passepartalpha = 0.2f; + cam->flag |= CAM_SHOWPASSEPARTOUT; + cam->passepartalpha = 0.5f; return cam; } -- cgit v1.2.3 From 3e56c4dda180103f71cf20ccaa76a2d70f363bb7 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 9 Jun 2010 08:00:45 +0000 Subject: Logic Editor: bugfix for "Unable to Add Controllers sometimes" (reported in IRC by Daniel Salazar (ZanQdo) What was happening; if the old code (2.49) was changing the status from 0 to 1 inside the interface code. e.g. if (!ob->status) ob->status = 1; Initializing it properly (in blenkernel) and making sure the new status is ever 0 (in rna_object.c) should fix it. And yes, the log is bigger than the patch ! --- source/blender/blenkernel/intern/object.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 179e83fdc66..c544e27a102 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1026,6 +1026,8 @@ Object *add_only_object(int type, char *name) ob->anisotropicFriction[2] = 1.0f; ob->gameflag= OB_PROP|OB_COLLISION; ob->margin = 0.0; + ob->init_state=1; + ob->state=1; /* ob->pad3 == Contact Processing Threshold */ ob->m_contactProcessingThreshold = 1.; -- cgit v1.2.3 From e2bc4ca9cee0c66c10efb9cf552c1135f30e7a4b Mon Sep 17 00:00:00 2001 From: Diego Borghetti Date: Wed, 9 Jun 2010 15:35:10 +0000 Subject: Fix #22317 View reamins in camera's view after camera is deleted (again) The problem was not in the editors, the code in blenkernel have a XXX in the perspective value. Now unlink_object also update the ARegion. --- source/blender/blenkernel/intern/object.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c544e27a102..ac4fd28bd28 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -320,6 +320,7 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec ob->recalc |= OB_RECALC; } } + void unlink_object(Scene *scene, Object *ob) { Object *obt; @@ -334,6 +335,8 @@ void unlink_object(Scene *scene, Object *ob) bConstraint *con; //bActionStrip *strip; // XXX animsys ModifierData *md; + ARegion *ar; + RegionView3D *rv3d; int a; unlink_controllers(&ob->controllers); @@ -606,17 +609,27 @@ void unlink_object(Scene *scene, Object *ob) while(sa) { SpaceLink *sl; + if (sa->spacetype == SPACE_VIEW3D) { + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype==RGN_TYPE_WINDOW) { + rv3d= (RegionView3D *)ar->regiondata; + if (rv3d->persp == RV3D_CAMOB) + rv3d->persp= RV3D_PERSP; + if (rv3d->localvd && rv3d->localvd->persp == RV3D_CAMOB) + rv3d->localvd->persp= RV3D_PERSP; + } + } + } + for (sl= sa->spacedata.first; sl; sl= sl->next) { if(sl->spacetype==SPACE_VIEW3D) { View3D *v3d= (View3D*) sl; if(v3d->camera==ob) { v3d->camera= NULL; - // XXX if(v3d->persp==V3D_CAMOB) v3d->persp= V3D_PERSP; } if(v3d->localvd && v3d->localvd->camera==ob ) { v3d->localvd->camera= NULL; - // XXX if(v3d->localvd->persp==V3D_CAMOB) v3d->localvd->persp= V3D_PERSP; } } else if(sl->spacetype==SPACE_OUTLINER) { -- cgit v1.2.3 From 7e21cede8f9a392db31889b398233f7b4ed829f0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Jun 2010 15:41:01 +0000 Subject: setting the sequencer strip filepath for sound strips would rename the strip path but not the sounds, resulting in sounds that didnt play in the sequencer unless you removed and replaced them with a strip that pointed to the new path. The way these 2 datablocks work together is a bit odd, I think this is OK for now but should be better defined. --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index f1e60ee2cfd..3ff7370a443 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -566,7 +566,7 @@ void calc_sequence(Scene *scene, Sequence *seq) } } -/* note: caller should run calc_sequence(scene, seq) */ +/* note: caller should run calc_sequence(scene, seq) after */ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) { char str[FILE_MAXDIR+FILE_MAXFILE]; -- cgit v1.2.3 From 0d36ce3252d00b03df873a14d9edac31041d3343 Mon Sep 17 00:00:00 2001 From: Diego Borghetti Date: Thu, 10 Jun 2010 21:12:22 +0000 Subject: Fix bug #22563 Two modifers with same name on one object The copy_object function don't call modifier_unique_name so every modifier (in this case, the array) get the same name. --- source/blender/blenkernel/intern/object.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ac4fd28bd28..6e5afcbd1ec 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1280,6 +1280,7 @@ Object *copy_object(Object *ob) for (md=ob->modifiers.first; md; md=md->next) { ModifierData *nmd = modifier_new(md->type); + modifier_unique_name(&obn->modifiers, nmd); modifier_copyData(md, nmd); BLI_addtail(&obn->modifiers, nmd); } -- cgit v1.2.3 From 6aaf55eee5a2a7fb4482ecb5eead0b3b92e24caa Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 10 Jun 2010 21:23:09 +0000 Subject: Copy name from original modifier rather than generate new unique in copy_object --- source/blender/blenkernel/intern/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6e5afcbd1ec..972c07eb272 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1280,7 +1280,7 @@ Object *copy_object(Object *ob) for (md=ob->modifiers.first; md; md=md->next) { ModifierData *nmd = modifier_new(md->type); - modifier_unique_name(&obn->modifiers, nmd); + BLI_strncpy(nmd->name, md->name, sizeof(nmd->name)); modifier_copyData(md, nmd); BLI_addtail(&obn->modifiers, nmd); } -- cgit v1.2.3 From 2980d902b94bddac0a9ebcb6023343b18f1a482e Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 11 Jun 2010 07:57:43 +0000 Subject: Fixed bug #21348, Hide selection in Edit Mode not working with some modifiers (VBOs) Was actually a couple bugs: * VBO bug was that hidden faces weren't being skipped correctly. Fixed that and rewrote this bit of VBO drawing code more clearly (less duplication, less unecessary state, and comments even) * Second bug was that CCGDerivedMesh wasn't outputing ORIGINDEX data for faces. (it's not doing it for edges or verts either, but I don't know that we need it to.) At any rate, we do need this data for faces so that additional DerivedMeshes on top of subsurf know what faces in the editmesh are hidden. --- source/blender/blenkernel/intern/cdderivedmesh.c | 44 ++++++++++-------------- source/blender/blenkernel/intern/subsurf_ccg.c | 5 +++ 2 files changed, 24 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index cadf5f375b5..80f39531b34 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -853,47 +853,41 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us } } else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ - int state = 1; - int prevstate = 1; int prevstart = 0; GPU_vertex_setup(dm); GPU_normal_setup(dm); if( useColors && mc ) GPU_color_setup(dm); if( !GPU_buffer_legacy(dm) ) { + int tottri = dm->drawObject->nelements/3; glShadeModel(GL_SMOOTH); - for( i = 0; i < dm->drawObject->nelements/3; i++ ) { + + for( i = 0; i < tottri; i++ ) { int actualFace = dm->drawObject->faceRemap[i]; int drawSmooth = (mf[actualFace].flag & ME_SMOOTH); - int dontdraw = 0; + int draw = 1; + if(index) { orig = index[actualFace]; if(setDrawOptions && orig == ORIGINDEX_NONE) - dontdraw = 1; + draw = 0; } else orig = actualFace; - if( dontdraw ) { - state = 0; - } - else { - if(!setDrawOptions || setDrawOptions(userData, orig, &drawSmooth)) { - state = 1; - } - else { - state = 0; - } - } - if( prevstate != state && prevstate == 1 ) { - if( i-prevstart > 0 ) { - glDrawArrays(GL_TRIANGLES,prevstart*3,(i-prevstart)*3); - } - prevstart = i; + + if(setDrawOptions && !setDrawOptions(userData, orig, &drawSmooth)) + draw = 0; + + /* Goal is to draw as long of a contiguous triangle + array as possible, so draw when we hit either an + invisible triangle or at the end of the array */ + if(!draw || i == tottri - 1) { + if(prevstart != i) + /* Add one to the length (via `draw') + if we're drawing at the end of the array */ + glDrawArrays(GL_TRIANGLES,prevstart*3, (i-prevstart+draw)*3); + prevstart = i + 1; } - prevstate = state; - } - if(state==1) { - glDrawArrays(GL_TRIANGLES,prevstart*3,dm->drawObject->nelements-prevstart*3); } glShadeModel(GL_FLAT); } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 53206bb3970..0d7738353df 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2328,6 +2328,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, int gridInternalEdges; MEdge *medge = NULL; MFace *mface = NULL; + int *orig_indices; FaceVertWeight *qweight, *tweight; DM_from_template(&ccgdm->dm, dm, DM_TYPE_CCGDM, @@ -2437,6 +2438,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, faceFlags = ccgdm->faceFlags = MEM_callocN(sizeof(char)*2*totface, "faceFlags"); + orig_indices = (int*)ccgdm->dm.getFaceDataArray(&ccgdm->dm, CD_ORIGINDEX); for(index = 0; index < totface; ++index) { CCGFace *f = ccgdm->faceMap[index].face; int numVerts = ccgSubSurf_getFaceNumVerts(f); @@ -2450,6 +2452,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ccgdm->faceMap[index].startEdge = edgeNum; ccgdm->faceMap[index].startFace = faceNum; + if(orig_indices) + orig_indices[faceNum] = origIndex; + /* set the face base vert */ *((int*)ccgSubSurf_getFaceUserData(ss, f)) = vertNum; -- cgit v1.2.3 From bb0b5967111b07ed1a9a82f32420bc4c07215409 Mon Sep 17 00:00:00 2001 From: Jens Ole Wund Date: Fri, 11 Jun 2010 23:05:43 +0000 Subject: adding TODO comment --- source/blender/blenkernel/intern/softbody.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index c06e0679a7d..eb7c67c8688 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3584,7 +3584,11 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) setgoal= 1; for(nu= cu->nurb.first; nu; nu= nu->next) { - if(nu->bezt) { + if(nu->bezt) { + /* bezier case ; this is nicly said naive; who ever wrote this part, it was not me (JOW) :) */ + /* a: never ever make tangent handles (sub) and or (ob)ject to collision */ + /* b: rather calculate them using some C2 (C2= continous in second derivate -> no jump in bending ) condition */ + /* not too hard to do, but needs some more code to care for; some one may want look at it JOW 2010/06/12*/ for(bezt=nu->bezt, a=0; apntsu; a++, bezt++, bp+=3, curindex+=3) { if(setgoal) { bp->goal= bezt->weight; -- cgit v1.2.3 From 971e4be1081fb655f80d6d4065c734ccf625c987 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Jun 2010 17:30:21 +0000 Subject: modify my last commit to fix [#22486] add_actuator crashes when name is bigger than 32 chars Throwing an exception if the strings too long means scripts need to be aware of string lengths and changing a string length in RNA can too easily break scripts. Instead honor the string length in RNA_property_string_set() --- source/blender/blenkernel/BKE_idprop.h | 3 ++- source/blender/blenkernel/intern/idprop.c | 42 ++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index e33239293a8..0e0d76f4284 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -71,7 +71,8 @@ void IDP_FreeArray(struct IDProperty *prop); void IDP_UnlinkArray(struct IDProperty *prop); /* ---------- String Type ------------ */ -void IDP_AssignString(struct IDProperty *prop, char *st); +IDProperty *IDP_NewString(const char *st, const char *name, int maxlen);/* maxlen excludes '\0' */ +void IDP_AssignString(struct IDProperty *prop, char *st, int maxlen); /* maxlen excludes '\0' */ void IDP_ConcatStringC(struct IDProperty *prop, char *st); void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append); void IDP_FreeString(struct IDProperty *prop); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 98b3522059c..2ccb33b088a 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -299,6 +299,34 @@ IDProperty *IDP_CopyArray(IDProperty *prop) /* ---------- String Type ------------ */ +IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) +{ + IDProperty *prop = MEM_callocN(sizeof(IDProperty), "IDProperty string"); + + if (st == NULL) { + prop->data.pointer = MEM_callocN(DEFAULT_ALLOC_FOR_NULL_STRINGS, "id property string 1"); + prop->totallen = DEFAULT_ALLOC_FOR_NULL_STRINGS; + prop->len = 1; /*NULL string, has len of 1 to account for null byte.*/ + } + else { + int stlen = strlen(st); + + if(maxlen > 0 && maxlen < stlen) + stlen = maxlen; + + stlen++; /* null terminator '\0' */ + + prop->data.pointer = MEM_callocN(stlen, "id property string 2"); + prop->len = prop->totallen = stlen; + BLI_strncpy(prop->data.pointer, st, stlen); + } + + prop->type = IDP_STRING; + BLI_strncpy(prop->name, name, MAX_IDPROP_NAME); + + return prop; +} + IDProperty *IDP_CopyString(IDProperty *prop) { IDProperty *newp = idp_generic_copy(prop); @@ -312,14 +340,19 @@ IDProperty *IDP_CopyString(IDProperty *prop) } -void IDP_AssignString(IDProperty *prop, char *st) +void IDP_AssignString(IDProperty *prop, char *st, int maxlen) { int stlen; stlen = strlen(st); - IDP_ResizeArray(prop, stlen+1); /*make room for null byte :) */ - strcpy(prop->data.pointer, st); + if(maxlen > 0 && maxlen < stlen) + stlen= maxlen; + + stlen++; /* make room for null byte */ + + IDP_ResizeArray(prop, stlen); + BLI_strncpy(prop->data.pointer, st, stlen); } void IDP_ConcatStringC(IDProperty *prop, char *st) @@ -709,9 +742,6 @@ IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name) prop->type = type; BLI_strncpy(prop->name, name, MAX_IDPROP_NAME); - /*security null byte*/ - prop->name[MAX_IDPROP_NAME-1] = 0; - return prop; } -- cgit v1.2.3 From 95b9e4171efaef3a6d6a9fe1d7c51931ea9aea32 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 13 Jun 2010 00:11:42 +0000 Subject: use utility functions for vertex groups, no functional changes --- source/blender/blenkernel/intern/lattice.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 53fa7c14730..1954bac7e93 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -845,26 +845,20 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, use_vgroups = 0; if(vgroup && vgroup[0] && use_vgroups) { - bDeformGroup *curdef; Mesh *me = target->data; - int index = 0; - - /* find the group (weak loop-in-loop) */ - for(curdef = target->defbase.first; curdef; - curdef = curdef->next, index++) - if(!strcmp(curdef->name, vgroup)) break; + int index = defgroup_name_index(target, vgroup); + float weight; - if(curdef && (me->dvert || dm)) { + if(index >= 0 && (me->dvert || dm)) { MDeformVert *dvert = me->dvert; - int j; for(a = 0; a < numVerts; a++, dvert++) { if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - for(j = 0; j < dvert->totweight; j++) { - if (dvert->dw[j].def_nr == index) { - calc_latt_deform(laOb, vertexCos[a], dvert->dw[j].weight); - } - } + + weight= defvert_find_weight(dvert, index); + + if(weight > 0.0f) + calc_latt_deform(laOb, vertexCos[a], weight); } } } else { -- cgit v1.2.3 From 4ee8d74680821e4c80479b2498e3e55791c46974 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Jun 2010 00:10:11 +0000 Subject: bugfix [#22573] image pack isn't working right own fault with recent commit to stop packing of generated images, now this works as expected. --- source/blender/blenkernel/intern/packedFile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index dc4a9ee3bdc..db457f043e7 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -216,7 +216,7 @@ void packAll(Main *bmain, ReportList *reports) bSound *sound; for(ima=bmain->image.first; ima; ima=ima->id.next) - if(ima->packedfile == NULL && ima->id.lib==NULL && ELEM3(ima->type, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) + if(ima->packedfile == NULL && ima->id.lib==NULL && ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) ima->packedfile = newPackedFile(reports, ima->name); for(vf=bmain->vfont.first; vf; vf=vf->id.next) -- cgit v1.2.3 From c2f36a4d6abf829f28079c80e7e9dae6b80251cc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Jun 2010 03:52:10 +0000 Subject: naming changes path -> filepath (for rna and operators, as agreed on with elubie) path -> data_path (for windowmanager context functions, this was alredy used in many places) --- source/blender/blenkernel/intern/anim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 20afc715c77..6044cfa7692 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -475,7 +475,7 @@ void calc_curvepath(Object *ob) bl= cu->bev.first; if(bl==NULL || !bl->nr) return; - cu->path=path= MEM_callocN(sizeof(Path), "path"); + cu->path=path= MEM_callocN(sizeof(Path), "calc_curvepath"); /* if POLY: last vertice != first vertice */ cycl= (bl->poly!= -1); -- cgit v1.2.3 From 148cca898b76e18d1338f6d7efb51a4b08438026 Mon Sep 17 00:00:00 2001 From: Jens Ole Wund Date: Mon, 14 Jun 2010 23:56:12 +0000 Subject: sofbody beziers may work nicer --- source/blender/blenkernel/BKE_softbody.h | 6 +- source/blender/blenkernel/intern/softbody.c | 989 ++++++++++++++-------------- 2 files changed, 501 insertions(+), 494 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h index ef7fa473ad0..738fe7dde82 100644 --- a/source/blender/blenkernel/BKE_softbody.h +++ b/source/blender/blenkernel/BKE_softbody.h @@ -1,6 +1,6 @@ /** - * BKE_softbody.h - * + * BKE_softbody.h + * * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** @@ -43,7 +43,7 @@ typedef struct BodyPoint { int nofsprings; int *springs; float choke,choke2,frozen; float colball; - short flag; + short loc_flag; //reserved by locale module specific states //char octantflag; float mass; float springweight; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index eb7c67c8688..bbf51717e92 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1,5 +1,5 @@ -/* softbody.c - * +/* softbody.c + * * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** @@ -32,17 +32,17 @@ ****** variables on the UI for now - float mediafrict; friction to env - float nodemass; softbody mass of *vertex* - float grav; softbody amount of gravitaion to apply - - float goalspring; softbody goal springs - float goalfrict; softbody goal springs friction - float mingoal; quick limits for goal + float mediafrict; friction to env + float nodemass; softbody mass of *vertex* + float grav; softbody amount of gravitaion to apply + + float goalspring; softbody goal springs + float goalfrict; softbody goal springs friction + float mingoal; quick limits for goal float maxgoal; - float inspring; softbody inner springs - float infrict; softbody inner springs friction + float inspring; softbody inner springs + float infrict; softbody inner springs friction ***** */ @@ -136,12 +136,12 @@ typedef struct SB_thread_context { int tot; }SB_thread_context; -#define NLF_BUILD 1 -#define NLF_SOLVE 2 +#define NLF_BUILD 1 +#define NLF_SOLVE 2 #define MID_PRESERVE 1 -#define SOFTGOALSNAP 0.999f +#define SOFTGOALSNAP 0.999f /* if bp-> goal is above make it a *forced follow original* and skip all ODE stuff for this bp removes *unnecessary* stiffnes from ODE system */ @@ -149,7 +149,11 @@ typedef struct SB_thread_context { #define BSF_INTERSECT 1 /* edge intersects collider face */ -#define SBF_DOFUZZY 1 /* edge intersects collider face */ + +/* private definitions for bodypoint states */ +#define SBF_DOFUZZY 1 /* Bodypoint do fuzzy */ +#define SBF_OUTOFCOLLISION 2 /* Bodypoint does not collide */ + #define BFF_INTERSECT 1 /* collider edge intrudes face */ #define BFF_CLOSEVERT 2 /* collider vertex repulses face */ @@ -187,15 +191,15 @@ static float sb_time_scale(Object *ob) { SoftBody *sb= ob->soft; /* is supposed to be there */ if (sb){ - return(sb->physics_speed); - /*hrms .. this could be IPO as well :) + return(sb->physics_speed); + /*hrms .. this could be IPO as well :) estimated range [0.001 sluggish slug - 100.0 very fast (i hope ODE solver can handle that)] 1 approx = a unit 1 pendulum at g = 9.8 [earth conditions] has period 65 frames - theory would give a 50 frames period .. so there must be something inaccurate .. looking for that (BM) + theory would give a 50 frames period .. so there must be something inaccurate .. looking for that (BM) */ } return (1.0f); - /* + /* this would be frames/sec independant timing assuming 25 fps is default but does not work very well with NLA return (25.0f/scene->r.frs_sec) @@ -206,10 +210,10 @@ static float sb_time_scale(Object *ob) /* helper functions for everything is animatable jow_go_for2_5 +++++++*/ /* introducing them here, because i know: steps in properties ( at frame timing ) will cause unwanted responses of the softbody system (which does inter frame calculations ) - so first 'cure' would be: interpolate linear in time .. + so first 'cure' would be: interpolate linear in time .. Q: why do i write this? A: because it happend once, that some eger coder 'streamlined' code to fail. - We DO linear interpolation for goals .. and i think we should do on animated properties as well + We DO linear interpolation for goals .. and i think we should do on animated properties as well */ /* animate sb->maxgoal,sb->mingoal */ @@ -221,7 +225,7 @@ static float _final_goal(Object *ob,BodyPoint *bp)/*jow_go_for2_5 */ if(!(ob->softflag & OB_SB_GOAL)) return (0.0f); if (sb&&bp){ if (bp->goal < 0.0f) return (0.0f); - f = sb->mingoal + bp->goal*ABS(sb->maxgoal - sb->mingoal); + f = sb->mingoal + bp->goal*ABS(sb->maxgoal - sb->mingoal); f = pow(f, 4.0f); return (f); } @@ -247,15 +251,15 @@ static float _final_mass(Object *ob,BodyPoint *bp) /******************** for each target object/face the axis aligned bounding box (AABB) is stored -faces paralell to global axes +faces paralell to global axes so only simple "value" in [min,max] ckecks are used float operations still */ /* just an ID here to reduce the prob for killing objects ** ob->sumohandle points to we should not kill :) -*/ -const int CCD_SAVETY = 190561; +*/ +const int CCD_SAVETY = 190561; typedef struct ccdf_minmax{ float minx,miny,minz,maxx,maxy,maxz; @@ -285,11 +289,11 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) MFace *mface=NULL; float v[3],hull; int i; - + /* first some paranoia checks */ if (!dm) return NULL; if (!dm->getNumVerts(dm) || !dm->getNumFaces(dm)) return NULL; - + pccd_M = MEM_mallocN(sizeof(ccd_Mesh),"ccd_Mesh"); pccd_M->totvert = dm->getNumVerts(dm); pccd_M->totface = dm->getNumFaces(dm); @@ -297,32 +301,32 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f; pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f; pccd_M->mprevvert=NULL; - - + + /* blow it up with forcefield ranges */ hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft); - + /* alloc and copy verts*/ pccd_M->mvert = dm->dupVertArray(dm); - /* ah yeah, put the verices to global coords once */ - /* and determine the ortho BB on the fly */ + /* ah yeah, put the verices to global coords once */ + /* and determine the ortho BB on the fly */ for(i=0; i < pccd_M->totvert; i++){ mul_m4_v3(ob->obmat, pccd_M->mvert[i].co); - + /* evaluate limits */ VECCOPY(v,pccd_M->mvert[i].co); pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2],v[2]-hull); - + pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0],v[0]+hull); pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1],v[1]+hull); pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2],v[2]+hull); - + } /* alloc and copy faces*/ pccd_M->mface = dm->dupFaceArray(dm); - + /* OBBs for idea1 */ pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax)*pccd_M->totface,"ccd_Mesh_Faces_mima"); mima = pccd_M->mima; @@ -333,7 +337,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) for(i=0; i < pccd_M->totface; i++){ mima->minx=mima->miny=mima->minz=1e30f; mima->maxx=mima->maxy=mima->maxz=-1e30f; - + VECCOPY(v,pccd_M->mvert[mface->v1].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); @@ -341,7 +345,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) mima->maxx = MAX2(mima->maxx,v[0]+hull); mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - + VECCOPY(v,pccd_M->mvert[mface->v2].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); @@ -349,7 +353,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) mima->maxx = MAX2(mima->maxx,v[0]+hull); mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - + VECCOPY(v,pccd_M->mvert[mface->v3].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); @@ -357,7 +361,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) mima->maxx = MAX2(mima->maxx,v[0]+hull); mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - + if(mface->v4){ VECCOPY(v,pccd_M->mvert[mface->v4].co); mima->minx = MIN2(mima->minx,v[0]-hull); @@ -368,10 +372,10 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) mima->maxz = MAX2(mima->maxz,v[2]+hull); } - + mima++; mface++; - + } return pccd_M; } @@ -381,7 +385,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) MFace *mface=NULL; float v[3],hull; int i; - + /* first some paranoia checks */ if (!dm) return ; if (!dm->getNumVerts(dm) || !dm->getNumFaces(dm)) return ; @@ -391,27 +395,27 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f; pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f; - - + + /* blow it up with forcefield ranges */ hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft); - + /* rotate current to previous */ if(pccd_M->mprevvert) MEM_freeN(pccd_M->mprevvert); pccd_M->mprevvert = pccd_M->mvert; /* alloc and copy verts*/ pccd_M->mvert = dm->dupVertArray(dm); - /* ah yeah, put the verices to global coords once */ - /* and determine the ortho BB on the fly */ + /* ah yeah, put the verices to global coords once */ + /* and determine the ortho BB on the fly */ for(i=0; i < pccd_M->totvert; i++){ mul_m4_v3(ob->obmat, pccd_M->mvert[i].co); - + /* evaluate limits */ VECCOPY(v,pccd_M->mvert[i].co); pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2],v[2]-hull); - + pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0],v[0]+hull); pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1],v[1]+hull); pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2],v[2]+hull); @@ -421,13 +425,13 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2],v[2]-hull); - + pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0],v[0]+hull); pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1],v[1]+hull); pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2],v[2]+hull); - + } - + mima = pccd_M->mima; mface = pccd_M->mface; @@ -436,7 +440,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) for(i=0; i < pccd_M->totface; i++){ mima->minx=mima->miny=mima->minz=1e30f; mima->maxx=mima->maxy=mima->maxz=-1e30f; - + VECCOPY(v,pccd_M->mvert[mface->v1].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); @@ -444,7 +448,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) mima->maxx = MAX2(mima->maxx,v[0]+hull); mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - + VECCOPY(v,pccd_M->mvert[mface->v2].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); @@ -452,7 +456,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) mima->maxx = MAX2(mima->maxx,v[0]+hull); mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - + VECCOPY(v,pccd_M->mvert[mface->v3].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); @@ -460,7 +464,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) mima->maxx = MAX2(mima->maxx,v[0]+hull); mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - + if(mface->v4){ VECCOPY(v,pccd_M->mvert[mface->v4].co); mima->minx = MIN2(mima->minx,v[0]-hull); @@ -479,7 +483,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) mima->maxx = MAX2(mima->maxx,v[0]+hull); mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - + VECCOPY(v,pccd_M->mprevvert[mface->v2].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); @@ -487,7 +491,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) mima->maxx = MAX2(mima->maxx,v[0]+hull); mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - + VECCOPY(v,pccd_M->mprevvert[mface->v3].co); mima->minx = MIN2(mima->minx,v[0]-hull); mima->miny = MIN2(mima->miny,v[1]-hull); @@ -495,7 +499,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) mima->maxx = MAX2(mima->maxx,v[0]+hull); mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - + if(mface->v4){ VECCOPY(v,pccd_M->mprevvert[mface->v4].co); mima->minx = MIN2(mima->minx,v[0]-hull); @@ -506,10 +510,10 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) mima->maxz = MAX2(mima->maxz,v[2]+hull); } - + mima++; mface++; - + } return ; } @@ -537,7 +541,7 @@ static void ccd_build_deflector_hash(Scene *scene, Object *vertexowner, GHash *h if(base->object->type==OB_MESH && (base->lay & vertexowner->lay)) { ob= base->object; if((vertexowner) && (ob == vertexowner)) { - /* if vertexowner is given we don't want to check collision with owner object */ + /* if vertexowner is given we don't want to check collision with owner object */ base = base->next; continue; } @@ -557,11 +561,11 @@ static void ccd_build_deflector_hash(Scene *scene, Object *vertexowner, GHash *h /* we did copy & modify all we need so give 'em away again */ dm->release(dm); - + } }/*--- only with deflecting set */ - }/* mesh && layer*/ + }/* mesh && layer*/ base = base->next; } /* while (base) */ } @@ -576,16 +580,16 @@ static void ccd_update_deflector_hash(Scene *scene, Object *vertexowner, GHash * /*Only proceed for mesh object in same layer */ if(base->object->type==OB_MESH && (base->lay & vertexowner->lay)) { ob= base->object; - if(ob == vertexowner){ - /* if vertexowner is given we don't want to check collision with owner object */ + if(ob == vertexowner){ + /* if vertexowner is given we don't want to check collision with owner object */ base = base->next; - continue; + continue; } /*+++ only with deflecting set */ if(ob->pd && ob->pd->deflect) { DerivedMesh *dm= NULL; - + if(ob->softflag & OB_SB_COLLFINAL) { /* so maybe someone wants overkill to collide with subsurfed */ dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); } else { @@ -601,7 +605,7 @@ static void ccd_update_deflector_hash(Scene *scene, Object *vertexowner, GHash * } }/*--- only with deflecting set */ - }/* mesh && layer*/ + }/* mesh && layer*/ base = base->next; } /* while (base) */ } @@ -616,12 +620,12 @@ static int count_mesh_quads(Mesh *me) { int a,result = 0; MFace *mface= me->mface; - + if(mface) { for(a=me->totface; a>0; a--, mface++) { if(mface->v4) result++; } - } + } return result; } @@ -632,21 +636,21 @@ static void add_mesh_quad_diag_springs(Object *ob) BodyPoint *bp; BodySpring *bs, *bs_new; int a ; - + if (ob->soft){ int nofquads; //float s_shear = ob->soft->shearstiff*ob->soft->shearstiff; - + nofquads = count_mesh_quads(me); if (nofquads) { /* resize spring-array to hold additional quad springs */ bs_new= MEM_callocN( (ob->soft->totspring + nofquads *2 )*sizeof(BodySpring), "bodyspring"); memcpy(bs_new,ob->soft->bspring,(ob->soft->totspring )*sizeof(BodySpring)); - + if(ob->soft->bspring) MEM_freeN(ob->soft->bspring); /* do this before reassigning the pointer or have a 1st class memory leak */ - ob->soft->bspring = bs_new; - + ob->soft->bspring = bs_new; + /* fill the tail */ a = 0; bs = bs_new+ob->soft->totspring; @@ -662,11 +666,11 @@ static void add_mesh_quad_diag_springs(Object *ob) bs->v2= mface->v4; bs->springtype =SB_STIFFQUAD; bs++; - + } - } + } } - + /* now we can announce new springs */ ob->soft->totspring += nofquads *2; } @@ -677,7 +681,7 @@ static void add_2nd_order_roller(Object *ob,float stiffness,int *counter, int ad { /*assume we have a softbody*/ SoftBody *sb= ob->soft; /* is supposed to be there */ - BodyPoint *bp,*bpo; + BodyPoint *bp,*bpo; BodySpring *bs,*bs2,*bs3= NULL; int a,b,c,notthis= 0,v0; if (!sb->bspring){return;} /* we are 2nd order here so 1rst should have been build :) */ @@ -692,7 +696,7 @@ static void add_2nd_order_roller(Object *ob,float stiffness,int *counter, int ad bs = sb->bspring + bp->springs[b-1]; /*nasty thing here that springs have two ends so here we have to make sure we examine the other */ - if (( v0 == bs->v1) ){ + if (( v0 == bs->v1) ){ bpo =sb->bpoint+bs->v2; notthis = bs->v2; } @@ -700,7 +704,7 @@ static void add_2nd_order_roller(Object *ob,float stiffness,int *counter, int ad if (( v0 == bs->v2) ){ bpo =sb->bpoint+bs->v1; notthis = bs->v1; - } + } else {printf("oops we should not get here - add_2nd_order_springs");} } if (bpo){/* so now we have a 2nd order humpdidump */ @@ -726,9 +730,9 @@ static void add_2nd_order_roller(Object *ob,float stiffness,int *counter, int ad } } - + } - + } /*scan for neighborhood done*/ } @@ -740,17 +744,17 @@ static void add_2nd_order_springs(Object *ob,float stiffness) int counter = 0; BodySpring *bs_new; stiffness *=stiffness; - + add_2nd_order_roller(ob,stiffness,&counter,0); /* counting */ if (counter) { /* resize spring-array to hold additional springs */ bs_new= MEM_callocN( (ob->soft->totspring + counter )*sizeof(BodySpring), "bodyspring"); memcpy(bs_new,ob->soft->bspring,(ob->soft->totspring )*sizeof(BodySpring)); - + if(ob->soft->bspring) - MEM_freeN(ob->soft->bspring); - ob->soft->bspring = bs_new; - + MEM_freeN(ob->soft->bspring); + ob->soft->bspring = bs_new; + add_2nd_order_roller(ob,stiffness,&counter,1); /* adding */ ob->soft->totspring +=counter ; } @@ -759,7 +763,7 @@ static void add_2nd_order_springs(Object *ob,float stiffness) static void add_bp_springlist(BodyPoint *bp,int springID) { int *newlist; - + if (bp->springs == NULL) { bp->springs = MEM_callocN( sizeof(int), "bpsprings"); bp->springs[0] = springID; @@ -781,35 +785,35 @@ it is O(N^2) so scanning for springs every iteration is too expensive static void build_bps_springlist(Object *ob) { SoftBody *sb= ob->soft; /* is supposed to be there */ - BodyPoint *bp; - BodySpring *bs; + BodyPoint *bp; + BodySpring *bs; int a,b; - + if (sb==NULL) return; /* paranoya check */ - + for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { /* throw away old list */ if (bp->springs) { MEM_freeN(bp->springs); bp->springs=NULL; } - /* scan for attached inner springs */ + /* scan for attached inner springs */ for(b=sb->totspring, bs= sb->bspring; b>0; b--, bs++) { - if (( (sb->totpoint-a) == bs->v1) ){ + if (( (sb->totpoint-a) == bs->v1) ){ add_bp_springlist(bp,sb->totspring -b); } - if (( (sb->totpoint-a) == bs->v2) ){ + if (( (sb->totpoint-a) == bs->v2) ){ add_bp_springlist(bp,sb->totspring -b); } }/*for springs*/ - }/*for bp*/ + }/*for bp*/ } static void calculate_collision_balls(Object *ob) { SoftBody *sb= ob->soft; /* is supposed to be there */ - BodyPoint *bp; - BodySpring *bs; + BodyPoint *bp; + BodySpring *bs; int a,b,akku_count; float min,max,akku; @@ -850,12 +854,12 @@ static void calculate_collision_balls(Object *ob) } } else bp->colball=0; - }/*for bp*/ + }/*for bp*/ } /* creates new softbody if didn't exist yet, makes new points and springs arrays */ -static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring) +static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring) { SoftBody *sb; int i; @@ -864,38 +868,38 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring else free_softbody_intern(ob->soft); sb= ob->soft; softflag=ob->softflag; - + if(totpoint) { sb->totpoint= totpoint; sb->totspring= totspring; - + sb->bpoint= MEM_mallocN( totpoint*sizeof(BodyPoint), "bodypoint"); - if(totspring) + if(totspring) sb->bspring= MEM_mallocN( totspring*sizeof(BodySpring), "bodyspring"); /* initialise BodyPoint array */ for (i=0; ibpoint[i]; - + /* hum as far as i see this is overridden by _final_goal() now jow_go_for2_5 */ /* sadly breaks compatibility with older versions */ - /* but makes goals behave the same for meshes, lattices and curves */ + /* but makes goals behave the same for meshes, lattices and curves */ if(softflag & OB_SB_GOAL) { bp->goal= sb->defgoal; } - else { - bp->goal= 0.0f; + else { + bp->goal= 0.0f; /* so this will definily be below SOFTGOALSNAP */ } - + bp->nofsprings= 0; bp->springs= NULL; bp->choke = 0.0f; bp->choke2 = 0.0f; bp->frozen = 1.0f; bp->colball = 0.0f; - bp->flag = 0; + bp->loc_flag = 0; bp->springweight = 1.0f; bp->mass = 1.0f; } @@ -912,7 +916,7 @@ static void free_softbody_baked(SoftBody *sb) if(key) MEM_freeN(key); } if(sb->keys) MEM_freeN(sb->keys); - + sb->keys= NULL; sb->totkey= 0; } @@ -934,7 +938,7 @@ static void free_scratch(SoftBody *sb) MEM_freeN(sb->scratch); sb->scratch = NULL; } - + } /* only frees internal data */ @@ -943,19 +947,19 @@ static void free_softbody_intern(SoftBody *sb) if(sb) { int a; BodyPoint *bp; - + if(sb->bpoint){ for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - /* free spring list */ + /* free spring list */ if (bp->springs != NULL) { MEM_freeN(bp->springs); } } MEM_freeN(sb->bpoint); } - + if(sb->bspring) MEM_freeN(sb->bspring); - + sb->totpoint= sb->totspring= 0; sb->bpoint= NULL; sb->bspring= NULL; @@ -968,28 +972,28 @@ static void free_softbody_intern(SoftBody *sb) /* ************ dynamics ********** */ -/* the most general (micro physics correct) way to do collision -** (only needs the current particle position) +/* the most general (micro physics correct) way to do collision +** (only needs the current particle position) ** -** it actually checks if the particle intrudes a short range force field generated +** it actually checks if the particle intrudes a short range force field generated ** by the faces of the target object and returns a force to drive the particel out ** the strenght of the field grows exponetially if the particle is on the 'wrong' side of the face ** 'wrong' side : projection to the face normal is negative (all referred to a vertex in the face) ** -** flaw of this: 'fast' particles as well as 'fast' colliding faces -** give a 'tunnel' effect such that the particle passes through the force field -** without ever 'seeing' it +** flaw of this: 'fast' particles as well as 'fast' colliding faces +** give a 'tunnel' effect such that the particle passes through the force field +** without ever 'seeing' it ** this is fully compliant to heisenberg: h >= fuzzy(location) * fuzzy(time) ** besides our h is way larger than in QM because forces propagate way slower here ** we have to deal with fuzzy(time) in the range of 1/25 seconds (typical frame rate) -** yup collision targets are not known here any better +** yup collision targets are not known here any better ** and 1/25 second is looong compared to real collision events -** Q: why not use 'simple' collision here like bouncing back a particle +** Q: why not use 'simple' collision here like bouncing back a particle ** --> reverting is velocity on the face normal -** A: because our particles are not alone here -** and need to tell their neighbours exactly what happens via spring forces +** A: because our particles are not alone here +** and need to tell their neighbours exactly what happens via spring forces ** unless sbObjectStep( .. ) is called on sub frame timing level -** BTW that also questions the use of a 'implicit' solvers on softbodies +** BTW that also questions the use of a 'implicit' solvers on softbodies ** since that would only valid for 'slow' moving collision targets and dito particles */ @@ -1006,10 +1010,10 @@ static void Vec3PlusStVec(float *v, float s, float *v1) static int are_there_deflectors(Scene *scene, unsigned int layer) { Base *base; - + for(base = scene->base.first; base; base= base->next) { if( (base->lay & layer) && base->object->pd) { - if(base->object->pd->deflect) + if(base->object->pd->deflect) return 1; } } @@ -1055,17 +1059,17 @@ static int sb_detect_aabb_collisionCached( float force[3], unsigned int par_laye mprevvert= ccdm->mprevvert; mima= ccdm->mima; a = ccdm->totface; - - if ((aabbmax[0] < ccdm->bbmin[0]) || + + if ((aabbmax[0] < ccdm->bbmin[0]) || (aabbmax[1] < ccdm->bbmin[1]) || (aabbmax[2] < ccdm->bbmin[2]) || - (aabbmin[0] > ccdm->bbmax[0]) || - (aabbmin[1] > ccdm->bbmax[1]) || + (aabbmin[0] > ccdm->bbmax[0]) || + (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2]) ) { - /* boxes dont intersect */ + /* boxes dont intersect */ BLI_ghashIterator_step(ihash); - continue; - } + continue; + } /* so now we have the 2 boxes overlapping */ /* forces actually not used */ @@ -1076,19 +1080,19 @@ static int sb_detect_aabb_collisionCached( float force[3], unsigned int par_laye /*aye that should be cached*/ printf("missing cache error \n"); BLI_ghashIterator_step(ihash); - continue; + continue; } } /* if(ob->pd && ob->pd->deflect) */ BLI_ghashIterator_step(ihash); } /* while () */ BLI_ghashIterator_free(ihash); - return deflected; + return deflected; } /* --- the aabb section*/ /* +++ the face external section*/ -static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float face_v3[3],float *damp, +static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float face_v3[3],float *damp, float force[3], unsigned int par_layer,struct Object *vertexowner,float time) { Object *ob; @@ -1124,33 +1128,33 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa MVert *mprevvert= NULL; if(ccdm){ mvert= ccdm->mvert; - a = ccdm->totvert; - mprevvert= ccdm->mprevvert; + a = ccdm->totvert; + mprevvert= ccdm->mprevvert; outerfacethickness =ob->pd->pdef_sboft; - if ((aabbmax[0] < ccdm->bbmin[0]) || + if ((aabbmax[0] < ccdm->bbmin[0]) || (aabbmax[1] < ccdm->bbmin[1]) || (aabbmax[2] < ccdm->bbmin[2]) || - (aabbmin[0] > ccdm->bbmax[0]) || - (aabbmin[1] > ccdm->bbmax[1]) || + (aabbmin[0] > ccdm->bbmax[0]) || + (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2]) ) { - /* boxes dont intersect */ + /* boxes dont intersect */ BLI_ghashIterator_step(ihash); - continue; - } + continue; + } } else{ /*aye that should be cached*/ printf("missing cache error \n"); BLI_ghashIterator_step(ihash); - continue; + continue; } /* use mesh*/ if (mvert) { while(a){ - VECCOPY(nv1,mvert[a-1].co); + VECCOPY(nv1,mvert[a-1].co); if(mprevvert){ mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[a-1].co); @@ -1182,11 +1186,11 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa BLI_ghashIterator_step(ihash); } /* while () */ BLI_ghashIterator_free(ihash); - return deflected; + return deflected; } -static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],float face_v3[3],float *damp, +static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],float face_v3[3],float *damp, float force[3], unsigned int par_layer,struct Object *vertexowner,float time) { Object *ob; @@ -1221,36 +1225,36 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa mprevvert= ccdm->mprevvert; mima= ccdm->mima; a = ccdm->totface; - - if ((aabbmax[0] < ccdm->bbmin[0]) || + + if ((aabbmax[0] < ccdm->bbmin[0]) || (aabbmax[1] < ccdm->bbmin[1]) || (aabbmax[2] < ccdm->bbmin[2]) || - (aabbmin[0] > ccdm->bbmax[0]) || - (aabbmin[1] > ccdm->bbmax[1]) || + (aabbmin[0] > ccdm->bbmax[0]) || + (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2]) ) { - /* boxes dont intersect */ + /* boxes dont intersect */ BLI_ghashIterator_step(ihash); - continue; - } + continue; + } } else{ /*aye that should be cached*/ printf("missing cache error \n"); BLI_ghashIterator_step(ihash); - continue; + continue; } /* use mesh*/ while (a--) { if ( - (aabbmax[0] < mima->minx) || - (aabbmin[0] > mima->maxx) || + (aabbmax[0] < mima->minx) || + (aabbmin[0] > mima->maxx) || (aabbmax[1] < mima->miny) || - (aabbmin[1] > mima->maxy) || + (aabbmin[1] > mima->maxy) || (aabbmax[2] < mima->minz) || - (aabbmin[2] > mima->maxz) + (aabbmin[2] > mima->maxz) ) { mface++; mima++; @@ -1260,7 +1264,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa if (mvert){ - VECCOPY(nv1,mvert[mface->v1].co); + VECCOPY(nv1,mvert[mface->v1].co); VECCOPY(nv2,mvert[mface->v2].co); VECCOPY(nv3,mvert[mface->v3].co); if (mface->v4){ @@ -1269,18 +1273,18 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa if (mprevvert){ mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); - + mul_v3_fl(nv2,time); Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); - + mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); - + if (mface->v4){ mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } - } + } } /* switch origin to be nv2*/ @@ -1288,7 +1292,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa VECSUB(edge2, nv3, nv2); cross_v3_v3v3(d_nvect, edge2, edge1); normalize_v3(d_nvect); - if ( + if ( isect_line_tri_v3(nv1, nv2, face_v1, face_v2, face_v3, &t, NULL) || isect_line_tri_v3(nv2, nv3, face_v1, face_v2, face_v3, &t, NULL) || isect_line_tri_v3(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL) ){ @@ -1299,10 +1303,10 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa if (mface->v4){ /* quad */ /* switch origin to be nv4 */ VECSUB(edge1, nv3, nv4); - VECSUB(edge2, nv1, nv4); + VECSUB(edge2, nv1, nv4); cross_v3_v3v3(d_nvect, edge2, edge1); - normalize_v3(d_nvect); - if ( + normalize_v3(d_nvect); + if ( /* isect_line_tri_v3(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) || we did that edge already */ isect_line_tri_v3(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) || @@ -1313,13 +1317,13 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa } } mface++; - mima++; - }/* while a */ + mima++; + }/* while a */ } /* if(ob->pd && ob->pd->deflect) */ BLI_ghashIterator_step(ihash); } /* while () */ BLI_ghashIterator_free(ihash); - return deflected; + return deflected; } @@ -1329,20 +1333,20 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) SoftBody *sb = ob->soft; BodyFace *bf; int a; - float damp=0.0f,choke=1.0f; + float damp=0.0f,choke=1.0f; float tune = -10.0f; float feedback[3]; - + if (sb && sb->scratch->totface){ - - + + bf = sb->scratch->bodyface; for(a=0; ascratch->totface; a++, bf++) { - bf->ext_force[0]=bf->ext_force[1]=bf->ext_force[2]=0.0f; + bf->ext_force[0]=bf->ext_force[1]=bf->ext_force[2]=0.0f; /*+++edges intruding*/ - bf->flag &= ~BFF_INTERSECT; + bf->flag &= ~BFF_INTERSECT; feedback[0]=feedback[1]=feedback[2]=0.0f; - if (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos, + if (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos, &damp, feedback, ob->lay ,ob , timenow)){ Vec3PlusStVec(sb->bpoint[bf->v1].force,tune,feedback); Vec3PlusStVec(sb->bpoint[bf->v2].force,tune,feedback); @@ -1353,7 +1357,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) } feedback[0]=feedback[1]=feedback[2]=0.0f; - if ((bf->v4) && (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v3].pos, sb->bpoint[bf->v4].pos, + if ((bf->v4) && (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v3].pos, sb->bpoint[bf->v4].pos, &damp, feedback, ob->lay ,ob , timenow))){ Vec3PlusStVec(sb->bpoint[bf->v1].force,tune,feedback); Vec3PlusStVec(sb->bpoint[bf->v3].force,tune,feedback); @@ -1369,7 +1373,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) bf->flag &= ~BFF_CLOSEVERT; tune = -1.0f; feedback[0]=feedback[1]=feedback[2]=0.0f; - if (sb_detect_face_pointCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos, + if (sb_detect_face_pointCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos, &damp, feedback, ob->lay ,ob , timenow)){ Vec3PlusStVec(sb->bpoint[bf->v1].force,tune,feedback); Vec3PlusStVec(sb->bpoint[bf->v2].force,tune,feedback); @@ -1380,7 +1384,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) } feedback[0]=feedback[1]=feedback[2]=0.0f; - if ((bf->v4) && (sb_detect_face_pointCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v3].pos, sb->bpoint[bf->v4].pos, + if ((bf->v4) && (sb_detect_face_pointCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v3].pos, sb->bpoint[bf->v4].pos, &damp, feedback, ob->lay ,ob , timenow))){ Vec3PlusStVec(sb->bpoint[bf->v1].force,tune,feedback); Vec3PlusStVec(sb->bpoint[bf->v3].force,tune,feedback); @@ -1402,7 +1406,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) if (bf->v4){ sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke); } - } + } } } } @@ -1412,7 +1416,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) /* +++ the spring external section*/ -static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],float *damp, +static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],float *damp, float force[3], unsigned int par_layer,struct Object *vertexowner,float time) { Object *ob; @@ -1449,36 +1453,36 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa mprevvert= ccdm->mprevvert; mima= ccdm->mima; a = ccdm->totface; - - if ((aabbmax[0] < ccdm->bbmin[0]) || + + if ((aabbmax[0] < ccdm->bbmin[0]) || (aabbmax[1] < ccdm->bbmin[1]) || (aabbmax[2] < ccdm->bbmin[2]) || - (aabbmin[0] > ccdm->bbmax[0]) || - (aabbmin[1] > ccdm->bbmax[1]) || + (aabbmin[0] > ccdm->bbmax[0]) || + (aabbmin[1] > ccdm->bbmax[1]) || (aabbmin[2] > ccdm->bbmax[2]) ) { - /* boxes dont intersect */ + /* boxes dont intersect */ BLI_ghashIterator_step(ihash); - continue; - } + continue; + } } else{ /*aye that should be cached*/ printf("missing cache error \n"); BLI_ghashIterator_step(ihash); - continue; + continue; } /* use mesh*/ while (a--) { if ( - (aabbmax[0] < mima->minx) || - (aabbmin[0] > mima->maxx) || + (aabbmax[0] < mima->minx) || + (aabbmin[0] > mima->maxx) || (aabbmax[1] < mima->miny) || - (aabbmin[1] > mima->maxy) || + (aabbmin[1] > mima->maxy) || (aabbmax[2] < mima->minz) || - (aabbmin[2] > mima->maxz) + (aabbmin[2] > mima->maxz) ) { mface++; mima++; @@ -1488,7 +1492,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa if (mvert){ - VECCOPY(nv1,mvert[mface->v1].co); + VECCOPY(nv1,mvert[mface->v1].co); VECCOPY(nv2,mvert[mface->v2].co); VECCOPY(nv3,mvert[mface->v3].co); if (mface->v4){ @@ -1497,18 +1501,18 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa if (mprevvert){ mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); - + mul_v3_fl(nv2,time); Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); - + mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); - + if (mface->v4){ mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } - } + } } /* switch origin to be nv2*/ @@ -1535,7 +1539,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa VECSUB(edge2, nv1, nv4); cross_v3_v3v3(d_nvect, edge2, edge1); - normalize_v3(d_nvect); + normalize_v3(d_nvect); if (isect_line_tri_v3( edge_v1, edge_v2,nv1, nv3, nv4, &t, NULL)){ float v1[3],v2[3]; float intrusiondepth,i1,i2; @@ -1552,26 +1556,26 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa } } mface++; - mima++; - }/* while a */ + mima++; + }/* while a */ } /* if(ob->pd && ob->pd->deflect) */ BLI_ghashIterator_step(ihash); } /* while () */ BLI_ghashIterator_free(ihash); - return deflected; + return deflected; } static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, int ifirst, int ilast, struct ListBase *do_effector) { SoftBody *sb = ob->soft; int a; - float damp; + float damp; float feedback[3]; if (sb && sb->totspring){ for(a=ifirst; abspring[a]; - bs->ext_force[0]=bs->ext_force[1]=bs->ext_force[2]=0.0f; + bs->ext_force[0]=bs->ext_force[1]=bs->ext_force[2]=0.0f; feedback[0]=feedback[1]=feedback[2]=0.0f; bs->flag &= ~BSF_INTERSECT; @@ -1590,10 +1594,10 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, /* ---- springs colliding */ /* +++ springs seeing wind ... n stuff depending on their orientation*/ - /* note we don't use sb->mediafrict but use sb->aeroedge for magnitude of effect*/ + /* note we don't use sb->mediafrict but use sb->aeroedge for magnitude of effect*/ if(sb->aeroedge){ float vel[3],sp[3],pr[3],force[3]; - float f,windfactor = 0.25f; + float f,windfactor = 0.25f; /*see if we have wind*/ if(do_effector) { EffectedPoint epoint; @@ -1604,7 +1608,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, pd_point_from_soft(scene, pos, vel, -1, &epoint); pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); - mul_v3_fl(speed,windfactor); + mul_v3_fl(speed,windfactor); add_v3_v3(vel, speed); } /* media in rest */ @@ -1614,7 +1618,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, f = normalize_v3(vel); f = -0.0001f*f*f*sb->aeroedge; /* (todo) add a nice angle dependant function done for now BUT */ - /* still there could be some nice drag/lift function, but who needs it */ + /* still there could be some nice drag/lift function, but who needs it */ VECSUB(sp, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos); project_v3_v3v3(pr,vel,sp); @@ -1624,7 +1628,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, normalize_v3(sp); Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(dot_v3v3(vel,sp))),vel); } - else{ + else{ Vec3PlusStVec(bs->ext_force,f,vel); // to keep compatible with 2.45 release files } } @@ -1638,8 +1642,8 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, static void scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow) { SoftBody *sb = ob->soft; - ListBase *do_effector = NULL; - + ListBase *do_effector = NULL; + do_effector = pdInitEffectors(scene, ob, NULL, sb->effector_weights); if (sb){ _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector); @@ -1652,11 +1656,11 @@ static void *exec_scan_for_ext_spring_forces(void *data) SB_thread_context *pctx = (SB_thread_context*)data; _scan_for_ext_spring_forces(pctx->scene, pctx->ob, pctx->timenow, pctx->ifirst, pctx->ilast, pctx->do_effector); return 0; -} +} static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,int totsprings,int *ptr_to_break_func()) { - ListBase *do_effector = NULL; + ListBase *do_effector = NULL; ListBase threads; SB_thread_context *sb_threads; int i, totthread,left,dec; @@ -1680,16 +1684,16 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow, dec = totsprings/totthread +1; for(i=0; i0){ sb_threads[i].ifirst = left; } else - sb_threads[i].ifirst = 0; + sb_threads[i].ifirst = 0; sb_threads[i].do_effector = do_effector; sb_threads[i].do_deflector = 0;// not used here sb_threads[i].fieldfactor = 0.0f;// not used here @@ -1709,7 +1713,7 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow, exec_scan_for_ext_spring_forces(&sb_threads[0]); /* clean up */ MEM_freeN(sb_threads); - + pdEndEffectors(&do_effector); } @@ -1733,10 +1737,10 @@ static int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,fl mindist = cp; winner =3; } - switch (winner){ - case 1: VECCOPY(w,ca); break; - case 2: VECCOPY(w,cb); break; - case 3: VECCOPY(w,cc); + switch (winner){ + case 1: VECCOPY(w,ca); break; + case 2: VECCOPY(w,cb); break; + case 3: VECCOPY(w,cc); } return(winner); } @@ -1751,7 +1755,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], GHash *hash; GHashIterator *ihash; float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3],d_nvect[3], dv1[3],ve[3],avel[3]={0.0,0.0,0.0}, - vv1[3], vv2[3], vv3[3], vv4[3], coledge[3]={0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f, + vv1[3], vv2[3], vv3[3], vv4[3], coledge[3]={0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f, outerforceaccu[3],innerforceaccu[3], facedist,n_mag,force_mag_norm,minx,miny,minz,maxx,maxy,maxz, innerfacethickness = -0.5f, outerfacethickness = 0.2f, @@ -1782,30 +1786,30 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], mima= ccdm->mima; a = ccdm->totface; - minx =ccdm->bbmin[0]; - miny =ccdm->bbmin[1]; + minx =ccdm->bbmin[0]; + miny =ccdm->bbmin[1]; minz =ccdm->bbmin[2]; - maxx =ccdm->bbmax[0]; - maxy =ccdm->bbmax[1]; - maxz =ccdm->bbmax[2]; + maxx =ccdm->bbmax[0]; + maxy =ccdm->bbmax[1]; + maxz =ccdm->bbmax[2]; - if ((opco[0] < minx) || + if ((opco[0] < minx) || (opco[1] < miny) || (opco[2] < minz) || - (opco[0] > maxx) || - (opco[1] > maxy) || + (opco[0] > maxx) || + (opco[1] > maxy) || (opco[2] > maxz) ) { - /* outside the padded boundbox --> collision object is too far away */ + /* outside the padded boundbox --> collision object is too far away */ BLI_ghashIterator_step(ihash); - continue; - } + continue; + } } else{ /*aye that should be cached*/ printf("missing cache error \n"); BLI_ghashIterator_step(ihash); - continue; + continue; } /* do object level stuff */ @@ -1819,12 +1823,12 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], /* use mesh*/ while (a--) { if ( - (opco[0] < mima->minx) || - (opco[0] > mima->maxx) || + (opco[0] < mima->minx) || + (opco[0] > mima->maxx) || (opco[1] < mima->miny) || - (opco[1] > mima->maxy) || + (opco[1] > mima->maxy) || (opco[2] < mima->minz) || - (opco[2] > mima->maxz) + (opco[2] > mima->maxz) ) { mface++; mima++; @@ -1833,7 +1837,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], if (mvert){ - VECCOPY(nv1,mvert[mface->v1].co); + VECCOPY(nv1,mvert[mface->v1].co); VECCOPY(nv2,mvert[mface->v2].co); VECCOPY(nv3,mvert[mface->v3].co); if (mface->v4){ @@ -1842,7 +1846,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], if (mprevvert){ /* grab the average speed of the collider vertices - before we spoil nvX + before we spoil nvX humm could be done once a SB steps but then we' need to store that too since the AABB reduced propabitlty to get here drasticallly it might be a nice tradeof CPU <--> memory @@ -1867,9 +1871,9 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } - } + } } - + /* switch origin to be nv2*/ VECSUB(edge1, nv1, nv2); VECSUB(edge2, nv3, nv2); @@ -1881,7 +1885,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], // so rules are // - if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){ + if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){ if (isect_point_tri_prism_v3(opco, nv1, nv2, nv3) ){ force_mag_norm =(float)exp(-ee*facedist); if (facedist > outerfacethickness*ff) @@ -1905,7 +1909,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], *intrusion += facedist; ci++; } - } + } if (mface->v4){ /* quad */ /* switch origin to be nv4 */ VECSUB(edge1, nv3, nv4); @@ -1948,7 +1952,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], float dist; closest_to_line_segment_v3(ve, opco, nv1, nv2); - VECSUB(ve,opco,ve); + VECSUB(ve,opco,ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); @@ -1957,7 +1961,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } closest_to_line_segment_v3(ve, opco, nv2, nv3); - VECSUB(ve,opco,ve); + VECSUB(ve,opco,ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); @@ -1966,7 +1970,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } closest_to_line_segment_v3(ve, opco, nv3, nv1); - VECSUB(ve,opco,ve); + VECSUB(ve,opco,ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); @@ -1975,7 +1979,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } if (mface->v4){ /* quad */ closest_to_line_segment_v3(ve, opco, nv3, nv4); - VECSUB(ve,opco,ve); + VECSUB(ve,opco,ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); @@ -1984,22 +1988,22 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } closest_to_line_segment_v3(ve, opco, nv1, nv4); - VECSUB(ve,opco,ve); + VECSUB(ve,opco,ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )){ VECCOPY(coledge,ve); mindistedge = dist, deflected=1; } - + } } } mface++; - mima++; - }/* while a */ + mima++; + }/* while a */ } /* if(ob->pd && ob->pd->deflect) */ BLI_ghashIterator_step(ihash); } /* while () */ @@ -2026,11 +2030,11 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], if (cavel) mul_v3_fl(avel,1.0f/(float)cavel); VECCOPY(vel,avel); if (ci) *intrusion /= ci; - if (deflected){ + if (deflected){ VECCOPY(facenormal,force); normalize_v3(facenormal); } - return deflected; + return deflected; } @@ -2038,7 +2042,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], static int sb_deflect_face(Object *ob,float *actpos,float *facenormal,float *force,float *cf,float time,float *vel,float *intrusion) { float s_actpos[3]; - int deflected; + int deflected; VECCOPY(s_actpos,actpos); deflected= sb_detect_vertex_collisionCached(s_actpos, facenormal, cf, force , ob->lay, ob,time,vel,intrusion); //deflected= sb_detect_vertex_collisionCachedEx(s_actpos, facenormal, cf, force , ob->lay, ob,time,vel,intrusion); @@ -2047,7 +2051,7 @@ static int sb_deflect_face(Object *ob,float *actpos,float *facenormal,float *for /* hiding this for now .. but the jacobian may pop up on other tasks .. so i'd like to keep it static void dfdx_spring(int ia, int ic, int op, float dir[3],float L,float len,float factor) -{ +{ float m,delta_ij; int i ,j; if (L < len){ @@ -2069,13 +2073,13 @@ static void dfdx_spring(int ia, int ic, int op, float dir[3],float L,float len,f static void dfdx_goal(int ia, int ic, int op, float factor) -{ +{ int i; for(i=0;i<3;i++) nlMatrixAdd(ia+i,op+ic+i,factor); } static void dfdv_goal(int ia, int ic,float factor) -{ +{ int i; for(i=0;i<3;i++) nlMatrixAdd(ia+i,ic+i,factor); } @@ -2125,13 +2129,13 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo kw = kw * kw; switch (bs->springtype){ case SB_EDGE: - forcefactor *= kw; + forcefactor *= kw; break; case SB_BEND: - forcefactor *=sb->secondspring*kw; + forcefactor *=sb->secondspring*kw; break; case SB_STIFFQUAD: - forcefactor *=sb->shearstiff*sb->shearstiff* kw; + forcefactor *=sb->shearstiff*sb->shearstiff* kw; break; default: break; @@ -2153,12 +2157,12 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo //int op =3*sb->totpoint; //float mvel = -forcetime*kd; //float mpos = -forcetime*forcefactor; - /* depending on my pos */ + /* depending on my pos */ // dfdx_spring(ia,ia,op,dir,bs->len,distance,-mpos); /* depending on my vel */ // dfdv_goal(ia,ia,mvel); // well that ignores geometie if(bp2->goal < SOFTGOALSNAP){ /* ommit this bp when it snaps */ - /* depending on other pos */ + /* depending on other pos */ // dfdx_spring(ia,ic,op,dir,bs->len,distance,mpos); /* depending on other vel */ // dfdv_goal(ia,ia,-mvel); // well that ignores geometie @@ -2177,7 +2181,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo int number_of_points_here = ilast - ifirst; SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bp; - + /* intitialize */ if (sb) { /* check conditions for various options */ @@ -2200,7 +2204,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* debugerin */ - bp = &sb->bpoint[ifirst]; + bp = &sb->bpoint[ifirst]; for(bb=number_of_points_here; bb>0; bb--, bp++) { /* clear forces accumulator */ bp->force[0]= bp->force[1]= bp->force[2]= 0.0; @@ -2209,7 +2213,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if(do_selfcollision){ int attached; BodyPoint *obp; - BodySpring *bs; + BodySpring *bs; int c,b; float velcenter[3],dvel[3],def[3]; float distance; @@ -2217,7 +2221,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo float bstune = sb->ballstiff; for(c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) { - compare = (obp->colball + bp->colball); + compare = (obp->colball + bp->colball); sub_v3_v3v3(def, bp->pos, obp->pos); /* rather check the AABBoxes before ever calulating the real distance */ /* mathematically it is completly nuts, but performace is pretty much (3) times faster */ @@ -2255,7 +2259,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* naive ball self collision done */ if(_final_goal(ob,bp) < SOFTGOALSNAP){ /* ommit this bp when it snaps */ - float auxvect[3]; + float auxvect[3]; float velgoal[3]; /* do goal stuff */ @@ -2272,7 +2276,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo sub_v3_v3v3(velgoal,bp->origS, bp->origE); kd = sb->goalfrict * sb_fric_force_scale(ob) ; add_v3_v3v3(auxvect,velgoal,bp->vec); - + if (forcetime > 0.0 ) { /* make sure friction does not become rocket motor on time reversal */ bp->force[0]-= kd * (auxvect[0]); bp->force[1]-= kd * (auxvect[1]); @@ -2285,15 +2289,15 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo } } /* done goal stuff */ - + /* gravitation */ - if (sb && scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ + if (sb && scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ float gravity[3]; VECCOPY(gravity, scene->physics_settings.gravity); mul_v3_fl(gravity, sb_grav_force_scale(ob)*_final_mass(ob,bp)*sb->effector_weights->global_gravity); /* individual mass of node here */ add_v3_v3(bp->force, gravity); } - + /* particle field & vortex */ if(do_effector) { EffectedPoint epoint; @@ -2303,22 +2307,22 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */ pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint-bp, &epoint); pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); - + /* apply forcefield*/ - mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale); + mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale); VECADD(bp->force, bp->force, force); - - /* BP friction in moving media */ - kd= sb->mediafrict* eval_sb_fric_force_scale; + + /* BP friction in moving media */ + kd= sb->mediafrict* eval_sb_fric_force_scale; bp->force[0] -= kd * (bp->vec[0] + windfactor*speed[0]/eval_sb_fric_force_scale); bp->force[1] -= kd * (bp->vec[1] + windfactor*speed[1]/eval_sb_fric_force_scale); bp->force[2] -= kd * (bp->vec[2] + windfactor*speed[2]/eval_sb_fric_force_scale); /* now we'll have nice centrifugal effect for vortex */ - + } else { /* BP friction in media (not) moving*/ - float kd = sb->mediafrict* sb_fric_force_scale(ob); + float kd = sb->mediafrict* sb_fric_force_scale(ob); /* assume it to be proportional to actual velocity */ bp->force[0]-= bp->vec[0]*kd; bp->force[1]-= bp->vec[1]*kd; @@ -2328,22 +2332,22 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* +++cached collision targets */ bp->choke = 0.0f; bp->choke2 = 0.0f; - bp->flag &= ~SBF_DOFUZZY; - if(do_deflector) { + bp->loc_flag &= ~SBF_DOFUZZY; + if(do_deflector && !(bp->loc_flag & SBF_OUTOFCOLLISION) ) { float cfforce[3],defforce[3] ={0.0f,0.0f,0.0f}, vel[3] = {0.0f,0.0f,0.0f}, facenormal[3], cf = 1.0f,intrusion; float kd = 1.0f; if (sb_deflect_face(ob,bp->pos,facenormal,defforce,&cf,timenow,vel,&intrusion)){ if (intrusion < 0.0f){ sb->scratch->flag |= SBF_DOFUZZY; - bp->flag |= SBF_DOFUZZY; + bp->loc_flag |= SBF_DOFUZZY; bp->choke = sb->choke*0.01f; } VECSUB(cfforce,bp->vec,vel); Vec3PlusStVec(bp->force,-cf*50.0f,cfforce); - - Vec3PlusStVec(bp->force,kd,defforce); + + Vec3PlusStVec(bp->force,kd,defforce); } } @@ -2354,19 +2358,19 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if(ob->softflag & OB_SB_EDGES) { if (sb->bspring){ /* spring list exists at all ? */ int b; - BodySpring *bs; + BodySpring *bs; for(b=bp->nofsprings;b>0;b--){ bs = sb->bspring + bp->springs[b-1]; if (do_springcollision || do_aero){ add_v3_v3(bp->force, bs->ext_force); if (bs->flag & BSF_INTERSECT) - bp->choke = bs->cf; + bp->choke = bs->cf; } // sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float forcetime,int nl_flags) sb_spring_force(ob,ilast-bb,bs,iks,forcetime,0); }/* loop springs */ - }/* existing spring list */ + }/* existing spring list */ }/*any edges*/ /* ---springs */ }/*omit on snap */ @@ -2379,7 +2383,7 @@ static void *exec_softbody_calc_forces(void *data) SB_thread_context *pctx = (SB_thread_context*)data; _softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->do_effector,pctx->do_deflector,pctx->fieldfactor,pctx->windfactor); return 0; -} +} static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow,int totpoint,int *ptr_to_break_func(),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) { @@ -2406,16 +2410,16 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t dec = totpoint/totthread +1; for(i=0; i0){ sb_threads[i].ifirst = left; } else - sb_threads[i].ifirst = 0; + sb_threads[i].ifirst = 0; sb_threads[i].do_effector = do_effector; sb_threads[i].do_deflector = do_deflector; sb_threads[i].fieldfactor = fieldfactor; @@ -2441,30 +2445,30 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, float timenow, int nl_flags) { -/* rule we never alter free variables :bp->vec bp->pos in here ! - * this will ruin adaptive stepsize AKA heun! (BM) +/* rule we never alter free variables :bp->vec bp->pos in here ! + * this will ruin adaptive stepsize AKA heun! (BM) */ SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bproot; ListBase *do_effector = NULL; float iks, gravity; - float fieldfactor = -1.0f, windfactor = 0.25; + float fieldfactor = -1.0f, windfactor = 0.25; int do_deflector,do_selfcollision,do_springcollision,do_aero; - - gravity = sb->grav * sb_grav_force_scale(ob); - + + gravity = sb->grav * sb_grav_force_scale(ob); + /* check conditions for various options */ do_deflector= query_external_colliders(scene, ob); do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); - + iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */ bproot= sb->bpoint; /* need this for proper spring addressing */ - - if (do_springcollision || do_aero) - sb_sfesf_threads_run(scene, ob, timenow,sb->totspring,NULL); - + + if (do_springcollision || do_aero) + sb_sfesf_threads_run(scene, ob, timenow,sb->totspring,NULL); + /* after spring scan because it uses Effoctors too */ do_effector= pdInitEffectors(scene, ob, NULL, sb->effector_weights); @@ -2477,7 +2481,7 @@ static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, fl /* finally add forces caused by face collision */ if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob,timenow); - + /* finish matrix and solve */ pdEndEffectors(&do_effector); } @@ -2497,20 +2501,20 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* |||||||||||||||||||||||||| */ /* VVVVVVVVVVVVVVVVVVVVVVVVVV */ /*backward compatibility note: - fixing bug [17428] which forces adaptive step size to tiny steps - in some situations + fixing bug [17428] which forces adaptive step size to tiny steps + in some situations .. keeping G.rt==17 0x11 option for old files 'needing' the bug*/ - /* rule we never alter free variables :bp->vec bp->pos in here ! - * this will ruin adaptive stepsize AKA heun! (BM) + /* rule we never alter free variables :bp->vec bp->pos in here ! + * this will ruin adaptive stepsize AKA heun! (BM) */ SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bp; BodyPoint *bproot; - BodySpring *bs; + BodySpring *bs; ListBase *do_effector = NULL; float iks, ks, kd, gravity[3] = {0.0f,0.0f,0.0f}; - float fieldfactor = -1.0f, windfactor = 0.25f; + float fieldfactor = -1.0f, windfactor = 0.25f; float tune = sb->ballstiff; int a, b, do_deflector,do_selfcollision,do_springcollision,do_aero; @@ -2525,10 +2529,10 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa */ - if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ + if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ VECCOPY(gravity, scene->physics_settings.gravity); mul_v3_fl(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity); - } + } /* check conditions for various options */ do_deflector= query_external_colliders(scene, ob); @@ -2554,7 +2558,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if(nl_flags & NLF_BUILD){ //int ia =3*(sb->totpoint-a); //int op =3*sb->totpoint; - /* dF/dV = v */ + /* dF/dV = v */ /* jacobioan nlMatrixAdd(op+ia,ia,-forcetime); nlMatrixAdd(op+ia+1,ia+1,-forcetime); @@ -2586,7 +2590,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa //if ((bp->octantflag & obp->octantflag) == 0) continue; - compare = (obp->colball + bp->colball); + compare = (obp->colball + bp->colball); sub_v3_v3v3(def, bp->pos, obp->pos); /* rather check the AABBoxes before ever calulating the real distance */ @@ -2630,11 +2634,11 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /*TODO sit down an X-out the true jacobian entries*/ /*well does not make to much sense because the eigenvalues of the jacobian go negative; and negative eigenvalues - on a complex iterative system z(n+1)=A * z(n) + on a complex iterative system z(n+1)=A * z(n) give imaginary roots in the charcateristic polynom - --> solutions that to z(t)=u(t)* exp ( i omega t) --> oscilations we don't want here + --> solutions that to z(t)=u(t)* exp ( i omega t) --> oscilations we don't want here where u(t) is a unknown amplitude function (worst case rising fast) - */ + */ } /* exploit force(a,b) == -force(b,a) part2/2 */ @@ -2652,7 +2656,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* naive ball self collision done */ if(_final_goal(ob,bp) < SOFTGOALSNAP){ /* ommit this bp when it snaps */ - float auxvect[3]; + float auxvect[3]; float velgoal[3]; /* do goal stuff */ @@ -2667,7 +2671,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if(nl_flags & NLF_BUILD){ //int ia =3*(sb->totpoint-a); //int op =3*(sb->totpoint); - /* depending on my pos */ + /* depending on my pos */ //dfdx_goal(ia,ia,op,ks*forcetime); } @@ -2684,7 +2688,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if(nl_flags & NLF_BUILD){ //int ia =3*(sb->totpoint-a); normalize_v3(auxvect); - /* depending on my vel */ + /* depending on my vel */ //dfdv_goal(ia,ia,kd*forcetime); } @@ -2712,11 +2716,11 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); /* apply forcefield*/ - mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale); + mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale); VECADD(bp->force, bp->force, force); - /* BP friction in moving media */ - kd= sb->mediafrict* eval_sb_fric_force_scale; + /* BP friction in moving media */ + kd= sb->mediafrict* eval_sb_fric_force_scale; bp->force[0] -= kd * (bp->vec[0] + windfactor*speed[0]/eval_sb_fric_force_scale); bp->force[1] -= kd * (bp->vec[1] + windfactor*speed[1]/eval_sb_fric_force_scale); bp->force[2] -= kd * (bp->vec[2] + windfactor*speed[2]/eval_sb_fric_force_scale); @@ -2725,7 +2729,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa } else { /* BP friction in media (not) moving*/ - kd= sb->mediafrict* sb_fric_force_scale(ob); + kd= sb->mediafrict* sb_fric_force_scale(ob); /* assume it to be proportional to actual velocity */ bp->force[0]-= bp->vec[0]*kd; bp->force[1]-= bp->vec[1]*kd; @@ -2733,7 +2737,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* friction in media done */ if(nl_flags & NLF_BUILD){ //int ia =3*(sb->totpoint-a); - /* da/dv = */ + /* da/dv = */ // nlMatrixAdd(ia,ia,forcetime*kd); // nlMatrixAdd(ia+1,ia+1,forcetime*kd); @@ -2744,7 +2748,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* +++cached collision targets */ bp->choke = 0.0f; bp->choke2 = 0.0f; - bp->flag &= ~SBF_DOFUZZY; + bp->loc_flag &= ~SBF_DOFUZZY; if(do_deflector) { float cfforce[3],defforce[3] ={0.0f,0.0f,0.0f}, vel[3] = {0.0f,0.0f,0.0f}, facenormal[3], cf = 1.0f,intrusion; kd = 1.0f; @@ -2752,15 +2756,15 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if (sb_deflect_face(ob,bp->pos,facenormal,defforce,&cf,timenow,vel,&intrusion)){ if ((!nl_flags)&&(intrusion < 0.0f)){ if(G.rt & 0x01){ // 17 we did check for bit 0x10 before - /*fixing bug [17428] this forces adaptive step size to tiny steps + /*fixing bug [17428] this forces adaptive step size to tiny steps in some situations .. keeping G.rt==17 option for old files 'needing' the bug */ - /*bjornmose: uugh.. what an evil hack - violation of the 'don't touch bp->pos in here' rule + /*bjornmose: uugh.. what an evil hack + violation of the 'don't touch bp->pos in here' rule but works nice, like this--> we predict the solution beeing out of the collider in heun step No1 and leave the heun step No2 adapt to it - so we kind of introduced a implicit solver for this case + so we kind of introduced a implicit solver for this case */ Vec3PlusStVec(bp->pos,-intrusion,facenormal); } @@ -2772,7 +2776,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa sb->scratch->flag |= SBF_DOFUZZY; - bp->flag |= SBF_DOFUZZY; + bp->loc_flag |= SBF_DOFUZZY; bp->choke = sb->choke*0.01f; } else{ @@ -2801,14 +2805,14 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if (do_springcollision || do_aero){ add_v3_v3(bp->force, bs->ext_force); if (bs->flag & BSF_INTERSECT) - bp->choke = bs->cf; + bp->choke = bs->cf; } // sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float forcetime,int nl_flags) // rather remove nl_falgs from code .. will make things a lot cleaner sb_spring_force(ob,sb->totpoint-a,bs,iks,forcetime,0); }/* loop springs */ - }/* existing spring list */ + }/* existing spring list */ }/*any edges*/ /* ---springs */ }/*omit on snap */ @@ -2833,7 +2837,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa nlEnd(NL_SYSTEM); if ((G.rt == 32) && (nl_flags & NLF_BUILD)) - { + { printf("####MEE#####\n"); nlPrintMatrix(); } @@ -2905,7 +2909,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * int a,fuzzy=0; forcetime *= sb_time_scale(ob); - + aabbmin[0]=aabbmin[1]=aabbmin[2] = 1e20f; aabbmax[0]=aabbmax[1]=aabbmax[2] = -1e20f; @@ -2915,7 +2919,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * if (sb->nodemass > 0.009999f) timeovermass = forcetime/sb->nodemass; else timeovermass = forcetime/0.009999f; */ - + for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { /* now we have individual masses */ /* claim a minimum mass for vertex */ @@ -2926,14 +2930,14 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * if(_final_goal(ob,bp) < SOFTGOALSNAP){ /* this makes t~ = t */ if(mid_flags & MID_PRESERVE) VECCOPY(dx,bp->vec); - + /* so here is (v)' = a(cceleration) = sum(F_springs)/m + gravitation + some friction forces + more forces*/ /* the ( ... )' operator denotes derivate respective time */ /* the euler step for velocity then becomes */ - /* v(t + dt) = v(t) + a(t) * dt */ + /* v(t + dt) = v(t) + a(t) * dt */ mul_v3_fl(bp->force,timeovermass);/* individual mass of node here */ /* some nasty if's to have heun in here too */ - VECCOPY(dv,bp->force); + VECCOPY(dv,bp->force); if (mode == 1){ VECCOPY(bp->prevvec, bp->vec); @@ -2957,7 +2961,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* so here is (x)'= v(elocity) */ /* the euler step for location then becomes */ - /* x(t + dt) = x(t) + v(t~) * dt */ + /* x(t + dt) = x(t) + v(t~) * dt */ mul_v3_fl(dx,forcetime); /* the freezer coming sooner or later */ @@ -2975,7 +2979,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * VECCOPY(bp->prevpos,bp->pos); VECCOPY(bp->prevdx ,dx); } - + if (mode ==2){ bp->pos[0] = bp->prevpos[0] + 0.5f * ( dx[0] + bp->prevdx[0]); bp->pos[1] = bp->prevpos[1] + 0.5f * ( dx[1] + bp->prevdx[1]); @@ -2984,9 +2988,9 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * maxerrpos = MAX2(maxerrpos,ABS(dx[1] - bp->prevdx[1])); maxerrpos = MAX2(maxerrpos,ABS(dx[2] - bp->prevdx[2])); -/* bp->choke is set when we need to pull a vertex or edge out of the collider. - the collider object signals to get out by pushing hard. on the other hand - we don't want to end up in deep space so we add some +/* bp->choke is set when we need to pull a vertex or edge out of the collider. + the collider object signals to get out by pushing hard. on the other hand + we don't want to end up in deep space so we add some to balance that out */ if (bp->choke2 > 0.0f){ mul_v3_fl(bp->vec,(1.0f - bp->choke2)); @@ -3005,7 +3009,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * aabbmax[0] = MAX2(aabbmax[0],bp->pos[0]); aabbmax[1] = MAX2(aabbmax[1],bp->pos[1]); aabbmax[2] = MAX2(aabbmax[2],bp->pos[2]); - if (bp->flag & SBF_DOFUZZY) fuzzy =1; + if (bp->loc_flag & SBF_DOFUZZY) fuzzy =1; } /*for*/ if (sb->totpoint) mul_v3_fl(cm,1.0f/sb->totpoint); @@ -3013,7 +3017,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * VECCOPY(sb->scratch->aabbmin,aabbmin); VECCOPY(sb->scratch->aabbmax,aabbmax); } - + if (err){ /* so step size will be controlled by biggest difference in slope */ if (sb->solverflags & SBSO_OLDERR) *err = MAX2(maxerrpos,maxerrvel); @@ -3032,7 +3036,7 @@ static void softbody_restore_prev_step(Object *ob) SoftBody *sb= ob->soft; /* is supposed to be there*/ BodyPoint *bp; int a; - + for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { VECCOPY(bp->vec, bp->prevvec); VECCOPY(bp->pos, bp->prevpos); @@ -3045,7 +3049,7 @@ static void softbody_store_step(Object *ob) SoftBody *sb= ob->soft; /* is supposed to be there*/ BodyPoint *bp; int a; - + for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { VECCOPY(bp->prevvec,bp->vec); VECCOPY(bp->prevpos,bp->pos); @@ -3060,12 +3064,12 @@ static void softbody_store_state(Object *ob,float *ppos,float *pvel) BodyPoint *bp; int a; float *pp=ppos,*pv=pvel; - + for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - - VECCOPY(pv, bp->vec); + + VECCOPY(pv, bp->vec); pv+=3; - + VECCOPY(pp, bp->pos); pp+=3; } @@ -3078,12 +3082,12 @@ static void softbody_retrieve_state(Object *ob,float *ppos,float *pvel) BodyPoint *bp; int a; float *pp=ppos,*pv=pvel; - + for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - - VECCOPY(bp->vec,pv); + + VECCOPY(bp->vec,pv); pv+=3; - + VECCOPY(bp->pos,pp); pp+=3; } @@ -3097,17 +3101,17 @@ static void softbody_swap_state(Object *ob,float *ppos,float *pvel) int a; float *pp=ppos,*pv=pvel; float temp[3]; - + for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - - VECCOPY(temp, bp->vec); - VECCOPY(bp->vec,pv); - VECCOPY(pv,temp); + + VECCOPY(temp, bp->vec); + VECCOPY(bp->vec,pv); + VECCOPY(pv,temp); pv+=3; - + VECCOPY(temp, bp->pos); - VECCOPY(bp->pos,pp); - VECCOPY(pp,temp); + VECCOPY(bp->pos,pp); + VECCOPY(pp,temp); pp+=3; } } @@ -3116,8 +3120,8 @@ static void softbody_swap_state(Object *ob,float *ppos,float *pvel) /* care for bodypoints taken out of the 'ordinary' solver step ** because they are screwed to goal by bolts -** they just need to move along with the goal in time -** we need to adjust them on sub frame timing in solver +** they just need to move along with the goal in time +** we need to adjust them on sub frame timing in solver ** so now when frame is done .. put 'em to the position at the end of frame */ static void softbody_apply_goalsnap(Object *ob) @@ -3125,12 +3129,12 @@ static void softbody_apply_goalsnap(Object *ob) SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bp; int a; - + for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { if (_final_goal(ob,bp) >= SOFTGOALSNAP){ VECCOPY(bp->prevpos,bp->pos); VECCOPY(bp->pos,bp->origT); - } + } } } @@ -3165,20 +3169,20 @@ static void interpolate_exciter(Object *ob, int timescale, int time) BodyPoint *bp; float f; int a; - + f = (float)time/(float)timescale; - - for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - bp->origT[0] = bp->origS[0] + f*(bp->origE[0] - bp->origS[0]); - bp->origT[1] = bp->origS[1] + f*(bp->origE[1] - bp->origS[1]); - bp->origT[2] = bp->origS[2] + f*(bp->origE[2] - bp->origS[2]); + + for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { + bp->origT[0] = bp->origS[0] + f*(bp->origE[0] - bp->origS[0]); + bp->origT[1] = bp->origS[1] + f*(bp->origE[1] - bp->origS[1]); + bp->origT[2] = bp->origS[2] + f*(bp->origE[2] - bp->origS[2]); if (_final_goal(ob,bp) >= SOFTGOALSNAP){ bp->vec[0] = bp->origE[0] - bp->origS[0]; bp->vec[1] = bp->origE[1] - bp->origS[1]; bp->vec[2] = bp->origE[2] - bp->origS[2]; } } - + } @@ -3191,13 +3195,13 @@ static void interpolate_exciter(Object *ob, int timescale, int time) static void get_scalar_from_vertexgroup(Object *ob, int vertID, short groupindex, float *target) /* result 0 on success, else indicates error number -- kind of *inverse* result defintion, --- but this way we can signal error condition to caller +-- but this way we can signal error condition to caller -- and yes this function must not be here but in a *vertex group module* */ { MDeformVert *dv= NULL; int i; - + /* spot the vert in deform vert list at mesh */ if(ob->type==OB_MESH) { Mesh *me= ob->data; @@ -3218,10 +3222,10 @@ static void get_scalar_from_vertexgroup(Object *ob, int vertID, short groupindex } } } -} +} -/* Resetting a Mesh SB object's springs */ -/* Spring lenght are caculted from'raw' mesh vertices that are NOT altered by modifier stack. */ +/* Resetting a Mesh SB object's springs */ +/* Spring lenght are caculted from'raw' mesh vertices that are NOT altered by modifier stack. */ static void springs_from_mesh(Object *ob) { SoftBody *sb; @@ -3229,21 +3233,21 @@ static void springs_from_mesh(Object *ob) BodyPoint *bp; int a; float scale =1.0f; - - sb= ob->soft; + + sb= ob->soft; if (me && sb) - { + { /* using bp->origS as a container for spring calcualtions here - ** will be overwritten sbObjectStep() to receive + ** will be overwritten sbObjectStep() to receive ** actual modifier stack positions */ - if(me->totvert) { + if(me->totvert) { bp= ob->soft->bpoint; for(a=0; atotvert; a++, bp++) { - VECCOPY(bp->origS, me->mvert[a].co); + VECCOPY(bp->origS, me->mvert[a].co); mul_m4_v3(ob->obmat, bp->origS); } - + } /* recalculate spring length for meshes here */ /* public version shrink to fit */ @@ -3271,21 +3275,21 @@ static void mesh_to_softbody(Scene *scene, Object *ob) int a, totedge; if (ob->softflag & OB_SB_EDGES) totedge= me->totedge; else totedge= 0; - + /* renew ends with ob->soft with points and edges, also checks & makes ob->soft */ renew_softbody(scene, ob, me->totvert, totedge); - + /* we always make body points */ - sb= ob->soft; + sb= ob->soft; bp= sb->bpoint; - + for(a=0; atotvert; a++, bp++) { /* get scalar values needed *per vertex* from vertex group functions, - so we can *paint* them nicly .. + so we can *paint* them nicly .. they are normalized [0.0..1.0] so may be we need amplitude for scale - which can be done by caller but still .. i'd like it to go this way - */ - + which can be done by caller but still .. i'd like it to go this way + */ + if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { /* even this is a deprecated evil hack */ /* I'd like to have it .. if (sb->namedVG_Goal[0]) */ @@ -3300,9 +3304,9 @@ static void mesh_to_softbody(Scene *scene, Object *ob) else{ /* in consequence if no group was set .. but we want to animate it laters */ /* logically attach to goal with default first */ - if(ob->softflag & OB_SB_GOAL){bp->goal =sb->defgoal;} + if(ob->softflag & OB_SB_GOAL){bp->goal =sb->defgoal;} } - + /* to proove the concept this enables per vertex *mass painting* */ @@ -3324,7 +3328,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) if (sb->namedVG_Spring_K[0]) { int grp= defgroup_name_index (ob,sb->namedVG_Spring_K); - //printf("VGN %s %d \n",sb->namedVG_Spring_K,grp); + //printf("VGN %s %d \n",sb->namedVG_Spring_K,grp); if(grp > -1){ get_scalar_from_vertexgroup(ob, a,(short) (grp), &bp->springweight); //printf("bp->springweight %f \n",bp->springweight); @@ -3332,7 +3336,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) } } - + } /* but we only optionally add body edge springs */ @@ -3344,13 +3348,13 @@ static void mesh_to_softbody(Scene *scene, Object *ob) bs->v2= medge->v2; bs->springtype=SB_EDGE; } - - + + /* insert *diagonal* springs in quads if desired */ if (ob->softflag & OB_SB_QUADS) { add_mesh_quad_diag_springs(ob); } - + build_bps_springlist(ob); /* scan for springs attached to bodypoints ONCE */ /* insert *other second order* springs if desired */ if (sb->secondspring > 0.0000001f) { @@ -3359,22 +3363,22 @@ static void mesh_to_softbody(Scene *scene, Object *ob) } springs_from_mesh(ob); /* write the 'rest'-lenght of the springs */ if (ob->softflag & OB_SB_SELF) {calculate_collision_balls(ob);} - + } - + } } static void mesh_faces_to_scratch(Object *ob) { - SoftBody *sb= ob->soft; + SoftBody *sb= ob->soft; Mesh *me= ob->data; MFace *mface; BodyFace *bodyface; int a; /* alloc and copy faces*/ - + bodyface = sb->scratch->bodyface = MEM_mallocN(sizeof(BodyFace)*me->totface,"SB_body_Faces"); //memcpy(sb->scratch->mface,me->mface,sizeof(MFace)*me->totface); mface = me->mface; @@ -3384,13 +3388,13 @@ static void mesh_faces_to_scratch(Object *ob) bodyface->v3 = mface->v3; bodyface->v4 = mface->v4; bodyface->ext_force[0] = bodyface->ext_force[1] = bodyface->ext_force[2] = 0.0f; - bodyface->flag =0; + bodyface->flag =0; } sb->scratch->totface = me->totface; } static void reference_to_scratch(Object *ob) { - SoftBody *sb= ob->soft; + SoftBody *sb= ob->soft; ReferenceVert *rp; BodyPoint *bp; float accu_pos[3] ={0.f,0.f,0.f}; @@ -3411,14 +3415,14 @@ static void reference_to_scratch(Object *ob) } /* -helper function to get proper spring length +helper function to get proper spring length when object is rescaled */ static float globallen(float *v1,float *v2,Object *ob) { float p1[3],p2[3]; VECCOPY(p1,v1); - mul_m4_v3(ob->obmat, p1); + mul_m4_v3(ob->obmat, p1); VECCOPY(p2,v2); mul_m4_v3(ob->obmat, p2); return len_v3v3(p1,p2); @@ -3428,16 +3432,16 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object * { BPoint *bp=lt->def, *bpu; int u, v, w, dv, dw, bpc=0, bpuc; - + dv= lt->pntsu; dw= dv*lt->pntsv; - + for(w=0; wpntsw; w++) { - + for(v=0; vpntsv; v++) { - + for(u=0, bpuc=0, bpu=NULL; upntsu; u++, bp++, bpc++) { - + if(w) { bs->v1 = bpc; bs->v2 = bpc-dw; @@ -3459,7 +3463,7 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object * bs->len= globallen((bpu)->vec, bp->vec,ob); bs++; } - + if (dostiff) { if(w){ @@ -3469,14 +3473,14 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object * bs->springtype=SB_BEND; bs->len= globallen((bp-dw-dv-1)->vec, bp->vec,ob); bs++; - } + } if( (v < lt->pntsv-1) && (u) ) { bs->v1 = bpc; bs->v2 = bpc-dw+dv-1; bs->springtype=SB_BEND; bs->len= globallen((bp-dw+dv-1)->vec, bp->vec,ob); bs++; - } + } } if(w < lt->pntsw -1){ @@ -3486,14 +3490,14 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object * bs->springtype=SB_BEND; bs->len= globallen((bp+dw-dv-1)->vec, bp->vec,ob); bs++; - } + } if( (v < lt->pntsv-1) && (u) ) { bs->v1 = bpc; bs->v2 = bpc+dw+dv-1; bs->springtype=SB_BEND; bs->len= globallen((bp+dw+dv-1)->vec, bp->vec,ob); bs++; - } + } } } bpu = bp; @@ -3514,19 +3518,19 @@ static void lattice_to_softbody(Scene *scene, Object *ob) totvert= lt->pntsu*lt->pntsv*lt->pntsw; if (ob->softflag & OB_SB_EDGES){ - totspring = ((lt->pntsu -1) * lt->pntsv + totspring = ((lt->pntsu -1) * lt->pntsv + (lt->pntsv -1) * lt->pntsu) * lt->pntsw +lt->pntsu*lt->pntsv*(lt->pntsw -1); if (ob->softflag & OB_SB_QUADS){ totspring += 4*(lt->pntsu -1) * (lt->pntsv -1) * (lt->pntsw-1); } } - + /* renew ends with ob->soft with points and edges, also checks & makes ob->soft */ renew_softbody(scene, ob, totvert, totspring); sb= ob->soft; /* can be created in renew_softbody() */ - + /* weights from bpoints, same code used as for mesh vertices */ /* if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { 2.4x one*/ /* new! take the weights from lattice vertex anyhow */ @@ -3539,8 +3543,8 @@ static void lattice_to_softbody(Scene *scene, Object *ob) for(a=0; agoal= bpnt->weight; } - } - + } + /* create some helper edges to enable SB lattice to be usefull at all */ if (ob->softflag & OB_SB_EDGES){ makelatticesprings(lt,ob->soft->bspring,ob->softflag & OB_SB_QUADS,ob); @@ -3560,44 +3564,47 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) BPoint *bpnt; int a, curindex=0; int totvert, totspring = 0, setgoal=0; - + totvert= count_curveverts(&cu->nurb); - + if (ob->softflag & OB_SB_EDGES){ if(ob->type==OB_CURVE) { totspring= totvert - BLI_countlist(&cu->nurb); } } - + /* renew ends with ob->soft with points and edges, also checks & makes ob->soft */ renew_softbody(scene, ob, totvert, totspring); sb= ob->soft; /* can be created in renew_softbody() */ - + /* set vars now */ bp= sb->bpoint; bs= sb->bspring; - + /* weights from bpoints, same code used as for mesh vertices */ /* if((ob->softflag & OB_SB_GOAL) && sb->vertgroup) 2.4x hack*/ /* new! take the weights from curve vertex anyhow */ - if(ob->softflag & OB_SB_GOAL) + if(ob->softflag & OB_SB_GOAL) setgoal= 1; - + for(nu= cu->nurb.first; nu; nu= nu->next) { - if(nu->bezt) { + if(nu->bezt) { /* bezier case ; this is nicly said naive; who ever wrote this part, it was not me (JOW) :) */ - /* a: never ever make tangent handles (sub) and or (ob)ject to collision */ + /* a: never ever make tangent handles (sub) and or (ob)ject to collision */ /* b: rather calculate them using some C2 (C2= continous in second derivate -> no jump in bending ) condition */ /* not too hard to do, but needs some more code to care for; some one may want look at it JOW 2010/06/12*/ for(bezt=nu->bezt, a=0; apntsu; a++, bezt++, bp+=3, curindex+=3) { if(setgoal) { bp->goal= bezt->weight; - + /* all three triples */ (bp+1)->goal= bp->goal; (bp+2)->goal= bp->goal; + /*do not collide handles */ + (bp+1)->loc_flag |= SBF_OUTOFCOLLISION; + (bp+2)->loc_flag |= SBF_OUTOFCOLLISION; } - + if(totspring) { if(a>0) { bs->v1= curindex-1; @@ -3635,7 +3642,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) } } } - + if(totspring) { build_bps_springlist(ob); /* link bps to springs */ @@ -3656,7 +3663,7 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, for(a=0; apos); - if(local==0) + if(local==0) mul_m4_v3(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */ } } @@ -3673,7 +3680,7 @@ static void sb_new_scratch(SoftBody *sb) sb->scratch->aabbmax[0]=sb->scratch->aabbmax[1]=sb->scratch->aabbmax[2] = 1.0e30f; sb->scratch->aabbmin[0]=sb->scratch->aabbmin[1]=sb->scratch->aabbmin[2] = -1.0e30f; sb->scratch->Ref.ivert = NULL; - + } /* --- ************ maintaining scratch *************** */ @@ -3683,26 +3690,26 @@ static void sb_new_scratch(SoftBody *sb) SoftBody *sbNew(Scene *scene) { SoftBody *sb; - + sb= MEM_callocN(sizeof(SoftBody), "softbody"); - - sb->mediafrict= 0.5f; + + sb->mediafrict= 0.5f; sb->nodemass= 1.0f; - sb->grav= 9.8f; + sb->grav= 9.8f; sb->physics_speed= 1.0f; sb->rklimit= 0.1f; - sb->goalspring= 0.5f; - sb->goalfrict= 0.0f; - sb->mingoal= 0.0f; + sb->goalspring= 0.5f; + sb->goalfrict= 0.0f; + sb->mingoal= 0.0f; sb->maxgoal= 1.0f; sb->defgoal= 0.7f; - + sb->inspring= 0.5f; - sb->infrict= 0.5f; + sb->infrict= 0.5f; /*todo backward file compat should copy inspring to inpush while reading old files*/ - sb->inpush = 0.5f; - + sb->inpush = 0.5f; + sb->interval= 10; sb->sfra= scene->r.sfra; sb->efra= scene->r.efra; @@ -3754,7 +3761,7 @@ void sbObjectToSoftbody(Object *ob) free_softbody_intern(ob->soft); } -static int object_has_edges(Object *ob) +static int object_has_edges(Object *ob) { if(ob->type==OB_MESH) { return ((Mesh*) ob->data)->totedge; @@ -3767,7 +3774,7 @@ static int object_has_edges(Object *ob) } } -/* SB global visible functions */ +/* SB global visible functions */ void sbSetInterruptCallBack(int (*f)(void)) { SB_localInterruptCallBack = f; @@ -3782,7 +3789,7 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo return; for(a=0,bp=sb->bpoint; aorigS, bp->origE); /* copy the position of the goals at desired end time */ VECCOPY(bp->origE, vertexCos[a]); @@ -3790,7 +3797,7 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo mul_m4_v3(ob->obmat, bp->origE); /* just to be save give bp->origT a defined value will be calulated in interpolate_exciter()*/ - VECCOPY(bp->origT, bp->origE); + VECCOPY(bp->origT, bp->origE); } } @@ -3804,7 +3811,7 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo see: this is kind of reverse engeneering: having to states of a point cloud and recover what happend our advantage here we know the identity of the vertex there are others methods giving other results. - lloc,lrot,lscale are allowed to be NULL, just in case you don't need it. + lloc,lrot,lscale are allowed to be NULL, just in case you don't need it. should be pretty useful for pythoneers :) not! velocity .. 2nd order stuff vcloud_estimate_transform see @@ -3825,10 +3832,10 @@ void SB_estimate_transform(Object *ob,float lloc[3],float lrot[3][3],float lscal if(!sb || !sb->bpoint) return; opos= MEM_callocN( (sb->totpoint)*3*sizeof(float), "SB_OPOS"); rpos= MEM_callocN( (sb->totpoint)*3*sizeof(float), "SB_RPOS"); - /* might filter vertex selection with a vertex group */ + /* might filter vertex selection with a vertex group */ for(a=0, bp=sb->bpoint, rp=sb->scratch->Ref.ivert; atotpoint; a++, bp++, rp++) { - VECCOPY(rpos[a],rp->pos); - VECCOPY(opos[a],bp->pos); + VECCOPY(rpos[a],rp->pos); + VECCOPY(opos[a],bp->pos); } vcloud_estimate_transform(sb->totpoint, opos, NULL, rpos, NULL, com, rcom,lrot,lscale); @@ -3838,7 +3845,7 @@ void SB_estimate_transform(Object *ob,float lloc[3],float lrot[3][3],float lscal if (lscale) copy_m3_m3(sb->lscale,lscale); if (lrot) copy_m3_m3(sb->lrot,lrot); - + MEM_freeN(opos); MEM_freeN(rpos); } @@ -3861,9 +3868,9 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int 1. set sheduled time step to new dtime 2. try to advance the sheduled time step, beeing optimistic execute it 3. check for success - 3.a we 're fine continue, may be we can increase sheduled time again ?? if so, do so! + 3.a we 're fine continue, may be we can increase sheduled time again ?? if so, do so! 3.b we did exceed error limit --> roll back, shorten the sheduled time and try again at 2. - 4. check if we did reach dtime + 4. check if we did reach dtime 4.a nope we need to do some more at 2. 4.b yup we're done */ @@ -3877,7 +3884,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int /* make a nice clean scratch struc */ free_scratch(sb); /* clear if any */ sb_new_scratch(sb); /* make a new */ - sb->scratch->needstobuildcollider=1; + sb->scratch->needstobuildcollider=1; zero_v3(sb->lcom); unit_m3(sb->lrot); unit_m3(sb->lscale); @@ -3910,15 +3917,15 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) /* the simulator */ float forcetime; double sct,sst; - - + + sst=PIL_check_seconds_timer(); - /* Integration back in time is possible in theory, but pretty useless here. + /* Integration back in time is possible in theory, but pretty useless here. So we refuse to do so. Since we do not know anything about 'outside' canges especially colliders we refuse to go more than 10 frames. */ - if(dtime < 0 || dtime > 10.5f) return; - + if(dtime < 0 || dtime > 10.5f) return; + ccd_update_deflector_hash(scene, ob, sb->scratch->colliderhash); if(sb->scratch->needstobuildcollider){ @@ -3928,7 +3935,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) sb->scratch->needstobuildcollider=0; } - if (sb->solver_ID < 2) { + if (sb->solver_ID < 2) { /* special case of 2nd order Runge-Kutta type AKA Heun */ int mid_flags=0; float err = 0; @@ -3938,21 +3945,21 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) /* loops = counter for emergency brake * we don't want to lock up the system if physics fail */ - int loops =0 ; - + int loops =0 ; + SoftHeunTol = sb->rklimit; /* humm .. this should be calculated from sb parameters and sizes */ /* adjust loop limits */ if (sb->minloops > 0) forcetimemax = dtime / sb->minloops; if (sb->maxloops > 0) forcetimemin = dtime / sb->maxloops; if(sb->solver_ID>0) mid_flags |= MID_PRESERVE; - + forcetime =forcetimemax; /* hope for integrating in one step */ while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) ) { - /* set goals in time */ + /* set goals in time */ interpolate_exciter(ob,200,(int)(200.0*(timedone/dtime))); - + sb->scratch->flag &= ~SBF_DOFUZZY; /* do predictive euler step */ softbody_calc_forces(scene, ob, forcetime,timedone/dtime,0); @@ -3964,9 +3971,9 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) softbody_apply_forces(ob, forcetime, 2, &err,mid_flags); softbody_apply_goalsnap(ob); - + if (err > SoftHeunTol) { /* error needs to be scaled to some quantity */ - + if (forcetime > forcetimemin){ forcetime = MAX2(forcetime / 2.0f,forcetimemin); softbody_restore_prev_step(ob); @@ -3978,7 +3985,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) } else { float newtime = forcetime * 1.1f; /* hope for 1.1 times better conditions in next step */ - + if (sb->scratch->flag & SBF_DOFUZZY){ //if (err > SoftHeunTol/(2.0f*sb->fuzzyness)) { /* stay with this stepsize unless err really small */ newtime = forcetime; @@ -3994,7 +4001,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) //if (newtime > forcetime) printf("up,"); if (forcetime > 0.0) forcetime = MIN2(dtime - timedone,newtime); - else + else forcetime = MAX2(dtime - timedone,newtime); } loops++; @@ -4002,20 +4009,20 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) sct=PIL_check_seconds_timer(); if (sct-sst > 0.5f) printf("%3.0f%% \r",100.0f*timedone/dtime); } - /* ask for user break */ + /* ask for user break */ if (SB_localInterruptCallBack && SB_localInterruptCallBack()) break; } /* move snapped to final position */ interpolate_exciter(ob, 2, 2); softbody_apply_goalsnap(ob); - + // if(G.f & G_DEBUG){ if(sb->solverflags & SBSO_MONITOR ){ if (loops > HEUNWARNLIMIT) /* monitor high loop counts */ printf("\r needed %d steps/frame",loops); } - + } else if (sb->solver_ID == 2) {/* do semi "fake" implicit euler */ -- cgit v1.2.3 From 7b0bda22e119d1cd568ed5e7f9644b2517430bfe Mon Sep 17 00:00:00 2001 From: Jens Ole Wund Date: Tue, 15 Jun 2010 09:47:37 +0000 Subject: soft body disable edge collision for bezier handles because of massive pointlessness --- source/blender/blenkernel/intern/softbody.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index bbf51717e92..b44fe1ad1d0 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -83,7 +83,7 @@ static int (*SB_localInterruptCallBack)(void) = NULL; /* ********** soft body engine ******* */ -typedef enum {SB_EDGE=1,SB_BEND=2,SB_STIFFQUAD=3} type_spring; +typedef enum {SB_EDGE=1,SB_BEND=2,SB_STIFFQUAD=3,SB_HANDLE=4} type_spring; typedef struct BodySpring { int v1, v2; @@ -2129,6 +2129,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo kw = kw * kw; switch (bs->springtype){ case SB_EDGE: + case SB_HANDLE: forcefactor *= kw; break; case SB_BEND: @@ -3607,21 +3608,21 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) if(totspring) { if(a>0) { - bs->v1= curindex-1; + bs->v1= curindex-3; bs->v2= curindex; - bs->springtype=SB_EDGE; - bs->len= globallen( (bezt-1)->vec[2], bezt->vec[0], ob ); + bs->springtype=SB_HANDLE; + bs->len= globallen( (bezt-1)->vec[0], bezt->vec[0], ob ); bs++; } bs->v1= curindex; bs->v2= curindex+1; - bs->springtype=SB_EDGE; + bs->springtype=SB_HANDLE; bs->len= globallen( bezt->vec[0], bezt->vec[1], ob ); bs++; bs->v1= curindex+1; bs->v2= curindex+2; - bs->springtype=SB_EDGE; + bs->springtype=SB_HANDLE; bs->len= globallen( bezt->vec[1], bezt->vec[2], ob ); bs++; } -- cgit v1.2.3 From 3173232bfa1e6878088cdbb0134fe709a1f757bd Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 17 Jun 2010 07:20:12 +0000 Subject: Fix [#22610] Alpha problem with textureswhen Brightness > 1 or Contrast < 1 * Enabled premultiplication for packed images * Added pack/unpack operator to image template * Moved brightness/contrast corrections to after de-premultiplication in image texture sampling --- source/blender/blenkernel/intern/image.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ef95139abda..f06e9302a60 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1715,7 +1715,10 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) /* is there a PackedFile with this image ? */ if (ima->packedfile) { - ibuf = IMB_ibImageFromMemory((unsigned char*)ima->packedfile->data, ima->packedfile->size, IB_rect|IB_multilayer); + flag = IB_rect|IB_multilayer; + if(ima->flag & IMA_DO_PREMUL) flag |= IB_premul; + + ibuf = IMB_ibImageFromMemory((unsigned char*)ima->packedfile->data, ima->packedfile->size, flag); } else { flag= IB_rect|IB_multilayer|IB_metadata; -- cgit v1.2.3 From a7386bf9862a8d2960931c9d6df21549473adeec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Jun 2010 14:22:13 +0000 Subject: fix for crash with opengl sequencer strips that dont have a camera --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 3ff7370a443..d1ab63ca65e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2194,7 +2194,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int seq->scene->markers.first= seq->scene->markers.last= NULL; #endif - if(sequencer_view3d_cb && doseq_gl && (seq->scene == scene || have_seq==0)) { + if(sequencer_view3d_cb && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) { /* opengl offscreen render */ scene_update_for_newframe(seq->scene, seq->scene->lay); se->ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, scene->r.seq_prev_type); -- cgit v1.2.3 From 0aef0d2538573cdb6eefae9c2fc10d80fe1d572e Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 18 Jun 2010 05:18:46 +0000 Subject: Raise the default report popup severity to errors only (not warnings). All reports still get displayed in header. --- source/blender/blenkernel/intern/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index d5990ce81ec..173c6c136f2 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -67,7 +67,7 @@ void BKE_reports_init(ReportList *reports, int flag) memset(reports, 0, sizeof(ReportList)); reports->storelevel= RPT_INFO; - reports->printlevel= RPT_INFO; + reports->printlevel= RPT_ERROR; reports->flag= flag; } -- cgit v1.2.3 From e4c9381f14bccdfebf1d33aa7bad97948223dab3 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 18 Jun 2010 11:34:45 +0000 Subject: Fix for [#22479] Hair is left our when moving emitter unless Hair Dynamics is set on --- source/blender/blenkernel/intern/particle_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index ce84ee96d01..aa0ed983154 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3943,7 +3943,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) BKE_animsys_evaluate_animdata(&part->id, part->adt, cfra, ADT_RECALC_DRIVERS); /* TODO: only free child paths in case of PSYS_RECALC_CHILD */ - if(psys->recalc & PSYS_RECALC) + if(psys->recalc & PSYS_RECALC || ob->recalc & OB_RECALC) psys_free_path_cache(psys, NULL); if(psys->recalc & PSYS_RECALC_CHILD) -- cgit v1.2.3 From 61b0a5bdb5abfc219c430b7492d4efd44085eaf2 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 18 Jun 2010 11:36:51 +0000 Subject: Fix for [#22410] Texture force field doesn't depend on empty location (patch by Matt Ebb) --- source/blender/blenkernel/intern/effect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index c780971c3fa..e9283ea867e 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -777,7 +777,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP } if(eff->pd->flag & PFIELD_TEX_OBJECT) { - mul_mat3_m4_v3(eff->ob->obmat, tex_co); + mul_m4_v3(eff->ob->obmat, tex_co); } hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 0, result); -- cgit v1.2.3 From fe3d388af2ad033f6375acb6d069265af281d352 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 18 Jun 2010 14:14:13 +0000 Subject: Changes to scene updating with set scenes. The most useful effect of this is that set scenes can take the simplify settings from the current scene (render team doesnt have to worry about animators simplify settings). details... - updating on frame change now passes the parent scene to object update function. (this was alredy happening for updating tagged objects) - set scenes objects update first so scenes can depend on set objects however this only happened at once level, now set scenes are updated recursively, so deepest level is updated first. - collision objects used to only look through the current scene, now set objects are included. --- source/blender/blenkernel/intern/collision.c | 19 +++++--- source/blender/blenkernel/intern/scene.c | 67 +++++++--------------------- 2 files changed, 30 insertions(+), 56 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index a77ac9b8e24..9b49ac9c6ff 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -40,6 +40,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_global.h" +#include "BKE_scene.h" #include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_modifier.h" @@ -1353,10 +1354,13 @@ Object **get_collisionobjects(Scene *scene, Object *self, Group *group, int *num add_collision_object(&objs, &numobj, &maxobj, go->ob, self, 0); } else { + Scene *sce; /* for SETLOOPER macro */ /* add objects in same layer in scene */ - for(base = scene->base.first; base; base = base->next) - if(base->lay & self->lay) + for(SETLOOPER(scene, base)) { + if(base->lay & self->lay) add_collision_object(&objs, &numobj, &maxobj, base->object, self, 0); + + } } *numcollobj= numobj; @@ -1400,7 +1404,6 @@ static void add_collider_cache_object(ListBase **objs, Object *ob, Object *self, ListBase *get_collider_cache(Scene *scene, Object *self, Group *group) { - Base *base; GroupObject *go; ListBase *objs= NULL; @@ -1410,9 +1413,15 @@ ListBase *get_collider_cache(Scene *scene, Object *self, Group *group) add_collider_cache_object(&objs, go->ob, self, 0); } else { - for(base = scene->base.first; base; base = base->next) - if(!self || (base->lay & self->lay)) + Scene *sce; /* for SETLOOPER macro */ + Base *base; + + /* add objects in same layer in scene */ + for(SETLOOPER(scene, base)) { + if(!self || (base->lay & self->lay)) add_collider_cache_object(&objs, base->object, self, 0); + + } } return objs; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index dcd305ef87e..0e4b36d724d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -887,68 +887,38 @@ float frame_to_float (Scene *scene, int cfra) /* see also bsystem_time in objec return ctime; } -static void scene_update_newframe(Scene *scene, int cfra, unsigned int lay) +static void scene_update_tagged_recursive(Scene *scene, Scene *scene_parent) { Base *base; - Object *ob; - int cfra_back= scene->r.cfra; - scene->r.cfra= cfra; - + + /* sets first, we allow per definition current scene to have + dependencies on sets, but not the other way around. */ + if(scene->set) + scene_update_tagged_recursive(scene->set, scene_parent); + for(base= scene->base.first; base; base= base->next) { - ob= base->object; - - object_handle_update(scene, ob); // bke_object.h + Object *ob= base->object; + + object_handle_update(scene_parent, ob); 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 - //if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) { - // base->lay= ob->lay; - //} + group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); } - - scene->r.cfra= cfra_back; } /* this is called in main loop, doing tagged updates before redraw */ void scene_update_tagged(Scene *scene) { - Scene *sce; - Base *base; - Object *ob; - float ctime = frame_to_float(scene, scene->r.cfra); - scene->physics_settings.quick_cache_step= 0; /* update all objects: drivers, matrices, displists, etc. flags set by depgraph or manual, no layer check here, gets correct flushed */ - /* 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)) { - 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) { - 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); - } + scene_update_tagged_recursive(scene, scene); /* recalc scene animation data here (for sequencer) */ { + float ctime = frame_to_float(scene, scene->r.cfra); AnimData *adt= BKE_animdata_from_id(&scene->id); if(adt && (adt->recalc & ADT_RECALC_ANIM)) @@ -978,7 +948,7 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay) /* Following 2 functions are recursive - * so dont call within 'scene_update_newframe' */ + * so dont call within 'scene_update_tagged_recursive' */ DAG_scene_update_flags(sce, lay); // only stuff that moves or needs display still /* All 'standard' (i.e. without any dependencies) animation is handled here, @@ -990,13 +960,8 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay) BKE_animsys_evaluate_all_animation(G.main, ctime); /*...done with recusrive funcs */ - - /* 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, sce->r.cfra, lay); - } - - scene_update_newframe(sce, sce->r.cfra, lay); + /* object_handle_update() on all objects, groups and sets */ + scene_update_tagged_recursive(sce, sce); } /* return default layer, also used to patch old files */ -- cgit v1.2.3 From 000d23e05ced975fa28c87e78b446624c6992e67 Mon Sep 17 00:00:00 2001 From: Diego Borghetti Date: Fri, 18 Jun 2010 15:23:39 +0000 Subject: Fix #22625 My fix for #22317 make that every time you delete an object, blender go to perspective view, fixed now. --- source/blender/blenkernel/intern/object.c | 35 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 972c07eb272..10c94ed1eeb 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -337,7 +337,7 @@ void unlink_object(Scene *scene, Object *ob) ModifierData *md; ARegion *ar; RegionView3D *rv3d; - int a; + int a, found; unlink_controllers(&ob->controllers); unlink_actuators(&ob->actuators); @@ -609,27 +609,36 @@ void unlink_object(Scene *scene, Object *ob) while(sa) { SpaceLink *sl; - if (sa->spacetype == SPACE_VIEW3D) { - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { - rv3d= (RegionView3D *)ar->regiondata; - if (rv3d->persp == RV3D_CAMOB) - rv3d->persp= RV3D_PERSP; - if (rv3d->localvd && rv3d->localvd->persp == RV3D_CAMOB) - rv3d->localvd->persp= RV3D_PERSP; - } - } - } - for (sl= sa->spacedata.first; sl; sl= sl->next) { if(sl->spacetype==SPACE_VIEW3D) { View3D *v3d= (View3D*) sl; + found= 0; if(v3d->camera==ob) { v3d->camera= NULL; + found= 1; } if(v3d->localvd && v3d->localvd->camera==ob ) { v3d->localvd->camera= NULL; + found += 2; + } + + if (found) { + if (sa->spacetype == SPACE_VIEW3D) { + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype==RGN_TYPE_WINDOW) { + rv3d= (RegionView3D *)ar->regiondata; + if (found == 1 || found == 3) { + if (rv3d->persp == RV3D_CAMOB) + rv3d->persp= RV3D_PERSP; + } + if (found == 2 || found == 3) { + if (rv3d->localvd && rv3d->localvd->persp == RV3D_CAMOB) + rv3d->localvd->persp= RV3D_PERSP; + } + } + } + } } } else if(sl->spacetype==SPACE_OUTLINER) { -- cgit v1.2.3 From 229b7639e72c5290b3be24747fafd14c7aeaf71b Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 19 Jun 2010 10:50:23 +0000 Subject: Merged revision 29562 from /branches/soc-2010-nexyon. --- source/blender/blenkernel/intern/blender.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 046b8de2431..134d49cdf24 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -65,7 +65,6 @@ #include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_library.h" -#include "BKE_ipo.h" #include "BKE_main.h" #include "BKE_node.h" #include "BKE_report.h" @@ -287,10 +286,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) //setscreen(G.curscreen); } - // XXX temporarily here - if(G.main->versionfile < 250) - do_versions_ipos_to_animato(G.main); // XXX fixme... complicated versionpatching - if(recover && bfd->filename[0] && G.relbase_valid) { /* in case of autosave or quit.blend, use original filename instead * use relbase_valid to make sure the file is saved, else we get in the filename */ -- cgit v1.2.3 From 72d21c35adcea937bbf2e2423472c9ca5ed315c6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Jun 2010 17:37:50 +0000 Subject: sequencer swap data operator. needed for durian so we can swap out preview AVI's for EXR sequences. --- source/blender/blenkernel/BKE_sequencer.h | 6 ++- source/blender/blenkernel/intern/sequencer.c | 62 ++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 354638013ec..9b96363dd23 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -191,6 +191,7 @@ int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test, struct Scene int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene); int seqbase_isolated_sel_check(struct ListBase *seqbase); void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage); +int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b); void seq_update_sound(struct Scene* scene, struct Sequence *seq); void seq_update_muting(struct Scene* scene, struct Editing *ed); @@ -200,8 +201,9 @@ void clear_scene_in_allseqs(struct Scene *sce); struct Sequence *get_seq_by_name(struct ListBase *seqbase, const char *name, int recursive); -struct Sequence *active_seq_get(struct Scene *scene); -void active_seq_set(struct Scene *scene, struct Sequence *seq); +struct Sequence *seq_active_get(struct Scene *scene); +void seq_active_set(struct Scene *scene, struct Sequence *seq); +int seq_active_pair_get(struct Scene *scene, struct Sequence **seq_act, struct Sequence **seq_other); /* api for adding new sequence strips */ typedef struct SeqLoadInfo { diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d1ab63ca65e..51428f56dc9 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3790,6 +3790,33 @@ ListBase *seq_seqbase(ListBase *seqbase, Sequence *seq) return NULL; } +int seq_swap(Sequence *seq_a, Sequence *seq_b) +{ + if(seq_a->len != seq_b->len) + return 0; + + /* type checking, could be more advanced but disalow sound vs non-sound copy */ + if(seq_a->type != seq_b->type) { + if(seq_a->type == SEQ_SOUND || seq_b->type == SEQ_SOUND) { + return 0; + } + } + + SWAP(Sequence, *seq_a, *seq_b); + SWAP(void *, seq_a->prev, seq_b->prev); + SWAP(void *, seq_a->next, seq_b->next); + + SWAP(int, seq_a->start, seq_b->start); + SWAP(int, seq_a->startofs, seq_b->startofs); + SWAP(int, seq_a->endofs, seq_b->endofs); + SWAP(int, seq_a->startstill, seq_b->startstill); + SWAP(int, seq_a->endstill, seq_b->endstill); + SWAP(int, seq_a->machine, seq_b->machine); + SWAP(int, seq_a->startdisp, seq_b->enddisp); + + return 1; +} + /* XXX - hackish function needed for transforming strips! TODO - have some better solution */ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs) { @@ -3832,14 +3859,14 @@ Sequence *get_seq_by_name(ListBase *seqbase, const char *name, int recursive) } -Sequence *active_seq_get(Scene *scene) +Sequence *seq_active_get(Scene *scene) { Editing *ed= seq_give_editing(scene, FALSE); if(ed==NULL) return NULL; return ed->act_seq; } -void active_seq_set(Scene *scene, Sequence *seq) +void seq_active_set(Scene *scene, Sequence *seq) { Editing *ed= seq_give_editing(scene, FALSE); if(ed==NULL) return; @@ -3847,6 +3874,35 @@ void active_seq_set(Scene *scene, Sequence *seq) ed->act_seq= seq; } +int seq_active_pair_get(Scene *scene, Sequence **seq_act, Sequence **seq_other) +{ + Editing *ed= seq_give_editing(scene, FALSE); + + *seq_act= seq_active_get(scene); + + if(*seq_act == NULL) { + return 0; + } + else { + Sequence *seq; + + *seq_other= NULL; + + for(seq= ed->seqbasep->first; seq; seq= seq->next) { + if(seq->flag & SELECT && (seq != (*seq_act))) { + if(*seq_other) { + return 0; + } + else { + *seq_other= seq; + } + } + } + + return (*seq_other != NULL); + } +} + /* api like funcs for adding */ void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load) @@ -3861,7 +3917,7 @@ void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load) if(seq_load->flag & SEQ_LOAD_REPLACE_SEL) { seq_load->flag |= SELECT; - active_seq_set(scene, seq); + seq_active_set(scene, seq); } if(seq_load->flag & SEQ_LOAD_SOUND_CACHE) { -- cgit v1.2.3 From 425da6206f75b9218cf4123ac1b9cdeaf7f86bb1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 21 Jun 2010 20:10:59 +0000 Subject: [#22262] Sculpting shape keys using the Smooth brush switches the shape to the Basis PBVH used the same verts array as mesh data and shape key/reference key coords were applying on the mesh data, so on some refreshing undeformed mesh was displayed. Added utility functions to get vert coords from key block, apply new vert coords on keyblock and function to apply coords on bpvh, so now pbvh uses it's ovn vertex array and no changes are making to the mesh data. Additional change: Store key block name in SculptUndoNode, so now shape wouldn't be copied to wrong keyblock on undo --- source/blender/blenkernel/BKE_key.h | 2 + source/blender/blenkernel/BKE_paint.h | 4 +- source/blender/blenkernel/intern/cdderivedmesh.c | 14 ++- source/blender/blenkernel/intern/depsgraph.c | 3 - source/blender/blenkernel/intern/key.c | 149 +++++++++++++++++++++++ 5 files changed, 166 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 6b8f18e9e17..c94955e611e 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -75,6 +75,8 @@ void key_to_latt(struct KeyBlock *kb, struct Lattice *lt); void latt_to_key(struct Lattice *lt, struct KeyBlock *kb); void key_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb); void curve_to_key(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb); +float (*key_to_vertcos(struct Object *ob, struct KeyBlock *kb))[3]; +void vertcos_to_key(struct Object *ob, struct KeyBlock *kb, float (*vertCos)[3]); #ifdef __cplusplus }; diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 81fb724b3a5..cd412ca5a74 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -70,7 +70,7 @@ typedef struct SculptSession { int totvert, totface; float *face_normals; struct Object *ob; - struct KeyBlock *kb, *refkb; + struct KeyBlock *kb; /* Mesh connectivity */ struct ListBase *fmap; @@ -94,6 +94,8 @@ typedef struct SculptSession { struct StrokeCache *cache; struct GPUDrawObject *drawobject; + + int modifiers_active; } SculptSession; void free_sculptsession(struct Object *ob); diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 80f39531b34..9612dac2ac4 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -186,6 +186,16 @@ static ListBase *cdDM_getFaceMap(Object *ob, DerivedMesh *dm) return cddm->fmap; } +static int can_pbvh_draw(Object *ob, DerivedMesh *dm) +{ + CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + Mesh *me= (ob)? ob->data: NULL; + + if(ob->sculpt->modifiers_active) return 0; + + return (cddm->mvert == me->mvert) || ob->sculpt->kb; +} + static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; @@ -200,7 +210,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) return NULL; if(ob->sculpt->pbvh) { cddm->pbvh= ob->sculpt->pbvh; - cddm->pbvh_draw = (cddm->mvert == me->mvert) || ob->sculpt->kb; + cddm->pbvh_draw = can_pbvh_draw(ob, dm); } /* always build pbvh from original mesh, and only use it for drawing if @@ -208,7 +218,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) that this is actually for, to support a pbvh on a modified mesh */ if(!cddm->pbvh && ob->type == OB_MESH) { cddm->pbvh = BLI_pbvh_new(); - cddm->pbvh_draw = (cddm->mvert == me->mvert) || ob->sculpt->kb; + cddm->pbvh_draw = can_pbvh_draw(ob, dm); BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert, me->totface, me->totvert); } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index bdeacdf6946..4be5cce38a8 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2286,9 +2286,6 @@ void DAG_id_flush_update(ID *id, short flag) /* no point in trying in this cases */ if(!id || id->us <= 1) id= NULL; - /* for locked shape keys we make an exception */ - else if(ob_get_key(ob) && (ob->shapeflag & OB_SHAPE_LOCK)) - id= NULL; } } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index f604d307551..84484417f42 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BLI_math_vector.h" #include "DNA_anim_types.h" #include "DNA_key_types.h" @@ -1719,3 +1720,151 @@ void key_to_mesh(KeyBlock *kb, Mesh *me) VECCOPY(mvert->co, fp); } } + +/************************* vert coords ************************/ +float (*key_to_vertcos(Object *ob, KeyBlock *kb))[3] +{ + float (*vertCos)[3], *co; + float *fp= kb->data; + int tot= 0, a; + + /* Count of vertex coords in array */ + if(ob->type == OB_MESH) { + Mesh *me= (Mesh*)ob->data; + tot= me->totvert; + } else if(ob->type == OB_LATTICE) { + Lattice *lt= (Lattice*)ob->data; + tot= lt->pntsu*lt->pntsv*lt->pntsw; + } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { + Curve *cu= (Curve*)ob->data; + tot= count_curveverts(&cu->nurb); + } + + if (tot == 0) return NULL; + + vertCos= MEM_callocN(tot*sizeof(*vertCos), "key_to_vertcos vertCos"); + + /* Copy coords to array */ + co= (float*)vertCos; + + if(ELEM(ob->type, OB_MESH, OB_LATTICE)) { + for (a= 0; atype, OB_CURVE, OB_SURF)) { + Curve *cu= (Curve*)ob->data; + Nurb *nu= cu->nurb.first; + BezTriple *bezt; + BPoint *bp; + + while (nu) { + if(nu->bezt) { + int i; + bezt= nu->bezt; + a= nu->pntsu; + + while (a--) { + for (i= 0; i<3; i++) { + copy_v3_v3(co, fp); + fp+= 3; co+= 3; + } + + fp+= 3; /* skip alphas */ + + bezt++; + } + } + else { + bp= nu->bp; + a= nu->pntsu*nu->pntsv; + + while (a--) { + copy_v3_v3(co, fp); + + fp+= 4; + co+= 3; + + bp++; + } + } + + nu= nu->next; + } + } + + return vertCos; +} + +void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) +{ + float *co= (float*)vertCos, *fp; + int tot= 0, a, elemsize; + + if (kb->data) MEM_freeN(kb->data); + + /* Count of vertex coords in array */ + if(ob->type == OB_MESH) { + Mesh *me= (Mesh*)ob->data; + tot= me->totvert; + elemsize= me->key->elemsize; + } else if(ob->type == OB_LATTICE) { + Lattice *lt= (Lattice*)ob->data; + tot= lt->pntsu*lt->pntsv*lt->pntsw; + elemsize= lt->key->elemsize; + } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { + Curve *cu= (Curve*)ob->data; + elemsize= cu->key->elemsize; + tot= count_curveverts(&cu->nurb); + } + + fp= kb->data= MEM_callocN(tot*elemsize, "key_to_vertcos vertCos"); + + if (tot == 0) return; + + /* Copy coords to keyblock */ + + if(ELEM(ob->type, OB_MESH, OB_LATTICE)) { + for (a= 0; atype, OB_CURVE, OB_SURF)) { + Curve *cu= (Curve*)ob->data; + Nurb *nu= cu->nurb.first; + BezTriple *bezt; + BPoint *bp; + + while (nu) { + if(nu->bezt) { + int i; + bezt= nu->bezt; + a= nu->pntsu; + + while (a--) { + for (i= 0; i<3; i++) { + copy_v3_v3(fp, co); + fp+= 3; co+= 3; + } + + fp+= 3; /* skip alphas */ + + bezt++; + } + } + else { + bp= nu->bp; + a= nu->pntsu*nu->pntsv; + + while (a--) { + copy_v3_v3(fp, co); + + fp+= 4; + co+= 3; + + bp++; + } + } + + nu= nu->next; + } + } +} -- cgit v1.2.3 From 4bade8e13785fe79478d13aedac201bba4bf8ee9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Jun 2010 22:05:34 +0000 Subject: sequence.swap(other) rna function. --- source/blender/blenkernel/intern/sequencer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 51428f56dc9..94d9b90fe7f 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3812,7 +3812,8 @@ int seq_swap(Sequence *seq_a, Sequence *seq_b) SWAP(int, seq_a->startstill, seq_b->startstill); SWAP(int, seq_a->endstill, seq_b->endstill); SWAP(int, seq_a->machine, seq_b->machine); - SWAP(int, seq_a->startdisp, seq_b->enddisp); + SWAP(int, seq_a->startdisp, seq_b->startdisp); + SWAP(int, seq_a->enddisp, seq_b->enddisp); return 1; } -- cgit v1.2.3 From 8bc1e44e3364ba6d7888c04f97ecea0fad382d41 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Tue, 22 Jun 2010 09:13:30 +0000 Subject: slight cleaning of texture type changing functionality, done while working on other stuff today --- source/blender/blenkernel/BKE_texture.h | 1 + source/blender/blenkernel/intern/texture.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index ace352395d2..39c12a2bfd8 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -64,6 +64,7 @@ void colorband_table_RGBA(struct ColorBand *coba, float **array, int *size); void default_tex(struct Tex *tex); struct Tex *add_texture(const char *name); +void tex_set_type(struct Tex *tex, int type); void default_mtex(struct MTex *mtex); struct MTex *add_mtex(void); struct Tex *copy_texture(struct Tex *tex); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 6d8c339d2b9..31826f5be28 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -509,6 +509,27 @@ void default_tex(Tex *tex) tex->preview = NULL; } +void tex_set_type(Tex *tex, int type) +{ + switch(type) { + + case TEX_VOXELDATA: + if (tex->vd == NULL) + tex->vd = BKE_add_voxeldata(); + break; + case TEX_POINTDENSITY: + if (tex->pd == NULL) + tex->pd = BKE_add_pointdensity(); + break; + case TEX_ENVMAP: + if (tex->env == NULL) + tex->env = BKE_add_envmap(); + break; + } + + tex->type = type; +} + /* ------------------------------------------------------------------------- */ Tex *add_texture(const char *name) -- cgit v1.2.3 From e0368d31a5b3a593d9650de688fdaf77e6975103 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 22 Jun 2010 15:09:41 +0000 Subject: Enabled openmp multithreading for multires/subsurf again, but only if there are >= 1 million faces estimated in the resulting mesh. (merge from render25 branch) --- source/blender/blenkernel/intern/CCGSubSurf.c | 18 +++++++++--------- source/blender/blenkernel/intern/CCGSubSurf.h | 4 ++++ source/blender/blenkernel/intern/multires.c | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 8fad398f00a..bbd68fb797b 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1159,7 +1159,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, int normalDataOffset = ss->normalDataOffset; int vertDataSize = ss->meshIFC.vertDataSize; - //#pragma omp parallel for private(ptrIdx) schedule(static) + #pragma omp parallel for private(ptrIdx) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT) for (ptrIdx=0; ptrIdx= CCG_OMP_LIMIT) for (ptrIdx=0; ptrIdxmeshIFC.vertDataSize; void *q = ss->q, *r = ss->r; - //#pragma omp parallel for private(ptrIdx) schedule(static) + #pragma omp parallel for private(ptrIdx) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT) for (ptrIdx=0; ptrIdx= CCG_OMP_LIMIT) { void *q, *r; - //#pragma omp critical + #pragma omp critical { q = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf q"); r = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf r"); } - //#pragma omp for schedule(static) + #pragma omp for schedule(static) for (ptrIdx=0; ptrIdx= CCG_OMP_LIMIT) for (i=0; iv0, nextLvl)); VertDataCopy(EDGE_getCo(e, nextLvl, edgeSize-1), VERT_getCo(e->v1, nextLvl)); } - //#pragma omp parallel for private(i) schedule(static) + #pragma omp parallel for private(i) if(numEffectedF*edgeSize*edgeSize*4 >= CCG_OMP_LIMIT) for (i=0; itotface*gridSize*gridSize*4 >= CCG_OMP_LIMIT) for(i = 0; i < me->totface; ++i) { const int numVerts = mface[i].v4 ? 4 : 3; MDisps *mdisp = &mdisps[i]; @@ -568,7 +568,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int /* when adding new faces in edit mode, need to allocate disps */ if(!mdisp->disps) - //#pragma omp critical + #pragma omp critical { multires_reallocate_mdisps(me, mdisps, totlvl); } -- cgit v1.2.3 From c28aec9ae11c4b68406cf74fa9ac228886cdb376 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 22 Jun 2010 16:46:13 +0000 Subject: Fix #22589: pressing subdivide or updating displacements after sculpting on multire would unnecessarily subdivide vertex groups and other layers, making the operation slower than necessary. --- source/blender/blenkernel/intern/multires.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index aab9f2a0935..76d82889cda 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -459,6 +459,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updat /* create subsurf DM from original mesh at high level */ cddm = CDDM_from_mesh(me, NULL); + DM_set_only_copy(cddm, CD_MASK_BAREMESH); highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0); /* create multires DM from original mesh at low level */ @@ -656,6 +657,7 @@ static void multiresModifier_update(DerivedMesh *dm) /* create subsurf DM from original mesh at high level */ if (ob->derivedDeform) cddm = CDDM_copy(ob->derivedDeform); else cddm = CDDM_from_mesh(me, NULL); + DM_set_only_copy(cddm, CD_MASK_BAREMESH); highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0); @@ -709,6 +711,7 @@ static void multiresModifier_update(DerivedMesh *dm) if (ob->derivedDeform) cddm = CDDM_copy(ob->derivedDeform); else cddm = CDDM_from_mesh(me, NULL); + DM_set_only_copy(cddm, CD_MASK_BAREMESH); subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0); cddm->release(cddm); -- cgit v1.2.3 From df76cebb8a27eb1206eebbcfebac9a0ab439ce91 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Tue, 22 Jun 2010 21:09:50 +0000 Subject: == Sequencer == Removed "frame_locked"-flag from sequencer completely, since it doesn't work any more in Blender 2.5. (All IPOs are frame-locked now anyways.) --- source/blender/blenkernel/intern/seqeffects.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index b5f9c8fe542..56a8edcc4fc 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2802,7 +2802,7 @@ static void init_speed_effect(Sequence *seq) v = (SpeedControlVars *)seq->effectdata; v->globalSpeed = 1.0; v->frameMap = 0; - v->flags = SEQ_SPEED_COMPRESS_IPO_Y; + v->flags = 0; v->length = 0; } @@ -2925,14 +2925,8 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) for (cfra = 1; cfra < v->length; cfra++) { if(fcu) { - if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) { - ctime = seq->startdisp + cfra; - div = 1.0; - } else { - ctime= cfra; - div= v->length / 100.0f; - if(div==0.0) return; - } + ctime = seq->startdisp + cfra; + div = 1.0; facf = evaluate_fcurve(fcu, ctime/div); } else { @@ -2956,14 +2950,8 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) for (cfra = 0; cfra < v->length; cfra++) { if(fcu) { - if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) { - ctime = seq->startdisp + cfra; - div = 1.0; - } else { - ctime= cfra; - div= v->length / 100.0f; - if(div==0.0) return; - } + ctime = seq->startdisp + cfra; + div = 1.0; facf = evaluate_fcurve(fcu, ctime / div); if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) { -- cgit v1.2.3 From d200243a5ca9d9cf17fb5ad1b4df711698b82b1d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 23 Jun 2010 09:58:02 +0000 Subject: Fix #22654: Converted curve from mesh disappearing Curve object should have ob->bb=NULL if there is no derivedMesh --- source/blender/blenkernel/intern/displist.c | 6 ++++++ source/blender/blenkernel/intern/mesh.c | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 24f996fbb31..ae225fd19b7 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1855,6 +1855,12 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) DM_set_object_boundbox (ob, ob->derivedFinal); } else { boundbox_displist (ob); + + /* if there is no derivedMesh, object's boundbox is unneeded */ + if (ob->bb) { + MEM_freeN(ob->bb); + ob->bb= NULL; + } } } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 6ddc4b8bb16..cd8b2eb0a8e 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1186,6 +1186,12 @@ void mesh_to_curve(Scene *scene, Object *ob) if (needsFree) { ob->derivedFinal = NULL; + + /* curve object could have got bounding box only in special cases */ + if(ob->bb) { + MEM_freeN(ob->bb); + ob->bb= NULL; + } } } -- cgit v1.2.3 From 2567129e7fe7a2a4439ee6c9607d3eb5660e7d7c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Jun 2010 10:18:51 +0000 Subject: Converting a mesh into a mesh (alt-c), was broken with shape keys and modifiers that changed the vertex count. removal of the shape key was undone in DM_to_mesh(). --- source/blender/blenkernel/intern/DerivedMesh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 339326f75d5..d5ece6ae31f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -247,8 +247,8 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me) /* if the number of verts has changed, remove invalid data */ if(tmp.totvert != me->totvert) { - if(me->key) me->key->id.us--; - me->key = NULL; + if(tmp.key) tmp.key->id.us--; + tmp.key = NULL; } *me = tmp; -- cgit v1.2.3 From 46d28a5e8dee014fe3aadce6c137eb5d67b9e4ac Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 23 Jun 2010 12:27:13 +0000 Subject: Sculpt+shape keys: - Sculpting on the basis key should change original mesh - For relative keys sculpting on basis key should update others --- source/blender/blenkernel/BKE_key.h | 1 + source/blender/blenkernel/intern/key.c | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index c94955e611e..31e920406c0 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -77,6 +77,7 @@ void key_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb) void curve_to_key(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb); float (*key_to_vertcos(struct Object *ob, struct KeyBlock *kb))[3]; void vertcos_to_key(struct Object *ob, struct KeyBlock *kb, float (*vertCos)[3]); +void offset_to_key(struct Object *ob, struct KeyBlock *kb, float (*ofs)[3]); #ifdef __cplusplus }; diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 84484417f42..b8219c4aa35 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1868,3 +1868,54 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) } } } + +void offset_to_key(Object *ob, KeyBlock *kb, float (*ofs)[3]) +{ + int a; + float *co= (float*)ofs, *fp= kb->data; + + if(ELEM(ob->type, OB_MESH, OB_LATTICE)) { + for (a= 0; atotelem; a++, fp+=3, co+=3) { + add_v3_v3(fp, co); + } + } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { + Curve *cu= (Curve*)ob->data; + Nurb *nu= cu->nurb.first; + BezTriple *bezt; + BPoint *bp; + + while (nu) { + if(nu->bezt) { + int i; + bezt= nu->bezt; + a= nu->pntsu; + + while (a--) { + for (i= 0; i<3; i++) { + add_v3_v3(fp, co); + fp+= 3; co+= 3; + } + + fp+= 3; /* skip alphas */ + + bezt++; + } + } + else { + bp= nu->bp; + a= nu->pntsu*nu->pntsv; + + while (a--) { + add_v3_v3(fp, co); + + fp+= 4; + co+= 3; + + bp++; + } + } + + nu= nu->next; + } + } +} -- cgit v1.2.3 From 989cca1434419682aa04fa65ced5e69b33ffd3fa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 23 Jun 2010 13:18:50 +0000 Subject: Fix #21369: normals on extruded text and curve objects were flipped for the backside, giving problems with e.g. boolean operations. --- source/blender/blenkernel/BKE_displist.h | 2 +- source/blender/blenkernel/intern/displist.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index febe0a11ae6..9e75e55adf6 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -99,7 +99,7 @@ extern void shadeMeshMCol(struct Scene *scene, struct Object *ob, struct Mesh *m int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); void imagestodisplist(void); void reshadeall_displist(struct Scene *scene); -void filldisplist(struct ListBase *dispbase, struct ListBase *to); +void filldisplist(struct ListBase *dispbase, struct ListBase *to, int flipnormal); void fastshade_free_render(void); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index ae225fd19b7..a958d8c353b 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -925,7 +925,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) } -void filldisplist(ListBase *dispbase, ListBase *to) +void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) { EditVert *eve, *v1, *vlast; EditFace *efa; @@ -1019,6 +1019,9 @@ void filldisplist(ListBase *dispbase, ListBase *to) index[0]= (intptr_t)efa->v1->tmp.l; index[1]= (intptr_t)efa->v2->tmp.l; index[2]= (intptr_t)efa->v3->tmp.l; + + if(flipnormal) + SWAP(int, index[0], index[2]); index+= 3; efa= efa->next; @@ -1095,13 +1098,13 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) dl= dl->next; } - filldisplist(&front, dispbase); - filldisplist(&back, dispbase); + filldisplist(&front, dispbase, 1); + filldisplist(&back, dispbase, 0); freedisplist(&front); freedisplist(&back); - filldisplist(dispbase, dispbase); + filldisplist(dispbase, dispbase, 0); } @@ -1113,7 +1116,7 @@ static void curve_to_filledpoly(Curve *cu, ListBase *nurb, ListBase *dispbase) bevels_to_filledpoly(cu, dispbase); } else { - filldisplist(dispbase, dispbase); + filldisplist(dispbase, dispbase, 0); } } @@ -1315,7 +1318,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba ModifierData *preTesselatePoint; Curve *cu= ob->data; ListBase *nurb= cu->editnurb?cu->editnurb:&cu->nurb; - int required_mode, totvert; + int required_mode, totvert = 0; int editmode = (!forRender && cu->editnurb); DerivedMesh *dm= NULL, *ndm; float (*vertCos)[3] = NULL; -- cgit v1.2.3 From 4596588fe8f61c4138b5edd6760dbabdd04fbb35 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Jun 2010 15:07:20 +0000 Subject: - avoid divide by zero with node progress - write_crash_blend() was writing to the original path. --- source/blender/blenkernel/intern/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 13ea55ebf0f..add011d0950 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2465,7 +2465,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) node= getExecutableNode(ntree); if(node) { - if(ntree->progress) + if(ntree->progress && totnode) ntree->progress(ntree->prh, (1.0 - curnode/(float)totnode)); if(ntree->stats_draw) { char str[64]; -- cgit v1.2.3 From 4e3913397023b99c42b5952c89769f0b4430e76b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 23 Jun 2010 16:35:42 +0000 Subject: Fix #21370: VBO does not display material colors in textured solid. --- source/blender/blenkernel/intern/cdderivedmesh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 9612dac2ac4..9bba893c2c8 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -744,7 +744,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if( flag != lastFlag ) { if( startFace < i ) { if( lastFlag != 0 ) { /* if the flag is 0 it means the face is hidden or invisible */ - if (lastFlag==1 && mcol) + if (lastFlag==1 && col) GPU_color_switch(1); else GPU_color_switch(0); @@ -757,7 +757,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } if( startFace < dm->drawObject->nelements/3 ) { if( lastFlag != 0 ) { /* if the flag is 0 it means the face is hidden or invisible */ - if (lastFlag==1 && mcol) + if (lastFlag==1 && col) GPU_color_switch(1); else GPU_color_switch(0); -- cgit v1.2.3 From 4c810198230fda35589586238a0da549c5c2c7d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Jun 2010 10:04:18 +0000 Subject: Move some sequencer functions about, no functional changes. - Remove SEQ_DESEL, better not have a flag which includes ~, use ~SEQ_ALLSEL instead. - Rename recurs_dupli_seq -> seqbase_dupli_recursive - Rename deep_dupli_seq -> seq_dupli_recursive --- source/blender/blenkernel/BKE_sequencer.h | 3 + source/blender/blenkernel/intern/scene.c | 1 + source/blender/blenkernel/intern/sequencer.c | 127 +++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 9b96363dd23..ad95780268b 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -191,12 +191,15 @@ int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test, struct Scene int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene); int seqbase_isolated_sel_check(struct ListBase *seqbase); void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage); +struct Sequence *seq_dupli_recursive(struct Scene *scene, struct Sequence * seq); int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b); void seq_update_sound(struct Scene* scene, struct Sequence *seq); void seq_update_muting(struct Scene* scene, struct Editing *ed); void seqbase_sound_reload(Scene *scene, ListBase *seqbase); void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq); +void seqbase_dupli_recursive(struct Scene *scene, ListBase *nseqbase, ListBase *seqbase, int do_context); + void clear_scene_in_allseqs(struct Scene *sce); struct Sequence *get_seq_by_name(struct ListBase *seqbase, const char *name, int recursive); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 0e4b36d724d..6f049df917c 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -44,6 +44,7 @@ #include "DNA_group_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_sequence_types.h" #include "BKE_anim.h" #include "BKE_animsys.h" diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 94d9b90fe7f..f16b169a4fb 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -4086,3 +4086,130 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo return seq; } + + +static Sequence *dupli_seq(struct Scene *scene, Sequence *seq) +{ + Sequence *seqn = MEM_dupallocN(seq); + + seq->tmp = seqn; + seqn->strip= MEM_dupallocN(seq->strip); + + // XXX: add F-Curve duplication stuff? + + seqn->strip->tstripdata = 0; + seqn->strip->tstripdata_startstill = 0; + seqn->strip->tstripdata_endstill = 0; + seqn->strip->ibuf_startstill = 0; + seqn->strip->ibuf_endstill = 0; + + if (seq->strip->crop) { + seqn->strip->crop = MEM_dupallocN(seq->strip->crop); + } + + if (seq->strip->transform) { + seqn->strip->transform = MEM_dupallocN(seq->strip->transform); + } + + if (seq->strip->proxy) { + seqn->strip->proxy = MEM_dupallocN(seq->strip->proxy); + } + + if (seq->strip->color_balance) { + seqn->strip->color_balance + = MEM_dupallocN(seq->strip->color_balance); + } + + if(seq->type==SEQ_META) { + seqn->strip->stripdata = 0; + + seqn->seqbase.first= seqn->seqbase.last= 0; + /* WATCH OUT!!! - This metastrip is not recursively duplicated here - do this after!!! */ + /* - seq_dupli_recursive(&seq->seqbase,&seqn->seqbase);*/ + } else if(seq->type == SEQ_SCENE) { + seqn->strip->stripdata = 0; + if(seq->scene_sound) + seqn->scene_sound = sound_scene_add_scene_sound(scene, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); + } else if(seq->type == SEQ_MOVIE) { + seqn->strip->stripdata = + MEM_dupallocN(seq->strip->stripdata); + seqn->anim= 0; + } else if(seq->type == SEQ_SOUND) { + seqn->strip->stripdata = + MEM_dupallocN(seq->strip->stripdata); + if(seq->scene_sound) + seqn->scene_sound = sound_add_scene_sound(scene, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); + + seqn->sound->id.us++; + } else if(seq->type == SEQ_IMAGE) { + seqn->strip->stripdata = + MEM_dupallocN(seq->strip->stripdata); + } else if(seq->type >= SEQ_EFFECT) { + if(seq->seq1 && seq->seq1->tmp) seqn->seq1= seq->seq1->tmp; + if(seq->seq2 && seq->seq2->tmp) seqn->seq2= seq->seq2->tmp; + if(seq->seq3 && seq->seq3->tmp) seqn->seq3= seq->seq3->tmp; + + if (seq->type & SEQ_EFFECT) { + struct SeqEffectHandle sh; + sh = get_sequence_effect(seq); + if(sh.copy) + sh.copy(seq, seqn); + } + + seqn->strip->stripdata = 0; + + } else { + fprintf(stderr, "Aiiiiekkk! sequence type not " + "handled in duplicate!\nExpect a crash" + " now...\n"); + } + + seqbase_unique_name_recursive(&scene->ed->seqbase, seqn); + + return seqn; +} + +Sequence * seq_dupli_recursive(struct Scene *scene, Sequence * seq) +{ + Sequence * seqn = dupli_seq(scene, seq); + if (seq->type == SEQ_META) { + Sequence * s; + for(s= seq->seqbase.first; s; s = s->next) { + Sequence *n = seq_dupli_recursive(scene, s); + if (n) { + BLI_addtail(&seqn->seqbase, n); + } + } + } + return seqn; +} + +void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase, int do_context) +{ + Sequence *seq; + Sequence *seqn = 0; + Sequence *last_seq = seq_active_get(scene); + + for(seq= seqbase->first; seq; seq= seq->next) { + seq->tmp= NULL; + if(seq->flag & SELECT) { + seqn = dupli_seq(scene, seq); + if (seqn) { /*should never fail */ + if(do_context) { + seq->flag &= ~SEQ_ALLSEL; + seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL+SEQ_LOCK); + } + + BLI_addtail(nseqbase, seqn); + if(seq->type==SEQ_META) + seqbase_dupli_recursive(scene, &seqn->seqbase, &seq->seqbase, do_context); + + if(do_context) { + if (seq == last_seq) { + seq_active_set(scene, seqn); + } + } + } + } + } +} -- cgit v1.2.3 From 29b402f376716ba77f254eac4a214cda52e60608 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 25 Jun 2010 11:41:39 +0000 Subject: Fix #22618: Deleting an object doesnt remove its self from pinned buttons Clear pin flag and pin ID in unlink_object if pinid points to unlinking object --- source/blender/blenkernel/intern/object.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 10c94ed1eeb..4e90387a2c3 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -652,6 +652,14 @@ void unlink_object(Scene *scene, Object *ob) } } } + else if(sl->spacetype==SPACE_BUTS) { + SpaceButs *sbuts= (SpaceButs *)sl; + + if(sbuts->pinid==(ID *)ob) { + sbuts->flag&= ~SB_PIN_CONTEXT; + sbuts->pinid= NULL; + } + } } sa= sa->next; -- cgit v1.2.3 From 7b36b2ebbb5449cebd6264d707a43bcaf910b81c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Jun 2010 12:04:04 +0000 Subject: - duplicating a scene now duplicates its sequence strips too. - bugfix for copying a scene with FFMPEG properties set (wasnt copying the ID properties, could crash blender) - relative path option for adding sequence strips and replaceing images. --- source/blender/blenkernel/BKE_sequencer.h | 9 ++++++-- source/blender/blenkernel/intern/scene.c | 10 +++++++++ source/blender/blenkernel/intern/sequencer.c | 31 ++++++++++++++++------------ 3 files changed, 35 insertions(+), 15 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index ad95780268b..6fe1c2a96ea 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -191,14 +191,14 @@ int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test, struct Scene int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene); int seqbase_isolated_sel_check(struct ListBase *seqbase); void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage); -struct Sequence *seq_dupli_recursive(struct Scene *scene, struct Sequence * seq); +struct Sequence *seq_dupli_recursive(struct Scene *scene, struct Sequence * seq, int dupe_flag); int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b); void seq_update_sound(struct Scene* scene, struct Sequence *seq); void seq_update_muting(struct Scene* scene, struct Editing *ed); void seqbase_sound_reload(Scene *scene, ListBase *seqbase); void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq); -void seqbase_dupli_recursive(struct Scene *scene, ListBase *nseqbase, ListBase *seqbase, int do_context); +void seqbase_dupli_recursive(struct Scene *scene, ListBase *nseqbase, ListBase *seqbase, int dupe_flag); void clear_scene_in_allseqs(struct Scene *sce); @@ -228,6 +228,11 @@ typedef struct SeqLoadInfo { #define SEQ_LOAD_MOVIE_SOUND 1<<2 #define SEQ_LOAD_SOUND_CACHE 1<<3 + +/* seq_dupli' flags */ +#define SEQ_DUPE_UNIQUE_NAME 1<<0 +#define SEQ_DUPE_CONTEXT 1<<1 + /* use as an api function */ typedef struct Sequence *(*SeqLoadFunc)(struct bContext *, ListBase *, struct SeqLoadInfo *); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6f049df917c..a2fdf35583f 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -198,6 +198,10 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) scen->r.qtcodecdata->cdParms = MEM_dupallocN(scen->r.qtcodecdata->cdParms); } + if(sce->r.ffcodecdata.properties) { /* intentionally check scen not sce. */ + scen->r.ffcodecdata.properties= IDP_CopyProperty(scen->r.ffcodecdata.properties); + } + /* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations * are done outside of blenkernel with ED_objects_single_users! */ @@ -212,6 +216,12 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) id_us_plus((ID *)scen->world); scen->world= copy_world(scen->world); } + + if(sce->ed) { + scen->ed= MEM_callocN( sizeof(Editing), "addseq"); + scen->ed->seqbasep= &scen->ed->seqbase; + seqbase_dupli_recursive(sce, &scen->ed->seqbase, &sce->ed->seqbase, 0); + } } sound_create_scene(scen); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index f16b169a4fb..4241f481c30 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3991,7 +3991,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo AUD_SoundInfo info; - sound = sound_new_file(CTX_data_main(C), seq_load->path); + sound = sound_new_file(CTX_data_main(C), seq_load->path); /* handles relative paths */ if (sound==NULL || sound->playback_handle == NULL) { //if(op) @@ -4039,6 +4039,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load) { Scene *scene= CTX_data_scene(C); /* only for sound */ + char path[sizeof(seq_load->path)]; Sequence *seq, *soundseq; /* generic strip vars */ Strip *strip; @@ -4046,7 +4047,10 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo struct anim *an; - an = openanim(seq_load->path, IB_rect); + BLI_strncpy(path, seq_load->path, sizeof(path)); + BLI_path_abs(path, G.sce); + + an = openanim(path, IB_rect); if(an==NULL) return NULL; @@ -4088,7 +4092,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo } -static Sequence *dupli_seq(struct Scene *scene, Sequence *seq) +static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag) { Sequence *seqn = MEM_dupallocN(seq); @@ -4164,18 +4168,19 @@ static Sequence *dupli_seq(struct Scene *scene, Sequence *seq) " now...\n"); } - seqbase_unique_name_recursive(&scene->ed->seqbase, seqn); + if(dupe_flag & SEQ_DUPE_UNIQUE_NAME) + seqbase_unique_name_recursive(&scene->ed->seqbase, seqn); return seqn; } -Sequence * seq_dupli_recursive(struct Scene *scene, Sequence * seq) +Sequence * seq_dupli_recursive(struct Scene *scene, Sequence * seq, int dupe_flag) { - Sequence * seqn = dupli_seq(scene, seq); + Sequence * seqn = seq_dupli(scene, seq, dupe_flag); if (seq->type == SEQ_META) { - Sequence * s; + Sequence *s; for(s= seq->seqbase.first; s; s = s->next) { - Sequence *n = seq_dupli_recursive(scene, s); + Sequence *n = seq_dupli_recursive(scene, s, dupe_flag); if (n) { BLI_addtail(&seqn->seqbase, n); } @@ -4184,7 +4189,7 @@ Sequence * seq_dupli_recursive(struct Scene *scene, Sequence * seq) return seqn; } -void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase, int do_context) +void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase, int dupe_flag) { Sequence *seq; Sequence *seqn = 0; @@ -4193,18 +4198,18 @@ void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase for(seq= seqbase->first; seq; seq= seq->next) { seq->tmp= NULL; if(seq->flag & SELECT) { - seqn = dupli_seq(scene, seq); + seqn = seq_dupli(scene, seq, dupe_flag); if (seqn) { /*should never fail */ - if(do_context) { + if(dupe_flag & SEQ_DUPE_CONTEXT) { seq->flag &= ~SEQ_ALLSEL; seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL+SEQ_LOCK); } BLI_addtail(nseqbase, seqn); if(seq->type==SEQ_META) - seqbase_dupli_recursive(scene, &seqn->seqbase, &seq->seqbase, do_context); + seqbase_dupli_recursive(scene, &seqn->seqbase, &seq->seqbase, dupe_flag); - if(do_context) { + if(dupe_flag & SEQ_DUPE_CONTEXT) { if (seq == last_seq) { seq_active_set(scene, seqn); } -- cgit v1.2.3 From f3ffb225989ede422dbf831841272b7fe43c154d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Jun 2010 12:17:35 +0000 Subject: error in fix for ID property copy --- source/blender/blenkernel/intern/scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index a2fdf35583f..719dc964b89 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -199,7 +199,7 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) } if(sce->r.ffcodecdata.properties) { /* intentionally check scen not sce. */ - scen->r.ffcodecdata.properties= IDP_CopyProperty(scen->r.ffcodecdata.properties); + scen->r.ffcodecdata.properties= IDP_CopyProperty(sce->r.ffcodecdata.properties); } /* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations -- cgit v1.2.3 From 03fa4bb9992293b51eb7c24f2c1f810df634e632 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sun, 27 Jun 2010 05:39:55 +0000 Subject: Partial cleanup of timing system, with some guidance from Joshua: * Fractional frames support has been changed to use a new var, scene->r.subframe. This is a 0.0-1.0 float representing a subframe interval, used in generating a final float frame number to evaluate animation system etc. * Changed frame_to_float() and some instances of bsystem_time() into a convenience function: float BKE_curframe(scene) which retrieves the floating point current frame, after subframe and frame length corrections. * Removed blur_offs and field_offs globals. These are now stored in render, used to generate a scene->r.subframe before render database processing. --- source/blender/blenkernel/BKE_scene.h | 2 ++ source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/object.c | 18 ++------------ source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/scene.c | 28 +++++++++------------- 5 files changed, 17 insertions(+), 35 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 090979b33e9..9966aa11be3 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -80,6 +80,8 @@ void scene_select_base(struct Scene *sce, struct Base *selbase); /* checks for cycle, returns 1 if it's all OK */ int scene_check_setscene(struct Scene *sce); +float BKE_curframe(struct Scene *scene); + void scene_update_tagged(struct Scene *sce); void scene_update_for_newframe(struct Scene *sce, unsigned int lay); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 50552d33c41..6c8e5c48745 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1418,7 +1418,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) bActionStrip *strip, *striplast=NULL, *stripfirst=NULL; float striptime, frametime, length, actlength; float blendfac, stripframe; - float scene_cfra= frame_to_float(scene, scene->r.cfra); + float scene_cfra= BKE_curframe(scene); int doit, dostride; if(blocktype==ID_AR) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 4e90387a2c3..4e729ce4e9d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1605,20 +1605,8 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) /* there is also a timing calculation in drawobject() */ -float bluroffs= 0.0f, fieldoffs= 0.0f; int no_speed_curve= 0; -/* ugly calls from render */ -void set_mblur_offs(float blur) -{ - bluroffs= blur; -} - -void set_field_offs(float field) -{ - fieldoffs= field; -} - void disable_speed_curve(int val) { no_speed_curve= val; @@ -1628,11 +1616,9 @@ void disable_speed_curve(int val) /* ob can be NULL */ float bsystem_time(struct Scene *scene, Object *ob, float cfra, float ofs) { - /* returns float ( see frame_to_float in ipo.c) */ + /* returns float ( see BKE_curframe in scene.c) */ + cfra += scene->r.subframe; - /* bluroffs and fieldoffs are ugly globals that are set by render */ - cfra+= bluroffs+fieldoffs; - /* global time */ if (scene) cfra*= scene->r.framelen; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index aa0ed983154..3a6fb92d63a 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3925,7 +3925,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if(!psys_check_enabled(ob, psys)) return; - cfra= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0f); + cfra= BKE_curframe(scene); sim.psmd= psys_get_modifier(ob, psys); /* system was already updated from modifier stack */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 719dc964b89..1bc690eb0ed 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -879,22 +879,16 @@ int scene_check_setscene(Scene *sce) return 1; } -/* This (evil) function is needed to cope with two legacy Blender rendering features -* mblur (motion blur that renders 'subframes' and blurs them together), and fields -* rendering. Thus, the use of ugly globals from object.c -*/ -// BAD... EVIL... JUJU...!!!! -// XXX moved here temporarily -float frame_to_float (Scene *scene, int cfra) /* see also bsystem_time in object.c */ +/* This function is needed to cope with fractional frames - including two Blender rendering features +* mblur (motion blur that renders 'subframes' and blurs them together), and fields rendering. */ + +/* see also bsystem_time in object.c */ +float BKE_curframe(Scene *scene) { - extern float bluroffs; /* bad stuff borrowed from object.c */ - extern float fieldoffs; - float ctime; - - ctime= (float)cfra; - ctime+= bluroffs+fieldoffs; - ctime*= scene->r.framelen; - + float ctime = scene->r.cfra; + ctime+= scene->r.subframe; + ctime*= scene->r.framelen; + return ctime; } @@ -929,7 +923,7 @@ void scene_update_tagged(Scene *scene) /* recalc scene animation data here (for sequencer) */ { - float ctime = frame_to_float(scene, scene->r.cfra); + float ctime = BKE_curframe(scene); AnimData *adt= BKE_animdata_from_id(&scene->id); if(adt && (adt->recalc & ADT_RECALC_ANIM)) @@ -946,7 +940,7 @@ void scene_update_tagged(Scene *scene) /* applies changes right away, does all sets too */ void scene_update_for_newframe(Scene *sce, unsigned int lay) { - float ctime = frame_to_float(sce, sce->r.cfra); + float ctime = BKE_curframe(sce); Scene *sce_iter; /* clear animation overrides */ -- cgit v1.2.3 From e86c5cf9ea951c102be1206ca489252166623e38 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sun, 27 Jun 2010 07:45:57 +0000 Subject: Fix [#22564] Object name by object type Restored auto-naming newly created objects by type, for Mesh, Lamp, Meta --- source/blender/blenkernel/intern/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 4e729ce4e9d..61d81e461b6 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -986,7 +986,7 @@ static char *get_obdata_defname(int type) case OB_MESH: return "Mesh"; case OB_CURVE: return "Curve"; case OB_SURF: return "Surf"; - case OB_FONT: return "Font"; + case OB_FONT: return "Text"; case OB_MBALL: return "Mball"; case OB_CAMERA: return "Camera"; case OB_LAMP: return "Lamp"; -- cgit v1.2.3 From 3262dfdadd352f27043f2ba13540c3fb45d3743a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 27 Jun 2010 08:35:27 +0000 Subject: Fix #22051: crash when scaling parent metaball Keep the constant resolution for any motherball's scale --- source/blender/blenkernel/BKE_mball.h | 1 + source/blender/blenkernel/intern/mball.c | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index e28e2c4d86e..ce70b4cca2f 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -97,6 +97,7 @@ typedef struct process { /* parameters, function, storage */ CENTERLIST **centers; /* cube center hash table */ CORNER **corners; /* corner value hash table */ EDGELIST **edges; /* edge and vertex id hash table */ + float scale[3]; } PROCESS; /* dividing scene using octal tree makes polygonisation faster */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 3acc46967be..8d2dbf964b8 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -876,11 +876,11 @@ CORNER *setcorner (PROCESS* p, int i, int j, int k) c = (CORNER *) new_pgn_element(sizeof(CORNER)); c->i = i; - c->x = ((float)i-0.5f)*p->size; + c->x = ((float)i-0.5f)*p->size/p->scale[0]; c->j = j; - c->y = ((float)j-0.5f)*p->size; + c->y = ((float)j-0.5f)*p->size/p->scale[1]; c->k = k; - c->z = ((float)k-0.5f)*p->size; + c->z = ((float)k-0.5f)*p->size/p->scale[2]; c->value = p->function(c->x, c->y, c->z); c->next = p->corners[index]; @@ -1409,9 +1409,9 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) workp_v = in_v; max_len = sqrt((out.x-in.x)*(out.x-in.x) + (out.y-in.y)*(out.y-in.y) + (out.z-in.z)*(out.z-in.z)); - nx = abs((out.x - in.x)/mbproc->size); - ny = abs((out.y - in.y)/mbproc->size); - nz = abs((out.z - in.z)/mbproc->size); + nx = abs((out.x - in.x)/mbproc->size*mbproc->scale[0]); + ny = abs((out.y - in.y)/mbproc->size*mbproc->scale[1]); + nz = abs((out.z - in.z)/mbproc->size*mbproc->scale[2]); MAXN = MAX3(nx,ny,nz); if(MAXN!=0.0f) { @@ -1430,9 +1430,9 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) if((tmp_v<0.0 && workp_v>=0.0)||(tmp_v>0.0 && workp_v<=0.0)) { /* indexes of CUBE, which includes "first point" */ - c_i= (int)floor(workp.x/mbproc->size); - c_j= (int)floor(workp.y/mbproc->size); - c_k= (int)floor(workp.z/mbproc->size); + c_i= (int)floor(workp.x/mbproc->size*mbproc->scale[0]); + c_j= (int)floor(workp.y/mbproc->size*mbproc->scale[1]); + c_k= (int)floor(workp.z/mbproc->size*mbproc->scale[2]); /* add CUBE (with indexes c_i, c_j, c_k) to the stack, * this cube includes found point of Implicit Surface */ @@ -2082,13 +2082,16 @@ void metaball_polygonize(Scene *scene, Object *ob) DispList *dl; int a, nr_cubes; float *ve, *no, totsize, width; - + float smat[3][3]; + mb= ob->data; if(totelem==0) return; if(!(G.rendering) && (mb->flag==MB_UPDATE_NEVER)) return; if(G.moving && mb->flag==MB_UPDATE_FAST) return; + object_scale_to_mat3(ob, smat); + freedisplist(&ob->disp); curindex= totindex= 0; indices= 0; @@ -2130,6 +2133,7 @@ void metaball_polygonize(Scene *scene, Object *ob) width= mb->wiresize; if(G.moving && mb->flag==MB_UPDATE_HALFRES) width*= 2; } + /* nr_cubes is just for safety, minimum is totsize */ nr_cubes= (int)(0.5+totsize/width); @@ -2140,6 +2144,11 @@ void metaball_polygonize(Scene *scene, Object *ob) mbproc.cubes= 0; mbproc.delta = width/(float)(RES*RES); + /* to keep constant resolution for any motherball scale */ + mbproc.scale[0]= smat[0][0]; + mbproc.scale[1]= smat[1][1]; + mbproc.scale[2]= smat[2][2]; + polygonize(&mbproc, mb); MEM_freeN(mainb); -- cgit v1.2.3 From 650de24271501bddce1c0782ea071e9d8727101a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 27 Jun 2010 12:45:09 +0000 Subject: Recalculate motherball when metaball is deleting --- source/blender/blenkernel/BKE_mball.h | 1 + source/blender/blenkernel/intern/mball.c | 13 +++++++++++++ source/blender/blenkernel/intern/object.c | 11 ++++------- 3 files changed, 18 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index ce70b4cca2f..130969d4892 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -168,6 +168,7 @@ float *make_orco_mball(struct Object *ob); void copy_mball_properties(struct Scene *scene, struct Object *active_object); struct Object *find_basis_mball(struct Scene *scene, struct Object *ob); int is_basis_mball(struct Object *ob); +int is_mball_basis_for(struct Object *ob1, struct Object *ob2); void metaball_polygonize(struct Scene *scene, struct Object *ob); void calc_mballco(struct MetaElem *ml, float *vec); float densfunc(struct MetaElem *ball, float x, float y, float z); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 8d2dbf964b8..a15dad16e41 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -275,6 +275,19 @@ int is_basis_mball(Object *ob) return 1; } +/* return nonzero if ob1 is a basis mball for ob */ +int is_mball_basis_for(Object *ob1, Object *ob2) +{ + int basis1nr, basis2nr; + char basis1name[32], basis2name[32]; + + splitIDname(ob1->id.name+2, basis1name, &basis1nr); + splitIDname(ob2->id.name+2, basis2name, &basis2nr); + + if(!strcmp(basis1name, basis2name)) return is_basis_mball(ob1); + else return 0; +} + /* \brief copy some properties from object to other metaball object with same base name * * When some properties (wiresize, threshold, update flags) of metaball are changed, then this properties diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 61d81e461b6..5d3527d5afc 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -404,6 +404,9 @@ void unlink_object(Scene *scene, Object *ob) if(pchan->custom==ob) pchan->custom= NULL; } + } else if(ELEM(OB_MBALL, ob->type, obt->type)) { + if(is_mball_basis_for(obt, ob)) + obt->recalc|= OB_RECALC_DATA; } sca_remove_ob_poin(obt, ob); @@ -536,13 +539,7 @@ void unlink_object(Scene *scene, Object *ob) } tex= tex->id.next; } - - /* mballs (scene==NULL when called from library.c) */ - if(scene && ob->type==OB_MBALL) { - obt= find_basis_mball(scene, ob); - if(obt) freedisplist(&obt->disp); - } - + /* worlds */ wrld= G.main->world.first; while(wrld) { -- cgit v1.2.3 From aae952be1fc0d3ff6955e8d542d5330e93e96ef7 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 28 Jun 2010 00:11:28 +0000 Subject: Fix [#22669] Packing a .wav used in a LB crashes Blender --- source/blender/blenkernel/intern/packedFile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index db457f043e7..b01f570898e 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -224,7 +224,7 @@ void packAll(Main *bmain, ReportList *reports) vf->packedfile = newPackedFile(reports, vf->name); for(sound=bmain->sound.first; sound; sound=sound->id.next) - if(sound->packedfile == NULL && vf->id.lib==NULL) + if(sound->packedfile == NULL && sound->id.lib==NULL) sound->packedfile = newPackedFile(reports, sound->name); } -- cgit v1.2.3 From 8517a7a3cd93532ef1ff53ccbf07e8fc14a5109e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 28 Jun 2010 11:07:02 +0000 Subject: Fix #20965: metaballs partticles and volume material crash rendering Fix #21187: 2.5svn26947 - particles + meta sphere = crash in rendering Use separated displists for mballs in view3d and render stuff. Do not recalculate displist for view3d while rendering - mball.c uses several global variables which shouldn't be accepted from parallel threads. --- source/blender/blenkernel/BKE_displist.h | 1 + source/blender/blenkernel/BKE_lattice.h | 2 +- source/blender/blenkernel/BKE_mball.h | 4 ++-- source/blender/blenkernel/intern/displist.c | 16 +++++++++++++--- source/blender/blenkernel/intern/lattice.c | 4 ++-- source/blender/blenkernel/intern/mball.c | 10 ++++------ 6 files changed, 23 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 9e75e55adf6..df0627f61ba 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -93,6 +93,7 @@ extern void makeDispListCurveTypes(struct Scene *scene, struct Object *ob, int f extern void makeDispListCurveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forOrco); extern void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); extern void makeDispListMBall(struct Scene *scene, struct Object *ob); +extern void makeDispListMBall_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); extern void shadeDispList(struct Scene *scene, struct Base *base); extern void shadeMeshMCol(struct Scene *scene, struct Object *ob, struct Mesh *me); diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index f35dff53cd5..880f3f7e724 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -49,7 +49,7 @@ void init_latt_deform(struct Object *oblatt, struct Object *ob); void calc_latt_deform(struct Object *, float *co, float weight); void end_latt_deform(struct Object *); -int object_deform_mball(struct Object *ob); +int object_deform_mball(struct Object *ob, struct ListBase *dispbase); void outside_lattice(struct Lattice *lt); void curve_deform_verts(struct Scene *scene, struct Object *cuOb, struct Object *target, diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 130969d4892..5d41f4e374e 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -164,12 +164,12 @@ struct MetaBall *add_mball(char *name); struct MetaBall *copy_mball(struct MetaBall *mb); void make_local_mball(struct MetaBall *mb); void tex_space_mball(struct Object *ob); -float *make_orco_mball(struct Object *ob); +float *make_orco_mball(struct Object *ob, struct ListBase *dispbase); void copy_mball_properties(struct Scene *scene, struct Object *active_object); struct Object *find_basis_mball(struct Scene *scene, struct Object *ob); int is_basis_mball(struct Object *ob); int is_mball_basis_for(struct Object *ob1, struct Object *ob2); -void metaball_polygonize(struct Scene *scene, struct Object *ob); +void metaball_polygonize(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); void calc_mballco(struct MetaElem *ml, float *vec); float densfunc(struct MetaElem *ball, float x, float y, float z); float metaball(float x, float y, float z); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index a958d8c353b..716d3110bc3 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1172,20 +1172,30 @@ void makeDispListMBall(Scene *scene, Object *ob) { if(!ob || ob->type!=OB_MBALL) return; + // XXX: mball stuff uses plenty of global variables + // while this is unchanged updating during render is unsafe + if(G.rendering) return; + freedisplist(&(ob->disp)); - + if(ob->type==OB_MBALL) { if(ob==find_basis_mball(scene, ob)) { - metaball_polygonize(scene, ob); + metaball_polygonize(scene, ob, &ob->disp); tex_space_mball(ob); - object_deform_mball(ob); + object_deform_mball(ob, &ob->disp); } } boundbox_displist(ob); } +void makeDispListMBall_forRender(Scene *scene, Object *ob, ListBase *dispbase) +{ + metaball_polygonize(scene, ob, dispbase); + object_deform_mball(ob, dispbase); +} + static ModifierData *curve_get_tesselate_point(Scene *scene, Object *ob, int forRender, int editmode) { ModifierData *md = modifiers_getVirtualModifierList(ob); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 1954bac7e93..5824afd9ded 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -869,12 +869,12 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, end_latt_deform(laOb); } -int object_deform_mball(Object *ob) +int object_deform_mball(Object *ob, ListBase *dispbase) { if(ob->parent && ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) { DispList *dl; - for (dl=ob->disp.first; dl; dl=dl->next) { + for (dl=dispbase->first; dl; dl=dl->next) { lattice_deform_verts(ob->parent, ob, NULL, (float(*)[3]) dl->verts, dl->nr, NULL); } diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index a15dad16e41..da9740a1486 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -226,7 +226,7 @@ void tex_space_mball(Object *ob) boundbox_set_from_min_max(bb, min, max); } -float *make_orco_mball(Object *ob) +float *make_orco_mball(Object *ob, ListBase *dispbase) { BoundBox *bb; DispList *dl; @@ -243,7 +243,7 @@ float *make_orco_mball(Object *ob) loc[2]= (bb->vec[0][2]+bb->vec[1][2])/2.0f; size[2]= bb->vec[1][2]-loc[2]; - dl= ob->disp.first; + dl= dispbase->first; orcodata= MEM_mallocN(sizeof(float)*3*dl->nr, "MballOrco"); data= dl->verts; @@ -2088,7 +2088,7 @@ void init_metaball_octal_tree(int depth) subdivide_metaball_octal_node(node, size[0], size[1], size[2], metaball_tree->depth); } -void metaball_polygonize(Scene *scene, Object *ob) +void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) { PROCESS mbproc; MetaBall *mb; @@ -2105,7 +2105,6 @@ void metaball_polygonize(Scene *scene, Object *ob) object_scale_to_mat3(ob, smat); - freedisplist(&ob->disp); curindex= totindex= 0; indices= 0; thresh= mb->thresh; @@ -2174,9 +2173,8 @@ void metaball_polygonize(Scene *scene, Object *ob) } if(curindex) { - dl= MEM_callocN(sizeof(DispList), "mbaldisp"); - BLI_addtail(&ob->disp, dl); + BLI_addtail(dispbase, dl); dl->type= DL_INDEX4; dl->nr= mbproc.vertices.count; dl->parts= curindex; -- cgit v1.2.3 From a72679350789ce247c4428196f139b47c7d0963f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Jun 2010 16:37:50 +0000 Subject: default to global space for point density cache space. --- source/blender/blenkernel/intern/texture.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 31826f5be28..8178ef75a91 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1132,6 +1132,7 @@ PointDensity *BKE_add_pointdensity(void) pd->totpoints = 0; pd->object = NULL; pd->psys = 0; + pd->psys_cache_space= TEX_PD_WORLDSPACE; return pd; } -- cgit v1.2.3 From fab7671d20ac95474956b29decf96975ea01b13b Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Tue, 29 Jun 2010 15:56:05 +0000 Subject: Fixed bug #22686, Screw modifier VBO-related crash * Problem was calling setDrawOptions even if there was no original face index to use --- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 9bba893c2c8..a586ca57966 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -885,7 +885,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us else orig = actualFace; - if(setDrawOptions && !setDrawOptions(userData, orig, &drawSmooth)) + if(draw && setDrawOptions && !setDrawOptions(userData, orig, &drawSmooth)) draw = 0; /* Goal is to draw as long of a contiguous triangle -- cgit v1.2.3 From 35dd09a9efc7840a79e7ef345f5e8850c41f77b1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Jun 2010 22:07:27 +0000 Subject: add alpha option for new images (operator and function) --- source/blender/blenkernel/BKE_image.h | 2 +- source/blender/blenkernel/intern/image.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 7bdb9aaf709..d7eb5fe8246 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -115,7 +115,7 @@ void BKE_image_release_ibuf(struct Image *ima, void *lock); struct Image *BKE_add_image_file(const char *name, int frame); /* adds image, adds ibuf, generates color or pattern */ -struct Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4]); +struct Image *BKE_add_image_size(int width, int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]); /* adds image from imbuf, owns imbuf */ struct Image *BKE_add_image_imbuf(struct ImBuf *ibuf); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index f06e9302a60..a584e91fc0f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -380,18 +380,18 @@ Image *BKE_add_image_file(const char *name, int frame) return ima; } -static ImBuf *add_ibuf_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4]) +static ImBuf *add_ibuf_size(int width, int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { ImBuf *ibuf; unsigned char *rect= NULL; float *rect_float= NULL; if (floatbuf) { - ibuf= IMB_allocImBuf(width, height, 24, IB_rectfloat, 0); + ibuf= IMB_allocImBuf(width, height, depth, IB_rectfloat, 0); rect_float= (float*)ibuf->rect_float; } else { - ibuf= IMB_allocImBuf(width, height, 24, IB_rect, 0); + ibuf= IMB_allocImBuf(width, height, depth, IB_rect, 0); rect= (unsigned char*)ibuf->rect; } @@ -413,7 +413,7 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, int floatbuf, sho } /* adds new image block, creates ImBuf and initializes color */ -Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4]) +Image *BKE_add_image_size(int width, int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { /* on save, type is changed to FILE in editsima.c */ Image *ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); @@ -426,7 +426,7 @@ Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short ima->gen_y= height; ima->gen_type= uvtestgrid; - ibuf= add_ibuf_size(width, height, name, floatbuf, uvtestgrid, color); + ibuf= add_ibuf_size(width, height, name, depth, floatbuf, uvtestgrid, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ima->ok= IMA_OK_LOADED; @@ -2075,7 +2075,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) /* UV testgrid or black or solid etc */ if(ima->gen_x==0) ima->gen_x= 1024; if(ima->gen_y==0) ima->gen_y= 1024; - ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 0, ima->gen_type, color); + ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, 0, ima->gen_type, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ima->ok= IMA_OK_LOADED; } -- cgit v1.2.3 From 6ff10f00d4f239405a6f0e3706036dd1978dc6f8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 30 Jun 2010 14:43:28 +0000 Subject: Bugfix: effector weights were not copied when copying particle settings. --- source/blender/blenkernel/intern/particle.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 0c55cc2aaac..f33ac2ad380 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3536,6 +3536,7 @@ ParticleSettings *psys_copy_settings(ParticleSettings *part) partn= copy_libblock(part); if(partn->pd) partn->pd= MEM_dupallocN(part->pd); if(partn->pd2) partn->pd2= MEM_dupallocN(part->pd2); + partn->effector_weights = MEM_dupallocN(part->effector_weights); partn->boids = boid_copy_settings(part->boids); -- cgit v1.2.3 From 15be7b215f0ea53e68e114430267823e2b3fd37d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Jul 2010 20:09:42 +0000 Subject: - changes to the sequencer so new strips use the data name. - removed the name option for the sequence operators. --- source/blender/blenkernel/intern/sequencer.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4241f481c30..ddbe748ede9 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3909,7 +3909,7 @@ int seq_active_pair_get(Scene *scene, Sequence **seq_act, Sequence **seq_other) void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load) { if(seq) { - strcpy(seq->name, seq_load->name); + BLI_strncpy(seq->name+2, seq_load->name, sizeof(seq->name)-2); seqbase_unique_name_recursive(&scene->ed->seqbase, seq); if(seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) { @@ -3963,8 +3963,6 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel); seq->type= SEQ_IMAGE; - BLI_strncpy(seq->name+2, "Image", SEQ_NAME_MAXSTR-2); - seqbase_unique_name_recursive(&scene->ed->seqbase, seq); /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); @@ -3972,8 +3970,8 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->len = seq->len = seq_load->len ? seq_load->len : 1; strip->us= 1; strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - BLI_split_dirfile(seq_load->path, strip->dir, se->name); - + BLI_strncpy(strip->dir, seq_load->path, sizeof(strip->dir)); + seq_load_apply(scene, seq, seq_load); return seq; @@ -4085,6 +4083,9 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo seq_load->channel--; } + if(seq_load->name[0] == '\0') + BLI_strncpy(seq_load->name, se->name, sizeof(seq_load->name)); + /* can be NULL */ seq_load_apply(scene, seq, seq_load); -- cgit v1.2.3 From 7a495a12e1c367f8f1dbe14586c3798db5982171 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 3 Jul 2010 17:19:44 +0000 Subject: Fix for layer restoring with duplis, could be wrong sometimes when there with multiple instances and recursion. --- source/blender/blenkernel/intern/anim.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 6044cfa7692..fa0ddc5f1d3 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1532,7 +1532,10 @@ void free_object_duplilist(ListBase *lb) { DupliObject *dob; - for(dob= lb->first; dob; dob= dob->next) { + /* loop in reverse order, if object is instanced multiple times + the original layer may not really be original otherwise, proper + solution is more complicated */ + for(dob= lb->last; dob; dob= dob->prev) { dob->ob->lay= dob->origlay; copy_m4_m4(dob->ob->obmat, dob->omat); } -- cgit v1.2.3 From 80f6102629b746ea520d3ec54aaa6414c669a998 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 3 Jul 2010 17:47:06 +0000 Subject: better reporting for file i/o failier, use system error message in more places: Permission Denied, No space left, File not found etc. - blend load/save uses os message. - image load gives os message. (remove check for slash at end of line, just let the os report an error) - python api load image/font/text raise errors with message (was just retuning None for image and font) - minor edits to py api errors. --- source/blender/blenkernel/intern/image.c | 7 ------- source/blender/blenkernel/intern/object.c | 6 ++---- 2 files changed, 2 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a584e91fc0f..4daa38001bf 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -328,13 +328,6 @@ Image *BKE_add_image_file(const char *name, int frame) const char *libname; char str[FILE_MAX], strtest[FILE_MAX]; - /* escape when name is directory */ - len= strlen(name); - if(len) { - if(name[len-1]=='/' || name[len-1]=='\\') - return NULL; - } - BLI_strncpy(str, name, sizeof(str)); BLI_path_abs(str, G.sce); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 5d3527d5afc..8d38f5c8d15 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1724,10 +1724,8 @@ void object_to_mat4(Object *ob, float mat[][4]) object_to_mat3(ob, tmat); copy_m4_m3(mat, tmat); - - mat[3][0]= ob->loc[0] + ob->dloc[0]; - mat[3][1]= ob->loc[1] + ob->dloc[1]; - mat[3][2]= ob->loc[2] + ob->dloc[2]; + + add_v3_v3v3(mat[3], ob->loc, ob->dloc); } int enable_cu_speed= 1; -- cgit v1.2.3 From 6e5a436f56a6d7e69a61393d3a34940aecbf8a92 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sat, 3 Jul 2010 21:13:08 +0000 Subject: == Sequencer == This fixes: [#22722] Removing a sequence strip doesnt remove assosiated fcurves by using the same hack that is used for moving curve-data along with the strips on grab. Should be cleaned up (both functions!) by making sequencer-strips finally true IDs. Until that happens, there is only an more or less ugly way of doing that. --- source/blender/blenkernel/intern/sequencer.c | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index ddbe748ede9..baeff5a838b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -213,6 +213,8 @@ void seq_free_strip(Strip *strip) MEM_freeN(strip); } +static void seq_free_animdata(Scene *scene, Sequence *seq); + void seq_free_sequence(Scene *scene, Sequence *seq) { if(seq->strip) seq_free_strip(seq->strip); @@ -236,6 +238,8 @@ void seq_free_sequence(Scene *scene, Sequence *seq) sound_remove_scene_sound(scene, seq->scene_sound); } + seq_free_animdata(scene, seq); + MEM_freeN(seq); } @@ -3842,6 +3846,33 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs) } } +/* XXX - hackish function needed to remove all fcurves belonging to a sequencer strip */ +static void seq_free_animdata(Scene *scene, Sequence *seq) +{ + char str[32]; + FCurve *fcu; + + if(scene->adt==NULL || scene->adt->action==NULL) + return; + + sprintf(str, "[\"%s\"]", seq->name+2); + + fcu= scene->adt->action->curves.first; + + while (fcu) { + if(strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str)) { + FCurve *next_fcu = fcu->next; + + BLI_remlink(&scene->adt->action->curves, fcu); + free_fcurve(fcu); + + fcu = next_fcu; + } else { + fcu = fcu->next; + } + } +} + Sequence *get_seq_by_name(ListBase *seqbase, const char *name, int recursive) { -- cgit v1.2.3 From 5553f66eb777ff4ee589b91b42258e5e7a6fbfec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 4 Jul 2010 08:49:54 +0000 Subject: sequencer - effects strips now add directly above the strips they operate on (almost always what you want) - blend mode for new image/movie/scene/color strips is now cross: without this adjusting alpha will fade to black rather then the strip below. - SEQ_HAS_PATH macro didnt include sound-ram or sound-hd - meta drawing code has misleading variable names (from own commit). --- source/blender/blenkernel/intern/sequencer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index baeff5a838b..d0678bc1866 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3994,6 +3994,7 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel); seq->type= SEQ_IMAGE; + seq->blend_mode= SEQ_CROSS; /* so alpha adjustment fade to the strip below */ /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); @@ -4085,8 +4086,9 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo return NULL; seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel); - seq->type= SEQ_MOVIE; + seq->blend_mode= SEQ_CROSS; /* so alpha adjustment fade to the strip below */ + seq->anim= an; seq->anim_preseek = IMB_anim_get_preseek(an); BLI_strncpy(seq->name+2, "Movie", SEQ_NAME_MAXSTR-2); -- cgit v1.2.3 From 8aa0f9b033eff5aa4f6b66d3148d6379a60ebf06 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 4 Jul 2010 10:51:10 +0000 Subject: last fix still could give corrupt sound, rather then updating the sound info just add and remove the sound handle. --- source/blender/blenkernel/intern/sequencer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d0678bc1866..e21901f70d9 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -549,8 +549,8 @@ void calc_sequence(Scene *scene, Sequence *seq) if(seq->type==SEQ_META) { seqm= seq->seqbase.first; if(seqm) { - min= 1000000; - max= -1000000; + min= MAXFRAME * 2; + max= -MAXFRAME * 2; while(seqm) { if(seqm->startdisp < min) min= seqm->startdisp; if(seqm->enddisp > max) max= seqm->enddisp; -- cgit v1.2.3 From f9933b2fee786c0ba6341da0f151581fd768c921 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 4 Jul 2010 11:56:31 +0000 Subject: commenting group timeoffset since it causes groups objects to recalculate modifiers etc. constantly even when animation isnt playing. --- source/blender/blenkernel/intern/group.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index c8848572643..5f68c990ed2 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -328,6 +328,11 @@ void group_handle_recalc_and_update(Scene *scene, Object *parent, Group *group) { GroupObject *go; +#if 0 /* warning, isnt clearing the recalc flag on the object which causes it to run all the time, + * not just on frame change. + * This isnt working because the animation data is only re-evalyated on frame change so commenting for now + * but when its enabled at some point it will need to be changed so as not to update so much - campbell */ + /* if animated group... */ if(give_timeoffset(parent) != 0.0f || parent->nlastrips.first) { int cfrao; @@ -353,7 +358,9 @@ void group_handle_recalc_and_update(Scene *scene, Object *parent, Group *group) /* restore */ scene->r.cfra= cfrao; } - else { + else +#endif + { /* only do existing tags, as set by regular depsgraph */ for(go= group->gobject.first; go; go= go->next) { if(go->ob) { -- cgit v1.2.3 From ace570cb1024f0b3affd48b2f2104af3048d1707 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 4 Jul 2010 12:16:01 +0000 Subject: Fix for 15-day-old bug causing crashes when loading old 2.49 files, especially those with animation. Reverting 29563 ("* Moved do_versions_ipos_to_animato from blender.c to readfile.c, where it should be.") part to the original version that (so far) is guaranteed to work fine. While this means that "nice software design" isn't obeyed once again, this works and the other approach doesn't. So far there really isn't anything really obviously different between the approaches, even after trying a few different placements of the version patches within the file-reading internals. --- source/blender/blenkernel/intern/blender.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 134d49cdf24..9a97d975ede 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -64,6 +64,7 @@ #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_idprop.h" +#include "BKE_ipo.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_node.h" @@ -286,6 +287,11 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) //setscreen(G.curscreen); } + // FIXME: this version patching should really be part of the file-reading code, + // but we still get too many unrelated data-corruption crashes otherwise... + if (G.main->versionfile < 250) + do_versions_ipos_to_animato(G.main); + if(recover && bfd->filename[0] && G.relbase_valid) { /* in case of autosave or quit.blend, use original filename instead * use relbase_valid to make sure the file is saved, else we get in the filename */ -- cgit v1.2.3 From ca81aa704e958a73a55e79654f70eaa9a0fad85a Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sun, 4 Jul 2010 15:35:23 +0000 Subject: Patch [#22339] File/installation paths changes Patch Tracker: http://projects.blender.org/tracker/?func=detail&aid=22339&group_id=9&atid=127 This patch implements the proposal outlined here: http://wiki.blender.org/index.php/Dev:2.5/Source/Installation/Proposal Original patch by Matt Ebb. Contributions by Nathan Letwory, Damien Plisson and Andrea Weikert NOTE: This is a work in progress commit, some work still needs to be done on the SCons and CMake files for this to work properly, but at least should compile and the files should be created in the right directory. Commit discussed on IRC with Ton and Campbell. --- source/blender/blenkernel/SConscript | 1 + source/blender/blenkernel/intern/blender.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 6198520c853..a6705653769 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -67,6 +67,7 @@ if env['BF_NO_ELBEEM']: if env['WITH_BF_LCMS']: defs.append('WITH_LCMS') + incs += ' ' + env['BF_LCMS_INC'] if env['WITH_BF_LZO']: incs += ' #/extern/lzo/minilzo' diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 9a97d975ede..57e72fc5671 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -55,6 +55,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_path_util.h" #include "IMB_imbuf.h" @@ -368,7 +369,7 @@ int BKE_read_file(bContext *C, char *dir, void *unused, ReportList *reports) BlendFileData *bfd; int retval= 1; - if(strstr(dir, ".B25.blend")==0) /* dont print user-pref loading */ + if(strstr(dir, BLENDER_STARTUP_FILE)==0) /* dont print user-pref loading */ printf("read blend: %s\n", dir); bfd= BLO_read_from_file(dir, reports); -- cgit v1.2.3 From 83a2a4e5b889a023cb3d22120f348bd9e96bc2bb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 4 Jul 2010 20:59:10 +0000 Subject: Improvements to Blenders color balance (lift/gamma/gain). Fairly closely match some mac application colin has called 'Looks', to give better results. - lift is now applied non linear (was being added to the color) - change the color wheel to preserve the luminance of the gamma and gain values, this stops the color from being set too dark (option for the color wheel template). - sub-pixel precission for the color wheel since the white area at the center can make a lot of difference with a very small change. This change will make existing node and sequencer setups lift render slighly differently however discussed this with Ton and he's ok with it. --- source/blender/blenkernel/intern/sequencer.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index e21901f70d9..28cae5eeaa6 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -49,6 +49,7 @@ #include "RNA_access.h" #include "RE_pipeline.h" +#include "BLI_math.h" #include "BLI_fileops.h" #include "BLI_listbase.h" #include "BLI_path_util.h" @@ -1528,32 +1529,35 @@ static void make_cb_table_byte(float lift, float gain, float gamma, unsigned char * table, float mul) { int y; + /* matches 'LooksBuilder', generally looks nice too */ + if(lift >= 1.0f) lift= 0.0f; + else lift= (1.0f - lift) * (1.0f - lift); + /* end modif's */ for (y = 0; y < 256; y++) { - float v = 1.0 * y / 255; + float v = (float)y * (1.0 / 255.0f); v *= gain; - v += lift; + v = pow(v, lift); v = pow(v, gamma); v *= mul; - if ( v > 1.0) { - v = 1.0; - } else if (v < 0.0) { - v = 0.0; - } + CLAMP(v, 0.0f, 1.0f); table[y] = v * 255; } - } static void make_cb_table_float(float lift, float gain, float gamma, float * table, float mul) { int y; + /* matches 'LooksBuilder', generally looks nice too */ + if(lift >= 1.0f) lift= 0.0f; + else lift= (1.0f - lift) * (1.0f - lift); + /* end modif's */ for (y = 0; y < 256; y++) { - float v = (float) y * 1.0 / 255.0; + float v = (float)y * (1.0 / 255.0f); v *= gain; - v += lift; + v = pow(v, lift); v = pow(v, gamma); v *= mul; table[y] = v; -- cgit v1.2.3 From a824220d3e71afda0460c769324c9029243d0560 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 4 Jul 2010 23:26:55 +0000 Subject: better errors for failier to read blends --- source/blender/blenkernel/intern/group.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 5f68c990ed2..6377a6f6ccd 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -280,6 +280,7 @@ int group_is_animated(Object *parent, Group *group) return 0; } +#if 0 // add back when timeoffset & animsys work again /* only replaces object strips or action when parent nla instructs it */ /* keep checking nla.c though, in case internal structure of strip changes */ static void group_replaces_nla(Object *parent, Object *target, char mode) @@ -319,6 +320,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode) } } } +#endif /* puts all group members in local timing system, after this call you can draw everything, leaves tags in objects to signal it needs further updating */ -- cgit v1.2.3 From 9c4e3a7b6b3c90efd1f849dedd64ccfda98b97c2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 5 Jul 2010 00:00:40 +0000 Subject: bugfix [#22724] "Scene" switch on the console doesn't work --- source/blender/blenkernel/intern/scene.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 1bc690eb0ed..135464830f7 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -553,18 +553,17 @@ void set_scene_bg(Scene *scene) } /* called from creator.c */ -void set_scene_name(char *name) +Scene *set_scene_name(char *name) { - Scene *sce; - - for (sce= G.main->scene.first; sce; sce= sce->id.next) { - if (BLI_streq(name, sce->id.name+2)) { - set_scene_bg(sce); - return; - } + Scene *sce= (Scene *)find_id("SC", name); + if(sce) { + set_scene_bg(sce); + printf("Scene switch: '%s' in file: '%s'\n", name, G.sce); + return sce; } - - //XXX error("Can't find scene: %s", name); + + printf("Can't find scene: '%s' in file: '%s'\n", name, G.sce); + return NULL; } void unlink_scene(Main *bmain, Scene *sce, Scene *newsce) -- cgit v1.2.3 From fe6dfa52e9fd8dc8c1223255cdefafa1bd3e2aca Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 5 Jul 2010 00:48:57 +0000 Subject: Compile fix for r29954. He probably missed a file in the commit. --- source/blender/blenkernel/BKE_scene.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 9966aa11be3..b5b0a72d2d8 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -58,7 +58,7 @@ struct Scene *add_scene(char *name); struct Base *object_in_scene(struct Object *ob, struct Scene *sce); void set_scene_bg(struct Scene *sce); -void set_scene_name(char *name); +struct Scene *set_scene_name(char *name); struct Scene *copy_scene(struct Main *bmain, struct Scene *sce, int type); void unlink_scene(struct Main *bmain, struct Scene *sce, struct Scene *newsce); -- cgit v1.2.3 From 8c042f779f1cbbaec60532cbbc87a7eb99d84350 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 5 Jul 2010 01:11:25 +0000 Subject: Bugfix #19221: Layer animation not working Now object layers and scene-base layers are now always synced. In 2.4x, they were only synced if there was animation for layers, but it's probably not worth checking for this these days... Finally we can close this bug report :) --- source/blender/blenkernel/intern/ipo.c | 17 ++++++++--------- source/blender/blenkernel/intern/scene.c | 3 +++ 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 7f2ac50acd5..cd8ab8290e5 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1068,7 +1068,7 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c bActionGroup *agrp= NULL; /* init the temp action */ - //memset(&tmp_act, 0, sizeof(bAction)); // XXX only enable this line if we get errors + memset(&tmp_act, 0, sizeof(bAction)); // XXX only enable this line if we get errors tmp_act.groups.first= groups->first; tmp_act.groups.last= groups->last; tmp_act.curves.first= list->first; @@ -1084,8 +1084,8 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup"); agrp->flag = AGRP_SELECTED; - if(muteipo) agrp->flag |= AGRP_MUTED; - + if (muteipo) agrp->flag |= AGRP_MUTED; + strncpy(agrp->name, grpname, sizeof(agrp->name)); BLI_addtail(&tmp_act.groups, agrp); @@ -1097,9 +1097,9 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c /* WARNING: this func should only need to look at the stuff we initialised, if not, things may crash */ action_groups_add_channel(&tmp_act, agrp, fcu); - if(agrp->flag & AGRP_MUTED) /* flush down */ + if (agrp->flag & AGRP_MUTED) /* flush down */ fcu->flag |= FCURVE_MUTED; - + /* set the output lists based on the ones in the temp action */ groups->first= tmp_act.groups.first; groups->last= tmp_act.groups.last; @@ -1843,9 +1843,9 @@ void do_versions_ipos_to_animato(Main *main) Editing * ed = scene->ed; if (ed && ed->seqbasep) { Sequence * seq; - + adt= BKE_id_add_animdata(id); - + SEQ_BEGIN(ed, seq) { IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL; short adrcode = SEQ_FAC1; @@ -1877,8 +1877,7 @@ void do_versions_ipos_to_animato(Main *main) icu->adrcode = adrcode; /* convert IPO */ - ipo_to_animdata((ID *)scene, seq->ipo, - NULL, NULL, seq); + ipo_to_animdata((ID *)scene, seq->ipo, NULL, NULL, seq); seq->ipo->id.us--; seq->ipo = NULL; } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 135464830f7..af13aae159f 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -907,6 +907,9 @@ static void scene_update_tagged_recursive(Scene *scene, Scene *scene_parent) if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); + + /* always update layer, so that animating layers works */ + base->lay= ob->lay; } } -- cgit v1.2.3 From faf1c9a4bb27dfdd843cc745707d15ab47ce8683 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 5 Jul 2010 03:55:28 +0000 Subject: Bugfix #22685: Screen update slow, animation player ALT-A, files created with 2.4x Modifiers were being mistakenly recalculated at every frame as long as the object had animation, slowing things down due to incorrect depsgraph recalc tags. Renamed OB_RECALC -> OB_RECALC_ALL to reduce future confusion. During this process, I noticed a few dubious usages of OB_RECALC, so it's best to use this commit as a guide of places to check on. Apart from the place responsible for this bug, I haven't changed any OB_RECALC -> OB_RECALC_OB/DATA in case that introduces more unforseen bugs now, making it more difficult to track the problems later (rename + value change can be confusing to identify the genuine typos). --- source/blender/blenkernel/intern/depsgraph.c | 45 +++++++++++++++------- source/blender/blenkernel/intern/exotic.c | 2 +- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/object.c | 21 +++++----- source/blender/blenkernel/intern/particle_system.c | 2 +- 5 files changed, 46 insertions(+), 26 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 4be5cce38a8..c1223a5c37f 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1754,7 +1754,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) node->lasttime= curtime; ob= node->ob; - if(ob && (ob->recalc & OB_RECALC)) { + if(ob && (ob->recalc & OB_RECALC_ALL)) { all_layer= node->scelay; /* got an object node that changes, now check relations */ @@ -1797,7 +1797,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) if(ob->recalc & OB_RECALC_DATA) object_free_display(ob); - ob->recalc &= ~OB_RECALC; + ob->recalc &= ~OB_RECALC_ALL; } } @@ -1810,7 +1810,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) if(itA->node->type==ID_OB) { obc= itA->node->ob; /* child moves */ - if((obc->recalc & OB_RECALC)==OB_RECALC_OB) { + if((obc->recalc & OB_RECALC_ALL)==OB_RECALC_OB) { /* parent has deforming info */ if(itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) { // printf("parent %s changes ob %s\n", ob->id.name, obc->id.name); @@ -1864,7 +1864,7 @@ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int if(itA->node->lasttime!=curtime) { ob= (Object*)(node->ob); - if(reset || (ob->recalc & OB_RECALC)) { + if(reset || (ob->recalc & OB_RECALC_ALL)) { if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) ob->recalc |= OB_RECALC_DATA; @@ -1946,7 +1946,7 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB) { ob= (Object*)(itA->node->ob); - if(ob->recalc & OB_RECALC) { + if(ob->recalc & OB_RECALC_ALL) { if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) ob->recalc |= OB_RECALC_DATA; @@ -1962,11 +1962,30 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) static int object_modifiers_use_time(Object *ob) { ModifierData *md; - + + /* check if a modifier in modifier stack needs time input */ for (md=ob->modifiers.first; md; md=md->next) if (modifier_dependsOnTime(md)) return 1; - + + /* check whether any modifiers are animated */ + if (ob->adt) { + AnimData *adt = ob->adt; + + /* action - check for F-Curves with paths containing 'modifiers[' */ + if (adt->action) { + FCurve *fcu; + + for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) { + if (fcu->rna_path && strstr(fcu->rna_path, "modifiers[")) + return 1; + } + } + + // XXX: also, should check NLA strips, though for now assume that nobody uses + // that and we can omit that for performance reasons... + } + return 0; } @@ -2026,14 +2045,14 @@ static void dag_object_time_update_flags(Object *ob) /* this case is for groups with nla, whilst nla target has no action or nla */ for(strip= ob->nlastrips.first; strip; strip= strip->next) { if(strip->object) - strip->object->recalc |= OB_RECALC; + strip->object->recalc |= OB_RECALC_ALL; } } } #endif // XXX old animation system if(animdata_use_time(ob->adt)) { - ob->recalc |= OB_RECALC; + ob->recalc |= OB_RECALC_OB; ob->adt->recalc |= ADT_RECALC_ANIM; } @@ -2276,7 +2295,7 @@ void DAG_id_flush_update(ID *id, short flag) /* set flags & pointcache for object */ if(GS(id->name) == ID_OB) { ob= (Object*)id; - ob->recalc |= (flag & OB_RECALC); + ob->recalc |= (flag & OB_RECALC_ALL); BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH); if(flag & OB_RECALC_DATA) { @@ -2331,7 +2350,7 @@ void DAG_id_flush_update(ID *id, short flag) for(obt=bmain->object.first; obt; obt= obt->id.next) { Key *key= ob_get_key(obt); if(!(ob && obt == ob) && ((ID *)key == id)) { - obt->flag |= (OB_RECALC|OB_RECALC_DATA); + obt->flag |= (OB_RECALC_OB|OB_RECALC_DATA); BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); } } @@ -2344,7 +2363,7 @@ void DAG_id_flush_update(ID *id, short flag) for(psys=obt->particlesystem.first; psys; psys=psys->next) { if(&psys->part->id == id) { BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); - obt->recalc |= (flag & OB_RECALC); + obt->recalc |= (flag & OB_RECALC_ALL); psys->recalc |= (flag & PSYS_RECALC); } } @@ -2424,7 +2443,7 @@ void DAG_id_update_flags(ID *id) GroupObject *go; /* primitive; tag all... this call helps building groups for particles */ for(go= group->gobject.first; go; go= go->next) - go->ob->recalc= OB_RECALC; + go->ob->recalc= OB_RECALC_ALL; } } else { diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 91c5a633ff6..cdefbb54ecf 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -4071,7 +4071,7 @@ static void dxf_read(Scene *scene, char *filename) ob->dupon= 1; ob->dupoff= 0; ob->dupsta= 1; ob->dupend= 100; - ob->recalc= OB_RECALC; /* needed because of weird way of adding libdata directly */ + ob->recalc= OB_RECALC_ALL; /* needed because of weird way of adding libdata directly */ ob->data= obdata; ((ID*)ob->data)->us++; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 5931bf973af..8d859a2f712 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -445,7 +445,7 @@ void recalc_all_library_objects(Main *main) /* flag for full recalc */ for(ob=main->object.first; ob; ob=ob->id.next) if(ob->id.lib) - ob->recalc |= OB_RECALC; + ob->recalc |= OB_RECALC_ALL; } /* note: MAX_LIBARRAY define should match this code */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 8d38f5c8d15..1b8405a91de 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -317,7 +317,7 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec if (*obpoin==unlinkOb) { *obpoin = NULL; - ob->recalc |= OB_RECALC; + ob->recalc |= OB_RECALC_ALL; // XXX: should this just be OB_RECALC_DATA? } } @@ -357,7 +357,7 @@ void unlink_object(Scene *scene, Object *ob) if(obt->parent==ob) { obt->parent= NULL; - obt->recalc |= OB_RECALC; + obt->recalc |= OB_RECALC_ALL; } modifiers_foreachObjectLink(obt, unlink_object__unlinkModifierLinks, ob); @@ -367,15 +367,15 @@ void unlink_object(Scene *scene, Object *ob) if(cu->bevobj==ob) { cu->bevobj= NULL; - obt->recalc |= OB_RECALC; + obt->recalc |= OB_RECALC_ALL; } if(cu->taperobj==ob) { cu->taperobj= NULL; - obt->recalc |= OB_RECALC; + obt->recalc |= OB_RECALC_ALL; } if(cu->textoncurve==ob) { cu->textoncurve= NULL; - obt->recalc |= OB_RECALC; + obt->recalc |= OB_RECALC_ALL; } } else if(obt->type==OB_ARMATURE && obt->pose) { @@ -1087,7 +1087,7 @@ Object *add_object(struct Scene *scene, int type) base= scene_add_base(scene, ob); scene_select_base(scene, base); - ob->recalc |= OB_RECALC; + ob->recalc |= OB_RECALC_ALL; return ob; } @@ -1533,7 +1533,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) ob->proxy_group= gob; id_lib_extern(&target->id); - ob->recalc= target->recalc= OB_RECALC; + ob->recalc= target->recalc= OB_RECALC_ALL; /* copy transform */ if(gob) { @@ -2474,14 +2474,15 @@ void object_tfm_restore(Object *ob, void *obtfm_pt) /* requires flags to be set! */ void object_handle_update(Scene *scene, Object *ob) { - if(ob->recalc & OB_RECALC) { + if(ob->recalc & OB_RECALC_ALL) { /* speed optimization for animation lookups */ if(ob->pose) make_pose_channels_hash(ob->pose); /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, which is only in where_is_object now */ - if(ob->recalc & OB_RECALC) { + // XXX: should this case be OB_RECALC_OB instead? + if(ob->recalc & OB_RECALC_ALL) { if (G.f & G_DEBUG) printf("recalcob %s\n", ob->id.name+2); @@ -2623,7 +2624,7 @@ void object_handle_update(Scene *scene, Object *ob) object_handle_update(scene, ob->proxy); } - ob->recalc &= ~OB_RECALC; + ob->recalc &= ~OB_RECALC_ALL; } /* the case when this is a group proxy, object_update is called in group.c */ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 3a6fb92d63a..3ed2181f908 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3943,7 +3943,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) BKE_animsys_evaluate_animdata(&part->id, part->adt, cfra, ADT_RECALC_DRIVERS); /* TODO: only free child paths in case of PSYS_RECALC_CHILD */ - if(psys->recalc & PSYS_RECALC || ob->recalc & OB_RECALC) + if(psys->recalc & PSYS_RECALC || ob->recalc & OB_RECALC_ALL) psys_free_path_cache(psys, NULL); if(psys->recalc & PSYS_RECALC_CHILD) -- cgit v1.2.3 From 58778d41e2496d3ba4d150eda7fb9d247a639c53 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 5 Jul 2010 09:56:06 +0000 Subject: Color Balance - color_balance_float_float wasnt using the new calculation method - moved calculation into an inline function color_balance_fl() & made the lift adjustments less confusing. --- source/blender/blenkernel/intern/sequencer.c | 46 +++++++++++----------------- 1 file changed, 18 insertions(+), 28 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 28cae5eeaa6..2f25c24272e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1493,15 +1493,15 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) StripColorBalance cb = *cb_; int c; - if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) { - for (c = 0; c < 3; c++) { - cb.lift[c] = 1.0 - cb.lift[c]; - } - } else { - for (c = 0; c < 3; c++) { - cb.lift[c] = -(1.0 - cb.lift[c]); - } + for (c = 0; c < 3; c++) { + cb.lift[c] = 2.0f - pow(cb.lift[c], 2); + } + + if(cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) { + negate_v3(cb.lift); } + + if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAIN) { for (c = 0; c < 3; c++) { if (cb.gain[c] != 0.0) { @@ -1525,21 +1525,20 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) return cb; } +/* compiler should inline */ +MINLINE float color_balance_fl(float v, float lift, float gain, float gamma, float mul) +{ + return pow(pow(v * gain, lift), gamma) * mul; +} + + static void make_cb_table_byte(float lift, float gain, float gamma, unsigned char * table, float mul) { int y; - /* matches 'LooksBuilder', generally looks nice too */ - if(lift >= 1.0f) lift= 0.0f; - else lift= (1.0f - lift) * (1.0f - lift); - /* end modif's */ for (y = 0; y < 256; y++) { - float v = (float)y * (1.0 / 255.0f); - v *= gain; - v = pow(v, lift); - v = pow(v, gamma); - v *= mul; + float v= color_balance_fl((float)y * (1.0 / 255.0f), lift, gain, gamma, mul); CLAMP(v, 0.0f, 1.0f); table[y] = v * 255; } @@ -1549,17 +1548,9 @@ static void make_cb_table_float(float lift, float gain, float gamma, float * table, float mul) { int y; - /* matches 'LooksBuilder', generally looks nice too */ - if(lift >= 1.0f) lift= 0.0f; - else lift= (1.0f - lift) * (1.0f - lift); - /* end modif's */ for (y = 0; y < 256; y++) { - float v = (float)y * (1.0 / 255.0f); - v *= gain; - v = pow(v, lift); - v = pow(v, gamma); - v *= mul; + float v= color_balance_fl((float)y * (1.0 / 255.0f), lift, gain, gamma, mul); table[y] = v; } } @@ -1630,8 +1621,7 @@ static void color_balance_float_float(Sequence * seq, TStripElem* se, float mul) while (p < e) { int c; for (c = 0; c < 3; c++) { - p[c] = pow(p[c] * cb.gain[c] + cb.lift[c], - cb.gamma[c]) * mul; + p[c]= color_balance_fl(p[c], cb.lift[c], cb.gain[c], cb.gamma[c], mul); } p += 4; } -- cgit v1.2.3 From c9f667a92e492636ee6989c9cefda3c6caafc843 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 5 Jul 2010 10:18:59 +0000 Subject: texture saturation option. we'll need a do-version bump soon or this will convert 0.0 saturation to 1.0 on load. --- source/blender/blenkernel/intern/texture.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 8178ef75a91..57816b7e470 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -451,6 +451,7 @@ void default_tex(Tex *tex) tex->nabla= 0.025; // also in do_versions tex->bright= 1.0; tex->contrast= 1.0; + tex->saturation= 1.0; tex->filtersize= 1.0; tex->rfac= 1.0; tex->gfac= 1.0; -- cgit v1.2.3 From 5bacd2df29855e0628d8a48c1f0321b8d1c429ac Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 Jul 2010 11:52:54 +0000 Subject: Fix #22666: linked data lights lag during transform in GLSL mode. Actually a depsgraph issue, transforming objects was incorrectly tagging their data for recalculation. --- source/blender/blenkernel/intern/depsgraph.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index c1223a5c37f..0dbdd802ff6 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2303,8 +2303,10 @@ void DAG_id_flush_update(ID *id, short flag) id= ob->data; /* no point in trying in this cases */ - if(!id || id->us <= 1) + if(id && id->us <= 1) { + dag_editors_update(bmain, id); id= NULL; + } } } -- cgit v1.2.3 From efeb8148c8dc03a08121767492e34fa31c70d72b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 Jul 2010 12:20:49 +0000 Subject: Fix #22213: applying deform modifier in front of multires modifier crashes, should not do multires reshape in this case, but just regular apply. --- source/blender/blenkernel/BKE_multires.h | 3 ++- source/blender/blenkernel/intern/multires.c | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index e8bbb58a895..39fc795e6ff 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -47,7 +47,8 @@ void multires_force_external_reload(struct Object *ob); struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, int local_mmd, struct DerivedMesh*, struct Object *, int, int); -struct MultiresModifierData *find_multires_modifier(struct Scene *scene, struct Object *ob); +struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene, + struct ModifierData *lastmd); struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd, struct Object *ob); void multiresModifier_join(struct Object *); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 76d82889cda..56d517f1e13 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -75,11 +75,11 @@ DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob return dm; } -MultiresModifierData *find_multires_modifier(Scene *scene, Object *ob) +MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData *lastmd) { ModifierData *md; - for(md = ob->modifiers.first; md; md = md->next) { + for(md = lastmd; md; md = md->prev) { if(md->type == eModifierType_Multires) { if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) return (MultiresModifierData*)md; @@ -249,6 +249,9 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm int numVerts, result; float (*deformedVerts)[3]; + if(multires_get_level(ob, mmd, 0) == 0) + return 0; + /* Create DerivedMesh for deformation modifier */ dm = get_multires_dm(scene, mmd, ob); numVerts= dm->getNumVerts(dm); -- cgit v1.2.3 From b1cdc52b30f709848c7f30eb077d6d5c20c43428 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 5 Jul 2010 14:29:16 +0000 Subject: Color Balance Node changes from sequencer applied to compositor mostly noticable is how the lift works. Before & After, http://www.graphicall.org/ftp/ideasman42/color_balance_before_after.png even with lower values these kinds of errors can be seen. --- source/blender/blenkernel/intern/sequencer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 2f25c24272e..fa2c11f3395 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1525,13 +1525,12 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) return cb; } -/* compiler should inline */ -MINLINE float color_balance_fl(float v, float lift, float gain, float gamma, float mul) +/* pow(p[c] * cb.gain[c] + cb.lift[c], cb.gamma[c]) * mul;*/ +MINLINE float color_balance_fl(const float v, const float lift, const float gain, const float gamma, const float mul) { - return pow(pow(v * gain, lift), gamma) * mul; + return powf(powf(v * gain, lift), gamma) * mul; } - static void make_cb_table_byte(float lift, float gain, float gamma, unsigned char * table, float mul) { -- cgit v1.2.3 From aea7ea5b30cc5434f0b747ead8d2947d91a28964 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 5 Jul 2010 14:53:11 +0000 Subject: recent commit broke invert option for sequencer lift. --- source/blender/blenkernel/intern/sequencer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index fa2c11f3395..a4c1527c3c5 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1498,10 +1498,11 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) } if(cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) { - negate_v3(cb.lift); + for (c = 0; c < 3; c++) { + cb.lift[c] = 2.0f - cb.lift[c]; + } } - if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAIN) { for (c = 0; c < 3; c++) { if (cb.gain[c] != 0.0) { -- cgit v1.2.3 From ca252e39f59a0ca71aba06bf93e40b86029f0d72 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 Jul 2010 10:21:28 +0000 Subject: Correction to recent color balance compositor and sequencer changes. - In my changes lift was acting like a second gamma. - In blender 2.4x it was being added which gave ugly clipping. - in Magic Bullet Looks it scales the color about 1.0: (col - 1 * (2-lift)) + 1 Did more testing and made sure the order of applying lift/gamma/gain works the same as MagicBulletLooks (tested on Collin's mac laptop). --- source/blender/blenkernel/intern/sequencer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index a4c1527c3c5..bd3e0129bcc 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1494,7 +1494,7 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) int c; for (c = 0; c < 3; c++) { - cb.lift[c] = 2.0f - pow(cb.lift[c], 2); + cb.lift[c] = 2.0f - cb.lift[c]; } if(cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) { @@ -1526,10 +1526,10 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) return cb; } -/* pow(p[c] * cb.gain[c] + cb.lift[c], cb.gamma[c]) * mul;*/ -MINLINE float color_balance_fl(const float v, const float lift, const float gain, const float gamma, const float mul) +/* note: lift is actually 2-lift */ +MINLINE float color_balance_fl(float v, const float lift, const float gain, const float gamma, const float mul) { - return powf(powf(v * gain, lift), gamma) * mul; + return powf((((v - 1.0f) * lift) + 1.0f) * gain, gamma) * mul; } static void make_cb_table_byte(float lift, float gain, float gamma, -- cgit v1.2.3 From 137e53064cf65b736347b75f2580d82fe63d17ca Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 6 Jul 2010 11:44:45 +0000 Subject: Revert revision 29735: Fix #22051: crash when scaling parent metaball. Keep the constant resolution for any motherball's scale. This avoids running out of memory when scaling the metaball down, but there's a reason it depends on this scaling, for example for instancing it's more useful to have this. It also doesn't really solve the problem but only moves it, it's still possible to run out of memory with different setups/scales. --- source/blender/blenkernel/BKE_mball.h | 1 - source/blender/blenkernel/intern/mball.c | 27 +++++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 5d41f4e374e..8d7d205e847 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -97,7 +97,6 @@ typedef struct process { /* parameters, function, storage */ CENTERLIST **centers; /* cube center hash table */ CORNER **corners; /* corner value hash table */ EDGELIST **edges; /* edge and vertex id hash table */ - float scale[3]; } PROCESS; /* dividing scene using octal tree makes polygonisation faster */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index da9740a1486..a97bec670d6 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -889,11 +889,11 @@ CORNER *setcorner (PROCESS* p, int i, int j, int k) c = (CORNER *) new_pgn_element(sizeof(CORNER)); c->i = i; - c->x = ((float)i-0.5f)*p->size/p->scale[0]; + c->x = ((float)i-0.5f)*p->size; c->j = j; - c->y = ((float)j-0.5f)*p->size/p->scale[1]; + c->y = ((float)j-0.5f)*p->size; c->k = k; - c->z = ((float)k-0.5f)*p->size/p->scale[2]; + c->z = ((float)k-0.5f)*p->size; c->value = p->function(c->x, c->y, c->z); c->next = p->corners[index]; @@ -1422,9 +1422,9 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) workp_v = in_v; max_len = sqrt((out.x-in.x)*(out.x-in.x) + (out.y-in.y)*(out.y-in.y) + (out.z-in.z)*(out.z-in.z)); - nx = abs((out.x - in.x)/mbproc->size*mbproc->scale[0]); - ny = abs((out.y - in.y)/mbproc->size*mbproc->scale[1]); - nz = abs((out.z - in.z)/mbproc->size*mbproc->scale[2]); + nx = abs((out.x - in.x)/mbproc->size); + ny = abs((out.y - in.y)/mbproc->size); + nz = abs((out.z - in.z)/mbproc->size); MAXN = MAX3(nx,ny,nz); if(MAXN!=0.0f) { @@ -1443,9 +1443,9 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) if((tmp_v<0.0 && workp_v>=0.0)||(tmp_v>0.0 && workp_v<=0.0)) { /* indexes of CUBE, which includes "first point" */ - c_i= (int)floor(workp.x/mbproc->size*mbproc->scale[0]); - c_j= (int)floor(workp.y/mbproc->size*mbproc->scale[1]); - c_k= (int)floor(workp.z/mbproc->size*mbproc->scale[2]); + c_i= (int)floor(workp.x/mbproc->size); + c_j= (int)floor(workp.y/mbproc->size); + c_k= (int)floor(workp.z/mbproc->size); /* add CUBE (with indexes c_i, c_j, c_k) to the stack, * this cube includes found point of Implicit Surface */ @@ -2095,7 +2095,6 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) DispList *dl; int a, nr_cubes; float *ve, *no, totsize, width; - float smat[3][3]; mb= ob->data; @@ -2103,8 +2102,6 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) if(!(G.rendering) && (mb->flag==MB_UPDATE_NEVER)) return; if(G.moving && mb->flag==MB_UPDATE_FAST) return; - object_scale_to_mat3(ob, smat); - curindex= totindex= 0; indices= 0; thresh= mb->thresh; @@ -2145,7 +2142,6 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) width= mb->wiresize; if(G.moving && mb->flag==MB_UPDATE_HALFRES) width*= 2; } - /* nr_cubes is just for safety, minimum is totsize */ nr_cubes= (int)(0.5+totsize/width); @@ -2156,11 +2152,6 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) mbproc.cubes= 0; mbproc.delta = width/(float)(RES*RES); - /* to keep constant resolution for any motherball scale */ - mbproc.scale[0]= smat[0][0]; - mbproc.scale[1]= smat[1][1]; - mbproc.scale[2]= smat[2][2]; - polygonize(&mbproc, mb); MEM_freeN(mainb); -- cgit v1.2.3 From 2a95a246eda72b3d08d0572562953a5703baa4b7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 Jul 2010 16:44:05 +0000 Subject: color balance can now be animated in the sequencer. --- source/blender/blenkernel/BKE_sequencer.h | 4 ++-- source/blender/blenkernel/intern/sequencer.c | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 6fe1c2a96ea..5c5bf30980c 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -136,8 +136,8 @@ struct SeqEffectHandle { void printf_strip(struct Sequence *seq); /* apply functions recursively */ -void seqbase_recursive_apply(struct ListBase *seqbase, int (*apply_func)(struct Sequence *seq, void *), void *arg); -void seq_recursive_apply(struct Sequence *seq, int (*apply_func)(struct Sequence *, void *), void *arg); +int seqbase_recursive_apply(struct ListBase *seqbase, int (*apply_func)(struct Sequence *seq, void *), void *arg); +int seq_recursive_apply(struct Sequence *seq, int (*apply_func)(struct Sequence *, void *), void *arg); // extern void seq_free_sequence(struct Scene *scene, struct Sequence *seq); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index bd3e0129bcc..894b8b6ab60 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -87,18 +87,27 @@ void printf_strip(Sequence *seq) fprintf(stderr, "\tseq_tx_set_final_left: %d %d\n\n", seq_tx_get_final_left(seq, 0), seq_tx_get_final_right(seq, 0)); } -void seqbase_recursive_apply(ListBase *seqbase, int (*apply_func)(Sequence *seq, void *), void *arg) +int seqbase_recursive_apply(ListBase *seqbase, int (*apply_func)(Sequence *seq, void *), void *arg) { Sequence *iseq; for(iseq= seqbase->first; iseq; iseq= iseq->next) { - seq_recursive_apply(iseq, apply_func, arg); + if(seq_recursive_apply(iseq, apply_func, arg) == -1) + return -1; /* bail out */ } + return 1; } -void seq_recursive_apply(Sequence *seq, int (*apply_func)(Sequence *, void *), void *arg) +int seq_recursive_apply(Sequence *seq, int (*apply_func)(Sequence *, void *), void *arg) { - if(apply_func(seq, arg) && seq->seqbase.first) - seqbase_recursive_apply(&seq->seqbase, apply_func, arg); + int ret= apply_func(seq, arg); + + if(ret == -1) + return -1; /* bail out */ + + if(ret && seq->seqbase.first) + ret = seqbase_recursive_apply(&seq->seqbase, apply_func, arg); + + return ret; } /* ********************************************************************** -- cgit v1.2.3 From ed1de5d2760e565fd149496549614b36ff3a6543 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 Jul 2010 13:14:51 +0000 Subject: dont swap strip names when swapping strips, means they keep their fcurves --- source/blender/blenkernel/intern/sequencer.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 894b8b6ab60..8412b5d64de 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3799,6 +3799,8 @@ ListBase *seq_seqbase(ListBase *seqbase, Sequence *seq) int seq_swap(Sequence *seq_a, Sequence *seq_b) { + char name[sizeof(seq_a->name)]; + if(seq_a->len != seq_b->len) return 0; @@ -3807,12 +3809,33 @@ int seq_swap(Sequence *seq_a, Sequence *seq_b) if(seq_a->type == SEQ_SOUND || seq_b->type == SEQ_SOUND) { return 0; } + + /* disallow effects to swap with non-effects strips */ + if((seq_a->type & SEQ_EFFECT) != (seq_b->type & SEQ_EFFECT)) { + return 0; + } + + if((seq_a->type & SEQ_EFFECT) && (seq_b->type & SEQ_EFFECT)) { + if(get_sequence_effect_num_inputs(seq_a->type) != get_sequence_effect_num_inputs(seq_b->type)) { + return 0; + } + } } SWAP(Sequence, *seq_a, *seq_b); + + /* swap back names so animation fcurves dont get swapped */ + strcpy(name, seq_a->name+2); + strcpy(seq_a->name+2, seq_b->name+2); + strcpy(seq_b->name+2, name); + + /* swap back opacity, and overlay mode */ + SWAP(int, seq_a->blend_mode, seq_b->blend_mode); + SWAP(float, seq_a->blend_opacity, seq_b->blend_opacity); + + SWAP(void *, seq_a->prev, seq_b->prev); SWAP(void *, seq_a->next, seq_b->next); - SWAP(int, seq_a->start, seq_b->start); SWAP(int, seq_a->startofs, seq_b->startofs); SWAP(int, seq_a->endofs, seq_b->endofs); -- cgit v1.2.3 From 358738c1aa6115aa7ccbd676166f943e4ee1dbd3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 Jul 2010 14:28:22 +0000 Subject: Fix #22354, #22727, #22501: image window not display correct renders with compositing and slots. --- source/blender/blenkernel/intern/image.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 4daa38001bf..dc78dac04dd 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1827,10 +1827,13 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ layer= (iuser)? iuser->layer: 0; pass= (iuser)? iuser->pass: 0; - if(from_render) + if(from_render) { RE_AcquireResultImage(re, &rres); - else if(ima->renders[ima->render_slot]) + } + else if(ima->renders[ima->render_slot]) { rres= *(ima->renders[ima->render_slot]); + rres.have_combined= rres.rectf != NULL; + } else memset(&rres, 0, sizeof(RenderResult)); @@ -1852,10 +1855,10 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ rectz= rres.rectz; dither= iuser->scene->r.dither_intensity; - /* get compo/seq result by default */ - if(rres.compo_seq && layer==0); + /* combined layer gets added as first layer */ + if(rres.have_combined && layer==0); else if(rres.layers.first) { - RenderLayer *rl= BLI_findlink(&rres.layers, layer-(rres.compo_seq?1:0)); + RenderLayer *rl= BLI_findlink(&rres.layers, layer-(rres.have_combined?1:0)); if(rl) { RenderPass *rpass; -- cgit v1.2.3 From be1846bcf68636628b60e5b958a6b41e41b3f5a0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 Jul 2010 15:06:57 +0000 Subject: fix for numeric problems for color balance in the sequencer (same check as in compositor). for optimized builds this gave crazy colors. --- source/blender/blenkernel/intern/sequencer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 8412b5d64de..cf9e159bafb 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1536,9 +1536,14 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) } /* note: lift is actually 2-lift */ -MINLINE float color_balance_fl(float v, const float lift, const float gain, const float gamma, const float mul) +MINLINE float color_balance_fl(float in, const float lift, const float gain, const float gamma, const float mul) { - return powf((((v - 1.0f) * lift) + 1.0f) * gain, gamma) * mul; + float x= (((in - 1.0f) * lift) + 1.0f) * gain; + + /* prevent NaN */ + if (x < 0.f) x = 0.f; + + return powf(x, gamma) * mul; } static void make_cb_table_byte(float lift, float gain, float gamma, -- cgit v1.2.3 From e8be069870b9125e87d533cbb84cf049be5d1442 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 Jul 2010 16:17:18 +0000 Subject: duplicating a sequence strip now duplicates its fcurves --- source/blender/blenkernel/BKE_sequencer.h | 2 ++ source/blender/blenkernel/intern/sequencer.c | 39 +++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 5c5bf30980c..3b95c25006d 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -187,6 +187,7 @@ void seq_single_fix(struct Sequence *seq); int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test); struct ListBase *seq_seqbase(struct ListBase *seqbase, struct Sequence *seq); void seq_offset_animdata(struct Scene *scene, struct Sequence *seq, int ofs); +void seq_dupe_animdata(struct Scene *scene, char *name_from, char *name_to); int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test, struct Scene *evil_scene); int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene); int seqbase_isolated_sel_check(struct ListBase *seqbase); @@ -232,6 +233,7 @@ typedef struct SeqLoadInfo { /* seq_dupli' flags */ #define SEQ_DUPE_UNIQUE_NAME 1<<0 #define SEQ_DUPE_CONTEXT 1<<1 +#define SEQ_DUPE_ANIM 1<<2 /* use as an api function */ typedef struct Sequence *(*SeqLoadFunc)(struct bContext *, ListBase *, struct SeqLoadInfo *); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index cf9e159bafb..2bf328147c8 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -40,6 +40,7 @@ #include "DNA_anim_types.h" #include "DNA_object_types.h" +#include "BKE_animsys.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.h" @@ -3877,6 +3878,37 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs) } } +void seq_dupe_animdata(Scene *scene, char *name_from, char *name_to) +{ + char str_from[32]; + char str_to[32]; + FCurve *fcu; + FCurve *fcu_last; + FCurve *fcu_cpy; + ListBase lb= {NULL, NULL}; + + if(scene->adt==NULL || scene->adt->action==NULL) + return; + + sprintf(str_from, "[\"%s\"]", name_from); + sprintf(str_to, "[\"%s\"]", name_to); + + fcu_last= scene->adt->action->curves.last; + + for (fcu= scene->adt->action->curves.first; fcu && fcu->prev != fcu_last; fcu= fcu->next) { + if(strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str_from)) { + fcu_cpy= copy_fcurve(fcu); + BLI_addtail(&lb, fcu_cpy); + } + } + + /* notice validate is 0, keep this because the seq may not be added to the scene yet */ + BKE_animdata_fix_paths_rename(&scene->id, scene->adt, "sequence_editor.sequences_all", name_from, name_to, 0, 0, 0); + + /* add the original fcurves back */ + addlisttolist(&scene->adt->action->curves, &lb); +} + /* XXX - hackish function needed to remove all fcurves belonging to a sequencer strip */ static void seq_free_animdata(Scene *scene, Sequence *seq) { @@ -4233,8 +4265,13 @@ static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag) " now...\n"); } - if(dupe_flag & SEQ_DUPE_UNIQUE_NAME) + if(dupe_flag & SEQ_DUPE_UNIQUE_NAME) { seqbase_unique_name_recursive(&scene->ed->seqbase, seqn); + printf("%s %s\n", seqn->name+2, seq->name+2); + } + + if(dupe_flag & SEQ_DUPE_ANIM) + seq_dupe_animdata(scene, seq->name+2, seqn->name+2); return seqn; } -- cgit v1.2.3 From 6debe0fcf6ac0978162808621f7fa29e104f833b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 Jul 2010 16:37:41 +0000 Subject: fix for duplicating metastrips, unique names and animation data. --- source/blender/blenkernel/intern/sequencer.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 2bf328147c8..cfe2a6bb207 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3881,7 +3881,6 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs) void seq_dupe_animdata(Scene *scene, char *name_from, char *name_to) { char str_from[32]; - char str_to[32]; FCurve *fcu; FCurve *fcu_last; FCurve *fcu_cpy; @@ -3891,7 +3890,6 @@ void seq_dupe_animdata(Scene *scene, char *name_from, char *name_to) return; sprintf(str_from, "[\"%s\"]", name_from); - sprintf(str_to, "[\"%s\"]", name_to); fcu_last= scene->adt->action->curves.last; @@ -4265,10 +4263,8 @@ static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag) " now...\n"); } - if(dupe_flag & SEQ_DUPE_UNIQUE_NAME) { + if(dupe_flag & SEQ_DUPE_UNIQUE_NAME) seqbase_unique_name_recursive(&scene->ed->seqbase, seqn); - printf("%s %s\n", seqn->name+2, seq->name+2); - } if(dupe_flag & SEQ_DUPE_ANIM) seq_dupe_animdata(scene, seq->name+2, seqn->name+2); -- cgit v1.2.3 From 1ff98fb454477dafa88a5499ad97511e571ce17a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 Jul 2010 17:08:20 +0000 Subject: Fix #21540: depsgraph problem on load, meshes on non-visible layers were not created when objects on visible layers depended on them, now it uses the flushed layer to determine if the object data should be recalculated. --- source/blender/blenkernel/intern/depsgraph.c | 45 +++++++++++++++++++--------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 0dbdd802ff6..1a1ca8a8d3e 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1877,26 +1877,19 @@ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int } } -/* flushes all recalc flags in objects down the dependency tree */ -void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) +/* flush layer flags to dependencies */ +static void dag_scene_flush_layers(Scene *sce, int lay) { - DagNode *firstnode, *node; + DagNode *node, *firstnode; DagAdjList *itA; - Object *ob; Base *base; int lasttime; - - if(sce->theDag==NULL) { - printf("DAG zero... not allowed to happen!\n"); - DAG_scene_sort(sce); - } - + firstnode= sce->theDag->DagNode.first; // always scene node for(itA = firstnode->child; itA; itA= itA->next) itA->lay= 0; - - /* first we flush the layer flags */ + sce->theDag->time++; // so we know which nodes were accessed lasttime= sce->theDag->time; @@ -1930,7 +1923,26 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) for(itA = firstnode->child; itA; itA= itA->next) if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB) flush_layer_node(sce, itA->node, lasttime); +} + +/* flushes all recalc flags in objects down the dependency tree */ +void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) +{ + DagNode *firstnode; + DagAdjList *itA; + Object *ob; + int lasttime; + + if(sce->theDag==NULL) { + printf("DAG zero... not allowed to happen!\n"); + DAG_scene_sort(sce); + } + firstnode= sce->theDag->DagNode.first; // always scene node + + /* first we flush the layer flags */ + dag_scene_flush_layers(sce, lay); + /* then we use the relationships + layer info to flush update events */ sce->theDag->time++; // so we know which nodes were accessed lasttime= sce->theDag->time; @@ -2231,7 +2243,8 @@ void DAG_on_load_update(void) Object *ob; Group *group; GroupObject *go; - unsigned int lay; + DagNode *node; + unsigned int lay, oblay; dag_current_scene_layers(bmain, &scene, &lay); @@ -2240,10 +2253,14 @@ void DAG_on_load_update(void) remade, tag them so they get remade in the scene update loop, note armature poses or object matrices are preserved and do not require updates, so we skip those */ + dag_scene_flush_layers(scene, lay); + for(SETLOOPER(scene, base)) { ob= base->object; + node= (sce->theDag)? dag_get_node(sce->theDag, ob): NULL; + oblay= (node)? node->lay: ob->lay; - if(base->lay & lay) { + if(oblay & lay) { if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) ob->recalc |= OB_RECALC_DATA; if(ob->dup_group) -- cgit v1.2.3 From c689e46ff306790e3c9953792b91c12b42000d23 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 Jul 2010 18:47:49 +0000 Subject: Fix #22340: sintel appears in seemingly random poses on load. Pose proxy synchronization happened after drivers were already evaluated, now moved to start of object_handle_update. --- source/blender/blenkernel/intern/object.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 1b8405a91de..78ec473ef93 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2479,6 +2479,17 @@ void object_handle_update(Scene *scene, Object *ob) if(ob->pose) make_pose_channels_hash(ob->pose); + if(ob->recalc & OB_RECALC_DATA) { + if(ob->type==OB_ARMATURE) { + /* this happens for reading old files and to match library armatures + with poses we do it ahead of where_is_object to ensure animation + is evaluated on the rebuilt pose, otherwise we get incorrect poses + on file load */ + if(ob->pose==NULL || (ob->pose->flag & POSE_RECALC)) + armature_rebuild_pose(ob, ob->data); + } + } + /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, which is only in where_is_object now */ // XXX: should this case be OB_RECALC_OB instead? @@ -2541,11 +2552,6 @@ void object_handle_update(Scene *scene, Object *ob) lattice_calc_modifiers(scene, ob); } else if(ob->type==OB_ARMATURE) { - /* this happens for reading old files and to match library armatures with poses */ - // XXX this won't screw up the pose set already... - if(ob->pose==NULL || (ob->pose->flag & POSE_RECALC)) - armature_rebuild_pose(ob, ob->data); - /* evaluate drivers */ BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); -- cgit v1.2.3 From b511fbea6d3e0185f8ba39405bc9f71dab7a5f20 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Jul 2010 10:03:29 +0000 Subject: Sequencer display overlay option, this can show a border area from another time to help compare for color grading. - Okey sets the border in the display. - Okey resets the frame offset in the sequencer timeline. - ghost icon in the header can enable/disable. - frame offset can be relative or absolute (lock icon) Not very happy that this commit adds a call to BKE_animsys_evaluate_animdata(scene, ...) in do_build_seq_array_recursively() without this the offset frames dont have fcurves applied. Though we will need something like this for prefetch frames to work too. --- source/blender/blenkernel/intern/sequencer.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index cfe2a6bb207..82ed85a1983 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2544,6 +2544,10 @@ static TStripElem* do_build_seq_array_recursively( int i; TStripElem* se = 0; + // XXX for prefetch and overlay offset!..., very bad!!! + AnimData *adt= BKE_animdata_from_id(&scene->id); + BKE_animsys_evaluate_animdata(&scene->id, adt, cfra, ADT_RECALC_ANIM); + count = get_shown_sequences(seqbasep, cfra, chanshown, (Sequence **)&seq_arr); -- cgit v1.2.3 From 6fcacf077df261183bfe1976909cb1d636a913ed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Jul 2010 14:30:43 +0000 Subject: - duplicating a scene now duplicates all strips (not just selected ones) - python change, dont import 'bpy' by default, initially I thaught this would make scripting easier but it ends up being annoying when you want to register a script or if you want to import it. (more trouble then its worth to save 1 line, also not very pythonic). --- source/blender/blenkernel/BKE_sequencer.h | 1 + source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 3b95c25006d..002a1958a13 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -234,6 +234,7 @@ typedef struct SeqLoadInfo { #define SEQ_DUPE_UNIQUE_NAME 1<<0 #define SEQ_DUPE_CONTEXT 1<<1 #define SEQ_DUPE_ANIM 1<<2 +#define SEQ_DUPE_ALL 1<<3 /* otherwise only selected are copied */ /* use as an api function */ typedef struct Sequence *(*SeqLoadFunc)(struct bContext *, ListBase *, struct SeqLoadInfo *); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index af13aae159f..2896ac68f40 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -220,7 +220,7 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) if(sce->ed) { scen->ed= MEM_callocN( sizeof(Editing), "addseq"); scen->ed->seqbasep= &scen->ed->seqbase; - seqbase_dupli_recursive(sce, &scen->ed->seqbase, &sce->ed->seqbase, 0); + seqbase_dupli_recursive(sce, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL); } } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 82ed85a1983..36e768ec98d 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -4299,7 +4299,7 @@ void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase for(seq= seqbase->first; seq; seq= seq->next) { seq->tmp= NULL; - if(seq->flag & SELECT) { + if((seq->flag & SELECT) || (dupe_flag & SEQ_DUPE_ALL)) { seqn = seq_dupli(scene, seq, dupe_flag); if (seqn) { /*should never fail */ if(dupe_flag & SEQ_DUPE_CONTEXT) { -- cgit v1.2.3 From 24f63b20810692ff3d25fbe205098467ba32d277 Mon Sep 17 00:00:00 2001 From: Diego Borghetti Date: Thu, 8 Jul 2010 20:58:34 +0000 Subject: New option for Scale node. This is because problem reported by venomgfx on the irc. If you have a render of 2k with a render size of 25% (and this problem is for any resolution/size) and you try to use a image of 1k in the compo, the first thing you do is put a scale node. Here come the problem, if you set the option "Scene Size" in the node scale, the buffer output is not the same size that the render. This is because the "Scene size" work with the image size and not the render size, so in this case is the 25% of 1k.. not the 25% 2k. So this new option "Render Size" scale the output buffer to the render resolution, taking into account the render size (percentage) too. --- source/blender/blenkernel/BKE_node.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 0e5ad8e3ee9..4c7dcff0cd2 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -383,6 +383,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat); #define CMP_SCALE_RELATIVE 0 #define CMP_SCALE_ABSOLUTE 1 #define CMP_SCALE_SCENEPERCENT 2 +#define CMP_SCALE_RENDERPERCENT 3 /* the type definitions array */ -- cgit v1.2.3 From 1f019c23fd11aefc363bb1694b94d0aee34501a1 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 9 Jul 2010 00:14:46 +0000 Subject: Logic Editor UI: move s/c/a operators and interface buttons Tchatcharantcharan ... Three new operators: bpy.ops.logic.sensor_move bpy.ops.logic.controller_move bpy.ops.logic.actuator_move direction is a parameter (UP,DOWN) Moved some interface code to sca.c instead of logic_window.c. (and changed accordingly). One note: as in 2.49, the move up/down button is only available in non-expanded mode. However instead of one button with two options we have 2 buttons (as we had originally in 2.50). That also means the s/c/a header is getting more clunky. Design, thoughts, ideas are appreciated. For the time been functionality back is still the priority (mine at least ;) --- source/blender/blenkernel/BKE_sca.h | 4 ++ source/blender/blenkernel/intern/sca.c | 124 +++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sca.h b/source/blender/blenkernel/BKE_sca.h index 910f381823c..b1df32d5cd7 100644 --- a/source/blender/blenkernel/BKE_sca.h +++ b/source/blender/blenkernel/BKE_sca.h @@ -67,5 +67,9 @@ void set_sca_new_poins_ob(struct Object *ob); void set_sca_new_poins(void); void sca_remove_ob_poin(struct Object *obt, struct Object *ob); +void sca_move_sensor(struct bSensor *sens_to_move, Object *ob, int move_up); +void sca_move_controller(struct bController *cont_to_move, Object *ob, int move_up); +void sca_move_actuator(struct bActuator *act_to_move, Object *ob, int move_up); + #endif diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 3102d4b054b..02b66dd9b32 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -683,3 +683,127 @@ void sca_remove_ob_poin(Object *obt, Object *ob) act= act->next; } } + +/* ******************** INTERFACE ******************* */ +void sca_move_sensor(bSensor *sens_to_move, Object *ob, int *move_up) +{ + bSensor *sens, *tmp; + + int val; + val = move_up ? 1:2; + + /* make sure this sensor belongs to this object */ + sens= ob->sensors.first; + while(sens) { + if(sens == sens_to_move) break; + sens= sens->next; + } + if(!sens) return; + + /* move up */ + if( val==1 && sens->prev) { + for (tmp=sens->prev; tmp; tmp=tmp->prev) { + if (tmp->flag & SENS_VISIBLE) + break; + } + if (tmp) { + BLI_remlink(&ob->sensors, sens); + BLI_insertlinkbefore(&ob->sensors, tmp, sens); + } + } + /* move down */ + else if( val==2 && sens->next) { + for (tmp=sens->next; tmp; tmp=tmp->next) { + if (tmp->flag & SENS_VISIBLE) + break; + } + if (tmp) { + BLI_remlink(&ob->sensors, sens); + BLI_insertlink(&ob->sensors, tmp, sens); + } + } +} + +void sca_move_controller(bController *cont_to_move, Object *ob, int move_up) +{ + bController *cont, *tmp; + + int val; + val = move_up ? 1:2; + + /* make sure this controller belongs to this object */ + cont= ob->controllers.first; + while(cont) { + if(cont == cont_to_move) break; + cont= cont->next; + } + if(!cont) return; + + /* move up */ + if( val==1 && cont->prev) { + /* locate the controller that has the same state mask but is earlier in the list */ + tmp = cont->prev; + while(tmp) { + if(tmp->state_mask & cont->state_mask) + break; + tmp = tmp->prev; + } + if (tmp) { + BLI_remlink(&ob->controllers, cont); + BLI_insertlinkbefore(&ob->controllers, tmp, cont); + } + } + + /* move down */ + else if( val==2 && cont->next) { + tmp = cont->next; + while(tmp) { + if(tmp->state_mask & cont->state_mask) + break; + tmp = tmp->next; + } + BLI_remlink(&ob->controllers, cont); + BLI_insertlink(&ob->controllers, tmp, cont); + } +} + +void sca_move_actuator(bActuator *act_to_move, Object *ob, int move_up) +{ + bActuator *act, *tmp; + int val; + + val = move_up ? 1:2; + + /* make sure this actuator belongs to this object */ + act= ob->actuators.first; + while(act) { + if(act == act_to_move) break; + act= act->next; + } + if(!act) return; + + /* move up */ + if( val==1 && act->prev) { + /* locate the first visible actuators before this one */ + for (tmp = act->prev; tmp; tmp=tmp->prev) { + if (tmp->flag & ACT_VISIBLE) + break; + } + if (tmp) { + BLI_remlink(&ob->actuators, act); + BLI_insertlinkbefore(&ob->actuators, tmp, act); + } + } + /* move down */ + else if( val==2 && act->next) { + /* locate the first visible actuators after this one */ + for (tmp=act->next; tmp; tmp=tmp->next) { + if (tmp->flag & ACT_VISIBLE) + break; + } + if (tmp) { + BLI_remlink(&ob->actuators, act); + BLI_insertlink(&ob->actuators, tmp, act); + } + } +} -- cgit v1.2.3 From 0d9a81a1111ec5d60b95938e2a634a6d52298bef Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 9 Jul 2010 19:20:57 +0000 Subject: Fix #22794: problem with rendering panorama in 2.4 created files. --- source/blender/blenkernel/intern/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 78ec473ef93..6d264b3fed2 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2755,7 +2755,7 @@ void object_camera_matrix( float pixsize; float shiftx=0.0, shifty=0.0, winside, viewfac; - rd->mode &= ~R_ORTHO; + rd->mode &= ~(R_ORTHO|R_PANORAMA); /* question mark */ (*ycor)= rd->yasp / rd->xasp; -- cgit v1.2.3 From e37cbe9461a589699445b35e43ae731960b32429 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 10 Jul 2010 18:11:01 +0000 Subject: Bugfix [#22811] Dupli-Instancing for particles broken. commit r29079 removed 2 lines that are needed for instancing particles. --- source/blender/blenkernel/intern/particle_system.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 3ed2181f908..33ea9f5ba6e 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3232,6 +3232,10 @@ static void hair_step(ParticleSimulationData *sim, float cfra) if(psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) do_hair_dynamics(sim); + /* following lines were removed r29079 but cause bug [#22811], see report for details */ + psys_update_effectors(sim); + psys_update_path_cache(sim, cfra); + psys->flag |= PSYS_HAIR_UPDATED; } -- cgit v1.2.3 From 22371e88168f5a36623f68265f9994d76790c503 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 10 Jul 2010 19:17:52 +0000 Subject: [#22791] Can't change keyed strip attributes if two sequencer windows open own recent commit for overlay sequencer view brokey keyframing in the sequencer. for now prefetch and overlay views wont have correct fcurves applied. --- source/blender/blenkernel/intern/sequencer.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 36e768ec98d..6e48a71cec4 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2544,10 +2544,6 @@ static TStripElem* do_build_seq_array_recursively( int i; TStripElem* se = 0; - // XXX for prefetch and overlay offset!..., very bad!!! - AnimData *adt= BKE_animdata_from_id(&scene->id); - BKE_animsys_evaluate_animdata(&scene->id, adt, cfra, ADT_RECALC_ANIM); - count = get_shown_sequences(seqbasep, cfra, chanshown, (Sequence **)&seq_arr); @@ -2561,6 +2557,14 @@ static TStripElem* do_build_seq_array_recursively( return 0; } +#if 0 /* commentind since this breaks keyframing, since it resets the value on draw */ + if(scene->r.cfra != cfra) { + // XXX for prefetch and overlay offset!..., very bad!!! + AnimData *adt= BKE_animdata_from_id(&scene->id); + BKE_animsys_evaluate_animdata(&scene->id, adt, cfra, ADT_RECALC_ANIM); + } +#endif + test_and_auto_discard_ibuf(se, seqrectx, seqrecty); if (se->ibuf_comp != 0) { -- cgit v1.2.3 From 96a7e478b6ef0c9f4b15e27ab22db548bbab1fe5 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 10 Jul 2010 21:15:10 +0000 Subject: Logic Editor Python API: link/unlink logics through python After initial talk with Matt (awhile ago) we realzed that rna_api would fit well for this instead of an operator. The next step would be to move the current UI code to use the rna funcs instead. Note: it takes the s/c/a as argument, not its name. (e.g. cont.link(actuator=act) ) Sample code to link all the logic bricks between each other: ob = bpy.context.object for cont in ob.game.controllers: for sens in ob.game.sensors: cont.link(sensor=sens) for act in ob.game.actuators: cont.link(actuator=act) For a script to create bricks, link bricks, unlink bricks and remove them: http://www.pasteall.org/14266 --- source/blender/blenkernel/BKE_sca.h | 3 ++ source/blender/blenkernel/intern/sca.c | 85 ++++++++++++++++++++++------------ 2 files changed, 59 insertions(+), 29 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_sca.h b/source/blender/blenkernel/BKE_sca.h index b1df32d5cd7..7adbfd9b48d 100644 --- a/source/blender/blenkernel/BKE_sca.h +++ b/source/blender/blenkernel/BKE_sca.h @@ -37,6 +37,9 @@ struct Object; struct bController; struct bActuator; +void link_logicbricks(void **poin, void ***ppoin, short *tot, short size); +void unlink_logicbricks(void **poin, void ***ppoin, short *tot); + void unlink_controller(struct bController *cont); void unlink_controllers(struct ListBase *lb); void free_controller(struct bController *cont); diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 02b66dd9b32..12d1dfc83b0 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -45,6 +45,7 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_library.h" +#include "BKE_sca.h" /* ******************* SENSORS ************************ */ @@ -189,26 +190,13 @@ void unlink_controller(bController *cont) { bSensor *sens; Object *ob; - int a, removed; /* check for controller pointers in sensors */ ob= G.main->object.first; while(ob) { sens= ob->sensors.first; while(sens) { - removed= 0; - for(a=0; atotlinks; a++) { - if(removed) (sens->links)[a-1] = (sens->links)[a]; - else if((sens->links)[a] == cont) removed= 1; - } - if(removed) { - sens->totlinks--; - - if(sens->totlinks==0) { - MEM_freeN(sens->links); - sens->links= NULL; - } - } + unlink_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks); sens= sens->next; } ob= ob->id.next; @@ -313,26 +301,13 @@ void unlink_actuator(bActuator *act) { bController *cont; Object *ob; - int a, removed; /* check for actuator pointers in controllers */ ob= G.main->object.first; while(ob) { cont= ob->controllers.first; while(cont) { - removed= 0; - for(a=0; atotlinks; a++) { - if(removed) (cont->links)[a-1] = (cont->links)[a]; - else if((cont->links)[a] == act) removed= 1; - } - if(removed) { - cont->totlinks--; - - if(cont->totlinks==0) { - MEM_freeN(cont->links); - cont->links= NULL; - } - } + unlink_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks); cont= cont->next; } ob= ob->id.next; @@ -512,7 +487,6 @@ bActuator *new_actuator(int type) } /* ******************** GENERAL ******************* */ - void clear_sca_new_poins_ob(Object *ob) { bSensor *sens; @@ -807,3 +781,56 @@ void sca_move_actuator(bActuator *act_to_move, Object *ob, int move_up) } } } + +void link_logicbricks(void **poin, void ***ppoin, short *tot, short size) +{ + void **old_links= NULL; + + int ibrick; + + /* check if the bricks are already linked */ + for (ibrick=0; ibrick < *tot; ibrick++) { + if ((*ppoin)[ibrick] == *poin) + return; + } + + if (*ppoin) { + old_links= *ppoin; + + (*tot) ++; + *ppoin = MEM_callocN((*tot)*size, "new link"); + + for (ibrick=0; ibrick < *tot - 1; ibrick++) { + (*ppoin)[ibrick] = old_links[ibrick]; + } + (*ppoin)[ibrick] = *poin; + + if(old_links) MEM_freeN(old_links); + } + else { + (*tot) = 1; + *ppoin = MEM_callocN((*tot)*size, "new link"); + (*ppoin)[0] = *poin; + } +} + +void unlink_logicbricks(void **poin, void ***ppoin, short *tot) +{ + int ibrick, removed; + + removed= 0; + for (ibrick=0; ibrick < *tot; ibrick++) { + if(removed) (*ppoin)[ibrick - removed] = (*ppoin)[ibrick]; + else if((*ppoin)[ibrick] == *poin) removed = 1; + } + + if (removed) { + (*tot) --; + + if(*tot == 0) { + MEM_freeN(*ppoin); + (*ppoin)= NULL; + } + return; + } +} -- cgit v1.2.3 From f91f4d317615889d086d79161c9906b11879e9d3 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Sat, 10 Jul 2010 23:21:25 +0000 Subject: Fix type mismatch. --- source/blender/blenkernel/intern/sca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 12d1dfc83b0..61e98ce9d45 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -659,7 +659,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob) } /* ******************** INTERFACE ******************* */ -void sca_move_sensor(bSensor *sens_to_move, Object *ob, int *move_up) +void sca_move_sensor(bSensor *sens_to_move, Object *ob, int move_up) { bSensor *sens, *tmp; -- cgit v1.2.3 From c013974a7c2e0365f8884390002ba9b515a5edb2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 12 Jul 2010 08:43:49 +0000 Subject: set metaball limit for not drawing small scale motherballs to a 1/10th of what it was. durian blood splats were reaching this threshold. also fix for memory leaks when the motherball is too small. --- source/blender/blenkernel/intern/mball.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index a97bec670d6..c41dcfa9588 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -2125,13 +2125,22 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) if((totelem > 512) && (totelem <= 1024)) init_metaball_octal_tree(4); if(totelem > 1024) init_metaball_octal_tree(5); - /* don't polygonize metaballs with too high resolution (base mball to small) */ + /* don't polygonize metaballs with too high resolution (base mball to small) + * note: Eps was 0.0001f but this was giving problems for blood animation for durian, using 0.00001f */ if(metaball_tree) { - if(ob->size[0]<=0.0001f*(metaball_tree->first->x_max - metaball_tree->first->x_min) || - ob->size[1]<=0.0001f*(metaball_tree->first->y_max - metaball_tree->first->y_min) || - ob->size[2]<=0.0001f*(metaball_tree->first->z_max - metaball_tree->first->z_min)) + if( ob->size[0] <= 0.00001f * (metaball_tree->first->x_max - metaball_tree->first->x_min) || + ob->size[1] <= 0.00001f * (metaball_tree->first->y_max - metaball_tree->first->y_min) || + ob->size[2] <= 0.00001f * (metaball_tree->first->z_max - metaball_tree->first->z_min)) { + new_pgn_element(-1); /* free values created by init_meta */ + MEM_freeN(mainb); + + /* free tree */ + free_metaball_octal_node(metaball_tree->first); + MEM_freeN(metaball_tree); + metaball_tree= NULL; + return; } } -- cgit v1.2.3 From fa39db244148911f04fd4de52425258248b8eb91 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 12 Jul 2010 11:04:51 +0000 Subject: 2.5: remove armature "B-Bone Rest" option, this was only added to keep broken behavior for backwards compatibility, it's been there long enough now to be removed. --- source/blender/blenkernel/intern/armature.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 557f3900d7b..990993b1077 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -687,11 +687,11 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) /* ************ Armature Deform ******************* */ -static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion, int rest_def) +static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion) { Bone *bone= pchan->bone; Mat4 *b_bone= b_bone_spline_setup(pchan, 0); - Mat4 *b_bone_rest= (rest_def)? NULL: b_bone_spline_setup(pchan, 1); + Mat4 *b_bone_rest= b_bone_spline_setup(pchan, 1); Mat4 *b_bone_mats; DualQuat *b_bone_dual_quats= NULL; float tmat[4][4]; @@ -718,10 +718,7 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion, int re unit_m4(tmat); for(a=0; asegments; a++) { - if(b_bone_rest) - invert_m4_m4(tmat, b_bone_rest[a].mat); - else - tmat[3][1] = -a*(bone->length/(float)bone->segments); + invert_m4_m4(tmat, b_bone_rest[a].mat); mul_serie_m4(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat, NULL, NULL, NULL); @@ -919,7 +916,6 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float obinv[4][4], premat[4][4], postmat[4][4]; int use_envelope = deformflag & ARM_DEF_ENVELOPE; int use_quaternion = deformflag & ARM_DEF_QUATERNION; - int bbone_rest_def = deformflag & ARM_DEF_B_BONE_REST; int invert_vgroup= deformflag & ARM_DEF_INVERT_VGROUP; int numGroups = 0; /* safety for vertexgroup index overflow */ int i, target_totvert = 0; /* safety for vertexgroup overflow */ @@ -946,7 +942,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, for(pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next) { if(!(pchan->bone->flag & BONE_NO_DEFORM)) { if(pchan->bone->segments > 1) - pchan_b_bone_defmats(pchan, use_quaternion, bbone_rest_def); + pchan_b_bone_defmats(pchan, use_quaternion); if(use_quaternion) { pchan->dual_quat= &dualquats[totchan++]; @@ -1701,6 +1697,8 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) ob->pose->flag &= ~POSE_RECALC; ob->pose->flag |= POSE_WAS_REBUILT; + + make_pose_channels_hash(ob->pose); } -- cgit v1.2.3 From a470640f2e88c0997b12600b9de652da6aac7444 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 12 Jul 2010 14:57:24 +0000 Subject: sequencer float conversion was only using rgb -> float conversion inconsistantly, some places used colorspace conversion, some not. Added IMB_float_from_rect_simple() for the sequencer to use. --- source/blender/blenkernel/intern/displist.c | 15 +++++------- source/blender/blenkernel/intern/seqeffects.c | 4 ++-- source/blender/blenkernel/intern/sequencer.c | 34 ++++++++++----------------- 3 files changed, 21 insertions(+), 32 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 716d3110bc3..bb020c936a6 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -575,9 +575,9 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un char *col1= (char*)&col1base[j*4]; char *col2= (char*)(col2base?&col2base[j*4]:NULL); float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1; - - VECCOPY(vec, mv->co); - mul_m4_v3(mat, vec); + + mul_v3_m4v3(vec, mat, mv->co); + vec[0]+= 0.001*vn[0]; vec[1]+= 0.001*vn[1]; vec[2]+= 0.001*vn[2]; @@ -688,8 +688,7 @@ void shadeDispList(Scene *scene, Base *base) a= dl->nr; while(a--) { - VECCOPY(vec, fp); - mul_m4_v3(mat, vec); + mul_v3_m4v3(vec, mat, fp); fastshade(vec, n1, fp, ma, (char *)col1, NULL); @@ -704,8 +703,7 @@ void shadeDispList(Scene *scene, Base *base) nor= dl->nors; while(a--) { - VECCOPY(vec, fp); - mul_m4_v3(mat, vec); + mul_v3_m4v3(vec, mat, fp); n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; @@ -742,8 +740,7 @@ void shadeDispList(Scene *scene, Base *base) a= dl->nr; while(a--) { - VECCOPY(vec, fp); - mul_m4_v3(mat, vec); + mul_v3_m4v3(vec, mat, fp); /* transpose ! */ n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 56a8edcc4fc..73c19772c69 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -312,7 +312,7 @@ static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, IMB_convert_rgba_to_abgr(out); } if (seq->plugin->version<=3 && float_rendering) { - IMB_float_from_rect(out); + IMB_float_from_rect_simple(out); } if (use_temp_bufs) { @@ -2783,7 +2783,7 @@ static void do_multicam(Scene *scene, Sequence *seq, int cfra, IMB_rect_from_float(i); memcpy(out->rect, i->rect, out->x * out->y * 4); } else if (out->rect_float && i->rect) { - IMB_float_from_rect(i); + IMB_float_from_rect_simple(i); memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float)); } } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 6e48a71cec4..fd3e56a418c 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1022,13 +1022,13 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se, y= se2->ibuf->y; if (!se1->ibuf->rect_float && se->ibuf->rect_float) { - IMB_float_from_rect(se1->ibuf); + IMB_float_from_rect_simple(se1->ibuf); } if (!se2->ibuf->rect_float && se->ibuf->rect_float) { - IMB_float_from_rect(se2->ibuf); + IMB_float_from_rect_simple(se2->ibuf); } if (!se3->ibuf->rect_float && se->ibuf->rect_float) { - IMB_float_from_rect(se3->ibuf); + IMB_float_from_rect_simple(se3->ibuf); } if (!se1->ibuf->rect && !se->ibuf->rect_float) { @@ -1784,17 +1784,9 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf } if(seq->flag & SEQ_MAKE_FLOAT) { - if (!se->ibuf->rect_float) { - int profile = IB_PROFILE_NONE; - - /* no color management: - * don't disturb the existing profiles */ - SWAP(int, se->ibuf->profile, profile); + if (!se->ibuf->rect_float) + IMB_float_from_rect_simple(se->ibuf); - IMB_float_from_rect(se->ibuf); - - SWAP(int, se->ibuf->profile, profile); - } if (se->ibuf->rect) { imb_freerectImBuf(se->ibuf); } @@ -2085,14 +2077,14 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int } copy_from_ibuf_still(seq, se); - if (!se->ibuf) { - se->ibuf= IMB_loadiffname( - name, IB_rect); + if (se->ibuf==NULL && (se->ibuf= IMB_loadiffname(name, IB_rect))) { /* we don't need both (speed reasons)! */ - if (se->ibuf && - se->ibuf->rect_float && se->ibuf->rect) { + if (se->ibuf->rect_float && se->ibuf->rect) imb_freerectImBuf(se->ibuf); - } + + /* all sequencer color is done in SRGB space, linear gives odd crossfades */ + if(se->ibuf->profile == IB_PROFILE_LINEAR_RGB) + IMB_convert_profile(se->ibuf, IB_PROFILE_NONE); copy_to_ibuf_still(seq, se); } @@ -2707,11 +2699,11 @@ static TStripElem* do_build_seq_array_recursively( if (!se1->ibuf_comp->rect_float && se2->ibuf_comp->rect_float) { - IMB_float_from_rect(se1->ibuf_comp); + IMB_float_from_rect_simple(se1->ibuf_comp); } if (!se2->ibuf->rect_float && se2->ibuf_comp->rect_float) { - IMB_float_from_rect(se2->ibuf); + IMB_float_from_rect_simple(se2->ibuf); } if (!se1->ibuf_comp->rect && -- cgit v1.2.3 From a586541d74a3ba9a7c841efa0f06f1da9977ed53 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 12 Jul 2010 16:20:51 +0000 Subject: tweak to color balance after talking with colin and testing other software, lift for values above 1.0 was too intense. Use: 1 + ((lift-1) * (lift-1)) so 2.0 is still a full lift but 1.x isnt so strong. Changed color picker to give more precission, we were having to edit the buttons to see what the numbers were. --- source/blender/blenkernel/intern/sequencer.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index fd3e56a418c..1ab4e75ee06 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1509,6 +1509,11 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) if(cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) { for (c = 0; c < 3; c++) { + /* tweak to give more subtle results + * values above 1.0 are scaled */ + if(cb.lift[c] > 1.0f) + cb.lift[c] = pow(cb.lift[c] - 1.0f, 2.0f) + 1.0f; + cb.lift[c] = 2.0f - cb.lift[c]; } } -- cgit v1.2.3 From 64091ff5bd6258cd05cf4b1d96da22cb3aef6976 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 12 Jul 2010 20:35:10 +0000 Subject: fix for crash when psys_get_dupli_texture() was called on a subsurf mesh with simplify enabled. --- source/blender/blenkernel/intern/particle.c | 9 +++++++-- 1 file changed, 7 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 f33ac2ad380..96c0afedfb0 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4257,8 +4257,13 @@ void psys_get_dupli_texture(Object *ob, ParticleSettings *part, ParticleSystemMo num= pa->num_dmcache; if(num == DMCACHE_NOTFOUND) - if(pa->num < psmd->dm->getNumFaces(psmd->dm)) - num= pa->num; + num= pa->num; + + if (num >= psmd->dm->getNumFaces(psmd->dm)) { + /* happens when simplify is enabled + * gives invalid coords but would crash otherwise */ + num= DMCACHE_NOTFOUND; + } if(mtface && num != DMCACHE_NOTFOUND) { mface= psmd->dm->getFaceData(psmd->dm, num, CD_MFACE); -- cgit v1.2.3 From 291c99c5d9fd25e69a17a150ee86d3261987cf34 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 13 Jul 2010 09:28:01 +0000 Subject: - saturation option for sequencer strips, runs before multiply and color balance. - multiply of 0.0 wasnt being applied. --- source/blender/blenkernel/intern/sequencer.c | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 1ab4e75ee06..69dd4b3a1b7 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1769,12 +1769,31 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf if(seq->flag & SEQ_FLIPX) { IMB_flipx(se->ibuf); } - if(seq->flag & SEQ_FLIPY) { - IMB_flipy(se->ibuf); - } - if(seq->mul == 0.0) { - seq->mul = 1.0; + if(seq->sat != 1.0f) { + /* inline for now, could become an imbuf function */ + int i; + char *rct= (char *)se->ibuf->rect; + float *rctf= se->ibuf->rect_float; + const float sat= seq->sat; + float hsv[3]; + + if(rct) { + float rgb[3]; + for (i = se->ibuf->x * se->ibuf->y; i > 0; i--, rct+=4) { + rgb_byte_to_float(rct, rgb); + rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); + hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rgb, rgb+1, rgb+2); + rgb_float_to_byte(rgb, rct); + } + } + + if(rctf) { + for (i = se->ibuf->x * se->ibuf->y; i > 0; i--, rctf+=4) { + rgb_to_hsv(rctf[0], rctf[1], rctf[2], hsv, hsv+1, hsv+2); + hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rctf, rctf+1, rctf+2); + } + } } mul = seq->mul; -- cgit v1.2.3 From 862427e0b2de1a0dc3d5bed023a3e908c2444775 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 13 Jul 2010 09:31:28 +0000 Subject: fix for crash copying in the sequencer. --- source/blender/blenkernel/intern/sequencer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 69dd4b3a1b7..4a5d08f96cc 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -247,9 +247,9 @@ void seq_free_sequence(Scene *scene, Sequence *seq) if(seq->scene_sound) sound_remove_scene_sound(scene, seq->scene_sound); - } - seq_free_animdata(scene, seq); + seq_free_animdata(scene, seq); + } MEM_freeN(seq); } @@ -4062,6 +4062,7 @@ Sequence *alloc_sequence(ListBase *lb, int cfra, int machine) seq->flag= SELECT; seq->start= cfra; seq->machine= machine; + seq->sat= 1.0; seq->mul= 1.0; seq->blend_opacity = 100.0; seq->volume = 1.0f; -- cgit v1.2.3 From 161ee379a06d57f0dc732960ae05f089924727fb Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 13 Jul 2010 10:29:41 +0000 Subject: 2.5: startup.blend changes, these should all be consistent with new datablocks, mostly the startup.blend was trailing behind. Also renamed B.blend.c. * Lamp shadow buffer was Classical instead of Classical Halfway. * Point Lamp was named "Spot". * Render resolution is 50% 1080p. * Scene and material bake/use tangent space normal maps. * Remove empty text datablock. * Enable auto ray bias on material. * Change default material diffuse color to match new material. * Mist start/depth from 0/0 to 5/25 so it does something. * AO uses Add instead of Multiply. * Change world colors for new world same as startup.blend. * Default cube rotation was 0,-0,0 now 0,0,0. * Enable relative/filter/hide files in user preferences. --- source/blender/blenkernel/intern/world.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index fa8c8188f54..6fb1c5ff70c 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -72,12 +72,12 @@ World *add_world(char *name) wrld= alloc_libblock(&G.main->world, ID_WO, name); - wrld->horr= 0.25f; - wrld->horg= 0.25f; - wrld->horb= 0.25f; - wrld->zenr= 0.1f; - wrld->zeng= 0.1f; - wrld->zenb= 0.1f; + wrld->horr= 0.05f; + wrld->horg= 0.05f; + wrld->horb= 0.05f; + wrld->zenr= 0.01f; + wrld->zeng= 0.01f; + wrld->zenb= 0.01f; wrld->skytype= 0; wrld->stardist= 15.0f; wrld->starsize= 2.0f; @@ -96,6 +96,8 @@ World *add_world(char *name) wrld->ao_approx_error= 0.25f; wrld->preview = NULL; + wrld->miststa = 5.0f; + wrld->mistdist = 25.0f; return wrld; } -- cgit v1.2.3 From e86b78c47c7ebfd15ea51de99c02e45790cbf9d7 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 13 Jul 2010 15:19:15 +0000 Subject: Merging revision 30264:30270 from my GSoC branch to trunk, logs: Bugfix for [#22284] Blender cursor gets stuck in the timeline when scrubbing (jack transport). Dirty hack fix for: * [#22366] Cutting audio and meta strips with audio does not actually cut audio * [#22639] Audio not clipped to meta bounds Also fixed a seemingly symptomless bug in sequencer_edit.c --- source/blender/blenkernel/intern/sequencer.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4a5d08f96cc..e8f8c2f3c3b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -517,6 +517,31 @@ void calc_sequence_disp(Scene *scene, Sequence *seq) seq_update_sound(scene, seq); } +static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq) +{ + Sequence *seq; + + /* for sound we go over full meta tree to update bounds of the sound strips, + since sound is played outside of evaluating the imbufs, */ + for(seq=metaseq->seqbase.first; seq; seq=seq->next) { + if(seq->type == SEQ_META) { + seq_update_sound_bounds_recursive(scene, seq); + } + else if((seq->type == SEQ_SOUND) || (seq->type == SEQ_SCENE)) { + if(seq->scene_sound) { + int startofs = seq->startofs; + int endofs = seq->endofs; + if(seq->startofs + seq->start < metaseq->start + metaseq->startofs) + startofs = metaseq->start + metaseq->startofs - seq->start; + + if(seq->start + seq->len - seq->endofs > metaseq->start + metaseq->len - metaseq->endofs) + endofs = seq->start + seq->len - metaseq->start - metaseq->len + metaseq->endofs; + sound_move_scene_sound(scene, seq->scene_sound, seq->start + startofs, seq->start+seq->len - endofs, startofs); + } + } + } +} + void calc_sequence(Scene *scene, Sequence *seq) { Sequence *seqm; @@ -576,6 +601,7 @@ void calc_sequence(Scene *scene, Sequence *seq) new_tstripdata(seq); } } + seq_update_sound_bounds_recursive(scene, seq); } calc_sequence_disp(scene, seq); } -- cgit v1.2.3 From 8ee36e1da56b10a84e02ba9790fbcafbdbf43f51 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 13 Jul 2010 16:06:51 +0000 Subject: - fix for eternal loop with metaballs in set scenes. - next_object() now loops through all set scenes, not just the first one. - removed F_SET, rather them having a mode for looping on a set, just use the set when the first scene ends. - metaballs can now glob between scenes however there are still some depsgraph issues that existed before. --- source/blender/blenkernel/BKE_scene.h | 2 +- source/blender/blenkernel/intern/mball.c | 16 ++++++++------- source/blender/blenkernel/intern/scene.c | 35 +++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index b5b0a72d2d8..f0fb2a65673 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -63,7 +63,7 @@ struct Scene *set_scene_name(char *name); struct Scene *copy_scene(struct Main *bmain, struct Scene *sce, int type); void unlink_scene(struct Main *bmain, struct Scene *sce, struct Scene *newsce); -int next_object(struct Scene *scene, int val, struct Base **base, struct Object **ob); +int next_object(struct Scene **scene, int val, struct Base **base, struct Object **ob); struct Object *scene_find_camera(struct Scene *sc); struct Object *scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH int scene_camera_switch_update(struct Scene *scene); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index c41dcfa9588..e35d8bce886 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -296,6 +296,7 @@ int is_mball_basis_for(Object *ob1, Object *ob2) * because this metaball influence polygonisation of metaballs. */ void copy_mball_properties(Scene *scene, Object *active_object) { + Scene *sce_iter= scene; Base *base; Object *ob; MetaBall *active_mball = (MetaBall*)active_object->data; @@ -305,10 +306,10 @@ void copy_mball_properties(Scene *scene, Object *active_object) splitIDname(active_object->id.name+2, basisname, &basisnr); /* XXX recursion check, see scene.c, just too simple code this next_object() */ - if(F_ERROR==next_object(scene, 0, 0, 0)) + if(F_ERROR==next_object(&sce_iter, 0, 0, 0)) return; - while(next_object(scene, 1, &base, &ob)) { + while(next_object(&sce_iter, 1, &base, &ob)) { if (ob->type==OB_MBALL) { if(ob!=active_object){ splitIDname(ob->id.name+2, obname, &obnr); @@ -338,6 +339,7 @@ void copy_mball_properties(Scene *scene, Object *active_object) */ Object *find_basis_mball(Scene *scene, Object *basis) { + Scene *sce_iter= scene; Base *base; Object *ob,*bob= basis; MetaElem *ml=NULL; @@ -348,10 +350,10 @@ Object *find_basis_mball(Scene *scene, Object *basis) totelem= 0; /* XXX recursion check, see scene.c, just too simple code this next_object() */ - if(F_ERROR==next_object(scene, 0, 0, 0)) + if(F_ERROR==next_object(&sce_iter, 0, 0, 0)) return NULL; - while(next_object(scene, 1, &base, &ob)) { + while(next_object(&sce_iter, 1, &base, &ob)) { if (ob->type==OB_MBALL) { if(ob==bob){ @@ -1507,6 +1509,7 @@ void polygonize(PROCESS *mbproc, MetaBall *mb) float init_meta(Scene *scene, Object *ob) /* return totsize */ { + Scene *sce_iter= scene; Base *base; Object *bob; MetaBall *mb; @@ -1523,9 +1526,8 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ splitIDname(ob->id.name+2, obname, &obnr); /* make main array */ - - next_object(scene, 0, 0, 0); - while(next_object(scene, 1, &base, &bob)) { + next_object(&sce_iter, 0, 0, 0); + while(next_object(&sce_iter, 1, &base, &bob)) { if(bob->type==OB_MBALL) { zero_size= 0; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 2896ac68f40..fe52375617b 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -593,7 +593,7 @@ void unlink_scene(Main *bmain, Scene *sce, Scene *newsce) /* used by metaballs * doesnt return the original duplicated object, only dupli's */ -int next_object(Scene *scene, int val, Base **base, Object **ob) +int next_object(Scene **scene, int val, Base **base, Object **ob) { static ListBase *duplilist= NULL; static DupliObject *dupob; @@ -622,17 +622,21 @@ int next_object(Scene *scene, int val, Base **base, Object **ob) /* the first base */ if(fase==F_START) { - *base= scene->base.first; + *base= (*scene)->base.first; if(*base) { *ob= (*base)->object; fase= F_SCENE; } else { /* exception: empty scene */ - if(scene->set && scene->set->base.first) { - *base= scene->set->base.first; - *ob= (*base)->object; - fase= F_SET; + while((*scene)->set) { + (*scene)= (*scene)->set; + if((*scene)->base.first) { + *base= (*scene)->base.first; + *ob= (*base)->object; + fase= F_SCENE; + break; + } } } } @@ -642,11 +646,14 @@ int next_object(Scene *scene, int val, Base **base, Object **ob) if(*base) *ob= (*base)->object; else { if(fase==F_SCENE) { - /* scene is finished, now do the set */ - if(scene->set && scene->set->base.first) { - *base= scene->set->base.first; - *ob= (*base)->object; - fase= F_SET; + /* (*scene) is finished, now do the set */ + while((*scene)->set) { + (*scene)= (*scene)->set; + if((*scene)->base.first) { + *base= (*scene)->base.first; + *ob= (*base)->object; + break; + } } } } @@ -661,7 +668,7 @@ int next_object(Scene *scene, int val, Base **base, Object **ob) this enters eternal loop because of makeDispListMBall getting called inside of group_duplilist */ if((*base)->object->dup_group == NULL) { - duplilist= object_duplilist(scene, (*base)->object); + duplilist= object_duplilist((*scene), (*base)->object); dupob= duplilist->first; @@ -697,6 +704,10 @@ int next_object(Scene *scene, int val, Base **base, Object **ob) } } + /* if(ob && *ob) { + printf("Scene: '%s', '%s'\n", (*scene)->id.name+2, (*ob)->id.name+2); + } */ + /* reset recursion test */ in_next_object= 0; -- cgit v1.2.3 From c0ba1671c34683654b691684473bb4f3899604a7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 13 Jul 2010 16:53:17 +0000 Subject: group refcount checking was inconsistent. - if a group has one or more objects in it, it gets a refcount of 1 on load (unchanged from before) - dupli-groups, and materials no longer add/remove a reference. - now groups are only freed when they contain no objects or when manually unlinked. --- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/object.c | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index fa0ddc5f1d3..157c0743c50 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -741,7 +741,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i if(go->ob->transflag & OB_DUPLI) { copy_m4_m4(dob->ob->obmat, dob->mat); - object_duplilist_recursive((ID *)group, scene, go->ob, lb, ob->obmat, level+1, animated); + object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, level+1, animated); copy_m4_m4(dob->ob->obmat, dob->omat); } } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 3b6a10c0872..11c96e9a347 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -210,7 +210,7 @@ Material *copy_material(Material *ma) #if 0 // XXX old animation system id_us_plus((ID *)man->ipo); #endif // XXX old animation system - id_us_plus((ID *)man->group); + id_lib_extern((ID *)man->group); for(a=0; amtex[a]) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6d264b3fed2..012b38570da 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -283,7 +283,6 @@ void free_object(Object *ob) ob->path= 0; if(ob->adt) BKE_free_animdata((ID *)ob); if(ob->poselib) ob->poselib->id.us--; - if(ob->dup_group) ob->dup_group->id.us--; if(ob->gpd) ob->gpd->id.us--; if(ob->defbase.first) BLI_freelistN(&ob->defbase); @@ -1320,7 +1319,7 @@ Object *copy_object(Object *ob) /* increase user numbers */ id_us_plus((ID *)obn->data); - id_us_plus((ID *)obn->dup_group); + id_lib_extern((ID *)obn->dup_group); for(a=0; atotcol; a++) id_us_plus((ID *)obn->mat[a]); -- cgit v1.2.3 From 03e638d1285b2a26902230772ae9261406fd6658 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 13 Jul 2010 22:21:59 +0000 Subject: - make duplis real wasnt redrawing - small caps option for titles (doing manually is quite painful to watch). --- source/blender/blenkernel/intern/curve.c | 1 + source/blender/blenkernel/intern/font.c | 65 +++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 18 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index a01ee15dde1..2e645592229 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -138,6 +138,7 @@ Curve *add_curve(char *name, int type) cu->fsize= 1.0; cu->ulheight = 0.05; cu->texflag= CU_AUTOSPACE; + cu->smallcaps_scale= 0.75f; cu->twist_mode= CU_TWIST_MINIMUM; // XXX: this one seems to be the best one in most cases, at least for curve deform... cu->bb= unit_boundbox(); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 01f2b57de71..d07bd2ba8e5 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1,4 +1,4 @@ -/* font.c +/* font.c * * * $Id$ @@ -34,6 +34,7 @@ #include #include #include +#include #include "MEM_guardedalloc.h" @@ -597,9 +598,23 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float } bezt2 = nu2->bezt; + if(info->flag & CU_SMALLCAPS) { + const float sca= cu->smallcaps_scale; + for (i= nu2->pntsu; i > 0; i--) { + fp= bezt2->vec[0]; + fp[0] *= sca; + fp[1] *= sca; + fp[3] *= sca; + fp[4] *= sca; + fp[6] *= sca; + fp[7] *= sca; + bezt2++; + } + } + bezt2 = nu2->bezt; + for (i= nu2->pntsu; i > 0; i--) { fp= bezt2->vec[0]; - fp[0]= (fp[0]+ofsx)*fsize; fp[1]= (fp[1]+ofsy)*fsize; fp[3]= (fp[3]+ofsx)*fsize; @@ -635,6 +650,20 @@ int BKE_font_getselection(Object *ob, int *start, int *end) } } +static float char_width(Curve *cu, VChar *che, CharInfo *info) +{ + // The character wasn't found, propably ascii = 0, then the width shall be 0 as well + if(che == NULL) { + return 0.0f; + } + else if(info->flag & CU_SMALLCAPS) { + return che->width * cu->smallcaps_scale; + } + else { + return che->width; + } +} + struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) { VFont *vfont, *oldvfont; @@ -729,8 +758,18 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) makebreak: // Characters in the list che = vfd->characters.first; - ascii = mem[i]; info = &(custrinfo[i]); + ascii = mem[i]; + if(info->flag & CU_SMALLCAPS) { + ascii = towupper(ascii); + if(mem[i] != ascii) { + mem[i]= ascii; + } + else { + info->flag &= ~CU_SMALLCAPS; /* could have a different way to not scale caps */ + } + } + vfont = which_vfont(cu, info); if(vfont==NULL) break; @@ -780,11 +819,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) return 0; } - // The character wasn't found, propably ascii = 0, then the width shall be 0 as well - if(!che) - twidth = 0; - else - twidth = che->width; + twidth = char_width(cu, che, info); // Calculate positions if((tb->w != 0.0) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w) { @@ -881,10 +916,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) else wsfac = 1.0; // Set the width of the character - if(!che) - twidth = 0; - else - twidth = che->width; + twidth = char_width(cu, che, info); xof += (twidth*wsfac*(1.0+(info->kern/40.0)) ) + xtrax; @@ -1024,10 +1056,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) che = che->next; } - if(che) - twidth = che->width; - else - twidth = 0; + twidth = char_width(cu, che, info); dtime= distfac*0.35f*twidth; /* why not 0.5? */ dtime= distfac*0.5f*twidth; /* why not 0.5? */ @@ -1167,8 +1196,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) break; che = che->next; } - - if(!che) twidth =0; else twidth=che->width; + + twidth = char_width(cu, che, info); ulwidth = cu->fsize * ((twidth* (1.0+(info->kern/40.0)))+uloverlap); build_underline(cu, ct->xof*cu->fsize, ct->yof*cu->fsize + (cu->ulpos-0.05)*cu->fsize, ct->xof*cu->fsize + ulwidth, -- cgit v1.2.3 From 3580d6229a2c2ee5815ff76665d4bb014eacfb99 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 13 Jul 2010 23:51:21 +0000 Subject: - text3d was missing menu items for toggling bold/underline/italic/smallcaps. - made smallcaps use a temp flag so caps can still have the smallcaps flag. - utility function for getting the char from a font. find_vfont_char(), was inline in ~5 places. - removed CU_STYLE mix of flags only used in one place, not needed. removed 'style' from rna too. - fix for some warnings. --- source/blender/blenkernel/intern/font.c | 81 +++++++++++++-------------------- 1 file changed, 31 insertions(+), 50 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index d07bd2ba8e5..a99f2599f66 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -427,12 +427,12 @@ VFont *load_vfont(char *name) static VFont *which_vfont(Curve *cu, CharInfo *info) { - switch(info->flag & CU_STYLE) { - case CU_BOLD: + switch(info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) { + case CU_CHINFO_BOLD: if (cu->vfontb) return(cu->vfontb); else return(cu->vfont); - case CU_ITALIC: + case CU_CHINFO_ITALIC: if (cu->vfonti) return(cu->vfonti); else return(cu->vfont); - case (CU_BOLD|CU_ITALIC): + case (CU_CHINFO_BOLD|CU_CHINFO_ITALIC): if (cu->vfontbi) return(cu->vfontbi); else return(cu->vfont); default: return(cu->vfont); @@ -450,6 +450,17 @@ VFont *get_builtin_font(void) return load_vfont(""); } +static VChar *find_vfont_char(VFontData *vfd, intptr_t character) +{ + VChar *che= NULL; + + for(che = vfd->characters.first; che; che = che->next) { + if(che->index == character) + break; + } + return che; /* NULL if not found */ +} + static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, int charidx, short mat_nr) { Nurb *nu2; @@ -524,14 +535,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float si= (float)sin(rot); co= (float)cos(rot); - // Find the correct character from the font - che = vfd->characters.first; - while(che) - { - if(che->index == character) - break; - che = che->next; - } + che= find_vfont_char(vfd, character); // Select the glyph data if(che) @@ -598,7 +602,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float } bezt2 = nu2->bezt; - if(info->flag & CU_SMALLCAPS) { + if(info->flag & CU_CHINFO_SMALLCAPS_CHECK) { const float sca= cu->smallcaps_scale; for (i= nu2->pntsu; i > 0; i--) { fp= bezt2->vec[0]; @@ -656,7 +660,7 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info) if(che == NULL) { return 0.0f; } - else if(info->flag & CU_SMALLCAPS) { + else if(info->flag & CU_CHINFO_SMALLCAPS_CHECK) { return che->width * cu->smallcaps_scale; } else { @@ -745,7 +749,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) oldvfont = NULL; - for (i=0; iselboxes) MEM_freeN(cu->selboxes); cu->selboxes = NULL; @@ -760,26 +764,19 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) che = vfd->characters.first; info = &(custrinfo[i]); ascii = mem[i]; - if(info->flag & CU_SMALLCAPS) { + if(info->flag & CU_CHINFO_SMALLCAPS) { ascii = towupper(ascii); if(mem[i] != ascii) { mem[i]= ascii; - } - else { - info->flag &= ~CU_SMALLCAPS; /* could have a different way to not scale caps */ + info->flag |= CU_CHINFO_SMALLCAPS_CHECK; } } vfont = which_vfont(cu, info); if(vfont==NULL) break; - - // Find the character - while(che) { - if(che->index == ascii) - break; - che = che->next; - } + + che= find_vfont_char(vfd, ascii); /* * The character wasn't in the current curve base so load it @@ -791,12 +788,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) } /* Try getting the character again from the list */ - che = vfd->characters.first; - while(che) { - if(che->index == ascii) - break; - che = che->next; - } + che= find_vfont_char(vfd, ascii); /* No VFont found */ if (vfont==0) { @@ -833,13 +825,13 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) i = j-1; xof = ct->xof; ct[1].dobreak = 1; - custrinfo[i+1].flag |= CU_WRAP; + custrinfo[i+1].flag |= CU_CHINFO_WRAP; goto makebreak; } if (chartransdata[j].dobreak) { // fprintf(stderr, "word too long: %c%c%c...\n", mem[j], mem[j+1], mem[j+2]); ct->dobreak= 1; - custrinfo[i+1].flag |= CU_WRAP; + custrinfo[i+1].flag |= CU_CHINFO_WRAP; ct -= 1; cnr -= 1; i--; @@ -1047,14 +1039,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) /* rotate around center character */ ascii = mem[i]; - - // Find the character - che = vfd->characters.first; - while(che) { - if(che->index == ascii) - break; - che = che->next; - } + + che= find_vfont_char(vfd, ascii); twidth = char_width(cu, che, info); @@ -1180,22 +1166,17 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) if(cha != '\n' && cha != '\r') buildchar(cu, cha, info, ct->xof, ct->yof, ct->rot, i); - if ((info->flag & CU_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) { + if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) { float ulwidth, uloverlap= 0.0f; if ( (i<(slen-1)) && (mem[i+1] != '\n') && (mem[i+1] != '\r') && - ((mem[i+1] != ' ') || (custrinfo[i+1].flag & CU_UNDERLINE)) && ((custrinfo[i+1].flag & CU_WRAP)==0) + ((mem[i+1] != ' ') || (custrinfo[i+1].flag & CU_CHINFO_UNDERLINE)) && ((custrinfo[i+1].flag & CU_CHINFO_WRAP)==0) ) { uloverlap = xtrax + 0.1; } // Find the character, the characters has to be in the memory already // since character checking has been done earlier already. - che = vfd->characters.first; - while(che) { - if(che->index == cha) - break; - che = che->next; - } + che= find_vfont_char(vfd, cha); twidth = char_width(cu, che, info); ulwidth = cu->fsize * ((twidth* (1.0+(info->kern/40.0)))+uloverlap); -- cgit v1.2.3 From 6b6cdbe322a2663954b8c46699a8e162d1e923c5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2010 07:47:03 +0000 Subject: pointcache support for relative external paths with the useual // prefix as well as library path option. --- source/blender/blenkernel/intern/pointcache.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index e14828d0f20..5295a496d2b 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1067,20 +1067,20 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup static int ptcache_path(PTCacheID *pid, char *filename) { - Library *lib; + Library *lib= (pid)? pid->ob->id.lib: NULL; + const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.sce; size_t i; - lib= (pid)? pid->ob->id.lib: NULL; - if(pid->cache->flag & PTCACHE_EXTERNAL) { strcpy(filename, pid->cache->path); + + if(strncmp(filename, "//", 2)==0) + BLI_path_abs(filename, blendfilename); + return BLI_add_slash(filename); /* new strlen() */ } else if (G.relbase_valid || lib) { char file[MAX_PTCACHE_PATH]; /* we dont want the dir, only the file */ - char *blendfilename; - - blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.sce; BLI_split_dirfile(blendfilename, NULL, file); i = strlen(file); -- cgit v1.2.3 From 7ad8e5b6f87fbee78d6676e33b80be9cfc74feea Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 14 Jul 2010 09:46:26 +0000 Subject: Fix #22816: crash in depsgraph loading some 2.49 files, tagging objects for update on load should be done later because it's not known yet which scene is used with which layers visible before the windows are created. --- source/blender/blenkernel/intern/blender.c | 5 +++-- source/blender/blenkernel/intern/depsgraph.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 57e72fc5671..101c7a3bbbd 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -313,8 +313,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) /* baseflags, groups, make depsgraph, etc */ set_scene_bg(CTX_data_scene(C)); - - DAG_on_load_update(); MEM_freeN(bfd); } @@ -478,6 +476,9 @@ static int read_undosave(bContext *C, UndoElem *uel) strcpy(G.sce, scestr); G.fileflags= fileflags; + if(success) + DAG_on_load_update(); + return success; } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 1a1ca8a8d3e..142f80a350e 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2217,7 +2217,7 @@ static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay *sce= bmain->scene.first; if(*sce) *lay= (*sce)->lay; - /* XXX for background mode, we should get the scen + /* XXX for background mode, we should get the scene from somewhere, for the -S option, but it's in the context, how to get it here? */ } @@ -2248,7 +2248,7 @@ void DAG_on_load_update(void) dag_current_scene_layers(bmain, &scene, &lay); - if(scene) { + if(scene && scene->theDag) { /* derivedmeshes and displists are not saved to file so need to be remade, tag them so they get remade in the scene update loop, note armature poses or object matrices are preserved and do not -- cgit v1.2.3 From f406cf4ac82510c6b064d9411ec0cbd38a0ef7e0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 14 Jul 2010 10:46:12 +0000 Subject: Fix a few compile warnings and rename gpu_buffers.h to GPU_buffers.h for consistency. --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index d5ece6ae31f..8b1443403a3 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -59,7 +59,7 @@ #include "BIF_gl.h" #include "BIF_glutil.h" -#include "gpu_buffers.h" +#include "GPU_buffers.h" #include "GPU_draw.h" #include "GPU_extensions.h" #include "GPU_material.h" diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index a586ca57966..41e33002999 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -54,7 +54,7 @@ #include "MEM_guardedalloc.h" -#include "gpu_buffers.h" +#include "GPU_buffers.h" #include "GPU_draw.h" #include "GPU_extensions.h" #include "GPU_material.h" -- cgit v1.2.3 From ae1748b98470f08ed805e101b218f44c17d9b6b2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2010 12:16:23 +0000 Subject: bugfix [#22847] 18+ char Name in Edit Strip causes errors when duplicating strips --- source/blender/blenkernel/intern/sequencer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index e8f8c2f3c3b..d97e6151a13 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -795,7 +795,7 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui) Sequence *seq; for(seq=seqbasep->first; seq; seq= seq->next) { if (sui->seq != seq && strcmp(sui->name_dest, seq->name+2)==0) { - sprintf(sui->name_dest, "%.18s.%03d", sui->name_src, sui->count++); + sprintf(sui->name_dest, "%.17s.%03d", sui->name_src, sui->count++); /*24 - 2 for prefix, -1 for \0 */ sui->match= 1; /* be sure to re-scan */ } } @@ -816,12 +816,17 @@ void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq) strcpy(sui.name_src, seq->name+2); strcpy(sui.name_dest, seq->name+2); + sui.count= 1; + sui.match= 1; /* assume the worst to start the loop */ + /* Strip off the suffix */ - if ((dot=strrchr(sui.name_src, '.'))) + if ((dot=strrchr(sui.name_src, '.'))) { *dot= '\0'; + dot++; - sui.count= 1; - sui.match= 1; /* assume the worst to start the loop */ + if(*dot) + sui.count= atoi(dot) + 1; + } while(sui.match) { sui.match= 0; -- cgit v1.2.3 From 5505697ac508c02b8a2e196c5a8c07431bc687cf Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Wed, 14 Jul 2010 14:11:03 +0000 Subject: Merge GSOC Sculpt Branch: 28499-30319 https://svn.blender.org/svnroot/bf-blender/branches/soc-2010-jwilkins See log of that branch for details. --- source/blender/blenkernel/BKE_blender.h | 4 +- source/blender/blenkernel/BKE_brush.h | 10 +++ source/blender/blenkernel/BKE_paint.h | 4 + source/blender/blenkernel/intern/brush.c | 102 +++++++++++++++++++------- source/blender/blenkernel/intern/colortools.c | 56 ++++++++++---- source/blender/blenkernel/intern/icons.c | 5 +- source/blender/blenkernel/intern/image.c | 6 +- 7 files changed, 140 insertions(+), 47 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 7ac5815943a..5936805765d 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -43,9 +43,9 @@ struct bContext; struct ReportList; struct Scene; struct Main; - + #define BLENDER_VERSION 252 -#define BLENDER_SUBVERSION 5 +#define BLENDER_SUBVERSION 6 // XXX: this shouldn't be merged with trunk, this is so Sculpt branch can detect old files #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index fcc636215c9..6a209167f93 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -84,5 +84,15 @@ unsigned int *brush_gen_texture_cache(struct Brush *br, int half_side); void brush_radial_control_invoke(struct wmOperator *op, struct Brush *br, float size_weight); int brush_radial_control_exec(struct wmOperator *op, struct Brush *br, float size_weight); +/* unified strength and size */ +int sculpt_get_brush_size(struct Brush *brush); +void sculpt_set_brush_size(struct Brush *brush, int size); +int sculpt_get_lock_brush_size(struct Brush *brush); +float sculpt_get_brush_unprojected_radius(struct Brush *brush); +void sculpt_set_brush_unprojected_radius(struct Brush *brush, float unprojected_radius); +float sculpt_get_brush_alpha(struct Brush *brush); +void sculpt_set_brush_alpha(struct Brush *brush, float alpha); + + #endif diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index cd412ca5a74..f9954b3d55d 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -28,6 +28,8 @@ #ifndef BKE_PAINT_H #define BKE_PAINT_H +#include "DNA_vec_types.h" + struct Brush; struct MFace; struct MultireModifierData; @@ -96,6 +98,8 @@ typedef struct SculptSession { struct GPUDrawObject *drawobject; int modifiers_active; + + rcti previous_r; } SculptSession; void free_sculptsession(struct Object *ob); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 538012ccc41..c423d426e32 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -53,8 +53,7 @@ #include "BKE_main.h" #include "BKE_paint.h" #include "BKE_texture.h" - - +#include "BKE_icons.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -70,29 +69,59 @@ Brush *add_brush(const char *name) brush= alloc_libblock(&G.main->brush, ID_BR, name); - brush->rgb[0]= 1.0f; + /* BRUSH SCULPT TOOL SETTINGS */ + brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */ + brush->size= 35; /* radius of the brush in pixels */ + brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */ + brush->autosmooth_factor= 0.0f; + brush->crease_pinch_factor= 0.5f; + brush->sculpt_plane = SCULPT_DISP_DIR_VIEW; + brush->plane_offset= 0.0f; /* how far above or below the plane that is found by averaging the faces */ + brush->plane_trim= 0.5f; + brush->clone.alpha= 0.5f; + brush->normal_weight= 0.0f; + + /* BRUSH PAINT TOOL SETTINGS */ + brush->rgb[0]= 1.0f; /* default rgb color of the brush when painting - white */ brush->rgb[1]= 1.0f; brush->rgb[2]= 1.0f; - brush->alpha= 0.2f; - brush->size= 25; - brush->spacing= 3.5f; + + /* BRUSH STROKE SETTINGS */ + brush->flag |= (BRUSH_SPACE|BRUSH_SPACE_ATTEN); + brush->spacing= 10; /* how far each brush dot should be spaced as a percentage of brush diameter */ + brush->smooth_stroke_radius= 75; - brush->smooth_stroke_factor= 0.9; - brush->rate= 0.1f; + brush->smooth_stroke_factor= 0.9f; + + brush->rate= 0.1f; /* time delay between dots of paint or sculpting when doing airbrush mode */ + brush->jitter= 0.0f; - brush->clone.alpha= 0.5; - brush->sculpt_tool = SCULPT_TOOL_DRAW; - brush->flag |= BRUSH_SPACE; - brush_curve_preset(brush, CURVE_PRESET_SMOOTH); - + /* BRUSH TEXTURE SETTINGS */ default_mtex(&brush->mtex); + brush->texture_sample_bias= 0; /* value to added to texture samples */ + + /* brush appearance */ + + brush->image_icon= NULL; + + brush->add_col[0]= 1.00; /* add mode color is light red */ + brush->add_col[1]= 0.39; + brush->add_col[2]= 0.39; + + brush->sub_col[0]= 0.39; /* subtract mode color is light blue */ + brush->sub_col[1]= 0.39; + brush->sub_col[2]= 1.00; + + /* the default alpha falloff curve */ + brush_curve_preset(brush, CURVE_PRESET_SMOOTH); + /* enable fake user by default */ brush->id.flag |= LIB_FAKEUSER; brush_toggled_fake_user(brush); - - return brush; + + return brush; } Brush *copy_brush(Brush *brush) @@ -118,7 +147,7 @@ Brush *copy_brush(Brush *brush) void free_brush(Brush *brush) { if(brush->mtex.tex) brush->mtex.tex->id.us--; - + curvemapping_free(brush->curve); } @@ -731,11 +760,19 @@ static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pres brush->spacing = MAX2(1.0, painter->startspacing*(1.5f-pressure)); } -static void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos) +void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos) { if(brush->jitter){ - jitterpos[0] = pos[0] + ((BLI_frand()-0.5f) * brush->size * brush->jitter * 2); - jitterpos[1] = pos[1] + ((BLI_frand()-0.5f) * brush->size * brush->jitter * 2); + float rand_pos[2]; + + // find random position within a circle of diameter 1 + do { + rand_pos[0] = BLI_frand()-0.5f; + rand_pos[1] = BLI_frand()-0.5f; + } while (len_v2(rand_pos) > 0.5f); + + jitterpos[0] = pos[0] + 2*rand_pos[0]*brush->size*brush->jitter; + jitterpos[1] = pos[1] + 2*rand_pos[1]*brush->size*brush->jitter; } else { VECCOPY2D(jitterpos, pos); @@ -887,7 +924,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl /* Uses the brush curve control to find a strength value between 0 and 1 */ float brush_curve_strength_clamp(Brush *br, float p, const float len) { - if(p >= len) p= 1.0f; + if(p >= len) return 0; else p= p/len; p= curvemapping_evaluateF(br->curve, 0, p); @@ -899,9 +936,12 @@ float brush_curve_strength_clamp(Brush *br, float p, const float len) * used for sculpt only */ float brush_curve_strength(Brush *br, float p, const float len) { - if(p >= len) p= 1.0f; - else p= p/len; - return curvemapping_evaluateF(br->curve, 0, p); + if(p >= len) + p= 1.0f; + else + p= p/len; + + return curvemapping_evaluateF(br->curve, 0, p); } /* TODO: should probably be unified with BrushPainter stuff? */ @@ -915,7 +955,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side) memset(&texres, 0, sizeof(TexResult)); - if(mtex && mtex->tex) { + if(mtex->tex) { float x, y, step = 2.0 / side, co[3]; texcache = MEM_callocN(sizeof(int) * side * side, "Brush texture cache"); @@ -993,9 +1033,9 @@ void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight) float original_value= 0; if(mode == WM_RADIALCONTROL_SIZE) - original_value = br->size * size_weight; + original_value = sculpt_get_brush_size(br) * size_weight; else if(mode == WM_RADIALCONTROL_STRENGTH) - original_value = br->alpha; + original_value = sculpt_get_brush_alpha(br); else if(mode == WM_RADIALCONTROL_ANGLE) { MTex *mtex = brush_active_texture(br); if(mtex) @@ -1013,9 +1053,15 @@ int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight) const float conv = 0.017453293; if(mode == WM_RADIALCONTROL_SIZE) - br->size = new_value * size_weight; + if (sculpt_get_lock_brush_size(br)) { + float initial_value = RNA_float_get(op->ptr, "initial_value"); + const float unprojected_radius = sculpt_get_brush_unprojected_radius(br); + sculpt_set_brush_unprojected_radius(br, unprojected_radius * new_value/initial_value * size_weight); + } + else + sculpt_set_brush_size(br, new_value * size_weight); else if(mode == WM_RADIALCONTROL_STRENGTH) - br->alpha = new_value; + sculpt_set_brush_alpha(br, new_value); else if(mode == WM_RADIALCONTROL_ANGLE) { MTex *mtex = brush_active_texture(br); if(mtex) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index c8a01b1c12f..a07c18f42f3 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -126,6 +126,9 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa cumap->cm[a].curve[1].x= maxx; cumap->cm[a].curve[1].y= maxy; } + + cumap->changed_timestamp = 0; + return cumap; } @@ -240,10 +243,12 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset) switch(preset) { case CURVE_PRESET_LINE: cuma->totpoint= 2; break; - case CURVE_PRESET_SHARP: cuma->totpoint= 3; break; + case CURVE_PRESET_SHARP: cuma->totpoint= 4; break; case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break; case CURVE_PRESET_MAX: cuma->totpoint= 2; break; - case CURVE_PRESET_MID9: cuma->totpoint= 9; + case CURVE_PRESET_MID9: cuma->totpoint= 9; break; + case CURVE_PRESET_ROUND: cuma->totpoint= 4; break; + case CURVE_PRESET_ROOT: cuma->totpoint= 4; break; } cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points"); @@ -251,27 +256,29 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset) switch(preset) { case CURVE_PRESET_LINE: cuma->curve[0].x= clipr->xmin; - cuma->curve[0].y= clipr->ymin; + cuma->curve[0].y= clipr->ymax; cuma->curve[0].flag= 0; cuma->curve[1].x= clipr->xmax; - cuma->curve[1].y= clipr->ymax; + cuma->curve[1].y= clipr->ymin; cuma->curve[1].flag= 0; break; case CURVE_PRESET_SHARP: cuma->curve[0].x= 0; cuma->curve[0].y= 1; - cuma->curve[1].x= 0.33; - cuma->curve[1].y= 0.33; - cuma->curve[2].x= 1; - cuma->curve[2].y= 0; + cuma->curve[1].x= 0.25; + cuma->curve[1].y= 0.50; + cuma->curve[2].x= 0.75; + cuma->curve[2].y= 0.04; + cuma->curve[3].x= 1; + cuma->curve[3].y= 0; break; case CURVE_PRESET_SMOOTH: cuma->curve[0].x= 0; cuma->curve[0].y= 1; cuma->curve[1].x= 0.25; - cuma->curve[1].y= 0.92; + cuma->curve[1].y= 0.94; cuma->curve[2].x= 0.75; - cuma->curve[2].y= 0.08; + cuma->curve[2].y= 0.06; cuma->curve[3].x= 1; cuma->curve[3].y= 0; break; @@ -290,8 +297,29 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset) cuma->curve[i].y= 0.5; } } + break; + case CURVE_PRESET_ROUND: + cuma->curve[0].x= 0; + cuma->curve[0].y= 1; + cuma->curve[1].x= 0.5; + cuma->curve[1].y= 0.90; + cuma->curve[2].x= 0.86; + cuma->curve[2].y= 0.5; + cuma->curve[3].x= 1; + cuma->curve[3].y= 0; + break; + case CURVE_PRESET_ROOT: + cuma->curve[0].x= 0; + cuma->curve[0].y= 1; + cuma->curve[1].x= 0.25; + cuma->curve[1].y= 0.95; + cuma->curve[2].x= 0.75; + cuma->curve[2].y= 0.44; + cuma->curve[3].x= 1; + cuma->curve[3].y= 0; + break; } - + if(cuma->table) { MEM_freeN(cuma->table); cuma->table= NULL; @@ -619,7 +647,9 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) float thresh= 0.01f*(clipr->xmax - clipr->xmin); float dx= 0.0f, dy= 0.0f; int a; - + + cumap->changed_timestamp++; + /* clamp with clip */ if(cumap->flag & CUMA_DO_CLIP) { for(a=0; atotpoint; a++) { @@ -701,7 +731,7 @@ float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value) if(cuma->table==NULL) { curvemap_make_table(cuma, &cumap->clipr); if(cuma->table==NULL) - return value; + return 1.0f-value; } return curvemap_evaluateF(cuma, value); } diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 29314fb4865..ad2c857be75 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -38,6 +38,7 @@ #include "DNA_material_types.h" #include "DNA_texture_types.h" #include "DNA_world_types.h" +#include "DNA_brush_types.h" #include "BLI_ghash.h" @@ -120,6 +121,7 @@ struct PreviewImage* BKE_previewimg_create() for (i=0; ichanged[i] = 1; + prv_img->changed_timestamp[i] = 0; } return prv_img; } @@ -202,7 +204,7 @@ PreviewImage* BKE_previewimg_get(ID *id) Image *img = (Image*)id; if (!img->preview) img->preview = BKE_previewimg_create(); prv_img = img->preview; - } + } return prv_img; } @@ -224,6 +226,7 @@ void BKE_icon_changed(int id) int i; for (i=0; ichanged[i] = 1; + prv->changed_timestamp[i]++; } } } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index dc78dac04dd..b66b5c60916 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -200,9 +200,9 @@ void free_image(Image *ima) } BKE_icon_delete(&ima->id); ima->id.icon_id = 0; - if (ima->preview) { - BKE_previewimg_free(&ima->preview); - } + + BKE_previewimg_free(&ima->preview); + for(a=0; arenders[a]) { RE_FreeRenderResult(ima->renders[a]); -- cgit v1.2.3 From 8e3a9634a3dd939225d1424e0fd97b3d45746503 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Jul 2010 17:47:58 +0000 Subject: Change to text3d: When back or front is enabled, the bevel rim on the other side is not created anymore, just as the back/front filling faces are not created when disabled. when both are off the behavior is unchanged. This is needed when rendering alpha text so its possible to have a single layer of faces but use the bevel option to make text thicker. adding a rim on the back when back is disabled also doesnt make much sense IMHO. minor python edits too. --- source/blender/blenkernel/intern/curve.c | 99 +++++++++++++++++--------------- 1 file changed, 52 insertions(+), 47 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 2e645592229..aa7b44aecda 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1318,30 +1318,33 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) short dnr; /* bevel now in three parts, for proper vertex normals */ - /* part 1 */ - dnr= nr= 2+ cu->bevresol; - if( (cu->flag & (CU_FRONT|CU_BACK))==0) - nr= 3+ 2*cu->bevresol; - - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p1"); - dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p1"); - BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->parts= 1; - dl->flag= DL_BACK_CURVE; - dl->nr= nr; + /* part 1, back */ - /* half a circle */ - fp= dl->verts; - dangle= (0.5*M_PI/(dnr-1)); - angle= -(nr-1)*dangle; - - for(a=0; aext2)); - fp[2]= (float)(sin(angle)*(cu->ext2)) - cu->ext1; - angle+= dangle; - fp+= 3; + if((cu->flag & CU_BACK) || !(cu->flag & CU_FRONT)) { + dnr= nr= 2+ cu->bevresol; + if( (cu->flag & (CU_FRONT|CU_BACK))==0) + nr= 3+ 2*cu->bevresol; + + dl= MEM_callocN(sizeof(DispList), "makebevelcurve p1"); + dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p1"); + BLI_addtail(disp, dl); + dl->type= DL_SEGM; + dl->parts= 1; + dl->flag= DL_BACK_CURVE; + dl->nr= nr; + + /* half a circle */ + fp= dl->verts; + dangle= (0.5*M_PI/(dnr-1)); + angle= -(nr-1)*dangle; + + for(a=0; aext2)); + fp[2]= (float)(sin(angle)*(cu->ext2)) - cu->ext1; + angle+= dangle; + fp+= 3; + } } /* part 2, sidefaces */ @@ -1374,30 +1377,32 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) } } - /* part 3 */ - dnr= nr= 2+ cu->bevresol; - if( (cu->flag & (CU_FRONT|CU_BACK))==0) - nr= 3+ 2*cu->bevresol; - - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p3"); - dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p3"); - BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->flag= DL_FRONT_CURVE; - dl->parts= 1; - dl->nr= nr; - - /* half a circle */ - fp= dl->verts; - angle= 0.0; - dangle= (0.5*M_PI/(dnr-1)); - - for(a=0; aext2)); - fp[2]= (float)(sin(angle)*(cu->ext2)) + cu->ext1; - angle+= dangle; - fp+= 3; + /* part 3, front */ + if((cu->flag & CU_FRONT) || !(cu->flag & CU_BACK)) { + dnr= nr= 2+ cu->bevresol; + if( (cu->flag & (CU_FRONT|CU_BACK))==0) + nr= 3+ 2*cu->bevresol; + + dl= MEM_callocN(sizeof(DispList), "makebevelcurve p3"); + dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p3"); + BLI_addtail(disp, dl); + dl->type= DL_SEGM; + dl->flag= DL_FRONT_CURVE; + dl->parts= 1; + dl->nr= nr; + + /* half a circle */ + fp= dl->verts; + angle= 0.0; + dangle= (0.5*M_PI/(dnr-1)); + + for(a=0; aext2)); + fp[2]= (float)(sin(angle)*(cu->ext2)) + cu->ext1; + angle+= dangle; + fp+= 3; + } } } } -- cgit v1.2.3 From 7de6a8e1aceaa109cd4c4f9274b25303c7c8a2ba Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Wed, 14 Jul 2010 20:08:30 +0000 Subject: * Accidentally bumped file subversion after sculpt merge. Perhaps this should be done, but not without permission. My comment even said not to merge it :) --- 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 5936805765d..baec6ecfe6a 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 6 // XXX: this shouldn't be merged with trunk, this is so Sculpt branch can detect old files +#define BLENDER_SUBVERSION 5 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 -- cgit v1.2.3