diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-06-26 17:39:43 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-06-26 17:39:43 +0400 |
commit | cb805085ef5b149ade908f3962f655acf31b1d08 (patch) | |
tree | 85e755ba02324c2a808464995c8ee80c2015d2f0 /source | |
parent | ee61785384b9fa351d57b0803ab1ab44c8498016 (diff) | |
parent | 892851f787fb4613a297ecb350df114b379ab21b (diff) |
Merged changes in the trunk up to revision 29702.
Diffstat (limited to 'source')
111 files changed, 2443 insertions, 717 deletions
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/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 6b8f18e9e17..31e920406c0 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -75,6 +75,9 @@ 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]); +void offset_to_key(struct Object *ob, struct KeyBlock *kb, float (*ofs)[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/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 354638013ec..6fe1c2a96ea 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -191,17 +191,22 @@ 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 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 dupe_flag); + 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 { @@ -223,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/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/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<numEffectedF; ptrIdx++) { CCGFace *f = (CCGFace*) effectedF[ptrIdx]; int S, x, y; @@ -1285,7 +1285,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, } } - //#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<numEffectedF; ptrIdx++) { CCGFace *f = (CCGFace*) effectedF[ptrIdx]; int S, x, y; @@ -1351,7 +1351,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, int vertDataSize = ss->meshIFC.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<numEffectedF; ptrIdx++) { CCGFace *f = (CCGFace*) effectedF[ptrIdx]; int S, x, y; @@ -1685,17 +1685,17 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - //#pragma omp parallel private(ptrIdx) + #pragma omp parallel private(ptrIdx) if(numEffectedF*edgeSize*edgeSize*4 >= 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<numEffectedF; ptrIdx++) { CCGFace *f = (CCGFace*) effectedF[ptrIdx]; int S, x, y; @@ -1779,7 +1779,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - //#pragma omp critical + #pragma omp critical { MEM_freeN(q); MEM_freeN(r); @@ -1791,14 +1791,14 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, gridSize = 1 + (1<<((nextLvl)-1)); cornerIdx = gridSize-1; - //#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; i<numEffectedE; i++) { CCGEdge *e = effectedE[i]; VertDataCopy(EDGE_getCo(e, nextLvl, 0), VERT_getCo(e->v0, 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; i<numEffectedF; i++) { CCGFace *f = effectedF[i]; int S, x; diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h index 12212c7a37b..34d684221b0 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.h +++ b/source/blender/blenkernel/intern/CCGSubSurf.h @@ -39,6 +39,10 @@ typedef enum { /***/ +#define CCG_OMP_LIMIT 1000000 + +/***/ + typedef struct _CCGSubSurf CCGSubSurf; CCGSubSurf* ccgSubSurf_new (CCGMeshIFC *ifc, int subdivisionLevels, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator); 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; 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 <memory2> in the filename */ diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 80f39531b34..9bba893c2c8 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); } @@ -734,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); @@ -747,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); 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/displist.c b/source/blender/blenkernel/intern/displist.c index 24f996fbb31..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; @@ -1855,6 +1858,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/key.c b/source/blender/blenkernel/intern/key.c index f604d307551..b8219c4aa35 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,202 @@ 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; a<tot; a++, fp+=3, co+=3) { + copy_v3_v3(co, fp); + } + } 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++) { + 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; a<tot; a++, fp+=3, co+=3) { + copy_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++) { + 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; + } + } +} + +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; a<kb->totelem; 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; + } + } +} 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; + } } } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index d567e0f0408..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 */ @@ -560,7 +561,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int dGridSize = multires_side_tot[totlvl]; dSkip = (dGridSize-1)/(gridSize-1); - //#pragma omp parallel for private(i) schedule(static) + #pragma omp parallel for private(i) if(me->totface*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 +569,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); } @@ -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); 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]; 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; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6d195dc0838..4c38913fa56 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" @@ -199,6 +200,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(sce->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! */ @@ -213,6 +218,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/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) { diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d1ab63ca65e..4241f481c30 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3790,6 +3790,34 @@ 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->startdisp); + SWAP(int, seq_a->enddisp, 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 +3860,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 +3875,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 +3918,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) { @@ -3934,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) @@ -3982,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; @@ -3989,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; @@ -4029,3 +4090,131 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo return seq; } + + +static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag) +{ + 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"); + } + + 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, int dupe_flag) +{ + Sequence * seqn = seq_dupli(scene, seq, dupe_flag); + if (seq->type == SEQ_META) { + Sequence *s; + for(s= seq->seqbase.first; s; s = s->next) { + Sequence *n = seq_dupli_recursive(scene, s, dupe_flag); + if (n) { + BLI_addtail(&seqn->seqbase, n); + } + } + } + return seqn; +} + +void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase, int dupe_flag) +{ + 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 = seq_dupli(scene, seq, dupe_flag); + if (seqn) { /*should never fail */ + 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, dupe_flag); + + if(dupe_flag & SEQ_DUPE_CONTEXT) { + if (seq == last_seq) { + seq_active_set(scene, seqn); + } + } + } + } + } +} 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) diff --git a/source/blender/blenlib/BLI_cpu.h b/source/blender/blenlib/BLI_cpu.h new file mode 100644 index 00000000000..d809f1cc594 --- /dev/null +++ b/source/blender/blenlib/BLI_cpu.h @@ -0,0 +1,30 @@ +/* + * + * $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. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BLI_CPU_H +#define BLI_CPU_H + +int BLI_cpu_support_sse2(void); + +#endif + diff --git a/source/blender/blenlib/BLI_linklist.h b/source/blender/blenlib/BLI_linklist.h index 2ce40cf6231..b10d48e3ee6 100644 --- a/source/blender/blenlib/BLI_linklist.h +++ b/source/blender/blenlib/BLI_linklist.h @@ -47,11 +47,14 @@ typedef struct LinkNode { int BLI_linklist_length (struct LinkNode *list); int BLI_linklist_index (struct LinkNode *list, void *ptr); +struct LinkNode *BLI_linklist_find (struct LinkNode *list, int index); + void BLI_linklist_reverse (struct LinkNode **listp); void BLI_linklist_prepend (struct LinkNode **listp, void *ptr); void BLI_linklist_append (struct LinkNode **listp, void *ptr); void BLI_linklist_prepend_arena (struct LinkNode **listp, void *ptr, struct MemArena *ma); +void BLI_linklist_insert_after (struct LinkNode **listp, void *ptr); void BLI_linklist_free (struct LinkNode *list, LinkNodeFreeFP freefunc); void BLI_linklist_apply (struct LinkNode *list, LinkNodeApplyFP applyfunc, void *userdata); diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index c143c44c594..bb20cb7c8e1 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -115,6 +115,9 @@ extern "C" { #ifndef fmodf #define fmodf(a, b) ((float)fmod(a, b)) #endif +#ifndef hypotf +#define hypotf(a, b) ((float)hypot(a, b)) +#endif #ifdef WIN32 #ifndef FREE_WINDOWS diff --git a/source/blender/blenlib/BLI_math_inline.h b/source/blender/blenlib/BLI_math_inline.h index c762144a4b8..d002c0880b2 100644 --- a/source/blender/blenlib/BLI_math_inline.h +++ b/source/blender/blenlib/BLI_math_inline.h @@ -38,11 +38,14 @@ extern "C" { #ifdef BLI_MATH_INLINE #ifdef _MSC_VER #define MINLINE static __forceinline +#define MALWAYS_INLINE MINLINE #else #define MINLINE static inline +#define MALWAYS_INLINE static __attribute__((always_inline)) #endif #else #define MINLINE +#define MALWAYS_INLINE #endif #ifdef __cplusplus diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 31cefb21e7a..77ebcb24975 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -122,6 +122,9 @@ float determinant_m3( float g, float h, float i); float determinant_m4(float A[4][4]); +void svd_m4(float U[4][4], float s[4], float V[4][4], float A[4][4]); +void pseudoinverse_m4_m4(float Ainv[4][4], float A[4][4], float epsilon); + /****************************** Transformations ******************************/ void scale_m3_fl(float R[3][3], float scale); diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h index e32e85e70ec..519e3ddde1d 100644 --- a/source/blender/blenlib/BLI_pbvh.h +++ b/source/blender/blenlib/BLI_pbvh.h @@ -114,6 +114,12 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot void BLI_pbvh_grids_update(PBVH *bvh, struct DMGridData **grids, struct DMGridAdjacency *gridadj, void **gridfaces); +/* vertex deformer */ +float (*BLI_pbvh_get_vertCos(struct PBVH *pbvh))[3]; +void BLI_pbvh_apply_vertCos(struct PBVH *pbvh, float (*vertCos)[3]); +int BLI_pbvh_isDeformed(struct PBVH *pbvh); + + /* Vertex Iterator */ /* this iterator has quite a lot of code, but it's designed to: diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c index afa4d273090..c903e66057e 100644 --- a/source/blender/blenlib/intern/BLI_linklist.c +++ b/source/blender/blenlib/intern/BLI_linklist.c @@ -45,18 +45,28 @@ int BLI_linklist_length(LinkNode *list) { } } -int BLI_linklist_index(struct LinkNode *list, void *ptr) +int BLI_linklist_index(LinkNode *list, void *ptr) { int index; - for (index = 0; list; list= list->next, index++) { + for (index = 0; list; list= list->next, index++) if (list->link == ptr) return index; - } return -1; } +LinkNode *BLI_linklist_find(LinkNode *list, int index) +{ + int i; + + for (i = 0; list; list= list->next, i++) + if (i == index) + return list; + + return NULL; +} + void BLI_linklist_reverse(LinkNode **listp) { LinkNode *rhead= NULL, *cur= *listp; @@ -105,6 +115,22 @@ void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, MemArena *ma) { *listp= nlink; } +void BLI_linklist_insert_after(LinkNode **listp, void *ptr) { + LinkNode *nlink= MEM_mallocN(sizeof(*nlink), "nlink"); + LinkNode *node = *listp; + + nlink->link = ptr; + + if(node) { + nlink->next = node->next; + node->next = nlink; + } + else { + nlink->next = NULL; + *listp = nlink; + } +} + void BLI_linklist_free(LinkNode *list, LinkNodeFreeFP freefunc) { while (list) { LinkNode *next= list->next; diff --git a/source/blender/blenlib/intern/cpu.c b/source/blender/blenlib/intern/cpu.c new file mode 100644 index 00000000000..65e6b34488c --- /dev/null +++ b/source/blender/blenlib/intern/cpu.c @@ -0,0 +1,57 @@ +/** + * + * $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. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "BLI_cpu.h" + +int BLI_cpu_support_sse2(void) +{ +#if defined(__x86_64__) || defined(_M_X64) + /* x86_64 always has SSE2 instructions */ + return 1; +#elif defined(__GNUC__) && defined(i386) + /* for GCC x86 we check cpuid */ + unsigned int d; + __asm__( + "pushl %%ebx\n\t" + "cpuid\n\t" + "popl %%ebx\n\t" + : "=d"(d) + : "a"(1)); + return (d & 0x04000000) != 0; +#elif (defined(_MSC_VER) && defined(_M_IX86)) + /* also check cpuid for MSVC x86 */ + unsigned int d; + __asm { + xor eax, eax + inc eax + push ebx + cpuid + pop ebx + mov d, edx + } + return (d & 0x04000000) != 0; +#endif + + return 0; +} + diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 396ae7ca5ee..6e8f4622488 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1149,3 +1149,458 @@ void print_m4(char *str, float m[][4]) printf("%f %f %f %f\n",m[0][3],m[1][3],m[2][3],m[3][3]); printf("\n"); } + +/*********************************** SVD ************************************ + * from TNT matrix library + + * Compute the Single Value Decomposition of an arbitrary matrix A + * That is compute the 3 matrices U,W,V with U column orthogonal (m,n) + * ,W a diagonal matrix and V an orthogonal square matrix s.t. + * A = U.W.Vt. From this decomposition it is trivial to compute the + * (pseudo-inverse) of A as Ainv = V.Winv.tranpose(U). + */ + +void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) +{ + float A[4][4]; + float work1[4], work2[4]; + int m = 4; + int n = 4; + int maxiter = 200; + int nu = minf(m,n); + + float *work = work1; + float *e = work2; + float eps; + + int i=0, j=0, k=0, p, pp, iter; + + // Reduce A to bidiagonal form, storing the diagonal elements + // in s and the super-diagonal elements in e. + + int nct = minf(m-1,n); + int nrt = maxf(0,minf(n-2,m)); + + copy_m4_m4(A, A_); + zero_m4(U); + zero_v4(s); + + for (k = 0; k < maxf(nct,nrt); k++) { + if (k < nct) { + + // Compute the transformation for the k-th column and + // place the k-th diagonal in s[k]. + // Compute 2-norm of k-th column without under/overflow. + s[k] = 0; + for (i = k; i < m; i++) { + s[k] = hypotf(s[k],A[i][k]); + } + if (s[k] != 0.0f) { + float invsk; + if (A[k][k] < 0.0f) { + s[k] = -s[k]; + } + invsk = 1.0f/s[k]; + for (i = k; i < m; i++) { + A[i][k] *= invsk; + } + A[k][k] += 1.0f; + } + s[k] = -s[k]; + } + for (j = k+1; j < n; j++) { + if ((k < nct) && (s[k] != 0.0f)) { + + // Apply the transformation. + + float t = 0; + for (i = k; i < m; i++) { + t += A[i][k]*A[i][j]; + } + t = -t/A[k][k]; + for (i = k; i < m; i++) { + A[i][j] += t*A[i][k]; + } + } + + // Place the k-th row of A into e for the + // subsequent calculation of the row transformation. + + e[j] = A[k][j]; + } + if (k < nct) { + + // Place the transformation in U for subsequent back + // multiplication. + + for (i = k; i < m; i++) + U[i][k] = A[i][k]; + } + if (k < nrt) { + + // Compute the k-th row transformation and place the + // k-th super-diagonal in e[k]. + // Compute 2-norm without under/overflow. + e[k] = 0; + for (i = k+1; i < n; i++) { + e[k] = hypotf(e[k],e[i]); + } + if (e[k] != 0.0f) { + float invek; + if (e[k+1] < 0.0f) { + e[k] = -e[k]; + } + invek = 1.0f/e[k]; + for (i = k+1; i < n; i++) { + e[i] *= invek; + } + e[k+1] += 1.0f; + } + e[k] = -e[k]; + if ((k+1 < m) & (e[k] != 0.0f)) { + float invek1; + + // Apply the transformation. + + for (i = k+1; i < m; i++) { + work[i] = 0.0f; + } + for (j = k+1; j < n; j++) { + for (i = k+1; i < m; i++) { + work[i] += e[j]*A[i][j]; + } + } + invek1 = 1.0f/e[k+1]; + for (j = k+1; j < n; j++) { + float t = -e[j]*invek1; + for (i = k+1; i < m; i++) { + A[i][j] += t*work[i]; + } + } + } + + // Place the transformation in V for subsequent + // back multiplication. + + for (i = k+1; i < n; i++) + V[i][k] = e[i]; + } + } + + // Set up the final bidiagonal matrix or order p. + + p = minf(n,m+1); + if (nct < n) { + s[nct] = A[nct][nct]; + } + if (m < p) { + s[p-1] = 0.0f; + } + if (nrt+1 < p) { + e[nrt] = A[nrt][p-1]; + } + e[p-1] = 0.0f; + + // If required, generate U. + + for (j = nct; j < nu; j++) { + for (i = 0; i < m; i++) { + U[i][j] = 0.0f; + } + U[j][j] = 1.0f; + } + for (k = nct-1; k >= 0; k--) { + if (s[k] != 0.0f) { + for (j = k+1; j < nu; j++) { + float t = 0; + for (i = k; i < m; i++) { + t += U[i][k]*U[i][j]; + } + t = -t/U[k][k]; + for (i = k; i < m; i++) { + U[i][j] += t*U[i][k]; + } + } + for (i = k; i < m; i++ ) { + U[i][k] = -U[i][k]; + } + U[k][k] = 1.0f + U[k][k]; + for (i = 0; i < k-1; i++) { + U[i][k] = 0.0f; + } + } else { + for (i = 0; i < m; i++) { + U[i][k] = 0.0f; + } + U[k][k] = 1.0f; + } + } + + // If required, generate V. + + for (k = n-1; k >= 0; k--) { + if ((k < nrt) & (e[k] != 0.0f)) { + for (j = k+1; j < nu; j++) { + float t = 0; + for (i = k+1; i < n; i++) { + t += V[i][k]*V[i][j]; + } + t = -t/V[k+1][k]; + for (i = k+1; i < n; i++) { + V[i][j] += t*V[i][k]; + } + } + } + for (i = 0; i < n; i++) { + V[i][k] = 0.0f; + } + V[k][k] = 1.0f; + } + + // Main iteration loop for the singular values. + + pp = p-1; + iter = 0; + eps = powf(2.0f,-52.0f); + while (p > 0) { + int kase=0; + k=0; + + // Test for maximum iterations to avoid infinite loop + if(maxiter == 0) + break; + maxiter--; + + // This section of the program inspects for + // negligible elements in the s and e arrays. On + // completion the variables kase and k are set as follows. + + // kase = 1 if s(p) and e[k-1] are negligible and k<p + // kase = 2 if s(k) is negligible and k<p + // kase = 3 if e[k-1] is negligible, k<p, and + // s(k), ..., s(p) are not negligible (qr step). + // kase = 4 if e(p-1) is negligible (convergence). + + for (k = p-2; k >= -1; k--) { + if (k == -1) { + break; + } + if (fabsf(e[k]) <= eps*(fabsf(s[k]) + fabsf(s[k+1]))) { + e[k] = 0.0f; + break; + } + } + if (k == p-2) { + kase = 4; + } else { + int ks; + for (ks = p-1; ks >= k; ks--) { + float t; + if (ks == k) { + break; + } + t = (ks != p ? fabsf(e[ks]) : 0.f) + + (ks != k+1 ? fabsf(e[ks-1]) : 0.0f); + if (fabsf(s[ks]) <= eps*t) { + s[ks] = 0.0f; + break; + } + } + if (ks == k) { + kase = 3; + } else if (ks == p-1) { + kase = 1; + } else { + kase = 2; + k = ks; + } + } + k++; + + // Perform the task indicated by kase. + + switch (kase) { + + // Deflate negligible s(p). + + case 1: { + float f = e[p-2]; + e[p-2] = 0.0f; + for (j = p-2; j >= k; j--) { + float t = hypotf(s[j],f); + float invt = 1.0f/t; + float cs = s[j]*invt; + float sn = f*invt; + s[j] = t; + if (j != k) { + f = -sn*e[j-1]; + e[j-1] = cs*e[j-1]; + } + + for (i = 0; i < n; i++) { + t = cs*V[i][j] + sn*V[i][p-1]; + V[i][p-1] = -sn*V[i][j] + cs*V[i][p-1]; + V[i][j] = t; + } + } + } + break; + + // Split at negligible s(k). + + case 2: { + float f = e[k-1]; + e[k-1] = 0.0f; + for (j = k; j < p; j++) { + float t = hypotf(s[j],f); + float invt = 1.0f/t; + float cs = s[j]*invt; + float sn = f*invt; + s[j] = t; + f = -sn*e[j]; + e[j] = cs*e[j]; + + for (i = 0; i < m; i++) { + t = cs*U[i][j] + sn*U[i][k-1]; + U[i][k-1] = -sn*U[i][j] + cs*U[i][k-1]; + U[i][j] = t; + } + } + } + break; + + // Perform one qr step. + + case 3: { + + // Calculate the shift. + + float scale = maxf(maxf(maxf(maxf( + fabsf(s[p-1]),fabsf(s[p-2])),fabsf(e[p-2])), + fabsf(s[k])),fabsf(e[k])); + float invscale = 1.0f/scale; + float sp = s[p-1]*invscale; + float spm1 = s[p-2]*invscale; + float epm1 = e[p-2]*invscale; + float sk = s[k]*invscale; + float ek = e[k]*invscale; + float b = ((spm1 + sp)*(spm1 - sp) + epm1*epm1)*0.5f; + float c = (sp*epm1)*(sp*epm1); + float shift = 0.0f; + float f, g; + if ((b != 0.0f) || (c != 0.0f)) { + shift = sqrtf(b*b + c); + if (b < 0.0f) { + shift = -shift; + } + shift = c/(b + shift); + } + f = (sk + sp)*(sk - sp) + shift; + g = sk*ek; + + // Chase zeros. + + for (j = k; j < p-1; j++) { + float t = hypotf(f,g); + /* division by zero checks added to avoid NaN (brecht) */ + float cs = (t == 0.0f)? 0.0f: f/t; + float sn = (t == 0.0f)? 0.0f: g/t; + if (j != k) { + e[j-1] = t; + } + f = cs*s[j] + sn*e[j]; + e[j] = cs*e[j] - sn*s[j]; + g = sn*s[j+1]; + s[j+1] = cs*s[j+1]; + + for (i = 0; i < n; i++) { + t = cs*V[i][j] + sn*V[i][j+1]; + V[i][j+1] = -sn*V[i][j] + cs*V[i][j+1]; + V[i][j] = t; + } + + t = hypotf(f,g); + /* division by zero checks added to avoid NaN (brecht) */ + cs = (t == 0.0f)? 0.0f: f/t; + sn = (t == 0.0f)? 0.0f: g/t; + s[j] = t; + f = cs*e[j] + sn*s[j+1]; + s[j+1] = -sn*e[j] + cs*s[j+1]; + g = sn*e[j+1]; + e[j+1] = cs*e[j+1]; + if (j < m-1) { + for (i = 0; i < m; i++) { + t = cs*U[i][j] + sn*U[i][j+1]; + U[i][j+1] = -sn*U[i][j] + cs*U[i][j+1]; + U[i][j] = t; + } + } + } + e[p-2] = f; + iter = iter + 1; + } + break; + + // Convergence. + + case 4: { + + // Make the singular values positive. + + if (s[k] <= 0.0f) { + s[k] = (s[k] < 0.0f ? -s[k] : 0.0f); + + for (i = 0; i <= pp; i++) + V[i][k] = -V[i][k]; + } + + // Order the singular values. + + while (k < pp) { + float t; + if (s[k] >= s[k+1]) { + break; + } + t = s[k]; + s[k] = s[k+1]; + s[k+1] = t; + if (k < n-1) { + for (i = 0; i < n; i++) { + t = V[i][k+1]; V[i][k+1] = V[i][k]; V[i][k] = t; + } + } + if (k < m-1) { + for (i = 0; i < m; i++) { + t = U[i][k+1]; U[i][k+1] = U[i][k]; U[i][k] = t; + } + } + k++; + } + iter = 0; + p--; + } + break; + } + } +} + +void pseudoinverse_m4_m4(float Ainv[4][4], float A[4][4], float epsilon) +{ + /* compute moon-penrose pseudo inverse of matrix, singular values + below epsilon are ignored for stability (truncated SVD) */ + float V[4][4], W[4], Wm[4][4], U[4][4]; + int i; + + transpose_m4(A); + svd_m4(V, W, U, A); + transpose_m4(U); + transpose_m4(V); + + zero_m4(Wm); + for(i=0; i<4; i++) + Wm[i][i]= (W[i] < epsilon)? 0.0f: 1.0f/W[i]; + + transpose_m4(V); + + mul_serie_m4(Ainv, U, Wm, V, 0, 0, 0, 0, 0); +} diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index d6b8582ef26..141e5438bc9 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -199,8 +199,15 @@ float hashvectf[768]= { /* IMPROVED PERLIN NOISE */ /**************************/ -#define lerp(t, a, b) ((a)+(t)*((b)-(a))) -#define npfade(t) ((t)*(t)*(t)*((t)*((t)*6-15)+10)) +static float lerp(float t, float a, float b) +{ + return (a+t*(b-a)); +} + +static float npfade(float t) +{ + return (t*t*t*(t*(t*6.0f-15.0f)+10.0f)); +} static float grad(int hash, float x, float y, float z) { diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 1fd18e2967c..92e2c88e8a1 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -29,6 +29,7 @@ #include "BLI_pbvh.h" #include "BKE_DerivedMesh.h" +#include "BKE_mesh.h" /* for mesh_calc_normals */ #include "gpu_buffers.h" @@ -120,6 +121,9 @@ struct PBVH { #ifdef PERFCNTRS int perf_modified; #endif + + /* flag are verts/faces deformed */ + int deformed; }; #define STACK_FIXED_DEPTH 100 @@ -576,6 +580,15 @@ void BLI_pbvh_free(PBVH *bvh) } } + if (bvh->deformed) { + if (bvh->verts) { + /* if pbvh was deformed, new memory was allocated for verts/faces -- free it */ + + MEM_freeN(bvh->verts); + MEM_freeN(bvh->faces); + } + } + MEM_freeN(bvh->nodes); MEM_freeN(bvh->prim_indices); MEM_freeN(bvh); @@ -1330,3 +1343,55 @@ void BLI_pbvh_grids_update(PBVH *bvh, DMGridData **grids, DMGridAdjacency *grida bvh->gridfaces= gridfaces; } +float (*BLI_pbvh_get_vertCos(PBVH *pbvh))[3] +{ + int a; + float (*vertCos)[3]= NULL; + + if (pbvh->verts) { + float *co; + MVert *mvert= pbvh->verts; + + vertCos= MEM_callocN(3*pbvh->totvert*sizeof(float), "BLI_pbvh_get_vertCoords"); + co= (float*)vertCos; + + for (a= 0; a<pbvh->totvert; a++, mvert++, co+= 3) { + copy_v3_v3(co, mvert->co); + } + } + + return vertCos; +} + +void BLI_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3]) +{ + int a; + + if (!pbvh->deformed) { + if (pbvh->verts) { + /* if pbvh is not already deformed, verts/faces points to the */ + /* original data and applying new coords to this arrays would lead to */ + /* unneeded deformation -- duplicate verts/faces to avoid this */ + + pbvh->verts= MEM_dupallocN(pbvh->verts); + pbvh->faces= MEM_dupallocN(pbvh->faces); + + pbvh->deformed= 1; + } + } + + if (pbvh->verts) { + /* copy new verts coords */ + for (a= 0; a < pbvh->totvert; ++a) { + copy_v3_v3(pbvh->verts[a].co, vertCos[a]); + } + + /* coordinates are new -- normals should also be updated */ + mesh_calc_normals(pbvh->verts, pbvh->totvert, pbvh->faces, pbvh->totprim, NULL); + } +} + +int BLI_pbvh_isDeformed(PBVH *pbvh) +{ + return pbvh->deformed; +} diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 0ad6f84e8f0..726ed817f8b 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -158,20 +158,20 @@ void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot) tslot->do_thread= do_thread; tslot->avail= 1; } - - if(thread_levels == 0) { - MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread); + } + + if(thread_levels == 0) { + MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread); #if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) - /* workaround for Apple gcc 4.2.1 omp vs background thread bug, - we copy gomp thread local storage pointer to setting it again - inside the thread that we start */ - thread_tls_data = pthread_getspecific(gomp_tls_key); + /* workaround for Apple gcc 4.2.1 omp vs background thread bug, + we copy gomp thread local storage pointer to setting it again + inside the thread that we start */ + thread_tls_data = pthread_getspecific(gomp_tls_key); #endif - } - - thread_levels++; } + + thread_levels++; } /* amount of available threads */ @@ -287,11 +287,11 @@ void BLI_end_threads(ListBase *threadbase) } } BLI_freelistN(threadbase); - - thread_levels--; - if(thread_levels==0) - MEM_set_lock_callback(NULL, NULL); } + + thread_levels--; + if(thread_levels==0) + MEM_set_lock_callback(NULL, NULL); } /* System Information */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5cc2676d80e..e10a982dc2a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -138,7 +138,7 @@ #include "BKE_sequencer.h" #include "BKE_texture.h" // for open_plugin_tex #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND - +#include "BKE_ipo.h" #include "BKE_sound.h" //XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes @@ -5173,6 +5173,10 @@ static void direct_link_screen(FileData *fd, bScreen *sc) } snode->nodetree= snode->edittree= NULL; } + else if(sl->spacetype==SPACE_TIME) { + SpaceTime *stime= (SpaceTime *)sl; + stime->caches.first= stime->caches.last= NULL; + } else if(sl->spacetype==SPACE_LOGIC) { SpaceLogic *slogic= (SpaceLogic *)sl; @@ -9758,11 +9762,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main) do_versions_gpencil_2_50(main, screen); } - /* old Animation System (using IPO's) needs to be converted to the new Animato system - * (NOTE: conversion code in blenkernel/intern/ipo.c for now) - */ - //do_versions_ipos_to_animato(main); - /* shader, composit and texture node trees have id.name empty, put something in * to have them show in RNA viewer and accessible otherwise. */ @@ -10886,14 +10885,21 @@ static void do_versions(FileData *fd, Library *lib, Main *main) SpaceLink *sl; for (sl= sa->spacedata.first; sl; sl= sl->next) { if (sl->spacetype == SPACE_NODE) { - SpaceNode *snode; - - snode= (SpaceNode *)sl; + SpaceNode *snode= (SpaceNode *)sl; + if (snode->v2d.minzoom > 0.09f) snode->v2d.minzoom= 0.09f; if (snode->v2d.maxzoom < 2.31f) snode->v2d.maxzoom= 2.31f; } + else if (sl->spacetype == SPACE_TIME) { + SpaceTime *stime= (SpaceTime *)sl; + + /* enable all cache display */ + stime->cache_display |= TIME_CACHE_DISPLAY; + stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES); + stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE); + } } } } @@ -10954,6 +10960,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* don't forget to set version number in blender.c! */ } +static void do_versions_after_linking(FileData *fd, Library *lib, Main *main) +{ + /* old Animation System (using IPO's) needs to be converted to the new Animato system + */ + if(main->versionfile < 250) + do_versions_ipos_to_animato(main); +} + static void lib_link_all(FileData *fd, Main *main) { oldnewmap_sort(fd); @@ -11100,6 +11114,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filename) blo_join_main(&fd->mainlist); lib_link_all(fd, bfd->main); + do_versions_after_linking(fd, NULL, bfd->main); lib_verify_nodetree(bfd->main, 1); fix_relpaths_library(fd->relabase, bfd->main); /* make all relative paths, relative to the open blend file */ diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index b4185c5021f..a415b90ff08 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -1543,7 +1543,7 @@ private: vert += 3; } - filldisplist(&dispbase, &dispbase); + filldisplist(&dispbase, &dispbase, 0); int tottri = 0; dl= (DispList*)dispbase.first; diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt index f9136b69d9e..9e22bbd7d44 100644 --- a/source/blender/editors/armature/CMakeLists.txt +++ b/source/blender/editors/armature/CMakeLists.txt @@ -27,7 +27,6 @@ SET(INC ../../blenlib ../../makesdna ../../makesrna - ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc ../../../../intern/opennl/extern diff --git a/source/blender/editors/armature/Makefile b/source/blender/editors/armature/Makefile index 0291bcb1830..4838282de92 100644 --- a/source/blender/editors/armature/Makefile +++ b/source/blender/editors/armature/Makefile @@ -50,7 +50,6 @@ CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../python CPPFLAGS += -I../../gpu CPPFLAGS += -I../../makesrna -CPPFLAGS += -I../../render/extern/include CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include # own include diff --git a/source/blender/editors/armature/SConscript b/source/blender/editors/armature/SConscript index fd4b885b730..33e237a14db 100644 --- a/source/blender/editors/armature/SConscript +++ b/source/blender/editors/armature/SConscript @@ -5,7 +5,6 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' -incs += ' ../../render/extern/include' incs += ' ../../gpu ../../makesrna #/intern/opennl/extern' if env['OURPLATFORM'] == 'linux2': diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 099cfeddad7..a4a2d020482 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -130,6 +130,7 @@ void SKETCH_OT_draw_stroke(struct wmOperatorType *ot); void SKETCH_OT_draw_preview(struct wmOperatorType *ot); void SKETCH_OT_finish_stroke(struct wmOperatorType *ot); void SKETCH_OT_cancel_stroke(struct wmOperatorType *ot); +void SKETCH_OT_convert(struct wmOperatorType *ot); void SKETCH_OT_select(struct wmOperatorType *ot); /* ******************************************************* */ diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index acf30b45357..672dd22b704 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -96,6 +96,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(SKETCH_OT_draw_preview); WM_operatortype_append(SKETCH_OT_finish_stroke); WM_operatortype_append(SKETCH_OT_cancel_stroke); + WM_operatortype_append(SKETCH_OT_convert); WM_operatortype_append(SKETCH_OT_select); /* POSE */ @@ -190,14 +191,15 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SKETCH_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SKETCH_OT_finish_stroke", SELECTMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "SKETCH_OT_finish_stroke", RIGHTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_cancel_stroke", ESCKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SKETCH_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); + // Already part of view3d select + //WM_keymap_add_item(keymap, "SKETCH_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); /* sketch poll checks mode */ - WM_keymap_add_item(keymap, "SKETCH_OT_gesture", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", ACTIONMOUSE, KM_PRESS, 0, 0); - kmi = WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "SKETCH_OT_gesture", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", LEFTMOUSE, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "snap", 1); WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, 0, 0); kmi = WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, KM_CTRL, 0); diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 907fe50305a..fdc89936029 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -2154,7 +2154,7 @@ void sk_applyGesture(bContext *C, SK_Sketch *sketch) /********************************************/ -void sk_selectStroke(bContext *C, SK_Sketch *sketch, short mval[2], int extend) +int sk_selectStroke(bContext *C, SK_Sketch *sketch, short mval[2], int extend) { ViewContext vc; rcti rect; @@ -2199,7 +2199,10 @@ void sk_selectStroke(bContext *C, SK_Sketch *sketch, short mval[2], int extend) } + return 1; } + + return 0; } void sk_queueRedrawSketch(SK_Sketch *sketch) @@ -2301,7 +2304,7 @@ void sk_drawSketch(Scene *scene, View3D *v3d, SK_Sketch *sketch, int with_names) } } -#if 1 +#if 0 if (sketch->depth_peels.first != NULL) { float colors[8][3] = { @@ -2471,7 +2474,8 @@ void BIF_sk_selectStroke(bContext *C, short mval[2], short extend) if (sketch != NULL && ts->bone_sketching & BONE_SKETCHING) { - sk_selectStroke(C, sketch, mval, extend); + if (sk_selectStroke(C, sketch, mval, extend)) + ED_area_tag_redraw(CTX_wm_area(C)); } } @@ -2558,6 +2562,17 @@ SK_Sketch* viewcontextSketch(ViewContext *vc, int create) return sketch; } +static int sketch_convert(bContext *C, wmOperator *op, wmEvent *event) +{ + SK_Sketch *sketch = contextSketch(C, 0); + if (sketch != NULL) + { + sk_convert(C, sketch); + ED_area_tag_redraw(CTX_wm_area(C)); + } + return OPERATOR_FINISHED; +} + static int sketch_cancel(bContext *C, wmOperator *op, wmEvent *event) { SK_Sketch *sketch = contextSketch(C, 0); @@ -2590,8 +2605,8 @@ static int sketch_select(bContext *C, wmOperator *op, wmEvent *event) if (sketch) { short extend = 0; - sk_selectStroke(C, sketch, event->mval, extend); - ED_area_tag_redraw(CTX_wm_area(C)); + if (sk_selectStroke(C, sketch, event->mval, extend)) + ED_area_tag_redraw(CTX_wm_area(C)); } return OPERATOR_FINISHED; @@ -2859,6 +2874,21 @@ void SKETCH_OT_cancel_stroke(wmOperatorType *ot) // ot->flag= OPTYPE_UNDO; } +void SKETCH_OT_convert(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "convert"; + ot->idname= "SKETCH_OT_convert"; + + /* api callbacks */ + ot->invoke= sketch_convert; + + ot->poll= ED_operator_sketch_full_mode; + + /* flags */ + ot->flag= OPTYPE_UNDO; +} + void SKETCH_OT_finish_stroke(wmOperatorType *ot) { /* identifiers */ diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 1b1448477ea..546a15467c4 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -52,8 +52,6 @@ #include "BLI_polardecomp.h" #endif -#include "RE_raytrace.h" - #include "ONL_opennl.h" #include "BLO_sys_types.h" // for intptr_t support @@ -107,8 +105,7 @@ struct LaplacianSystem { float *p; /* values from all p vectors */ float *mindist; /* minimum distance to a bone for all vertices */ - RayObject *raytree; /* ray tracing acceleration structure */ - RayFace *faces; /* faces to add to the ray tracing struture */ + BVHTree *bvhtree; /* ray tracing acceleration structure */ MFace **vface; /* a face that the vertex belongs to */ } heat; @@ -396,29 +393,65 @@ float laplacian_system_get_solution(int v) #define WEIGHT_LIMIT_END 0.025f #define DISTANCE_EPSILON 1e-4f +typedef struct BVHCallbackUserData { + float start[3]; + float vec[3]; + LaplacianSystem *sys; +} BVHCallbackUserData; + +static void bvh_callback(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) +{ + BVHCallbackUserData *data = (struct BVHCallbackUserData*)userdata; + MFace *mf = data->sys->heat.mface + index; + float (*verts)[3] = data->sys->heat.verts; + float lambda, uv[2], n[3], dir[3]; + + mul_v3_v3fl(dir, data->vec, hit->dist); + + if(isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v2], verts[mf->v3], &lambda, uv)) { + normal_tri_v3(n, verts[mf->v1], verts[mf->v2], verts[mf->v3]); + if(lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) { + hit->index = index; + hit->dist *= lambda; + } + } + + mul_v3_v3fl(dir, data->vec, hit->dist); + + if(isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v3], verts[mf->v4], &lambda, uv)) { + normal_tri_v3(n, verts[mf->v1], verts[mf->v3], verts[mf->v4]); + if(lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) { + hit->index = index; + hit->dist *= lambda; + } + } +} + /* Raytracing for vertex to bone/vertex visibility */ static void heat_ray_tree_create(LaplacianSystem *sys) { MFace *mface = sys->heat.mface; + float (*verts)[3] = sys->heat.verts; int totface = sys->heat.totface; int totvert = sys->heat.totvert; int a; - sys->heat.raytree = RE_rayobject_vbvh_create(totface); - sys->heat.faces = MEM_callocN(sizeof(RayFace)*totface, "Heat RayFaces"); + sys->heat.bvhtree = BLI_bvhtree_new(totface, 0.0f, 4, 6); sys->heat.vface = MEM_callocN(sizeof(MFace*)*totvert, "HeatVFaces"); for(a=0; a<totface; a++) { - MFace *mf = mface+a; - RayFace *rayface = sys->heat.faces+a; - - RayObject *obj = RE_rayface_from_coords( - rayface, &sys->heat, mf, - sys->heat.verts[mf->v1], sys->heat.verts[mf->v2], - sys->heat.verts[mf->v3], mf->v4 ? sys->heat.verts[mf->v4] : 0 - ); - RE_rayobject_add(sys->heat.raytree, obj); + float bb[6]; + + INIT_MINMAX(bb, bb+3); + DO_MINMAX(verts[mf->v1], bb, bb+3); + DO_MINMAX(verts[mf->v2], bb, bb+3); + DO_MINMAX(verts[mf->v3], bb, bb+3); + if(mf->v4) { + DO_MINMAX(verts[mf->v4], bb, bb+3); + } + + BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2); //Setup inverse pointers to use on isect.orig sys->heat.vface[mf->v1]= mf; @@ -426,12 +459,14 @@ static void heat_ray_tree_create(LaplacianSystem *sys) sys->heat.vface[mf->v3]= mf; if(mf->v4) sys->heat.vface[mf->v4]= mf; } - RE_rayobject_done(sys->heat.raytree); + + BLI_bvhtree_balance(sys->heat.bvhtree); } static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) { - Isect isec; + BVHTreeRayHit hit; + BVHCallbackUserData data; MFace *mface; float end[3]; int visible; @@ -440,27 +475,24 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) if(!mface) return 1; - /* setup isec */ - memset(&isec, 0, sizeof(isec)); - isec.mode= RE_RAY_SHADOW; - isec.lay= -1; - isec.orig.ob = &sys->heat; - isec.orig.face = mface; - isec.skip = RE_SKIP_CULLFACE; - - copy_v3_v3(isec.start, sys->heat.verts[vertex]); + data.sys= sys; + copy_v3_v3(data.start, sys->heat.verts[vertex]); if(sys->heat.root) /* bone */ - closest_to_line_segment_v3(end, isec.start, + closest_to_line_segment_v3(end, data.start, sys->heat.root[source], sys->heat.tip[source]); else /* vertex */ copy_v3_v3(end, sys->heat.source[source]); - sub_v3_v3v3(isec.vec, end, isec.start); - isec.labda = 1.0f - 1e-5; - madd_v3_v3v3fl(isec.start, isec.start, isec.vec, 1e-5); + sub_v3_v3v3(data.vec, end, data.start); + madd_v3_v3v3fl(data.start, data.start, data.vec, 1e-5); + mul_v3_fl(data.vec, 1.0f - 2e-5); - visible= !RE_rayobject_raycast(sys->heat.raytree, &isec); + /* pass normalized vec + distance to bvh */ + hit.index = -1; + hit.dist = normalize_v3(data.vec); + + visible= BLI_bvhtree_ray_cast(sys->heat.bvhtree, data.start, data.vec, 0.0f, &hit, bvh_callback, (void*)&data) == -1; return visible; } @@ -587,9 +619,8 @@ static void heat_laplacian_create(LaplacianSystem *sys) static void heat_system_free(LaplacianSystem *sys) { - RE_rayobject_free(sys->heat.raytree); + BLI_bvhtree_free(sys->heat.bvhtree); MEM_freeN(sys->heat.vface); - MEM_freeN(sys->heat.faces); MEM_freeN(sys->heat.mindist); MEM_freeN(sys->heat.H); @@ -1050,11 +1081,19 @@ typedef struct MeshDeformBind { /* direct solver */ int *varidx; - - /* raytrace */ - RayObject *raytree; } MeshDeformBind; +typedef struct MeshDeformIsect { + float start[3]; + float vec[3]; + float labda; + + void *face; + int isect; + float u, v; + +} MeshDeformIsect; + /* ray intersection */ /* our own triangle intersection, so we can fully control the epsilons and @@ -1117,63 +1156,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], return 1; } -/* blender's raytracer is not use now, even though it is much faster. it can - * give problems with rays falling through, so we use our own intersection - * function above with tweaked epsilons */ - -#if 0 -static MeshDeformBind *MESHDEFORM_BIND = NULL; - -static void meshdeform_ray_coords_func(RayFace *face, float **v1, float **v2, float **v3, float **v4) -{ - MFace *mface= (MFace*)face; - float (*cagecos)[3]= MESHDEFORM_BIND->cagecos; - - *v1= cagecos[mface->v1]; - *v2= cagecos[mface->v2]; - *v3= cagecos[mface->v3]; - *v4= (mface->v4)? cagecos[mface->v4]: NULL; -} - -static int meshdeform_ray_check_func(Isect *is, RayFace *face) -{ - return 1; -} - -static void meshdeform_ray_tree_create(MeshDeformBind *mdb) -{ - MFace *mface; - float min[3], max[3]; - int a, totface; - - /* create a raytrace tree from the mesh */ - INIT_MINMAX(min, max); - - for(a=0; a<mdb->totcagevert; a++) - DO_MINMAX(mdb->cagecos[a], min, max) - - MESHDEFORM_BIND= mdb; - - mface= mdb->cagedm->getFaceArray(mdb->cagedm); - totface= mdb->cagedm->getNumFaces(mdb->cagedm); - - mdb->raytree= RE_ray_tree_create(64, totface, min, max, - meshdeform_ray_coords_func, meshdeform_ray_check_func); - - for(a=0; a<totface; a++, mface++) - RE_ray_tree_add_face(mdb->raytree, mface); - - RE_ray_tree_done(mdb->raytree); -} - -static void meshdeform_ray_tree_free(MeshDeformBind *mdb) -{ - MESHDEFORM_BIND= NULL; - RE_ray_tree_free(mdb->raytree); -} -#endif - -static int meshdeform_intersect(MeshDeformBind *mdb, Isect *isec) +static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec) { MFace *mface; float face[4][3], co[3], uvw[3], len, nor[3], end[3]; @@ -1212,7 +1195,7 @@ static int meshdeform_intersect(MeshDeformBind *mdb, Isect *isec) len= len_v3v3(isec->start, co)/len_v3v3(isec->start, end); if(len < isec->labda) { isec->labda= len; - isec->hit.face = mface; + isec->face = mface; isec->isect= (INPR(isec->vec, nor) <= 0.0f); is= 1; } @@ -1225,7 +1208,7 @@ static int meshdeform_intersect(MeshDeformBind *mdb, Isect *isec) static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float *co1, float *co2) { MDefBoundIsect *isect; - Isect isec; + MeshDeformIsect isec; float (*cagecos)[3]; MFace *mface; float vert[4][3], len, end[3]; @@ -1233,21 +1216,15 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float /* setup isec */ memset(&isec, 0, sizeof(isec)); - isec.mode= RE_RAY_MIRROR; /* we want the closest intersection */ - isec.lay= -1; isec.labda= 1e10f; VECADD(isec.start, co1, epsilon); VECADD(end, co2, epsilon); sub_v3_v3v3(isec.vec, end, isec.start); -#if 0 - /*if(RE_ray_tree_intersect(mdb->raytree, &isec)) {*/ -#endif - if(meshdeform_intersect(mdb, &isec)) { len= isec.labda; - mface=(MFace*)isec.hit.face; + mface=(MFace*)isec.face; /* create MDefBoundIsect */ isect= BLI_memarena_alloc(mdb->memarena, sizeof(*isect)); @@ -1790,11 +1767,6 @@ static void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, progress_bar(0, "Setting up mesh deform system"); -#if 0 - /* create ray tree */ - meshdeform_ray_tree_create(mdb); -#endif - totinside= 0; for(a=0; a<mdb->totvert; a++) { copy_v3_v3(vec, mdb->vertexcos[a]); @@ -1817,11 +1789,6 @@ static void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd, for(x=0; x<mdb->size; x++) meshdeform_add_intersections(mdb, x, y, z); -#if 0 - /* free ray tree */ - meshdeform_ray_tree_free(mdb); -#endif - /* compute exterior and interior tags */ meshdeform_bind_floodfill(mdb); diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h index dc07822bde2..10c1bd84262 100644 --- a/source/blender/editors/curve/curve_intern.h +++ b/source/blender/editors/curve/curve_intern.h @@ -66,6 +66,9 @@ void FONT_OT_change_spacing(struct wmOperatorType *ot); void FONT_OT_open(struct wmOperatorType *ot); void FONT_OT_unlink(struct wmOperatorType *ot); +void FONT_OT_textbox_add(struct wmOperatorType *ot); +void FONT_OT_textbox_remove(struct wmOperatorType *ot); + /* editcurve.c */ void CURVE_OT_hide(struct wmOperatorType *ot); void CURVE_OT_reveal(struct wmOperatorType *ot); diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 7586023d012..026a10c013c 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -81,6 +81,9 @@ void ED_operatortypes_curve(void) WM_operatortype_append(FONT_OT_open); WM_operatortype_append(FONT_OT_unlink); + + WM_operatortype_append(FONT_OT_textbox_add); + WM_operatortype_append(FONT_OT_textbox_remove); WM_operatortype_append(CURVE_OT_hide); WM_operatortype_append(CURVE_OT_reveal); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 7e8154f9381..dad111432de 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5256,54 +5256,62 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname) return nu; } -static int curve_prim_add(bContext *C, wmOperator *op, int type){ +static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) { Object *obedit= CTX_data_edit_object(C); ListBase *editnurb; Nurb *nu; - int newob= 0;//, type= RNA_enum_get(op->ptr, "type"); + int newob= 0; int enter_editmode; unsigned int layer; float loc[3], rot[3]; float mat[4][4]; - - //object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called + if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer)) return OPERATOR_CANCELLED; - - if(obedit==NULL || obedit->type!=OB_CURVE) { - Curve *cu; - obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); - newob = 1; - - cu= (Curve*)obedit->data; - cu->flag |= CU_DEFORM_FILL; - if(type & CU_PRIM_PATH) - cu->flag |= CU_PATH|CU_3D; - } - else if(obedit==NULL || obedit->type!=OB_SURF) { - obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); - newob = 1; + if (!isSurf) { /* adding curve */ + if(obedit==NULL || obedit->type!=OB_CURVE) { + Curve *cu; + obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); + newob = 1; + + cu= (Curve*)obedit->data; + cu->flag |= CU_DEFORM_FILL; + if(type & CU_PRIM_PATH) + cu->flag |= CU_PATH|CU_3D; + } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); + } else { /* adding surface */ + if(obedit==NULL || obedit->type!=OB_SURF) { + obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); + newob = 1; + } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); } - else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - - + ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); - + nu= add_nurbs_primitive(C, mat, type, newob); editnurb= curve_get_editcurve(obedit); BLI_addtail(editnurb, nu); - + /* userdef */ if (newob && !enter_editmode) { ED_object_exit_editmode(C, EM_FREEDATA); } - + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); - + return OPERATOR_FINISHED; } + +static int curve_prim_add(bContext *C, wmOperator *op, int type) { + return curvesurf_prim_add(C, op, type, 0); +} + +static int surf_prim_add(bContext *C, wmOperator *op, int type) { + return curvesurf_prim_add(C, op, type, 1); +} + /* ******************** Curves ******************* */ static int add_primitive_bezier_exec(bContext *C, wmOperator *op) @@ -5424,7 +5432,7 @@ void CURVE_OT_primitive_nurbs_path_add(wmOperatorType *ot) /* **************** NURBS surfaces ********************** */ static int add_primitive_nurbs_surface_curve_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_PRIM_CURVE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_CURVE|CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_curve_add(wmOperatorType *ot) @@ -5447,7 +5455,7 @@ void SURFACE_OT_primitive_nurbs_surface_curve_add(wmOperatorType *ot) static int add_primitive_nurbs_surface_circle_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_PRIM_CIRCLE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_CIRCLE|CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_circle_add(wmOperatorType *ot) @@ -5470,7 +5478,7 @@ void SURFACE_OT_primitive_nurbs_surface_circle_add(wmOperatorType *ot) static int add_primitive_nurbs_surface_surface_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_PRIM_PATCH|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_PATCH|CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_surface_add(wmOperatorType *ot) @@ -5493,7 +5501,7 @@ void SURFACE_OT_primitive_nurbs_surface_surface_add(wmOperatorType *ot) static int add_primitive_nurbs_surface_tube_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_PRIM_TUBE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_TUBE|CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_tube_add(wmOperatorType *ot) @@ -5516,7 +5524,7 @@ void SURFACE_OT_primitive_nurbs_surface_tube_add(wmOperatorType *ot) static int add_primitive_nurbs_surface_sphere_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_PRIM_SPHERE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_SPHERE|CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_sphere_add(wmOperatorType *ot) @@ -5539,7 +5547,7 @@ void SURFACE_OT_primitive_nurbs_surface_sphere_add(wmOperatorType *ot) static int add_primitive_nurbs_surface_donut_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_PRIM_DONUT|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_DONUT|CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_donut_add(wmOperatorType *ot) diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 46970a401a8..3a5f185c550 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1363,6 +1363,99 @@ void FONT_OT_text_insert(wmOperatorType *ot) RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position."); } + +/*********************** textbox add operator *************************/ +static int textbox_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + + if (!ED_operator_object_active_editable(C) ) return 0; + if (ob->type != OB_FONT) return 0; + + return 1; +} + +static int textbox_add_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_active_object(C); + Curve *cu= obedit->data; + int i; + + if (cu->totbox < 256) { + for (i = cu->totbox; i>cu->actbox; i--) cu->tb[i]= cu->tb[i-1]; + cu->tb[cu->actbox]= cu->tb[cu->actbox-1]; + cu->actbox++; + cu->totbox++; + } + + WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + return OPERATOR_FINISHED; +} + +void FONT_OT_textbox_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Textbox"; + ot->description= "Add a new text box"; + ot->idname= "FONT_OT_textbox_add"; + + /* api callbacks */ + ot->exec= textbox_add_exec; + ot->poll= textbox_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + +} + + + +/*********************** textbox remove operator *************************/ + + + +static int textbox_remove_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_active_object(C); + Curve *cu= obedit->data; + int i; + int index = RNA_int_get(op->ptr, "index"); + + + if (cu->totbox > 1) { + for (i = index; i < cu->totbox; i++) cu->tb[i]= cu->tb[i+1]; + cu->totbox--; + if (cu->actbox >= index) + cu->actbox--; + } + + WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + + return OPERATOR_FINISHED; +} + +void FONT_OT_textbox_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Textbox"; + ot->description= "Remove the textbox"; + ot->idname= "FONT_OT_textbox_remove"; + + /* api callbacks */ + ot->exec= textbox_remove_exec; + ot->poll= textbox_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box.", 0, INT_MAX); + + +} + + + /***************** editmode enter/exit ********************/ void make_editText(Object *obedit) diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index e06722c1af1..b52297a319c 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1481,6 +1481,7 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) /* moving mouse - assumed that mouse button is down if in painting status */ case MOUSEMOVE: + case INBETWEEN_MOUSEMOVE: /* check if we're currently painting */ if (p->status == GP_STATUS_PAINTING) { /* handle drawing event */ diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 4a4c546ec92..3478447b058 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -55,6 +55,7 @@ void ED_region_set(const struct bContext *C, struct ARegion *ar); void ED_region_init(struct bContext *C, struct ARegion *ar); void ED_region_tag_redraw(struct ARegion *ar); void ED_region_tag_redraw_partial(struct ARegion *ar, struct rcti *rct); +void ED_region_tag_redraw_overlay(struct ARegion *ar); void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *ar); void ED_region_panels(const struct bContext *C, struct ARegion *ar, int vertical, char *context, int contextnr); void ED_region_header_init(struct ARegion *ar); @@ -97,8 +98,8 @@ void ED_screen_set_scene(struct bContext *C, struct Scene *scene); void ED_screen_delete_scene(struct bContext *C, struct Scene *scene); void ED_screen_set_subwinactive(struct wmWindow *win, struct wmEvent *event); void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); -void ED_screen_animation_timer(struct bContext *C, int redraws, int sync, int enable); -void ED_screen_animation_timer_update(struct bScreen *screen, int redraws); +void ED_screen_animation_timer(struct bContext *C, int redraws, int refresh, int sync, int enable); +void ED_screen_animation_timer_update(struct bScreen *screen, int redraws, int refresh); int ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type); void ED_screen_full_prevspace(struct bContext *C, ScrArea *sa); void ED_screen_full_restore(struct bContext *C, ScrArea *sa); diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index 03ea9a8f976..c55dafa6f51 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -35,6 +35,7 @@ typedef struct ScreenAnimData { ARegion *ar; /* do not read from this, only for comparing if region exists */ short redraws; + short refresh; short flag; /* flags for playback */ int sfra; /* frame that playback was started from */ } ScreenAnimData; diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 4bc5030094e..5ac70d8f54c 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -186,7 +186,7 @@ static void draw_triangulated(short mcords[][2], short tot) } /* do the fill */ - filldisplist(&lb, &lb); + filldisplist(&lb, &lb, 0); /* do the draw */ dl= lb.first; /* filldisplist adds in head of list */ diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index e29c23b1f4d..ee0fd2b47e9 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -490,74 +490,6 @@ void OBJECT_OT_camera_add(wmOperatorType *ot) /* ***************** add primitives *************** */ -static EnumPropertyItem prop_surface_types[]= { - {CU_PRIM_CURVE|CU_NURBS, "NURBS_CURVE", ICON_SURFACE_NCURVE, "NURBS Curve", ""}, - {CU_PRIM_CIRCLE|CU_NURBS, "NURBS_CIRCLE", ICON_SURFACE_NCIRCLE, "NURBS Circle", ""}, - {CU_PRIM_PATCH|CU_NURBS, "NURBS_SURFACE", ICON_SURFACE_NSURFACE, "NURBS Surface", ""}, - {CU_PRIM_TUBE|CU_NURBS, "NURBS_TUBE", ICON_SURFACE_NTUBE, "NURBS Tube", ""}, - {CU_PRIM_SPHERE|CU_NURBS, "NURBS_SPHERE", ICON_SURFACE_NSPHERE, "NURBS Sphere", ""}, - {CU_PRIM_DONUT|CU_NURBS, "NURBS_DONUT", ICON_SURFACE_NDONUT, "NURBS Donut", ""}, - {0, NULL, 0, NULL, NULL} -}; - -static int object_add_surface_exec(bContext *C, wmOperator *op) -{ - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb; - Nurb *nu; - int newob= 0; - int enter_editmode; - unsigned int layer; - float loc[3], rot[3]; - float mat[4][4]; - - object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called - - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer)) - return OPERATOR_CANCELLED; - - if(obedit==NULL || obedit->type!=OB_SURF) { - obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); - newob = 1; - } - else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - - ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); - - nu= add_nurbs_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob); - editnurb= curve_get_editcurve(obedit); - BLI_addtail(editnurb, nu); - - /* userdef */ - if (newob && !enter_editmode) { - ED_object_exit_editmode(C, EM_FREEDATA); - } - - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); - - return OPERATOR_FINISHED; -} - -void OBJECT_OT_surface_add(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Add Surface"; - ot->description = "Add a surface object to the scene"; - ot->idname= "OBJECT_OT_surface_add"; - - /* api callbacks */ - ot->invoke= WM_menu_invoke; - ot->exec= object_add_surface_exec; - - ot->poll= ED_operator_scene_editable; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - ot->prop= RNA_def_enum(ot->srna, "type", prop_surface_types, 0, "Primitive", ""); - ED_object_add_generic_props(ot, TRUE); -} - static EnumPropertyItem prop_metaball_types[]= { {MB_BALL, "MBALL_BALL", ICON_META_BALL, "Meta Ball", ""}, {MB_TUBE, "MBALL_TUBE", ICON_META_TUBE, "Meta Tube", ""}, diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index d8ca65fa8c9..059805fdf2d 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -69,7 +69,9 @@ static int particle_system_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; object_add_particle_system(scene, ob, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; } @@ -107,7 +109,8 @@ static int particle_system_remove_exec(bContext *C, wmOperator *op) if(scene->basact && scene->basact->object==ob) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; } @@ -166,7 +169,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *op) DAG_scene_sort(scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); return OPERATOR_FINISHED; } @@ -214,7 +217,7 @@ static int new_particle_target_exec(bContext *C, wmOperator *op) DAG_scene_sort(scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); return OPERATOR_FINISHED; } @@ -262,7 +265,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *op) DAG_scene_sort(scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); return OPERATOR_FINISHED; } @@ -300,7 +303,7 @@ static int target_move_up_exec(bContext *C, wmOperator *op) BLI_insertlink(&psys->targets, pt->prev->prev, pt); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); break; } } @@ -338,7 +341,7 @@ static int target_move_down_exec(bContext *C, wmOperator *op) BLI_insertlink(&psys->targets, pt->next, pt); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); break; } } @@ -376,7 +379,7 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *op) BLI_remlink(&part->dupliweights, dw); BLI_insertlink(&part->dupliweights, dw->prev->prev, dw); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); break; } } @@ -415,7 +418,7 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *op) dw->flag |= PART_DUPLIW_CURRENT; BLI_addhead(&part->dupliweights, dw); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); break; } } @@ -461,7 +464,7 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *op) if(dw) dw->flag |= PART_DUPLIW_CURRENT; - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); return OPERATOR_FINISHED; } @@ -498,7 +501,7 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *op) BLI_remlink(&part->dupliweights, dw); BLI_insertlink(&part->dupliweights, dw->next, dw); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); break; } } @@ -590,7 +593,7 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op) disconnect_hair(scene, ob, psys); } - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); return OPERATOR_FINISHED; } @@ -729,7 +732,7 @@ static int connect_hair_exec(bContext *C, wmOperator *op) connect_hair(scene, ob, psys); } - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 5ebbb00939e..8e53e3c6f50 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -115,6 +115,7 @@ static int ptcache_bake_all_exec(bContext *C, wmOperator *op) BKE_ptcache_make_cache(&baker); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, NULL); return OPERATOR_FINISHED; } @@ -133,6 +134,8 @@ static int ptcache_free_bake_all_exec(bContext *C, wmOperator *op) } BLI_freelistN(&pidlist); + + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, base->object); } WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); @@ -211,6 +214,7 @@ static int ptcache_bake_exec(bContext *C, wmOperator *op) BLI_freelistN(&pidlist); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; } @@ -218,6 +222,7 @@ static int ptcache_free_bake_exec(bContext *C, wmOperator *op) { PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache); PointCache *cache= ptr.data; + Object *ob= ptr.id.data; if(cache->edit) { if(!cache->edit->edited || 1) {// XXX okee("Lose changes done in particle mode?")) { @@ -228,6 +233,8 @@ static int ptcache_free_bake_exec(bContext *C, wmOperator *op) } else cache->flag &= ~PTCACHE_BAKED; + + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; } @@ -235,8 +242,11 @@ static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *op) { PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache); PointCache *cache= ptr.data; + Object *ob= ptr.id.data; cache->flag |= PTCACHE_BAKED; + + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; } @@ -303,6 +313,7 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *op) BLI_freelistN(&pidlist); WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; } @@ -331,6 +342,8 @@ static int ptcache_remove_exec(bContext *C, wmOperator *op) } BLI_freelistN(&pidlist); + + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 268acba1db7..48ad3bbcc94 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -221,7 +221,7 @@ void screen_set_image_output(bContext *C, int mx, int my) sa= CTX_wm_area(C); } else if(scene->r.displaymode==R_OUTPUT_SCREEN) { - if (CTX_wm_area(C)->spacetype == SPACE_IMAGE) + if (CTX_wm_area(C) && CTX_wm_area(C)->spacetype == SPACE_IMAGE) area_was_image = 1; /* this function returns with changed context */ diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index d9b22553c7a..7cc074a74fd 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -60,6 +60,7 @@ #include "ED_screen.h" #include "ED_view3d.h" +#include "ED_image.h" #include "RE_pipeline.h" #include "IMB_imbuf_types.h" @@ -304,6 +305,10 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) int ok= 0; int view_context = (oglrender->v3d != NULL); + /* update animated image textures for gpu, etc, + * call before scene_update_for_newframe so modifiers with textuers dont lag 1 frame */ + ED_image_update_frame(C); + /* go to next frame */ while(CFRA<oglrender->nfra) { unsigned int lay= screen_opengl_layers(oglrender); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 758a2b1d8ef..65b2923d884 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -372,6 +372,12 @@ void ED_region_tag_redraw(ARegion *ar) } } +void ED_region_tag_redraw_overlay(ARegion *ar) +{ + if(ar) + ar->do_draw_overlay= RGN_DRAW; +} + void ED_region_tag_redraw_partial(ARegion *ar, rcti *rct) { if(ar) { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 4a0a79b2163..1bd1fef4673 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1651,7 +1651,7 @@ void ED_refresh_viewport_fps(bContext *C) /* redraws: uses defines from stime->redraws * enable: 1 - forward on, -1 - backwards on, 0 - off */ -void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable) +void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync, int enable) { bScreen *screen= CTX_wm_screen(C); wmWindowManager *wm= CTX_wm_manager(C); @@ -1669,6 +1669,7 @@ void ED_screen_animation_timer(bContext *C, int redraws, int sync, int enable) sad->ar= CTX_wm_region(C); sad->sfra = scene->r.cfra; sad->redraws= redraws; + sad->refresh= refresh; sad->flag |= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0; sad->flag |= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0; screen->animtimer->customdata= sad; @@ -1702,13 +1703,14 @@ static ARegion *time_top_left_3dwindow(bScreen *screen) return aret; } -void ED_screen_animation_timer_update(bScreen *screen, int redraws) +void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) { if(screen && screen->animtimer) { wmTimer *wt= screen->animtimer; ScreenAnimData *sad= wt->customdata; sad->redraws= redraws; + sad->refresh= refresh; sad->ar= NULL; if(redraws & TIME_REGION) sad->ar= time_top_left_3dwindow(screen); @@ -1735,6 +1737,10 @@ void ED_update_for_newframe(const bContext *C, int mute) //extern void audiostream_scrub(unsigned int frame); /* seqaudio.c */ + /* update animated image textures for gpu, etc, + * call before scene_update_for_newframe so modifiers with textuers dont lag 1 frame */ + ED_image_update_frame(C); + /* this function applies the changes too */ /* XXX future: do all windows */ scene_update_for_newframe(scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ @@ -1752,9 +1758,6 @@ void ED_update_for_newframe(const bContext *C, int mute) if(scene->use_nodes && scene->nodetree) ntreeCompositTagAnimated(scene->nodetree); - /* update animated image textures for gpu, etc */ - ED_image_update_frame(C); - /* update animated texture nodes */ { Tex *tex; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4d644cecf66..515b06feba1 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2359,6 +2359,18 @@ void SCREEN_OT_header_toolbox(wmOperatorType *ot) /* ****************** anim player, with timer ***************** */ +static int match_area_with_refresh(int spacetype, int refresh) +{ + switch (spacetype) { + case SPACE_TIME: + if (refresh & SPACE_TIME) + return 1; + break; + } + + return 0; +} + static int match_region_with_redraws(int spacetype, int regiontype, int redraws) { if(regiontype==RGN_TYPE_WINDOW) { @@ -2505,6 +2517,9 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) if(match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) ED_region_tag_redraw(ar); } + + if (match_area_with_refresh(sa->spacetype, sad->refresh)) + ED_area_tag_refresh(sa); } /* update frame rate info too @@ -2548,11 +2563,12 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) if(screen->animtimer) { /* stop playback now */ - ED_screen_animation_timer(C, 0, 0, 0); + ED_screen_animation_timer(C, 0, 0, 0, 0); sound_stop_scene(scene); } else { ScrArea *sa= CTX_wm_area(C); + int refresh= SPACE_TIME; if(mode == 1) // XXX only play audio forwards!? sound_play_scene(scene); @@ -2561,10 +2577,10 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) if ((sa) && (sa->spacetype == SPACE_TIME)) { SpaceTime *stime= (SpaceTime *)sa->spacedata.first; - ED_screen_animation_timer(C, stime->redraws, sync, mode); + ED_screen_animation_timer(C, stime->redraws, refresh, sync, mode); /* update region if TIME_REGION was set, to leftmost 3d window */ - ED_screen_animation_timer_update(screen, stime->redraws); + ED_screen_animation_timer_update(screen, stime->redraws, refresh); } else { int redraws = TIME_REGION|TIME_ALL_3D_WIN; @@ -2574,7 +2590,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) redraws |= TIME_SEQ; } - ED_screen_animation_timer(C, redraws, sync, mode); + ED_screen_animation_timer(C, redraws, refresh, sync, mode); if(screen->animtimer) { wmTimer *wt= screen->animtimer; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 64f00caf479..6269b9c5e09 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4872,6 +4872,7 @@ static int paint_modal(bContext *C, wmOperator *op, wmEvent *event) paint_exit(C, op); return OPERATOR_FINISHED; case MOUSEMOVE: + case INBETWEEN_MOUSEMOVE: paint_apply_event(C, op, event); break; case TIMER: diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 03454a305ba..441464c5743 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -275,7 +275,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) MEM_freeN(stroke); return OPERATOR_FINISHED; } - else if(first || event->type == MOUSEMOVE || (event->type == TIMER && (event->customdata == stroke->timer))) { + else if(first || ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) || (event->type == TIMER && (event->customdata == stroke->timer))) { if(stroke->stroke_started) { if(paint_smooth_stroke(stroke, mouse, event)) { if(paint_space_stroke_enabled(stroke->brush)) { diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index cf760f345b5..53e07a50020 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -91,6 +91,11 @@ /* Number of vertices to average in order to determine the flatten distance */ #define FLATTEN_SAMPLE_SIZE 10 +/* ==== FORWARD DEFINITIONS ===== + * + */ +static void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]); + /* ===== STRUCTS ===== * */ @@ -275,6 +280,9 @@ typedef struct SculptUndoNode { /* layer brush */ float *layer_disp; + + /* shape keys */ + char *shapeName[32]; /* keep size in sync with keyblock dna */ } SculptUndoNode; static void update_cb(PBVHNode *node, void *data) @@ -326,16 +334,53 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) continue; if(unode->maxvert) { + char *shapeName= (char*)unode->shapeName; + /* regular mesh restore */ if(ss->totvert != unode->maxvert) continue; + if (ss->kb && strcmp(ss->kb->name, shapeName)) { + /* shape key has been changed before calling undo operator */ + + Key *key= ob_get_key(ob); + KeyBlock *kb= key_get_named_keyblock(key, shapeName); + + if (kb) { + ob->shapenr= BLI_findindex(&key->block, kb) + 1; + ob->shapeflag|= OB_SHAPE_LOCK; + + sculpt_update_mesh_elements(scene, ob, 0); + WM_event_add_notifier(C, NC_OBJECT|ND_DATA, ob); + } else { + /* key has been removed -- skip this undo node */ + continue; + } + } + index= unode->index; mvert= ss->mvert; - for(i=0; i<unode->totvert; i++) { - swap_v3_v3(mvert[index[i]].co, unode->co[i]); - mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; + if (ss->kb) { + float (*vertCos)[3]; + vertCos= key_to_vertcos(ob, ss->kb); + + for(i=0; i<unode->totvert; i++) + swap_v3_v3(vertCos[index[i]], unode->co[i]); + + /* propagate new coords to keyblock */ + sculpt_vertcos_to_key(ob, ss->kb, vertCos); + + /* pbvh uses it's own mvert array, so coords should be */ + /* propagated to pbvh here */ + BLI_pbvh_apply_vertCos(ss->pbvh, vertCos); + + MEM_freeN(vertCos); + } else { + for(i=0; i<unode->totvert; i++) { + swap_v3_v3(mvert[index[i]].co, unode->co[i]); + mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; + } } } else if(unode->maxgrid && dm->getGridData) { @@ -365,9 +410,6 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) } if(update) { - if(ss->kb) sculpt_mesh_to_key(ss->ob, ss->kb); - if(ss->refkb) sculpt_key_to_mesh(ss->refkb, ob); - /* we update all nodes still, should be more clever, but also needs to work correct when exiting/entering sculpt mode and the nodes get recreated, though in that case it could do all */ @@ -377,7 +419,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) if((mmd=sculpt_multires_active(scene, ob))) multires_mark_as_modified(ob); - if(sculpt_modifiers_active(scene, ob)) + if(ss->modifiers_active || ((Mesh*)ob->data)->id.us > 1) DAG_id_flush_update(&ob->id, OB_RECALC_DATA); } } @@ -475,7 +517,11 @@ static SculptUndoNode *sculpt_undo_push_node(SculptSession *ss, PBVHNode *node) if(unode->grids) memcpy(unode->grids, grids, sizeof(int)*totgrid); - + + /* store active shape key */ + if(ss->kb) BLI_strncpy((char*)unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); + else unode->shapeName[0]= '\0'; + return unode; } @@ -1367,6 +1413,68 @@ static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, PBVHNode **node } } +static void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) +{ + Mesh *me= (Mesh*)ob->data; + float (*ofs)[3]= NULL; + int a, is_basis= 0; + KeyBlock *currkey; + + /* for relative keys editing of base should update other keys */ + if (me->key->type == KEY_RELATIVE) + for (currkey = me->key->block.first; currkey; currkey= currkey->next) + if(ob->shapenr-1 == currkey->relative) { + is_basis= 1; + break; + } + + if (is_basis) { + ofs= key_to_vertcos(ob, kb); + + /* calculate key coord offsets (from previous location) */ + for (a= 0; a < me->totvert; a++) { + VECSUB(ofs[a], vertCos[a], ofs[a]); + } + + /* apply offsets on other keys */ + currkey = me->key->block.first; + while (currkey) { + int apply_offset = ((currkey != kb) && (ob->shapenr-1 == currkey->relative)); + + if (apply_offset) + offset_to_key(ob, currkey, ofs); + + currkey= currkey->next; + } + + MEM_freeN(ofs); + } + + /* modifying of basis key should update mesh */ + if (kb == me->key->refkey) { + MVert *mvert= me->mvert; + + for (a= 0; a < me->totvert; a++, mvert++) + VECCOPY(mvert->co, vertCos[a]); + + mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); + } + + /* apply new coords on active key block */ + vertcos_to_key(ob, kb, vertCos); +} + +/* copy the modified vertices from bvh to the active key */ +static void sculpt_update_keyblock(SculptSession *ss) +{ + float (*vertCos)[3]= BLI_pbvh_get_vertCos(ss->pbvh); + + if (vertCos) { + sculpt_vertcos_to_key(ss->ob, ss->kb, vertCos); + MEM_freeN(vertCos); + } +} + static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) { SculptSearchSphereData data; @@ -1424,13 +1532,15 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) do_flatten_clay_brush(sd, ss, nodes, totnode, 1); break; } - - /* copy the modified vertices from mesh to the active key */ - if(ss->kb) mesh_to_key(ss->ob->data, ss->kb); - + + /* optimization: we could avoid copying new coords to keyblock at each */ + /* stroke step if there are no modifiers due to pbvh is used for displaying */ + /* so to increase speed we'll copy new coords to keyblock when stroke is done */ + if(ss->kb && ss->modifiers_active) sculpt_update_keyblock(ss); + if(nodes) MEM_freeN(nodes); - } + } } /* Flip all the editdata across the axis/axes specified by symm. Used to @@ -1506,40 +1616,18 @@ struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) return NULL; } -void sculpt_key_to_mesh(KeyBlock *kb, Object *ob) -{ - Mesh *me= ob->data; - - key_to_mesh(kb, me); - mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); -} - -void sculpt_mesh_to_key(Object *ob, KeyBlock *kb) -{ - Mesh *me= ob->data; - - mesh_to_key(me, kb); -} - void sculpt_update_mesh_elements(Scene *scene, Object *ob, int need_fmap) { - DerivedMesh *dm = mesh_get_derived_final(scene, ob, 0); + DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); SculptSession *ss = ob->sculpt; MultiresModifierData *mmd= sculpt_multires_active(scene, ob); ss->ob= ob; - if((ob->shapeflag & OB_SHAPE_LOCK) && !mmd) { - ss->kb= ob_get_keyblock(ob); - ss->refkb= ob_get_reference_keyblock(ob); - } - else { - ss->kb= NULL; - ss->refkb= NULL; - } + ss->modifiers_active= sculpt_modifiers_active(scene, ob); - /* need to make PBVH with shape key coordinates */ - if(ss->kb) sculpt_key_to_mesh(ss->kb, ss->ob); + if((ob->shapeflag & OB_SHAPE_LOCK) && !mmd) ss->kb= ob_get_keyblock(ob); + else ss->kb= NULL; if(mmd) { ss->multires = mmd; @@ -1561,6 +1649,17 @@ void sculpt_update_mesh_elements(Scene *scene, Object *ob, int need_fmap) ss->pbvh = dm->getPBVH(ob, dm); ss->fmap = (need_fmap && dm->getFaceMap)? dm->getFaceMap(ob, dm): NULL; + + /* if pbvh is deformed, key block is already applied to it */ + if (ss->kb && !BLI_pbvh_isDeformed(ss->pbvh)) { + float (*vertCos)[3]= key_to_vertcos(ob, ss->kb); + + if (vertCos) { + /* apply shape keys coordinates to PBVH */ + BLI_pbvh_apply_vertCos(ss->pbvh, vertCos); + MEM_freeN(vertCos); + } + } } static int sculpt_mode_poll(bContext *C) @@ -1815,9 +1914,7 @@ static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, struct P static void sculpt_stroke_modifiers_check(bContext *C, SculptSession *ss) { - Scene *scene= CTX_data_scene(C); - - if(sculpt_modifiers_active(scene, ss->ob)) { + if(ss->modifiers_active) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Brush *brush = paint_brush(&sd->paint); @@ -1995,7 +2092,6 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) static void sculpt_flush_update(bContext *C) { - Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; ARegion *ar = CTX_wm_region(C); @@ -2005,7 +2101,7 @@ static void sculpt_flush_update(bContext *C) if(mmd) multires_mark_as_modified(ob); - if(sculpt_modifiers_active(scene, ob)) { + if(ss->modifiers_active) { DAG_id_flush_update(&ob->id, OB_RECALC_DATA); ED_region_tag_redraw(ar); } @@ -2089,10 +2185,13 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *stroke) BLI_pbvh_update(ss->pbvh, PBVH_UpdateOriginalBB, NULL); - if(ss->refkb) sculpt_key_to_mesh(ss->refkb, ob); + /* optimization: if there is locked key and active modifiers present in */ + /* the stack, keyblock is updating at each step. otherwise we could update */ + /* keyblock only when stroke is finished */ + if(ss->kb && !ss->modifiers_active) sculpt_update_keyblock(ss); ss->partial_redraw = 0; - + /* try to avoid calling this, only for e.g. linked duplicates now */ if(((Mesh*)ob->data)->id.us > 1) DAG_id_flush_update(&ob->id, OB_RECALC_DATA); @@ -2225,9 +2324,6 @@ static void sculpt_init_session(Scene *scene, Object *ob) ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); sculpt_update_mesh_elements(scene, ob, 0); - - if(ob->sculpt->refkb) - sculpt_key_to_mesh(ob->sculpt->refkb, ob); } static int sculpt_toggle_mode(bContext *C, wmOperator *op) diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index d8043d2c988..c7c6833b695 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -58,8 +58,6 @@ void sculpt(Sculpt *sd); int sculpt_poll(struct bContext *C); void sculpt_update_mesh_elements(struct Scene *scene, struct Object *ob, int need_fmap); -void sculpt_key_to_mesh(struct KeyBlock *kb, struct Object *ob); -void sculpt_mesh_to_key(struct Object *ob, struct KeyBlock *kb); /* Stroke */ struct SculptStroke *sculpt_stroke_new(const int max); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 36aecd02138..96cf79d880f 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -30,6 +30,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_userdef_types.h" #include "BKE_context.h" @@ -129,6 +130,10 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_string_set(op->ptr, "filepath", str); MEM_freeN(str); + if(RNA_struct_find_property(op->ptr, "relative_path")) + if(!RNA_property_is_set(op->ptr, "relative_path")) + RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; @@ -147,6 +152,6 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) ot->cancel= file_browse_cancel; /* properties */ - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, 0); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH); } diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 9028e5f15c6..7c2a2f436cc 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -545,7 +545,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot) int file_exec(bContext *C, wmOperator *exec_op) { SpaceFile *sfile= CTX_wm_space_file(C); - char name[FILE_MAX]; + char filepath[FILE_MAX]; if(sfile->op) { wmOperator *op= sfile->op; @@ -567,16 +567,23 @@ int file_exec(bContext *C, wmOperator *exec_op) } sfile->op = NULL; - RNA_string_set(op->ptr, "filename", sfile->params->file); - BLI_strncpy(name, sfile->params->dir, sizeof(name)); - RNA_string_set(op->ptr, "directory", name); - strcat(name, sfile->params->file); // XXX unsafe - if(RNA_struct_find_property(op->ptr, "relative_path")) - if(RNA_boolean_get(op->ptr, "relative_path")) - BLI_path_rel(name, G.sce); + BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file); + if(RNA_struct_find_property(op->ptr, "relative_path")) { + if(RNA_boolean_get(op->ptr, "relative_path")) { + BLI_path_rel(filepath, G.sce); + } + } - RNA_string_set(op->ptr, "filepath", name); + if(RNA_struct_find_property(op->ptr, "filename")) { + RNA_string_set(op->ptr, "filename", sfile->params->file); + } + if(RNA_struct_find_property(op->ptr, "directory")) { + RNA_string_set(op->ptr, "directory", sfile->params->dir); + } + if(RNA_struct_find_property(op->ptr, "filepath")) { + RNA_string_set(op->ptr, "filepath", filepath); + } /* some ops have multiple files to select */ { @@ -612,8 +619,8 @@ int file_exec(bContext *C, wmOperator *exec_op) folderlist_free(sfile->folders_next); fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1); - BLI_make_file_string(G.sce, name, BLI_gethome(), ".Bfs"); - fsmenu_write_file(fsmenu_get(), name); + BLI_make_file_string(G.sce, filepath, BLI_gethome(), ".Bfs"); + fsmenu_write_file(fsmenu_get(), filepath); WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC); ED_fileselect_clear(C, sfile); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index c4265c6e011..f84fd6fc430 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -780,7 +780,6 @@ static int replace_exec(bContext *C, wmOperator *op) static int replace_invoke(bContext *C, wmOperator *op, wmEvent *event) { SpaceImage *sima= CTX_wm_space_image(C); - char *path= (sima->image)? sima->image->name: U.textudir; if(!sima->image) return OPERATOR_CANCELLED; @@ -788,7 +787,10 @@ static int replace_invoke(bContext *C, wmOperator *op, wmEvent *event) if(RNA_property_is_set(op->ptr, "filepath")) return replace_exec(C, op); - image_filesel(C, op, path); + if(!RNA_property_is_set(op->ptr, "relative_path")) + RNA_boolean_set(op->ptr, "relative_path", (strncmp(sima->image->name, "//", 2))==0); + + image_filesel(C, op, sima->image->name); return OPERATOR_RUNNING_MODAL; } @@ -808,7 +810,7 @@ void IMAGE_OT_replace(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, 0); //XXX TODO, relative_path + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH); } /******************** save image as operator ********************/ diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 104bcc6286d..409277cb66e 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3172,9 +3172,9 @@ static int is_sensor_linked(uiBlock *block, bSensor *sens) /* Sensors code */ -static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr) +static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr) { - uiLayout *box, *row; + uiLayout *box, *row, *subrow; box= uiLayoutBox(layout); row= uiLayoutRow(box, 0); @@ -3182,6 +3182,12 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "expanded", UI_ITEM_R_NO_BG, "", 0); uiItemR(row, ptr, "type", 0, "", 0); uiItemR(row, ptr, "name", 0, "", 0); + + subrow= uiLayoutRow(row, 0); + uiLayoutSetActive(subrow, (RNA_boolean_get(logic_ptr, "sensors_show_active_states") + && RNA_boolean_get(ptr, "expanded") || RNA_boolean_get(ptr, "pinned"))); + uiItemR(subrow, ptr, "pinned", UI_ITEM_R_NO_BG, "", 0); + uiItemO(row, "", ICON_X, "LOGIC_OT_sensor_remove"); } @@ -3584,9 +3590,9 @@ void draw_brick_controller(uiLayout *layout, PointerRNA *ptr) } /* Actuator code */ -static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr) +static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr) { - uiLayout *box, *row; + uiLayout *box, *row, *subrow; box= uiLayoutBox(layout); row= uiLayoutRow(box, 0); @@ -3594,6 +3600,12 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "expanded", UI_ITEM_R_NO_BG, "", 0); uiItemR(row, ptr, "type", 0, "", 0); uiItemR(row, ptr, "name", 0, "", 0); + + subrow= uiLayoutRow(row, 0); + uiLayoutSetActive(subrow, (RNA_boolean_get(logic_ptr, "actuators_show_active_states") + && RNA_boolean_get(ptr, "expanded") || RNA_boolean_get(ptr, "pinned"))); + uiItemR(subrow, ptr, "pinned", UI_ITEM_R_NO_BG, "", 0); + uiItemO(row, "", ICON_X, "LOGIC_OT_actuator_remove"); } @@ -4351,7 +4363,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) PointerRNA logic_ptr, settings_ptr; - uiLayout *layout, *row, *split, *subsplit, *box, *col; + uiLayout *layout, *row, *box; uiBlock *block; uiBut *but; char name[32]; @@ -4367,13 +4379,17 @@ static void logic_buttons_new(bContext *C, ARegion *ar) block= uiBeginBlock(C, ar, name, UI_EMBOSS); uiBlockSetHandleFunc(block, do_logic_buts, NULL); - /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that - we can determine which is actually linked/visible */ + /* loop over all objects and set visible/linked flags for the logic bricks */ for(a=0; a<count; a++) { bActuator *act; bSensor *sens; + bController *cont; + int iact; + short flag; + ob= (Object *)idar[a]; + /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that we can determine which is actually linked/visible */ act = ob->actuators.first; while(act) { act->flag &= ~(ACT_LINKED|ACT_VISIBLE); @@ -4385,6 +4401,23 @@ static void logic_buttons_new(bContext *C, ARegion *ar) sens->flag &= ~(SENS_VISIBLE); sens = sens->next; } + + /* mark the linked and visible actuators */ + cont= ob->controllers.first; + while(cont) { + flag = ACT_LINKED; + + /* this controller is visible, mark all its actuator */ + if ((ob->scaflag & OB_ALLSTATE) || (ob->state & cont->state_mask)) + flag |= ACT_VISIBLE; + + for (iact=0; iact<cont->totlinks; iact++) { + act = cont->links[iact]; + if (act) + act->flag |= flag; + } + cont = cont->next; + } } /* ****************** Controllers ****************** */ @@ -4393,7 +4426,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, U.uistyles.first); row = uiLayoutRow(layout, 1); - uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco, 70, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ + uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ uiItemR(row, &logic_ptr, "controllers_show_selected_objects", 0, "Sel", 0); uiItemR(row, &logic_ptr, "controllers_show_active_objects", 0, "Act", 0); @@ -4406,6 +4439,9 @@ static void logic_buttons_new(bContext *C, ARegion *ar) int iact; ob= (Object *)idar[a]; + + /* only draw the controller common header if "visible" */ + if( (ob->scavisflag & OB_VIS_CONT) == 0) continue; /* Drawing the Controller Header common to all Selected Objects */ @@ -4442,7 +4478,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* End of Drawing the Controller Header common to all Selected Objects */ - if (!(ob->scavisflag & OB_VIS_CONT) || !(ob->scaflag & OB_SHOWCONT)) continue; + if ((ob->scaflag & OB_SHOWCONT) == 0) continue; uiItemS(layout); @@ -4452,16 +4488,6 @@ static void logic_buttons_new(bContext *C, ARegion *ar) if (!(ob->scaflag & OB_ALLSTATE) && !(ob->state & cont->state_mask)) continue; - //if (!(cont->state_mask & (1<<stbit))) - // continue; - - /* this controller is visible, mark all its actuator */ - /* XXX: perhaps move this to a preprocessing stage if possible? */ - for (iact=0; iact<cont->totlinks; iact++) { - bActuator *act = cont->links[iact]; - if (act) - act->flag |= ACT_VISIBLE; - } /* use two nested splits to align inlinks/links properly */ split = uiLayoutSplit(layout, 0.05, 0); @@ -4501,7 +4527,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, U.uistyles.first); row = uiLayoutRow(layout, 1); - uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco, 70, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ + uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ uiItemR(row, &logic_ptr, "sensors_show_selected_objects", 0, "Sel", 0); uiItemR(row, &logic_ptr, "sensors_show_active_objects", 0, "Act", 0); @@ -4514,11 +4540,14 @@ static void logic_buttons_new(bContext *C, ARegion *ar) ob= (Object *)idar[a]; + /* only draw the sensor common header if "visible" */ + if((ob->scavisflag & OB_VIS_SENS) == 0) continue; + row = uiLayoutRow(layout, 1); uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors"); uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", 0); - if (!(ob->scavisflag & OB_VIS_SENS) || !(ob->scaflag & OB_SHOWSENS)) continue; + if ((ob->scaflag & OB_SHOWSENS) == 0) continue; uiItemS(layout); @@ -4526,7 +4555,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &ptr); if ((ob->scaflag & OB_ALLSTATE) || - (slogic->scaflag & BUTS_SENS_STATE) || + !(slogic->scaflag & BUTS_SENS_STATE) || (sens->totlinks == 0) || /* always display sensor without links so that is can be edited */ (sens->flag & SENS_PIN && slogic->scaflag & BUTS_SENS_STATE) || /* states can hide some sensors, pinned sensors ignore the visible state */ (is_sensor_linked(block, sens)) @@ -4539,7 +4568,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiLayoutSetContextPointer(col, "sensor", &ptr); /* should make UI template for sensor header.. function will do for now */ - draw_sensor_header(col, &ptr); + draw_sensor_header(col, &ptr, &logic_ptr); /* draw the brick contents */ draw_brick_sensor(col, &ptr, C); @@ -4560,7 +4589,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, U.uistyles.first); row = uiLayoutRow(layout, 1); - uiDefBlockBut(block, sensor_menu, NULL, "Actuators", xco-10, yco, 70, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ + uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ uiItemR(row, &logic_ptr, "actuators_show_selected_objects", 0, "Sel", 0); uiItemR(row, &logic_ptr, "actuators_show_active_objects", 0, "Act", 0); @@ -4573,11 +4602,14 @@ static void logic_buttons_new(bContext *C, ARegion *ar) ob= (Object *)idar[a]; + /* only draw the actuator common header if "visible" */ + if( (ob->scavisflag & OB_VIS_ACT) == 0) continue; + row = uiLayoutRow(layout, 1); uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators"); uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", 0); - if (!(ob->scavisflag & OB_VIS_ACT) || !(ob->scaflag & OB_SHOWACT)) continue; + if ((ob->scaflag & OB_SHOWACT) == 0) continue; uiItemS(layout); @@ -4586,7 +4618,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &ptr); if ((ob->scaflag & OB_ALLSTATE) || - (slogic->scaflag & BUTS_ACT_STATE) || + !(slogic->scaflag & BUTS_ACT_STATE) || !(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */ (act->flag & ACT_VISIBLE) || /* this actuator has visible connection, display it */ (act->flag & ACT_PIN && slogic->scaflag & BUTS_ACT_STATE) /* states can hide some sensors, pinned sensors ignore the visible state */ @@ -4604,7 +4636,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiLayoutSetContextPointer(col, "actuator", &ptr); /* should make UI template for actuator header.. function will do for now */ - draw_actuator_header(col, &ptr); + draw_actuator_header(col, &ptr, &logic_ptr); /* draw the brick contents */ draw_brick_actuator(col, &ptr, C); diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 3c6d7e055ba..c92e7a80b4c 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -1927,7 +1927,8 @@ static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *so /* we search for the object parent */ ob= (Object *)outliner_search_back(soops, te, ID_OB); - if(ob==NULL || ob!=OBACT) return 0; // just paranoia + // note: ob->matbits can be NULL when a local object points to a library mesh. + if(ob==NULL || ob!=OBACT || ob->matbits==NULL) return 0; // just paranoia /* searching in ob mat array? */ tes= te->parent; diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 06c7725984a..1a56cb6d683 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -43,6 +43,7 @@ #include "DNA_scene_types.h" +#include "DNA_userdef_types.h" #include "BKE_context.h" #include "BKE_global.h" @@ -203,7 +204,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); - active_seq_set(scene, seq); + seq_active_set(scene, seq); seq->flag |= SELECT; } @@ -313,6 +314,9 @@ static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, wmEvent return OPERATOR_CANCELLED; } + if(!RNA_property_is_set(op->ptr, "relative_path")) + RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); + sequencer_generic_invoke_xy__internal(C, op, event, 0); return WM_operator_filesel(C, op, event); //return sequencer_add_movie_strip_exec(C, op); @@ -336,7 +340,7 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, 0); //XXX TODO, relative_path + WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES); RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie"); } @@ -355,6 +359,9 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, wmEvent return OPERATOR_CANCELLED; } + if(!RNA_property_is_set(op->ptr, "relative_path")) + RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); + sequencer_generic_invoke_xy__internal(C, op, event, 0); return WM_operator_filesel(C, op, event); //return sequencer_add_sound_strip_exec(C, op); @@ -378,7 +385,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, 0); //XXX TODO, relative_path + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES); RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); } @@ -446,6 +453,9 @@ static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, wmEvent return OPERATOR_CANCELLED; } + if(!RNA_property_is_set(op->ptr, "relative_path")) + RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); + sequencer_generic_invoke_xy__internal(C, op, event, SEQPROP_ENDFRAME); return WM_operator_filesel(C, op, event); //return sequencer_add_image_strip_exec(C, op); @@ -469,7 +479,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, 0); //XXX TODO, relative_path + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME|SEQPROP_FILES); } @@ -572,7 +582,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); - active_seq_set(scene, seq); + seq_active_set(scene, seq); seq->flag |= SELECT; } @@ -593,6 +603,10 @@ static int sequencer_add_effect_strip_invoke(bContext *C, wmOperator *op, wmEven sequencer_generic_invoke_xy__internal(C, op, event, SEQPROP_ENDFRAME); if (RNA_property_is_set(op->ptr, "type") && RNA_enum_get(op->ptr, "type")==SEQ_PLUGIN) { + + if(!RNA_property_is_set(op->ptr, "relative_path")) + RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); + /* only plugins need the file selector */ return WM_operator_filesel(C, op, event); } @@ -617,7 +631,7 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, 0); //XXX TODO, relative_path + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME); RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type"); RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color", "Initialize the strip with this color (only used when type='COLOR')", 0.0f, 1.0f); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 4f8ded4e315..bf7f053ad71 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -900,7 +900,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) Scene *scene= CTX_data_scene(C); SpaceSeq *sseq= CTX_wm_space_seq(C); View2D *v2d= &ar->v2d; - Sequence *last_seq = active_seq_get(scene); + Sequence *last_seq = seq_active_get(scene); int sel = 0, j; float pixelx = (v2d->cur.xmax - v2d->cur.xmin)/(v2d->mask.xmax - v2d->mask.xmin); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index dedde7e10c3..6d225647a52 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -75,10 +75,6 @@ /* own include */ #include "sequencer_intern.h" -/* XXX */ -//static Sequence *_last_seq=0; -//static int _last_seq_init=0; -/* XXX */ static void error(const char *dummy) {} static void waitcursor(int val) {} static void activate_fileselect(int d1, char *d2, char *d3, void *d4) {} @@ -167,7 +163,7 @@ static void change_plugin_seq(Scene *scene, char *str) /* called from fileselect { Editing *ed= seq_give_editing(scene, FALSE); struct SeqEffectHandle sh; - Sequence *last_seq= active_seq_get(scene); + Sequence *last_seq= seq_active_get(scene); if(last_seq && last_seq->type != SEQ_PLUGIN) return; @@ -393,7 +389,7 @@ void deselect_all_seq(Scene *scene) if(ed==NULL) return; SEQP_BEGIN(ed, seq) { - seq->flag &= SEQ_DESEL; + seq->flag &= ~SEQ_ALLSEL; } SEQ_END @@ -406,9 +402,9 @@ void recurs_sel_seq(Sequence *seqm) seq= seqm->seqbase.first; while(seq) { - if(seqm->flag & (SEQ_LEFTSEL+SEQ_RIGHTSEL)) seq->flag &= SEQ_DESEL; + if(seqm->flag & (SEQ_LEFTSEL+SEQ_RIGHTSEL)) seq->flag &= ~SEQ_ALLSEL; else if(seqm->flag & SELECT) seq->flag |= SELECT; - else seq->flag &= SEQ_DESEL; + else seq->flag &= ~SEQ_ALLSEL; if(seq->seqbase.first) recurs_sel_seq(seq); @@ -441,7 +437,7 @@ static void reload_sound_strip(Scene *scene, char *name) Editing *ed; Sequence *seq, *seqact; SpaceFile *sfile; - Sequence *last_seq= active_seq_get(scene); + Sequence *last_seq= seq_active_get(scene); ed= scene->ed; @@ -483,7 +479,7 @@ static void reload_image_strip(Scene *scene, char *name) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq=NULL, *seqact; SpaceFile *sfile=NULL; - Sequence *last_seq= active_seq_get(scene); + Sequence *last_seq= seq_active_get(scene); @@ -519,7 +515,7 @@ static void reload_image_strip(Scene *scene, char *name) void change_sequence(Scene *scene) { Editing *ed= seq_give_editing(scene, FALSE); - Sequence *last_seq= active_seq_get(scene); + Sequence *last_seq= seq_active_get(scene); Scene *sce; short event; @@ -621,7 +617,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen *error_str= NULL; if (!activeseq) - seq2= active_seq_get(scene); + seq2= seq_active_get(scene); for(seq=ed->seqbasep->first; seq; seq=seq->next) { if(seq->flag & SELECT) { @@ -684,7 +680,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen void reassign_inputs_seq_effect(Scene *scene) { Editing *ed= seq_give_editing(scene, FALSE); - Sequence *seq1, *seq2, *seq3, *last_seq = active_seq_get(scene); + Sequence *seq1, *seq2, *seq3, *last_seq = seq_active_get(scene); char *error_msg; if(last_seq==0 || !(last_seq->type & SEQ_EFFECT)) return; @@ -753,7 +749,7 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall) { Sequence *seq, *seqn; - Sequence *last_seq = active_seq_get(scene); + Sequence *last_seq = seq_active_get(scene); seq= lb->first; while(seq) { @@ -763,7 +759,7 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de seq->sound->id.us--; BLI_remlink(lb, seq); - if(seq==last_seq) active_seq_set(scene, NULL); + if(seq==last_seq) seq_active_set(scene, NULL); if(seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); if(seq->ipo) seq->ipo->id.us--; seq_free_sequence(scene, seq); @@ -772,132 +768,6 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de } } -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!!! */ - /* - recurs_dupli_seq(&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; -} - -static Sequence * deep_dupli_seq(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 = deep_dupli_seq(scene, s); - if (n) { - BLI_addtail(&seqn->seqbase, n); - } - } - } - return seqn; -} - - -static void recurs_dupli_seq(Scene *scene, ListBase *old, ListBase *new, int do_context) -{ - Sequence *seq; - Sequence *seqn = 0; - Sequence *last_seq = active_seq_get(scene); - - for(seq= old->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_DESEL; - seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL+SEQ_LOCK); - } - - BLI_addtail(new, seqn); - if(seq->type==SEQ_META) - recurs_dupli_seq(scene, &seq->seqbase,&seqn->seqbase, do_context); - - if(do_context) { - if (seq == last_seq) { - active_seq_set(scene, seqn); - } - } - } - } - } -} static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) { @@ -951,7 +821,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = deep_dupli_seq(scene, seq); + seqn = seq_dupli_recursive(scene, seq, SEQ_DUPE_UNIQUE_NAME); } if (seqn) { @@ -1040,7 +910,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) if (!skip_dup) { /* Duplicate AFTER the first change */ - seqn = deep_dupli_seq(scene, seq); + seqn = seq_dupli_recursive(scene, seq, SEQ_DUPE_UNIQUE_NAME); } if (seqn) { @@ -1190,7 +1060,7 @@ void set_filter_seq(Scene *scene) void seq_remap_paths(Scene *scene) { - Sequence *seq, *last_seq = active_seq_get(scene); + Sequence *seq, *last_seq = seq_active_get(scene); Editing *ed= seq_give_editing(scene, FALSE); char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX]; @@ -1625,11 +1495,11 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) SEQP_BEGIN(ed, seq) { if (cut_side==SEQ_SIDE_LEFT) { if ( seq->startdisp >= cut_frame ) { - seq->flag &= SEQ_DESEL; + seq->flag &= ~SEQ_ALLSEL; } } else { if ( seq->enddisp <= cut_frame ) { - seq->flag &= SEQ_DESEL; + seq->flag &= ~SEQ_ALLSEL; } } } @@ -1691,17 +1561,17 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); - ListBase new= {NULL, NULL}; + ListBase nseqbase= {NULL, NULL}; if(ed==NULL) return OPERATOR_CANCELLED; - recurs_dupli_seq(scene, ed->seqbasep, &new, TRUE); + seqbase_dupli_recursive(scene, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME|SEQ_DUPE_CONTEXT); - if(new.first) { - Sequence * seq= new.first; - /* rely on the new list being added at the end */ - addlisttolist(ed->seqbasep, &new); + if(nseqbase.first) { + Sequence * seq= nseqbase.first; + /* rely on the nseqbase list being added at the end */ + addlisttolist(ed->seqbasep, &nseqbase); for( ; seq; seq= seq->next) seqbase_unique_name_recursive(&ed->seqbase, seq); @@ -1751,7 +1621,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *op) MetaStack *ms; int nothingSelected = TRUE; - seq=active_seq_get(scene); + seq=seq_active_get(scene); if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */ nothingSelected = FALSE; } else { @@ -1918,7 +1788,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); - Sequence *last_seq= active_seq_get(scene); + Sequence *last_seq= seq_active_get(scene); MetaStack *ms; if(last_seq && last_seq->type==SEQ_META && last_seq->flag & SELECT) { @@ -1930,7 +1800,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op) ed->seqbasep= &last_seq->seqbase; - active_seq_set(scene, NULL); + seq_active_set(scene, NULL); } else { @@ -1950,7 +1820,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op) for(seq= ed->seqbasep->first; seq; seq= seq->next) calc_sequence(scene, seq); - active_seq_set(scene, ms->parseq); + seq_active_set(scene, ms->parseq); ms->parseq->flag |= SELECT; recurs_sel_seq(ms->parseq); @@ -2020,7 +1890,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) seqm->strip->len= seqm->len; seqm->strip->us= 1; - active_seq_set(scene, seqm); + seq_active_set(scene, seqm); if( seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene); @@ -2065,7 +1935,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); - Sequence *seq, *last_seq = active_seq_get(scene); /* last_seq checks ed==NULL */ + Sequence *seq, *last_seq = seq_active_get(scene); /* last_seq checks ed==NULL */ if(last_seq==NULL || last_seq->type!=SEQ_META) return OPERATOR_CANCELLED; @@ -2521,7 +2391,7 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); - Sequence *active_seq = active_seq_get(scene); + Sequence *active_seq = seq_active_get(scene); Sequence *seq, *iseq; int side= RNA_enum_get(op->ptr, "side"); @@ -2597,7 +2467,7 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *op) { int retval = OPERATOR_CANCELLED; Scene *scene= CTX_data_scene(C); - Sequence *active_seq = active_seq_get(scene); + Sequence *active_seq = seq_active_get(scene); if(active_seq==NULL) return OPERATOR_CANCELLED; @@ -2670,7 +2540,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - recurs_dupli_seq(scene, ed->seqbasep, &seqbase_clipboard, FALSE); + seqbase_dupli_recursive(scene, &seqbase_clipboard, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME); seqbase_clipboard_frame= scene->r.cfra; /* Need to remove anything that references the current scene */ @@ -2717,23 +2587,23 @@ static int sequencer_paste_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, TRUE); /* create if needed */ - ListBase new = {NULL, NULL}; + ListBase nseqbase = {NULL, NULL}; int ofs; Sequence *iseq; deselect_all_seq(scene); ofs = scene->r.cfra - seqbase_clipboard_frame; - recurs_dupli_seq(scene, &seqbase_clipboard, &new, FALSE); + seqbase_dupli_recursive(scene, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME); /* transform pasted strips before adding */ if(ofs) { - for(iseq= new.first; iseq; iseq= iseq->next) { + for(iseq= nseqbase.first; iseq; iseq= iseq->next) { seq_offset(scene, iseq, ofs); } } - addlisttolist(ed->seqbasep, &new); + addlisttolist(ed->seqbasep, &nseqbase); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); @@ -2756,3 +2626,45 @@ void SEQUENCER_OT_paste(wmOperatorType *ot) /* properties */ } + +static int sequencer_swap_data_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Sequence *seq_act; + Sequence *seq_other; + + if(seq_active_pair_get(scene, &seq_act, &seq_other) == 0) { + BKE_report(op->reports, RPT_ERROR, "Must select 2 strips"); + return OPERATOR_CANCELLED; + } + + if(seq_swap(seq_act, seq_other) == 0) { + BKE_report(op->reports, RPT_ERROR, "Strips were not compatible"); + return OPERATOR_CANCELLED; + } + + calc_sequence(scene, seq_act); + calc_sequence(scene, seq_other); + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_swap_data(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Sequencer Swap Data"; + ot->idname= "SEQUENCER_OT_swap_data"; + ot->description="Swap 2 sequencer strips"; + + /* api callbacks */ + ot->exec= sequencer_swap_data_exec; + ot->poll= ED_operator_sequencer_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ +} + diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index fd4ee70e258..71953ff3ddd 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -95,6 +95,7 @@ void SEQUENCER_OT_snap(struct wmOperatorType *ot); void SEQUENCER_OT_previous_edit(struct wmOperatorType *ot); void SEQUENCER_OT_next_edit(struct wmOperatorType *ot); void SEQUENCER_OT_swap(struct wmOperatorType *ot); +void SEQUENCER_OT_swap_data(struct wmOperatorType *ot); void SEQUENCER_OT_rendersize(struct wmOperatorType *ot); void SEQUENCER_OT_view_toggle(struct wmOperatorType *ot); @@ -145,8 +146,6 @@ enum { }; /* defines used internally */ -#define SEQ_ALLSEL (SELECT+SEQ_LEFTSEL+SEQ_RIGHTSEL) -#define SEQ_DESEL ~SEQ_ALLSEL #define SCE_MARKERS 0 // XXX - dummy /* sequencer_ops.c */ diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 559a090a2ee..69457e5c6e8 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -73,6 +73,7 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_next_edit); WM_operatortype_append(SEQUENCER_OT_previous_edit); WM_operatortype_append(SEQUENCER_OT_swap); + WM_operatortype_append(SEQUENCER_OT_swap_data); WM_operatortype_append(SEQUENCER_OT_rendersize); WM_operatortype_append(SEQUENCER_OT_view_all); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 170b9fbda80..83fa8bffd58 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -166,7 +166,7 @@ void select_single_seq(Scene *scene, Sequence *seq, int deselect_all) /* BRING B if(deselect_all) deselect_all_seq(scene); - active_seq_set(scene, seq); + seq_active_set(scene, seq); if((seq->type==SEQ_IMAGE) || (seq->type==SEQ_MOVIE)) { if(seq->strip) @@ -185,7 +185,7 @@ void select_single_seq(Scene *scene, Sequence *seq, int deselect_all) /* BRING B void select_neighbor_from_last(Scene *scene, int lr) { - Sequence *seq= active_seq_get(scene); + Sequence *seq= seq_active_get(scene); Sequence *neighbor; int change = 0; if (seq) { @@ -231,7 +231,7 @@ static int sequencer_deselect_exec(bContext *C, wmOperator *op) for(seq= ed->seqbasep->first; seq; seq=seq->next) { if (desel) { - seq->flag &= SEQ_DESEL; + seq->flag &= ~SEQ_ALLSEL; } else { seq->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL); @@ -269,7 +269,7 @@ static int sequencer_select_inverse_exec(bContext *C, wmOperator *op) for(seq= ed->seqbasep->first; seq; seq=seq->next) { if (seq->flag & SELECT) { - seq->flag &= SEQ_DESEL; + seq->flag &= ~SEQ_ALLSEL; } else { seq->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL); @@ -392,7 +392,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) deselect_all_seq(scene); if(seq) { - active_seq_set(scene, seq); + seq_active_set(scene, seq); if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) { if(seq->strip) { @@ -409,7 +409,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) switch(hand) { case SEQ_SIDE_NONE: if (linked_handle==0) - seq->flag &= SEQ_DESEL; + seq->flag &= ~SEQ_ALLSEL; break; case SEQ_SIDE_LEFT: seq->flag ^= SEQ_LEFTSEL; @@ -794,7 +794,7 @@ static int sequencer_select_active_side_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, 0); - Sequence *seq_act= active_seq_get(scene); + Sequence *seq_act= seq_active_get(scene); if (ed==NULL || seq_act==NULL) return OPERATOR_CANCELLED; @@ -860,7 +860,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) if(BLI_isect_rctf(&rq, &rectf, 0)) { if(selecting) seq->flag |= SELECT; - else seq->flag &= SEQ_DESEL; + else seq->flag &= ~SEQ_ALLSEL; recurs_sel_seq(seq); } } diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 1460d08b396..7928fc6284a 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -31,6 +31,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_particle_types.h" #include "MEM_guardedalloc.h" @@ -40,6 +41,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_screen.h" +#include "BKE_pointcache.h" #include "BKE_utildefines.h" #include "ED_anim_api.h" @@ -84,6 +86,174 @@ static void time_draw_sfra_efra(const bContext *C, SpaceTime *stime, ARegion *ar fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax); } +#define CACHE_DRAW_HEIGHT 3.0f + +static void time_draw_cache(const bContext *C, SpaceTime *stime, ARegion *ar) +{ + SpaceTimeCache *stc; + float yoffs=0.f; + + if (!(stime->cache_display & TIME_CACHE_DISPLAY)) + return; + + for (stc= stime->caches.first; stc; stc=stc->next) { + float col[4]; + + if (!stc->array || !stc->ok) + continue; + + glPushMatrix(); + glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT+yoffs, 0.0); + glScalef(1.0, CACHE_DRAW_HEIGHT, 0.0); + + switch(stc->type) { + case PTCACHE_TYPE_SOFTBODY: + col[0] = 1.0; col[1] = 0.4; col[2] = 0.02; + col[3] = 0.1; + break; + case PTCACHE_TYPE_PARTICLES: + col[0] = 1.0; col[1] = 0.1; col[2] = 0.02; + col[3] = 0.1; + break; + case PTCACHE_TYPE_CLOTH: + col[0] = 0.1; col[1] = 0.1; col[2] = 0.75; + col[3] = 0.1; + break; + case PTCACHE_TYPE_SMOKE_DOMAIN: + case PTCACHE_TYPE_SMOKE_HIGHRES: + col[0] = 0.2; col[1] = 0.2; col[2] = 0.2; + col[3] = 0.1; + break; + } + glColor4fv(col); + + glEnable(GL_BLEND); + + glRectf((float)stc->startframe, 0.0, (float)stc->endframe, 1.0); + + col[3] = 0.4; + if (stc->flag & PTCACHE_BAKED) { + col[0] -= 0.4; col[1] -= 0.4; col[2] -= 0.4; + } + glColor4fv(col); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, stc->array); + glDrawArrays(GL_QUADS, 0, stc->len); + glDisableClientState(GL_VERTEX_ARRAY); + + glDisable(GL_BLEND); + + glPopMatrix(); + + yoffs += CACHE_DRAW_HEIGHT; + } +} + +static void time_cache_free(SpaceTime *stime) +{ + SpaceTimeCache *stc; + + for (stc= stime->caches.first; stc; stc=stc->next) { + if (stc->array) { + MEM_freeN(stc->array); + stc->array = NULL; + } + } + + BLI_freelistN(&stime->caches); +} + +static void time_cache_refresh(const bContext *C, SpaceTime *stime, ARegion *ar) +{ + Object *ob = CTX_data_active_object(C); + PTCacheID *pid; + ListBase pidlist; + + time_cache_free(stime); + + if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob)) + return; + + BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + + /* iterate over pointcaches on the active object, + * add spacetimecache and vertex array for each */ + for(pid=pidlist.first; pid; pid=pid->next) { + SpaceTimeCache *stc; + float *fp, *array; + int i, len; + + switch(pid->type) { + case PTCACHE_TYPE_SOFTBODY: + if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue; + break; + case PTCACHE_TYPE_PARTICLES: + if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue; + break; + case PTCACHE_TYPE_CLOTH: + if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue; + break; + case PTCACHE_TYPE_SMOKE_DOMAIN: + case PTCACHE_TYPE_SMOKE_HIGHRES: + if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue; + break; + } + + stc= MEM_callocN(sizeof(SpaceTimeCache), "spacetimecache"); + + stc->type = pid->type; + + if (pid->cache->flag & PTCACHE_BAKED) + stc->flag |= PTCACHE_BAKED; + if (pid->cache->flag & PTCACHE_DISK_CACHE) + stc->flag |= PTCACHE_DISK_CACHE; + + /* first allocate with maximum number of frames needed */ + BKE_ptcache_id_time(pid, CTX_data_scene(C), 0, &stc->startframe, &stc->endframe, NULL); + len = (stc->endframe - stc->startframe + 1)*4; + fp = array = MEM_callocN(len*2*sizeof(float), "temporary timeline cache array"); + + /* fill the vertex array with a quad for each cached frame */ + for (i=stc->startframe; i<=stc->endframe; i++) { + + if (BKE_ptcache_id_exist(pid, i)) { + fp[0] = (float)i; + fp[1] = 0.0; + fp+=2; + + fp[0] = (float)i; + fp[1] = 1.0; + fp+=2; + + fp[0] = (float)(i+1); + fp[1] = 1.0; + fp+=2; + + fp[0] = (float)(i+1); + fp[1] = 0.0; + fp+=2; + } + } + /* update with final number of frames */ + stc->len = (i-stc->startframe)*4; + stc->array = MEM_mallocN(stc->len*2*sizeof(float), "SpaceTimeCache array"); + memcpy(stc->array, array, stc->len*2*sizeof(float)); + + MEM_freeN(array); + array = NULL; + + stc->ok = 1; + + BLI_addtail(&stime->caches, stc); + } + + /* todo: sort time->caches list for consistent order */ + // ... + + BLI_freelistN(&pidlist); +} + /* helper function - find actkeycolumn that occurs on cframe, or the nearest one if not found */ static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe) { @@ -206,6 +376,52 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar /* ---------------- */ +static void time_refresh(const bContext *C, ScrArea *sa) +{ + SpaceTime *stime = (SpaceTime *)sa->spacedata.first; + ARegion *ar; + + /* find the main timeline region and refresh cache display*/ + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype==RGN_TYPE_WINDOW) { + time_cache_refresh(C, stime, ar); + break; + } + } +} + +/* editor level listener */ +static void time_listener(ScrArea *sa, wmNotifier *wmn) +{ + + /* mainly for updating cache display */ + switch (wmn->category) { + case NC_OBJECT: + switch (wmn->data) { + case ND_POINTCACHE: + ED_area_tag_refresh(sa); + ED_area_tag_redraw(sa); + break; + } + break; + case NC_SCENE: + switch (wmn->data) { + case ND_OB_ACTIVE: + case ND_FRAME: + ED_area_tag_refresh(sa); + break; + } + case NC_SPACE: + switch (wmn->data) { + case ND_SPACE_CHANGED: + ED_area_tag_refresh(sa); + break; + } + } +} + +/* ---------------- */ + /* add handlers, stuff you only do once or on area/region changes */ static void time_main_area_init(wmWindowManager *wm, ARegion *ar) { @@ -235,7 +451,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) /* start and end frame */ time_draw_sfra_efra(C, stime, ar); - + /* grid */ unit= (stime->flag & TIME_DRAWFRAMES)? V2D_UNIT_FRAMES: V2D_UNIT_SECONDS; grid= UI_view2d_grid_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); @@ -254,6 +470,9 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_orthoSpecial(C, v2d, 1); draw_markers_time(C, 0); + /* caches */ + time_draw_cache(C, stime, ar); + /* reset view matrix */ UI_view2d_view_restore(C); @@ -277,7 +496,6 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) break; case NC_SCENE: - /* any scene change for now */ ED_region_tag_redraw(ar); break; @@ -377,13 +595,23 @@ static SpaceLink *time_new(const bContext *C) /* not spacelink itself */ static void time_free(SpaceLink *sl) { + SpaceTime *stime= (SpaceTime *)sl; + + time_cache_free(stime); } /* spacetype; init callback in ED_area_initialize() */ /* init is called to (re)initialize an existing editor (file read, screen changes) */ /* validate spacedata, add own area level handlers */ static void time_init(wmWindowManager *wm, ScrArea *sa) { + SpaceTime *stime= (SpaceTime *)sa->spacedata.first; + time_cache_free(stime); + + /* enable all cache display */ + stime->cache_display |= TIME_CACHE_DISPLAY; + stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES); + stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE); } static SpaceLink *time_duplicate(SpaceLink *sl) @@ -391,6 +619,8 @@ static SpaceLink *time_duplicate(SpaceLink *sl) SpaceTime *stime= (SpaceTime *)sl; SpaceTime *stimen= MEM_dupallocN(stime); + time_cache_free(stimen); + return (SpaceLink *)stimen; } @@ -410,6 +640,8 @@ void ED_spacetype_time(void) st->duplicate= time_duplicate; st->operatortypes= time_operatortypes; st->keymap= NULL; + st->listener= time_listener; + st->refresh= time_refresh; /* regions: main window */ art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index ced745bb5d4..63155a95601 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -430,7 +430,7 @@ static int draw_tface__set_draw(MTFace *tface, MCol *mcol, int matnr) } else if (tface && tface->mode&TF_OBCOL) { return 2; /* Don't set color */ } else if (!mcol) { - return 2; /* Don't set color */ + return 1; /* Don't set color */ } else { return 1; /* Set color from mcol */ } @@ -465,9 +465,9 @@ static void add_tface_color_layer(DerivedMesh *dm) } } else if (tface && tface->mode&TF_OBCOL) { for(j=0;j<4;j++) { - finalCol[i*4+j].r = Gtexdraw.obcol[0]; - finalCol[i*4+j].g = Gtexdraw.obcol[1]; - finalCol[i*4+j].b = Gtexdraw.obcol[2]; + finalCol[i*4+j].r = FTOCHAR(Gtexdraw.obcol[0]); + finalCol[i*4+j].g = FTOCHAR(Gtexdraw.obcol[1]); + finalCol[i*4+j].b = FTOCHAR(Gtexdraw.obcol[2]); } } else if (!mcol) { if (tface) { @@ -486,9 +486,9 @@ static void add_tface_color_layer(DerivedMesh *dm) else copy_v3_v3(col, &ma->r); for(j=0;j<4;j++) { - finalCol[i*4+j].b = col[2]; - finalCol[i*4+j].g = col[1]; - finalCol[i*4+j].r = col[0]; + finalCol[i*4+j].b = FTOCHAR(col[2]); + finalCol[i*4+j].g = FTOCHAR(col[1]); + finalCol[i*4+j].r = FTOCHAR(col[0]); } } else @@ -535,7 +535,7 @@ static int draw_em_tf_mapped__set_draw(void *userData, int index) mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL); matnr = efa->mat_nr; - return draw_tface__set_draw(tface, mcol, matnr); + return draw_tface__set_draw_legacy(tface, mcol, matnr); } static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmooth_r) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 45bab2ed16e..7cae427112b 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3927,6 +3927,20 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv cd2=cdata2=0; glLineWidth(1.0f); + + if((part->draw & PART_DRAW_NUM) && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0){ + cache=psys->pathcache; + + for(a=0, pa=psys->particles; a<totpart; a++, pa++){ + float vec_txt[3]; + val[0]= '\0'; + + sprintf(val, "%i", a); + /* use worldspace beause object matrix is alredy applied */ + mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co); + view3d_cached_text_draw_add(vec_txt[0], vec_txt[1], vec_txt[2], val, 10, V3D_CACHE_TEXT_WORLDSPACE); + } + } } else if(pdd && ELEM(draw_as, 0, PART_DRAW_CIRC)==0){ glDisableClientState(GL_COLOR_ARRAY); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 472379ec6e1..92e3b35f614 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -587,7 +587,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) break; case NC_BRUSH: if(wmn->action == NA_EDITED) - ED_region_tag_redraw(ar); + ED_region_tag_redraw_overlay(ar); break; case NC_MATERIAL: switch(wmn->data) { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 1944628c244..77ba7939ccd 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1242,7 +1242,17 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2. minmax_object(base->object, min, max); } } - if(!onedone) return OPERATOR_FINISHED; /* TODO - should this be cancel? */ + if(!onedone) { + ED_region_tag_redraw(ar); + /* TODO - should this be cancel? + * I think no, because we always move the cursor, with or without + * object, but in this case there is no change in the scene, + * only the cursor so I choice a ED_region_tag like + * smooth_view do for the center_cursor. + * See bug #22640 + */ + return OPERATOR_FINISHED; + } afm[0]= (max[0]-min[0]); afm[1]= (max[1]-min[1]); diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 85e13879367..29bcd4e8592 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -392,6 +392,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) { prop= RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION); RNA_def_property_array(prop, 3); + /* Make this not hidden when there's a nice axis selection widget */ RNA_def_property_flag(prop, PROP_HIDDEN); RNA_def_property_ui_text(prop, "Axis", "The axis around which the transformation occurs"); @@ -400,9 +401,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) if (flags & P_CONSTRAINT) { prop= RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", ""); - RNA_def_property_flag(prop, PROP_HIDDEN); prop= RNA_def_property(ot->srna, "constraint_orientation", PROP_ENUM, PROP_NONE); - RNA_def_property_flag(prop, PROP_HIDDEN); RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation"); RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf); diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c index 2cb63b7274c..bfc3433875d 100644 --- a/source/blender/imbuf/intern/anim.c +++ b/source/blender/imbuf/intern/anim.c @@ -589,9 +589,9 @@ static int startffmpeg(struct anim * anim) { anim->duration = pFormatCtx->duration * pCodecCtx->frame_rate / pCodecCtx->frame_rate_base / AV_TIME_BASE; #else - anim->duration = pFormatCtx->duration + anim->duration = ceil(pFormatCtx->duration * av_q2d(pFormatCtx->streams[videoStream]->r_frame_rate) - / AV_TIME_BASE; + / AV_TIME_BASE); #endif anim->params = 0; diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 3c14189a292..09aaccc1ab6 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -592,8 +592,10 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, int mem_size, int flags) if (flags & IB_test) return (ibuf); if (tga.imgtyp != 1 && tga.imgtyp != 9) { /* happens sometimes (beuh) */ - MEM_freeN(cmap); - cmap= NULL; + if(cmap) { + MEM_freeN(cmap); + cmap= NULL; + } } switch(tga.imgtyp){ diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 6d73c261f23..a811fd9c014 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -152,7 +152,9 @@ typedef struct ARegion { short sizex, sizey; /* current split size in pixels (if zero it uses regiontype) */ short do_draw; /* private, cached notifier events */ + short do_draw_overlay; /* private, cached notifier events */ short swap; /* private, indicator to survive swap-exchange */ + short pad[3]; struct ARegionType *type; /* callbacks for this region type */ diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 9f395d6e876..84d8e8c8e67 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -276,6 +276,9 @@ typedef struct SpeedControlVars { #define SEQ_USE_PROXY_CUSTOM_FILE 2097152 #define SEQ_USE_EFFECT_DEFAULT_FADE 4194304 +/* convenience define for all selection flags */ +#define SEQ_ALLSEL (SELECT+SEQ_LEFTSEL+SEQ_RIGHTSEL) + /* deprecated, dont use a flag anymore*/ /*#define SEQ_ACTIVE 1048576*/ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index e59cad09d6c..ba9d0380c9f 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -346,6 +346,17 @@ typedef struct SpaceScript { void *but_refs; } SpaceScript; +typedef struct SpaceTimeCache { + struct SpaceTimeCache *next, *prev; + int type; + int flag; + + float *array; + int len; + int startframe, endframe; + int ok; +} SpaceTimeCache; + typedef struct SpaceTime { SpaceLink *next, *prev; ListBase regionbase; /* storage of regions for inactive spaces */ @@ -354,6 +365,9 @@ typedef struct SpaceTime { View2D v2d; /* deprecated, copied to region */ + ListBase caches; + int cache_display, pad; + int flag, redraws; } SpaceTime; @@ -860,6 +874,13 @@ enum { #define TIME_CONTINUE_PHYSICS 128 #define TIME_NODES 256 +/* time->cache */ +#define TIME_CACHE_DISPLAY 1 +#define TIME_CACHE_SOFTBODY 2 +#define TIME_CACHE_PARTICLES 4 +#define TIME_CACHE_CLOTH 8 +#define TIME_CACHE_SMOKE 16 + /* sseq->mainb */ #define SEQ_DRAW_SEQUENCE 0 #define SEQ_DRAW_IMG_IMBUF 1 diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 386ae0c10c2..5a705a862ab 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -2275,7 +2275,7 @@ RNAProcessItem PROCESS_ITEMS[]= { {"rna_screen.c", NULL, RNA_def_screen}, {"rna_sculpt_paint.c", NULL, RNA_def_sculpt_paint}, {"rna_sensor.c", NULL, RNA_def_sensor}, - {"rna_sequencer.c", NULL, RNA_def_sequencer}, + {"rna_sequencer.c", "rna_sequencer_api.c", RNA_def_sequencer}, {"rna_smoke.c", NULL, RNA_def_smoke}, {"rna_space.c", NULL, RNA_def_space}, {"rna_test.c", NULL, RNA_def_test}, diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 2ca327f8907..2a29f3332b5 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -476,6 +476,12 @@ void rna_def_actuator(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, NULL, "rna_Actuator_type_set", "rna_Actuator_type_itemf"); RNA_def_property_ui_text(prop, "Type", ""); + prop= RNA_def_property(srna, "pinned", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_PIN); + RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller"); + RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); + RNA_def_property_update(prop, NC_LOGIC, NULL); + prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SHOW); RNA_def_property_ui_text(prop, "Expanded", "Set actuator expanded in the user interface"); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 899902683bd..5ab1435a5bc 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -34,6 +34,7 @@ struct ID; struct IDProperty; struct SDNA; +struct Sequence; /* Data structures used during define */ @@ -233,6 +234,7 @@ void RNA_api_object_base(struct StructRNA *srna); void RNA_api_pose_channel(struct StructRNA *srna); void RNA_api_scene(struct StructRNA *srna); void RNA_api_scene_render(struct StructRNA *srna); +void RNA_api_sequence_strip(StructRNA *srna); void RNA_api_text(struct StructRNA *srna); void RNA_api_ui_layout(struct StructRNA *srna); void RNA_api_wm(struct StructRNA *srna); @@ -342,6 +344,7 @@ PointerRNA rna_pointer_inherit_refine(struct PointerRNA *ptr, struct StructRNA * int rna_parameter_size(struct PropertyRNA *parm); int rna_parameter_size_alloc(struct PropertyRNA *parm); + #endif /* RNA_INTERNAL_H */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 3859ac5b834..66784f6cbfc 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2620,6 +2620,13 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Motion Samples", "Number of scene samples to take with motion blur"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + prop= RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "blurfac"); + RNA_def_property_range(prop, 0.01f, 10.0f); + RNA_def_property_ui_range(prop, 0.01, 2.0f, 1, 0); + RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + /* border */ prop= RNA_def_property(srna, "use_border", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_BORDER); @@ -2677,8 +2684,9 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "color_management", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "color_mgt_flag", R_COLOR_MANAGEMENT); - RNA_def_property_ui_text(prop, "Color Management", "Use color profiles and gamma corrected imaging pipeline"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS|NC_MATERIAL|ND_SHADING, "rna_RenderSettings_color_management_update"); + RNA_def_property_ui_text(prop, "Color Management", "Use linear workflow - gamma corrected imaging pipeline"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_RenderSettings_color_management_update"); + prop= RNA_def_property(srna, "use_file_extension", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXTENSION); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 31fa8f018dc..17137d0d259 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -260,6 +260,12 @@ static void rna_def_sensor(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Type", ""); RNA_def_property_update(prop, NC_LOGIC, NULL); + prop= RNA_def_property(srna, "pinned", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_PIN); + RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller"); + RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); + RNA_def_property_update(prop, NC_LOGIC, NULL); + prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_SHOW); RNA_def_property_ui_text(prop, "Expanded", "Set sensor expanded in the user interface"); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index c52fd7f5cba..4ee4fde0d8a 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -163,7 +163,7 @@ static void rna_Sequence_anim_endofs_final_set(PointerRNA *ptr, int value) rna_Sequence_frame_change_update(scene, seq); } -static void rna_Sequence_length_set(PointerRNA *ptr, int value) +static void rna_Sequence_frame_length_set(PointerRNA *ptr, int value) { Sequence *seq= (Sequence*)ptr->data; Scene *scene= (Scene*)ptr->id.data; @@ -172,7 +172,7 @@ static void rna_Sequence_length_set(PointerRNA *ptr, int value) rna_Sequence_frame_change_update(scene, seq); } -static int rna_Sequence_length_get(PointerRNA *ptr) +static int rna_Sequence_frame_length_get(PointerRNA *ptr) { Sequence *seq= (Sequence*)ptr->data; return seq_tx_get_final_right(seq, 0)-seq_tx_get_final_left(seq, 0); @@ -627,7 +627,6 @@ static void rna_def_sequence(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - FunctionRNA *func; static const EnumPropertyItem seq_type_items[]= { {SEQ_IMAGE, "IMAGE", 0, "Image", ""}, @@ -707,11 +706,6 @@ static void rna_def_sequence(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mute", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_mute_update"); - prop= RNA_def_property(srna, "frame_locked", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_IPO_FRAME_LOCKED); - RNA_def_property_ui_text(prop, "Frame Locked", "Lock the animation curve to the global frame counter"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); - prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_LOCK); RNA_def_property_ui_text(prop, "Lock", "Lock strip so that it can't be transformed"); @@ -719,13 +713,18 @@ static void rna_def_sequence(BlenderRNA *brna) /* strip positioning */ - prop= RNA_def_property(srna, "length", PROP_INT, PROP_TIME); - RNA_def_property_int_sdna(prop, NULL, "len"); + prop= RNA_def_property(srna, "frame_final_length", PROP_INT, PROP_TIME); RNA_def_property_range(prop, 1, MAXFRAME); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Length", "The length of the contents of this strip before the handles are applied"); - RNA_def_property_int_funcs(prop, "rna_Sequence_length_get", "rna_Sequence_length_set",NULL); + RNA_def_property_int_funcs(prop, "rna_Sequence_frame_length_get", "rna_Sequence_frame_length_set",NULL); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + + prop= RNA_def_property(srna, "frame_length", PROP_INT, PROP_TIME); + RNA_def_property_int_sdna(prop, NULL, "len"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE|PROP_ANIMATABLE); + RNA_def_property_range(prop, 1, MAXFRAME); + RNA_def_property_ui_text(prop, "Length", "The length of the contents of this strip before the handles are applied"); prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "start"); @@ -811,12 +810,7 @@ static void rna_def_sequence(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Speed effect fader position", ""); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); - /* functions */ - func= RNA_def_function(srna, "getStripElem", "give_stripelem"); - RNA_def_function_ui_description(func, "Return the strip element from a given frame or None."); - prop= RNA_def_int(func, "frame", 0, -MAXFRAME, MAXFRAME, "Frame", "The frame to get the strip element from", -MAXFRAME, MAXFRAME); - RNA_def_property_flag(prop, PROP_REQUIRED); - RNA_def_function_return(func, RNA_def_pointer(func, "elem", "SequenceElement", "", "strip element of the current frame")); + RNA_api_sequence_strip(srna); } static void rna_def_editor(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c new file mode 100644 index 00000000000..425bad9fcd7 --- /dev/null +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -0,0 +1,72 @@ +/** + * $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. + * + * Contributor(s): Blender Foundation (2010) + * + * ***** END GPL LICENSE BLOCK ***** + */ + + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "RNA_define.h" + +#include "BLO_sys_types.h" /* needed for intptr_t used in ED_mesh.h */ + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "rna_internal.h" + +#include "DNA_scene_types.h" +#include "DNA_sequence_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_report.h" +#include "BKE_sequencer.h" + +static void rna_Sequence_swap_internal(Sequence *seq_self, ReportList *reports, Sequence *seq_other) +{ + if(seq_swap(seq_self, seq_other) == 0) + BKE_report(reports, RPT_ERROR, "both strips must be the same length"); +} + +#else + +void RNA_api_sequence_strip(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + func= RNA_def_function(srna, "getStripElem", "give_stripelem"); + RNA_def_function_ui_description(func, "Return the strip element from a given frame or None."); + parm= RNA_def_int(func, "frame", 0, -MAXFRAME, MAXFRAME, "Frame", "The frame to get the strip element from", -MAXFRAME, MAXFRAME); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_function_return(func, RNA_def_pointer(func, "elem", "SequenceElement", "", "strip element of the current frame")); + + func= RNA_def_function(srna, "swap", "rna_Sequence_swap_internal"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm= RNA_def_pointer(func, "other", "Sequence", "Other", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 3058fe62e0f..d5b3db1185e 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -603,7 +603,7 @@ static void rna_SpaceTime_redraw_update(Main *bmain, Scene *scene, PointerRNA *p SpaceTime *st= (SpaceTime*)ptr->data; bScreen *screen= (bScreen*)ptr->id.data; - ED_screen_animation_timer_update(screen, st->redraws); + ED_screen_animation_timer_update(screen, st->redraws, SPACE_TIME); } /* Space Dopesheet */ @@ -1878,6 +1878,32 @@ static void rna_def_space_time(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_CFRA_NUM); RNA_def_property_ui_text(prop, "Show Frame Number Indicator", "Show frame number beside the current frame indicator line"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL); + + /* displaying cache status */ + prop= RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DISPLAY); + RNA_def_property_ui_text(prop, "Show Cache", "Show the status of cached frames in the timeline"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL); + + prop= RNA_def_property(srna, "cache_softbody", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SOFTBODY); + RNA_def_property_ui_text(prop, "Softbody", "Show the active object's softbody point cache"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL); + + prop= RNA_def_property(srna, "cache_particles", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_PARTICLES); + RNA_def_property_ui_text(prop, "Particles", "Show the active object's particle point cache"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL); + + prop= RNA_def_property(srna, "cache_cloth", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_CLOTH); + RNA_def_property_ui_text(prop, "Cloth", "Show the active object's cloth point cache"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL); + + prop= RNA_def_property(srna, "cache_smoke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SMOKE); + RNA_def_property_ui_text(prop, "Smoke", "Show the active object's smoke cache"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL); } static void rna_def_console_line(BlenderRNA *brna) @@ -2202,7 +2228,7 @@ static void rna_def_space_logic(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "sensors_show_active_states", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "scaflag", BUTS_SENS_STATE); + RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_STATE); RNA_def_property_ui_text(prop, "Show Active States", "Show only sensors connected to active states"); RNA_def_property_update(prop, NC_LOGIC, NULL); @@ -2239,7 +2265,7 @@ static void rna_def_space_logic(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "actuators_show_active_states", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "scaflag", BUTS_ACT_STATE); + RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_STATE); RNA_def_property_ui_text(prop, "Show Active States", "Show only actuators connected to active states"); RNA_def_property_update(prop, NC_LOGIC, NULL); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 32221e51cb9..a12b8c55552 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -160,24 +160,8 @@ static void rna_Texture_nodes_update(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Texture_type_set(PointerRNA *ptr, int value) { Tex *tex= (Tex*)ptr->data; - - switch(value) { - - 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 = value; + tex_set_type(tex, value); } void rna_TextureSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 52c18b4e581..1797df2abf0 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -114,6 +114,7 @@ EnumPropertyItem event_type_items[] = { {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", ""}, {0, "", 0, NULL, NULL}, {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", ""}, + {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "Inbetween Move", ""}, {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""}, {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""}, {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""}, diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 531aaff504b..e73c3e29f66 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -124,7 +124,7 @@ static int isDisabled(ModifierData *md, int useRenderParams) { DisplaceModifierData *dmd = (DisplaceModifierData*) md; - return !dmd->texture; + return (!dmd->texture || dmd->strength == 0.0f); } static void updateDepgraph( diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c b/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c index d2eb27d13c6..6f29548fcc3 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c @@ -47,7 +47,12 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack * if(nif->sfra!=nif->efra && (rd->cfra<nif->sfra || rd->cfra>nif->efra)) { return; /* BAIL OUT RETURN */ } - else { + else if (!G.rendering) { + /* only output files when rendering a sequence - + * otherwise, it overwrites the output files just + * scrubbing through the timeline when the compositor updates */ + return; + } else { CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); ImBuf *ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0, 0); char string[256]; diff --git a/source/blender/python/doc/examples/mathutils.py b/source/blender/python/doc/examples/mathutils.py index dee8fa4d6bd..6cd11a1baaa 100644 --- a/source/blender/python/doc/examples/mathutils.py +++ b/source/blender/python/doc/examples/mathutils.py @@ -1,8 +1,9 @@ import mathutils +from math import radians vec = mathutils.Vector(1.0, 2.0, 3.0) -mat_rot = mathutils.RotationMatrix(90, 4, 'X') +mat_rot = mathutils.RotationMatrix(radians(90), 4, 'X') mat_trans = mathutils.TranslationMatrix(vec) mat = mat_trans * mat_rot diff --git a/source/blender/python/generic/geometry.c b/source/blender/python/generic/geometry.c index 18907bb3012..586c6a3406d 100644 --- a/source/blender/python/generic/geometry.c +++ b/source/blender/python/generic/geometry.c @@ -419,7 +419,7 @@ static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq ) } else if (totpoints) { /* now make the list to return */ - filldisplist(&dispbase, &dispbase); + filldisplist(&dispbase, &dispbase, 0); /* The faces are stored in a new DisplayList thats added to the head of the listbase */ diff --git a/source/blender/python/generic/mathutils.c b/source/blender/python/generic/mathutils.c index 95be795dd4e..f0571f32f58 100644 --- a/source/blender/python/generic/mathutils.c +++ b/source/blender/python/generic/mathutils.c @@ -168,7 +168,7 @@ static char M_Mathutils_RotationMatrix_doc[] = "\n" " Create a matrix representing a rotation.\n" "\n" -" :arg angle: The angle of rotation desired.\n" +" :arg angle: The angle of rotation desired, in radians.\n" " :type angle: float\n" " :arg size: The size of the rotation matrix to construct [2, 4].\n" " :type size: int\n" diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 8f49263b375..e5719a84fdd 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -59,10 +59,6 @@ static int bpy_pydriver_create_dict(void) mod = PyImport_ImportModule("math"); if (mod) { PyDict_Merge(d, PyModule_GetDict(mod), 0); /* 0 - dont overwrite existing values */ - - /* Only keep for backwards compat! - just import all math into root, they are standard */ - PyDict_SetItemString(d, "math", mod); - PyDict_SetItemString(d, "m", mod); Py_DECREF(mod); } diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 3d7c0b133db..c278ad56ab9 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -586,7 +586,7 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) } prop= RNA_def_property(srna, id, PROP_STRING, subtype); - if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen); + if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */ if(def) RNA_def_property_string_default(prop, def); RNA_def_property_ui_text(prop, name, description); diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index b184b681846..bdc1dcc2782 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -41,9 +41,10 @@ #include "BKE_node.h" #include "BKE_utildefines.h" -#include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_cpu.h" #include "BLI_jitter.h" +#include "BLI_math.h" #include "BLI_rand.h" #include "PIL_time.h" @@ -98,7 +99,7 @@ RayObject* RE_rayobject_create(Render *re, int type, int size) //TODO //if(detect_simd()) #ifdef __SSE__ - type = R_RAYSTRUCTURE_SIMD_SVBVH; + type = BLI_cpu_support_sse2()? R_RAYSTRUCTURE_SIMD_SVBVH: R_RAYSTRUCTURE_VBVH; #else type = R_RAYSTRUCTURE_VBVH; #endif @@ -370,6 +371,10 @@ static void makeraytree_single(Render *re) if(has_special_rayobject(re, obi)) { RayObject *obj = makeraytree_object(re, obi); + + if(test_break(re)) + break; + RE_rayobject_add( re->raytree, obj ); } else diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 199b17b9810..067df17917d 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -195,6 +195,7 @@ typedef struct wmNotifier { #define ND_KEYS (23<<16) #define ND_CONSTRAINT (24<<16) #define ND_PARTICLE (25<<16) +#define ND_POINTCACHE (26<<16) /* NC_MATERIAL Material */ #define ND_SHADING (30<<16) diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 0331613d392..d2afef3b117 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -642,6 +642,13 @@ static int wm_draw_update_test_window(wmWindow *win) { ScrArea *sa; ARegion *ar; + + for(ar= win->screen->regionbase.first; ar; ar= ar->next) { + if(ar->do_draw_overlay) { + wm_tag_redraw_overlay(win, ar); + ar->do_draw_overlay= 0; + } + } if(win->screen->do_refresh) return 1; @@ -687,8 +694,11 @@ static int wm_automatic_draw_method(wmWindow *win) void wm_tag_redraw_overlay(wmWindow *win, ARegion *ar) { /* for draw triple gestures, paint cursors don't need region redraw */ - if(ar && win && wm_automatic_draw_method(win) != USER_DRAW_TRIPLE) - ED_region_tag_redraw(ar); + if(ar && win) { + if(wm_automatic_draw_method(win) != USER_DRAW_TRIPLE) + ED_region_tag_redraw(ar); + win->screen->do_draw_paintcursor= 1; + } } void wm_draw_update(bContext *C) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 70e804758b2..330244e910e 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1614,7 +1614,7 @@ void wm_event_do_handlers(bContext *C) while( (event= win->queue.first) ) { int action = WM_HANDLER_CONTINUE; - if((G.f & G_DEBUG) && event && event->type!=MOUSEMOVE) + if((G.f & G_DEBUG) && event && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) printf("pass on evt %d val %d\n", event->type, event->val); wm_eventemulation(event); @@ -2138,6 +2138,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t case GHOST_kEventCursorMove: { if(win->active) { GHOST_TEventCursorData *cd= customdata; + wmEvent *lastevent= win->queue.last; #if defined(__APPLE__) && defined(GHOST_COCOA) //Cocoa already uses coordinates with y=0 at bottom, and returns inwindow coordinates on mouse moved event @@ -2156,6 +2157,12 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int t event.type= MOUSEMOVE; + /* some painting operators want accurate mouse events, they can + handle inbetween mouse move moves, others can happily ignore + them for better performance */ + if(lastevent && lastevent->type == MOUSEMOVE) + lastevent->type = INBETWEEN_MOUSEMOVE; + update_tablet_data(win, &event); wm_event_add(win, &event); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 17a04cab7be..1357b96fe70 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -533,6 +533,22 @@ static ImBuf *blend_file_thumb(const char *path, Scene *scene, int **thumb_pt) return ibuf; } +/* easy access from gdb */ +int write_crash_blend(void) +{ + char path[FILE_MAX]; + BLI_strncpy(path, G.sce, sizeof(path)); + BLI_replace_extension(path, sizeof(path), "_crash.blend"); + if(BLO_write_file(G.main, path, G.fileflags, NULL, NULL)) { + printf("written: %s\n", path); + return 1; + } + else { + printf("failed: %s\n", path); + return 0; + } +} + int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports) { Library *li; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index c38ba67a648..058c39749a6 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -789,8 +789,6 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, PropertyRNA *prop; RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "File Path", "Path to file"); - RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name of the file"); - RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Directory of the file"); if (action == FILE_SAVE) { prop= RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files"); @@ -1653,6 +1651,9 @@ static void WM_OT_link_append(wmOperatorType *ot) RNA_def_boolean(ot->srna, "active_layer", 1, "Active Layer", "Put the linked objects on the active layer"); RNA_def_boolean(ot->srna, "instance_groups", 1, "Instance Groups", "Create instances for each group as a DupliGroup"); + RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name of the file"); + RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Directory of the file"); + RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); } diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index a93214e9a54..6cb3971bd21 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -70,6 +70,7 @@ /* mapped with userdef */ #define WHEELINMOUSE 0x00c #define WHEELOUTMOUSE 0x00d +#define INBETWEEN_MOUSEMOVE 0x011 /* SYSTEM : 0x01xx */ diff --git a/source/creator/creator.c b/source/creator/creator.c index 7936e53e007..511fd423beb 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -687,10 +687,22 @@ static int render_frame(int argc, char **argv, void *data) Scene *scene= CTX_data_scene(C); if (argc > 1) { - int frame = atoi(argv[1]); Render *re = RE_NewRender(scene->id.name); + int frame; ReportList reports; + switch(*argv[1]) { + case '+': + frame= scene->r.sfra + atoi(argv[1]+1); + break; + case '-': + frame= (scene->r.efra - atoi(argv[1]+1)) + 1; + break; + default: + frame= atoi(argv[1]); + break; + } + BKE_reports_init(&reports, RPT_PRINT); frame = MIN2(MAXFRAME, MAX2(MINAFRAME, frame)); @@ -968,7 +980,7 @@ void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) /* fourth pass: processing arguments */ BLI_argsAdd(ba, 4, "-g", NULL, game_doc, set_ge_parameters, syshandle); - BLI_argsAdd(ba, 4, "-f", "--render-frame", "<frame>\n\tRender frame <frame> and save it", render_frame, C); + BLI_argsAdd(ba, 4, "-f", "--render-frame", "<frame>\n\tRender frame <frame> and save it.\n\t+<frame> start frame relative, -<frame> end frame relative.", render_frame, C); BLI_argsAdd(ba, 4, "-a", "--render-anim", "\n\tRender frames from start to end (inclusive)", render_animation, C); BLI_argsAdd(ba, 4, "-S", "--scene", "<name>\n\tSet the active scene <name> for rendering", set_scene, NULL); BLI_argsAdd(ba, 4, "-s", "--frame-start", "<frame>\n\tSet start to frame <frame> (use before the -a argument)", set_start_frame, C); diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index c916cdeb67c..a83ec7e132f 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -84,6 +84,7 @@ extern "C" { #include "BLI_blenlib.h" #include "BLO_readfile.h" #include "DNA_scene_types.h" +#include "BKE_ipo.h" /***/ #include "AUD_C-API.h" @@ -120,7 +121,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c { /* context values */ struct wmWindow *win= CTX_wm_window(C); - struct Scene *scene= CTX_data_scene(C); + struct Scene *startscene= CTX_data_scene(C); struct Main* maggie1= CTX_data_main(C); @@ -133,7 +134,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c int exitrequested = KX_EXIT_REQUEST_NO_REQUEST; Main* blenderdata = maggie1; - char* startscenename = scene->id.name+2; + char* startscenename = startscene->id.name+2; char pathname[FILE_MAXDIR+FILE_MAXFILE], oldsce[FILE_MAXDIR+FILE_MAXFILE]; STR_String exitstring = ""; BlendFileData *bfd= NULL; @@ -220,12 +221,12 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c #endif //lock frame and camera enabled - storing global values - int tmp_lay= scene->lay; - Object *tmp_camera = scene->camera; + int tmp_lay= startscene->lay; + Object *tmp_camera = startscene->camera; if (v3d->scenelock==0){ - scene->lay= v3d->lay; - scene->camera= v3d->camera; + startscene->lay= v3d->lay; + startscene->camera= v3d->camera; } // some blender stuff @@ -246,7 +247,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c } if(rv3d->persp==RV3D_CAMOB) { - if(scene->gm.framing.type == SCE_GAMEFRAMING_BARS) { /* Letterbox */ + if(startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) { /* Letterbox */ camzoom = 1.0f; } else { @@ -317,22 +318,22 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c } } - Scene *blscene= bfd ? bfd->curscene : (Scene *)BLI_findstring(&blenderdata->scene, startscenename, offsetof(ID, name) + 2); + Scene *scene= bfd ? bfd->curscene : (Scene *)BLI_findstring(&blenderdata->scene, startscenename, offsetof(ID, name) + 2); - if (blscene) + if (scene) { - int startFrame = blscene->r.cfra; + int startFrame = scene->r.cfra; ketsjiengine->SetAnimRecordMode(animation_record, startFrame); // Quad buffered needs a special window. - if(blscene->gm.stereoflag == STEREO_ENABLED){ - if (blscene->gm.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED) - rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) blscene->gm.stereomode); + if(scene->gm.stereoflag == STEREO_ENABLED){ + if (scene->gm.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED) + rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) scene->gm.stereomode); - rasterizer->SetEyeSeparation(blscene->gm.eyeseparation); + rasterizer->SetEyeSeparation(scene->gm.eyeseparation); } - rasterizer->SetBackColor(blscene->gm.framing.col[0], blscene->gm.framing.col[1], blscene->gm.framing.col[2], 0.0f); + rasterizer->SetBackColor(scene->gm.framing.col[0], scene->gm.framing.col[1], scene->gm.framing.col[2], 0.0f); } if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME) @@ -361,19 +362,19 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c if(GPU_glsl_support()) useglslmat = true; - else if(blscene->gm.matmode == GAME_MAT_GLSL) + else if(scene->gm.matmode == GAME_MAT_GLSL) usemat = false; - if(usemat && (blscene->gm.matmode != GAME_MAT_TEXFACE)) + if(usemat && (scene->gm.matmode != GAME_MAT_TEXFACE)) sceneconverter->SetMaterials(true); - if(useglslmat && (blscene->gm.matmode == GAME_MAT_GLSL)) + if(useglslmat && (scene->gm.matmode == GAME_MAT_GLSL)) sceneconverter->SetGLSLMaterials(true); KX_Scene* startscene = new KX_Scene(keyboarddevice, mousedevice, networkdevice, startscenename, - blscene, + scene, canvas); #ifndef DISABLE_PYTHON @@ -383,13 +384,13 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c #endif // DISABLE_PYTHON //initialize Dome Settings - if(blscene->gm.stereoflag == STEREO_DOME) - ketsjiengine->InitDome(blscene->gm.dome.res, blscene->gm.dome.mode, blscene->gm.dome.angle, blscene->gm.dome.resbuf, blscene->gm.dome.tilt, blscene->gm.dome.warptext); + if(scene->gm.stereoflag == STEREO_DOME) + ketsjiengine->InitDome(scene->gm.dome.res, scene->gm.dome.mode, scene->gm.dome.angle, scene->gm.dome.resbuf, scene->gm.dome.tilt, scene->gm.dome.warptext); // initialize 3D Audio Settings - AUD_set3DSetting(AUD_3DS_SPEED_OF_SOUND, blscene->audio.speed_of_sound); - AUD_set3DSetting(AUD_3DS_DOPPLER_FACTOR, blscene->audio.doppler_factor); - AUD_set3DSetting(AUD_3DS_DISTANCE_MODEL, blscene->audio.distance_model); + AUD_set3DSetting(AUD_3DS_SPEED_OF_SOUND, scene->audio.speed_of_sound); + AUD_set3DSetting(AUD_3DS_DOPPLER_FACTOR, scene->audio.doppler_factor); + AUD_set3DSetting(AUD_3DS_DISTANCE_MODEL, scene->audio.distance_model); if (sceneconverter) { @@ -505,8 +506,8 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c } //lock frame and camera enabled - restoring global values if (v3d->scenelock==0){ - scene->lay= tmp_lay; - scene->camera= tmp_camera; + startscene->lay= tmp_lay; + startscene->camera= tmp_camera; } // set the cursor back to normal diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index df071d50aa2..0d0cac3c084 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -467,6 +467,8 @@ int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *a if (!PyVecTo(value, self->m_linear_velocity)) return PY_SET_ATTR_FAIL; + self->UpdateFuzzyFlags(); + return PY_SET_ATTR_SUCCESS; } @@ -481,6 +483,8 @@ int KX_ObjectActuator::pyattr_set_angV(void *self_v, const KX_PYATTRIBUTE_DEF *a if (!PyVecTo(value, self->m_angular_velocity)) return PY_SET_ATTR_FAIL; + self->UpdateFuzzyFlags(); + return PY_SET_ATTR_SUCCESS; } |