diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-12-23 04:23:11 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-12-23 04:23:11 +0400 |
commit | 40449b1994301081f96d014df626a5375e020c76 (patch) | |
tree | 20220d8b071310fda8a0ab851c7a8f7bcc3ed8a2 /source/blender | |
parent | fa0211df269a3398dd70467982f9e129c79e501b (diff) | |
parent | 3ca00cbf541d0283e91dc454866a5f24576271be (diff) |
Merged changes in the trunk up to revision 53280.
Diffstat (limited to 'source/blender')
160 files changed, 2492 insertions, 1340 deletions
diff --git a/source/blender/avi/intern/avi_endian.c b/source/blender/avi/intern/avi_endian.c index 70add8bd90f..9720d83f2c8 100644 --- a/source/blender/avi/intern/avi_endian.c +++ b/source/blender/avi/intern/avi_endian.c @@ -49,7 +49,7 @@ #ifdef __BIG_ENDIAN__ /* copied from BLI_endian_switch_inline.h */ -static void invert(int *num) +static void invert(int *val) { int tval = *val; *val = ((tval >> 24)) | diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 570086e9b69..11759a82e60 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -50,7 +50,7 @@ extern "C" { /* used by packaging tools */ /* can be left blank, otherwise a,b,c... etc with no quotes */ -#define BLENDER_VERSION_CHAR +#define BLENDER_VERSION_CHAR a /* alpha/beta/rc/release, docs use this */ #define BLENDER_VERSION_CYCLE alpha diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 22b8f474cca..285077f258c 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -185,6 +185,7 @@ enum { PointerRNA CTX_data_pointer_get(const bContext *C, const char *member); PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type); ListBase CTX_data_collection_get(const bContext *C, const char *member); +ListBase CTX_data_dir_get_ex(const bContext *C, const short use_store, const short use_rna, const short use_all); ListBase CTX_data_dir_get(const bContext *C); int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type); diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 38a88607119..5458568433d 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -114,7 +114,7 @@ typedef struct Global { #define G_BACKBUFSEL (1 << 4) #define G_PICKSEL (1 << 5) -/* #define G_FACESELECT (1 << 8) use (mesh->editflag & ME_EDIT_PAINT_MASK) */ +/* #define G_FACESELECT (1 << 8) use (mesh->editflag & ME_EDIT_PAINT_FACE_SEL) */ #define G_SCRIPT_AUTOEXEC (1 << 13) #define G_SCRIPT_OVERRIDE_PREF (1 << 14) /* when this flag is set ignore the userprefs */ diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 3fc1b7d6136..320ced67a2f 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -123,6 +123,17 @@ void BKE_mesh_flush_hidden_from_verts(const struct MVert *mvert, struct MEdge *medge, int totedge, struct MPoly *mpoly, int totpoly); +void BKE_mesh_flush_select_from_polys_ex(struct MVert *mvert, const int totvert, + struct MLoop *mloop, + struct MEdge *medge, const int totedge, + const struct MPoly *mpoly, const int totpoly); +void BKE_mesh_flush_select_from_polys(struct Mesh *me); +void BKE_mesh_flush_select_from_verts_ex(const struct MVert *mvert, const int totvert, + struct MLoop *mloop, + struct MEdge *medge, const int totedge, + struct MPoly *mpoly, const int totpoly); +void BKE_mesh_flush_select_from_verts(struct Mesh *me); + void BKE_mesh_unlink(struct Mesh *me); void BKE_mesh_free(struct Mesh *me, int unlink); struct Mesh *BKE_mesh_add(const char *name); @@ -132,7 +143,7 @@ void mesh_update_customdata_pointers(struct Mesh *me, const short do_ensure_tess void BKE_mesh_make_local(struct Mesh *me); void BKE_mesh_boundbox_calc(struct Mesh *me, float r_loc[3], float r_size[3]); void BKE_mesh_texspace_calc(struct Mesh *me); -float *BKE_mesh_orco_verts_get(struct Object *ob); +float (*BKE_mesh_orco_verts_get(struct Object *ob))[3]; void BKE_mesh_orco_verts_transform(struct Mesh *me, float (*orco)[3], int totvert, int invert); int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, int nr); struct Mesh *BKE_mesh_from_object(struct Object *ob); @@ -152,7 +163,7 @@ void BKE_mesh_from_nurbs_displist(struct Object *ob, struct ListBase *dispbase, int **orco_index_ptr); void BKE_mesh_from_curve(struct Scene *scene, struct Object *ob); void free_dverts(struct MDeformVert *dvert, int totvert); -void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); /* __NLA */ +void copy_dverts(struct MDeformVert *dst, const struct MDeformVert *src, int totvert); void BKE_mesh_delete_material_index(struct Mesh *me, short index); void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth); void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 010839764b2..2dc01513149 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -857,30 +857,27 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, return dm; } -static float *get_editbmesh_orco_verts(BMEditMesh *em) +static float (*get_editbmesh_orco_verts(BMEditMesh *em))[3] { BMIter iter; BMVert *eve; - float *orco; - int a, totvert; + float (*orco)[3]; + int i; /* these may not really be the orco's, but it's only for preview. * could be solver better once, but isn't simple */ - - totvert = em->bm->totvert; - orco = MEM_mallocN(sizeof(float) * 3 * totvert, "BMEditMesh Orco"); + orco = MEM_mallocN(sizeof(float) * 3 * em->bm->totvert, "BMEditMesh Orco"); - eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL); - for (a = 0; eve; eve = BM_iter_step(&iter), a += 3) { - copy_v3_v3(orco + a, eve->co); + BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + copy_v3_v3(orco[i], eve->co); } return orco; } /* orco custom data layer */ -static void *get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *free) +static float (*get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *free))[3] { *free = 0; @@ -889,9 +886,9 @@ static void *get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *free *free = 1; if (em) - return (float(*)[3])get_editbmesh_orco_verts(em); + return get_editbmesh_orco_verts(em); else - return (float(*)[3])BKE_mesh_orco_verts_get(ob); + return BKE_mesh_orco_verts_get(ob); } else if (layer == CD_CLOTH_ORCO) { /* apply shape key for cloth, this should really be solved @@ -1815,17 +1812,18 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos BLI_linklist_free((LinkNode *)datamasks, NULL); } -float (*editbmesh_get_vertex_cos(BMEditMesh * em, int *numVerts_r))[3] +float (*editbmesh_get_vertex_cos(BMEditMesh *em, int *numVerts_r))[3] { - int i, numVerts = *numVerts_r = em->bm->totvert; - float (*cos)[3]; BMIter iter; BMVert *eve; + float (*cos)[3]; + int i; + + *numVerts_r = em->bm->totvert; - cos = MEM_mallocN(sizeof(float) * 3 * numVerts, "vertexcos"); + cos = MEM_mallocN(sizeof(float) * 3 * em->bm->totvert, "vertexcos"); - eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL); - for (i = 0; eve; eve = BM_iter_step(&iter), i++) { + BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { copy_v3_v3(cos[i], eve->co); } diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index e10a078c2f7..0d44f5cad6f 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -25,7 +25,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/blenlib/intern/bpath.c +/** \file blender/blenkernel/intern/bpath.c * \ingroup bli */ diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 34adeb4fefb..61d0936d41d 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1875,7 +1875,7 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps, bm->totface); CDDerivedMesh *cddm = (CDDerivedMesh *)dm; - BMIter iter, liter; + BMIter iter; BMVert *eve; BMEdge *eed; BMFace *efa; @@ -1913,7 +1913,7 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps, CD_CALLOC, dm->numLoopData); CustomData_merge(&bm->pdata, &dm->polyData, mask, CD_CALLOC, dm->numPolyData); - + /* add tessellation mface layers */ if (use_tessface) { CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em_tottri); @@ -2002,7 +2002,8 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps, j = 0; efa = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL); for (i = 0; efa; i++, efa = BM_iter_step(&iter), index++) { - BMLoop *l; + BMLoop *l_iter; + BMLoop *l_first; MPoly *mp = &mpoly[i]; BM_elem_index_set(efa, i); /* set_inline */ @@ -2011,15 +2012,16 @@ static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps, mp->flag = BM_face_flag_to_mflag(efa); mp->loopstart = j; mp->mat_nr = efa->mat_nr; - - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - mloop->v = BM_elem_index_get(l->v); - mloop->e = BM_elem_index_get(l->e); - CustomData_from_bmesh_block(&bm->ldata, &dm->loopData, l->head.data, j); + + l_iter = l_first = BM_FACE_FIRST_LOOP(efa); + do { + mloop->v = BM_elem_index_get(l_iter->v); + mloop->e = BM_elem_index_get(l_iter->e); + CustomData_from_bmesh_block(&bm->ldata, &dm->loopData, l_iter->head.data, j); j++; mloop++; - } + } while ((l_iter = l_iter->next) != l_first); CustomData_from_bmesh_block(&bm->pdata, &dm->polyData, efa->head.data, i); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index ffb93139358..7009f1235c9 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -427,11 +427,11 @@ int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListB return ret; } -static void data_dir_add(ListBase *lb, const char *member) +static void data_dir_add(ListBase *lb, const char *member, const short use_all) { LinkData *link; - if (strcmp(member, "scene") == 0) /* exception */ + if ((use_all == FALSE) && strcmp(member, "scene") == 0) /* exception */ return; if (BLI_findstring(lb, member, offsetof(LinkData, data))) @@ -442,7 +442,13 @@ static void data_dir_add(ListBase *lb, const char *member) BLI_addtail(lb, link); } -ListBase CTX_data_dir_get(const bContext *C) +/** + * \param C Context + * \param use_store Use 'C->wm.store' + * \param use_rna Use Include the properties from 'RNA_Context' + * \param use_all Don't skip values (currently only "scene") + */ +ListBase CTX_data_dir_get_ex(const bContext *C, const short use_store, const short use_rna, const short use_all) { bContextDataResult result; ListBase lb; @@ -453,11 +459,33 @@ ListBase CTX_data_dir_get(const bContext *C) memset(&lb, 0, sizeof(lb)); - if (C->wm.store) { + if (use_rna) { + char name[256], *nameptr; + int namelen; + + PropertyRNA *iterprop; + PointerRNA ctx_ptr; + RNA_pointer_create(NULL, &RNA_Context, (void *)C, &ctx_ptr); + + iterprop = RNA_struct_iterator_property(ctx_ptr.type); + + RNA_PROP_BEGIN (&ctx_ptr, itemptr, iterprop) + { + nameptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen); + data_dir_add(&lb, name, use_all); + if (nameptr) { + if (name != nameptr) { + MEM_freeN(nameptr); + } + } + } + RNA_PROP_END; + } + if (use_store && C->wm.store) { bContextStoreEntry *entry; for (entry = C->wm.store->entries.first; entry; entry = entry->next) - data_dir_add(&lb, entry->name); + data_dir_add(&lb, entry->name, use_all); } if ((ar = CTX_wm_region(C)) && ar->type && ar->type->context) { memset(&result, 0, sizeof(result)); @@ -465,7 +493,7 @@ ListBase CTX_data_dir_get(const bContext *C) if (result.dir) for (a = 0; result.dir[a]; a++) - data_dir_add(&lb, result.dir[a]); + data_dir_add(&lb, result.dir[a], use_all); } if ((sa = CTX_wm_area(C)) && sa->type && sa->type->context) { memset(&result, 0, sizeof(result)); @@ -473,7 +501,7 @@ ListBase CTX_data_dir_get(const bContext *C) if (result.dir) for (a = 0; result.dir[a]; a++) - data_dir_add(&lb, result.dir[a]); + data_dir_add(&lb, result.dir[a], use_all); } if ((sc = CTX_wm_screen(C)) && sc->context) { bContextDataCallback cb = sc->context; @@ -482,12 +510,17 @@ ListBase CTX_data_dir_get(const bContext *C) if (result.dir) for (a = 0; result.dir[a]; a++) - data_dir_add(&lb, result.dir[a]); + data_dir_add(&lb, result.dir[a], use_all); } return lb; } +ListBase CTX_data_dir_get(const bContext *C) +{ + return CTX_data_dir_get_ex(C, TRUE, FALSE, FALSE); +} + int CTX_data_equals(const char *member, const char *str) { return (strcmp(member, str) == 0); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 56b9db94108..e32f8d53b7d 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -687,7 +687,7 @@ static void boundInsert(Bounds3D *b, float point[3]) static float getSurfaceDimension(PaintSurfaceData *sData) { Bounds3D *mb = &sData->bData->mesh_bounds; - return MAX3((mb->max[0] - mb->min[0]), (mb->max[1] - mb->min[1]), (mb->max[2] - mb->min[2])); + return max_fff((mb->max[0] - mb->min[0]), (mb->max[1] - mb->min[1]), (mb->max[2] - mb->min[2])); } static void freeGrid(PaintSurfaceData *data) @@ -754,14 +754,14 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface) /* get dimensions */ sub_v3_v3v3(dim, grid->grid_bounds.max, grid->grid_bounds.min); copy_v3_v3(td, dim); - min_dim = MAX3(td[0], td[1], td[2]) / 1000.f; + min_dim = max_fff(td[0], td[1], td[2]) / 1000.f; /* deactivate zero axises */ for (i = 0; i < 3; i++) { if (td[i] < min_dim) { td[i] = 1.0f; axis -= 1; } } - if (axis == 0 || MAX3(td[0], td[1], td[2]) < 0.0001f) { + if (axis == 0 || max_fff(td[0], td[1], td[2]) < 0.0001f) { MEM_freeN(grid_bounds); MEM_freeN(bData->grid); bData->grid = NULL; @@ -4260,7 +4260,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s if (surface->effect & MOD_DPAINT_EFFECT_DO_SHRINK) shrink_speed = surface->shrink_speed; - fastest_effect = MAX3(spread_speed, shrink_speed, average_force); + fastest_effect = max_fff(spread_speed, shrink_speed, average_force); avg_dist = bData->average_dist * CANVAS_REL_SIZE / getSurfaceDimension(sData); steps = (int)ceil(1.5f * EFF_MOVEMENT_PER_FRAME * fastest_effect / avg_dist * timescale); @@ -4444,8 +4444,7 @@ static void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescal float dt, min_dist, damp_factor; float wave_speed = surface->wave_speed; double average_dist = 0.0f; - Bounds3D *mb = &sData->bData->mesh_bounds; - float canvas_size = MAX3((mb->max[0] - mb->min[0]), (mb->max[1] - mb->min[1]), (mb->max[2] - mb->min[2])); + const float canvas_size = getSurfaceDimension(sData); float wave_scale = CANVAS_REL_SIZE / canvas_size; /* allocate memory */ diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index bb8df834d0f..480ff23f100 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -115,10 +115,10 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *em) BMesh *bm = em->bm; BMLoop *(*looptris)[3] = NULL; BLI_array_declare(looptris); - BMIter iter, liter; + BMIter iter; BMFace *efa; BMLoop *l; - int i = 0, j; + int i = 0; ScanFillContext sf_ctx; @@ -161,16 +161,29 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *em) /* no need to ensure the loop order, we know its ok */ else if (efa->len == 3) { +#if 0 + int j; BLI_array_grow_one(looptris); BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) { looptris[i][j] = l; } i += 1; +#else + /* more cryptic but faster */ + BLI_array_grow_one(looptris); + { + BMLoop **l_ptr = looptris[i++]; + l_ptr[0] = l = BM_FACE_FIRST_LOOP(efa); + l_ptr[1] = l = l->next; + l_ptr[2] = l->next; + } +#endif } else if (efa->len == 4) { +#if 0 BMLoop *ltmp[4]; + int j; BLI_array_grow_items(looptris, 2); - BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) { ltmp[j] = l; } @@ -184,11 +197,27 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *em) looptris[i][1] = ltmp[2]; looptris[i][2] = ltmp[3]; i += 1; +#else + /* more cryptic but faster */ + BLI_array_grow_items(looptris, 2); + { + BMLoop **l_ptr_a = looptris[i++]; + BMLoop **l_ptr_b = looptris[i++]; + (l_ptr_a[0] = l_ptr_b[0] = l = BM_FACE_FIRST_LOOP(efa)); + (l_ptr_a[1] = l = l->next); + (l_ptr_a[2] = l_ptr_b[1] = l = l->next); + ( l_ptr_b[2] = l->next); + } +#endif } #endif /* USE_TESSFACE_SPEEDUP */ else { + int j; + BMLoop *l_iter; + BMLoop *l_first; + ScanFillVert *sf_vert, *sf_vert_last = NULL, *sf_vert_first = NULL; /* ScanFillEdge *e; */ /* UNUSED */ ScanFillFace *sf_tri; @@ -197,20 +226,25 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *em) BLI_scanfill_begin(&sf_ctx); /* scanfill time */ - BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, j) { - /*mark order */ - BM_elem_index_set(l, j); /* set_loop */ - - sf_vert = BLI_scanfill_vert_add(&sf_ctx, l->v->co); - sf_vert->tmp.p = l; + j = 0; + l_iter = l_first = BM_FACE_FIRST_LOOP(efa); + do { + sf_vert = BLI_scanfill_vert_add(&sf_ctx, l_iter->v->co); + sf_vert->tmp.p = l_iter; if (sf_vert_last) { /* e = */ BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert); } sf_vert_last = sf_vert; - if (sf_vert_first == NULL) sf_vert_first = sf_vert; - } + if (sf_vert_first == NULL) { + sf_vert_first = sf_vert; + } + + /*mark order */ + BM_elem_index_set(l_iter, j++); /* set_loop */ + + } while ((l_iter = l_iter->next) != l_first); /* complete the loop */ BLI_scanfill_edge_add(&sf_ctx, sf_vert_first, sf_vert); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index ec61311d89e..5e01773cab9 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -500,8 +500,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo BLI_assert(bezt_last != NULL); if (include_handles) { - xminv = MIN3(xminv, bezt_first->vec[0][0], bezt_first->vec[1][0]); - xmaxv = MAX3(xmaxv, bezt_last->vec[1][0], bezt_last->vec[2][0]); + xminv = min_fff(xminv, bezt_first->vec[0][0], bezt_first->vec[1][0]); + xmaxv = max_fff(xmaxv, bezt_last->vec[1][0], bezt_last->vec[2][0]); } else { xminv = min_ff(xminv, bezt_first->vec[1][0]); @@ -517,8 +517,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) { if ((do_sel_only == FALSE) || BEZSELECTED(bezt)) { if (include_handles) { - yminv = MIN4(yminv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]); - ymaxv = MAX4(ymaxv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]); + yminv = min_ffff(yminv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]); + ymaxv = max_ffff(ymaxv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]); } else { yminv = min_ff(yminv, bezt->vec[1][1]); diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 0c83bb8d39a..755030bd208 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -188,7 +188,7 @@ bGPDlayer *gpencil_layer_addnew(bGPdata *gpd, const char *name, int setactive) /* make this one the active one */ if (setactive) - gpencil_layer_setactive(gpd, gpl); + gpencil_layer_setactive(gpd, gpl); /* return layer */ return gpl; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 7f0475cf155..f3cdf11d664 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -937,7 +937,7 @@ int BKE_imtype_to_ftype(const char imtype) return RADHDR; #endif else if (imtype == R_IMF_IMTYPE_PNG) - return PNG; + return PNG | 90; #ifdef WITH_DDS else if (imtype == R_IMF_IMTYPE_DDS) return DDS; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 2192d2862c8..98625807ddc 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -158,8 +158,10 @@ void id_lib_extern(ID *id) /* ensure we have a real user */ void id_us_ensure_real(ID *id) { - if (ID_REAL_USERS(id) <= 0) { - id->us = MAX2(id->us, 0) + 1; + if (id) { + if (ID_REAL_USERS(id) <= 0) { + id->us = MAX2(id->us, 0) + 1; + } } } diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 5c882fd97d6..b3f71e58e9f 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1514,7 +1514,7 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) float in_v /*, out_v*/; float workp[3]; float dvec[3]; - float tmp_v, workp_v, max_len, len, nx, ny, nz, MAXN; + float tmp_v, workp_v, max_len, nx, ny, nz, max_dim; calc_mballco(ml, in); in_v = mbproc->function(in[0], in[1], in[2]); @@ -1573,17 +1573,17 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) ny = abs((out[1] - in[1]) / mbproc->size); nz = abs((out[2] - in[2]) / mbproc->size); - MAXN = MAX3(nx, ny, nz); - if (MAXN != 0.0f) { - dvec[0] = (out[0] - in[0]) / MAXN; - dvec[1] = (out[1] - in[1]) / MAXN; - dvec[2] = (out[2] - in[2]) / MAXN; + max_dim = max_fff(nx, ny, nz); + if (max_dim != 0.0f) { + float len = 0.0f; + + dvec[0] = (out[0] - in[0]) / max_dim; + dvec[1] = (out[1] - in[1]) / max_dim; + dvec[2] = (out[2] - in[2]) / max_dim; - len = 0.0; while (len <= max_len) { - workp[0] += dvec[0]; - workp[1] += dvec[1]; - workp[2] += dvec[2]; + add_v3_v3(workp, dvec); + /* compute value of implicite function */ tmp_v = mbproc->function(workp[0], workp[1], workp[2]); /* add cube to the stack, when value of implicite function crosses zero value */ diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 55cf2743bfa..3eb96f218e4 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -430,7 +430,7 @@ void BKE_mesh_free(Mesh *me, int unlink) if (me->edit_btmesh) MEM_freeN(me->edit_btmesh); } -void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount) +void copy_dverts(MDeformVert *dst, const MDeformVert *src, int copycount) { /* Assumes dst is already set up */ int i; @@ -442,7 +442,7 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount) for (i = 0; i < copycount; i++) { if (src[i].dw) { - dst[i].dw = MEM_callocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight"); + dst[i].dw = MEM_mallocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight"); memcpy(dst[i].dw, src[i].dw, sizeof(MDeformWeight) * src[i].totweight); } } @@ -731,7 +731,7 @@ void BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_siz if (r_size) copy_v3_v3(r_size, me->size); } -float *BKE_mesh_orco_verts_get(Object *ob) +float (*BKE_mesh_orco_verts_get(Object *ob))[3] { Mesh *me = ob->data; MVert *mvert = NULL; @@ -748,7 +748,7 @@ float *BKE_mesh_orco_verts_get(Object *ob) copy_v3_v3(vcos[a], mvert->co); } - return (float *)vcos; + return vcos; } void BKE_mesh_orco_verts_transform(Mesh *me, float (*orco)[3], int totvert, int invert) @@ -3107,6 +3107,107 @@ void BKE_mesh_flush_hidden_from_verts(const MVert *mvert, } } +/** + * simple poly -> vert/edge selection. + */ +void BKE_mesh_flush_select_from_polys_ex(MVert *mvert, const int totvert, + MLoop *mloop, + MEdge *medge, const int totedge, + const MPoly *mpoly, const int totpoly) +{ + MVert *mv; + MEdge *med; + const MPoly *mp; + int i; + + i = totvert; + for (mv = mvert; i--; mv++) { + mv->flag &= ~SELECT; + } + + i = totedge; + for (med = medge; i--; med++) { + med->flag &= ~SELECT; + } + + i = totpoly; + for (mp = mpoly; i--; mp++) { + /* assume if its selected its not hidden and none of its verts/edges are hidden + * (a common assumption)*/ + if (mp->flag & ME_FACE_SEL) { + MLoop *ml; + int j; + j = mp->totloop; + for (ml = &mloop[mp->loopstart]; j--; ml++) { + mvert[ml->v].flag |= SELECT; + medge[ml->e].flag |= SELECT; + } + } + } +} +void BKE_mesh_flush_select_from_polys(Mesh *me) +{ + BKE_mesh_flush_select_from_polys_ex(me->mvert, me->totvert, + me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); +} + +void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(totvert), + MLoop *mloop, + MEdge *medge, const int totedge, + MPoly *mpoly, const int totpoly) +{ + MEdge *med; + MPoly *mp; + int i; + + /* edges */ + i = totedge; + for (med = medge; i--; med++) { + if ((med->flag & ME_HIDE) == 0) { + if ((mvert[med->v1].flag & SELECT) && (mvert[med->v2].flag & SELECT)) { + med->flag |= SELECT; + } + else { + med->flag &= ~SELECT; + } + } + } + + /* polys */ + i = totpoly; + for (mp = mpoly; i--; mp++) { + if ((mp->flag & ME_HIDE) == 0) { + int ok = TRUE; + MLoop *ml; + int j; + j = mp->totloop; + for (ml = &mloop[mp->loopstart]; j--; ml++) { + if ((mvert[ml->v].flag & SELECT) == 0) { + ok = FALSE; + break; + } + } + + if (ok) { + mp->flag |= ME_FACE_SEL; + } + else { + mp->flag &= ~ME_FACE_SEL; + } + } + } +} +void BKE_mesh_flush_select_from_verts(Mesh *me) +{ + BKE_mesh_flush_select_from_verts_ex(me->mvert, me->totvert, + me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); +} + + /* basic vertex data functions */ int BKE_mesh_minmax(Mesh *me, float r_min[3], float r_max[3]) { diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 17dcf34b71f..8babdf2402f 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2162,6 +2162,24 @@ void nodeRegisterType(bNodeTreeType *ttype, bNodeType *ntype) if (found == NULL) BLI_addtail(typelist, ntype); + + /* Associate the RNA struct type with the bNodeType. + * Dynamically registered nodes will create an RNA type at runtime + * and call RNA_struct_blender_type_set, so this only needs to be done for old RNA types + * created in makesrna, which can not be associated to a bNodeType immediately, + * since bNodeTypes are registered afterward ... + */ + #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ + if (ID == ntype->type) { \ + StructRNA *srna = RNA_struct_find(STRINGIFY_ARG(Category##StructName)); \ + BLI_assert(srna != NULL); \ + RNA_struct_blender_type_set(srna, ntype); \ + } + + /* XXX hack, this file will be moved to the nodes folder in customnodes branch, + * then this stupid include path is not needed any more. + */ + #include "intern/rna_nodetree_types.h" } static void registerCompositNodes(bNodeTreeType *ttype) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f0819d426fb..d13d456a183 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1853,12 +1853,19 @@ static void ob_parbone(Object *ob, Object *par, float mat[4][4]) } /* get bone transform */ - copy_m4_m4(mat, pchan->pose_mat); + if (pchan->bone->flag & BONE_RELATIVE_PARENTING) { + /* the new option uses the root - expected bahaviour, but differs from old... */ + /* XXX check on version patching? */ + copy_m4_m4(mat, pchan->chan_mat); + } + else { + copy_m4_m4(mat, pchan->pose_mat); - /* but for backwards compatibility, the child has to move to the tail */ - copy_v3_v3(vec, mat[1]); - mul_v3_fl(vec, pchan->bone->length); - add_v3_v3(mat[3], vec); + /* but for backwards compatibility, the child has to move to the tail */ + copy_v3_v3(vec, mat[1]); + mul_v3_fl(vec, pchan->bone->length); + add_v3_v3(mat[3], vec); + } } static void give_parvert(Object *par, int nr, float vec[3]) @@ -1936,7 +1943,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) } else if (ELEM(par->type, OB_CURVE, OB_SURF)) { Curve *cu = par->data; - ListBase *nurb = BKE_curve_nurbs_get(cu);; + ListBase *nurb = BKE_curve_nurbs_get(cu); BKE_nurbList_index_get_co(nurb, nr, vec); } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 36f96045ced..fa5268e039e 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -154,7 +154,7 @@ int paint_facesel_test(Object *ob) return ( (ob != NULL) && (ob->type == OB_MESH) && (ob->data != NULL) && - (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_MASK) && + (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) ); } @@ -165,7 +165,7 @@ int paint_vertsel_test(Object *ob) return ( (ob != NULL) && (ob->type == OB_MESH) && (ob->data != NULL) && - (((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) && + (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) && (ob->mode & OB_MODE_WEIGHT_PAINT) ); } diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 3a4e8afca76..209461bad2f 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -18,7 +18,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/blenlib/intern/pbvh.c +/** \file blender/blenkernel/intern/pbvh.c * \ingroup bli */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 1c98f6c32a2..538f21ce20b 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -446,7 +446,8 @@ static Scene *scene_add(Main *bmain, const char *name) sce->r.bake_osa = 5; sce->r.bake_flag = R_BAKE_CLEAR; sce->r.bake_normal_space = R_BAKE_SPACE_TANGENT; - sce->r.bake_rays_number = 256; + sce->r.bake_samples = 256; + sce->r.bake_biasdist = 0.001; sce->r.scemode = R_DOCOMP | R_DOSEQ | R_EXTENSION; sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME; sce->r.stamp_font_id = 12; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 1467d24f323..5e44f2d6d9e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -593,8 +593,8 @@ void BKE_sequence_calc(Scene *scene, Sequence *seq) /* XXX These resets should not be necessary, but users used to be able to * edit effect's length, leading to strange results. See [#29190] */ seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0; - seq->start = seq->startdisp = MAX3(seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp); - seq->enddisp = MIN3(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp); + seq->start = seq->startdisp = max_iii(seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp); + seq->enddisp = min_iii(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp); /* we cant help if strips don't overlap, it wont give useful results. * but at least ensure 'len' is never negative which causes bad bugs elsewhere. */ if (seq->enddisp < seq->startdisp) { diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index c9cf5d561e5..629b2c989d3 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -170,7 +170,7 @@ void smoke_reallocate_fluid(SmokeDomainSettings *sds, float dx, int res[3], int if (free_old && sds->fluid) smoke_free(sds->fluid); - if (!MIN3(res[0], res[1], res[2])) { + if (!min_iii(res[0], res[1], res[2])) { sds->fluid = NULL; return; } @@ -191,7 +191,7 @@ void smoke_reallocate_highres_fluid(SmokeDomainSettings *sds, float dx, int res[ if (free_old && sds->wt) smoke_turbulence_free(sds->wt); - if (!MIN3(res[0], res[1], res[2])) { + if (!min_iii(res[0], res[1], res[2])) { sds->wt = NULL; return; } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index bb0cfe1a5c6..79356d39235 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1097,12 +1097,12 @@ static int sb_detect_face_pointCached(float face_v1[3], float face_v2[3], float float facedist, outerfacethickness, tune = 10.f; int a, deflected=0; - aabbmin[0] = MIN3(face_v1[0], face_v2[0], face_v3[0]); - aabbmin[1] = MIN3(face_v1[1], face_v2[1], face_v3[1]); - aabbmin[2] = MIN3(face_v1[2], face_v2[2], face_v3[2]); - aabbmax[0] = MAX3(face_v1[0], face_v2[0], face_v3[0]); - aabbmax[1] = MAX3(face_v1[1], face_v2[1], face_v3[1]); - aabbmax[2] = MAX3(face_v1[2], face_v2[2], face_v3[2]); + aabbmin[0] = min_fff(face_v1[0], face_v2[0], face_v3[0]); + aabbmin[1] = min_fff(face_v1[1], face_v2[1], face_v3[1]); + aabbmin[2] = min_fff(face_v1[2], face_v2[2], face_v3[2]); + aabbmax[0] = max_fff(face_v1[0], face_v2[0], face_v3[0]); + aabbmax[1] = max_fff(face_v1[1], face_v2[1], face_v3[1]); + aabbmax[2] = max_fff(face_v1[2], face_v2[2], face_v3[2]); /* calculate face normal once again SIGH */ sub_v3_v3v3(edge1, face_v1, face_v2); @@ -1196,12 +1196,12 @@ static int sb_detect_face_collisionCached(float face_v1[3], float face_v2[3], fl float t, tune = 10.0f; int a, deflected=0; - aabbmin[0] = MIN3(face_v1[0], face_v2[0], face_v3[0]); - aabbmin[1] = MIN3(face_v1[1], face_v2[1], face_v3[1]); - aabbmin[2] = MIN3(face_v1[2], face_v2[2], face_v3[2]); - aabbmax[0] = MAX3(face_v1[0], face_v2[0], face_v3[0]); - aabbmax[1] = MAX3(face_v1[1], face_v2[1], face_v3[1]); - aabbmax[2] = MAX3(face_v1[2], face_v2[2], face_v3[2]); + aabbmin[0] = min_fff(face_v1[0], face_v2[0], face_v3[0]); + aabbmin[1] = min_fff(face_v1[1], face_v2[1], face_v3[1]); + aabbmin[2] = min_fff(face_v1[2], face_v2[2], face_v3[2]); + aabbmax[0] = max_fff(face_v1[0], face_v2[0], face_v3[0]); + aabbmax[1] = max_fff(face_v1[1], face_v2[1], face_v3[1]); + aabbmax[2] = max_fff(face_v1[2], face_v2[2], face_v3[2]); hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); @@ -1957,7 +1957,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } closest_to_line_segment_v3(ve, opco, nv2, nv3); - sub_v3_v3v3(ve, opco, ve); + sub_v3_v3v3(ve, opco, ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )) { copy_v3_v3(coledge, ve); @@ -1966,7 +1966,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } closest_to_line_segment_v3(ve, opco, nv3, nv1); - sub_v3_v3v3(ve, opco, ve); + sub_v3_v3v3(ve, opco, ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )) { copy_v3_v3(coledge, ve); diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h index 6d34b0d48d5..7c8816cb58a 100644 --- a/source/blender/blenlib/BLI_array.h +++ b/source/blender/blenlib/BLI_array.h @@ -106,8 +106,8 @@ ((arr = (void *)_##arr##_static), (_##arr##_count += (num))) \ : \ /* use existing static array or allocate */ \ - ((BLI_array_totalsize(arr) >= _##arr##_count + num) ? \ - (_##arr##_count += num) : \ + (LIKELY(BLI_array_totalsize(arr) >= _##arr##_count + num) ? \ + (_##arr##_count += num) : /* UNLIKELY --> realloc */ \ ( \ (void) (_##arr##_tmp = MEM_callocN( \ sizeof(*arr) * (num < _##arr##_count ? \ diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index b9866f9c6e6..8eb6561003b 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -175,6 +175,42 @@ MINLINE int max_ii(int a, int b) return (b < a) ? a : b; } +MINLINE float min_fff(float a, float b, float c) +{ + return min_ff(min_ff(a, b), c); +} +MINLINE float max_fff(float a, float b, float c) +{ + return max_ff(max_ff(a, b), c); +} + +MINLINE int min_iii(int a, int b, int c) +{ + return min_ii(min_ii(a, b), c); +} +MINLINE int max_iii(int a, int b, int c) +{ + return max_ii(max_ii(a, b), c); +} + +MINLINE float min_ffff(float a, float b, float c, float d) +{ + return min_ff(min_fff(a, b, c), d); +} +MINLINE float max_ffff(float a, float b, float c, float d) +{ + return max_ff(max_fff(a, b, c), d); +} + +MINLINE int min_iiii(int a, int b, int c, int d) +{ + return min_ii(min_iii(a, b, c), d); +} +MINLINE int max_iiii(int a, int b, int c, int d) +{ + return max_ii(max_iii(a, b, c), d); +} + MINLINE float signf(float f) { return (f < 0.f) ? -1.f : 1.f; diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 64851dbf12c..07cd85c4107 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -266,8 +266,8 @@ void rgb_to_hsv_v(const float rgb[3], float r_hsv[3]) void rgb_to_hsl(float r, float g, float b, float *lh, float *ls, float *ll) { - float cmax = MAX3(r, g, b); - float cmin = MIN3(r, g, b); + const float cmax = max_fff(r, g, b); + const float cmin = min_fff(r, g, b); float h, s, l = (cmax + cmin) / 2.0f; if (cmax == cmin) { diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 931025606db..10a9a2df9f5 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -140,7 +140,7 @@ float area_poly_v3(int nr, float verts[][3], const float normal[3]) x = fabsf(normal[0]); y = fabsf(normal[1]); z = fabsf(normal[2]); - max = MAX3(x, y, z); + max = max_fff(x, y, z); if (max == y) py = 2; else if (max == x) { px = 1; @@ -1198,10 +1198,10 @@ int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3] return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda); /* first a simple bounding box test */ - if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0; - if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0; - if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0; - if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0; + if (min_fff(v0[a1], v1[a1], v2[a1]) > p1[a1]) return 0; + if (min_fff(v0[a2], v1[a2], v2[a2]) > p1[a2]) return 0; + if (max_fff(v0[a1], v1[a1], v2[a1]) < p1[a1]) return 0; + if (max_fff(v0[a2], v1[a2], v2[a2]) < p1[a2]) return 0; /* then a full intersection test */ #endif diff --git a/source/blender/blenloader/BLO_soundfile.h b/source/blender/blenloader/BLO_soundfile.h deleted file mode 100644 index d2f87139b74..00000000000 --- a/source/blender/blenloader/BLO_soundfile.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef __BLO_SOUNDFILE_H__ -#define __BLO_SOUNDFILE_H__ - -/** \file BLO_soundfile.h - * \ingroup blenloader - */ - -#include "DNA_sound_types.h" -#include "DNA_packedFile_types.h" - -struct bSound; -struct PackedFile; - -#endif - diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 894cd24fc4a..b55d6b679d2 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -52,7 +52,6 @@ set(SRC BLO_blend_defs.h BLO_readfile.h BLO_runtime.h - BLO_soundfile.h BLO_sys_types.h BLO_undofile.h BLO_writefile.h diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 453f35d8057..a1440386e99 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6824,9 +6824,16 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) bfd->globalf = fg->globalf; BLI_strncpy(bfd->filename, fg->filename, sizeof(bfd->filename)); - /* early 2.50 version patch - filename not in FileGlobal struct */ - if (fd->fileversion <= 250) - BLI_strncpy(bfd->filename, bfd->main->name, sizeof(bfd->main->name)); + /* error in 2.65 and older: main->name was not set if you save from startup (not after loading file) */ + if (bfd->filename[0] == 0) { + if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1)) + if ((G.fileflags & G_FILE_RECOVER)==0) + BLI_strncpy(bfd->filename, bfd->main->name, sizeof(bfd->filename)); + + /* early 2.50 version patch - filename not in FileGlobal struct at all */ + if (fd->fileversion <= 250) + BLI_strncpy(bfd->filename, bfd->main->name, sizeof(bfd->filename)); + } if (G.fileflags & G_FILE_RECOVER) BLI_strncpy(fd->relabase, fg->filename, sizeof(fd->relabase)); @@ -8087,7 +8094,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if (md->type == eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData *)md; if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { - int maxres = MAX3(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]); + int maxres = max_iii(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]); smd->domain->scale = smd->domain->dx * maxres; smd->domain->dx = 1.0f / smd->domain->scale; } @@ -8633,8 +8640,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Scene *scene; for (scene = main->scene.first; scene; scene = scene->id.next) { - if (scene->r.bake_rays_number == 0) - scene->r.bake_rays_number = 256; + if (scene->r.bake_samples == 0) + scene->r.bake_samples = 256; } } diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index 5af9690b47e..0961106f141 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -280,6 +280,6 @@ enum { * but should not error on valid cases */ #define BM_LOOP_RADIAL_MAX 10000 #define BM_NGON_MAX 100000 -#define BM_OMP_LIMIT 10000 +#define BM_OMP_LIMIT 0 /* setting zero so we can catch bugs in OpenMP/BMesh */ #endif /* __BMESH_CLASS_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index d23443daa7f..2362ae7237a 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -173,8 +173,8 @@ void BM_face_copy_shared(BMesh *bm, BMFace *f) */ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, const int create_flag) { - BMEdge **edges2 = BLI_array_alloca_and_count(edges2, len); - BMVert **verts = BLI_array_alloca_and_count(verts, len + 1); + BMEdge **edges2 = BLI_array_alloca(edges2, len); + BMVert **verts = BLI_array_alloca(verts, len + 1); int e2_index = 0; int v_index = 0; @@ -235,7 +235,7 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i e = e2; } while (e != edges[0]); - if (BLI_array_count(edges2) != len) { + if (e2_index != len) { goto err; /* we didn't use all edges in forming the boundary loop */ } @@ -296,10 +296,9 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i err: for (i = 0; i < len; i++) { BM_ELEM_API_FLAG_DISABLE(edges[i], _FLAG_MF); - /* vert count may != len */ - if (i < BLI_array_count(verts)) { - BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV); - } + } + for (i = 0; i < v_index; i++) { + BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV); } return NULL; @@ -817,6 +816,8 @@ void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *sour BMesh *BM_mesh_copy(BMesh *bm_old) { +#define USE_FAST_FACE_COPY + BMesh *bm_new; BMVert *v, *v2, **vtable = NULL; BMEdge *e, *e2, **edges = NULL, **etable = NULL; @@ -824,6 +825,10 @@ BMesh *BM_mesh_copy(BMesh *bm_old) BLI_array_declare(edges); BMLoop *l, /* *l2, */ **loops = NULL; BLI_array_declare(loops); +#ifdef USE_FAST_FACE_COPY + BMVert **verts = NULL; + BLI_array_declare(verts); +#endif BMFace *f, *f2, **ftable = NULL; BMEditSelection *ese; BMIter iter, liter; @@ -891,12 +896,24 @@ BMesh *BM_mesh_copy(BMesh *bm_old) BLI_array_grow_items(loops, f->len); BLI_array_grow_items(edges, f->len); +#ifdef USE_FAST_FACE_COPY + BLI_array_empty(verts); + BLI_array_grow_items(verts, f->len); +#endif + l = BM_iter_new(&liter, bm_old, BM_LOOPS_OF_FACE, f); for (j = 0; j < f->len; j++, l = BM_iter_step(&liter)) { loops[j] = l; edges[j] = etable[BM_elem_index_get(l->e)]; + +#ifdef USE_FAST_FACE_COPY + verts[j] = vtable[BM_elem_index_get(l->v)]; +#endif } +#ifdef USE_FAST_FACE_COPY + f2 = BM_face_create(bm_new, verts, edges, f->len, BM_CREATE_SKIP_CD); +#else v = vtable[BM_elem_index_get(loops[0]->v)]; v2 = vtable[BM_elem_index_get(loops[1]->v)]; @@ -906,6 +923,8 @@ BMesh *BM_mesh_copy(BMesh *bm_old) } f2 = BM_face_create_ngon(bm_new, v, v2, edges, f->len, BM_CREATE_SKIP_CD); +#endif + if (UNLIKELY(f2 == NULL)) { continue; } @@ -961,9 +980,12 @@ BMesh *BM_mesh_copy(BMesh *bm_old) MEM_freeN(vtable); MEM_freeN(ftable); +#ifdef USE_FAST_FACE_COPY + BLI_array_free(verts); +#endif + BLI_array_free(loops); BLI_array_free(edges); - return bm_new; } diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index b1ec4cde44b..669be315cc6 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -86,41 +86,50 @@ void BM_mesh_select_mode_flush_ex(BMesh *bm, const short selectmode) BMIter eiter; BMIter fiter; - int ok; - if (selectmode & SCE_SELECT_VERTEX) { - BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && - BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && - !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) + /* both loops only set edge/face flags and read off verts */ +#pragma omp parallel sections if (bm->totedge + bm->totface >= BM_OMP_LIMIT) + { +#pragma omp section { - BM_elem_flag_enable(e, BM_ELEM_SELECT); - } - else { - BM_elem_flag_disable(e, BM_ELEM_SELECT); + BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && + BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && + !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) + { + BM_elem_flag_enable(e, BM_ELEM_SELECT); + } + else { + BM_elem_flag_disable(e, BM_ELEM_SELECT); + } + } } - } - BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - ok = TRUE; - if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { - if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { +#pragma omp section + { + BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { + int ok = TRUE; + if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) { + ok = FALSE; + break; + } + } while ((l_iter = l_iter->next) != l_first); + } + else { ok = FALSE; - break; } - } while ((l_iter = l_iter->next) != l_first); - } - else { - ok = FALSE; - } - BM_elem_flag_set(f, BM_ELEM_SELECT, ok); + BM_elem_flag_set(f, BM_ELEM_SELECT, ok); + } + } } + /* end sections */ } else if (selectmode & SCE_SELECT_EDGE) { BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - ok = TRUE; + int ok = TRUE; if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 015c040dc95..769ede0c2ca 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -461,9 +461,6 @@ void bmesh_edit_end(BMesh *bm, int UNUSED(flag)) void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag) { - BMIter iter; - BMElem *ele; - #ifdef DEBUG BM_ELEM_INDEX_VALIDATE(bm, "Should Never Fail!", __func__); #endif @@ -474,6 +471,9 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag) { if (hflag & BM_VERT) { if (bm->elem_index_dirty & BM_VERT) { + BMIter iter; + BMElem *ele; + int index; BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, index) { BM_elem_index_set(ele, index); /* set_ok */ @@ -490,6 +490,9 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag) { if (hflag & BM_EDGE) { if (bm->elem_index_dirty & BM_EDGE) { + BMIter iter; + BMElem *ele; + int index; BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, index) { BM_elem_index_set(ele, index); /* set_ok */ @@ -506,6 +509,9 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag) { if (hflag & BM_FACE) { if (bm->elem_index_dirty & BM_FACE) { + BMIter iter; + BMElem *ele; + int index; BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, index) { BM_elem_index_set(ele, index); /* set_ok */ diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index bf3bafc57fb..956d9e5767e 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -51,28 +51,35 @@ enum { void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) { + BMVert **verts = NULL; + BLI_array_declare(verts); + BMEdge **edges = NULL; + BLI_array_declare(edges); + BMOIter siter; BMIter liter, liter2; BMFace *f, *f2, *f3; BMLoop *l, *l2, *l3, *l4, *l_tmp; - BMEdge **edges = NULL, *e, *laste; + BMEdge *e, *laste; BMVert *v, *lastv, *firstv; - BLI_array_declare(edges); int i; BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) { + BLI_array_empty(verts); BLI_array_empty(edges); + BLI_array_grow_items(verts, f->len); BLI_array_grow_items(edges, f->len); i = 0; firstv = lastv = NULL; BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { v = BM_vert_create(bm, l->v->co, l->v, 0); - /* skip on the first iteration */ if (lastv) { e = BM_edge_create(bm, lastv, v, l->e, 0); - edges[i++] = e; + edges[i] = e; + verts[i] = lastv; + i++; } lastv = v; @@ -82,11 +89,13 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) /* this fits in the array because we skip one in the loop above */ e = BM_edge_create(bm, v, firstv, laste, 0); - edges[i++] = e; + edges[i] = e; + verts[i] = lastv; + i++; BMO_elem_flag_enable(bm, f, EXT_DEL); - f2 = BM_face_create_ngon(bm, firstv, BM_edge_other_vert(edges[0], firstv), edges, f->len, 0); + f2 = BM_face_create(bm, verts, edges, f->len, 0); if (UNLIKELY(f2 == NULL)) { BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Extrude failed: could not create face"); BLI_array_free(edges); @@ -117,6 +126,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) } } + BLI_array_free(verts); BLI_array_free(edges); BMO_op_callf(bm, op->flag, diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index cc472e4a501..fbac538eb7f 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -269,7 +269,11 @@ static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, const int totv, BMF for (i = 0; i < totv; i++) { ee[i] = BM_edge_create(bm, vert_arr[i], vert_arr[(i + 1) % totv], NULL, BM_CREATE_NO_DOUBLE); } +#if 0 f = BM_face_create_ngon(bm, vert_arr[0], vert_arr[1], ee, totv, 0); +#else + f = BM_face_create(bm, vert_arr, ee, totv, 0); +#endif } if (facerep && f) { int has_mdisps = CustomData_has_layer(&bm->ldata, CD_MDISPS); diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index d2c6c833e2e..fb996f2abaf 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -204,10 +204,10 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input } #define UPDATE_INPUT { \ - newInput.xmin = MIN4(newInput.xmin, coords[0], coords[2], coords[4]); \ - newInput.ymin = MIN4(newInput.ymin, coords[1], coords[3], coords[5]); \ - newInput.xmax = MAX4(newInput.xmax, coords[0], coords[2], coords[4]); \ - newInput.ymax = MAX4(newInput.ymax, coords[1], coords[3], coords[5]); \ + newInput.xmin = min_ffff(newInput.xmin, coords[0], coords[2], coords[4]); \ + newInput.ymin = min_ffff(newInput.ymin, coords[1], coords[3], coords[5]); \ + newInput.xmax = max_ffff(newInput.xmax, coords[0], coords[2], coords[4]); \ + newInput.ymax = max_ffff(newInput.ymax, coords[1], coords[3], coords[5]); \ } (void)0 rcti newInput; @@ -273,7 +273,7 @@ void ScreenLensDistortionOperation::updateVariables(float distortion, float disp const float d = 0.25f * max_ff(min_ff(dispersion, 1.0f), 0.0f); this->m_kr = max_ff(min_ff((this->m_kg + d), 1.0f), -0.999f); this->m_kb = max_ff(min_ff((this->m_kg - d), 1.0f), -0.999f); - this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb); + this->m_maxk = max_fff(this->m_kr, this->m_kg, this->m_kb); this->m_sc = (this->m_data->fit && (this->m_maxk > 0.0f)) ? (1.0f / (1.0f + 2.0f * this->m_maxk)) : (1.0f / (1.0f + this->m_maxk)); this->m_drg = 4.0f * (this->m_kg - this->m_kr); diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp index 8b5288321c1..e647ae975ff 100644 --- a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp +++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp @@ -42,7 +42,7 @@ TrackPositionOperation::TrackPositionOperation() : NodeOperation() this->m_trackingObjectName[0] = 0; this->m_trackName[0] = 0; this->m_axis = 0; - this->m_position = POSITION_ABSOLUTE;; + this->m_position = POSITION_ABSOLUTE; this->m_relativeFrame = 0; } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 23d35c80409..37fd05f75a5 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -293,7 +293,7 @@ static short nlaedit_get_context(bAnimContext *ac, SpaceNla *snla) short ANIM_animdata_context_getdata(bAnimContext *ac) { SpaceLink *sl = ac->sl; - short ok = 0; + short ok = FALSE; /* context depends on editor we are currently in */ if (sl) { @@ -322,10 +322,7 @@ short ANIM_animdata_context_getdata(bAnimContext *ac) } /* check if there's any valid data */ - if (ok && ac->data) - return 1; - else - return 0; + return (ok && ac->data); } /* Obtain current anim-data context from Blender Context info @@ -357,6 +354,7 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) ac->regiontype = (ar) ? ar->regiontype : 0; /* get data context info */ + // XXX: if the below fails, try to grab this info from context instead... (to allow for scripting) return ANIM_animdata_context_getdata(ac); } @@ -931,14 +929,14 @@ static short skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_i Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq = NULL; char *seq_name; - + if (ed) { /* get strip name, and check if this strip is selected */ seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all["); seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, FALSE); if (seq_name) MEM_freeN(seq_name); } - + /* can only add this F-Curve if it is selected */ if (ads->filterflag & ADS_FILTER_ONLYSEL) { if ((seq == NULL) || (seq->flag & SELECT) == 0) @@ -2214,7 +2212,7 @@ static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_d if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) { tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)sce, ntree, filter_mode); } - + #ifdef WITH_FREESTYLE /* line styles */ if ((ads->filterflag & ADS_FILTER_NOLINESTYLE) == 0) { diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 79a4c9a769d..6bd774e084a 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -151,7 +151,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s } else { /* basic size (just "x") */ - maxXWidth = 15; + maxXWidth = UI_GetStringWidth("x") + 10; } /* draw controls for each coefficient and a + sign at end of row */ @@ -231,16 +231,16 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 100, 20, cp + 1, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, TIP_("Second coefficient")); - /* closing bracket and '+' sign */ + /* closing bracket and multiplication sign */ if ( (i != (data->poly_order - 1)) || ((i == 0) && data->poly_order == 2) ) { - uiDefBut(block, LABEL, 1, ") +", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 1, ") ×", 0, 0, 40, 20, NULL, 0.0, 0.0, 0, 0, ""); /* set up new row for the next pair of coefficients */ row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); } else - uiDefBut(block, LABEL, 1, ")", 0, 0, 20, 20, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 1, ") ", 0, 0, 40, 20, NULL, 0.0, 0.0, 0, 0, ""); } } break; diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index ffe58be0139..ae405c0e113 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -2256,6 +2256,7 @@ void undo_push_armature(bContext *C, const char *name) /* *************** Adding stuff in editmode *************** */ /* default bone add, returns it selected, but without tail set */ +/* XXX should be used everywhere, now it mallocs bones still locally in functions */ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) { EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); @@ -2265,7 +2266,7 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) BLI_addtail(arm->edbo, bone); - bone->flag |= BONE_TIPSEL; + bone->flag |= BONE_TIPSEL | BONE_RELATIVE_PARENTING; bone->weight = 1.0f; bone->dist = 0.25f; bone->xwidth = 0.1f; @@ -3410,7 +3411,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) copy_v3_v3(newbone->tail, newbone->head); newbone->parent = ebone; - newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone + newbone->flag = ebone->flag & (BONE_TIPSEL | BONE_RELATIVE_PARENTING); // copies it, in case mirrored bone if (newbone->parent) newbone->flag |= BONE_CONNECTED; } @@ -3419,7 +3420,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) copy_v3_v3(newbone->tail, ebone->head); newbone->parent = ebone->parent; - newbone->flag = BONE_TIPSEL; + newbone->flag = BONE_TIPSEL | BONE_RELATIVE_PARENTING; if (newbone->parent && (ebone->flag & BONE_CONNECTED)) { newbone->flag |= BONE_CONNECTED; diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 5376c897c29..2848db18d59 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -666,8 +666,8 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, *err_str = NULL; /* count triangles and create mask */ - if ((use_face_sel = ((me->editflag & ME_EDIT_PAINT_MASK) != 0)) || - (use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0))) + if ((use_face_sel = ((me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0)) || + (use_vert_sel = ((me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0))) { mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask"); diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index ae3d496b641..04815b9c33c 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -687,9 +687,6 @@ static int poselib_rename_exec(bContext *C, wmOperator *op) void POSELIB_OT_pose_rename(wmOperatorType *ot) { PropertyRNA *prop; - static EnumPropertyItem prop_poses_dummy_types[] = { - {0, NULL, 0, NULL, NULL} - }; /* identifiers */ ot->name = "PoseLib Rename Pose"; @@ -707,7 +704,7 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot) /* properties */ /* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */ ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose"); - prop = RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename"); + prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to rename"); RNA_def_enum_funcs(prop, poselib_stored_pose_itemf); } diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index b1bf13db69b..1b5c550df11 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -634,7 +634,7 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end if (aDst->bcount > 0 && aSrc->bcount > 0) { int indexDst = 0, indexSrc = 0; - start = MAX3(start, aDst->buckets[0].val, aSrc->buckets[0].val); + start = max_fff(start, aDst->buckets[0].val, aSrc->buckets[0].val); while (indexDst < aDst->bcount && aDst->buckets[indexDst].val < start) { indexDst++; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index f4dccd01007..53e610401b7 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1022,13 +1022,12 @@ static int curve_is_animated(Curve *cu) return ad && (ad->action || ad->drivers.first); } -static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char *rna_path, ListBase *orig_curves, ListBase *curves) +static void fcurve_path_rename(AnimData *adt, char *orig_rna_path, char *rna_path, ListBase *orig_curves, ListBase *curves) { FCurve *fcu, *nfcu, *nextfcu; int len = strlen(orig_rna_path); - fcu = orig_curves->first; - while (fcu) { + for (fcu = orig_curves->first; fcu; fcu = nextfcu) { nextfcu = fcu->next; if (!strncmp(fcu->rna_path, orig_rna_path, len)) { char *spath, *suffix = fcu->rna_path + len; @@ -1038,26 +1037,25 @@ static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char *rna_path BLI_addtail(curves, nfcu); if (fcu->grp) { - action_groups_remove_channel(ad->action, fcu); - action_groups_add_channel(ad->action, fcu->grp, nfcu); + action_groups_remove_channel(adt->action, fcu); + action_groups_add_channel(adt->action, fcu->grp, nfcu); } - else if (ad->action && &ad->action->curves == orig_curves) - BLI_remlink(&ad->action->curves, fcu); + else if ((adt->action) && (&adt->action->curves == orig_curves)) + BLI_remlink(&adt->action->curves, fcu); else - BLI_remlink(&ad->drivers, fcu); + BLI_remlink(&adt->drivers, fcu); free_fcurve(fcu); MEM_freeN(spath); } - fcu = nextfcu; } } -static void fcurve_remove(AnimData *ad, ListBase *orig_curves, FCurve *fcu) +static void fcurve_remove(AnimData *adt, ListBase *orig_curves, FCurve *fcu) { - if (orig_curves == &ad->drivers) BLI_remlink(&ad->drivers, fcu); - else action_groups_remove_channel(ad->action, fcu); + if (orig_curves == &adt->drivers) BLI_remlink(&adt->drivers, fcu); + else action_groups_remove_channel(adt->action, fcu); free_fcurve(fcu); } @@ -1073,7 +1071,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) ListBase curves = {NULL, NULL}; FCurve *fcu, *next; - while (nu) { + for (nu = editnurb->nurbs.first, nu_index = 0; nu != NULL; nu = nu->next, nu_index++) { if (nu->bezt) { BezTriple *bezt = nu->bezt; a = nu->pntsu; @@ -1126,8 +1124,6 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) pt_index++; } } - nu = nu->next; - nu_index++; } /* remove paths for removed control points @@ -1144,9 +1140,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) } } - nu_index = 0; - nu = editnurb->nurbs.first; - while (nu) { + for (nu = editnurb->nurbs.first, nu_index = 0; nu != NULL; nu = nu->next, nu_index++) { keyIndex = NULL; if (nu->pntsu) { if (nu->bezt) keyIndex = getCVKeyIndex(editnurb, &nu->bezt[0]); @@ -1158,9 +1152,6 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d]", keyIndex->nu_index); fcurve_path_rename(adt, orig_rna_path, rna_path, orig_curves, &curves); } - - nu_index++; - nu = nu->next; } /* the remainders in orig_curves can be copied back (like follow path) */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 8ca7d5a023e..f7f58a4ee7a 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -114,10 +114,11 @@ typedef enum { V3D_PROJ_TEST_NOP = 0, V3D_PROJ_TEST_CLIP_BB = (1 << 0), V3D_PROJ_TEST_CLIP_WIN = (1 << 1), + V3D_PROJ_TEST_CLIP_NEAR = (1 << 2), } eV3DProjTest; -#define V3D_PROJ_TEST_CLIP_DEFAULT (V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) -#define V3D_PROJ_TEST_ALL (V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) +#define V3D_PROJ_TEST_CLIP_DEFAULT (V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) +#define V3D_PROJ_TEST_ALL (V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) /* view3d_iterators.c */ diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index bbc9ca3502d..b32bc1c2815 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -292,6 +292,9 @@ void UI_SetTheme(int spacetype, int regionid); // get current theme struct bTheme *UI_GetTheme(void); +// return shadow width outside menus and popups */ +int UI_ThemeMenuShadowWidth(void); + /* only for buttons in theme editor! */ const unsigned char *UI_ThemeGetColorPtr(struct bTheme *btheme, int spacetype, int colorid); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 807f5279821..25f85883d9c 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1291,7 +1291,7 @@ void ui_delete_linkline(uiLinkLine *line, uiBut *but) void ui_get_but_vectorf(uiBut *but, float vec[3]) { PropertyRNA *prop; - int a, tot; + int a; if (but->editvec) { copy_v3_v3(vec, but->editvec); @@ -1300,18 +1300,25 @@ void ui_get_but_vectorf(uiBut *but, float vec[3]) if (but->rnaprop) { prop = but->rnaprop; - vec[0] = vec[1] = vec[2] = 0.0f; + zero_v3(vec); if (RNA_property_type(prop) == PROP_FLOAT) { - tot = RNA_property_array_length(&but->rnapoin, prop); - tot = min_ii(tot, 3); - - for (a = 0; a < tot; a++) - vec[a] = RNA_property_float_get_index(&but->rnapoin, prop, a); + int tot = RNA_property_array_length(&but->rnapoin, prop); + BLI_assert(tot > 0); + if (tot == 3) { + RNA_property_float_get_array(&but->rnapoin, prop, vec); + } + else { + tot = min_ii(tot, 3); + for (a = 0; a < tot; a++) { + vec[a] = RNA_property_float_get_index(&but->rnapoin, prop, a); + } + } } } else if (but->pointype == UI_BUT_POIN_CHAR) { char *cp = (char *)but->poin; + vec[0] = ((float)cp[0]) / 255.0f; vec[1] = ((float)cp[1]) / 255.0f; vec[2] = ((float)cp[2]) / 255.0f; @@ -1322,8 +1329,8 @@ void ui_get_but_vectorf(uiBut *but, float vec[3]) } else { if (but->editvec == NULL) { - fprintf(stderr, "ui_get_but_vectorf: can't get color, should never happen\n"); - vec[0] = vec[1] = vec[2] = 0.0f; + fprintf(stderr, "%s: can't get color, should never happen\n", __func__); + zero_v3(vec); } } @@ -1349,10 +1356,15 @@ void ui_set_but_vectorf(uiBut *but, const float vec[3]) int a; tot = RNA_property_array_length(&but->rnapoin, prop); - tot = min_ii(tot, 3); - - for (a = 0; a < tot; a++) { - RNA_property_float_set_index(&but->rnapoin, prop, a, vec[a]); + BLI_assert(tot > 0); + if (tot == 3) { + RNA_property_float_set_array(&but->rnapoin, prop, vec); + } + else { + tot = min_ii(tot, 3); + for (a = 0; a < tot; a++) { + RNA_property_float_set_index(&but->rnapoin, prop, a, vec[a]); + } } } } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 86fed3c2760..fed84092133 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1208,30 +1208,37 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, /* RGB triple */ else if (but->type == COLOR) { - float rgb[3]; + float rgba[4]; if (but->poin == NULL && but->rnapoin.data == NULL) { /* pass */ } else if (mode == 'c') { - - ui_get_but_vectorf(but, rgb); + if (RNA_property_array_length(&but->rnapoin, but->rnaprop) == 4) + rgba[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3); + else + rgba[3] = 1.0f; + + ui_get_but_vectorf(but, rgba); /* convert to linear color to do compatible copy between gamma and non-gamma */ if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - srgb_to_linearrgb_v3_v3(rgb, rgb); + srgb_to_linearrgb_v3_v3(rgba, rgba); - BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f]", rgb[0], rgb[1], rgb[2]); + BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f, %f]", rgba[0], rgba[1], rgba[2], rgba[3]); WM_clipboard_text_set(buf, 0); } else { - if (sscanf(buf, "[%f, %f, %f]", &rgb[0], &rgb[1], &rgb[2]) == 3) { + if (sscanf(buf, "[%f, %f, %f, %f]", &rgba[0], &rgba[1], &rgba[2], &rgba[3]) == 4) { /* assume linear colors in buffer */ if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - linearrgb_to_srgb_v3_v3(rgb, rgb); + linearrgb_to_srgb_v3_v3(rgba, rgba); button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - ui_set_but_vectorf(but, rgb); + ui_set_but_vectorf(but, rgba); + if (RNA_property_array_length(&but->rnapoin, but->rnaprop) == 4) + RNA_property_float_set_index(&but->rnapoin, but->rnaprop, 3, rgba[3]); + button_activate_state(C, but, BUTTON_STATE_EXIT); } } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 2dc77e96678..2928a5607c0 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -467,7 +467,10 @@ static void init_brush_icons(void) bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_ ##name## _png, \ datatoc_ ##name## _png_size, \ IB_rect, NULL, "<brush icon>"); \ - def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \ + if (bbuf) { \ + IMB_premultiply_alpha(bbuf); \ + def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \ + } \ IMB_freeImBuf(bbuf); \ } (void)0 /* end INIT_BRUSH_ICON */ @@ -537,10 +540,14 @@ static void init_internal_icons(void) if (b16buf == NULL) b16buf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons16_png, datatoc_blender_icons16_png_size, IB_rect, NULL, "<blender icons>"); + if (b16buf) + IMB_premultiply_alpha(b16buf); if (b32buf == NULL) b32buf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons32_png, datatoc_blender_icons32_png_size, IB_rect, NULL, "<blender icons>"); + if (b32buf) + IMB_premultiply_alpha(b32buf); if (b16buf && b32buf) { /* free existing texture if any */ @@ -940,8 +947,8 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy { float x1, x2, y1, y2; - if (rgb) glColor4f(rgb[0], rgb[1], rgb[2], alpha); - else glColor4f(1.0f, 1.0f, 1.0f, alpha); + if (rgb) glColor4f(alpha*rgb[0], rgb[1], rgb[2], alpha); + else glColor4f(alpha, alpha, alpha, alpha); x1 = ix * icongltex.invw; x2 = (ix + ih) * icongltex.invw; @@ -951,6 +958,9 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, icongltex.id); + /* sharper downscaling, has no effect when scale matches with a mip level */ + glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, -0.5f); + glBegin(GL_QUADS); glTexCoord2f(x1, y1); glVertex2f(x, y); @@ -965,6 +975,8 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy glVertex2f(x, y + h); glEnd(); + glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0.0f); + glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); } @@ -986,7 +998,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al Icon *icon = NULL; DrawInfo *di = NULL; IconImage *iimg; - float fdraw_size = draw_size; + const float fdraw_size = (float)draw_size; int w, h; icon = BKE_icon_get(icon_id); @@ -1017,8 +1029,11 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al di->data.vector.func((int)x, (int)y, ICON_DEFAULT_HEIGHT, ICON_DEFAULT_HEIGHT, 1.0f); } else if (di->type == ICON_TYPE_TEXTURE) { + /* texture image use premul alpha for correct scaling */ + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y, di->data.texture.w, di->data.texture.h, alpha, rgb); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } else if (di->type == ICON_TYPE_BUFFER) { /* it is a builtin icon */ @@ -1026,7 +1041,9 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al if (!iimg->rect) return; /* something has gone wrong! */ + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } else if (di->type == ICON_TYPE_PREVIEW) { PreviewImage *pi = BKE_previewimg_get((ID *)icon->obj); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 5f7ed644894..5b6a609e4d2 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -133,8 +133,6 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa) if (sbuts->re_align || sbuts->mainbo != sbuts->mainb) return 1; } - else if (ar->regiontype == RGN_TYPE_UI) - return 1; else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) return 1; else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) @@ -917,6 +915,7 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y) /* re-align, possibly with animation */ if (panels_re_align(sa, ar, &pa)) { + /* XXX code never gets here... PNL_ANIM_ALIGN flag is never set */ if (pa) panel_activate_state(C, pa, PANEL_STATE_ANIMATION); else @@ -1066,7 +1065,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in ED_region_tag_redraw(ar); } else { /* collapse */ - if(ctrl) + if (ctrl) panels_collapse_all(sa, ar, block->panel); if (block->panel->flag & PNL_CLOSED) { @@ -1150,7 +1149,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) } /* XXX hardcoded key warning */ - if (inside && event->val == KM_PRESS) { + if ((inside || inside_header) && event->val == KM_PRESS) { if (event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) { if (pa->flag & PNL_CLOSEDY) { @@ -1160,6 +1159,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) else ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl); + retval = WM_UI_HANDLER_BREAK; continue; } } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 60885f311ca..57c126c31c5 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -73,8 +73,6 @@ #include "interface_intern.h" #define B_NOP -1 -#define MENU_SHADOW_SIDE 8 -#define MENU_SHADOW_BOTTOM 10 #define MENU_TOP 8 /*********************** Menu Data Parsing ********************* */ @@ -693,16 +691,20 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) } /* widget rect, in region coords */ - data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = BLI_rcti_size_x(&rect_i) + MENU_SHADOW_SIDE; - data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = BLI_rcti_size_y(&rect_i) + MENU_SHADOW_BOTTOM; - - /* region bigger for shadow */ - ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; - ar->winrct.xmax = rect_i.xmax + MENU_SHADOW_SIDE; - ar->winrct.ymin = rect_i.ymin - MENU_SHADOW_BOTTOM; - ar->winrct.ymax = rect_i.ymax + MENU_TOP; + { + int width = UI_ThemeMenuShadowWidth(); + + data->bbox.xmin = width; + data->bbox.xmax = BLI_rcti_size_x(&rect_i) + width; + data->bbox.ymin = width; + data->bbox.ymax = BLI_rcti_size_y(&rect_i) + width; + + /* region bigger for shadow */ + ar->winrct.xmin = rect_i.xmin - width; + ar->winrct.xmax = rect_i.xmax + width; + ar->winrct.ymin = rect_i.ymin - width; + ar->winrct.ymax = rect_i.ymax + MENU_TOP; + } /* adds subwindow */ ED_region_init(C, ar); @@ -1140,16 +1142,17 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) /* compute position */ if (but->block->flag & UI_BLOCK_SEARCH_MENU) { + int width = UI_ThemeMenuShadowWidth(); /* this case is search menu inside other menu */ /* we copy region size */ ar->winrct = butregion->winrct; /* widget rect, in region coords */ - data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = BLI_rcti_size_x(&ar->winrct) - MENU_SHADOW_SIDE; - data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = BLI_rcti_size_y(&ar->winrct) - MENU_SHADOW_BOTTOM; + data->bbox.xmin = width; + data->bbox.xmax = BLI_rcti_size_x(&ar->winrct) - width; + data->bbox.ymin = width; + data->bbox.ymax = BLI_rcti_size_y(&ar->winrct) - width; /* check if button is lower half */ if (but->rect.ymax < BLI_rctf_cent_y(&but->block->rect)) { @@ -1161,6 +1164,8 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) } else { const int searchbox_width = uiSearchBoxWidth(); + const int shadow_width = UI_ThemeMenuShadowWidth(); + rect_fl.xmin = but->rect.xmin - 5; /* align text with button */ rect_fl.xmax = but->rect.xmax + 5; /* symmetrical */ rect_fl.ymax = but->rect.ymin; @@ -1212,15 +1217,15 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) } /* widget rect, in region coords */ - data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = BLI_rcti_size_x(&rect_i) + MENU_SHADOW_SIDE; - data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = BLI_rcti_size_y(&rect_i) + MENU_SHADOW_BOTTOM; + data->bbox.xmin = shadow_width; + data->bbox.xmax = BLI_rcti_size_x(&rect_i) + shadow_width; + data->bbox.ymin = shadow_width; + data->bbox.ymax = BLI_rcti_size_y(&rect_i) + shadow_width; /* region bigger for shadow */ - ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; - ar->winrct.xmax = rect_i.xmax + MENU_SHADOW_SIDE; - ar->winrct.ymin = rect_i.ymin - MENU_SHADOW_BOTTOM; + ar->winrct.xmin = rect_i.xmin - shadow_width; + ar->winrct.xmax = rect_i.xmax + shadow_width; + ar->winrct.ymin = rect_i.ymin - shadow_width; ar->winrct.ymax = rect_i.ymax; } @@ -1522,6 +1527,7 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar) static void ui_popup_block_clip(wmWindow *window, uiBlock *block) { + int width = UI_ThemeMenuShadowWidth(); int winx, winy; if (block->flag & UI_BLOCK_NO_WIN_CLIP) { @@ -1532,13 +1538,13 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block) winy = WM_window_pixels_y(window); // wm_window_get_size(window, &winx, &winy); - if (block->rect.xmin < MENU_SHADOW_SIDE) - block->rect.xmin = MENU_SHADOW_SIDE; - if (block->rect.xmax > winx - MENU_SHADOW_SIDE) - block->rect.xmax = winx - MENU_SHADOW_SIDE; + if (block->rect.xmin < width) + block->rect.xmin = width; + if (block->rect.xmax > winx - width) + block->rect.xmax = winx - width; - if (block->rect.ymin < MENU_SHADOW_BOTTOM) - block->rect.ymin = MENU_SHADOW_BOTTOM; + if (block->rect.ymin < width) + block->rect.ymin = width; if (block->rect.ymax > winy - MENU_TOP) block->rect.ymax = winy - MENU_TOP; } @@ -1590,6 +1596,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut uiBlock *block; uiPopupBlockHandle *handle; uiSafetyRct *saferct; + int width = UI_ThemeMenuShadowWidth(); /* create handle */ handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle"); @@ -1658,9 +1665,9 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut /* the block and buttons were positioned in window space as in 2.4x, now * these menu blocks are regions so we bring it back to region space. * additionally we add some padding for the menu shadow or rounded menus */ - ar->winrct.xmin = block->rect.xmin - MENU_SHADOW_SIDE; - ar->winrct.xmax = block->rect.xmax + MENU_SHADOW_SIDE; - ar->winrct.ymin = block->rect.ymin - MENU_SHADOW_BOTTOM; + ar->winrct.xmin = block->rect.xmin - width; + ar->winrct.xmax = block->rect.xmax + width; + ar->winrct.ymin = block->rect.ymin - width; ar->winrct.ymax = block->rect.ymax + MENU_TOP; ui_block_translate(block, -ar->winrct.xmin, -ar->winrct.ymin); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index e5b26148be5..4687647223a 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -261,7 +261,7 @@ static int round_box_shadow_edges(float (*vert)[2], const rcti *rect, float rad, if (2.0f * rad > BLI_rcti_size_y(rect)) rad = 0.5f * BLI_rcti_size_y(rect); - + minx = rect->xmin - step; miny = rect->ymin - step; maxx = rect->xmax + step; @@ -871,7 +871,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, const rcti aspect = but->block->aspect / UI_DPI_FAC; height = ICON_DEFAULT_HEIGHT / aspect; - + /* calculate blend color */ if (ELEM4(but->type, TOG, ROW, TOGN, LISTROW)) { if (but->flag & UI_SELECT) {} @@ -915,6 +915,12 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, const rcti ys = (rect->ymin + rect->ymax - height) / 2.0f; } + /* force positions to integers, for zoom levels near 1. draws icons crisp. */ + if (aspect > 0.95f && aspect < 1.05f) { + xs = (int)(xs + 0.1f); + ys = (int)(ys + 0.1f); + } + /* to indicate draggable */ if (but->dragpoin && (but->flag & UI_ACTIVE)) { float rgb[3] = {1.25f, 1.25f, 1.25f}; @@ -1793,13 +1799,19 @@ static void widget_state_menu_item(uiWidgetType *wt, int state) /* ************ menu backdrop ************************* */ /* outside of rect, rad to left/bottom/right */ -static void widget_softshadow(const rcti *rect, int roundboxalign, const float radin, const float radout) +static void widget_softshadow(const rcti *rect, int roundboxalign, const float radin) { + bTheme *btheme = UI_GetTheme(); uiWidgetBase wtb; rcti rect1 = *rect; - float alpha, alphastep; + float alphastep; int step, totvert; - float quad_strip[WIDGET_SIZE_MAX * 2][2]; + float quad_strip[WIDGET_SIZE_MAX * 2 + 2][2]; + const float radout = UI_ThemeMenuShadowWidth(); + + /* disabled shadow */ + if (radout == 0.0f) + return; /* prevent tooltips to not show round shadow */ if (radout > 0.2f * BLI_rcti_size_y(&rect1)) @@ -1810,24 +1822,22 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r /* inner part */ totvert = round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f); - /* inverse linear shadow alpha */ - alpha = 0.15f; - if (U.pixelsize > 1.0f) - alphastep = 0.78f; - else - alphastep = 0.67f; + /* we draw a number of increasing size alpha quad strips */ + alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout; glEnableClientState(GL_VERTEX_ARRAY); - for (step = 1; step <= radout; step++, alpha *= alphastep) { + for (step = 1; step <= (int)radout; step++) { + float expfac = sqrt(step / radout); + round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step); - glColor4f(0.0f, 0.0f, 0.0f, alpha); + glColor4f(0.0f, 0.0f, 0.0f, alphastep * (1.0f - expfac)); - widget_verts_to_quad_strip_open(&wtb, totvert, quad_strip); + widget_verts_to_quad_strip(&wtb, totvert, quad_strip); glVertexPointer(2, GL_FLOAT, 0, quad_strip); - glDrawArrays(GL_QUAD_STRIP, 0, totvert * 2); + glDrawArrays(GL_QUAD_STRIP, 0, totvert * 2 + 2); } glDisableClientState(GL_VERTEX_ARRAY); @@ -1855,7 +1865,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir } glEnable(GL_BLEND); - widget_softshadow(rect, roundboxalign, 0.25f * U.widget_unit, 0.4f * U.widget_unit); + widget_softshadow(rect, roundboxalign, 0.25f * U.widget_unit); round_box_edges(&wtb, roundboxalign, rect, 0.25f * U.widget_unit); wtb.emboss = 0; @@ -3403,7 +3413,7 @@ void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) uiWidgetType *wt = widget_type(UI_WTYPE_BOX); glEnable(GL_BLEND); - widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit, 0.4f * U.widget_unit); + widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit); glDisable(GL_BLEND); wt->state(wt, 0); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 20d7277a94d..fd84c1fd4c4 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -683,6 +683,9 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255); rgba_char_args_set(btheme->tui.zaxis, 0, 0, 220, 255); + btheme->tui.menu_shadow_fac = 0.5f; + btheme->tui.menu_shadow_width = 12; + /* Bone Color Sets */ ui_theme_init_boneColorSets(btheme); @@ -1269,6 +1272,12 @@ void UI_ThemeClearColor(int colorid) glClearColor(col[0], col[1], col[2], 0.0); } +int UI_ThemeMenuShadowWidth(void) +{ + bTheme *btheme = UI_GetTheme(); + return (int)(btheme->tui.menu_shadow_width * UI_DPI_FAC); +} + void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis) { unsigned char col[3]; @@ -2086,6 +2095,17 @@ void init_userdef_do_versions(void) } } + if (bmain->versionfile < 266) { + bTheme *btheme; + + for (btheme = U.themes.first; btheme; btheme = btheme->next) { + /* rna definition limits fac to 0.01 */ + if (btheme->tui.menu_shadow_fac == 0.0f) { + btheme->tui.menu_shadow_fac = 0.5f; + btheme->tui.menu_shadow_width = 12; + } + } + } if (U.pixelsize == 0.0f) U.pixelsize = 1.0f; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 306b328b431..190d90b3c36 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1151,7 +1151,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, pixels = (float)BLI_rcti_size_x(&v2d->mask); if (pixels != 0.0f) { - grid->dx = (U.v2d_min_gridsize * U.pixelsize * space) / (seconddiv * pixels); + grid->dx = (U.v2d_min_gridsize * UI_DPI_FAC * space) / (seconddiv * pixels); step_to_grid(&grid->dx, &grid->powerx, xunits); grid->dx *= seconddiv; } @@ -1168,7 +1168,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, space = BLI_rctf_size_y(&v2d->cur); pixels = (float)winy; - grid->dy = U.v2d_min_gridsize * U.pixelsize * space / pixels; + grid->dy = U.v2d_min_gridsize * UI_DPI_FAC * space / pixels; step_to_grid(&grid->dy, &grid->powery, yunits); if (yclamp == V2D_GRID_CLAMP) { @@ -1213,7 +1213,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) vec2[1] = v2d->cur.ymax; /* minor gridlines */ - step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * U.pixelsize); + step = (BLI_rcti_size_x(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC); UI_ThemeColor(TH_GRID); for (a = 0; a < step; a++) { @@ -1247,7 +1247,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) vec1[0] = grid->startx; vec2[0] = v2d->cur.xmax; - step = (BLI_rcti_size_y(&v2d->mask) + 1) / (U.v2d_min_gridsize * U.pixelsize); + step = (BLI_rcti_size_y(&v2d->mask) + 1) / (U.v2d_min_gridsize * UI_DPI_FAC); UI_ThemeColor(TH_GRID); for (a = 0; a <= step; a++) { diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 48a1f8bf0f3..006644bf366 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1015,12 +1015,12 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* x-axis transform */ dist = BLI_rcti_size_x(&v2d->mask) / 2.0f; - dx = 1.0f - (fabsf(vzd->lastx - dist) + 2.0f) / (fabsf(event->x - dist) + 2.0f); + dx = 1.0f - (fabsf(vzd->lastx - vzd->ar->winrct.xmin - dist) + 2.0f) / (fabsf(event->mval[0] - dist) + 2.0f); dx *= 0.5f * BLI_rctf_size_x(&v2d->cur); /* y-axis transform */ dist = BLI_rcti_size_y(&v2d->mask) / 2.0f; - dy = 1.0f - (fabsf(vzd->lasty - dist) + 2.0f) / (fabsf(event->y - dist) + 2.0f); + dy = 1.0f - (fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist) + 2.0f) / (fabsf(event->mval[1] - dist) + 2.0f); dy *= 0.5f * BLI_rctf_size_y(&v2d->cur); } else { @@ -1034,18 +1034,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* y-axis transform */ fac = 0.01f * (event->y - vzd->lasty); dy = fac * BLI_rctf_size_y(&v2d->cur); -#if 0 - /* continuous zoom shouldn't move that fast... */ - if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop? - double time = PIL_check_seconds_timer(); - float time_step = (float)(time - vzd->timer_lastdraw); - - dx /= (0.1f / time_step); - dy /= (0.1f / time_step); - - vzd->timer_lastdraw = time; - } -#endif + } /* set transform amount, and add current deltas to stored total delta (for redo) */ diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 05f2269c359..29139c5154f 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -27,12 +27,9 @@ * \ingroup edmesh */ -#include <math.h> -#include <string.h> #include "MEM_guardedalloc.h" -#include "BLI_utildefines.h" #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_edgehash.h" @@ -41,9 +38,7 @@ #include "IMB_imbuf.h" #include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" #include "DNA_object_types.h" -#include "DNA_scene_types.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" @@ -61,7 +56,6 @@ #include "WM_types.h" /* own include */ -#include "mesh_intern.h" /* copy the face flags, most importantly selection from the mesh to the final derived mesh, * use in object mode when selecting faces (while painting) */ diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index adcec5699a9..a356f9fca7f 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -29,7 +29,6 @@ * \ingroup edmesh */ -#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -39,7 +38,6 @@ #include "BLI_math.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_library.h" #include "BKE_tessmesh.h" diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 31d5eed83dc..c8a1264fd10 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -38,14 +38,11 @@ #include "BLI_blenlib.h" #include "BLI_array.h" #include "BLI_math.h" -#include "BLI_rand.h" #include "BLI_smallhash.h" -#include "BLI_scanfill.h" #include "BLI_memarena.h" #include "BKE_DerivedMesh.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BIF_gl.h" #include "BIF_glutil.h" /* for paint cursor */ @@ -59,7 +56,6 @@ #include "WM_types.h" #include "DNA_scene_types.h" -#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "BKE_tessmesh.h" #include "UI_resources.h" @@ -1150,7 +1146,7 @@ static float len_v3_tri_side_max(const float v1[3], const float v2[3], const flo const float s2 = len_squared_v3v3(v2, v3); const float s3 = len_squared_v3v3(v3, v1); - return sqrtf(MAX3(s1, s2, s3)); + return sqrtf(max_fff(s1, s2, s3)); } static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 7721f878ce6..5f923dd65c6 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -28,46 +28,21 @@ * \ingroup edmesh */ -#include <float.h> -#ifdef _MSC_VER -# define _USE_MATH_DEFINES -#endif -#include <math.h> -#include <string.h> -#include <ctype.h> -#include <stdio.h> - -#include "DNA_ID.h" #include "DNA_object_types.h" -#include "DNA_mesh_types.h" -#include "DNA_screen_types.h" #include "DNA_scene_types.h" -#include "DNA_userdef_types.h" #include "MEM_guardedalloc.h" -#include "PIL_time.h" - #include "BLI_array.h" #include "BLI_blenlib.h" #include "BLI_math.h" -#include "BLI_dynstr.h" /*for WM_operator_pystring */ -#include "BLI_utildefines.h" -#include "BKE_blender.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" -#include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_report.h" -#include "BKE_scene.h" #include "BKE_tessmesh.h" -#include "BKE_depsgraph.h" #include "BIF_gl.h" -#include "BIF_glutil.h" /* for paint cursor */ - -#include "IMB_imbuf_types.h" #include "ED_screen.h" #include "ED_space_api.h" @@ -78,8 +53,6 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "UI_interface.h" - #include "WM_api.h" #include "WM_types.h" @@ -187,7 +160,6 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select) BMWalker walker; float (*edges)[2][3] = NULL; BLI_array_declare(edges); - float co[2][3]; int i, tot = 0; memset(v, 0, sizeof(v)); @@ -245,16 +217,9 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select) BLI_array_grow_items(edges, previewlines); for (i = 1; i <= previewlines; i++) { - co[0][0] = (v[0][1]->co[0] - v[0][0]->co[0]) * (i / ((float)previewlines + 1)) + v[0][0]->co[0]; - co[0][1] = (v[0][1]->co[1] - v[0][0]->co[1]) * (i / ((float)previewlines + 1)) + v[0][0]->co[1]; - co[0][2] = (v[0][1]->co[2] - v[0][0]->co[2]) * (i / ((float)previewlines + 1)) + v[0][0]->co[2]; - - co[1][0] = (v[1][1]->co[0] - v[1][0]->co[0]) * (i / ((float)previewlines + 1)) + v[1][0]->co[0]; - co[1][1] = (v[1][1]->co[1] - v[1][0]->co[1]) * (i / ((float)previewlines + 1)) + v[1][0]->co[1]; - co[1][2] = (v[1][1]->co[2] - v[1][0]->co[2]) * (i / ((float)previewlines + 1)) + v[1][0]->co[2]; - - copy_v3_v3(edges[tot][0], co[0]); - copy_v3_v3(edges[tot][1], co[1]); + const float fac = (i / ((float)previewlines + 1)); + interp_v3_v3v3(edges[tot][0], v[0][0]->co, v[0][1]->co, fac); + interp_v3_v3v3(edges[tot][1], v[1][0]->co, v[1][1]->co, fac); tot++; } } @@ -274,19 +239,14 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select) BLI_array_grow_items(edges, previewlines); for (i = 1; i <= previewlines; i++) { - if (!v[0][0] || !v[0][1] || !v[1][0] || !v[1][1]) + const float fac = (i / ((float)previewlines + 1)); + + if (!v[0][0] || !v[0][1] || !v[1][0] || !v[1][1]) { continue; - - co[0][0] = (v[0][1]->co[0] - v[0][0]->co[0]) * (i / ((float)previewlines + 1)) + v[0][0]->co[0]; - co[0][1] = (v[0][1]->co[1] - v[0][0]->co[1]) * (i / ((float)previewlines + 1)) + v[0][0]->co[1]; - co[0][2] = (v[0][1]->co[2] - v[0][0]->co[2]) * (i / ((float)previewlines + 1)) + v[0][0]->co[2]; + } - co[1][0] = (v[1][1]->co[0] - v[1][0]->co[0]) * (i / ((float)previewlines + 1)) + v[1][0]->co[0]; - co[1][1] = (v[1][1]->co[1] - v[1][0]->co[1]) * (i / ((float)previewlines + 1)) + v[1][0]->co[1]; - co[1][2] = (v[1][1]->co[2] - v[1][0]->co[2]) * (i / ((float)previewlines + 1)) + v[1][0]->co[2]; - - copy_v3_v3(edges[tot][0], co[0]); - copy_v3_v3(edges[tot][1], co[1]); + interp_v3_v3v3(edges[tot][0], v[0][0]->co, v[0][1]->co, fac); + interp_v3_v3v3(edges[tot][1], v[1][0]->co, v[1][1]->co, fac); tot++; } } diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 4909561f677..6cbf5e88cee 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -31,7 +31,6 @@ #include "MEM_guardedalloc.h" -#include "DNA_scene_types.h" #include "DNA_object_types.h" #include "RNA_define.h" @@ -41,11 +40,9 @@ #include "BLI_array.h" #include "BKE_context.h" -#include "BKE_object.h" #include "BKE_report.h" #include "BKE_tessmesh.h" -#include "WM_api.h" #include "WM_types.h" #include "ED_mesh.h" diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index a46edb19662..48dfe3bf667 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -40,7 +40,6 @@ #include "BKE_context.h" #include "BKE_displist.h" -#include "BKE_depsgraph.h" #include "BKE_report.h" #include "BKE_paint.h" #include "BKE_tessmesh.h" @@ -56,9 +55,7 @@ #include "ED_mesh.h" #include "ED_screen.h" -#include "ED_util.h" #include "ED_uvedit.h" -#include "ED_object.h" #include "ED_view3d.h" #include "BIF_gl.h" @@ -1148,11 +1145,11 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short desele /* We can't be sure this has already been set... */ ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); - if (ED_view3d_project_float_object(vc.ar, eed->v1->co, v1_co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object(vc.ar, eed->v1->co, v1_co, V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { length_1 = len_squared_v2v2(mvalf, v1_co); } - if (ED_view3d_project_float_object(vc.ar, eed->v2->co, v2_co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object(vc.ar, eed->v2->co, v2_co, V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { length_2 = len_squared_v2v2(mvalf, v2_co); } #if 0 @@ -1179,7 +1176,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short desele float co[2], tdist; BM_face_calc_center_mean(f, cent); - if (ED_view3d_project_float_object(vc.ar, cent, co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object(vc.ar, cent, co, V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { tdist = len_squared_v2v2(mvalf, co); if (tdist < best_dist) { /* printf("Best face: %p (%f)\n", f, tdist);*/ diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index c15c1d4a4de..41b263e8929 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -40,8 +40,8 @@ #include "RNA_define.h" #include "RNA_access.h" +#include "RNA_enum_types.h" -#include "BLI_array.h" #include "BLI_blenlib.h" #include "BLI_noise.h" #include "BLI_math.h" @@ -49,9 +49,7 @@ #include "BKE_material.h" #include "BKE_context.h" -#include "BKE_cdderivedmesh.h" #include "BKE_depsgraph.h" -#include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_report.h" #include "BKE_texture.h" @@ -616,7 +614,7 @@ static int edbm_extrude_verts_exec(bContext *C, wmOperator *op) edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT, nor); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit); + EDBM_update_generic(em, TRUE, TRUE); return OPERATOR_FINISHED; } @@ -647,7 +645,7 @@ static int edbm_extrude_edges_exec(bContext *C, wmOperator *op) edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, nor); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit); + EDBM_update_generic(em, TRUE, TRUE); return OPERATOR_FINISHED; } @@ -911,7 +909,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent BMOIter oiter; copy_v3_v3(min, curs); - view3d_get_view_aligned_coordinate(&vc, min, event->mval, 0); + view3d_get_view_aligned_coordinate(&vc, min, event->mval, FALSE); invert_m4_m4(vc.obedit->imat, vc.obedit->obmat); mul_m4_v3(vc.obedit->imat, min); // back in object space @@ -2531,7 +2529,6 @@ static void edbm_blend_from_shape_ui(bContext *C, wmOperator *op) void MESH_OT_blend_from_shape(wmOperatorType *ot) { PropertyRNA *prop; - static EnumPropertyItem shape_items[] = {{0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name = "Blend From Shape"; @@ -2548,7 +2545,7 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop = RNA_def_enum(ot->srna, "shape", shape_items, 0, "Shape", "Shape key to use for blending"); + prop = RNA_def_enum(ot->srna, "shape", DummyRNA_NULL_items, 0, "Shape", "Shape key to use for blending"); RNA_def_enum_funcs(prop, shape_itemf); RNA_def_float(ot->srna, "blend", 1.0f, -FLT_MAX, FLT_MAX, "Blend", "Blending factor", -2.0f, 2.0f); RNA_def_boolean(ot->srna, "add", 1, "Add", "Add rather than blend between shapes"); @@ -2931,7 +2928,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) screen_vert_coords = sco = MEM_mallocN(bm->totvert * sizeof(float) * 2, __func__); BM_ITER_MESH_INDEX (bv, &iter, bm, BM_VERTS_OF_MESH, i) { - if (ED_view3d_project_float_object(ar, bv->co, *sco, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object(ar, bv->co, *sco, V3D_PROJ_TEST_CLIP_NEAR) != V3D_PROJ_RET_OK) { copy_v2_fl(*sco, FLT_MAX); /* set error value */ } BM_elem_index_set(bv, i); /* set_ok */ diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index b1094c75f27..e8132f5b82b 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -35,15 +35,12 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BLI_blenlib.h" #include "BLI_math.h" #include "BKE_DerivedMesh.h" -#include "BKE_bmesh.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_key.h" -#include "BKE_library.h" #include "BKE_mesh.h" #include "BKE_report.h" #include "BKE_tessmesh.h" @@ -56,7 +53,6 @@ #include "ED_mesh.h" #include "ED_util.h" -#include "bmesh.h" #include "mesh_intern.h" @@ -1302,15 +1298,15 @@ void EDBM_mesh_reveal(BMEditMesh *em) int sels[3] = {(em->selectmode & SCE_SELECT_VERTEX), (em->selectmode & SCE_SELECT_EDGE), (em->selectmode & SCE_SELECT_FACE), }; - - BMIter iter; - BMElem *ele; int i; /* Use tag flag to remember what was hidden before all is revealed. * BM_ELEM_HIDDEN --> BM_ELEM_TAG */ #pragma omp parallel for schedule(dynamic) if (em->bm->totvert + em->bm->totedge + em->bm->totface >= BM_OMP_LIMIT) for (i = 0; i < 3; i++) { + BMIter iter; + BMElem *ele; + BM_ITER_MESH (ele, &iter, em->bm, iter_types[i]) { BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_HIDDEN)); } @@ -1321,6 +1317,9 @@ void EDBM_mesh_reveal(BMEditMesh *em) /* Select relevant just-revealed elements */ for (i = 0; i < 3; i++) { + BMIter iter; + BMElem *ele; + if (!sels[i]) { continue; } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index e9906f852de..641d1be7a2e 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -28,35 +28,23 @@ * \ingroup edmesh */ - -#include <math.h> -#include <stdlib.h> -#include <string.h> - #include "MEM_guardedalloc.h" -#include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_view3d_types.h" -#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "BLI_array.h" #include "BLI_math.h" -#include "BLI_edgehash.h" -#include "BLI_linklist.h" -#include "BLI_listbase.h" #include "BKE_context.h" #include "BKE_depsgraph.h" -#include "BKE_displist.h" #include "BKE_image.h" #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_report.h" #include "BKE_tessmesh.h" @@ -72,10 +60,9 @@ #include "ED_uvedit.h" #include "ED_view3d.h" -#include "RE_render_ext.h" - #include "mesh_intern.h" + static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_tot) { CustomData *data; diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index 21564d2d348..1a81cab8de7 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -26,31 +26,22 @@ * ***** END GPL LICENSE BLOCK ***** */ -#include <math.h> - #include "MEM_guardedalloc.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" #include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" -#include "DNA_ID.h" #include "BLI_listbase.h" -#include "BLI_utildefines.h" #include "BLI_math_vector.h" #include "BLI_linklist.h" #include "BKE_library.h" #include "BKE_depsgraph.h" #include "BKE_context.h" -#include "BKE_main.h" #include "BKE_mesh.h" -#include "BKE_modifier.h" #include "BKE_scene.h" #include "BKE_DerivedMesh.h" -#include "BKE_cdderivedmesh.h" #include "BKE_report.h" #include "BKE_tessmesh.h" @@ -58,14 +49,13 @@ #include "ED_mesh.h" #include "ED_screen.h" -#include "RNA_access.h" - #include "WM_api.h" #include "WM_types.h" #include "mesh_intern.h" #include "recast-capi.h" + static void createVertsTrisData(bContext *C, LinkNode *obs, int *nverts_r, float **verts_r, int *ntris_r, int **tris_r) { MVert *mvert; diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 12b68f0e419..372d6feec0c 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -29,17 +29,11 @@ */ -#include <stdlib.h> -#include <math.h> -#include "DNA_object_types.h" -#include "DNA_scene_types.h" #include "BLI_math.h" -#include "BLI_blenlib.h" -#include "BKE_context.h" #include "RNA_access.h" @@ -49,7 +43,6 @@ #include "ED_object.h" #include "ED_mesh.h" #include "ED_screen.h" -#include "ED_view3d.h" #include "mesh_intern.h" diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index c0b6327d740..773331d20f8 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -27,35 +27,22 @@ /** \file blender/editors/mesh/meshtools.c * \ingroup edmesh + * + * meshtools.c: no editmode (violated already :), mirror & join), + * tools operating on meshes */ - -/* - * meshtools.c: no editmode (violated already :), tools operating on meshes - */ - -#include <stddef.h> -#include <stdlib.h> -#include <math.h> -#include <float.h> - #include "MEM_guardedalloc.h" #include "DNA_mesh_types.h" -#include "DNA_view3d_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" -#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BLI_math.h" #include "BLI_blenlib.h" -#include "BLI_utildefines.h" -#include "BLI_ghash.h" -#include "BLI_rand.h" /* for randome face sorting */ -#include "BLI_threads.h" #include "BKE_context.h" @@ -71,7 +58,6 @@ #include "BKE_tessmesh.h" #include "BKE_multires.h" -#include "BLO_sys_types.h" // for intptr_t support #include "ED_mesh.h" #include "ED_object.h" @@ -80,10 +66,6 @@ #include "WM_api.h" #include "WM_types.h" -/* own include */ -#include "mesh_intern.h" -#include "uvedit_intern.h" - /* * ********************** no editmode!!! *********** */ /*********************** JOIN ***************************/ @@ -1080,7 +1062,7 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float static unsigned int mirror_facehash(const void *ptr) { const MFace *mf = ptr; - int v0, v1; + unsigned int v0, v1; if (mf->v4) { v0 = MIN4(mf->v1, mf->v2, mf->v3, mf->v4); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index b21b77e4e34..473119c90f3 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -802,10 +802,18 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot) static int group_instance_add_exec(bContext *C, wmOperator *op) { - Group *group = BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group")); - + Group *group; unsigned int layer; float loc[3], rot[3]; + + if (RNA_struct_property_is_set(op->ptr, "name")) { + char name[MAX_ID_NAME - 2]; + + RNA_string_get(op->ptr, "name", name); + group = (Group *)BKE_libblock_find_name(ID_GR, name); + } + else + group = BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group")); if (!ED_object_add_generic_get_opts(C, op, loc, rot, NULL, &layer, NULL)) return OPERATOR_CANCELLED; @@ -847,6 +855,7 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ + RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME - 2, "Name", "Group name to add"); ot->prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", ""); RNA_def_enum_funcs(ot->prop, RNA_group_itemf); ED_object_add_generic_props(ot, FALSE); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 8b40379f88d..d3ebd1dae0a 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -100,6 +100,7 @@ typedef struct { float bias; int raytrace_structure; int octree_resolution; + int threads; } MultiresBakeJob; static int multiresbake_check(bContext *C, wmOperator *op) @@ -316,9 +317,10 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) bkr.mode = scene->r.bake_mode; bkr.use_lores_mesh = scene->r.bake_flag & R_BAKE_LORES_MESH; bkr.bias = scene->r.bake_biasdist; - bkr.number_of_rays = scene->r.bake_rays_number; + bkr.number_of_rays = scene->r.bake_samples; bkr.raytrace_structure = scene->r.raytrace_structure; bkr.octree_resolution = scene->r.ocres; + bkr.threads = scene->r.mode & R_FIXED_THREADS ? scene->r.threads : 0; /* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */ bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl, &bkr.simple); @@ -353,9 +355,10 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) bkj->use_lores_mesh = scene->r.bake_flag & R_BAKE_LORES_MESH; bkj->bake_clear = scene->r.bake_flag & R_BAKE_CLEAR; bkj->bias = scene->r.bake_biasdist; - bkj->number_of_rays = scene->r.bake_rays_number; + bkj->number_of_rays = scene->r.bake_samples; bkj->raytrace_structure = scene->r.raytrace_structure; bkj->octree_resolution = scene->r.ocres; + bkj->threads = scene->r.mode & R_FIXED_THREADS ? scene->r.threads : 0; CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { @@ -422,6 +425,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa bkr.number_of_rays = bkj->number_of_rays; bkr.raytrace_structure = bkj->raytrace_structure; bkr.octree_resolution = bkj->octree_resolution; + bkr.threads = bkj->threads; RE_multires_bake_images(&bkr); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 12edb3e8edb..c9492d8f683 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1676,10 +1676,6 @@ static EnumPropertyItem game_properties_copy_operations[] = { {0, NULL, 0, NULL, NULL} }; -static EnumPropertyItem gameprops_items[] = { - {0, NULL, 0, NULL, NULL} -}; - static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *ob = ED_object_active_context(C); @@ -1689,7 +1685,7 @@ static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), P int a, totitem = 0; if (!ob) - return gameprops_items; + return DummyRNA_NULL_items; for (a = 1, prop = ob->prop.first; prop; prop = prop->next, a++) { tmp.value = a; @@ -1760,7 +1756,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", ""); - prop = RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy"); + prop = RNA_def_enum(ot->srna, "property", DummyRNA_NULL_items, 0, "Property", "Properties to copy"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_enum_funcs(prop, gameprops_itemf); ot->prop = prop; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index f3e792def17..e7c619acb67 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -65,6 +65,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "WM_api.h" #include "WM_types.h" @@ -87,7 +88,7 @@ static int vertex_group_use_vert_sel(Object *ob) if (ob->mode == OB_MODE_EDIT) { return TRUE; } - else if (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) { + else if (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) { return TRUE; } else { @@ -1409,7 +1410,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, Mesh *me = ob->data; MVert *mvert = me->mvert; int *verts = NULL; - if (!(me->editflag & ME_EDIT_VERT_SEL)) + if (!(me->editflag & ME_EDIT_PAINT_VERT_SEL)) return; for (i = 0; i < me->totvert && mvert; i++, mvert++) { if (mvert->flag & SELECT) { @@ -2070,7 +2071,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v /* object mode / weight paint */ MVert *mv, *mv_mirr; int vidx, vidx_mirr; - const int use_vert_sel = (me->editflag & ME_EDIT_VERT_SEL) != 0; + const int use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; if (me->dvert == NULL) { goto cleanup; @@ -3369,10 +3370,6 @@ void OBJECT_OT_vertex_group_transfer_weight(wmOperatorType *ot) ot->prop = RNA_def_enum(ot->srna, "WT_replace_mode", WT_replace_mode_item, 1, "Replace", ""); } -static EnumPropertyItem vgroup_items[] = { - {0, NULL, 0, NULL, NULL} -}; - static int set_active_group_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); @@ -3396,7 +3393,7 @@ static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), Prop int a, totitem = 0; if (!ob) - return vgroup_items; + return DummyRNA_NULL_items; for (a = 0, def = ob->defbase.first; def; def = def->next, a++) { tmp.value = a; @@ -3430,7 +3427,7 @@ void OBJECT_OT_vertex_group_set_active(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop = RNA_def_enum(ot->srna, "group", vgroup_items, 0, "Group", "Vertex group to set as active"); + prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "Vertex group to set as active"); RNA_def_enum_funcs(prop, vgroup_itemf); ot->prop = prop; } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 30508a793ae..9dbc0f9a10c 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -421,7 +421,7 @@ static int key_test_depth(PEData *data, const float co[3], const int screen_co[2 /* used to calculate here but all callers have the screen_co already, so pass as arg */ #if 0 if (ED_view3d_project_int_global(data->vc.ar, co, screen_co, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_OK) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) != V3D_PROJ_RET_OK) { return 0; } @@ -2812,7 +2812,7 @@ static void brush_cut(PEData *data, int pa_index) if (edit->points[pa_index].flag & PEP_HIDE) return; - if (ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) + if (ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_CLIP_NEAR) != V3D_PROJ_RET_OK) return; rad2= data->rad * data->rad; @@ -2837,7 +2837,7 @@ static void brush_cut(PEData *data, int pa_index) /* calculate path time closest to root that was inside the circle */ for (k=1, key++; k<=keys; k++, key++) { - if ((ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) || + if ((ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_CLIP_NEAR) != V3D_PROJ_RET_OK) || key_test_depth(data, key->co, screen_co) == 0) { x0 = (float)screen_co[0]; @@ -3476,11 +3476,16 @@ static int brush_edit_init(bContext *C, wmOperator *op) PTCacheEdit *edit= PE_get_current(scene, ob); ARegion *ar= CTX_wm_region(C); BrushEdit *bedit; - + float min[3], max[3]; + if (pset->brushtype < 0) return 0; - initgrabz(ar->regiondata, ob->obmat[3][0], ob->obmat[3][1], ob->obmat[3][2]); + /* set the 'distance factor' for grabbing (used in comb etc) */ + INIT_MINMAX(min, max); + PE_minmax(scene, min, max); + mid_v3_v3v3(min, min, max); + initgrabz(ar->regiondata, min[0], min[1], min[2]); bedit= MEM_callocN(sizeof(BrushEdit), "BrushEdit"); bedit->first= 1; diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 221aad2161c..23069ab8a08 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -49,6 +49,7 @@ #include "BKE_main.h" #include "BKE_particle.h" #include "BKE_pointcache.h" +#include "BKE_report.h" #include "RNA_access.h" @@ -625,7 +626,7 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot) RNA_def_boolean(ot->srna, "all", 0, "All hair", "Disconnect all hair systems from the emitter mesh"); } -static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) +static int connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) { ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); ParticleData *pa; @@ -642,8 +643,8 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) float hairmat[4][4], imat[4][4]; float v[4][3], vec[3]; - if (!psys || !psys->part || psys->part->type != PART_HAIR) - return; + if (!psys || !psys->part || psys->part->type != PART_HAIR || !psmd->dm) + return FALSE; edit= psys->edit; point= edit ? edit->points : NULL; @@ -724,6 +725,8 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) psys->flag &= ~PSYS_GLOBAL_HAIR; PE_update_object(scene, ob, 0); + + return TRUE; } static int connect_hair_exec(bContext *C, wmOperator *op) @@ -733,18 +736,24 @@ static int connect_hair_exec(bContext *C, wmOperator *op) PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= NULL; int all = RNA_boolean_get(op->ptr, "all"); + int any_connected = FALSE; if (!ob) return OPERATOR_CANCELLED; if (all) { for (psys=ob->particlesystem.first; psys; psys=psys->next) { - connect_hair(scene, ob, psys); + any_connected |= connect_hair(scene, ob, psys); } } else { psys = ptr.data; - connect_hair(scene, ob, psys); + any_connected |= connect_hair(scene, ob, psys); + } + + if (!any_connected) { + BKE_report(op->reports, RPT_ERROR, "Can't disconnect hair if particle system modifier is disabled"); + return OPERATOR_CANCELLED; } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index db2023b7364..c54ac485be6 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -127,7 +127,7 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings * float longest_axis; BKE_object_dimensions_get(domainob, dim); - longest_axis = MAX3(dim[0], dim[1], dim[2]); + longest_axis = max_fff(dim[0], dim[1], dim[2]); return longest_axis * scene->unit.scale_length; } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index cde94ec46ee..fbdec3dd8ad 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -876,7 +876,7 @@ static int rct_fits(rcti *rect, char dir, int size) /* ar should be overlapping */ /* function checks if some overlapping region was defined before - on same place */ -static void region_overlap_fix(ARegion *ar) +static void region_overlap_fix(ScrArea *sa, ARegion *ar) { ARegion *ar1 = ar->prev; @@ -890,18 +890,26 @@ static void region_overlap_fix(ARegion *ar) ar1 = ar1->prev; } - /* translate */ + /* translate or close */ if (ar1) { int align1 = ar1->alignment & ~RGN_SPLIT_PREV; if (align1 == RGN_ALIGN_LEFT) { - BLI_rcti_translate(&ar->winrct, ar1->winx, 0); + if (ar->winrct.xmax + ar1->winx > sa->winx - U.widget_unit) + ar->flag |= RGN_FLAG_TOO_SMALL; + else + BLI_rcti_translate(&ar->winrct, ar1->winx, 0); } else if (align1 == RGN_ALIGN_RIGHT) { - BLI_rcti_translate(&ar->winrct, -ar1->winx, 0); + if (ar->winrct.xmin - ar1->winx < U.widget_unit) + ar->flag |= RGN_FLAG_TOO_SMALL; + else + BLI_rcti_translate(&ar->winrct, -ar1->winx, 0); } } + + } /* overlapping regions only in the following restricted cases */ @@ -943,8 +951,9 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti if (ar->next == NULL && alignment != RGN_ALIGN_QSPLIT) alignment = RGN_ALIGN_NONE; - /* prefsize, for header we stick to exception */ - prefsizex = ar->sizex > 1 ? ar->sizex : UI_DPI_FAC * ar->type->prefsizex; + /* prefsize, for header we stick to exception (prevent dpi rounding error) */ + prefsizex = UI_DPI_FAC * (ar->sizex > 1 ? ar->sizex + 0.5f : ar->type->prefsizex); + if (ar->regiontype == RGN_TYPE_HEADER) { prefsizey = ED_area_headersize(); } @@ -952,7 +961,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2); } else { - prefsizey = ar->sizey > 1 ? ar->sizey : UI_DPI_FAC * ar->type->prefsizey; + prefsizey = UI_DPI_FAC * (ar->sizey > 1 ? ar->sizey + 0.5f : ar->type->prefsizey); } @@ -1092,12 +1101,13 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti ar->winy = BLI_rcti_size_y(&ar->winrct) + 1; /* if region opened normally, we store this for hide/reveal usage */ - if (ar->winx > 1) ar->sizex = ar->winx; - if (ar->winy > 1) ar->sizey = ar->winy; + /* prevent rounding errors for UI_DPI_FAC mult and divide */ + if (ar->winx > 1) ar->sizex = (ar->winx + 0.5f) / UI_DPI_FAC; + if (ar->winy > 1) ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC; - /* exception for multiple aligned overlapping regions on same spot */ + /* exception for multiple overlapping regions on same spot */ if (ar->overlap) - region_overlap_fix(ar); + region_overlap_fix(sa, ar); /* set winrect for azones */ if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index f71d63e5fef..cca713ec14a 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -672,29 +672,6 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) CLAMP(sv->vec.y, 0, winsizey); } - - /* scale prefsizes of regions */ - for (sa = sc->areabase.first; sa; sa = sa->next) { - ARegion *ar; - - for (ar = sa->regionbase.first; ar; ar = ar->next) { - ar->sizex = (int)((float)ar->sizex * facx); - ar->sizey = (int)((float)ar->sizey * facy); - ar->winx = (int)((float)ar->winx * facx); - ar->winy = (int)((float)ar->winy * facy); - } - if (sa->spacedata.first) { - SpaceLink *sl = sa->spacedata.first; - for (sl = sl->next; sl; sl = sl->next) { - for (ar = sl->regionbase.first; ar; ar = ar->next) { - ar->sizex = (int)((float)ar->sizex * facx); - ar->sizey = (int)((float)ar->sizey * facy); - ar->winx = (int)((float)ar->winx * facx); - ar->winy = (int)((float)ar->winy * facy); - } - } - } - } } /* test for collapsed areas. This could happen in some blender version... */ @@ -1325,6 +1302,7 @@ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) screen_cursor_set(win, event); } else { + /* notifier invokes freeing the buttons... causing a bit too much redraws */ if (oldswin != scr->subwinactive) { region_cursor_set(win, scr->subwinactive, TRUE); WM_event_add_notifier(C, NC_SCREEN | ND_SUBWINACTIVE, scr); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index a26f5e87090..a22faea9eec 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1759,7 +1759,7 @@ static int region_scale_get_maxsize(RegionMoveData *rmd) int maxsize = 0; if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { - return rmd->sa->winx - UI_UNIT_X; + return (int) ( (rmd->sa->winx / UI_DPI_FAC) - UI_UNIT_X); } if (rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { @@ -1808,6 +1808,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) delta = event->x - rmd->origx; if (rmd->edge == AE_LEFT_TO_TOPRIGHT) delta = -delta; + /* region sizes now get multiplied */ + delta /= UI_DPI_FAC; + rmd->ar->sizex = rmd->origval + delta; CLAMP(rmd->ar->sizex, 0, rmd->maxsize); @@ -1824,6 +1827,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) delta = event->y - rmd->origy; if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) delta = -delta; + /* region sizes now get multiplied */ + delta /= UI_DPI_FAC; + rmd->ar->sizey = rmd->origval + delta; CLAMP(rmd->ar->sizey, 0, rmd->maxsize); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index b704414c321..8c9531e5554 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -3344,7 +3344,7 @@ static void project_paint_begin(ProjPaintState *ps) tpage = project_paint_face_image(ps, ps->dm_mtface, face_index); - if (tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_MASK) == 0 || mf->flag & ME_FACE_SEL)) { + if (tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) == 0 || mf->flag & ME_FACE_SEL)) { float *v1coSS, *v2coSS, *v3coSS, *v4coSS = NULL; @@ -5104,7 +5104,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) } pop->s.ob = ob; - pop->s.do_facesel = (me->editflag & ME_EDIT_PAINT_MASK) != 0; + pop->s.do_facesel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; /* for non prohect paint we need */ /* fill in derived mesh */ @@ -5705,7 +5705,7 @@ static int image_paint_sample_color_poll(bContext *C) if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { Mesh *me = BKE_mesh_from_object(obact); if (me) { - return !(me->editflag & ME_EDIT_PAINT_MASK); + return !(me->editflag & ME_EDIT_PAINT_FACE_SEL); } } } diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 162e2fa15d6..cf55c93efe4 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -89,6 +89,12 @@ void PAINT_OT_weight_from_bones(struct wmOperatorType *ot); void PAINT_OT_weight_sample(struct wmOperatorType *ot); void PAINT_OT_weight_sample_group(struct wmOperatorType *ot); +enum { + WPAINT_GRADIENT_TYPE_LINEAR, + WPAINT_GRADIENT_TYPE_RADIAL +}; +void PAINT_OT_weight_gradient(struct wmOperatorType *ot); + void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot); void PAINT_OT_vertex_paint(struct wmOperatorType *ot); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 40dcb92f087..10b9f26dbcd 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -475,6 +475,7 @@ void ED_operatortypes_paint(void) WM_operatortype_append(PAINT_OT_weight_paint); WM_operatortype_append(PAINT_OT_weight_set); WM_operatortype_append(PAINT_OT_weight_from_bones); + WM_operatortype_append(PAINT_OT_weight_gradient); WM_operatortype_append(PAINT_OT_weight_sample); WM_operatortype_append(PAINT_OT_weight_sample_group); @@ -710,6 +711,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample_group", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_gradient", LEFTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "type", WPAINT_GRADIENT_TYPE_LINEAR); + RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_gradient", LEFTMOUSE, KM_PRESS, KM_ALT | KM_CTRL, 0)->ptr, "type", WPAINT_GRADIENT_TYPE_RADIAL); + WM_keymap_add_item(keymap, "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 9bbf99ff3cf..359486a4a8d 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -224,7 +224,7 @@ static void do_shared_vertex_tesscol(Mesh *me) { /* if no mcol: do not do */ /* if tface: only the involved faces, otherwise all */ - const int use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK); + const int use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL); MFace *mface; int a; short *scolmain, *scol; @@ -284,7 +284,7 @@ static void do_shared_vertex_tesscol(Mesh *me) static void do_shared_vertexcol(Mesh *me, int do_tessface) { - const int use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK); + const int use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL); MPoly *mp; float (*scol)[4]; int i, j, has_shared = 0; @@ -402,12 +402,28 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active) return -1; } -static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot) +static void free_vpaint_prev(VPaint *vp) { if (vp->vpaint_prev) { MEM_freeN(vp->vpaint_prev); vp->vpaint_prev = NULL; + vp->tot = 0; } +} + +static void free_wpaint_prev(VPaint *vp) +{ + if (vp->wpaint_prev) { + MEM_freeN(vp->wpaint_prev); + vp->wpaint_prev = NULL; + vp->tot = 0; + } +} + +static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot) +{ + free_vpaint_prev(vp); + vp->tot = tot; if (lcol == NULL || tot == 0) return; @@ -419,10 +435,7 @@ static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot) static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount) { - if (wp->wpaint_prev) { - free_dverts(wp->wpaint_prev, wp->tot); - wp->wpaint_prev = NULL; - } + free_wpaint_prev(wp); if (dverts && dcount) { @@ -432,7 +445,6 @@ static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount) } } - void vpaint_fill(Object *ob, unsigned int paintcol) { Mesh *me; @@ -447,7 +459,7 @@ void vpaint_fill(Object *ob, unsigned int paintcol) if (!me->mloopcol) return; /* possible we can't make mcol's */ - selected = (me->editflag & ME_EDIT_PAINT_MASK); + selected = (me->editflag & ME_EDIT_PAINT_FACE_SEL); mp = me->mpoly; for (i = 0; i < me->totpoly; i++, mp++) { @@ -1018,7 +1030,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) me = BKE_mesh_from_object(vc.obact); if (me && me->dvert && vc.v3d && vc.rv3d) { - const int use_vert_sel = (me->editflag & ME_EDIT_VERT_SEL) != 0; + const int use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; int v_idx_best = -1; unsigned int index; @@ -1103,7 +1115,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA if (me && me->dvert && vc.v3d && vc.rv3d && vc.obact->defbase.first) { const int defbase_tot = BLI_countlist(&vc.obact->defbase); - const int use_vert_sel = (me->editflag & ME_EDIT_VERT_SEL) != 0; + const int use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; int *groups = MEM_callocN(defbase_tot * sizeof(int), "groups"); int found = FALSE; unsigned int index; @@ -1993,6 +2005,13 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ else { mesh_octree_table(NULL, NULL, NULL, 'e'); mesh_mirrtopo_table(NULL, 'e'); + + if (me->editflag & ME_EDIT_PAINT_VERT_SEL) { + BKE_mesh_flush_select_from_verts(me); + } + else if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { + BKE_mesh_flush_select_from_polys(me); + } } WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); @@ -2222,14 +2241,14 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P swap_m4m4(wpd->vc.rv3d->persmat, mat); - use_vert_sel = (me->editflag & ME_EDIT_VERT_SEL) != 0; + use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; /* which faces are involved */ if (wp->flag & VP_AREA) { /* Ugly hack, to avoid drawing vertex index when getting the face index buffer - campbell */ - me->editflag &= ~ME_EDIT_VERT_SEL; + me->editflag &= ~ME_EDIT_PAINT_VERT_SEL; totindex = sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); - me->editflag |= use_vert_sel ? ME_EDIT_VERT_SEL : 0; + me->editflag |= use_vert_sel ? ME_EDIT_PAINT_VERT_SEL : 0; } else { indexar[0] = view3d_sample_backbuf(vc, mval[0], mval[1]); @@ -2237,7 +2256,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P else totindex = 0; } - if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { + if ((me->editflag & ME_EDIT_PAINT_FACE_SEL) && me->mpoly) { for (index = 0; index < totindex; index++) { if (indexar[index] && indexar[index] <= me->totpoly) { MPoly *mpoly = ((MPoly *)me->mpoly) + (indexar[index] - 1); @@ -2476,6 +2495,10 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ if (ob->mode & OB_MODE_VERTEX_PAINT) { ob->mode &= ~OB_MODE_VERTEX_PAINT; + + if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { + BKE_mesh_flush_select_from_polys(me); + } } else { ob->mode |= OB_MODE_VERTEX_PAINT; @@ -2770,7 +2793,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P else totindex = 0; } - if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { + if ((me->editflag & ME_EDIT_PAINT_FACE_SEL) && me->mpoly) { for (index = 0; index < totindex; index++) { if (indexar[index] && indexar[index] <= me->totpoly) { MPoly *mpoly = ((MPoly *)me->mpoly) + (indexar[index] - 1); @@ -2927,3 +2950,256 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot) /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Method to use for assigning weights"); } + +/* *** VGroups Gradient *** */ +typedef struct DMGradient_vertStore { + float sco[2]; + float weight_orig; + enum { + VGRAD_STORE_NOP = 0, + VGRAD_STORE_DW_EXIST = (1 << 0) + } flag; +} DMGradient_vertStore; + +typedef struct DMGradient_userData { + struct ARegion *ar; + Scene *scene; + Mesh *me; + Brush *brush; + const float *sco_start; /* [2] */ + const float *sco_end; /* [2] */ + float sco_line_div; /* store (1.0f / len_v2v2(sco_start, sco_end)) */ + int def_nr; + short is_init; + DMGradient_vertStore *vert_cache; + + /* options */ + short use_select; + short type; + float weightpaint; +} DMGradient_userData; + +static void gradientVert__mapFunc(void *userData, int index, const float co[3], + const float UNUSED(no_f[3]), const short UNUSED(no_s[3])) +{ + DMGradient_userData *grad_data = userData; + Mesh *me = grad_data->me; + + if (grad_data->use_select == FALSE || (me->mvert[index].flag & SELECT)) { + DMGradient_vertStore *vs = &grad_data->vert_cache[index]; + + /* run first pass only, could be split into its own mapFunc + * the screen coords of the verts need to be cached because + * updating the mesh may move them about (entering feedback loop) */ + if (grad_data->is_init) { + if (ED_view3d_project_float_global(grad_data->ar, + co, vs->sco, + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) + { + /* ok */ + MDeformVert *dv = &me->dvert[index]; + MDeformWeight *dw; + dw = defvert_find_index(dv, grad_data->def_nr); + if (dw) { + vs->weight_orig = dw->weight; + vs->flag = VGRAD_STORE_DW_EXIST; + } + else { + vs->weight_orig = 0.0f; + vs->flag = VGRAD_STORE_NOP; + } + } + else { + /* no go */ + copy_v2_fl(vs->sco, FLT_MAX); + } + } + /* end init */ + + if (vs->sco[0] != FLT_MAX) { + float alpha; + + if (grad_data->type == WPAINT_GRADIENT_TYPE_LINEAR) { + alpha = line_point_factor_v2(vs->sco, grad_data->sco_start, grad_data->sco_end); + } + else if (grad_data->type == WPAINT_GRADIENT_TYPE_RADIAL) { + alpha = len_v2v2(grad_data->sco_start, vs->sco) * grad_data->sco_line_div; + } + else { + BLI_assert(0); + } + /* no need to clamp 'alpha' yet */ + + /* adjust weight */ + alpha = BKE_brush_curve_strength_clamp(grad_data->brush, alpha, 1.0f); + + if (alpha != 0.0f) { + MDeformVert *dv = &me->dvert[index]; + MDeformWeight *dw = defvert_verify_index(dv, grad_data->def_nr); + // dw->weight = alpha; // testing + int tool = grad_data->brush->vertexpaint_tool; + float testw; + + /* init if we just added */ + testw = wpaint_blend_tool(tool, vs->weight_orig, grad_data->weightpaint, alpha * grad_data->brush->alpha); + CLAMP(testw, 0.0f, 1.0f); + dw->weight = testw; + } + else { + MDeformVert *dv = &me->dvert[index]; + if (vs->flag & VGRAD_STORE_DW_EXIST) { + /* normally we NULL check, but in this case we know it exists */ + MDeformWeight *dw = defvert_find_index(dv, grad_data->def_nr); + dw->weight = vs->weight_orig; + } + else { + /* wasn't originally existing, remove */ + MDeformWeight *dw = defvert_find_index(dv, grad_data->def_nr); + if (dw) { + defvert_remove_group(dv, dw); + } + } + } + } + } +} + +static int paint_weight_gradient_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + int ret = WM_gesture_straightline_modal(C, op, event); + + if (ret & OPERATOR_RUNNING_MODAL) { + if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { /* XXX, hardcoded */ + /* generally crap! redo! */ + WM_gesture_straightline_cancel(C, op); + ret &= ~OPERATOR_RUNNING_MODAL; + ret |= OPERATOR_FINISHED; + } + } + + if (ret & OPERATOR_CANCELLED) { + ToolSettings *ts = CTX_data_tool_settings(C); + VPaint *wp = ts->wpaint; + Object *ob = CTX_data_active_object(C); + Mesh *me = ob->data; + copy_dverts(me->dvert, wp->wpaint_prev, me->totvert); + free_wpaint_prev(wp); + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + } + else if (ret & OPERATOR_FINISHED) { + ToolSettings *ts = CTX_data_tool_settings(C); + VPaint *wp = ts->wpaint; + free_wpaint_prev(wp); + } + + return ret; +} + +static int paint_weight_gradient_exec(bContext *C, wmOperator *op) +{ + wmGesture *gesture = op->customdata; + struct ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + Mesh *me = ob->data; + int x_start = RNA_int_get(op->ptr, "xstart"); + int y_start = RNA_int_get(op->ptr, "ystart"); + int x_end = RNA_int_get(op->ptr, "xend"); + int y_end = RNA_int_get(op->ptr, "yend"); + float sco_start[2] = {x_start, y_start}; + float sco_end[2] = {x_end, y_end}; + + DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask); + + DMGradient_userData data = {0}; + + if (gesture->userdata == NULL) { + VPaint *wp = scene->toolsettings->wpaint; + + gesture->userdata = MEM_mallocN(sizeof(DMGradient_vertStore) * me->totvert, __func__); + data.is_init = TRUE; + + copy_wpaint_prev(wp, me->dvert, me->totvert); + + /* on init only, convert face -> vert sel */ + if (me->editflag & ME_EDIT_PAINT_FACE_SEL) { + BKE_mesh_flush_select_from_polys(me); + } + + } + + data.ar = ar; + data.scene = scene; + data.me = ob->data; + data.sco_start = sco_start; + data.sco_end = sco_end; + data.sco_line_div = 1.0f / len_v2v2(sco_start, sco_end); + data.def_nr = ob->actdef - 1; + data.use_select = (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)); + data.vert_cache = gesture->userdata; + data.type = RNA_enum_get(op->ptr, "type"); + + { + ToolSettings *ts = CTX_data_tool_settings(C); + VPaint *wp = ts->wpaint; + struct Brush *brush = paint_brush(&wp->paint); + data.brush = brush; + data.weightpaint = BKE_brush_weight_get(scene, brush); + } + + dm->foreachMappedVert(dm, gradientVert__mapFunc, &data); + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + int ret = WM_gesture_straightline_invoke(C, op, event); + if (ret & OPERATOR_RUNNING_MODAL) { + struct ARegion *ar = CTX_wm_region(C); + if (ar->regiontype == RGN_TYPE_WINDOW) { + if (event->type == LEFTMOUSE && event->val == KM_PRESS) { /* TODO, hardcoded, extend WM_gesture_straightline_ */ + wmGesture *gesture = op->customdata; + gesture->mode = 1; + } + } + } + return ret; +} + +void PAINT_OT_weight_gradient(wmOperatorType *ot) +{ + /* defined in DNA_space_types.h */ + static EnumPropertyItem gradient_types[] = { + {WPAINT_GRADIENT_TYPE_LINEAR, "LINEAR", 0, "Linear", ""}, + {WPAINT_GRADIENT_TYPE_RADIAL, "RADIAL", 0, "Radial", ""}, + {0, NULL, 0, NULL, NULL} + }; + + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Weight Gradient"; + ot->idname = "PAINT_OT_weight_gradient"; + ot->description = "Sample a line and show it in Scope panels"; + + /* api callbacks */ + ot->invoke = paint_weight_gradient_invoke; + ot->modal = paint_weight_gradient_modal; + ot->exec = paint_weight_gradient_exec; + ot->poll = weight_paint_poll; + ot->cancel = WM_gesture_straightline_cancel; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + prop = RNA_def_enum(ot->srna, "type", gradient_types, 0, "Type", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + + WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT); +} diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index ac5cfbaed11..432032e9dbf 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -54,7 +54,7 @@ struct wmOperatorType; /* extra padding for lengths (to go under scrollers) */ #define EXTRA_SCROLL_PAD 100.0f -#define STRIP_HEIGHT_HALF (0.25 * UI_UNIT_Y) +#define STRIP_HEIGHT_HALF (0.25f * UI_UNIT_Y) /* internal exports only */ diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index b8e162bfb17..bec50130230 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -123,10 +123,10 @@ static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack * BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max); - epsx = MIN4(pat_min[0] - marker->search_min[0], marker->search_max[0] - pat_max[0], - fabsf(pat_min[0]), fabsf(pat_max[0])) / 2; - epsy = MIN4(pat_min[1] - marker->search_min[1], marker->search_max[1] - pat_max[1], - fabsf(pat_min[1]), fabsf(pat_max[1])) / 2; + epsx = min_ffff(pat_min[0] - marker->search_min[0], marker->search_max[0] - pat_max[0], + fabsf(pat_min[0]), fabsf(pat_max[0])) / 2; + epsy = min_ffff(pat_min[1] - marker->search_min[1], marker->search_max[1] - pat_max[1], + fabsf(pat_min[1]), fabsf(pat_max[1])) / 2; epsx = max_ff(epsx, 2.0f / width); epsy = max_ff(epsy, 2.0f / height); @@ -166,7 +166,7 @@ static float dist_to_rect(float co[2], float pos[2], float min[2], float max[2]) d3 = dist_squared_to_line_segment_v2(p, v3, v4); d4 = dist_squared_to_line_segment_v2(p, v4, v1); - return sqrtf(MIN4(d1, d2, d3, d4)); + return sqrtf(min_ffff(d1, d2, d3, d4)); } static float dist_to_crns(float co[2], float pos[2], float crns[4][2]) @@ -181,7 +181,7 @@ static float dist_to_crns(float co[2], float pos[2], float crns[4][2]) d3 = dist_squared_to_line_segment_v2(p, v3, v4); d4 = dist_squared_to_line_segment_v2(p, v4, v1); - return sqrtf(MIN4(d1, d2, d3, d4)); + return sqrtf(min_ffff(d1, d2, d3, d4)); } static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbase, float co[2]) @@ -210,7 +210,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas d3 = dist_to_rect(co, marker->pos, marker->search_min, marker->search_max); /* choose minimal distance. useful for cases of overlapped markers. */ - dist = MIN3(d1, d2, d3); + dist = min_fff(d1, d2, d3); if (track == NULL || dist < mindist) { track = cur; diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index f123bcdb94f..59dd66a0207 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3416,10 +3416,10 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa vec[2][0] = vec[3][0] - dist; vec[2][1] = vec[3][1]; } - if (v2d && MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) { + if (v2d && min_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) { /* clipped */ } - else if (v2d && MAX4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) { + else if (v2d && max_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) { /* clipped */ } else { diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 33217e042e5..6913ebc8a11 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -421,17 +421,17 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, &ptr, "hide", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_view_cb, scene, ob); bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob); bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob); @@ -445,15 +445,15 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); uiBlockSetEmboss(block, UI_EMBOSS); @@ -463,7 +463,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt = uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT - 1, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); @@ -476,13 +476,13 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar bt = uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT - 1, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, layflag, 0, 0, 0, 0, "Render this Pass"); + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, layflag, 0, 0, 0, 0, "Render this Pass"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); layflag++; /* is lay_xor */ if (ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) bt = uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag) ? ICON_DOT : ICON_BLANK1, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); @@ -493,11 +493,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); } else if (tselem->type == TSE_POSE_CHANNEL) { @@ -506,11 +506,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt = uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone); bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); } else if (tselem->type == TSE_EBONE) { @@ -518,11 +518,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); bt = uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone); bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X, UI_UNIT_Y, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL); } } @@ -1227,12 +1227,12 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa float ufac = UI_UNIT_X / 20.0f; uiSetRoundBox(UI_CNR_ALL); - glColor4ub(255, 255, 255, 128); + glColor4ub(255, 255, 255, 100); uiRoundBox((float) *offsx - 1.0f * ufac, (float)ys + 1.0f * ufac, - (float)*offsx + UI_UNIT_X - 1.0f * ufac, - (float)ys + UI_UNIT_Y - 1.0f * ufac, - (float)UI_UNIT_Y / 2.0f - 2.0f * ufac); + (float)*offsx + UI_UNIT_X - 2.0f * ufac, + (float)ys + UI_UNIT_Y - ufac, + (float)UI_UNIT_Y / 2.0f - ufac); glEnable(GL_BLEND); /* roundbox disables */ } @@ -1365,11 +1365,11 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene /* active circle */ if (active) { uiSetRoundBox(UI_CNR_ALL); - uiRoundBox((float)startx + UI_UNIT_X - 1.0f * ufac, + uiRoundBox((float)startx + UI_UNIT_X, (float)*starty + 1.0f * ufac, - (float)startx + 2.0f * UI_UNIT_X - 1.0f * ufac, + (float)startx + 2.0f * UI_UNIT_X - 2.0f * ufac, (float)*starty + UI_UNIT_Y - 1.0f * ufac, - UI_UNIT_Y / 2.0f - 2.0f * ufac); + UI_UNIT_Y / 2.0f - 1.0f * ufac); glEnable(GL_BLEND); /* roundbox disables it */ te->flag |= TE_ACTIVE; // for lookup in display hierarchies @@ -1641,7 +1641,7 @@ static void outliner_draw_restrictcols(ARegion *ar) void draw_outliner(const bContext *C) { - Main *mainvar = CTX_data_main(C); + Main *mainvar = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index d11a8ed6369..a087ff65f63 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -183,8 +183,8 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports) { - /* can't rename rna datablocks entries */ - if (ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { + /* can't rename rna datablocks entries or listbases */ + if (ELEM4(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM, TSE_ID_BASE)) { /* do nothing */; } else if (ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 65de2a27568..f9fca378568 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -103,6 +103,7 @@ typedef struct TreeElement { #define TSE_NLA_TRACK 33 #define TSE_KEYMAP 34 #define TSE_KEYMAP_ITEM 35 +#define TSE_ID_BASE 36 /* button events */ #define OL_NAMEBUTTON 1 diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 0b585e1272b..fa337ba7af1 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -336,7 +336,8 @@ static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *soops tep = te->parent; if (tep) { tselem = TREESTORE(tep); - sce = (Scene *)tselem->id; + if (tselem->type == 0) + sce = (Scene *)tselem->id; } if (set) { // make new scene active diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 3b83279e09d..b2070cc2f1c 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -764,7 +764,7 @@ static EnumPropertyItem prop_id_op_types[] = { {OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""}, {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""}, {OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User", - "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"}, + "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"}, {OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""}, {OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""}, {OUTLINER_IDOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""}, diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index e6910280da4..ddbc49bf995 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -66,8 +66,10 @@ #include "BKE_fcurve.h" #include "BKE_main.h" +#include "BKE_library.h" #include "BKE_modifier.h" #include "BKE_sequencer.h" +#include "BKE_idcode.h" #include "ED_armature.h" #include "ED_screen.h" @@ -593,6 +595,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0); } + // can be inlined if necessary static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, ID *id) { @@ -785,6 +788,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor } // TODO: this function needs to be split up! It's getting a bit too large... +// Note: "ID" is not always a real ID static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index) { @@ -798,7 +802,9 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i if (!id) id = ((PointerRNA *)idv)->data; } - if (id == NULL) return NULL; + /* One exception */ + if (type == TSE_ID_BASE); + else if (id == NULL) return NULL; te = MEM_callocN(sizeof(TreeElement), "tree elem"); /* add to the visual tree */ @@ -822,14 +828,20 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i else if (type == TSE_ANIM_DATA) { /* pass */ } + else if (type == TSE_ID_BASE) { + /* pass */ + } else { te->name = id->name + 2; // default, can be overridden by Library or non-ID data te->idcode = GS(id->name); } if (type == 0) { + TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL; + /* ID datablock */ - outliner_add_id_contents(soops, te, tselem, id); + if (tsepar==NULL || tsepar->type != TSE_ID_BASE) + outliner_add_id_contents(soops, te, tselem, id); } else if (type == TSE_ANIM_DATA) { IdAdtTemplate *iat = (IdAdtTemplate *)idv; @@ -1194,8 +1206,8 @@ typedef struct tTreeSort { short idcode; } tTreeSort; -/* alphabetical comparator */ -static int treesort_alpha(const void *v1, const void *v2) +/* alphabetical comparator, tryping to put objects first */ +static int treesort_alpha_ob(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; int comp; @@ -1216,6 +1228,20 @@ static int treesort_alpha(const void *v1, const void *v2) return 0; } +/* alphabetical comparator */ +static int treesort_alpha(const void *v1, const void *v2) +{ + const tTreeSort *x1 = v1, *x2 = v2; + int comp; + + comp = strcmp(x1->name, x2->name); + + if (comp > 0) return 1; + else if (comp < 0) return -1; + return 0; +} + + /* this is nice option for later? doesnt look too useful... */ #if 0 static int treesort_obtype_alpha(const void *v1, const void *v2) @@ -1254,8 +1280,8 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) if (te == NULL) return; tselem = TREESTORE(te); - /* sorting rules; only object lists or deformgroups */ - if ((tselem->type == TSE_DEFGROUP) || (tselem->type == 0 && te->idcode == ID_OB)) { + /* sorting rules; only object lists, ID lists, or deformgroups */ + if ( ELEM(tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || (tselem->type == 0 && te->idcode == ID_OB)) { /* count first */ for (te = lb->first; te; te = te->next) totelem++; @@ -1270,15 +1296,27 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) tp->te = te; tp->name = te->name; tp->idcode = te->idcode; - if (tselem->type && tselem->type != TSE_DEFGROUP) tp->idcode = 0; // don't sort this + + if (tselem->type && tselem->type != TSE_DEFGROUP) + tp->idcode = 0; // don't sort this + if (tselem->type == TSE_ID_BASE) + tp->idcode = 1; // do sort this + tp->id = tselem->id; } - /* keep beginning of list */ - for (tp = tear, skip = 0; skip < totelem; skip++, tp++) - if (tp->idcode) break; - if (skip < totelem) - qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha); + /* just sort alphabetically */ + if (tear->idcode == 1) { + qsort(tear, totelem, sizeof(tTreeSort), treesort_alpha); + } + else { + /* keep beginning of list */ + for (tp = tear, skip = 0; skip < totelem; skip++, tp++) + if (tp->idcode) break; + + if (skip < totelem) + qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob); + } lb->first = lb->last = NULL; tp = tear; @@ -1384,6 +1422,42 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) return (lb->first != NULL); } +static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeElement *te, Library *lib) +{ + TreeElement *ten; + ListBase *lbarray[MAX_LIBARRAY]; + int a, tot; + + tot = set_listbasepointers(mainvar, lbarray); + for (a = 0; a < tot; a++) { + if (lbarray[a]->first) { + ID *id = lbarray[a]->first; + + /* check if there's data in current lib */ + for (; id; id = id->next) + if (id->lib == lib) + break; + + if (id) { + + ten = outliner_add_element(soops, &te->subtree, (void *)lbarray[a], NULL, TSE_ID_BASE, 0); + ten->directdata = lbarray[a]; + + ten->name = (char *)BKE_idcode_to_name_plural(GS(id->name)); + if (ten->name == NULL) + ten->name = "UNKNOWN"; + + for (id = lbarray[a]->first; id; id = id->next) { + if (id->lib == lib) + outliner_add_element(soops, &ten->subtree, id, ten, 0, 0); + } + } + } + } + +} + + /* ======================================================= */ /* Main Tree Building API */ @@ -1418,17 +1492,31 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) if (soops->outlinevis == SO_LIBRARIES) { Library *lib; + /* current file first - mainvar provides tselem with unique pointer - not used */ + ten = outliner_add_element(soops, &soops->tree, mainvar, NULL, TSE_ID_BASE, 0); + ten->name = "Current File"; + + tselem = TREESTORE(ten); + if (!tselem->used) + tselem->flag &= ~TSE_CLOSED; + + outliner_add_library_contents(mainvar, soops, ten, NULL); + for (lib = mainvar->library.first; lib; lib = lib->id.next) { ten = outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); lib->id.newid = (ID *)ten; + + outliner_add_library_contents(mainvar, soops, ten, lib); + } /* make hierarchy */ ten = soops->tree.first; + ten= ten->next; /* first one is main */ while (ten) { TreeElement *nten = ten->next, *par; tselem = TREESTORE(ten); lib = (Library *)tselem->id; - if (lib->parent) { + if (lib && lib->parent) { BLI_remlink(&soops->tree, ten); par = (TreeElement *)lib->parent->id.newid; BLI_addtail(&par->subtree, ten); diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 8155f9d645e..6219a9061f4 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -859,9 +859,9 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) * the other strips. */ if (!RNA_struct_property_is_set(op->ptr, "channel")) { if (seq->seq1) { - int chan = MAX3(seq->seq1 ? seq->seq1->machine : 0, - seq->seq2 ? seq->seq2->machine : 0, - seq->seq3 ? seq->seq3->machine : 0); + int chan = max_iii(seq->seq1 ? seq->seq1->machine : 0, + seq->seq2 ? seq->seq2->machine : 0, + seq->seq3 ? seq->seq3->machine : 0); if (chan < MAXSEQ) seq->machine = chan; } diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt index 9cc407f0604..6aaf4212779 100644 --- a/source/blender/editors/space_text/CMakeLists.txt +++ b/source/blender/editors/space_text/CMakeLists.txt @@ -37,10 +37,13 @@ set(INC_SYS set(SRC space_text.c text_draw.c + text_format.c + text_format_py.c text_header.c text_ops.c text_python.c + text_format.h text_intern.h ) diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index d74e32620af..9ac66ca1698 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -30,17 +30,12 @@ #include <string.h> -#include <stdio.h> #include "DNA_text_types.h" -#include "DNA_object_types.h" #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_rand.h" -#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -61,7 +56,8 @@ #include "RNA_access.h" -#include "text_intern.h" // own include +#include "text_format.h" +#include "text_intern.h" /* own include */ /* ******************** default callbacks for text space ***************** */ @@ -556,5 +552,8 @@ void ED_spacetype_text(void) BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); + + /* register formatters */ + ED_text_format_register_py(); } diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 24f40dbbe2a..7d4c9e5af98 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -29,10 +29,6 @@ */ -#include <math.h> -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> #include "MEM_guardedalloc.h" @@ -40,12 +36,10 @@ #include "BLI_blenlib.h" #include "BLI_math.h" -#include "BLI_utildefines.h" #include "DNA_text_types.h" #include "DNA_space_types.h" #include "DNA_screen_types.h" -#include "DNA_userdef_types.h" #include "BKE_context.h" #include "BKE_suggestions.h" @@ -53,11 +47,12 @@ #include "BIF_gl.h" -#include "ED_datafiles.h" #include "UI_interface.h" #include "UI_resources.h" +#include "UI_view2d.h" #include "text_intern.h" +#include "text_format.h" /******************** text font drawing ******************/ // XXX, fixme @@ -105,350 +100,6 @@ static int text_font_draw_character_utf8(SpaceText *st, int x, int y, const char return st->cwidth; } -/****************** flatten string **********************/ - -static void flatten_string_append(FlattenString *fs, const char *c, int accum, int len) -{ - int i; - - if (fs->pos + len > fs->len) { - char *nbuf; int *naccum; - fs->len *= 2; - - nbuf = MEM_callocN(sizeof(*fs->buf) * fs->len, "fs->buf"); - naccum = MEM_callocN(sizeof(*fs->accum) * fs->len, "fs->accum"); - - memcpy(nbuf, fs->buf, fs->pos * sizeof(*fs->buf)); - memcpy(naccum, fs->accum, fs->pos * sizeof(*fs->accum)); - - if (fs->buf != fs->fixedbuf) { - MEM_freeN(fs->buf); - MEM_freeN(fs->accum); - } - - fs->buf = nbuf; - fs->accum = naccum; - } - - for (i = 0; i < len; i++) { - fs->buf[fs->pos + i] = c[i]; - fs->accum[fs->pos + i] = accum; - } - - fs->pos += len; -} - -int flatten_string(SpaceText *st, FlattenString *fs, const char *in) -{ - int r, i, total = 0; - - memset(fs, 0, sizeof(FlattenString)); - fs->buf = fs->fixedbuf; - fs->accum = fs->fixedaccum; - fs->len = sizeof(fs->fixedbuf); - - for (r = 0, i = 0; *in; r++) { - if (*in == '\t') { - i = st->tabnumber - (total % st->tabnumber); - total += i; - - while (i--) - flatten_string_append(fs, " ", r, 1); - - in++; - } - else { - size_t len = BLI_str_utf8_size_safe(in); - flatten_string_append(fs, in, r, len); - in += len; - total++; - } - } - - flatten_string_append(fs, "\0", r, 1); - - return total; -} - -void flatten_string_free(FlattenString *fs) -{ - if (fs->buf != fs->fixedbuf) - MEM_freeN(fs->buf); - if (fs->accum != fs->fixedaccum) - MEM_freeN(fs->accum); -} - -/* Checks the specified source string for a Python built-in function name. This - * name must start at the beginning of the source string and must be followed by - * a non-identifier (see text_check_identifier(char)) or null character. - * - * If a built-in function is found, the length of the matching name is returned. - * Otherwise, -1 is returned. - * - * See: - * http://docs.python.org/py3k/reference/lexical_analysis.html#keywords - */ - -static int find_builtinfunc(char *string) -{ - int a, i; - const char *builtinfuncs[] = { - /* "False", "None", "True", */ /* see find_bool() */ - "and", "as", "assert", "break", - "class", "continue", "def", "del", "elif", "else", "except", - "finally", "for", "from", "global", "if", "import", "in", - "is", "lambda", "nonlocal", "not", "or", "pass", "raise", - "return", "try", "while", "with", "yield", - }; - - for (a = 0; a < sizeof(builtinfuncs) / sizeof(builtinfuncs[0]); a++) { - i = 0; - while (1) { - /* If we hit the end of a keyword... (eg. "def") */ - if (builtinfuncs[a][i] == '\0') { - /* If we still have identifier chars in the source (eg. "definate") */ - if (text_check_identifier(string[i])) - i = -1; /* No match */ - break; /* Next keyword if no match, otherwise we're done */ - - /* If chars mismatch, move on to next keyword */ - } - else if (string[i] != builtinfuncs[a][i]) { - i = -1; - break; /* Break inner loop, start next keyword */ - } - i++; - } - if (i > 0) break; /* If we have a match, we're done */ - } - return i; -} - -/* Checks the specified source string for a Python special name. This name must - * start at the beginning of the source string and must be followed by a non- - * identifier (see text_check_identifier(char)) or null character. - * - * If a special name is found, the length of the matching name is returned. - * Otherwise, -1 is returned. */ - -static int find_specialvar(char *string) -{ - int i = 0; - /* Check for "def" */ - if (string[0] == 'd' && string[1] == 'e' && string[2] == 'f') - i = 3; - /* Check for "class" */ - else if (string[0] == 'c' && string[1] == 'l' && string[2] == 'a' && string[3] == 's' && string[4] == 's') - i = 5; - /* If next source char is an identifier (eg. 'i' in "definate") no match */ - if (i == 0 || text_check_identifier(string[i])) - return -1; - return i; -} - -static int find_decorator(char *string) -{ - if (string[0] == '@') { - int i = 1; - while (text_check_identifier(string[i])) { - i++; - } - return i; - } - return -1; -} - -static int find_bool(char *string) -{ - int i = 0; - /* Check for "False" */ - if (string[0] == 'F' && string[1] == 'a' && string[2] == 'l' && string[3] == 's' && string[4] == 'e') - i = 5; - /* Check for "True" */ - else if (string[0] == 'T' && string[1] == 'r' && string[2] == 'u' && string[3] == 'e') - i = 4; - /* Check for "None" */ - else if (string[0] == 'N' && string[1] == 'o' && string[2] == 'n' && string[3] == 'e') - i = 4; - /* If next source char is an identifier (eg. 'i' in "definate") no match */ - if (i == 0 || text_check_identifier(string[i])) - return -1; - return i; -} - -/* Ensures the format string for the given line is long enough, reallocating - * as needed. Allocation is done here, alone, to ensure consistency. */ -static int text_check_format_len(TextLine *line, unsigned int len) -{ - if (line->format) { - if (strlen(line->format) < len) { - MEM_freeN(line->format); - line->format = MEM_mallocN(len + 2, "SyntaxFormat"); - if (!line->format) return 0; - } - } - else { - line->format = MEM_mallocN(len + 2, "SyntaxFormat"); - if (!line->format) return 0; - } - - return 1; -} - -/* Formats the specified line. If do_next is set, the process will move on to - * the succeeding line if it is affected (eg. multiline strings). Format strings - * may contain any of the following characters: - * '_' Whitespace - * '#' Comment text - * '!' Punctuation and other symbols - * 'n' Numerals - * 'l' String letters - * 'v' Special variables (class, def) - * 'b' Built-in names (print, for, etc.) - * 'q' Other text (identifiers, etc.) - * It is terminated with a null-terminator '\0' followed by a continuation - * flag indicating whether the line is part of a multi-line string. */ - -static void txt_format_line(SpaceText *st, TextLine *line, int do_next) -{ - FlattenString fs; - char *str, *fmt, orig, cont, find, prev = ' '; - int len, i; - - /* Get continuation from previous line */ - if (line->prev && line->prev->format != NULL) { - fmt = line->prev->format; - cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */ - } - else cont = 0; - - /* Get original continuation from this line */ - if (line->format != NULL) { - fmt = line->format; - orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */ - } - else orig = 0xFF; - - len = flatten_string(st, &fs, line->line); - str = fs.buf; - if (!text_check_format_len(line, len)) { - flatten_string_free(&fs); - return; - } - fmt = line->format; - - while (*str) { - /* Handle escape sequences by skipping both \ and next char */ - if (*str == '\\') { - *fmt = prev; fmt++; str++; - if (*str == '\0') break; - *fmt = prev; fmt++; str += BLI_str_utf8_size_safe(str); - continue; - } - /* Handle continuations */ - else if (cont) { - /* Triple strings ("""...""" or '''...''') */ - if (cont & TXT_TRISTR) { - find = (cont & TXT_DBLQUOTSTR) ? '"' : '\''; - if (*str == find && *(str + 1) == find && *(str + 2) == find) { - *fmt = 'l'; fmt++; str++; - *fmt = 'l'; fmt++; str++; - cont = 0; - } - /* Handle other strings */ - } - else { - find = (cont & TXT_DBLQUOTSTR) ? '"' : '\''; - if (*str == find) cont = 0; - } - - *fmt = 'l'; - str += BLI_str_utf8_size_safe(str) - 1; - } - /* Not in a string... */ - else { - /* Deal with comments first */ - if (prev == '#' || *str == '#') { - *fmt = '#'; - str += BLI_str_utf8_size_safe(str) - 1; - } - else if (*str == '"' || *str == '\'') { - /* Strings */ - find = *str; - cont = (*str == '"') ? TXT_DBLQUOTSTR : TXT_SNGQUOTSTR; - if (*(str + 1) == find && *(str + 2) == find) { - *fmt = 'l'; fmt++; str++; - *fmt = 'l'; fmt++; str++; - cont |= TXT_TRISTR; - } - *fmt = 'l'; - } - /* Whitespace (all ws. has been converted to spaces) */ - else if (*str == ' ') - *fmt = '_'; - /* Numbers (digits not part of an identifier and periods followed by digits) */ - else if ((prev != 'q' && text_check_digit(*str)) || (*str == '.' && text_check_digit(*(str + 1)))) - *fmt = 'n'; - /* Booleans */ - else if (prev != 'q' && (i = find_bool(str)) != -1) - if (i > 0) { - while (i > 1) { - *fmt = 'n'; fmt++; str++; - i--; - } - *fmt = 'n'; - } - else { - str += BLI_str_utf8_size_safe(str) - 1; - *fmt = 'q'; - } - /* Punctuation */ - else if (text_check_delim(*str)) - *fmt = '!'; - /* Identifiers and other text (no previous ws. or delims. so text continues) */ - else if (prev == 'q') { - str += BLI_str_utf8_size_safe(str) - 1; - *fmt = 'q'; - } - /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ - else { - /* Special vars(v) or built-in keywords(b) */ - if ((i = find_specialvar(str)) != -1) - prev = 'v'; - else if ((i = find_builtinfunc(str)) != -1) - prev = 'b'; - else if ((i = find_decorator(str)) != -1) - prev = 'v'; /* could have a new color for this */ - if (i > 0) { - while (i > 1) { - *fmt = prev; fmt++; str++; - i--; - } - *fmt = prev; - } - else { - str += BLI_str_utf8_size_safe(str) - 1; - *fmt = 'q'; - } - } - } - prev = *fmt; - fmt++; - str++; - } - - /* Terminate and add continuation char */ - *fmt = '\0'; fmt++; - *fmt = cont; - - /* If continuation has changed and we're allowed, process the next line */ - if (cont != orig && do_next && line->next) { - txt_format_line(st, line->next, do_next); - } - - flatten_string_free(&fs); -} - #if 0 /* Formats every line of the current text */ static void txt_format_text(SpaceText *st) @@ -1085,12 +736,12 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) blank_lines = st->viewlines / 2; /* nicer code: use scroll rect for entire bar */ - back->xmin = ar->winx - 18; + back->xmin = ar->winx - (V2D_SCROLL_WIDTH + 1); back->xmax = ar->winx; back->ymin = 0; back->ymax = ar->winy; - scroll->xmin = ar->winx - 17; + scroll->xmin = ar->winx - V2D_SCROLL_WIDTH; scroll->xmax = ar->winx - 5; scroll->ymin = 4; scroll->ymax = 4 + pix_available; @@ -1394,7 +1045,7 @@ static void draw_cursor(SpaceText *st, ARegion *ar) UI_ThemeColor(TH_SHADE2); x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; - y = ar->winy - 2; + y = ar->winy; if (vcurl == vsell) { y -= vcurl * lheight; @@ -1469,7 +1120,7 @@ static void draw_cursor(SpaceText *st, ARegion *ar) /* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */ x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; x += vselc * st->cwidth; - y = ar->winy - 2 - vsell * lheight; + y = ar->winy - vsell * lheight; if (st->overwrite) { char ch = text->sell->line[text->selc]; @@ -1620,6 +1271,7 @@ static void draw_brackets(SpaceText *st, ARegion *ar) void draw_text_main(SpaceText *st, ARegion *ar) { Text *text = st->text; + TextFormatType *tft = ED_text_format_get(text); TextLine *tmp; rcti scroll, back; char linenr[12]; @@ -1651,7 +1303,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) lineno = 0; for (i = 0; i < st->top && tmp; i++) { if (st->showsyntax && !tmp->format) - txt_format_line(st, tmp, 0); + tft->format_line(st, tmp, 0); if (st->wordwrap) { int lines = text_get_visible_lines_no(st, lineno); @@ -1700,7 +1352,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) for (i = 0; y > 0 && i < st->viewlines && tmp; i++, tmp = tmp->next) { if (st->showsyntax && !tmp->format) - txt_format_line(st, tmp, 0); + tft->format_line(st, tmp, 0); if (st->showlinenrs && !wrap_skip) { /* draw line number */ diff --git a/source/blender/editors/space_text/text_format.c b/source/blender/editors/space_text/text_format.c new file mode 100644 index 00000000000..0b3856f4414 --- /dev/null +++ b/source/blender/editors/space_text/text_format.c @@ -0,0 +1,148 @@ +/* + * ***** 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 + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_text/text_format.c + * \ingroup sptext + */ + +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" + +#include "DNA_text_types.h" +#include "DNA_space_types.h" + +#include "text_format.h" + + +/****************** flatten string **********************/ + +static void flatten_string_append(FlattenString *fs, const char *c, int accum, int len) +{ + int i; + + if (fs->pos + len > fs->len) { + char *nbuf; int *naccum; + fs->len *= 2; + + nbuf = MEM_callocN(sizeof(*fs->buf) * fs->len, "fs->buf"); + naccum = MEM_callocN(sizeof(*fs->accum) * fs->len, "fs->accum"); + + memcpy(nbuf, fs->buf, fs->pos * sizeof(*fs->buf)); + memcpy(naccum, fs->accum, fs->pos * sizeof(*fs->accum)); + + if (fs->buf != fs->fixedbuf) { + MEM_freeN(fs->buf); + MEM_freeN(fs->accum); + } + + fs->buf = nbuf; + fs->accum = naccum; + } + + for (i = 0; i < len; i++) { + fs->buf[fs->pos + i] = c[i]; + fs->accum[fs->pos + i] = accum; + } + + fs->pos += len; +} + +int flatten_string(SpaceText *st, FlattenString *fs, const char *in) +{ + int r, i, total = 0; + + memset(fs, 0, sizeof(FlattenString)); + fs->buf = fs->fixedbuf; + fs->accum = fs->fixedaccum; + fs->len = sizeof(fs->fixedbuf); + + for (r = 0, i = 0; *in; r++) { + if (*in == '\t') { + i = st->tabnumber - (total % st->tabnumber); + total += i; + + while (i--) + flatten_string_append(fs, " ", r, 1); + + in++; + } + else { + size_t len = BLI_str_utf8_size_safe(in); + flatten_string_append(fs, in, r, len); + in += len; + total++; + } + } + + flatten_string_append(fs, "\0", r, 1); + + return total; +} + +void flatten_string_free(FlattenString *fs) +{ + if (fs->buf != fs->fixedbuf) + MEM_freeN(fs->buf); + if (fs->accum != fs->fixedaccum) + MEM_freeN(fs->accum); +} + +/* Ensures the format string for the given line is long enough, reallocating + * as needed. Allocation is done here, alone, to ensure consistency. */ +int text_check_format_len(TextLine *line, unsigned int len) +{ + if (line->format) { + if (strlen(line->format) < len) { + MEM_freeN(line->format); + line->format = MEM_mallocN(len + 2, "SyntaxFormat"); + if (!line->format) return 0; + } + } + else { + line->format = MEM_mallocN(len + 2, "SyntaxFormat"); + if (!line->format) return 0; + } + + return 1; +} + +/* *** Registration *** */ +static ListBase tft_lb = {NULL, NULL}; +void ED_text_format_register(TextFormatType *tft) +{ + BLI_addtail(&tft_lb, tft); +} + +TextFormatType *ED_text_format_get(Text *UNUSED(text)) +{ + /* NOTE: once more types are added we'll need to return some type based on 'text' + * for now this function is more of a placeholder */ + + return tft_lb.first; +} diff --git a/source/blender/editors/space_text/text_format.h b/source/blender/editors/space_text/text_format.h new file mode 100644 index 00000000000..7b5b326db6a --- /dev/null +++ b/source/blender/editors/space_text/text_format.h @@ -0,0 +1,77 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_text/text_format.h + * \ingroup sptext + */ + +#ifndef __TEXT_FORMAT_H__ +#define __TEXT_FORMAT_H__ + +/* *** Flatten String *** */ +typedef struct FlattenString { + char fixedbuf[256]; + int fixedaccum[256]; + + char *buf; + int *accum; + int pos, len; +} FlattenString; + +int flatten_string(struct SpaceText *st, FlattenString *fs, const char *in); +void flatten_string_free(FlattenString *fs); +int text_check_format_len(TextLine *line, unsigned int len); + + +/* *** Generalize Formatting *** */ +typedef struct TextFormatType { + struct TextFormatType *next, *prev; + + /* Formats the specified line. If do_next is set, the process will move on to + * the succeeding line if it is affected (eg. multiline strings). Format strings + * may contain any of the following characters: + * '_' Whitespace + * '#' Comment text + * '!' Punctuation and other symbols + * 'n' Numerals + * 'l' String letters + * 'v' Special variables (class, def) + * 'b' Built-in names (print, for, etc.) + * 'q' Other text (identifiers, etc.) + * It is terminated with a null-terminator '\0' followed by a continuation + * flag indicating whether the line is part of a multi-line string. */ + void (*format_line)(SpaceText *st, TextLine *line, int do_next); + + const char **ext; /* NULL terminated extensions */ +} TextFormatType; + +TextFormatType *ED_text_format_get(Text *text); +void ED_text_format_register(TextFormatType *tft); + +/* formatters */ +void ED_text_format_register_py(void); + +#endif /* __TEXT_FORMAT_H__ */ diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c new file mode 100644 index 00000000000..2a0f483d80c --- /dev/null +++ b/source/blender/editors/space_text/text_format_py.c @@ -0,0 +1,296 @@ +/* + * ***** 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 + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_text/text_format_py.c + * \ingroup sptext + */ + +#include <string.h> + +#include "BLI_blenlib.h" + +#include "DNA_text_types.h" +#include "DNA_space_types.h" + +#include "BKE_text.h" + +#include "text_format.h" + +/* *** Local Functions (for format_line) *** */ + + +/* Checks the specified source string for a Python built-in function name. This + * name must start at the beginning of the source string and must be followed by + * a non-identifier (see text_check_identifier(char)) or null character. + * + * If a built-in function is found, the length of the matching name is returned. + * Otherwise, -1 is returned. + * + * See: + * http://docs.python.org/py3k/reference/lexical_analysis.html#keywords + */ + +static int txtfmt_py_find_builtinfunc(char *string) +{ + int a, i; + const char *builtinfuncs[] = { + /* "False", "None", "True", */ /* see find_bool() */ + "and", "as", "assert", "break", + "class", "continue", "def", "del", "elif", "else", "except", + "finally", "for", "from", "global", "if", "import", "in", + "is", "lambda", "nonlocal", "not", "or", "pass", "raise", + "return", "try", "while", "with", "yield", + }; + + for (a = 0; a < sizeof(builtinfuncs) / sizeof(builtinfuncs[0]); a++) { + i = 0; + while (1) { + /* If we hit the end of a keyword... (eg. "def") */ + if (builtinfuncs[a][i] == '\0') { + /* If we still have identifier chars in the source (eg. "definate") */ + if (text_check_identifier(string[i])) + i = -1; /* No match */ + break; /* Next keyword if no match, otherwise we're done */ + + /* If chars mismatch, move on to next keyword */ + } + else if (string[i] != builtinfuncs[a][i]) { + i = -1; + break; /* Break inner loop, start next keyword */ + } + i++; + } + if (i > 0) break; /* If we have a match, we're done */ + } + return i; +} + +/* Checks the specified source string for a Python special name. This name must + * start at the beginning of the source string and must be followed by a non- + * identifier (see text_check_identifier(char)) or null character. + * + * If a special name is found, the length of the matching name is returned. + * Otherwise, -1 is returned. */ + +static int txtfmt_py_find_specialvar(char *string) +{ + int i = 0; + /* Check for "def" */ + if (string[0] == 'd' && string[1] == 'e' && string[2] == 'f') + i = 3; + /* Check for "class" */ + else if (string[0] == 'c' && string[1] == 'l' && string[2] == 'a' && string[3] == 's' && string[4] == 's') + i = 5; + /* If next source char is an identifier (eg. 'i' in "definate") no match */ + if (i == 0 || text_check_identifier(string[i])) + return -1; + return i; +} + +static int txtfmt_py_find_decorator(char *string) +{ + if (string[0] == '@') { + int i = 1; + while (text_check_identifier(string[i])) { + i++; + } + return i; + } + return -1; +} + +static int txtfmt_py_find_bool(char *string) +{ + int i = 0; + /* Check for "False" */ + if (string[0] == 'F' && string[1] == 'a' && string[2] == 'l' && string[3] == 's' && string[4] == 'e') + i = 5; + /* Check for "True" */ + else if (string[0] == 'T' && string[1] == 'r' && string[2] == 'u' && string[3] == 'e') + i = 4; + /* Check for "None" */ + else if (string[0] == 'N' && string[1] == 'o' && string[2] == 'n' && string[3] == 'e') + i = 4; + /* If next source char is an identifier (eg. 'i' in "definate") no match */ + if (i == 0 || text_check_identifier(string[i])) + return -1; + return i; +} + +static void txtfmt_py_format_line(SpaceText *st, TextLine *line, int do_next) +{ + FlattenString fs; + char *str, *fmt, orig, cont, find, prev = ' '; + int len, i; + + /* Get continuation from previous line */ + if (line->prev && line->prev->format != NULL) { + fmt = line->prev->format; + cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */ + } + else { + cont = 0; + } + + /* Get original continuation from this line */ + if (line->format != NULL) { + fmt = line->format; + orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */ + } + else { + orig = 0xFF; + } + + len = flatten_string(st, &fs, line->line); + str = fs.buf; + if (!text_check_format_len(line, len)) { + flatten_string_free(&fs); + return; + } + fmt = line->format; + + while (*str) { + /* Handle escape sequences by skipping both \ and next char */ + if (*str == '\\') { + *fmt = prev; fmt++; str++; + if (*str == '\0') break; + *fmt = prev; fmt++; str += BLI_str_utf8_size_safe(str); + continue; + } + /* Handle continuations */ + else if (cont) { + /* Triple strings ("""...""" or '''...''') */ + if (cont & TXT_TRISTR) { + find = (cont & TXT_DBLQUOTSTR) ? '"' : '\''; + if (*str == find && *(str + 1) == find && *(str + 2) == find) { + *fmt = 'l'; fmt++; str++; + *fmt = 'l'; fmt++; str++; + cont = 0; + } + /* Handle other strings */ + } + else { + find = (cont & TXT_DBLQUOTSTR) ? '"' : '\''; + if (*str == find) cont = 0; + } + + *fmt = 'l'; + str += BLI_str_utf8_size_safe(str) - 1; + } + /* Not in a string... */ + else { + /* Deal with comments first */ + if (prev == '#' || *str == '#') { + *fmt = '#'; + str += BLI_str_utf8_size_safe(str) - 1; + } + else if (*str == '"' || *str == '\'') { + /* Strings */ + find = *str; + cont = (*str == '"') ? TXT_DBLQUOTSTR : TXT_SNGQUOTSTR; + if (*(str + 1) == find && *(str + 2) == find) { + *fmt = 'l'; fmt++; str++; + *fmt = 'l'; fmt++; str++; + cont |= TXT_TRISTR; + } + *fmt = 'l'; + } + /* Whitespace (all ws. has been converted to spaces) */ + else if (*str == ' ') + *fmt = '_'; + /* Numbers (digits not part of an identifier and periods followed by digits) */ + else if ((prev != 'q' && text_check_digit(*str)) || (*str == '.' && text_check_digit(*(str + 1)))) + *fmt = 'n'; + /* Booleans */ + else if (prev != 'q' && (i = txtfmt_py_find_bool(str)) != -1) + if (i > 0) { + while (i > 1) { + *fmt = 'n'; fmt++; str++; + i--; + } + *fmt = 'n'; + } + else { + str += BLI_str_utf8_size_safe(str) - 1; + *fmt = 'q'; + } + /* Punctuation */ + else if (text_check_delim(*str)) + *fmt = '!'; + /* Identifiers and other text (no previous ws. or delims. so text continues) */ + else if (prev == 'q') { + str += BLI_str_utf8_size_safe(str) - 1; + *fmt = 'q'; + } + /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ + else { + /* Special vars(v) or built-in keywords(b) */ + if ((i = txtfmt_py_find_specialvar(str)) != -1) + prev = 'v'; + else if ((i = txtfmt_py_find_builtinfunc(str)) != -1) + prev = 'b'; + else if ((i = txtfmt_py_find_decorator(str)) != -1) + prev = 'v'; /* could have a new color for this */ + if (i > 0) { + while (i > 1) { + *fmt = prev; fmt++; str++; + i--; + } + *fmt = prev; + } + else { + str += BLI_str_utf8_size_safe(str) - 1; + *fmt = 'q'; + } + } + } + prev = *fmt; + fmt++; + str++; + } + + /* Terminate and add continuation char */ + *fmt = '\0'; fmt++; + *fmt = cont; + + /* If continuation has changed and we're allowed, process the next line */ + if (cont != orig && do_next && line->next) { + txtfmt_py_format_line(st, line->next, do_next); + } + + flatten_string_free(&fs); +} + +void ED_text_format_register_py(void) +{ + static TextFormatType tft = {0}; + static const char *ext[] = {"py", NULL}; + + tft.format_line = txtfmt_py_format_line; + tft.ext = ext; + + ED_text_format_register(&tft); +} diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index 7dc3ec1ac60..52253b2d5d2 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -29,20 +29,11 @@ */ -#include <stdlib.h> -#include <string.h> -#include <stdio.h> /* file time checking */ -#include <ctype.h> -#include <sys/types.h> -#include <sys/stat.h> #ifndef _WIN32 -# include <unistd.h> #else -# include <io.h> -# include "BLI_winstuff.h" #endif #include "DNA_windowmanager_types.h" @@ -50,7 +41,6 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_screen.h" diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index 6d3b184f6cf..c7f9512737f 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -68,18 +68,6 @@ void text_update_cursor_moved(struct bContext *C); #define TOOL_SUGG_LIST 0x01 #define TOOL_DOCUMENT 0x02 -typedef struct FlattenString { - char fixedbuf[256]; - int fixedaccum[256]; - - char *buf; - int *accum; - int pos, len; -} FlattenString; - -int flatten_string(struct SpaceText *st, FlattenString *fs, const char *in); -void flatten_string_free(FlattenString *fs); - int wrap_width(struct SpaceText *st, struct ARegion *ar); void wrap_offset(struct SpaceText *st, struct ARegion *ar, struct TextLine *linein, int cursin, int *offl, int *offc); void wrap_offset_in_line(struct SpaceText *st, struct ARegion *ar, struct TextLine *linep, int cursin, int *offl, int *offc); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 71044579df4..01041c0e385 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -30,19 +30,14 @@ */ -#include <stdlib.h> #include <string.h> -#include <ctype.h> /* ispunct */ -#include <sys/stat.h> #include <errno.h> #include "MEM_guardedalloc.h" #include "DNA_text_types.h" -#include "DNA_userdef_types.h" #include "BLI_blenlib.h" -#include "BLI_utildefines.h" #include "BLF_translation.h" @@ -72,6 +67,7 @@ #endif #include "text_intern.h" +#include "text_format.h" /************************ poll ***************************/ diff --git a/source/blender/editors/space_text/text_python.c b/source/blender/editors/space_text/text_python.c index a06144b8260..1201302dad0 100644 --- a/source/blender/editors/space_text/text_python.c +++ b/source/blender/editors/space_text/text_python.c @@ -28,22 +28,17 @@ * \ingroup sptext */ - #include <ctype.h> -#include <stdio.h> -#include <stdlib.h> #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_text_types.h" #include "DNA_userdef_types.h" -#include "BKE_blender.h" #include "BKE_suggestions.h" #include "BKE_text.h" #include "BLI_blenlib.h" -#include "BLI_utildefines.h" #include "WM_types.h" diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 1f071e5f20e..3722e6797f8 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -759,7 +759,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa (vos->flag & V3D_CACHE_TEXT_GLOBALSPACE) ? rv3d->persmat : rv3d->persmatob, (vos->flag & V3D_CACHE_TEXT_LOCALCLIP) != 0, vos->vec, vos->sco, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { tot++; } @@ -1290,6 +1290,13 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glVertex3fv(vvec_clip); glEnd(); } + /* Else, draw spot direction (using distance as end limit, same as for Area lamp). */ + else { + glBegin(GL_LINE_STRIP); + glVertex3f(0.0, 0.0, -circrad); + glVertex3f(0.0, 0.0, -la->dist); + glEnd(); + } } else if (ELEM(la->type, LA_HEMI, LA_SUN)) { @@ -7167,7 +7174,7 @@ static void bbs_mesh_solid(Scene *scene, Object *ob) glColor3ub(0, 0, 0); - if ((me->editflag & ME_EDIT_PAINT_MASK)) + if ((me->editflag & ME_EDIT_PAINT_FACE_SEL)) dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, GPU_enable_material, NULL, me, 0); else dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, GPU_enable_material, NULL, me, 0); @@ -7221,7 +7228,7 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec } else { Mesh *me = ob->data; - if ((me->editflag & ME_EDIT_VERT_SEL) && + if ((me->editflag & ME_EDIT_PAINT_VERT_SEL) && /* currently vertex select only supports weight paint */ (ob->mode & OB_MODE_WEIGHT_PAINT)) { diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 70690e2dce7..29daee3e11b 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -449,8 +449,8 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob, * inserting previously found vertex into the plane equation */ /* d0 = (viewnormal[0]*cv[i][0] + viewnormal[1]*cv[i][1] + viewnormal[2]*cv[i][2]); */ /* UNUSED */ - ds = (ABS(viewnormal[0]) * size[0] + ABS(viewnormal[1]) * size[1] + ABS(viewnormal[2]) * size[2]); - dd = MAX3(sds->global_size[0], sds->global_size[1], sds->global_size[2]) / 128.f; + ds = (fabsf(viewnormal[0]) * size[0] + fabsf(viewnormal[1]) * size[1] + fabsf(viewnormal[2]) * size[2]); + dd = max_fff(sds->global_size[0], sds->global_size[1], sds->global_size[2]) / 128.f; n = 0; good_index = i; @@ -570,7 +570,7 @@ void draw_smoke_velocity(SmokeDomainSettings *domain, Object *ob) float min[3]; float *cell_size = domain->cell_size; - float step_size = ((float)MAX3(base_res[0], base_res[1], base_res[2])) / 16.f; + float step_size = ((float)max_iii(base_res[0], base_res[1], base_res[2])) / 16.f; float vf = domain->scale / 16.f * 2.f; /* velocity factor */ glLineWidth(1.0f); @@ -624,7 +624,7 @@ void draw_smoke_heat(SmokeDomainSettings *domain, Object *ob) float min[3]; float *cell_size = domain->cell_size; - float step_size = ((float)MAX3(base_res[0], base_res[1], base_res[2])) / 16.f; + float step_size = ((float)max_iii(base_res[0], base_res[1], base_res[2])) / 16.f; float vf = domain->scale / 16.f * 2.f; /* velocity factor */ /* set first position so that it doesn't jump when domain moves */ diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 61649e105ee..4ade47fbdc7 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -466,6 +466,16 @@ static int view3d_ob_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSE return 0; } +static int view3d_group_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) +{ + if (drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if (GS(id->name) == ID_GR) + return 1; + } + return 0; +} + static int view3d_mat_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { if (drag->type == WM_DRAG_ID) { @@ -520,6 +530,14 @@ static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "name", id->name + 2); } +static void view3d_group_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + ID *id = (ID *)drag->poin; + + drop->opcontext = WM_OP_EXEC_DEFAULT; + RNA_string_set(drop->ptr, "name", id->name + 2); +} + static void view3d_id_drop_copy(wmDrag *drag, wmDropBox *drop) { ID *id = (ID *)drag->poin; @@ -547,6 +565,7 @@ static void view3d_dropboxes(void) WM_dropbox_add(lb, "OBJECT_OT_drop_named_material", view3d_mat_drop_poll, view3d_id_drop_copy); WM_dropbox_add(lb, "MESH_OT_drop_named_image", view3d_ima_ob_drop_poll, view3d_id_path_drop_copy); WM_dropbox_add(lb, "VIEW3D_OT_background_image_add", view3d_ima_bg_drop_poll, view3d_id_path_drop_copy); + WM_dropbox_add(lb, "OBJECT_OT_group_instance_add", view3d_group_drop_poll, view3d_group_drop_copy); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index a1f0bf69497..78c3f4e4f4a 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1551,7 +1551,8 @@ static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) vod = op->customdata; if (event->type == MOUSEPAN) { - viewmove_apply(vod, event->prevx, event->prevy); + /* invert it, trackpad scroll follows same principle as 2d windows this way */ + viewmove_apply(vod, 2 * event->x - event->prevx, 2 * event->y - event->prevy); ED_view3d_depth_tag_update(vod->rv3d); viewops_data_free(C, op); @@ -2232,7 +2233,7 @@ static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar, float new_dist; sub_v3_v3v3(afm, max, min); - size = MAX3(afm[0], afm[1], afm[2]); + size = max_fff(afm[0], afm[1], afm[2]); if (ok_dist) { /* fix up zoom distance if needed */ diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index cddfae53f6f..f8c9497a686 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -1041,8 +1041,8 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) const int flag = U.ndof_flag; #if 0 - int shouldRotate = (flag & NDOF_SHOULD_ROTATE) && (fly->pan_view == FALSE), - shouldTranslate = (flag & (NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM)); + int shouldRotate = (flag & NDOF_SHOULD_ROTATE) && (fly->pan_view == FALSE); + int shouldTranslate = (flag & (NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM)); #endif int shouldRotate = (fly->pan_view == FALSE); diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 34b983f83df..d4bdf6c3177 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -116,7 +116,7 @@ static eV3DProjStatus ed_view3d_project__internal(ARegion *ar, float perspmat[4][4], const int is_local, /* normally hidden */ const float co[3], float r_co[2], const eV3DProjTest flag) { - float fx, fy, vec4[4]; + float vec4[4]; /* check for bad flags */ BLI_assert((flag & V3D_PROJ_TEST_ALL) == flag); @@ -134,13 +134,19 @@ static eV3DProjStatus ed_view3d_project__internal(ARegion *ar, vec4[3] = 1.0; mul_m4_v4(perspmat, vec4); - if (vec4[3] > (float)BL_NEAR_CLIP) { - fx = ((float)ar->winx / 2.0f) * (1.0f + vec4[0] / vec4[3]); - if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fx > 0 && fx < ar->winx)) { - fy = ((float)ar->winy / 2.0f) * (1.0f + vec4[1] / vec4[3]); + if (((flag & V3D_PROJ_TEST_CLIP_NEAR) == 0) || (vec4[3] > (float)BL_NEAR_CLIP)) { + const float scalar = (vec4[3] != 0.0f) ? (1.0f / vec4[3]): 0.0f; + const float fx = ((float)ar->winx / 2.0f) * (1.0f + (vec4[0] * scalar)); + if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fx > 0.0f && fx < (float)ar->winx)) { + const float fy = ((float)ar->winy / 2.0f) * (1.0f + (vec4[1] * scalar)); if (((flag & V3D_PROJ_TEST_CLIP_WIN) == 0) || (fy > 0.0f && fy < (float)ar->winy)) { - r_co[0] = (short)floor(fx); - r_co[1] = (short)floor(fy); + r_co[0] = floorf(fx); + r_co[1] = floorf(fy); + + /* check if the point is behind the view, we need to flip in this case */ + if (UNLIKELY((flag & V3D_PROJ_TEST_CLIP_NEAR) == 0) && (vec4[3] < 0.0f)) { + negate_v2(r_co); + } } else { return V3D_PROJ_RET_CLIP_WIN; @@ -166,8 +172,8 @@ eV3DProjStatus ED_view3d_project_short_ex(ARegion *ar, float perspmat[4][4], con if ((tvec[0] > -32700.0f && tvec[0] < 32700.0f) && (tvec[1] > -32700.0f && tvec[1] < 32700.0f)) { - r_co[0] = (short)floor(tvec[0]); - r_co[1] = (short)floor(tvec[1]); + r_co[0] = (short)floorf(tvec[0]); + r_co[1] = (short)floorf(tvec[1]); } else { ret = V3D_PROJ_RET_OVERFLOW; @@ -185,8 +191,8 @@ eV3DProjStatus ED_view3d_project_int_ex(ARegion *ar, float perspmat[4][4], const if ((tvec[0] > -2140000000.0f && tvec[0] < 2140000000.0f) && (tvec[1] > -2140000000.0f && tvec[1] < 2140000000.0f)) { - r_co[0] = (int)floor(tvec[0]); - r_co[1] = (int)floor(tvec[1]); + r_co[0] = (int)floorf(tvec[0]); + r_co[1] = (int)floorf(tvec[1]); } else { ret = V3D_PROJ_RET_OVERFLOW; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index cffa53b5dfb..d37042fa2ec 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -541,11 +541,11 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m if (ts->selectmode & SCE_SELECT_EDGE) { /* Does both bbsel and non-bbsel versions (need screen cos for both) */ data.pass = 0; - mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_NOP); + mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); if (data.is_done == 0) { data.pass = 1; - mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_NOP); + mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); } } @@ -1448,7 +1448,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese if (BASE_SELECTABLE(v3d, base)) { float screen_co[2]; if (ED_view3d_project_float_global(ar, base->object->obmat[3], screen_co, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { float dist_temp = len_manhattan_v2v2(mval_fl, screen_co); if (base == BASACT) dist_temp += 10.0f; @@ -1803,11 +1803,11 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten /* Does both bbsel and non-bbsel versions (need screen cos for both) */ data.pass = 0; - mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_NOP); + mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); if (data.is_done == 0) { data.pass = 1; - mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_NOP); + mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); } } @@ -2333,7 +2333,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f edbm_backbuf_check_and_select_edges(vc->em, select == LEFTMOUSE); } else { - mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_PROJ_TEST_NOP); + mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); } } @@ -2670,7 +2670,7 @@ static int object_circle_select(ViewContext *vc, int select, const int mval[2], if (BASE_SELECTABLE(vc->v3d, base) && ((base->flag & SELECT) != select_flag)) { float screen_co[2]; if (ED_view3d_project_float_global(vc->ar, base->object->obmat[3], screen_co, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { if (len_squared_v2v2(mval_fl, screen_co) <= radius_squared) { ED_base_object_select(base, select); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 56ce9bda607..41d092ce2b1 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1070,11 +1070,9 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL } } } - - box[0] = (max[0] - min[0]); - box[1] = (max[1] - min[1]); - box[2] = (max[2] - min[2]); - size = MAX3(box[0], box[1], box[2]); + + sub_v3_v3v3(box, max, min); + size = max_fff(box[0], box[1], box[2]); /* do not zoom closer than the near clipping plane */ size = max_ff(size, v3d->near * 1.5f); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 65b29cf6475..b2ee17b8a8b 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -352,6 +352,7 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2]) case SPACE_VIEW3D: { if (t->ar->regiontype == RGN_TYPE_WINDOW) { + /* allow points behind the view [#33643] */ if (ED_view3d_project_float_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { /* XXX, 2.64 and prior did this, weak! */ adr[0] = t->ar->winx / 2.0f; @@ -4885,6 +4886,7 @@ static void calcNonProportionalEdgeSlide(TransInfo *t, SlideData *sld, const flo sv->edge_len = len_v3v3(sv->upvec, sv->downvec); mul_v3_m4v3(v_proj, t->obedit->obmat, sv->v->co); + /* allow points behind the view [#33643] */ if (ED_view3d_project_float_global(t->ar, v_proj, v_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { dist = len_squared_v2v2(mval, v_proj); if (dist < min_dist) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 6d7ddd4e0ed..8f1d6a7b46e 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1529,13 +1529,6 @@ void calculateCenterMedian(TransInfo *t) total++; } } - else { - /* - * All the selected elements are at the head of the array - * which means we can stop when it finds unselected data - */ - break; - } } if (i) mul_v3_fl(partial, 1.0f / total); @@ -1555,13 +1548,6 @@ void calculateCenterBound(TransInfo *t) if (!(t->data[i].flag & TD_NOCENTER)) minmax_v3v3_v3(min, max, t->data[i].center); } - else { - /* - * All the selected elements are at the head of the array - * which means we can stop when it finds unselected data - */ - break; - } } else { copy_v3_v3(max, t->data[i].center); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 8703234122a..5d3a5983030 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -3109,7 +3109,7 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart) sina2 = sin(a2); sina3 = sin(a3); - sinmax = MAX3(sina1, sina2, sina3); + sinmax = max_fff(sina1, sina2, sina3); /* shift vertices to find most stable order */ if (sina3 != sinmax) { diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 88a9122e88c..07462302700 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -101,9 +101,9 @@ void GPU_render_text(MTFace *tface, int mode, float line_start= 0.0f, line_height; if (v4) - line_height= MAX4(v1[1], v2[1], v3[1], v4[2]) - MIN4(v1[1], v2[1], v3[1], v4[2]); + line_height = max_ffff(v1[1], v2[1], v3[1], v4[2]) - min_ffff(v1[1], v2[1], v3[1], v4[2]); else - line_height= MAX3(v1[1], v2[1], v3[1]) - MIN3(v1[1], v2[1], v3[1]); + line_height = max_fff(v1[1], v2[1], v3[1]) - min_fff(v1[1], v2[1], v3[1]); line_height *= 1.2f; /* could be an option? */ /* end multiline */ @@ -768,11 +768,14 @@ int GPU_upload_dxt_texture(ImBuf *ibuf) return FALSE; } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + if (GLEW_EXT_texture_filter_anisotropic) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); + blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16; for (i=0; i<ibuf->dds_data.nummipmaps && (width||height); ++i) { if (width == 0) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 9a238e979fa..e89be91c89a 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -811,7 +811,7 @@ void mtex_rgb_mul(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 inc float facm; fact *= facg; - facm = 1.0-facg; + facm = 1.0-fact; incol = (facm + fact*texcol)*outcol; } @@ -821,7 +821,7 @@ void mtex_rgb_screen(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 float facm; fact *= facg; - facm = 1.0-facg; + facm = 1.0-fact; incol = vec3(1.0) - (vec3(facm) + fact*(vec3(1.0) - texcol))*(vec3(1.0) - outcol); } @@ -831,7 +831,7 @@ void mtex_rgb_overlay(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 float facm; fact *= facg; - facm = 1.0-facg; + facm = 1.0-fact; if(outcol.r < 0.5) incol.r = outcol.r*(facm + 2.0*fact*texcol.r); @@ -888,11 +888,11 @@ void mtex_rgb_dark(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 in fact *= facg; facm = 1.0-fact; - col = fact*texcol.r; + col= texcol.r + ((1.0 -texcol.r)*facm); if(col < outcol.r) incol.r = col; else incol.r = outcol.r; - col = fact*texcol.g; + col= texcol.g + ((1.0 -texcol.g)*facm); if(col < outcol.g) incol.g = col; else incol.g = outcol.g; - col = fact*texcol.b; + col= texcol.b + ((1.0 -texcol.b)*facm); if(col < outcol.b) incol.b = col; else incol.b = outcol.b; } @@ -901,7 +901,6 @@ void mtex_rgb_light(vec3 outcol, vec3 texcol, float fact, float facg, out vec3 i float facm, col; fact *= facg; - facm = 1.0-fact; col = fact*texcol.r; if(col > outcol.r) incol.r = col; else incol.r = outcol.r; diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 1b3a6d4a4cd..ca0b26fa4b7 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -355,7 +355,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int ibuf->x = x; ibuf->y = y; ibuf->planes = planes; - ibuf->ftype = TGA; + ibuf->ftype = PNG | 90; /* the 90 means, set compression to nearly the maximum */ ibuf->channels = 4; /* float option, is set to other values when buffers get assigned */ ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254f; /* IMB_DPI_DEFAULT -> pixels-per-meter */ diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp index 05821b27ca6..660643530ba 100644 --- a/source/blender/imbuf/intern/dds/FlipDXT.cpp +++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp @@ -147,10 +147,10 @@ static void FlipDXT5BlockFull(uint8_t *block) block[2] = line_3_2 & 0xff; block[3] = (line_3_2 & 0xff00) >> 8; - block[4] = (line_3_2 & 0xff0000) >> 8; + block[4] = (line_3_2 & 0xff0000) >> 16; block[5] = line_1_0 & 0xff; block[6] = (line_1_0 & 0xff00) >> 8; - block[7] = (line_1_0 & 0xff0000) >> 8; + block[7] = (line_1_0 & 0xff0000) >> 16; // And flip the DXT1 block using the above function. FlipDXT1BlockFull(block + 8); @@ -165,7 +165,7 @@ static void FlipDXT5BlockHalf(uint8_t *block) ((line_0_1 & 0xfff000) >> 12); block[2] = line_1_0 & 0xff; block[3] = (line_1_0 & 0xff00) >> 8; - block[4] = (line_1_0 & 0xff0000) >> 8; + block[4] = (line_1_0 & 0xff0000) >> 16; FlipDXT1BlockHalf(block + 8); } diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h index fd68a6d9a27..8fcb079cd4f 100644 --- a/source/blender/makesdna/DNA_armature_types.h +++ b/source/blender/makesdna/DNA_armature_types.h @@ -198,7 +198,9 @@ typedef enum eBone_Flag { BONE_EDITMODE_LOCKED = (1 << 19), /* bone transforms are locked in EditMode */ BONE_TRANSFORM_CHILD = (1 << 20), /* Indicates that a parent is also being transformed */ BONE_UNSELECTABLE = (1 << 21), /* bone cannot be selected */ - BONE_NO_LOCAL_LOCATION = (1 << 22) /* bone location is in armature space */ + BONE_NO_LOCAL_LOCATION = (1 << 22), /* bone location is in armature space */ + BONE_RELATIVE_PARENTING = (1 << 23) /* object child will use relative transform (like deform) */ + } eBone_Flag; #define MAXBONENAME 64 diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 4f47ed76d50..da7ea94aeff 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -147,15 +147,15 @@ typedef struct TFace { #define ME_EDIT_MIRROR_Y (1 << 1) // unused so far #define ME_EDIT_MIRROR_Z (1 << 2) // unused so far -#define ME_EDIT_PAINT_MASK (1 << 3) +#define ME_EDIT_PAINT_FACE_SEL (1 << 3) #define ME_EDIT_MIRROR_TOPO (1 << 4) -#define ME_EDIT_VERT_SEL (1 << 5) +#define ME_EDIT_PAINT_VERT_SEL (1 << 5) /* we cant have both flags enabled at once, * flags defined in DNA_scene_types.h */ #define ME_EDIT_PAINT_SEL_MODE(_me) ( \ - (_me->editflag & ME_EDIT_PAINT_MASK) ? SCE_SELECT_FACE : \ - (_me->editflag & ME_EDIT_VERT_SEL) ? SCE_SELECT_VERTEX : \ + (_me->editflag & ME_EDIT_PAINT_FACE_SEL) ? SCE_SELECT_FACE : \ + (_me->editflag & ME_EDIT_PAINT_VERT_SEL) ? SCE_SELECT_VERTEX : \ 0 \ ) diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 26a41054281..ef9dca58862 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -502,7 +502,7 @@ typedef struct RenderData { short bake_osa, bake_filter, bake_mode, bake_flag; short bake_normal_space, bake_quad_split; float bake_maxdist, bake_biasdist; - int bake_rays_number; + short bake_samples, bake_pad; /* path to render output */ char pic[1024]; /* 1024 = FILE_MAX */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 83d9ed6bf7c..ce4e0c1591d 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -161,6 +161,12 @@ typedef struct ThemeUI { uiPanelColors panel; /* depricated, but we keep it for do_versions (2.66.1) */ + /* fac: 0 - 1 for blend factor, width in pixels */ + float menu_shadow_fac; + short menu_shadow_width; + + short pad; + char iconfile[256]; // FILE_MAXFILE length float icon_alpha; diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 87504dc6eb7..dacb2fee212 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -309,9 +309,10 @@ typedef struct ParameterDynAlloc { typedef enum FunctionFlag { FUNC_NO_SELF = 1, /* for static functions */ - FUNC_USE_MAIN = 2, - FUNC_USE_CONTEXT = 4, - FUNC_USE_REPORTS = 8, + FUNC_USE_SELF_TYPE = 2, /* for class methods, only used when FUNC_NO_SELF is set */ + FUNC_USE_MAIN = 4, + FUNC_USE_CONTEXT = 8, + FUNC_USE_REPORTS = 16, FUNC_USE_SELF_ID = 2048, FUNC_ALLOW_WRITE = 4096, diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 1b5ab2ea600..1b1e4f19cbb 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1989,6 +1989,10 @@ static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, Func if (dsrna->dnaname) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname); else fprintf(f, "(::%s *) this->ptr.data", srna->identifier); } + else if (func->flag & FUNC_USE_SELF_TYPE) { + WRITE_COMMA; + fprintf(f, "this->ptr.type"); + } if (func->flag & FUNC_USE_MAIN) WRITE_PARAM("(::Main *) main"); @@ -2112,8 +2116,12 @@ static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, Functio if (func->flag & FUNC_USE_SELF_ID) WRITE_PARAM("_selfid"); - if ((func->flag & FUNC_NO_SELF) == 0) + if ((func->flag & FUNC_NO_SELF) == 0) { WRITE_PARAM("_self"); + } + else if (func->flag & FUNC_USE_SELF_TYPE) { + WRITE_PARAM("_type"); + } if (func->flag & FUNC_USE_MAIN) WRITE_PARAM("bmain"); @@ -2174,6 +2182,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA if (dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname); else fprintf(f, "\tstruct %s *_self;\n", srna->identifier); } + else if (func->flag & FUNC_USE_SELF_TYPE) { + fprintf(f, "\tstruct StructRNA *_type;\n"); + } dparm = dfunc->cont.properties.first; for (; dparm; dparm = dparm->next) { @@ -2223,6 +2234,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA if (dsrna->dnaname) fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", dsrna->dnaname); else fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", srna->identifier); } + else if (func->flag & FUNC_USE_SELF_TYPE) { + fprintf(f, "\t_type= _ptr->type;\n"); + } if (has_data) { fprintf(f, "\t_data= (char *)_parms->data;\n"); @@ -2300,6 +2314,11 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA fprintf(f, "_self"); first = 0; } + else if (func->flag & FUNC_USE_SELF_TYPE) { + if (!first) fprintf(f, ", "); + fprintf(f, "_type"); + first = 0; + } if (func->flag & FUNC_USE_MAIN) { if (!first) fprintf(f, ", "); @@ -2613,6 +2632,11 @@ static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, F else fprintf(f, "struct %s *_self", srna->identifier); first = 0; } + else if (func->flag & FUNC_USE_SELF_TYPE) { + if (!first) fprintf(f, ", "); + fprintf(f, "struct StructRNA *_type"); + first = 0; + } if (func->flag & FUNC_USE_MAIN) { if (!first) fprintf(f, ", "); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 23e0fa663b9..caa53a23d77 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4753,7 +4753,10 @@ static char *rna_pointer_as_string__idprop(bContext *C, PointerRNA *ptr) static char *rna_pointer_as_string__bldata(PointerRNA *ptr) { - if (RNA_struct_is_ID(ptr->type)) { + if (ptr->type == NULL) { + return BLI_strdup("None"); + } + else if (RNA_struct_is_ID(ptr->type)) { return RNA_path_full_ID_py(ptr->id.data); } else { diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 4c566d71981..6c48ed25b60 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -529,6 +529,11 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_LOCAL_LOCATION); RNA_def_property_update(prop, 0, "rna_Armature_update_data"); + prop = RNA_def_property(srna, "use_relative_parent", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Relative Parenting", "Object children will use relative transform, like deform"); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_RELATIVE_PARENTING); + RNA_def_property_update(prop, 0, "rna_Armature_update_data"); + prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_DRAWWIRE); RNA_def_property_ui_text(prop, "Draw Wire", diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index abc0b65a8f8..eb1fd61d9a7 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -152,8 +152,9 @@ void rna_Mesh_update_draw(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr) { Mesh *me = ptr->data; - if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) { - me->editflag ^= ME_EDIT_PAINT_MASK; + if ((me->editflag & ME_EDIT_PAINT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_FACE_SEL)) { + me->editflag &= ~ME_EDIT_PAINT_FACE_SEL; + BKE_mesh_flush_select_from_polys(me); } rna_Mesh_update_draw(bmain, scene, ptr); } @@ -161,8 +162,9 @@ static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr) { Mesh *me = ptr->data; - if ((me->editflag & ME_EDIT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_MASK)) { - me->editflag ^= ME_EDIT_VERT_SEL; + if ((me->editflag & ME_EDIT_PAINT_VERT_SEL) && (me->editflag & ME_EDIT_PAINT_FACE_SEL)) { + me->editflag &= ~ME_EDIT_PAINT_VERT_SEL; + BKE_mesh_flush_select_from_verts(me); } rna_Mesh_update_draw(bmain, scene, ptr); } @@ -2999,13 +3001,13 @@ static void rna_def_mesh(BlenderRNA *brna) "(for when both sides of mesh have matching, unique topology)"); prop = RNA_def_property(srna, "use_paint_mask", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_PAINT_MASK); + RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_PAINT_FACE_SEL); RNA_def_property_ui_text(prop, "Paint Mask", "Face selection masking for painting"); RNA_def_property_ui_icon(prop, ICON_FACESEL_HLT, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Mesh_update_facemask"); prop = RNA_def_property(srna, "use_paint_mask_vertex", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_VERT_SEL); + RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_PAINT_VERT_SEL); RNA_def_property_ui_text(prop, "Vertex Selection", "Vertex selection masking for painting (weight paint only)"); RNA_def_property_ui_icon(prop, ICON_VERTEXSEL, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Mesh_update_vertmask"); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 93ce3b8dc07..3e9f5f1b88f 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -271,24 +271,23 @@ static char *rna_Node_path(PointerRNA *ptr) return BLI_sprintfN("nodes[\"%s\"]", node->name); } -/* define a get_type function for each node type */ -#define DEF_NODE_GET_NODE_TYPE(name, enum_name) \ -static const char *rna_##name##_get_node_type() \ -{ \ - return enum_name; \ +static const char *rna_Node_get_node_type(StructRNA *type) +{ + bNodeType *nodetype = RNA_struct_blender_type_get(type); + if (nodetype) { + /* XXX hack: with customnodes branch, nodes will use an identifier string instead of integer ID. + * Then this can be returned directly instead of doing this ugly include thingy ... + */ + #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ + if (ID == nodetype->type) { \ + return EnumName; \ + } + + #include "rna_nodetree_types.h" + } + return ""; } -#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ -DEF_NODE_GET_NODE_TYPE(Category##StructName, EnumName) - -#include "rna_nodetree_types.h" - -/* some nodes not included in rna_nodetree_types.h */ -DEF_NODE_GET_NODE_TYPE(NodeGroup, "GROUP") -DEF_NODE_GET_NODE_TYPE(NodeFrame, "FRAME") -DEF_NODE_GET_NODE_TYPE(NodeReroute, "REROUTE") - - static StructRNA *rna_NodeSocket_refine(PointerRNA *ptr) { bNodeSocket *sock = (bNodeSocket *)ptr->data; @@ -1283,12 +1282,20 @@ static void init(void) static StructRNA *def_node(BlenderRNA *brna, int node_id) { StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; NodeInfo *node = nodes + node_id; srna = RNA_def_struct(brna, node->struct_name, node->base_name); RNA_def_struct_ui_text(srna, node->ui_name, node->ui_desc); RNA_def_struct_sdna(srna, "bNode"); + func = RNA_def_function(srna, "get_node_type", "rna_Node_get_node_type"); + RNA_def_function_ui_description(func, "Get the identifier of the node type"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_SELF_TYPE); + parm = RNA_def_string(func, "result", "", 0, "Result", ""); + RNA_def_function_return(func, parm); + return srna; } @@ -4637,7 +4644,7 @@ static void rna_def_node(BlenderRNA *brna) prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "locx"); RNA_def_property_array(prop, 2); - RNA_def_property_range(prop, -10000.0f, 10000.0f); + RNA_def_property_range(prop, -100000.0f, 100000.0f); RNA_def_property_ui_text(prop, "Location", ""); RNA_def_property_update(prop, NC_NODE, "rna_Node_update"); @@ -4924,20 +4931,12 @@ static void rna_def_texture_nodetree(BlenderRNA *brna) rna_def_texture_nodetree_api(brna, prop); } -static void define_specific_node(BlenderRNA *brna, int id, void (*def_func)(StructRNA *), const char *get_node_type_func) +static void define_specific_node(BlenderRNA *brna, int id, void (*def_func)(StructRNA *)) { StructRNA *srna = def_node(brna, id); - FunctionRNA *func; - PropertyRNA *parm; if (def_func) def_func(srna); - - func = RNA_def_function(srna, "get_node_type", get_node_type_func); - RNA_def_function_ui_description(func, "Get the identifier of the node type"); - RNA_def_function_flag(func, FUNC_NO_SELF); - parm = RNA_def_string(func, "result", "", 0, "Result", ""); - RNA_def_function_return(func, parm); } void RNA_def_nodetree(BlenderRNA *brna) @@ -4968,13 +4967,13 @@ void RNA_def_nodetree(BlenderRNA *brna) rna_def_shader_nodetree(brna); rna_def_texture_nodetree(brna); #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ - define_specific_node(brna, ID, DefFunc, "rna_" STRINGIFY_ARG(Category##StructName) "_get_node_type"); + define_specific_node(brna, ID, DefFunc); #include "rna_nodetree_types.h" - define_specific_node(brna, NODE_GROUP, def_group, "rna_NodeGroup_get_node_type"); - define_specific_node(brna, NODE_FRAME, def_frame, "rna_NodeFrame_get_node_type"); - define_specific_node(brna, NODE_REROUTE, 0, "rna_NodeReroute_get_node_type"); + define_specific_node(brna, NODE_GROUP, def_group); + define_specific_node(brna, NODE_FRAME, def_frame); + define_specific_node(brna, NODE_REROUTE, 0); /* special socket types */ rna_def_cmp_output_file_slot_file(brna); diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 14cdbc6cf7d..de535156199 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -104,12 +104,12 @@ DefNode( ShaderNode, SH_NODE_TEX_COORD, def_sh_tex_coord, "TE DefNode( CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" ) DefNode( CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) DefNode( CompositorNode, CMP_NODE_VALUE, 0, "VALUE", Value, "Value", "" ) -DefNode( CompositorNode, CMP_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" ) +DefNode( CompositorNode, CMP_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix", "" ) DefNode( CompositorNode, CMP_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) DefNode( CompositorNode, CMP_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) DefNode( CompositorNode, CMP_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) DefNode( CompositorNode, CMP_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", CurveVec, "Vector Curve", "" ) -DefNode( CompositorNode, CMP_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curve", "" ) +DefNode( CompositorNode, CMP_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curves", "" ) DefNode( CompositorNode, CMP_NODE_ALPHAOVER, def_cmp_alpha_over, "ALPHAOVER", AlphaOver, "Alpha Over", "" ) DefNode( CompositorNode, CMP_NODE_BLUR, def_cmp_blur, "BLUR", Blur, "Blur", "" ) DefNode( CompositorNode, CMP_NODE_FILTER, def_cmp_filter, "FILTER", Filter, "Filter", "" ) @@ -120,11 +120,11 @@ DefNode( CompositorNode, CMP_NODE_VECBLUR, def_cmp_vector_blur, "VECBL DefNode( CompositorNode, CMP_NODE_SEPRGBA, 0, "SEPRGBA", SepRGBA, "Separate RGBA", "" ) DefNode( CompositorNode, CMP_NODE_SEPHSVA, 0, "SEPHSVA", SepHSVA, "Separate HSVA", "" ) DefNode( CompositorNode, CMP_NODE_SETALPHA, 0, "SETALPHA", SetAlpha, "Set Alpha", "" ) -DefNode( CompositorNode, CMP_NODE_HUE_SAT, def_cmp_hue_saturation, "HUE_SAT", HueSat, "Hue/Saturation", "" ) +DefNode( CompositorNode, CMP_NODE_HUE_SAT, def_cmp_hue_saturation, "HUE_SAT", HueSat, "Hue Saturation Value","" ) DefNode( CompositorNode, CMP_NODE_IMAGE, def_cmp_image, "IMAGE", Image, "Image", "" ) DefNode( CompositorNode, CMP_NODE_R_LAYERS, def_cmp_render_layers, "R_LAYERS", RLayers, "Render Layers", "" ) DefNode( CompositorNode, CMP_NODE_COMPOSITE, 0, "COMPOSITE", Composite, "Composite", "" ) -DefNode( CompositorNode, CMP_NODE_OUTPUT_FILE, def_cmp_output_file, "OUTPUT_FILE", OutputFile, "Output File", "" ) +DefNode( CompositorNode, CMP_NODE_OUTPUT_FILE, def_cmp_output_file, "OUTPUT_FILE", OutputFile, "File Output", "" ) DefNode( CompositorNode, CMP_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) DefNode( CompositorNode, CMP_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" ) DefNode( CompositorNode, CMP_NODE_ZCOMBINE, def_cmp_zcombine, "ZCOMBINE", Zcombine, "Z Combine", "" ) @@ -134,8 +134,8 @@ DefNode( CompositorNode, CMP_NODE_INPAINT, def_cmp_inpaint, "INPAI DefNode( CompositorNode, CMP_NODE_DESPECKLE, def_cmp_despeckle, "DESPECKLE", Despeckle, "Despeckle", "" ) DefNode( CompositorNode, CMP_NODE_ROTATE, def_cmp_rotate, "ROTATE", Rotate, "Rotate", "" ) DefNode( CompositorNode, CMP_NODE_SCALE, def_cmp_scale, "SCALE", Scale, "Scale", "" ) -DefNode( CompositorNode, CMP_NODE_SEPYCCA, def_cmp_ycc, "SEPYCCA", SepYCCA, "Separate YCCA", "" ) -DefNode( CompositorNode, CMP_NODE_COMBYCCA, def_cmp_ycc, "COMBYCCA", CombYCCA, "Combine YCCA", "" ) +DefNode( CompositorNode, CMP_NODE_SEPYCCA, def_cmp_ycc, "SEPYCCA", SepYCCA, "Separate YCbCrA", "" ) +DefNode( CompositorNode, CMP_NODE_COMBYCCA, def_cmp_ycc, "COMBYCCA", CombYCCA, "Combine YCbCrA", "" ) DefNode( CompositorNode, CMP_NODE_SEPYUVA, 0, "SEPYUVA", SepYUVA, "Separate YUVA", "" ) DefNode( CompositorNode, CMP_NODE_COMBYUVA, 0, "COMBYUVA", CombYUVA, "Combine YUVA", "" ) DefNode( CompositorNode, CMP_NODE_DIFF_MATTE, def_cmp_diff_matte, "DIFF_MATTE", DiffMatte, "Difference Key", "" ) @@ -146,42 +146,43 @@ DefNode( CompositorNode, CMP_NODE_FLIP, def_cmp_flip, "FLIP" DefNode( CompositorNode, CMP_NODE_SPLITVIEWER, def_cmp_splitviewer, "SPLITVIEWER", SplitViewer, "Split Viewer", "" ) DefNode( CompositorNode, CMP_NODE_MAP_UV, def_cmp_map_uv, "MAP_UV", MapUV, "Map UV", "" ) DefNode( CompositorNode, CMP_NODE_ID_MASK, def_cmp_id_mask, "ID_MASK", IDMask, "ID Mask", "" ) -DefNode( CompositorNode, CMP_NODE_DOUBLEEDGEMASK, def_cmp_double_edge_mask,"DOUBLEEDGEMASK", DoubleEdgeMask, "Double Edge Mask", "" ) +DefNode( CompositorNode, CMP_NODE_DOUBLEEDGEMASK, def_cmp_double_edge_mask,"DOUBLEEDGEMASK", DoubleEdgeMask, "Double Edge Mask", "" ) DefNode( CompositorNode, CMP_NODE_DEFOCUS, def_cmp_defocus, "DEFOCUS", Defocus, "Defocus", "" ) DefNode( CompositorNode, CMP_NODE_DISPLACE, 0, "DISPLACE", Displace, "Displace", "" ) DefNode( CompositorNode, CMP_NODE_COMBHSVA, 0, "COMBHSVA", CombHSVA, "Combine HSVA", "" ) DefNode( CompositorNode, CMP_NODE_MATH, def_math, "MATH", Math, "Math", "" ) -DefNode( CompositorNode, CMP_NODE_LUMA_MATTE, def_cmp_luma_matte, "LUMA_MATTE", LumaMatte, "Luma Matte", "" ) -DefNode( CompositorNode, CMP_NODE_BRIGHTCONTRAST, 0, "BRIGHTCONTRAST", BrightContrast, "Bright Contrast", "" ) +DefNode( CompositorNode, CMP_NODE_LUMA_MATTE, def_cmp_luma_matte, "LUMA_MATTE", LumaMatte, "Luminance Key", "" ) +DefNode( CompositorNode, CMP_NODE_BRIGHTCONTRAST, 0, "BRIGHTCONTRAST", BrightContrast, "Bright/Contrast", "" ) DefNode( CompositorNode, CMP_NODE_GAMMA, 0, "GAMMA", Gamma, "Gamma", "" ) DefNode( CompositorNode, CMP_NODE_INVERT, def_cmp_invert, "INVERT", Invert, "Invert", "" ) DefNode( CompositorNode, CMP_NODE_NORMALIZE, 0, "NORMALIZE", Normalize, "Normalize", "" ) DefNode( CompositorNode, CMP_NODE_CROP, def_cmp_crop, "CROP", Crop, "Crop", "" ) DefNode( CompositorNode, CMP_NODE_DBLUR, def_cmp_dblur, "DBLUR", DBlur, "Directional Blur", "" ) DefNode( CompositorNode, CMP_NODE_BILATERALBLUR, def_cmp_bilateral_blur, "BILATERALBLUR", Bilateralblur, "Bilateral Blur", "" ) -DefNode( CompositorNode, CMP_NODE_PREMULKEY, def_cmp_premul_key, "PREMULKEY", PremulKey, "Premul Key", "" ) +DefNode( CompositorNode, CMP_NODE_PREMULKEY, def_cmp_premul_key, "PREMULKEY", PremulKey, "Alpha Convert", "" ) DefNode( CompositorNode, CMP_NODE_GLARE, def_cmp_glare, "GLARE", Glare, "Glare", "" ) DefNode( CompositorNode, CMP_NODE_TONEMAP, def_cmp_tonemap, "TONEMAP", Tonemap, "Tonemap", "" ) -DefNode( CompositorNode, CMP_NODE_LENSDIST, def_cmp_lensdist, "LENSDIST", Lensdist, "Lensdist", "" ) +DefNode( CompositorNode, CMP_NODE_LENSDIST, def_cmp_lensdist, "LENSDIST", Lensdist, "Lens Distortion", "" ) DefNode( CompositorNode, CMP_NODE_VIEW_LEVELS, def_cmp_levels, "LEVELS", Levels, "Levels", "" ) -DefNode( CompositorNode, CMP_NODE_COLOR_MATTE, def_cmp_color_matte, "COLOR_MATTE", ColorMatte, "Color Matte", "" ) -DefNode( CompositorNode, CMP_NODE_DIST_MATTE, def_cmp_distance_matte, "DISTANCE_MATTE", DistanceMatte, "Distance Matte", "" ) +DefNode( CompositorNode, CMP_NODE_COLOR_MATTE, def_cmp_color_matte, "COLOR_MATTE", ColorMatte, "Color Key", "" ) +DefNode( CompositorNode, CMP_NODE_DIST_MATTE, def_cmp_distance_matte, "DISTANCE_MATTE", DistanceMatte, "Distance Key", "" ) DefNode( CompositorNode, CMP_NODE_COLORBALANCE, def_cmp_colorbalance, "COLORBALANCE", ColorBalance, "Color Balance", "" ) DefNode( CompositorNode, CMP_NODE_HUECORRECT, def_cmp_huecorrect, "HUECORRECT", HueCorrect, "Hue Correct", "" ) -DefNode( CompositorNode, CMP_NODE_MOVIECLIP, def_cmp_movieclip, "MOVIECLIP", MovieClip, "MovieClip", "" ) +DefNode( CompositorNode, CMP_NODE_MOVIECLIP, def_cmp_movieclip, "MOVIECLIP", MovieClip, "Movie Clip", "" ) DefNode( CompositorNode, CMP_NODE_TRANSFORM, dev_cmd_transform, "TRANSFORM", Transform, "Transform", "" ) DefNode( CompositorNode, CMP_NODE_STABILIZE2D, def_cmp_stabilize2d, "STABILIZE2D", Stabilize, "Stabilize 2D", "" ) DefNode( CompositorNode, CMP_NODE_MOVIEDISTORTION,def_cmp_moviedistortion,"MOVIEDISTORTION",MovieDistortion, "Movie Distortion", "" ) -DefNode( CompositorNode, CMP_NODE_MASK_BOX, def_cmp_boxmask, "BOXMASK", BoxMask, "Box mask", "" ) -DefNode( CompositorNode, CMP_NODE_MASK_ELLIPSE, def_cmp_ellipsemask, "ELLIPSEMASK", EllipseMask, "Ellipse mask", "" ) -DefNode( CompositorNode, CMP_NODE_BOKEHIMAGE, def_cmp_bokehimage, "BOKEHIMAGE", BokehImage, "Bokeh image", "" ) +DefNode( CompositorNode, CMP_NODE_MASK_BOX, def_cmp_boxmask, "BOXMASK", BoxMask, "Box Mask", "" ) +DefNode( CompositorNode, CMP_NODE_MASK_ELLIPSE, def_cmp_ellipsemask, "ELLIPSEMASK", EllipseMask, "Ellipse Mask", "" ) +DefNode( CompositorNode, CMP_NODE_BOKEHIMAGE, def_cmp_bokehimage, "BOKEHIMAGE", BokehImage, "Bokeh Image", "" ) DefNode( CompositorNode, CMP_NODE_BOKEHBLUR, def_cmp_bokehblur, "BOKEHBLUR", BokehBlur, "Bokeh Blur", "" ) DefNode( CompositorNode, CMP_NODE_SWITCH, def_cmp_switch, "SWITCH", Switch, "Switch", "" ) -DefNode( CompositorNode, CMP_NODE_COLORCORRECTION,def_cmp_colorcorrection,"COLORCORRECTION",ColorCorrection, "ColorCorrection", "" ) +DefNode( CompositorNode, CMP_NODE_COLORCORRECTION,def_cmp_colorcorrection,"COLORCORRECTION",ColorCorrection, "Color Correction", "" ) DefNode( CompositorNode, CMP_NODE_MASK, def_cmp_mask, "MASK", Mask, "Mask", "" ) -DefNode( CompositorNode, CMP_NODE_KEYINGSCREEN, def_cmp_keyingscreen, "KEYINGSCREEN", KeyingScreen, "KeyingScreen", "" ) +DefNode( CompositorNode, CMP_NODE_KEYINGSCREEN, def_cmp_keyingscreen, "KEYINGSCREEN", KeyingScreen, "Keying Screen", "" ) DefNode( CompositorNode, CMP_NODE_KEYING, def_cmp_keying, "KEYING", Keying, "Keying", "" ) DefNode( CompositorNode, CMP_NODE_TRACKPOS, def_cmp_trackpos, "TRACKPOS", TrackPos, "Track Position", "" ) +DefNode( CompositorNode, CMP_NODE_PIXELATE, 0, "PIXELATE", Pixelate, "Pixelate", "" ) DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" ) DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" ) diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 7355e464fc3..3f03445635f 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -939,6 +939,12 @@ static int rna_Function_no_self_get(PointerRNA *ptr) return !(func->flag & FUNC_NO_SELF); } +static int rna_Function_use_self_type_get(PointerRNA *ptr) +{ + FunctionRNA *func = (FunctionRNA *)ptr->data; + return (func->flag & FUNC_USE_SELF_TYPE); +} + /* Blender RNA */ static void rna_BlenderRNA_structs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) @@ -1230,7 +1236,13 @@ static void rna_def_function(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Function_no_self_get", NULL); RNA_def_property_ui_text(prop, "No Self", - "Function does not pass its self as an argument (becomes a class method in python)"); + "Function does not pass its self as an argument (becomes a static method in python)"); + + prop = RNA_def_property(srna, "use_self_type", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Function_use_self_type_get", NULL); + RNA_def_property_ui_text(prop, "Use Self Type", + "Function passes its self type as an argument (becomes a class method in python if use_self is false)"); } static void rna_def_number_property(StructRNA *srna, PropertyType type) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index ce387952947..29d7391ccb4 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2920,12 +2920,12 @@ static void rna_def_scene_game_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem storage_items[] ={ + static EnumPropertyItem storage_items[] = { {RAS_STORE_AUTO, "AUTO", 0, "Auto Select", "Chooses the best supported mode"}, {RAS_STORE_IMMEDIATE, "IMMEDIATE", 0, "Immediate Mode", "Slowest performance, requires OpenGL (any version)"}, {RAS_STORE_VA, "VERTEX_ARRAY", 0, "Vertex Arrays", "Better performance, requires at least OpenGL 1.1"}, - /* VBOS are currently disabled since they cannot beat vertex array with display lists in performance. 8? - /*{RAS_STORE_VBO, "VERTEX_BUFFER_OBJECT", 0, "Vertex Buffer Objects", "Best performance, requires at least OpenGL 1.4"},*/ + /* VBOS are currently disabled since they cannot beat vertex array with display lists in performance. */ + /* {RAS_STORE_VBO, "VERTEX_BUFFER_OBJECT", 0, "Vertex Buffer Objects", "Best performance, requires at least OpenGL 1.4"}, */ {0, NULL, 0, NULL, NULL}}; srna = RNA_def_struct(brna, "SceneGameData", NULL); @@ -2963,7 +2963,7 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Exit Key", "The key that exits the Game Engine"); RNA_def_property_update(prop, NC_SCENE, NULL); - prop= RNA_def_property(srna, "raster_storage", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "raster_storage", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "raster_storage"); RNA_def_property_enum_items(prop, storage_items); RNA_def_property_ui_text(prop, "Storage", "Sets the storage mode used by the rasterizer"); @@ -4400,11 +4400,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna) "Calculate heights against unsubdivided low resolution mesh"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "bake_rays_number", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "bake_rays_number"); + prop = RNA_def_property(srna, "bake_samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "bake_samples"); RNA_def_property_range(prop, 64, 1024); RNA_def_property_int_default(prop, 256); - RNA_def_property_ui_text(prop, "Number of Rays", "Number of rays used for ambient occlusion baking from multires"); + RNA_def_property_ui_text(prop, "Samples", "Number of samples used for ambient occlusion baking from multires"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* stamp */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 83bf40f85f6..09209ddea4d 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -871,6 +871,9 @@ static void rna_SpaceDopeSheetEditor_action_update(Main *UNUSED(bmain), Scene *s /* show new id-count of action we're replacing */ adt->action = saction->action; id_us_plus(&adt->action->id); + + /* force update of animdata */ + adt->recalc |= ADT_RECALC_ANIM; } /* force depsgraph flush too */ @@ -1250,9 +1253,9 @@ static void rna_def_space_outliner(BlenderRNA *brna) {SO_SAME_TYPE, "SAME_TYPES", 0, "Same Types", "Display datablocks of all objects of same type as selected object"}, {SO_GROUPS, "GROUPS", 0, "Groups", "Display groups and their datablocks"}, - {SO_LIBRARIES, "LIBRARIES", 0, "Libraries", "Display libraries"}, {SO_SEQUENCE, "SEQUENCE", 0, "Sequence", "Display sequence datablocks"}, - {SO_DATABLOCKS, "DATABLOCKS", 0, "Datablocks", "Display raw datablocks"}, + {SO_LIBRARIES, "LIBRARIES", 0, "Blender File", "Display data of current file and linked libraries"}, + {SO_DATABLOCKS, "DATABLOCKS", 0, "Datablocks", "Display all raw datablocks"}, {SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", "Display the user preference datablocks"}, {SO_KEYMAP, "KEYMAPS", 0, "Key Maps", "Display keymap datablocks"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index e3eacb40e83..06154a235aa 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -760,6 +760,16 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "State Colors", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "menu_shadow_fac", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_ui_text(prop, "Menu Shadow Strength", "Blending factor for menu shadows"); + RNA_def_property_range(prop, 0.01f, 1.0f); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "menu_shadow_width", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Menu Shadow Width", "Width of menu shadows in standard pixels, set to zero to disable it"); + RNA_def_property_range(prop, 0.0f, 24.0f); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "icon_file", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "iconfile"); RNA_def_property_ui_text(prop, "Icon File", ""); diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index 72c2204d8c5..71b71c9dd4a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -149,7 +149,7 @@ void register_node_type_cmp_alphaover(bNodeTreeType *ttype) { static bNodeType ntype; - node_type_base(ttype, &ntype, CMP_NODE_ALPHAOVER, "AlphaOver", NODE_CLASS_OP_COLOR, NODE_OPTIONS); + node_type_base(ttype, &ntype, CMP_NODE_ALPHAOVER, "Alpha Over", NODE_CLASS_OP_COLOR, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_alphaover_in, cmp_node_alphaover_out); node_type_size(&ntype, 80, 40, 120); node_type_init(&ntype, node_alphaover_init); diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c index c3f64f0eacb..1ac8c457d45 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c +++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c @@ -85,7 +85,7 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb // so in the case of pincushion (kn < 0), corners will be outside window. // Now also optionally scales image such that black areas are not visible when distort factor is positive // (makes distorted corners match window corners, but really only valid if mk<=0.5) - const float mk = MAX3(kr, kg, kb); + const float mk = max_fff(kr, kg, kb); const float sc = (fit && (mk > 0.f)) ? (1.f/(1.f + 2.f*mk)) : (1.f/(1.f + mk)); const float drg = 4.f*(kg - kr), dgb = 4.f*(kb - kg); diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index 41fb0e822ed..523f1dee406 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -157,7 +157,7 @@ void register_node_type_cmp_splitviewer(bNodeTreeType *ttype) { static bNodeType ntype; - node_type_base(ttype, &ntype, CMP_NODE_SPLITVIEWER, "SplitViewer", NODE_CLASS_OUTPUT, NODE_PREVIEW|NODE_OPTIONS); + node_type_base(ttype, &ntype, CMP_NODE_SPLITVIEWER, "Split Viewer", NODE_CLASS_OUTPUT, NODE_PREVIEW|NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_splitviewer_in, NULL); node_type_size(&ntype, 140, 100, 320); node_type_init(&ntype, node_composit_init_splitviewer); diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index ddb8594de79..15403d7acf4 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -95,9 +95,6 @@ if env['WITH_BF_COMPOSITOR']: if env['WITH_BF_CYCLES']: defs.append('WITH_CYCLES') -if env['WITH_BF_CYCLES']: - defs.append('WITH_CYCLES') - if env['WITH_BF_CYCLES_OSL']: defs.append('WITH_CYCLES_OSL') diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c index f85c3347104..a43c5c18126 100644 --- a/source/blender/python/bmesh/bmesh_py_utils.c +++ b/source/blender/python/bmesh/bmesh_py_utils.c @@ -106,7 +106,7 @@ static PyObject *bpy_bm_utils_vert_collapse_edge(PyObject *UNUSED(self), PyObjec PyDoc_STRVAR(bpy_bm_utils_vert_collapse_faces_doc, ".. method:: vert_collapse_faces(vert, edge, fac, join_faces)\n" "\n" -" Split an edge, return the newly created data.\n" +" Collapses a vertex that has only two manifold edges onto a vertex it shares an edge with.\n" "\n" " :arg vert: The vert that will be collapsed.\n" " :type vert: :class:`bmesh.types.BMVert`\n" @@ -163,7 +163,7 @@ static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObje } else { PyErr_SetString(PyExc_ValueError, - "vert_collapse_edge(vert, edge): no new edge created, internal error"); + "vert_collapse_faces(vert, edge): no new edge created, internal error"); return NULL; } } diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 4f932ac68ff..c4d8f8ee9b8 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -238,6 +238,7 @@ static PyObject *bpy_import_test(const char *modname) return mod; } + /****************************************************************************** * Description: Creates the bpy module and adds it to sys.modules for importing ******************************************************************************/ @@ -300,6 +301,9 @@ void BPy_init_modules(void) PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module); + /* register bpy/rna classmethod callbacks */ + BPY_rna_register_cb(); + /* utility func's that have nowhere else to go */ PyModule_AddObject(mod, meth_bpy_script_paths.ml_name, (PyObject *)PyCFunction_New(&meth_bpy_script_paths, NULL)); PyModule_AddObject(mod, meth_bpy_blend_paths.ml_name, (PyObject *)PyCFunction_New(&meth_bpy_blend_paths, NULL)); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 55983c73895..2de477c46c3 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1510,12 +1510,18 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb /* prefer not to have an exception here * however so many poll functions return None or a valid Object. * its a hassle to convert these into a bool before returning, */ - if (RNA_property_flag(prop) & PROP_OUTPUT) + if (RNA_property_flag(prop) & PROP_OUTPUT) { param = PyObject_IsTrue(value); - else + } + else { param = PyLong_AsLong(value); - if (param < 0) { + if (UNLIKELY(param & ~1)) { /* only accept 0/1 */ + param = -1; /* error out below */ + } + } + + if (param == -1) { PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), @@ -4618,8 +4624,14 @@ static struct PyMethodDef pyrna_struct_methods[] = { {"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, NULL}, /* experimental */ + /* unused for now */ +#if 0 {"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS, NULL}, {"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS, NULL}, + + {"callback_add", (PyCFunction)pyrna_callback_classmethod_add, METH_VARARGS | METH_CLASS, NULL}, + {"callback_remove", (PyCFunction)pyrna_callback_classmethod_remove, METH_VARARGS | METH_CLASS, NULL}, +#endif {NULL, NULL, 0, NULL} }; @@ -6029,7 +6041,7 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) PyObject_SetAttr(newclass, bpy_intern_str_bl_rna, item); Py_DECREF(item); - /* add classmethods */ + /* add staticmethods and classmethods */ { const PointerRNA func_ptr = {{NULL}, srna, NULL}; const ListBase *lb; @@ -6039,10 +6051,10 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) for (link = lb->first; link; link = link->next) { FunctionRNA *func = (FunctionRNA *)link; const int flag = RNA_function_flag(func); - if ((flag & FUNC_NO_SELF) && /* is classmethod */ + if ((flag & FUNC_NO_SELF) && /* is staticmethod or classmethod */ (flag & FUNC_REGISTER) == FALSE) /* is not for registration */ { - /* we may went to set the type of this later */ + /* we may want to set the type of this later */ PyObject *func_py = pyrna_func_to_py(&func_ptr, func); PyObject_SetAttrString(newclass, RNA_function_identifier(func), func_py); Py_DECREF(func_py); @@ -6780,7 +6792,9 @@ static int rna_function_arg_count(FunctionRNA *func) const ListBase *lb = RNA_function_defined_parameters(func); PropertyRNA *parm; Link *link; - int count = (RNA_function_flag(func) & FUNC_NO_SELF) ? 0 : 1; + int flag = RNA_function_flag(func); + int is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE); + int count = is_staticmethod ? 0 : 1; for (link = lb->first; link; link = link->next) { parm = (PropertyRNA *)link; @@ -6802,7 +6816,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v PyObject *py_class = (PyObject *)py_data; PyObject *base_class = RNA_struct_py_type_get(srna); PyObject *item; - int i, flag, arg_count, func_arg_count; + int i, flag, is_staticmethod, arg_count, func_arg_count; const char *py_class_name = ((PyTypeObject *)py_class)->tp_name; /* __name__ */ if (srna_base) { @@ -6825,6 +6839,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v for (link = lb->first; link; link = link->next) { func = (FunctionRNA *)link; flag = RNA_function_flag(func); + is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE); if (!(flag & FUNC_REGISTER)) continue; @@ -6847,7 +6862,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v } else { Py_DECREF(item); /* no need to keep a ref, the class owns it (technically we should keep a ref but...) */ - if (flag & FUNC_NO_SELF) { + if (is_staticmethod) { if (PyMethod_Check(item) == 0) { PyErr_Format(PyExc_TypeError, "expected %.200s, %.200s class \"%.200s\" attribute to be a method, not a %.200s", @@ -6871,9 +6886,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount; /* note, the number of args we check for and the number of args we give to - * @classmethods are different (quirk of python), + * @staticmethods are different (quirk of python), * this is why rna_function_arg_count() doesn't return the value -1*/ - if (flag & FUNC_NO_SELF) + if (is_staticmethod) func_arg_count++; if (arg_count != func_arg_count) { @@ -6958,8 +6973,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param PropertyRNA *parm; ParameterIterator iter; PointerRNA funcptr; - int err = 0, i, flag, ret_len = 0; - const char is_static = (RNA_function_flag(func) & FUNC_NO_SELF) != 0; + int err = 0, i, ret_len = 0; + int flag = RNA_function_flag(func); + const char is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE); + const char is_classmethod = (flag & FUNC_NO_SELF) && (flag & FUNC_USE_SELF_TYPE); /* annoying!, need to check if the screen gets set to NULL which is a * hint that the file was actually re-loaded. */ @@ -6994,7 +7011,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param bpy_context_set(C, &gilstate); - if (!is_static) { + if (!(is_staticmethod || is_classmethod)) { /* some datatypes (operator, render engine) can store PyObjects for re-use */ if (ptr->data) { void **instance = RNA_struct_instance(ptr); @@ -7085,18 +7102,21 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param } } - if (err != -1 && (is_static || py_class_instance)) { /* Initializing the class worked, now run its invoke function */ + if (err != -1 && (is_staticmethod || is_classmethod || py_class_instance)) { /* Initializing the class worked, now run its invoke function */ PyObject *item = PyObject_GetAttrString((PyObject *)py_class, RNA_function_identifier(func)); -// flag = RNA_function_flag(func); if (item) { RNA_pointer_create(NULL, &RNA_Function, func, &funcptr); args = PyTuple_New(rna_function_arg_count(func)); /* first arg is included in 'item' */ - if (is_static) { + if (is_staticmethod) { i = 0; } + else if (is_classmethod) { + PyTuple_SET_ITEM(args, 0, (PyObject *)py_class); + i = 1; + } else { PyTuple_SET_ITEM(args, 0, py_class_instance); i = 1; @@ -7230,7 +7250,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param if (err != 0) { ReportList *reports; /* alert the user, else they wont know unless they see the console. */ - if ((!is_static) && + if ((!is_staticmethod) && (!is_classmethod) && (ptr->data) && (RNA_struct_is_a(ptr->type, &RNA_Operator)) && (is_valid_wm == (CTX_wm_manager(C) != NULL))) @@ -7613,3 +7633,39 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla Py_RETURN_NONE; } + +/* currently this is fairly limited, we would need to make some way to split up + * pyrna_callback_classmethod_... if we want more then one callback per type */ +typedef struct BPyRNA_CallBack { + PyMethodDef py_method; + StructRNA *bpy_srna; +} PyRNA_CallBack; + +static struct BPyRNA_CallBack pyrna_cb_methods[] = { + {{"draw_handler_add", (PyCFunction)pyrna_callback_classmethod_add, METH_VARARGS | METH_STATIC, ""}, &RNA_Space}, + {{"draw_handler_remove", (PyCFunction)pyrna_callback_classmethod_remove, METH_VARARGS | METH_STATIC, ""}, &RNA_Space}, + {{NULL, NULL, 0, NULL}, NULL} +}; + +void BPY_rna_register_cb(void) +{ + int i; + + for (i = 0; pyrna_cb_methods[i].bpy_srna; i++) { + PyObject *cls; + PyObject *func; + PyObject *classmethod; + PyObject *args = PyTuple_New(1); + + cls = pyrna_srna_Subtype(pyrna_cb_methods[i].bpy_srna); + func = PyCFunction_New(&pyrna_cb_methods[i].py_method, NULL); + PyTuple_SET_ITEM(args, 0, func); + classmethod = PyObject_CallObject((PyObject *)&PyClassMethod_Type, args); + + PyObject_SetAttrString(cls, pyrna_cb_methods[i].py_method.ml_name, classmethod); + + Py_DECREF(classmethod); + Py_DECREF(args); /* clears 'func' too */ + Py_DECREF(cls); + } +} diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 880ef4c2185..edd2ada0539 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -171,6 +171,7 @@ PyObject *BPY_rna_module(void); void BPY_update_rna_module(void); /*PyObject *BPY_rna_doc(void);*/ PyObject *BPY_rna_types(void); +void BPY_rna_register_cb(void); PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr); PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop); diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index f7114115a91..adb4ae6a2c6 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -38,17 +38,28 @@ #include "BLI_utildefines.h" +#include "DNA_space_types.h" #include "DNA_screen_types.h" #include "RNA_access.h" +#include "RNA_enum_types.h" #include "BKE_context.h" +#include "BKE_screen.h" + #include "ED_space_api.h" /* use this to stop other capsules from being mis-used */ #define RNA_CAPSULE_ID "RNA_HANDLE" #define RNA_CAPSULE_ID_INVALID "RNA_HANDLE_REMOVED" +static EnumPropertyItem region_draw_mode_items[] = { + {REGION_DRAW_POST_PIXEL, "POST_PIXEL", 0, "Post Pixel", ""}, + {REGION_DRAW_POST_VIEW, "POST_VIEW", 0, "Post View", ""}, + {REGION_DRAW_PRE_VIEW, "PRE_VIEW", 0, "Pre View", ""}, + {0, NULL, 0, NULL, NULL} +}; + static void cb_region_draw(const bContext *C, ARegion *UNUSED(ar), void *customdata) { PyObject *cb_func, *cb_args, *result; @@ -56,8 +67,8 @@ static void cb_region_draw(const bContext *C, ARegion *UNUSED(ar), void *customd bpy_context_set((bContext *)C, &gilstate); - cb_func = PyTuple_GET_ITEM((PyObject *)customdata, 0); - cb_args = PyTuple_GET_ITEM((PyObject *)customdata, 1); + cb_func = PyTuple_GET_ITEM((PyObject *)customdata, 1); + cb_args = PyTuple_GET_ITEM((PyObject *)customdata, 2); result = PyObject_CallObject(cb_func, cb_args); if (result) { @@ -71,6 +82,7 @@ static void cb_region_draw(const bContext *C, ARegion *UNUSED(ar), void *customd bpy_context_clear((bContext *)C, &gilstate); } +#if 0 PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args) { void *handle; @@ -89,12 +101,6 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args) if (RNA_struct_is_a(self->ptr.type, &RNA_Region)) { if (cb_event_str) { - static EnumPropertyItem region_draw_mode_items[] = { - {REGION_DRAW_POST_PIXEL, "POST_PIXEL", 0, "Post Pixel", ""}, - {REGION_DRAW_POST_VIEW, "POST_VIEW", 0, "Post View", ""}, - {REGION_DRAW_PRE_VIEW, "PRE_VIEW", 0, "Pre View", ""}, - {0, NULL, 0, NULL, NULL}}; - if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") < 0) { return NULL; } @@ -136,6 +142,163 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args) ED_region_draw_cb_exit(((ARegion *)self->ptr.data)->type, handle); } + else { + PyErr_SetString(PyExc_TypeError, "callback_remove(): type does not support callbacks"); + return NULL; + } + + /* don't allow reuse */ + PyCapsule_SetName(py_handle, RNA_CAPSULE_ID_INVALID); + + Py_RETURN_NONE; +} +#endif + +/* reverse of rna_Space_refine() */ +static eSpace_Type rna_Space_refine_reverse(StructRNA *srna) +{ + if (srna == &RNA_SpaceView3D) return SPACE_VIEW3D; + if (srna == &RNA_SpaceGraphEditor) return SPACE_IPO; + if (srna == &RNA_SpaceOutliner) return SPACE_OUTLINER; + if (srna == &RNA_SpaceProperties) return SPACE_BUTS; + if (srna == &RNA_SpaceFileBrowser) return SPACE_FILE; + if (srna == &RNA_SpaceImageEditor) return SPACE_IMAGE; + if (srna == &RNA_SpaceInfo) return SPACE_INFO; + if (srna == &RNA_SpaceSequenceEditor) return SPACE_SEQ; + if (srna == &RNA_SpaceTextEditor) return SPACE_TEXT; + if (srna == &RNA_SpaceDopeSheetEditor) return SPACE_ACTION; + if (srna == &RNA_SpaceNLA) return SPACE_NLA; + if (srna == &RNA_SpaceTimeline) return SPACE_TIME; + if (srna == &RNA_SpaceNodeEditor) return SPACE_NODE; + if (srna == &RNA_SpaceLogicEditor) return SPACE_LOGIC; + if (srna == &RNA_SpaceConsole) return SPACE_CONSOLE; + if (srna == &RNA_SpaceUserPreferences) return SPACE_USERPREF; + if (srna == &RNA_SpaceClipEditor) return SPACE_CLIP; + return -1; +} + +PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args) +{ + void *handle; + PyObject *cls; + PyObject *cb_func, *cb_args; + char *cb_regiontype_str; + char *cb_event_str; + int cb_event; + int cb_regiontype; + StructRNA *srna; + + if (PyTuple_GET_SIZE(args) < 2) { + PyErr_SetString(PyExc_ValueError, "handler_add(handle): expected at least 2 args"); + return NULL; + } + + cls = PyTuple_GET_ITEM(args, 0); + if (!(srna = pyrna_struct_as_srna(cls, FALSE, "handler_add"))) { + return NULL; + } + cb_func = PyTuple_GET_ITEM(args, 1); + if (!PyCallable_Check(cb_func)) { + PyErr_SetString(PyExc_TypeError, "first argument isn't callable"); + return NULL; + } + + /* class spesific callbacks */ + if (RNA_struct_is_a(srna, &RNA_Space)) { + if (!PyArg_ParseTuple(args, "OOO!ss:Space.draw_handler_add", + &cls, &cb_func, /* already assigned, no matter */ + &PyTuple_Type, &cb_args, &cb_regiontype_str, &cb_event_str)) + { + return NULL; + } + + if (pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") < 0) { + return NULL; + } + else if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_add()") < 0) { + return NULL; + } + else { + const eSpace_Type spaceid = rna_Space_refine_reverse(srna); + if (spaceid == -1) { + PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna)); + return NULL; + } + else { + SpaceType *st = BKE_spacetype_from_id(spaceid); + ARegionType *art = BKE_regiontype_from_id(st, cb_regiontype); + + handle = ED_region_draw_cb_activate(art, cb_region_draw, (void *)args, cb_event); + Py_INCREF(args); + } + } + } + else { + PyErr_SetString(PyExc_TypeError, "callback_add(): type does not support callbacks"); + return NULL; + } + + return PyCapsule_New((void *)handle, RNA_CAPSULE_ID, NULL); +} + +PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *args) +{ + PyObject *cls; + PyObject *py_handle; + void *handle; + void *customdata; + StructRNA *srna; + char *cb_regiontype_str; + int cb_regiontype; + + if (PyTuple_GET_SIZE(args) < 2) { + PyErr_SetString(PyExc_ValueError, "callback_remove(handle): expected at least 2 args"); + return NULL; + } + + cls = PyTuple_GET_ITEM(args, 0); + if (!(srna = pyrna_struct_as_srna(cls, FALSE, "callback_remove"))) { + return NULL; + } + py_handle = PyTuple_GET_ITEM(args, 1); + handle = PyCapsule_GetPointer(py_handle, RNA_CAPSULE_ID); + if (handle == NULL) { + PyErr_SetString(PyExc_ValueError, "callback_remove(handle): NULL handle given, invalid or already removed"); + return NULL; + } + + if (RNA_struct_is_a(srna, &RNA_Space)) { + if (!PyArg_ParseTuple(args, "OO!s:Space.draw_handler_remove", + &cls, &PyCapsule_Type, &py_handle, /* already assigned, no matter */ + &cb_regiontype_str)) + { + return NULL; + } + + customdata = ED_region_draw_cb_customdata(handle); + Py_DECREF((PyObject *)customdata); + + if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_remove()") < 0) { + return NULL; + } + else { + const eSpace_Type spaceid = rna_Space_refine_reverse(srna); + if (spaceid == -1) { + PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna)); + return NULL; + } + else { + SpaceType *st = BKE_spacetype_from_id(spaceid); + ARegionType *art = BKE_regiontype_from_id(st, cb_regiontype); + + ED_region_draw_cb_exit(art, handle); + } + } + } + else { + PyErr_SetString(PyExc_TypeError, "callback_remove(): type does not support callbacks"); + return NULL; + } /* don't allow reuse */ PyCapsule_SetName(py_handle, RNA_CAPSULE_ID_INVALID); diff --git a/source/blender/python/intern/bpy_rna_callback.h b/source/blender/python/intern/bpy_rna_callback.h index 7824d2b082d..4b801f35654 100644 --- a/source/blender/python/intern/bpy_rna_callback.h +++ b/source/blender/python/intern/bpy_rna_callback.h @@ -28,5 +28,10 @@ struct BPy_StructRNA; struct PyObject; +#if 0 PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args); PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args); +#endif + +PyObject *pyrna_callback_classmethod_add(PyObject *cls, PyObject *args); +PyObject *pyrna_callback_classmethod_remove(PyObject *cls, PyObject *args); diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 1db0538eb07..3d05f51fb96 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1102,7 +1102,7 @@ static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject return NULL; } - dims = MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size); + dims = max_iiii(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size); for (i = 0; i < vec_k1->size; i++) k1[i] = vec_k1->vec[i]; for (i = 0; i < vec_h1->size; i++) h1[i] = vec_h1->vec[i]; diff --git a/source/blender/render/extern/include/RE_multires_bake.h b/source/blender/render/extern/include/RE_multires_bake.h index 5e8ebdd8a18..04cfe55e3a3 100644 --- a/source/blender/render/extern/include/RE_multires_bake.h +++ b/source/blender/render/extern/include/RE_multires_bake.h @@ -50,7 +50,8 @@ typedef struct MultiresBakeRender { int raytrace_structure; int octree_resolution; - + int threads; + short *stop; short *do_update; float *progress; diff --git a/source/blender/render/intern/raytrace/rayobject_octree.cpp b/source/blender/render/intern/raytrace/rayobject_octree.cpp index dad7fe5fd60..148e3417ea9 100644 --- a/source/blender/render/intern/raytrace/rayobject_octree.cpp +++ b/source/blender/render/intern/raytrace/rayobject_octree.cpp @@ -542,13 +542,13 @@ static void octree_fill_rayface(Octree *oc, RayFace *face) oc2 = rts[1][c]; oc3 = rts[2][c]; if (!RE_rayface_isQuad(face)) { - ocmin[c] = MIN3(oc1, oc2, oc3); - ocmax[c] = MAX3(oc1, oc2, oc3); + ocmin[c] = min_iii(oc1, oc2, oc3); + ocmax[c] = max_iii(oc1, oc2, oc3); } else { oc4 = rts[3][c]; - ocmin[c] = MIN4(oc1, oc2, oc3, oc4); - ocmax[c] = MAX4(oc1, oc2, oc3, oc4); + ocmin[c] = min_iiii(oc1, oc2, oc3, oc4); + ocmax[c] = max_iiii(oc1, oc2, oc3, oc4); } if (ocmax[c] > oc->ocres - 1) ocmax[c] = oc->ocres - 1; if (ocmin[c] < 0) ocmin[c] = 0; @@ -993,7 +993,7 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) } xo = ocx1; yo = ocy1; zo = ocz1; - dda_lambda = MIN3(lambda_x, lambda_y, lambda_z); + dda_lambda = min_fff(lambda_x, lambda_y, lambda_z); vec2[0] = ox1; vec2[1] = oy1; @@ -1083,7 +1083,7 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) } - dda_lambda = MIN3(lambda_x, lambda_y, lambda_z); + dda_lambda = min_fff(lambda_x, lambda_y, lambda_z); if (dda_lambda == lambda_o) break; /* to make sure the last node is always checked */ if (lambda_o >= 1.0f) break; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 08da5dff3e0..cfa6bb0b11d 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -2871,7 +2871,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) } else { if (need_orco) { - orco= get_object_orco(re, ob); + orco = get_object_orco(re, ob); } while (dl) { diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index cd06839b004..7c14e0e5465 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -286,7 +286,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul if (texres->talpha) texres->tin= texres->ta; else if (tex->imaflag & TEX_CALCALPHA) { - texres->ta= texres->tin= MAX3(texres->tr, texres->tg, texres->tb); + texres->ta = texres->tin = max_fff(texres->tr, texres->tg, texres->tb); } else texres->ta= texres->tin= 1.0; @@ -1112,10 +1112,10 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex } /* pixel coordinates */ - minx = MIN3(dxt[0], dyt[0], dxt[0] + dyt[0]); - maxx = MAX3(dxt[0], dyt[0], dxt[0] + dyt[0]); - miny = MIN3(dxt[1], dyt[1], dxt[1] + dyt[1]); - maxy = MAX3(dxt[1], dyt[1], dxt[1] + dyt[1]); + minx = min_fff(dxt[0], dyt[0], dxt[0] + dyt[0]); + maxx = max_fff(dxt[0], dyt[0], dxt[0] + dyt[0]); + miny = min_fff(dxt[1], dyt[1], dxt[1] + dyt[1]); + maxy = max_fff(dxt[1], dyt[1], dxt[1] + dyt[1]); /* tex_sharper has been removed */ minx = (maxx - minx)*0.5f; @@ -1416,7 +1416,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex } if (tex->imaflag & TEX_CALCALPHA) - texres->ta = texres->tin = texres->ta * MAX3(texres->tr, texres->tg, texres->tb); + texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb); else texres->tin = texres->ta; if (tex->flag & TEX_NEGALPHA) texres->ta = 1.f - texres->ta; @@ -1535,10 +1535,10 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const /* pixel coordinates */ - minx = MIN3(dxt[0], dyt[0], dxt[0] + dyt[0]); - maxx = MAX3(dxt[0], dyt[0], dxt[0] + dyt[0]); - miny = MIN3(dxt[1], dyt[1], dxt[1] + dyt[1]); - maxy = MAX3(dxt[1], dyt[1], dxt[1] + dyt[1]); + minx = min_fff(dxt[0], dyt[0], dxt[0] + dyt[0]); + maxx = max_fff(dxt[0], dyt[0], dxt[0] + dyt[0]); + miny = min_fff(dxt[1], dyt[1], dxt[1] + dyt[1]); + maxy = max_fff(dxt[1], dyt[1], dxt[1] + dyt[1]); /* tex_sharper has been removed */ minx= (maxx-minx)/2.0f; @@ -1826,7 +1826,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const } if (tex->imaflag & TEX_CALCALPHA) { - texres->ta= texres->tin= texres->ta*MAX3(texres->tr, texres->tg, texres->tb); + texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb); } else texres->tin= texres->ta; diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c index 0eb0c9a51c3..9785edd3288 100644 --- a/source/blender/render/intern/source/multires_bake.c +++ b/source/blender/render/intern/source/multires_bake.c @@ -39,6 +39,7 @@ #include "BLI_math.h" #include "BLI_listbase.h" +#include "BLI_threads.h" #include "BKE_ccg.h" #include "BKE_context.h" @@ -326,104 +327,196 @@ static int multiresbake_test_break(MultiresBakeRender *bkr) return 0; } - return G.is_break; + return *bkr->stop || G.is_break; } -static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, int require_tangent, MPassKnownData passKnownData, - MInitBakeData initBakeData, MApplyBakeData applyBakeData, MFreeBakeData freeBakeData) +/* **** Threading routines **** */ + +typedef struct MultiresBakeQueue { + int cur_face; + int tot_face; + SpinLock spin; +} MultiresBakeQueue; + +typedef struct MultiresBakeThread { + /* this data is actually shared between all the threads */ + MultiresBakeQueue *queue; + MultiresBakeRender *bkr; + Image *image; + void *bake_data; + + /* thread-specific data */ + MBakeRast bake_rast; + MResolvePixelData data; +} MultiresBakeThread; + +static int multires_bake_queue_next_face(MultiresBakeQueue *queue) { - DerivedMesh *dm = bkr->lores_dm; - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); - const int lvl = bkr->lvl; - const int tot_face = dm->getNumTessFaces(dm); - MVert *mvert = dm->getVertArray(dm); - MFace *mface = dm->getTessFaceArray(dm); - MTFace *mtface = dm->getTessFaceDataArray(dm, CD_MTFACE); - float *pvtangent = NULL; + int face = -1; - if (require_tangent) { - if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1) - DM_add_tangent_layer(dm); + /* TODO: it could worth making it so thread will handle neighbor faces + * for better memory cache utilization + */ - pvtangent = DM_get_tessface_data_layer(dm, CD_TANGENT); + BLI_spin_lock(&queue->spin); + if (queue->cur_face < queue->tot_face) { + face = queue->cur_face; + queue->cur_face++; } + BLI_spin_unlock(&queue->spin); - if (tot_face > 0) { /* sanity check */ - int f = 0; - MBakeRast bake_rast; - MResolvePixelData data = {NULL}; - - data.mface = mface; - data.mvert = mvert; - data.mtface = mtface; - data.pvtangent = pvtangent; - data.precomputed_normals = dm->getTessFaceDataArray(dm, CD_NORMAL); /* don't strictly need this */ - data.w = ibuf->x; - data.h = ibuf->y; - data.lores_dm = dm; - data.hires_dm = bkr->hires_dm; - data.lvl = lvl; - data.pass_data = passKnownData; + return face; +} - if (initBakeData) - data.bake_data = initBakeData(bkr, ima); +static void *do_multires_bake_thread(void *data_v) +{ + MultiresBakeThread *handle = (MultiresBakeThread *) data_v; + MResolvePixelData *data = &handle->data; + MBakeRast *bake_rast = &handle->bake_rast; + MultiresBakeRender *bkr = handle->bkr; + int f; - init_bake_rast(&bake_rast, ibuf, &data, flush_pixel); + while ((f = multires_bake_queue_next_face(handle->queue)) >= 0) { + MTFace *mtfate = &data->mtface[f]; + int verts[3][2], nr_tris, t; - for (f = 0; f < tot_face; f++) { - MTFace *mtfate = &mtface[f]; - int verts[3][2], nr_tris, t; + if (multiresbake_test_break(bkr)) + break; - if (multiresbake_test_break(bkr)) - break; + if (mtfate->tpage != handle->image) + continue; - if (mtfate->tpage != ima) - continue; + data->face_index = f; - data.face_index = f; - data.ibuf = ibuf; + /* might support other forms of diagonal splits later on such as + * split by shortest diagonal.*/ + verts[0][0] = 0; + verts[1][0] = 1; + verts[2][0] = 2; - /* might support other forms of diagonal splits later on such as - * split by shortest diagonal.*/ - verts[0][0] = 0; - verts[1][0] = 1; - verts[2][0] = 2; + verts[0][1] = 0; + verts[1][1] = 2; + verts[2][1] = 3; - verts[0][1] = 0; - verts[1][1] = 2; - verts[2][1] = 3; + nr_tris = data->mface[f].v4 != 0 ? 2 : 1; + for (t = 0; t < nr_tris; t++) { + data->i0 = verts[0][t]; + data->i1 = verts[1][t]; + data->i2 = verts[2][t]; - nr_tris = mface[f].v4 != 0 ? 2 : 1; - for (t = 0; t < nr_tris; t++) { - data.i0 = verts[0][t]; - data.i1 = verts[1][t]; - data.i2 = verts[2][t]; + bake_rasterize(bake_rast, mtfate->uv[data->i0], mtfate->uv[data->i1], mtfate->uv[data->i2]); - bake_rasterize(&bake_rast, mtfate->uv[data.i0], mtfate->uv[data.i1], mtfate->uv[data.i2]); + /* tag image buffer for refresh */ + if (data->ibuf->rect_float) + data->ibuf->userflags |= IB_RECT_INVALID; - if (ibuf->rect_float) - ibuf->userflags |= IB_RECT_INVALID; + data->ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + } - ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; - } + /* update progress */ + BLI_spin_lock(&handle->queue->spin); + bkr->baked_faces++; + + if (bkr->do_update) + *bkr->do_update = TRUE; + + if (bkr->progress) + *bkr->progress = ((float)bkr->baked_objects + (float)bkr->baked_faces / handle->queue->tot_face) / bkr->tot_obj; + BLI_spin_unlock(&handle->queue->spin); + } - bkr->baked_faces++; + return NULL; +} + +static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, int require_tangent, MPassKnownData passKnownData, + MInitBakeData initBakeData, MApplyBakeData applyBakeData, MFreeBakeData freeBakeData) +{ + DerivedMesh *dm = bkr->lores_dm; + const int lvl = bkr->lvl; + const int tot_face = dm->getNumTessFaces(dm); + + if (tot_face > 0) { + MultiresBakeThread *handles; + MultiresBakeQueue queue; + + ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); + MVert *mvert = dm->getVertArray(dm); + MFace *mface = dm->getTessFaceArray(dm); + MTFace *mtface = dm->getTessFaceDataArray(dm, CD_MTFACE); + float *precomputed_normals = dm->getTessFaceDataArray(dm, CD_NORMAL); + float *pvtangent = NULL; - if (bkr->do_update) - *bkr->do_update = TRUE; + ListBase threads; + int i, tot_thread = bkr->threads > 0 ? bkr->threads : BLI_system_thread_count(); - if (bkr->progress) - *bkr->progress = ((float)bkr->baked_objects + (float)bkr->baked_faces / tot_face) / bkr->tot_obj; + void *bake_data = NULL; + + if (require_tangent) { + if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1) + DM_add_tangent_layer(dm); + + pvtangent = DM_get_tessface_data_layer(dm, CD_TANGENT); + } + + /* all threads shares the same custom bake data */ + if (initBakeData) + bake_data = initBakeData(bkr, ima); + + if (tot_thread > 1) + BLI_init_threads(&threads, do_multires_bake_thread, tot_thread); + + handles = MEM_callocN(tot_thread * sizeof(MultiresBakeThread), "do_multires_bake handles"); + + /* faces queue */ + queue.cur_face = 0; + queue.tot_face = tot_face; + BLI_spin_init(&queue.spin); + + /* fill in threads handles */ + for (i = 0; i < tot_thread; i++) { + MultiresBakeThread *handle = &handles[i]; + + handle->bkr = bkr; + handle->image = ima; + handle->queue = &queue; + + handle->data.mface = mface; + handle->data.mvert = mvert; + handle->data.mtface = mtface; + handle->data.pvtangent = pvtangent; + handle->data.precomputed_normals = precomputed_normals; /* don't strictly need this */ + handle->data.w = ibuf->x; + handle->data.h = ibuf->y; + handle->data.lores_dm = dm; + handle->data.hires_dm = bkr->hires_dm; + handle->data.lvl = lvl; + handle->data.pass_data = passKnownData; + handle->data.bake_data = bake_data; + handle->data.ibuf = ibuf; + + init_bake_rast(&handle->bake_rast, ibuf, &handle->data, flush_pixel); + + if (tot_thread > 1) + BLI_insert_thread(&threads, handle); } + /* run threads */ + if (tot_thread > 1) + BLI_end_threads(&threads); + else + do_multires_bake_thread(&handles[0]); + + BLI_spin_end(&queue.spin); + + /* finalize baking */ if (applyBakeData) - applyBakeData(data.bake_data); + applyBakeData(bake_data); if (freeBakeData) - freeBakeData(data.bake_data); - } + freeBakeData(bake_data); - BKE_image_release_ibuf(ima, ibuf, NULL); + BKE_image_release_ibuf(ima, ibuf, NULL); + } } /* mode = 0: interpolate normals, @@ -795,6 +888,7 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, /* **************** Ambient Occlusion Baker **************** */ +// must be a power of two #define MAX_NUMBER_OF_AO_RAYS 1024 static unsigned short ao_random_table_1[MAX_NUMBER_OF_AO_RAYS]; @@ -1036,19 +1130,19 @@ static void apply_ao_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, cons /* use N-Rooks to distribute our N ray samples across * a multi-dimensional domain (2D) */ - const unsigned short I = ao_random_table_1[(i + perm_offs) % ao_data->number_of_rays]; - const unsigned short J = ao_random_table_2[i]; + const unsigned short I = ao_data->permutation_table_1[(i + perm_offs) % ao_data->number_of_rays]; + const unsigned short J = ao_data->permutation_table_2[i]; const float JitPh = (get_ao_random2(I + perm_offs) & (MAX_NUMBER_OF_AO_RAYS-1))/((float) MAX_NUMBER_OF_AO_RAYS); const float JitTh = (get_ao_random1(J + perm_offs) & (MAX_NUMBER_OF_AO_RAYS-1))/((float) MAX_NUMBER_OF_AO_RAYS); const float SiSqPhi = (I + JitPh) / ao_data->number_of_rays; - const float Theta = 2 * M_PI * ((J + JitTh) / ao_data->number_of_rays); + const float Theta = (float)(2 * M_PI) * ((J + JitTh) / ao_data->number_of_rays); /* this gives results identical to the so-called cosine * weighted distribution relative to the north pole. */ float SiPhi = sqrt(SiSqPhi); - float CoPhi = SiSqPhi < 1.0f ? sqrt(1.0f - SiSqPhi) : 1.0f - SiSqPhi; + float CoPhi = SiSqPhi < 1.0f ? sqrtf(1.0f - SiSqPhi) : 0; float CoThe = cos(Theta); float SiThe = sin(Theta); diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index a7308821843..747362a7974 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -1520,8 +1520,8 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int return 0; /* require intensities not being too different */ - mino = MIN4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); - maxo = MAX4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); + mino = min_ffff(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); + maxo = max_ffff(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); if (maxo - mino > 0.05f) return 0; @@ -1793,9 +1793,9 @@ void sample_occ(Render *re, ShadeInput *shi) copy_v3_v3(sample->ao, shi->ao); copy_v3_v3(sample->env, shi->env); copy_v3_v3(sample->indirect, shi->indirect); - sample->intensity = MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); - sample->intensity = MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); - sample->intensity = MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); + sample->intensity = max_fff(sample->ao[0], sample->ao[1], sample->ao[2]); + sample->intensity = max_ff(sample->intensity, max_fff(sample->env[0], sample->env[1], sample->env[2])); + sample->intensity = max_ff(sample->intensity, max_fff(sample->indirect[0], sample->indirect[1], sample->indirect[2])); sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); sample->filled = 1; } @@ -1888,9 +1888,9 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) copy_v3_v3(sample->ao, shi->ao); copy_v3_v3(sample->env, shi->env); copy_v3_v3(sample->indirect, shi->indirect); - sample->intensity = MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); - sample->intensity = MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); - sample->intensity = MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); + sample->intensity = max_fff(sample->ao[0], sample->ao[1], sample->ao[2]); + sample->intensity = max_ff(sample->intensity, max_fff(sample->env[0], sample->env[1], sample->env[2])); + sample->intensity = max_ff(sample->intensity, max_fff(sample->indirect[0], sample->indirect[1], sample->indirect[2])); sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); sample->x = shi->xs; sample->y = shi->ys; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index e6daa5f9094..e3bfd535f11 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1339,7 +1339,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa case MTEX_MUL: fact*= facg; - facm= 1.0f-facg; + facm= 1.0f-fact; in[0]= (facm+fact*tex[0])*out[0]; in[1]= (facm+fact*tex[1])*out[1]; in[2]= (facm+fact*tex[2])*out[2]; @@ -1347,7 +1347,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa case MTEX_SCREEN: fact*= facg; - facm= 1.0f-facg; + facm= 1.0f-fact; in[0]= 1.0f - (facm+fact*(1.0f-tex[0])) * (1.0f-out[0]); in[1]= 1.0f - (facm+fact*(1.0f-tex[1])) * (1.0f-out[1]); in[2]= 1.0f - (facm+fact*(1.0f-tex[2])) * (1.0f-out[2]); @@ -1355,7 +1355,7 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa case MTEX_OVERLAY: fact*= facg; - facm= 1.0f-facg; + facm= 1.0f-fact; if (out[0] < 0.5f) in[0] = out[0] * (facm + 2.0f*fact*tex[0]); @@ -1745,8 +1745,8 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, else { /* 3d procedural, estimate from all dx/dy elems */ const float adx[3] = {fabsf(dx[0]), fabsf(dx[1]), fabsf(dx[2])}; const float ady[3] = {fabsf(dy[0]), fabsf(dy[1]), fabsf(dy[2])}; - du = MAX3(adx[0], adx[1], adx[2]); - dv = MAX3(ady[0], ady[1], ady[2]); + du = max_fff(adx[0], adx[1], adx[2]); + dv = max_fff(ady[0], ady[1], ady[2]); } } diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index c9c8501a3a4..003e74bd69a 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -1892,7 +1892,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) /* note: shi->mode! */ if (shi->mode & MA_TRANSP && (shi->mode & (MA_ZTRANSP|MA_RAYTRANSP))) { if (shi->spectra!=0.0f) { - float t = MAX3(shr->spec[0], shr->spec[1], shr->spec[2]); + float t = max_fff(shr->spec[0], shr->spec[1], shr->spec[2]); t *= shi->spectra; if (t>1.0f) t= 1.0f; shi->alpha= (1.0f-t)*shi->alpha+t; diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index 8757be740f3..549148f4e29 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -354,7 +354,7 @@ static void ms_diffuse(Render *re, int do_test_break, float *x0, float *x, float static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Material *ma) { const float diff = ma->vol.ms_diff * 0.001f; /* compensate for scaling for a nicer UI range */ - const int simframes = (int)(ma->vol.ms_spread * (float)MAX3(vp->res[0], vp->res[1], vp->res[2])); + const int simframes = (int)(ma->vol.ms_spread * (float)max_iii(vp->res[0], vp->res[1], vp->res[2])); const int shade_type = ma->vol.shade_type; float fac = ma->vol.ms_intensity; @@ -652,7 +652,7 @@ static int precache_resolution(Render *re, VolumePrecache *vp, ObjectInstanceRen global_bounds_obi(re, obi, bbmin, bbmax); sub_v3_v3v3(dim, bbmax, bbmin); - div = MAX3(dim[0], dim[1], dim[2]); + div = max_fff(dim[0], dim[1], dim[2]); dim[0] /= div; dim[1] /= div; dim[2] /= div; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index b0b020f3d97..75ab0f5bcd7 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -144,9 +144,11 @@ struct wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap); -struct wmEventHandler *WM_event_add_ui_handler(const struct bContext *C, ListBase *handlers, - int (*func)(struct bContext *C, struct wmEvent *event, void *userdata), - void (*remove)(struct bContext *C, void *userdata), void *userdata); +struct wmEventHandler *WM_event_add_ui_handler( + const struct bContext *C, ListBase *handlers, + int (*func)(struct bContext *C, struct wmEvent *event, void *userdata), + void (*remove)(struct bContext *C, void *userdata), void *userdata); + void WM_event_remove_ui_handler(ListBase *handlers, int (*func)(struct bContext *C, struct wmEvent *event, void *userdata), void (*remove)(struct bContext *C, void *userdata), diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 2cb19ccdf09..197d585bff4 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -410,6 +410,9 @@ typedef struct wmGesture { /* customdata for circle is recti, (xmin, ymin) is center, xmax radius */ /* customdata for lasso is short array */ /* customdata for straight line is a recti: (xmin,ymin) is start, (xmax, ymax) is end */ + + /* free pointer to use for operator allocs (if set, its freed on exit)*/ + void *userdata; } wmGesture; /* ************** wmEvent ************************ */ diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 11cf1088280..91be03986c1 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -606,6 +606,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->do_draw) { + if (ar->overlap == 0) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); @@ -635,7 +636,6 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) if (ar->swinid && ar->overlap) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); - ED_area_overdraw_flush(sa, ar); CTX_wm_region_set(C, NULL); wm_draw_region_blend(win, ar); @@ -796,7 +796,7 @@ void wm_draw_update(bContext *C) GPU_free_unused_buffers(); for (win = wm->windows.first; win; win = win->next) { - int state = GHOST_GetWindowState(win->ghostwin);; + int state = GHOST_GetWindowState(win->ghostwin); if (state == GHOST_kWindowStateMinimized) { /* do not update minimized windows, it gives issues on intel drivers (see [#33223]) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index d8dd0ac04c4..e462e21d9f4 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2689,8 +2689,10 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi if (wm->windows.first == wm->windows.last) return NULL; - /* top window bar... */ - if (mx < 0 || my < 0 || mx > win->sizex || my > win->sizey + 30) { + /* in order to use window size and mouse position (pixels), we have to use a WM function */ + + /* check if outside, include top window bar... */ + if (mx < 0 || my < 0 || mx > WM_window_pixels_x(win) || my > WM_window_pixels_y(win) + 30) { wmWindow *owin; wmEventHandler *handler; @@ -2701,18 +2703,21 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi return NULL; /* to desktop space */ - mx += (int)win->posx; - my += (int)win->posy; + mx += (int) (U.pixelsize * win->posx); + my += (int) (U.pixelsize * win->posy); /* check other windows to see if it has mouse inside */ for (owin = wm->windows.first; owin; owin = owin->next) { if (owin != win) { - if (mx - owin->posx >= 0 && my - owin->posy >= 0 && - mx - owin->posx <= owin->sizex && my - owin->posy <= owin->sizey) + int posx = (int) (U.pixelsize * owin->posx); + int posy = (int) (U.pixelsize * owin->posy); + + if (mx - posx >= 0 && owin->posy >= 0 && + mx - posx <= WM_window_pixels_x(owin) && my - posy <= WM_window_pixels_y(owin)) { - evt->x = mx - (int)owin->posx; - evt->y = my - (int)owin->posy; + evt->x = mx - (int)(U.pixelsize * owin->posx); + evt->y = my - (int)(U.pixelsize * owin->posy); return owin; } diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index a80386e9860..1cf44a69c17 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -113,6 +113,9 @@ void WM_gesture_end(bContext *C, wmGesture *gesture) win->tweak = NULL; BLI_remlink(&win->gesture, gesture); MEM_freeN(gesture->customdata); + if (gesture->userdata) { + MEM_freeN(gesture->userdata); + } MEM_freeN(gesture); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index cd3d5c97f99..b5f1d590f37 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -570,7 +570,8 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert * - see if the pointers ID is in the context. */ - ListBase lb = CTX_data_dir_get(C); + /* don't get from the context store since this is normally set only for the UI and not usable elsewhere */ + ListBase lb = CTX_data_dir_get_ex(C, FALSE, TRUE, TRUE); LinkData *link; const char *member_found = NULL; @@ -582,21 +583,21 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert for (link = lb.first; link; link = link->next) { const char *identifier = link->data; - PointerRNA ctx_ptr = CTX_data_pointer_get(C, identifier); + PointerRNA ctx_item_ptr = CTX_data_pointer_get(C, identifier); - if (ctx_ptr.type == NULL) { + if (ctx_item_ptr.type == NULL) { continue; } - if (ptr->id.data == ctx_ptr.id.data) { - if ((ptr->data == ctx_ptr.data) && - (ptr->type == ctx_ptr.type)) + if (ptr->id.data == ctx_item_ptr.id.data) { + if ((ptr->data == ctx_item_ptr.data) && + (ptr->type == ctx_item_ptr.type)) { /* found! */ member_found = identifier; break; } - else if (RNA_struct_is_ID(ctx_ptr.type)) { + else if (RNA_struct_is_ID(ctx_item_ptr.type)) { /* we found a reference to this ID, * so fallback to it if there is no direct reference */ member_id = identifier; @@ -604,15 +605,6 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert } } - /* grr, CTX_data_dir_get skips scene */ - if ((member_id == NULL) && - (ptr->id.data != NULL) && - (GS(((ID *)ptr->id.data)->name) == ID_SCE) && - (CTX_data_scene(C) == ptr->id.data)) - { - member_id = "scene"; - } - if (member_found) { prop_str = RNA_path_property_py(ptr, prop, index); if (prop_str) { @@ -4019,6 +4011,7 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf) /* assign map to operators */ WM_modalkeymap_assign(keymap, "IMAGE_OT_sample_line"); + WM_modalkeymap_assign(keymap, "PAINT_OT_weight_gradient"); } |