diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-04-05 19:42:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-04-05 19:42:31 +0400 |
commit | 89926a0598a794043ed9b702f32d119fed888c04 (patch) | |
tree | 9d6dae64adcd31e738e32141fa9c15219c6cb981 /source | |
parent | 83fff218cca47147183c1177de9db1381cfa48e6 (diff) | |
parent | 12981b004891aa6dbd2334a4c732ba38c1b0c349 (diff) |
svn merge ^/trunk/blender -r55776:55813
Diffstat (limited to 'source')
90 files changed, 1085 insertions, 722 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 6e298a6d4f6..8ae7155c205 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -87,7 +87,7 @@ float *BKE_curve_make_orco(struct Scene *scene, struct Object *ob); float *BKE_curve_surf_make_orco(struct Object *ob); void BKE_curve_bevelList_make(struct Object *ob); -void BKE_curve_bevel_make(struct Scene *scene, struct Object *ob, struct ListBase *disp, int forRender); +void BKE_curve_bevel_make(struct Scene *scene, struct Object *ob, struct ListBase *disp, int forRender, int renderResolution); void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride); diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 10c31189d02..b5d018cd4eb 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -87,9 +87,9 @@ void BKE_displist_count(struct ListBase *lb, int *totvert, int *totface, int *to void BKE_displist_free(struct ListBase *lb); bool BKE_displist_has_faces(struct ListBase *lb); -void BKE_displist_make_surf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forRender, int forOrco); +void BKE_displist_make_surf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forRender, int forOrco, int renderResolution); void BKE_displist_make_curveTypes(struct Scene *scene, struct Object *ob, int forOrco); -void BKE_displist_make_curveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forOrco); +void BKE_displist_make_curveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forOrco, int renderResolution); void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); void BKE_displist_make_mball(struct Scene *scene, struct Object *ob); void BKE_displist_make_mball_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); @@ -100,6 +100,6 @@ void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, int flipn float BKE_displist_calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); /* add Orco layer to the displist object which has got derived mesh and return orco */ -float *BKE_displist_make_orco(struct Scene *scene, struct Object *ob, struct DerivedMesh *derivedFinal, int forRender); +float *BKE_displist_make_orco(struct Scene *scene, struct Object *ob, struct DerivedMesh *derivedFinal, int forRender, int renderResolution); #endif diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 56f2237a61f..10c18fe94ad 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1418,7 +1418,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob) /* ***************** BEVEL ****************** */ -void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRender) +void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRender, int renderResolution) { DispList *dl, *dlnew; Curve *bevcu, *cu; @@ -1442,7 +1442,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende facy = cu->bevobj->size[1]; if (forRender) { - BKE_displist_make_curveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0); + BKE_displist_make_curveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0, renderResolution); dl = bevdisp.first; } else { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 9a012f9c009..b6df16db6aa 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -302,7 +302,7 @@ bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, i /* ****************** make displists ********************* */ -static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, int forRender) +static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, int forRender, int renderResolution) { Nurb *nu; DispList *dl; @@ -315,7 +315,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i nu = nubase->first; while (nu) { if (nu->hide == 0 || editmode == 0) { - if (forRender && cu->resolu_ren != 0) + if (renderResolution && cu->resolu_ren != 0) resolu = cu->resolu_ren; else resolu = nu->resolu; @@ -731,13 +731,13 @@ void BKE_displist_make_mball_forRender(Scene *scene, Object *ob, ListBase *dispb object_deform_mball(ob, dispbase); } -static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int forRender, int editmode) +static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int renderResolution, int editmode) { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; int required_mode; - if (forRender) + if (renderResolution) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; @@ -771,7 +771,8 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo return pretessellatePoint; } -static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, float (**originalVerts_r)[3], +static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, int renderResolution, + float (**originalVerts_r)[3], float (**deformedVerts_r)[3], int *numVerts_r) { ModifierData *md = modifiers_getVirtualModifierList(ob); @@ -788,14 +789,14 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl if (editmode) app_flag |= MOD_APPLY_USECACHE; - if (forRender) { + if (renderResolution) { app_flag |= MOD_APPLY_RENDER; required_mode = eModifierMode_Render; } else required_mode = eModifierMode_Realtime; - pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode); + pretessellatePoint = curve_get_tessellate_point(scene, ob, renderResolution, editmode); if (editmode) required_mode |= eModifierMode_Editmode; @@ -885,7 +886,8 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3]) } static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, DerivedMesh **derivedFinal, - int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) + int forRender, int renderResolution, + float (*originalVerts)[3], float (*deformedVerts)[3]) { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; @@ -898,14 +900,14 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba int useCache = !forRender; ModifierApplyFlag app_flag = 0; - if (forRender) { + if (renderResolution) { app_flag |= MOD_APPLY_RENDER; required_mode = eModifierMode_Render; } else required_mode = eModifierMode_Realtime; - pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode); + pretessellatePoint = curve_get_tessellate_point(scene, ob, renderResolution, editmode); if (editmode) required_mode |= eModifierMode_Editmode; @@ -1109,7 +1111,7 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco); } -static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) +static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender, int renderResolution) { /* this function represents logic of mesh's orcodm calculation * for displist-based objects @@ -1121,14 +1123,14 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina int required_mode; int editmode = (!forRender && (cu->editnurb || cu->editfont)); DerivedMesh *ndm, *orcodm = NULL; - const ModifierApplyFlag app_flag = forRender ? MOD_APPLY_RENDER : 0; + const ModifierApplyFlag app_flag = renderResolution ? MOD_APPLY_RENDER : 0; - if (forRender) + if (renderResolution) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; - pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode); + pretessellatePoint = curve_get_tessellate_point(scene, ob, renderResolution, editmode); if (editmode) required_mode |= eModifierMode_Editmode; @@ -1169,7 +1171,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina } void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, int forOrco) + DerivedMesh **derivedFinal, int forRender, int forOrco, int renderResolution) { ListBase *nubase; Nurb *nu; @@ -1187,13 +1189,13 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase, nubase = &cu->nurb; if (!forOrco) - curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); + curve_calc_modifiers_pre(scene, ob, forRender, renderResolution, &originalVerts, &deformedVerts, &numVerts); for (nu = nubase->first; nu; nu = nu->next) { if (forRender || nu->hide == 0) { int resolu = nu->resolu, resolv = nu->resolv; - if (forRender) { + if (renderResolution) { if (cu->resolu_ren) resolu = cu->resolu_ren; if (cu->resolv_ren) @@ -1263,7 +1265,8 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase, if (!forOrco) { curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, - forRender, originalVerts, deformedVerts); + forRender, renderResolution, + originalVerts, deformedVerts); } } @@ -1350,7 +1353,7 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp } static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, int forOrco) + DerivedMesh **derivedFinal, int forRender, int forOrco, int renderResolution) { Curve *cu = ob->data; @@ -1358,7 +1361,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; if (ob->type == OB_SURF) { - BKE_displist_make_surf(scene, ob, dispbase, derivedFinal, forRender, forOrco); + BKE_displist_make_surf(scene, ob, dispbase, derivedFinal, forRender, forOrco, renderResolution); } else if (ELEM(ob->type, OB_CURVE, OB_FONT)) { ListBase dlbev; @@ -1378,16 +1381,16 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba BKE_vfont_to_curve(G.main, scene, ob, 0); if (!forOrco) - curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); + curve_calc_modifiers_pre(scene, ob, forRender, renderResolution, &originalVerts, &deformedVerts, &numVerts); BKE_curve_bevelList_make(ob); /* If curve has no bevel will return nothing */ - BKE_curve_bevel_make(scene, ob, &dlbev, forRender); + BKE_curve_bevel_make(scene, ob, &dlbev, forRender, renderResolution); /* no bevel or extrude, and no width correction? */ if (!dlbev.first && cu->width == 1.0f) { - curve_to_displist(cu, nubase, dispbase, forRender); + curve_to_displist(cu, nubase, dispbase, forRender, renderResolution); } else { float widfac = cu->width - 1.0f; @@ -1569,7 +1572,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } if (!forOrco) - curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); + curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, renderResolution, originalVerts, deformedVerts); if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) { curve_to_filledpoly(cu, nubase, dispbase); @@ -1595,7 +1598,7 @@ void BKE_displist_make_curveTypes(Scene *scene, Object *ob, int forOrco) /* free displist used for textspace */ BKE_displist_free(&cu->disp); - do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco); + do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco, 0); if (ob->derivedFinal) { DM_set_object_boundbox(ob, ob->derivedFinal); @@ -1612,18 +1615,18 @@ void BKE_displist_make_curveTypes(Scene *scene, Object *ob, int forOrco) } void BKE_displist_make_curveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forOrco) + DerivedMesh **derivedFinal, int forOrco, int renderResolution) { - do_makeDispListCurveTypes(scene, ob, dispbase, derivedFinal, 1, forOrco); + do_makeDispListCurveTypes(scene, ob, dispbase, derivedFinal, 1, forOrco, renderResolution); } void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase) { - do_makeDispListCurveTypes(scene, ob, dispbase, NULL, 1, 1); + do_makeDispListCurveTypes(scene, ob, dispbase, NULL, 1, 1, 1); } /* add Orco layer to the displist object which has got derived mesh and return orco */ -float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) +float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender, int renderResolution) { float *orco; @@ -1631,7 +1634,7 @@ float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *derivedFina derivedFinal = ob->derivedFinal; if (!derivedFinal->getVertDataArray(derivedFinal, CD_ORCO)) { - curve_calc_orcodm(scene, ob, derivedFinal, forRender); + curve_calc_orcodm(scene, ob, derivedFinal, forRender, renderResolution); } orco = derivedFinal->getVertDataArray(derivedFinal, CD_ORCO); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 0863517c7d7..6b8f0348e16 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1585,7 +1585,7 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value float fuel_flow = emission_value * sfs->fuel_amount; /* add heat */ if (heat) { - heat[index] = MAX2(emission_value * sfs->temp, heat[index]); + heat[index] = ADD_IF_LOWER(heat[index], emission_value * sfs->temp); } /* absolute */ if (absolute_flow) { diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 011f9df6f8c..f01b2bcc5a7 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -727,6 +727,9 @@ static void write_node_socket_interface(WriteData *wd, bNodeTree *UNUSED(ntree), if (sock->prop) IDP_WriteProperty(sock->prop, wd); + + if (sock->default_value) + writedata(wd, DATA, MEM_allocN_len(sock->default_value), sock->default_value); } /* this is only direct data, tree itself should have been written */ static void write_nodetree(WriteData *wd, bNodeTree *ntree) diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 44392383925..c0db2c0a19e 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -776,6 +776,27 @@ bool BM_edge_is_contiguous(BMEdge *e) } /** + * Check if the edge is convex or concave + * (depends on face winding) + */ +bool BM_edge_is_convex(BMEdge *e) +{ + if (BM_edge_is_manifold(e)) { + BMLoop *l1 = e->l; + BMLoop *l2 = e->l->radial_next; + if (!equals_v3v3(l1->f->no, l2->f->no)) { + float cross[3]; + float l_dir[3]; + cross_v3_v3v3(cross, l1->f->no, l2->f->no); + /* we assume contiguous normals, otherwise the result isn't meaningful */ + sub_v3_v3v3(l_dir, l1->next->v->co, l1->v->co); + return (dot_v3v3(l_dir, cross) > 0.0f); + } + } + return true; +} + +/** * Tests whether or not an edge is on the boundary * of a shell (has one face associated with it) */ @@ -1153,6 +1174,27 @@ float BM_edge_calc_face_angle(BMEdge *e) } /** + * \brief BMESH EDGE/FACE ANGLE + * + * Calculates the angle between two faces. + * Assumes the face normals are correct. + * + * \return angle in radians + */ +float BM_edge_calc_face_angle_signed(BMEdge *e) +{ + if (BM_edge_is_manifold(e)) { + BMLoop *l1 = e->l; + BMLoop *l2 = e->l->radial_next; + const float angle = angle_normalized_v3v3(l1->f->no, l2->f->no); + return BM_edge_is_convex(e) ? angle : -angle; + } + else { + return DEG2RADF(90.0f); + } +} + +/** * \brief BMESH EDGE/FACE TANGENT * * Calculate the tangent at this loop corner or fallback to the face normal on straight lines. diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index 8326709a2eb..ec52a7af162 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -62,6 +62,7 @@ bool BM_vert_is_manifold(BMVert *v); bool BM_edge_is_manifold(BMEdge *e); bool BM_edge_is_boundary(BMEdge *e); bool BM_edge_is_contiguous(BMEdge *e); +bool BM_edge_is_convex(BMEdge *e); bool BM_loop_is_convex(BMLoop *l); @@ -71,6 +72,7 @@ void BM_loop_calc_face_direction(BMLoop *l, float r_normal[3]); void BM_loop_calc_face_tangent(BMLoop *l, float r_tangent[3]); float BM_edge_calc_face_angle(BMEdge *e); +float BM_edge_calc_face_angle_signed(BMEdge *e); void BM_edge_calc_face_tangent(BMEdge *e, BMLoop *e_loop, float r_tangent[3]); float BM_vert_calc_edge_angle(BMVert *v); diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp index d85b1ec1de1..aeed859b350 100644 --- a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp +++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp @@ -66,7 +66,7 @@ void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorCon } inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph); - inputImageSocket->relinkConnections(operation->getInputSocket(1), 0, graph); + inputImageSocket->relinkConnections(operation->getInputSocket(1), 1, graph); outputSocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); } diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cpp b/source/blender/compositor/nodes/COM_ZCombineNode.cpp index f48fca72c05..35eedf435f6 100644 --- a/source/blender/compositor/nodes/COM_ZCombineNode.cpp +++ b/source/blender/compositor/nodes/COM_ZCombineNode.cpp @@ -27,39 +27,72 @@ #include "COM_ExecutionSystem.h" #include "COM_SetValueOperation.h" #include "COM_MathBaseOperation.h" +#include "COM_AntiAliasOperation.h" +#include "COM_MixBlendOperation.h" #include "DNA_material_types.h" // the ramp types void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContext *context) { - if (this->getOutputSocket(0)->isConnected()) { - ZCombineOperation *operation = NULL; - if (this->getbNode()->custom1) { - operation = new ZCombineAlphaOperation(); + if (context->getRenderData()->scemode & R_FULL_SAMPLE) { + if (this->getOutputSocket(0)->isConnected()) { + ZCombineOperation *operation = NULL; + if (this->getbNode()->custom1) { + operation = new ZCombineAlphaOperation(); + } + else { + operation = new ZCombineOperation(); + } + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, system); + this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), 3, system); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + system->addOperation(operation); + if (this->getOutputSocket(1)->isConnected()) { + MathMinimumOperation *zoperation = new MathMinimumOperation(); + addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(0)); + addLink(system, operation->getInputSocket(3)->getConnection()->getFromSocket(), zoperation->getInputSocket(1)); + this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket()); + system->addOperation(zoperation); + } } else { - operation = new ZCombineOperation(); + if (this->getOutputSocket(1)->isConnected()) { + MathMinimumOperation *zoperation = new MathMinimumOperation(); + this->getInputSocket(1)->relinkConnections(zoperation->getInputSocket(0), 1, system); + this->getInputSocket(3)->relinkConnections(zoperation->getInputSocket(1), 3, system); + this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket()); + system->addOperation(zoperation); + } } + } else { + // not full anti alias, use masking for Z combine. be aware it uses anti aliasing. + // step 1 create mask + MathGreaterThanOperation *maskoperation = new MathGreaterThanOperation(); + this->getInputSocket(1)->relinkConnections(maskoperation->getInputSocket(0), 1, system); + this->getInputSocket(3)->relinkConnections(maskoperation->getInputSocket(1), 3, system); + + // step 2 anti alias mask bit of an expensive operation, but does the trick + AntiAliasOperation *antialiasoperation = new AntiAliasOperation(); + addLink(system, maskoperation->getOutputSocket(), antialiasoperation->getInputSocket(0)); + + // use mask to blend between the input colors. + ZCombineMaskOperation *zcombineoperation = this->getbNode()->custom1?new ZCombineMaskAlphaOperation():new ZCombineMaskOperation(); + addLink(system, antialiasoperation->getOutputSocket(), zcombineoperation->getInputSocket(0)); + this->getInputSocket(0)->relinkConnections(zcombineoperation->getInputSocket(1), 0, system); + this->getInputSocket(2)->relinkConnections(zcombineoperation->getInputSocket(2), 2, system); + this->getOutputSocket(0)->relinkConnections(zcombineoperation->getOutputSocket()); + + system->addOperation(maskoperation); + system->addOperation(antialiasoperation); + system->addOperation(zcombineoperation); - this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system); - this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system); - this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, system); - this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), 3, system); - this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); - system->addOperation(operation); - if (this->getOutputSocket(1)->isConnected()) { - MathMinimumOperation *zoperation = new MathMinimumOperation(); - addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(0)); - addLink(system, operation->getInputSocket(3)->getConnection()->getFromSocket(), zoperation->getInputSocket(1)); - this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket()); - system->addOperation(zoperation); - } - } - else { if (this->getOutputSocket(1)->isConnected()) { MathMinimumOperation *zoperation = new MathMinimumOperation(); - this->getInputSocket(1)->relinkConnections(zoperation->getInputSocket(0), 1, system); - this->getInputSocket(3)->relinkConnections(zoperation->getInputSocket(1), 3, system); + addLink(system, maskoperation->getInputSocket(0)->getConnection()->getFromSocket(), zoperation->getInputSocket(0)); + addLink(system, maskoperation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(1)); this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket()); system->addOperation(zoperation); } diff --git a/source/blender/compositor/operations/COM_MixHueOperation.cpp b/source/blender/compositor/operations/COM_MixHueOperation.cpp index 5688d6b26f0..1fa393bb362 100644 --- a/source/blender/compositor/operations/COM_MixHueOperation.cpp +++ b/source/blender/compositor/operations/COM_MixHueOperation.cpp @@ -56,6 +56,8 @@ void MixHueOperation::executePixel(float output[4], float x, float y, PixelSampl output[0] = valuem * (inputColor1[0]) + value * tmpr; output[1] = valuem * (inputColor1[1]) + value * tmpg; output[2] = valuem * (inputColor1[2]) + value * tmpb; + } else { + copy_v3_v3(output, inputColor1); } output[3] = inputColor1[3]; diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp index 401ad8d4247..69207d7fbaa 100644 --- a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp +++ b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp @@ -52,7 +52,10 @@ void MixSaturationOperation::executePixel(float output[4], float x, float y, Pix float colH, colS, colV; rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV); hsv_to_rgb(rH, (valuem * rS + value * colS), rV, &output[0], &output[1], &output[2]); + } else { + copy_v3_v3(output, inputColor1); } + output[3] = inputColor1[3]; clampIfNeeded(output); diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp index 5e4f90b0269..97a4aefbfac 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp +++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp @@ -92,3 +92,71 @@ void ZCombineOperation::deinitExecution() this->m_image2Reader = NULL; this->m_depth2Reader = NULL; } + +// MASK combine +ZCombineMaskOperation::ZCombineMaskOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_VALUE); //mask + this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_COLOR); + this->addOutputSocket(COM_DT_COLOR); + + this->m_maskReader = NULL; + this->m_image1Reader = NULL; + this->m_image2Reader = NULL; +} + +void ZCombineMaskOperation::initExecution() +{ + this->m_maskReader = this->getInputSocketReader(0); + this->m_image1Reader = this->getInputSocketReader(1); + this->m_image2Reader = this->getInputSocketReader(2); +} + +void ZCombineMaskOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +{ + float mask[4]; + float color1[4]; + float color2[4]; + + this->m_maskReader->read(mask, x, y, sampler); + this->m_image1Reader->read(color1, x, y, sampler); + this->m_image2Reader->read(color2, x, y, sampler); + + float fac = mask[0]; + // multiply mask with alpha, if mask == 0 color1, else color2 make sure + float mfac = 1.0f-fac; + output[0] = color1[0]*mfac + color2[0]*fac; + output[1] = color1[1]*mfac + color2[1]*fac; + output[2] = color1[2]*mfac + color2[2]*fac; + output[3] = max(color1[3], color2[3]); +} + +void ZCombineMaskAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +{ + float mask[4]; + float color1[4]; + float color2[4]; + + this->m_maskReader->read(mask, x, y, sampler); + this->m_image1Reader->read(color1, x, y, sampler); + this->m_image2Reader->read(color2, x, y, sampler); + + float fac = mask[0]; + // multiply mask with alpha, if mask == 0 color1, else color2 make sure + float mfac = 1.0f-fac; + float alpha = color1[3]*mfac + color2[3]*fac; + float facalpha = fac * alpha; + mfac = 1.0f-facalpha; + output[0] = color1[0]*mfac + color2[0]*facalpha; + output[1] = color1[1]*mfac + color2[1]*facalpha; + output[2] = color1[2]*mfac + color2[2]*facalpha; + output[3] = max(color1[3], color2[3]); +} + +void ZCombineMaskOperation::deinitExecution() +{ + this->m_image1Reader = NULL; + this->m_maskReader = NULL; + this->m_image2Reader = NULL; +} diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h index 61ceca340f7..4545775f26f 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.h +++ b/source/blender/compositor/operations/COM_ZCombineOperation.h @@ -54,4 +54,20 @@ class ZCombineAlphaOperation : public ZCombineOperation { void executePixel(float output[4], float x, float y, PixelSampler sampler); }; +class ZCombineMaskOperation : public NodeOperation { +protected: + SocketReader *m_maskReader; + SocketReader *m_image1Reader; + SocketReader *m_image2Reader; +public: + ZCombineMaskOperation(); + + void initExecution(); + void deinitExecution(); + void executePixel(float output[4], float x, float y, PixelSampler sampler); +}; +class ZCombineMaskAlphaOperation : public ZCombineMaskOperation { + void executePixel(float output[4], float x, float y, PixelSampler sampler); +}; + #endif diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index af2dc884508..dfb02fa9c1b 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -35,6 +35,8 @@ struct rctf; struct ImBuf; struct bContext; +struct ColorManagedViewSettings; +struct ColorManagedDisplaySettings; void fdrawbezier(float vec[4][3]); void fdrawline(float x1, float y1, float x2, float y2); @@ -213,6 +215,11 @@ void bgl_get_mats(bglMats *mats); /* **** Color management helper functions for GLSL display/transform ***** */ /* Draw imbuf on a screen, preferably using GLSL display transform */ +void glaDrawImBuf_glsl(struct ImBuf *ibuf, float x, float y, int zoomfilter, + struct ColorManagedViewSettings *view_settings, + struct ColorManagedDisplaySettings *display_settings); + +/* Draw imbuf on a screen, preferably using GLSL display transform */ void glaDrawImBuf_glsl_ctx(const struct bContext *C, struct ImBuf *ibuf, float x, float y, int zoomfilter); /* Transform buffer from role to scene linear space using GLSL OCIO conversion */ diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index a39476dad66..36ce7606a13 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -114,19 +114,19 @@ void EDBM_select_flush(struct BMEditMesh *em); void undo_push_mesh(struct bContext *C, const char *name); -int EDBM_vert_color_check(struct BMEditMesh *em); +bool EDBM_vert_color_check(struct BMEditMesh *em); -void EDBM_mesh_hide(struct BMEditMesh *em, int swap); +void EDBM_mesh_hide(struct BMEditMesh *em, bool swap); void EDBM_mesh_reveal(struct BMEditMesh *em); void EDBM_update_generic(struct BMEditMesh *em, const bool do_tessface, const bool is_destructive); -struct UvElementMap *EDBM_uv_element_map_create(struct BMEditMesh *em, int selected, int doIslands); +struct UvElementMap *EDBM_uv_element_map_create(struct BMEditMesh *em, const bool selected, const bool do_islands); void EDBM_uv_element_map_free(struct UvElementMap *vmap); struct UvElement *ED_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l); -int EDBM_mtexpoly_check(struct BMEditMesh *em); -struct MTexPoly *EDBM_mtexpoly_active_get(struct BMEditMesh *em, struct BMFace **r_act_efa, int sloppy, int selected); +bool EDBM_mtexpoly_check(struct BMEditMesh *em); +struct MTexPoly *EDBM_mtexpoly_active_get(struct BMEditMesh *em, struct BMFace **r_act_efa, const bool sloppy, const bool selected); void EDBM_uv_vert_map_free(struct UvVertMap *vmap); struct UvMapVert *EDBM_uv_vert_map_at_index(struct UvVertMap *vmap, unsigned int v); @@ -138,7 +138,7 @@ void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag); /* editmesh_select.c */ void EDBM_select_mirrored(struct Object *obedit, struct BMEditMesh *em, bool extend); -void EDBM_automerge(struct Scene *scene, struct Object *ob, int update); +void EDBM_automerge(struct Scene *scene, struct Object *ob, bool update); bool EDBM_backbuf_border_init(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); int EDBM_backbuf_check(unsigned int index); @@ -170,7 +170,7 @@ void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const s void EDBM_select_toggle_all(struct BMEditMesh *em); void EDBM_select_swap(struct BMEditMesh *em); /* exported for UV */ -int EDBM_select_interior_faces(struct BMEditMesh *em); +bool EDBM_select_interior_faces(struct BMEditMesh *em); void em_setup_viewcontext(struct bContext *C, struct ViewContext *vc); /* rename? */ extern unsigned int bm_vertoffs, bm_solidoffs, bm_wireoffs; @@ -192,7 +192,7 @@ void paintface_deselect_all_visible(struct Object *ob, int action, bool flush_fl void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], int mode); bool paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]); -void paintface_hide(struct Object *ob, const int unselected); +void paintface_hide(struct Object *ob, const bool unselected); void paintface_reveal(struct Object *ob); void paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags); @@ -223,13 +223,14 @@ struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, const char *name); void ED_vgroup_delete(struct Object *ob, struct bDeformGroup *defgroup); void ED_vgroup_clear(struct Object *ob); void ED_vgroup_select_by_name(struct Object *ob, const char *name); -int ED_vgroup_data_create(struct ID *id); +bool ED_vgroup_data_create(struct ID *id); void ED_vgroup_data_clamp_range(struct ID *id, const int total); -int ED_vgroup_give_array(struct ID *id, struct MDeformVert **dvert_arr, int *dvert_tot); -int ED_vgroup_copy_array(struct Object *ob, struct Object *ob_from); -void ED_vgroup_mirror(struct Object *ob, const short mirror_weights, const short flip_vgroups, const short all_vgroups); +bool ED_vgroup_give_array(struct ID *id, struct MDeformVert **dvert_arr, int *dvert_tot); +bool ED_vgroup_copy_array(struct Object *ob, struct Object *ob_from); +void ED_vgroup_mirror(struct Object *ob, + const bool mirror_weights, const bool flip_vgroups, const bool all_vgroups); -int ED_vgroup_object_is_edit_mode(struct Object *ob); +bool ED_vgroup_object_is_edit_mode(struct Object *ob); void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode); void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum); @@ -253,13 +254,13 @@ void ED_mesh_calc_normals(struct Mesh *me); void ED_mesh_calc_tessface(struct Mesh *mesh); void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface); -int ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool active_set); +int ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool active_set); bool ED_mesh_uv_texture_remove_index(struct Mesh *me, const int n); bool ED_mesh_uv_texture_remove_active(struct Mesh *me); bool ED_mesh_uv_texture_remove_named(struct Mesh *me, const char *name); -int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me); -int ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum); -int ED_mesh_color_add(struct Mesh *me, const char *name, const bool active_set); +void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me); +void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum); +int ED_mesh_color_add(struct Mesh *me, const char *name, const bool active_set); bool ED_mesh_color_remove_index(struct Mesh *me, const int n); bool ED_mesh_color_remove_active(struct Mesh *me); bool ED_mesh_color_remove_named(struct Mesh *me, const char *name); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index ee0946be620..091bc583360 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -243,7 +243,7 @@ void view3d_validate_backbuf(struct ViewContext *vc); struct ImBuf *view3d_read_backbuf(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const int mval[2], int size, unsigned int min, unsigned int max, float *dist, short strict, - void *handle, unsigned int (*indextest)(void *handle, unsigned int index)); + void *handle, bool (*indextest)(void *handle, unsigned int index)); unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y); /* draws and does a 4x4 sample */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 0c484a82778..480c4a83507 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -819,7 +819,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) /* XXX, this code will shorten any allocated string to 'UI_MAX_NAME_STR' * since this is really long its unlikely to be an issue, * but this could be supported */ -void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const short do_strip) +void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_strip) { if (do_strip) { diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index a644feca080..c40d91378b1 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -124,14 +124,14 @@ typedef struct uiHandleButtonData { wmWindow *window; ARegion *region; - int interactive; + bool interactive; /* overall state */ uiHandleButtonState state; int retval; /* booleans (could be made into flags) */ - char cancel, escapecancel; - char applied, appliedinteractive; + bool cancel, escapecancel; + bool applied, applied_interactive; wmTimer *flashtimer; /* edited value */ @@ -146,7 +146,7 @@ typedef struct uiHandleButtonData { wmTimer *tooltiptimer; /* auto open */ - int used_mouse; + bool used_mouse; wmTimer *autoopentimer; /* text selection/editing */ @@ -156,7 +156,8 @@ typedef struct uiHandleButtonData { /* coords are Window/uiBlock relative (depends on the button) */ int draglastx, draglasty; int dragstartx, dragstarty; - int dragchange, draglock, dragsel; + bool dragchange, draglock; + int dragsel; float dragf, dragfstart; CBData *dragcbd; @@ -257,7 +258,7 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) } } -static int ui_but_editable(uiBut *but) +static bool ui_but_editable(uiBut *but) { return ELEM5(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR); } @@ -517,7 +518,7 @@ static void ui_apply_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data) ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data) @@ -526,7 +527,7 @@ static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data) ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data) @@ -537,7 +538,7 @@ static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data ui_check_but(but); ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data) @@ -600,7 +601,7 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data) ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data) @@ -617,7 +618,7 @@ static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleBu ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data) @@ -636,7 +637,7 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data) ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data) @@ -646,7 +647,7 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data) data->value = ui_get_but_val(but); } else { - data->cancel = TRUE; + data->cancel = true; return; } } @@ -657,7 +658,7 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data) ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_TOG3(bContext *C, uiBut *but, uiHandleButtonData *data) @@ -692,7 +693,7 @@ static void ui_apply_but_TOG3(bContext *C, uiBut *but, uiHandleButtonData *data) ui_check_but(but); ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_VEC(bContext *C, uiBut *but, uiHandleButtonData *data) @@ -702,21 +703,21 @@ static void ui_apply_but_VEC(bContext *C, uiBut *but, uiHandleButtonData *data) ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_COLORBAND(bContext *C, uiBut *but, uiHandleButtonData *data) { ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_CURVE(bContext *C, uiBut *but, uiHandleButtonData *data) { ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_IDPOIN(bContext *C, uiBut *but, uiHandleButtonData *data) @@ -725,7 +726,7 @@ static void ui_apply_but_IDPOIN(bContext *C, uiBut *but, uiHandleButtonData *dat ui_check_but(but); ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } #ifdef WITH_INTERNATIONAL @@ -733,7 +734,7 @@ static void ui_apply_but_CHARTAB(bContext *C, uiBut *but, uiHandleButtonData *da { ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } #endif @@ -884,7 +885,7 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void #endif /* USE_DRAG_TOGGLE */ -static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, const wmEvent *event) +static bool ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, const wmEvent *event) { rcti rect; int x = event->x, y = event->y; @@ -908,7 +909,7 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, const wmEvent *even return BLI_rcti_isect_pt(&rect, x, y); } -static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) +static bool ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { /* prevent other WM gestures to start while we try to drag */ WM_gestures_remove(C); @@ -916,7 +917,7 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, if (ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold) { button_activate_state(C, but, BUTTON_STATE_EXIT); - data->cancel = TRUE; + data->cancel = true; #ifdef USE_DRAG_TOGGLE if (ui_is_but_bool(but)) { uiDragToggleHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__); @@ -941,10 +942,10 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, if (but->imb) WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect)); } - return 1; + return true; } - return 0; + return false; } /* ********************** linklines *********************** */ @@ -1159,39 +1160,39 @@ static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data) ui_apply_but_func(C, but); data->retval = but->retval; } - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_IMAGE(bContext *C, uiBut *but, uiHandleButtonData *data) { ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_HISTOGRAM(bContext *C, uiBut *but, uiHandleButtonData *data) { ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_WAVEFORM(bContext *C, uiBut *but, uiHandleButtonData *data) { ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } static void ui_apply_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonData *data) { ui_apply_but_func(C, but); data->retval = but->retval; - data->applied = TRUE; + data->applied = true; } -static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, int interactive) +static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const bool interactive) { char *editstr; double *editval; @@ -1219,9 +1220,9 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut /* we avoid applying interactive edits a second time * at the end with the appliedinteractive flag */ if (interactive) { - data->appliedinteractive = TRUE; + data->applied_interactive = true; } - else if (data->appliedinteractive) { + else if (data->applied_interactive) { return; } } @@ -1465,7 +1466,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); BLI_strncpy(buf, active_data->str, UI_MAX_DRAW_STR); WM_clipboard_text_set(active_data->str, 0); - active_data->cancel = TRUE; + active_data->cancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } else { @@ -1476,7 +1477,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) { /* else uiSearchboxData.active member is not updated [#26856] */ - ui_searchbox_update(C, data->searchbox, but, 1); + ui_searchbox_update(C, data->searchbox, but, true); } button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -1585,14 +1586,14 @@ void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but /* ************* in-button text selection/editing ************* */ -static int ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data) +static bool ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data) { char *str = data->str; - int len = strlen(str); - int change = 0; + const int len = strlen(str); + bool change = false; if (but->selsta != but->selend && len) { memmove(str + but->selsta, str + but->selend, (len - but->selend) + 1); - change = 1; + change = true; } but->pos = but->selend = but->selsta; @@ -1713,11 +1714,12 @@ static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data, /* this is used for both utf8 and ascii, its meant to be used for single keys, * notice the buffer is either copied or not, so its not suitable for pasting in * - campbell */ -static int ui_textedit_type_buf(uiBut *but, uiHandleButtonData *data, - const char *utf8_buf, int utf8_buf_len) +static bool ui_textedit_type_buf(uiBut *but, uiHandleButtonData *data, + const char *utf8_buf, int utf8_buf_len) { char *str; - int len, changed = 0; + int len; + bool changed = false; str = data->str; len = strlen(str); @@ -1735,14 +1737,14 @@ static int ui_textedit_type_buf(uiBut *but, uiHandleButtonData *data, memmove(&str[but->pos + step], &str[but->pos], (len + 1) - but->pos); memcpy(&str[but->pos], utf8_buf, step * sizeof(char)); but->pos += step; - changed = 1; + changed = true; } } return changed; } -static int ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char ascii) +static bool ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char ascii) { char buf[2] = {ascii, '\0'}; @@ -1750,7 +1752,7 @@ static int ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char asc printf("%s: entering invalid ascii char into an ascii key (%d)\n", __func__, (int)(unsigned char)ascii); - return 0; + return false; } /* in some cases we want to allow invalid utf8 chars */ @@ -1834,15 +1836,15 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJump } } -static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int direction, strCursorJumpType jump) +static bool ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int direction, strCursorJumpType jump) { char *str = data->str; const int len = strlen(str); - int changed = 0; + bool changed = false; if (jump == STRCUR_JUMP_ALL) { - if (len) changed = 1; + if (len) changed = true; str[0] = '\0'; but->pos = 0; } @@ -1856,7 +1858,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio BLI_str_cursor_step_utf8(str, len, &pos, direction, jump, true); step = pos - but->pos; memmove(&str[but->pos], &str[but->pos + step], (len + 1) - but->pos); - changed = 1; + changed = true; } } else { /* backspace */ @@ -1872,7 +1874,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio step = but->pos - pos; memmove(&str[but->pos - step], &str[but->pos], (len + 1) - but->pos); but->pos -= step; - changed = 1; + changed = true; } } } @@ -1880,10 +1882,11 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio return changed; } -static int ui_textedit_autocomplete(bContext *C, uiBut *but, uiHandleButtonData *data) +static bool ui_textedit_autocomplete(bContext *C, uiBut *but, uiHandleButtonData *data) { char *str; - int changed = 1; + /* TODO, should return false if it cant autocomp. */ + bool changed = true; str = data->str; @@ -1898,18 +1901,26 @@ static int ui_textedit_autocomplete(bContext *C, uiBut *but, uiHandleButtonData return changed; } -static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste, int copy, int cut) +/* mode for ui_textedit_copypaste() */ +enum { + UI_TEXTEDIT_PASTE = 1, + UI_TEXTEDIT_COPY, + UI_TEXTEDIT_CUT +}; + +static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const int mode) { char buf[UI_MAX_DRAW_STR] = {0}; char *str, *p, *pbuf; - int x, changed = 0; + int x; + bool changed = false; int str_len, buf_len; str = data->str; str_len = strlen(str); /* paste */ - if (paste) { + if (mode == UI_TEXTEDIT_PASTE) { /* TODO, ensure UTF8 ui_is_but_utf8() - campbell */ /* extract the first line from the clipboard */ p = pbuf = WM_clipboard_text_get(0); @@ -1941,7 +1952,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste } } - changed = 1; + changed = true; } if (pbuf) { @@ -1949,7 +1960,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste } } /* cut & copy */ - else if (copy || cut) { + else if (ELEM(mode, UI_TEXTEDIT_COPY, UI_TEXTEDIT_CUT)) { /* copy the contents to the copypaste buffer */ for (x = but->selsta; x <= but->selend; x++) { if (x == but->selend) @@ -1961,9 +1972,11 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste WM_clipboard_text_set(buf, 0); /* for cut only, delete the selection afterwards */ - if (cut) - if ((but->selend - but->selsta) > 0) + if (mode == UI_TEXTEDIT_CUT) { + if ((but->selend - but->selsta) > 0) { changed = ui_textedit_delete_selection(but, data); + } + } } return changed; @@ -2007,7 +2020,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) /* optional searchbox */ if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) { data->searchbox = ui_searchbox_create(C, data->region, but); - ui_searchbox_update(C, data->searchbox, but, 1); /* 1 = reset */ + ui_searchbox_update(C, data->searchbox, but, true); /* true = reset */ } ui_check_but(but); @@ -2028,7 +2041,7 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) } if (data->searchbox) { - if (data->cancel == 0) + if (data->cancel == false) ui_searchbox_apply(but, data->searchbox); ui_searchbox_free(C, data->searchbox); @@ -2101,7 +2114,8 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { - int mx, my, changed = 0, inbox = 0, update = 0, retval = WM_UI_HANDLER_CONTINUE; + int mx, my, retval = WM_UI_HANDLER_CONTINUE; + bool changed = false, inbox = false, update = false; switch (event->type) { case WHEELUPMOUSE: @@ -2114,8 +2128,8 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle break; case RIGHTMOUSE: case ESCKEY: - data->cancel = TRUE; - data->escapecancel = TRUE; + data->cancel = true; + data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); retval = WM_UI_HANDLER_BREAK; break; @@ -2138,10 +2152,10 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle button_activate_state(C, but, BUTTON_STATE_TEXT_SELECTING); retval = WM_UI_HANDLER_BREAK; } - else if (inbox == 0) { + else if (inbox == false) { /* if searchbox, click outside will cancel */ if (data->searchbox) - data->cancel = data->escapecancel = TRUE; + data->cancel = data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); retval = WM_UI_HANDLER_BREAK; } @@ -2161,11 +2175,11 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle case CKEY: if (event->ctrl || event->oskey) { if (event->type == VKEY) - changed = ui_textedit_copypaste(but, data, 1, 0, 0); + changed = ui_textedit_copypaste(but, data, UI_TEXTEDIT_PASTE); else if (event->type == CKEY) - changed = ui_textedit_copypaste(but, data, 0, 1, 0); + changed = ui_textedit_copypaste(but, data, UI_TEXTEDIT_COPY); else if (event->type == XKEY) - changed = ui_textedit_copypaste(but, data, 0, 0, 1); + changed = ui_textedit_copypaste(but, data, UI_TEXTEDIT_CUT); retval = WM_UI_HANDLER_BREAK; } @@ -2223,7 +2237,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle /* there is a key conflict here, we can't tab with autocomplete */ if (but->autocomplete_func || data->searchbox) { changed = ui_textedit_autocomplete(C, but, data); - update = 1; /* do live update for tab key */ + update = true; /* do live update for tab key */ } /* the hotkey here is not well defined, was G.qual so we check all */ else if (event->shift || event->ctrl || event->alt || event->oskey) { @@ -2270,21 +2284,21 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle } /* textbutton with magnifier icon: do live update for search button */ if (but->icon == ICON_VIEWZOOM) - update = 1; + update = true; } if (changed) { /* only update when typing for TAB key */ if (update && data->interactive) { - ui_apply_button(C, block, but, data, 1); + ui_apply_button(C, block, but, data, true); } else { ui_check_but(but); } - but->changed = TRUE; + but->changed = true; if (data->searchbox) - ui_searchbox_update(C, data->searchbox, but, 1); /* 1 = reset */ + ui_searchbox_update(C, data->searchbox, but, true); /* true = reset */ } if (changed || (retval == WM_UI_HANDLER_BREAK)) @@ -2351,8 +2365,8 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data) data->dragf = data->dragfstart; } - data->dragchange = 0; - data->draglock = 1; + data->dragchange = false; + data->draglock = true; } static void ui_numedit_end(uiBut *but, uiHandleButtonData *data) @@ -2364,7 +2378,7 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data) data->dragstartx = 0; data->draglastx = 0; - data->dragchange = 0; + data->dragchange = false; data->dragcbd = NULL; data->dragsel = 0; } @@ -2372,7 +2386,7 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data) static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data) { if (data->interactive) { - ui_apply_button(C, block, but, data, 1); + ui_apply_button(C, block, but, data, true); } else { ui_check_but(but); @@ -2499,7 +2513,7 @@ static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, cons else if (data->state == BUTTON_STATE_WAIT_RELEASE) { if (event->type == LEFTMOUSE && event->val != KM_PRESS) { if (!(but->flag & UI_SELECT)) - data->cancel = TRUE; + data->cancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -2530,7 +2544,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data if (but->flag & UI_BUT_IMMEDIATE) ui_set_but_val(but, 0); else - data->cancel = TRUE; + data->cancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -2552,14 +2566,14 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data if (WM_key_event_string(event->type)[0]) ui_set_but_val(but, event->type); else - data->cancel = TRUE; + data->cancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } else if (event->type == ESCKEY) { - data->cancel = TRUE; - data->escapecancel = TRUE; + data->cancel = true; + data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -2585,7 +2599,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, c if (WM_key_event_string(event->type)[0]) ui_set_but_val(but, event->type); else - data->cancel = TRUE; + data->cancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -2803,10 +2817,11 @@ static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int s return temp; } -static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, int snap, int mx) +static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, int snap, int mx) { float deler, tempf, softmin, softmax, softrange; - int lvalue, temp, changed = 0; + int lvalue, temp; + bool changed = false; const bool is_float = ui_is_but_float(but); if (mx == data->draglastx) @@ -2818,7 +2833,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i if (abs(mx - data->dragstartx) <= 3) return changed; - data->draglock = 0; + data->draglock = false; data->dragstartx = mx; /* ignore mouse movement within drag-lock */ } @@ -2848,9 +2863,9 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i #endif if (tempf != (float)data->value) { - data->dragchange = 1; + data->dragchange = true; data->value = tempf; - changed = 1; + changed = true; } } else { @@ -2875,9 +2890,9 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i #endif if (temp != data->value) { - data->dragchange = 1; + data->dragchange = true; data->value = temp; - changed = 1; + changed = true; } } @@ -2921,9 +2936,9 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i lvalue = (int)data->value; if (temp != lvalue) { - data->dragchange = 1; + data->dragchange = true; data->value = (double)temp; - changed = 1; + changed = true; } } else { @@ -2933,9 +2948,9 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i CLAMP(tempf, softmin, softmax); if (tempf != (float)data->value) { - data->dragchange = 1; + data->dragchange = true; data->value = tempf; - changed = 1; + changed = true; } } } @@ -2998,8 +3013,8 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == ESCKEY || event->type == RIGHTMOUSE) { - data->cancel = TRUE; - data->escapecancel = TRUE; + data->cancel = true; + data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } else if (event->type == LEFTMOUSE && event->val != KM_PRESS) { @@ -3049,7 +3064,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (temp >= softmin && temp <= softmax) data->value = (double)temp; else - data->cancel = TRUE; + data->cancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -3060,7 +3075,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (temp >= softmin && temp <= softmax) data->value = (double)temp; else - data->cancel = TRUE; + data->cancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -3185,7 +3200,7 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, if (temp != lvalue) { data->value = temp; - data->dragchange = 1; + data->dragchange = true; changed = true; } } @@ -3194,7 +3209,7 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, if (tempf != (float)data->value) { data->value = tempf; - data->dragchange = 1; + data->dragchange = true; changed = true; } } @@ -3321,7 +3336,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (temp >= softmin && temp <= softmax) data->value = temp; else - data->cancel = TRUE; + data->cancel = true; } else { if (f < tempf) tempf -= 0.01f; @@ -3330,7 +3345,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (tempf >= softmin && tempf <= softmax) data->value = tempf; else - data->cancel = TRUE; + data->cancel = true; } button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -3379,8 +3394,8 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut } else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == ESCKEY) { - data->cancel = TRUE; - data->escapecancel = TRUE; + data->cancel = true; + data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } else if (event->type == LEFTMOUSE && event->val != KM_PRESS) { @@ -3432,7 +3447,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co data->value = ui_step_name_menu(but, direction); button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, 1); + ui_apply_button(C, but->block, but, data, true); /* button's state need to be changed to EXIT so moving mouse away from this mouse wouldn't lead * to cancel changes made to this button, but changing state to EXIT also makes no button active for @@ -3478,7 +3493,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co ui_set_but_vectorf(but, data->vec); button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, 1); + ui_apply_button(C, but->block, but, data, true); return WM_UI_HANDLER_BREAK; } } @@ -3493,7 +3508,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co /* outside icon quit, not needed if drag activated */ if (0 == ui_but_mouse_inside_icon(but, data->region, event)) { button_activate_state(C, but, BUTTON_STATE_EXIT); - data->cancel = TRUE; + data->cancel = true; return WM_UI_HANDLER_BREAK; } @@ -3507,10 +3522,11 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co return WM_UI_HANDLER_CONTINUE; } -static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, int my) +static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, int my) { float dx, dy, rad, radsq, mrad, *fp; - int mdx, mdy, changed = 1; + int mdx, mdy; + bool changed = true; /* button is presumed square */ /* if mouse moves outside of sphere, it does negative normal */ @@ -3621,13 +3637,13 @@ static void clamp_axis_max_v3(float v[3], const float max) } } -static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, int my, const short shift) +static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, int my, const short shift) { float rgb[3]; float *hsv = ui_block_hsv_get(but->block); float x, y; float mx_fl, my_fl; - int changed = 1; + bool changed = true; int color_profile = but->block->color_profile; ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); @@ -3800,7 +3816,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu ui_ndofedit_but_HSVCUBE(but, data, ndof, event->shift); button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, 1); + ui_apply_button(C, but->block, but, data, true); return WM_UI_HANDLER_BREAK; } @@ -3840,8 +3856,8 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu } else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == ESCKEY || event->type == RIGHTMOUSE) { - data->cancel = TRUE; - data->escapecancel = TRUE; + data->cancel = true; + data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } else if (event->type == MOUSEMOVE) { @@ -3860,10 +3876,10 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu return WM_UI_HANDLER_CONTINUE; } -static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float mx, float my, int shift) +static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float mx, float my, int shift) { rcti rect; - int changed = 1; + bool changed = true; float mx_fl, my_fl; float rgb[3]; float hsv[3]; @@ -3999,7 +4015,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle ui_ndofedit_but_HSVCIRCLE(but, data, ndof, event->shift); button_activate_state(C, but, BUTTON_STATE_EXIT); - ui_apply_button(C, but->block, but, data, 1); + ui_apply_button(C, but->block, but, data, true); return WM_UI_HANDLER_BREAK; } @@ -4037,8 +4053,8 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle } else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == ESCKEY || event->type == RIGHTMOUSE) { - data->cancel = TRUE; - data->escapecancel = TRUE; + data->cancel = true; + data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } /* XXX hardcoded keymap check.... */ @@ -4070,10 +4086,10 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle } -static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx) +static bool ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx) { float dx; - int changed = 0; + bool changed = false; if (data->draglastx == mx) return changed; @@ -4086,7 +4102,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx data->dragcbd = data->coba->data + data->coba->cur; /* because qsort */ data->draglastx = mx; - changed = 1; + changed = true; return changed; } @@ -4152,7 +4168,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle return WM_UI_HANDLER_CONTINUE; } -static int ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data, int snap, +static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data, int snap, int evtx, int evty, const short shift) { CurveMapping *cumap = (CurveMapping *)but->poin; @@ -4160,7 +4176,8 @@ static int ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData * CurveMapPoint *cmp = cuma->curve; float fx, fy, zoomx, zoomy; int mx, my, dragx, dragy; - int a, changed = 0; + int a; + bool changed = false; /* evtx evty and drag coords are absolute mousecoords, prevents errors when editing when layout changes */ mx = evtx; @@ -4215,7 +4232,7 @@ static int ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData * if (moved_point) { data->draglastx = evtx; data->draglasty = evty; - changed = 1; + changed = true; #ifdef USE_CONT_MOUSE_CORRECT /* note: using 'cmp_last' is weak since there may be multiple points selected, @@ -4230,7 +4247,7 @@ static int ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData * } - data->dragchange = 1; /* mark for selection */ + data->dragchange = true; /* mark for selection */ } else { fx = (mx - dragx) / zoomx; @@ -4256,7 +4273,7 @@ static int ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData * data->draglastx = evtx; data->draglasty = evty; - changed = 1; + changed = true; } return changed; @@ -4264,7 +4281,8 @@ static int ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData * static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { - int mx, my, a, changed = 0; + int mx, my, a; + bool changed = false; mx = event->x; my = event->y; @@ -4290,7 +4308,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt curvemap_insert(cuma, fx, fy); curvemapping_changed(cumap, FALSE); - changed = 1; + changed = true; } /* check for selecting of a point */ @@ -4325,7 +4343,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt curvemap_insert(cuma, fx, fy); curvemapping_changed(cumap, FALSE); - changed = 1; + changed = true; /* reset cmp back to the curve points again, rather than drawing segments */ cmp = cuma->curve; @@ -4355,7 +4373,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt } else { /* move the view */ - data->cancel = TRUE; + data->cancel = true; } data->dragsel = sel; @@ -4383,7 +4401,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt CurveMap *cuma = cumap->cm + cumap->cur; CurveMapPoint *cmp = cuma->curve; - if (!data->dragchange) { + if (data->dragchange == false) { /* deselect all, select one */ if (event->shift == FALSE) { for (a = 0; a < cuma->totpoint; a++) @@ -4392,7 +4410,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt } } else { - curvemapping_changed(cumap, TRUE); /* remove doubles */ + curvemapping_changed(cumap, true); /* remove doubles */ } } @@ -4408,17 +4426,17 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt return WM_UI_HANDLER_CONTINUE; } -static int in_scope_resize_zone(uiBut *but, int UNUSED(x), int y) +static bool in_scope_resize_zone(uiBut *but, int UNUSED(x), int y) { /* bottom corner return (x > but->rect.xmax - SCOPE_RESIZE_PAD) && (y < but->rect.ymin + SCOPE_RESIZE_PAD); */ return (y < but->rect.ymin + SCOPE_RESIZE_PAD); } -static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx, int my) +static bool ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx, int my) { Histogram *hist = (Histogram *)but->poin; /* rcti rect; */ - int changed = 1; + bool changed = true; float /* dx, */ dy; /* UNUSED */ /* BLI_rcti_rctf_copy(&rect, &but->rect); */ @@ -4478,8 +4496,8 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle } else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == ESCKEY) { - data->cancel = TRUE; - data->escapecancel = TRUE; + data->cancel = true; + data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } else if (event->type == MOUSEMOVE) { @@ -4497,11 +4515,11 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle return WM_UI_HANDLER_CONTINUE; } -static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, int my) +static bool ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, int my) { Scopes *scopes = (Scopes *)but->poin; /* rcti rect; */ - int changed = 1; + bool changed = true; float /* dx, */ dy /* , yfac =1.0f */; /* UNUSED */ /* BLI_rcti_rctf_copy(&rect, &but->rect); */ @@ -4561,8 +4579,8 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB } else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == ESCKEY) { - data->cancel = TRUE; - data->escapecancel = TRUE; + data->cancel = true; + data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } else if (event->type == MOUSEMOVE) { @@ -4580,11 +4598,11 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB return WM_UI_HANDLER_CONTINUE; } -static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int mx, int my) +static bool ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int mx, int my) { Scopes *scopes = (Scopes *)but->poin; /* rcti rect; */ - int changed = 1; + bool changed = true; /* float dx, dy; */ /* BLI_rcti_rctf_copy(&rect, &but->rect); */ @@ -4628,8 +4646,8 @@ static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHand } else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == ESCKEY) { - data->cancel = TRUE; - data->escapecancel = TRUE; + data->cancel = true; + data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } else if (event->type == MOUSEMOVE) { @@ -4771,7 +4789,7 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, con if (event->type == LEFTMOUSE && event->val != KM_PRESS) { if (!(but->flag & UI_SELECT)) - data->cancel = TRUE; + data->cancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -4780,11 +4798,11 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, con return WM_UI_HANDLER_CONTINUE; } -static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonData *data, - int mx, int my, const short shift) +static bool ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonData *data, + int mx, int my, const short shift) { MovieClipScopes *scopes = (MovieClipScopes *)but->poin; - int changed = 1; + bool changed = true; float dx, dy; dx = mx - data->draglastx; @@ -4845,8 +4863,8 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan } else if (data->state == BUTTON_STATE_NUM_EDITING) { if (event->type == ESCKEY) { - data->cancel = TRUE; - data->escapecancel = TRUE; + data->cancel = true; + data->escapecancel = true; button_activate_state(C, but, BUTTON_STATE_EXIT); } else if (event->type == MOUSEMOVE) { @@ -4874,14 +4892,14 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) IDProperty *prop = (but->opptr) ? but->opptr->data : NULL; /* complex code to change name of button */ - if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, + if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, true, shortcut_str, sizeof(shortcut_str))) { - ui_but_add_shortcut(but, shortcut_str, TRUE); + ui_but_add_shortcut(but, shortcut_str, true); } else { /* simply strip the shortcut */ - ui_but_add_shortcut(but, NULL, TRUE); + ui_but_add_shortcut(but, NULL, true); } } } @@ -4992,7 +5010,7 @@ static void popup_add_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2)) } -static int ui_but_menu(bContext *C, uiBut *but) +static bool ui_but_menu(bContext *C, uiBut *but) { uiPopupMenu *pup; uiLayout *layout; @@ -5002,6 +5020,11 @@ static int ui_but_menu(bContext *C, uiBut *but) /* if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/ /* return 0;*/ + + /* having this menu for some buttons makes no sense */ + if (but->type == BUT_IMAGE) { + return false; + } button_timers_tooltip_remove(C, but); @@ -5279,7 +5302,7 @@ static int ui_but_menu(bContext *C, uiBut *but) uiPupMenuEnd(C, pup); - return 1; + return true; } static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *event) @@ -5372,7 +5395,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * /* verify if we can edit this button */ if (ELEM(event->type, LEFTMOUSE, RETKEY)) { /* this should become disabled button .. */ - if (but->lock == TRUE) { + if (but->lock == true) { if (but->lockstr) { BKE_report(NULL, RPT_WARNING, but->lockstr); button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -5552,7 +5575,7 @@ void uiFreeActiveButtons(const bContext *C, bScreen *screen) -/* returns TRUE if highlighted button allows drop of names */ +/* returns true if highlighted button allows drop of names */ /* called in region context */ int UI_but_active_drop_name(bContext *C) { @@ -5567,7 +5590,7 @@ int UI_but_active_drop_name(bContext *C) return 0; } -static void ui_blocks_set_tooltips(ARegion *ar, int enable) +static void ui_blocks_set_tooltips(ARegion *ar, const bool enable) { uiBlock *block; @@ -5707,7 +5730,7 @@ static uiBut *ui_list_find_mouse_over(ARegion *ar, int x, int y) /* ****************** button state handling **************************/ -static int button_modal_state(uiHandleButtonState state) +static bool button_modal_state(uiHandleButtonState state) { return ELEM6(state, BUTTON_STATE_WAIT_RELEASE, BUTTON_STATE_WAIT_KEY_EVENT, BUTTON_STATE_NUM_EDITING, BUTTON_STATE_TEXT_EDITING, @@ -5774,10 +5797,10 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s if (data->used_mouse && !data->autoopentimer) { int time; - if (but->block->auto_open == TRUE) { /* test for toolbox */ + if (but->block->auto_open == true) { /* test for toolbox */ time = 1; } - else if ((but->block->flag & UI_BLOCK_LOOP && but->type != BLOCK) || but->block->auto_open == TRUE) { + else if ((but->block->flag & UI_BLOCK_LOOP && but->type != BLOCK) || but->block->auto_open == true) { time = 5 * U.menuthreshold2; } else if (U.uiflag & USER_MENUOPENAUTO) { @@ -5809,7 +5832,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s /* number editing */ if (state == BUTTON_STATE_NUM_EDITING) { if (ui_is_a_warp_but(but)) - WM_cursor_grab_enable(CTX_wm_window(C), TRUE, TRUE, NULL); + WM_cursor_grab_enable(CTX_wm_window(C), true, true, NULL); ui_numedit_begin(but, data); } else if (data->state == BUTTON_STATE_NUM_EDITING) { @@ -5857,8 +5880,8 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s } else { if (button_modal_state(data->state)) { - /* TRUE = postpone free */ - WM_event_remove_ui_handler(&data->window->modalhandlers, ui_handler_region_menu, NULL, data, TRUE); + /* true = postpone free */ + WM_event_remove_ui_handler(&data->window->modalhandlers, ui_handler_region_menu, NULL, data, true); } } } @@ -5902,7 +5925,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA /* XXX curve is temp */ } else { - data->interactive = TRUE; + data->interactive = true; } data->state = BUTTON_STATE_INIT; @@ -5914,12 +5937,12 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA /* we disable auto_open in the block after a threshold, because we still * want to allow auto opening adjacent menus even if no button is activated * in between going over to the other button, but only for a short while */ - if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open == TRUE) + if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open == true) if (but->block->auto_open_last + BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer()) but->block->auto_open = FALSE; if (type == BUTTON_ACTIVATE_OVER) { - data->used_mouse = TRUE; + data->used_mouse = true; } button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); @@ -5965,7 +5988,7 @@ static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *da /* apply the button action or value */ if (!onfree) - ui_apply_button(C, block, but, data, 0); + ui_apply_button(C, block, but, data, false); /* if this button is in a menu, this will set the button return * value to the button value and the menu return value to ok, the @@ -5998,7 +6021,7 @@ static void button_activate_exit(bContext *C, uiBut *but, uiHandleButtonData *da block->tooltipdisabled = 1; } - ui_blocks_set_tooltips(data->region, 0); + ui_blocks_set_tooltips(data->region, false); /* clean up */ if (data->str) @@ -6042,7 +6065,7 @@ void ui_button_active_free(const bContext *C, uiBut *but) } /* returns the active button with an optional checking function */ -static uiBut *ui_context_button_active(const bContext *C, int (*but_check_cb)(uiBut *)) +static uiBut *ui_context_button_active(const bContext *C, bool (*but_check_cb)(uiBut *)) { uiBut *but_found = NULL; @@ -6084,7 +6107,7 @@ static uiBut *ui_context_button_active(const bContext *C, int (*but_check_cb)(ui return but_found; } -static int ui_context_rna_button_active_test(uiBut *but) +static bool ui_context_rna_button_active_test(uiBut *but) { return (but->rnapoin.data != NULL); } @@ -6328,7 +6351,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) } else if (event->x != event->prevx || event->y != event->prevy) { /* re-enable tooltip on mouse move */ - ui_blocks_set_tooltips(ar, 1); + ui_blocks_set_tooltips(ar, true); button_tooltip_timer_reset(C, but); } @@ -6586,7 +6609,7 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u if (menu->menuretval & UI_RETURN_UPDATE) { if (data->interactive) { - ui_apply_button(C, but->block, but, data, TRUE); + ui_apply_button(C, but->block, but, data, true); } else { ui_check_but(but); @@ -6609,7 +6632,7 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u else { if (ISKEYBOARD(event->type)) { /* keyboard menu hierarchy navigation, going back to previous level */ - but->active->used_mouse = FALSE; + but->active->used_mouse = false; button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); } else { @@ -6631,10 +6654,10 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u * - only for 1 second */ -static void ui_mouse_motion_towards_init(uiPopupBlockHandle *menu, int mx, int my, int force) +static void ui_mouse_motion_towards_init(uiPopupBlockHandle *menu, int mx, int my, const bool force) { if (!menu->dotowards || force) { - menu->dotowards = TRUE; + menu->dotowards = true; menu->towardsx = mx; menu->towardsy = my; @@ -6645,10 +6668,10 @@ static void ui_mouse_motion_towards_init(uiPopupBlockHandle *menu, int mx, int m } } -static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *menu, int mx, int my) +static bool ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *menu, int mx, int my) { float p1[2], p2[2], p3[2], p4[2], oldp[2], newp[2]; - int closer; + bool closer; if (!menu->dotowards) { return 0; @@ -6684,11 +6707,11 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men isect_point_tri_v2(newp, oldp, p4, p1)); if (!closer) - menu->dotowards = FALSE; + menu->dotowards = false; /* 1 second timer */ if (PIL_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH) - menu->dotowards = FALSE; + menu->dotowards = false; return menu->dotowards; } @@ -6797,7 +6820,7 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH /* if a button is activated modal, always reset the start mouse * position of the towards mechanism to avoid loosing focus, * and don't handle events */ - ui_mouse_motion_towards_init(menu, mx, my, 1); + ui_mouse_motion_towards_init(menu, mx, my, true); } else if (event->type == TIMER) { if (event->customdata == menu->scrolltimer) @@ -6806,7 +6829,7 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH else { /* for ui_mouse_motion_towards_block */ if (event->type == MOUSEMOVE) { - ui_mouse_motion_towards_init(menu, mx, my, 0); + ui_mouse_motion_towards_init(menu, mx, my, false); /* add menu scroll timer, if needed */ if (ui_menu_scroll_test(block, my)) @@ -7223,7 +7246,7 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo mx = event->x; my = event->y; ui_window_to_block(ar, block, &mx, &my); - ui_mouse_motion_towards_init(menu, mx, my, 1); + ui_mouse_motion_towards_init(menu, mx, my, true); if (menu->menuretval) return WM_UI_HANDLER_CONTINUE; @@ -7299,7 +7322,7 @@ static int ui_handler_region(bContext *C, const wmEvent *event, void *UNUSED(use /* re-enable tooltips */ if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) - ui_blocks_set_tooltips(ar, 1); + ui_blocks_set_tooltips(ar, true); /* delayed apply callbacks */ ui_apply_but_funcs_after(C); @@ -7372,7 +7395,7 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE /* re-enable tooltips */ if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) - ui_blocks_set_tooltips(ar, 1); + ui_blocks_set_tooltips(ar, true); /* delayed apply callbacks */ ui_apply_but_funcs_after(C); @@ -7420,7 +7443,7 @@ static int ui_handler_popup(bContext *C, const wmEvent *event, void *userdata) else { /* re-enable tooltips */ if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy)) - ui_blocks_set_tooltips(menu->region, 1); + ui_blocks_set_tooltips(menu->region, true); } /* delayed apply callbacks */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 41ceeb141c9..91dc6dcab7e 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -424,9 +424,9 @@ struct uiPopupBlockHandle { struct ARegion *region; int towardsx, towardsy; double towardstime; - int dotowards; + bool dotowards; - int popup; + bool popup; void (*popup_func)(struct bContext *C, void *arg, int event); void (*cancel_func)(struct bContext *C, void *arg); void *popup_arg; @@ -465,7 +465,7 @@ void ui_popup_block_scrolltest(struct uiBlock *block); /* searchbox for string button */ ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but); bool ui_searchbox_inside(struct ARegion *ar, int x, int y); -void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset); +void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, const bool reset); void ui_searchbox_autocomplete(struct bContext *C, struct ARegion *ar, uiBut *but, char *str); void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, const struct wmEvent *event); void ui_searchbox_apply(uiBut *but, struct ARegion *ar); @@ -556,7 +556,7 @@ void ui_resources_free(void); void ui_layout_add_but(uiLayout *layout, uiBut *but); int ui_but_can_align(uiBut *but); void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop); -void ui_but_add_shortcut(uiBut *but, const char *key_str, const short do_strip); +void ui_but_add_shortcut(uiBut *but, const char *key_str, const bool do_strip); /* interface_anim.c */ void ui_but_anim_flag(uiBut *but, float cfra); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 2ccba2e35f0..976033cd483 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -815,7 +815,7 @@ static void ui_searchbox_select(bContext *C, ARegion *ar, uiBut *but, int step) if (data->items.more) { data->items.offset++; data->active = data->items.totitem; - ui_searchbox_update(C, ar, but, 0); + ui_searchbox_update(C, ar, but, false); } else data->active = data->items.totitem; @@ -824,7 +824,7 @@ static void ui_searchbox_select(bContext *C, ARegion *ar, uiBut *but, int step) if (data->items.offset) { data->items.offset--; data->active = 1; - ui_searchbox_update(C, ar, but, 0); + ui_searchbox_update(C, ar, but, false); } else if (data->active < 0) data->active = 0; @@ -931,14 +931,14 @@ void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, const wmEvent *eve } /* ar is the search box itself */ -void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset) +void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset) { uiSearchboxData *data = ar->regiondata; /* reset vars */ data->items.totitem = 0; data->items.more = 0; - if (reset == 0) { + if (reset == false) { data->items.offset_i = data->items.offset; } else { @@ -2481,7 +2481,7 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut handle = ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup); if (!but) { - handle->popup = 1; + handle->popup = true; UI_add_popup_handlers(C, &window->modalhandlers, handle); WM_event_add_mousemove(C); @@ -2536,12 +2536,12 @@ void uiPupMenuEnd(bContext *C, uiPopupMenu *pup) wmWindow *window = CTX_wm_window(C); uiPopupBlockHandle *menu; - pup->popup = 1; + pup->popup = true; pup->mx = window->eventstate->x; pup->my = window->eventstate->y; menu = ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_POPUP, pup); - menu->popup = 1; + menu->popup = true; UI_add_popup_handlers(C, &window->modalhandlers, menu); WM_event_add_mousemove(C); @@ -2737,7 +2737,7 @@ void uiPupBlockO(bContext *C, uiBlockCreateFunc func, void *arg, const char *opn uiPopupBlockHandle *handle; handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg); - handle->popup = 1; + handle->popup = true; handle->optype = (opname) ? WM_operatortype_find(opname, 0) : NULL; handle->opcontext = opcontext; @@ -2756,7 +2756,7 @@ void uiPupBlockEx(bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_f uiPopupBlockHandle *handle; handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg); - handle->popup = 1; + handle->popup = true; handle->retvalue = 1; handle->popup_arg = arg; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index dd575dbf522..634f686c9e6 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2122,7 +2122,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe /* curve itself */ size = uiLayoutGetWidth(layout); row = uiLayoutRow(layout, FALSE); - uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, MIN2(size, 10.0f * UI_UNIT_X), cumap, 0.0f, 1.0f, bg, 0, ""); + uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, bg, 0, ""); /* sliders for selected point */ for (i = 0; i < cm->totpoint; i++) { diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index d6ae2497cbb..c12b2f57f1a 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -126,7 +126,7 @@ void paintface_flush_flags(Object *ob) } } -void paintface_hide(Object *ob, const int unselected) +void paintface_hide(Object *ob, const bool unselected) { Mesh *me; MPoly *mpoly; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 3dfa2fa5c6c..dab5adda790 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -104,7 +104,7 @@ void EDBM_select_mirrored(Object *UNUSED(obedit), BMEditMesh *em, bool extend) EDBM_verts_mirror_cache_end(em); } -void EDBM_automerge(Scene *scene, Object *obedit, int update) +void EDBM_automerge(Scene *scene, Object *obedit, bool update) { if ((scene->toolsettings->automerge) && @@ -377,13 +377,11 @@ static void findnearestvert__doClosest(void *userData, BMVert *eve, const float -static unsigned int findnearestvert__backbufIndextest(void *handle, unsigned int index) +static bool findnearestvert__backbufIndextest(void *handle, unsigned int index) { BMEditMesh *em = (BMEditMesh *)handle; BMVert *eve = BM_vert_at_index(em->bm, index - 1); - - if (eve && BM_elem_flag_test(eve, BM_ELEM_SELECT)) return 0; - return 1; + return !(eve && BM_elem_flag_test(eve, BM_ELEM_SELECT)); } /** * findnearestvert @@ -2346,7 +2344,7 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */ // if (EM_texFaceCheck()) } -int EDBM_select_interior_faces(BMEditMesh *em) +bool EDBM_select_interior_faces(BMEditMesh *em) { BMesh *bm = em->bm; BMIter iter; @@ -2954,7 +2952,7 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **r_eve, BMEdge **r_eed, } } -static int edbm_deselect_nth(BMEditMesh *em, int nth, int offset) +static bool edbm_deselect_nth(BMEditMesh *em, int nth, int offset) { BMVert *v; BMEdge *e; @@ -2964,18 +2962,18 @@ static int edbm_deselect_nth(BMEditMesh *em, int nth, int offset) if (v) { walker_deselect_nth(em, nth, offset, &v->head); - return 1; + return true; } else if (e) { walker_deselect_nth(em, nth, offset, &e->head); - return 1; + return true; } else if (f) { walker_deselect_nth(em, nth, offset, &f->head); - return 1; + return true; } - return 0; + return false; } static int edbm_select_nth_exec(bContext *C, wmOperator *op) @@ -2988,7 +2986,7 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op) /* so input of offset zero ends up being (nth - 1) */ offset = (offset + (nth - 1)) % nth; - if (edbm_deselect_nth(em, nth, offset) == 0) { + if (edbm_deselect_nth(em, nth, offset) == false) { BKE_report(op->reports, RPT_ERROR, "Mesh has no active vert/edge/face"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 9020e133b33..5547df89463 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -816,7 +816,7 @@ UvMapVert *EDBM_uv_vert_map_at_index(UvVertMap *vmap, unsigned int v) /* A specialized vert map used by stitch operator */ -UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, int selected, int do_islands) +UvElementMap *EDBM_uv_element_map_create(BMEditMesh *em, const bool selected, const bool do_islands) { BMVert *ev; BMFace *efa; @@ -1070,7 +1070,7 @@ UvElement *ED_uv_element_get(UvElementMap *map, BMFace *efa, BMLoop *l) /* last_sel, use em->act_face otherwise get the last selected face in the editselections * at the moment, last_sel is mainly useful for making sure the space image dosnt flicker */ -MTexPoly *EDBM_mtexpoly_active_get(BMEditMesh *em, BMFace **r_act_efa, int sloppy, int selected) +MTexPoly *EDBM_mtexpoly_active_get(BMEditMesh *em, BMFace **r_act_efa, const bool sloppy, const bool selected) { BMFace *efa = NULL; @@ -1089,14 +1089,14 @@ MTexPoly *EDBM_mtexpoly_active_get(BMEditMesh *em, BMFace **r_act_efa, int slopp } /* can we edit UV's for this mesh?*/ -int EDBM_mtexpoly_check(BMEditMesh *em) +bool EDBM_mtexpoly_check(BMEditMesh *em) { /* some of these checks could be a touch overkill */ return em && em->bm->totface && CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY) && CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV); } -int EDBM_vert_color_check(BMEditMesh *em) +bool EDBM_vert_color_check(BMEditMesh *em) { /* some of these checks could be a touch overkill */ return em && em->bm->totface && CustomData_has_layer(&em->bm->ldata, CD_MLOOPCOL); @@ -1265,11 +1265,12 @@ void EDBM_verts_mirror_apply(BMEditMesh *em, const int sel_from, const int sel_t /* swap is 0 or 1, if 1 it hides not selected */ -void EDBM_mesh_hide(BMEditMesh *em, int swap) +void EDBM_mesh_hide(BMEditMesh *em, bool swap) { BMIter iter; BMElem *ele; int itermode; + char hflag_swap = swap ? BM_ELEM_SELECT : 0; if (em == NULL) return; @@ -1281,7 +1282,7 @@ void EDBM_mesh_hide(BMEditMesh *em, int swap) itermode = BM_FACES_OF_MESH; BM_ITER_MESH (ele, &iter, em->bm, itermode) { - if (BM_elem_flag_test(ele, BM_ELEM_SELECT) ^ swap) + if (BM_elem_flag_test(ele, BM_ELEM_SELECT) ^ hflag_swap) BM_elem_hide_set(em->bm, ele, true); } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index cbaa80718ee..97650b3a318 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -220,7 +220,7 @@ static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer) } /* without bContext, called in uvedit */ -int ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) +void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) { BMEditMesh *em = me->edit_btmesh; MLoopUV *luv; @@ -323,20 +323,16 @@ int ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) BLI_array_free(polylengths); DAG_id_tag_update(&me->id, 0); - - return 1; } -int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me) +void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me) { /* could be ldata or pdata */ CustomData *pdata = GET_CD_DATA(me, pdata); const int layernum = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY); - int retval = ED_mesh_uv_loop_reset_ex(me, layernum); + ED_mesh_uv_loop_reset_ex(me, layernum); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); - - return retval; } /* note: keep in sync with ED_mesh_color_add */ diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index cdc920ba3ec..e242dbfde85 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -549,7 +549,7 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", ""); + ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_parent_types, CLEAR_PARENT_ALL, "Type", ""); } /* ******************** Make Parent Operator *********************** */ diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index bdf04dcd20d..a9fac006486 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -84,18 +84,18 @@ static void vgroup_remap_update_users(Object *ob, int *map); static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup); static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg); static void vgroup_delete_all(Object *ob); -static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_tot, const short use_vert_sel); +static bool ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_tot, const bool use_vert_sel); -static int vertex_group_use_vert_sel(Object *ob) +static bool vertex_group_use_vert_sel(Object *ob) { if (ob->mode == OB_MODE_EDIT) { - return TRUE; + return true; } else if (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) { - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -106,14 +106,14 @@ static Lattice *vgroup_edit_lattice(Object *ob) return (lt->editlatt) ? lt->editlatt->latt : lt; } -int ED_vgroup_object_is_edit_mode(Object *ob) +bool ED_vgroup_object_is_edit_mode(Object *ob) { if (ob->type == OB_MESH) return (BMEdit_FromObject(ob) != NULL); else if (ob->type == OB_LATTICE) return (((Lattice *)ob->data)->editlatt != NULL); - return 0; + return false; } bDeformGroup *ED_vgroup_add_name(Object *ob, const char *name) @@ -167,22 +167,22 @@ void ED_vgroup_clear(Object *ob) } } -int ED_vgroup_data_create(ID *id) +bool ED_vgroup_data_create(ID *id) { /* create deform verts */ if (GS(id->name) == ID_ME) { Mesh *me = (Mesh *)id; me->dvert = CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, me->totvert); - return TRUE; + return true; } else if (GS(id->name) == ID_LT) { Lattice *lt = (Lattice *)id; lt->dvert = MEM_callocN(sizeof(MDeformVert) * lt->pntsu * lt->pntsv * lt->pntsw, "lattice deformVert"); - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -209,7 +209,7 @@ void ED_vgroup_data_clamp_range(ID *id, const int total) } } -static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_tot, const short use_vert_sel) +static bool ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_tot, const bool use_vert_sel) { *dvert_tot = 0; *dvert_arr = NULL; @@ -227,7 +227,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to int i; if (!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) { - return 0; + return false; } i = em->bm->totvert; @@ -250,7 +250,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to } } - return 1; + return true; } else if (me->dvert) { MVert *mvert = me->mvert; @@ -272,10 +272,10 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to } } - return 1; + return true; } else { - return 0; + return false; } } case ID_LT: @@ -302,20 +302,20 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to } } - return 1; + return true; } else { - return 0; + return false; } } } } - return 0; + return false; } /* returns true if the id type supports weights */ -int ED_vgroup_give_array(ID *id, MDeformVert **dvert_arr, int *dvert_tot) +bool ED_vgroup_give_array(ID *id, MDeformVert **dvert_arr, int *dvert_tot) { if (id) { switch (GS(id->name)) { @@ -324,7 +324,7 @@ int ED_vgroup_give_array(ID *id, MDeformVert **dvert_arr, int *dvert_tot) Mesh *me = (Mesh *)id; *dvert_arr = me->dvert; *dvert_tot = me->totvert; - return TRUE; + return true; } case ID_LT: { @@ -332,18 +332,18 @@ int ED_vgroup_give_array(ID *id, MDeformVert **dvert_arr, int *dvert_tot) lt = (lt->editlatt) ? lt->editlatt->latt : lt; *dvert_arr = lt->dvert; *dvert_tot = lt->pntsu * lt->pntsv * lt->pntsw; - return TRUE; + return true; } } } *dvert_arr = NULL; *dvert_tot = 0; - return FALSE; + return false; } /* matching index only */ -int ED_vgroup_copy_array(Object *ob, Object *ob_from) +bool ED_vgroup_copy_array(Object *ob, Object *ob_from) { MDeformVert **dvert_array_from, **dvf; MDeformVert **dvert_array, **dv; @@ -352,25 +352,25 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from) int i; int defbase_tot_from = BLI_countlist(&ob_from->defbase); int defbase_tot = BLI_countlist(&ob->defbase); - short new_vgroup = FALSE; + bool new_vgroup = false; - ED_vgroup_give_parray(ob_from->data, &dvert_array_from, &dvert_tot_from, FALSE); - ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE); + ED_vgroup_give_parray(ob_from->data, &dvert_array_from, &dvert_tot_from, false); + ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, false); if ((dvert_array == NULL) && (dvert_array_from != NULL) && ED_vgroup_data_create(ob->data)) { - ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE); - new_vgroup = TRUE; + ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, false); + new_vgroup = true; } if (ob == ob_from || dvert_tot == 0 || (dvert_tot != dvert_tot_from) || dvert_array_from == NULL || dvert_array == NULL) { if (dvert_array) MEM_freeN(dvert_array); if (dvert_array_from) MEM_freeN(dvert_array_from); - if (new_vgroup == TRUE) { + if (new_vgroup == true) { /* free the newly added vgroup since it wasn't compatible */ vgroup_delete_all(ob); } - return 0; + return false; } /* do the copy */ @@ -404,7 +404,7 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from) MEM_freeN(dvert_array); MEM_freeN(dvert_array_from); - return 1; + return true; } /***********************Start weight transfer (WT)*********************************/ @@ -477,8 +477,8 @@ static void vgroup_transfer_weight(float *r_weight_dst, const float weight_src, /* Could be exposed externally by implementing it in header with the rest. * Simple refactoring will break something. * For now, naming is ed_ instead of ED_*/ -static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGroup *dg_src, Scene *scene, - WT_Method method, WT_ReplaceMode replace_mode, wmOperator *op) +static bool ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGroup *dg_src, Scene *scene, + WT_Method method, WT_ReplaceMode replace_mode, wmOperator *op) { bDeformGroup *dg_dst; Mesh *me_dst, *me_src; @@ -510,14 +510,14 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou /* Sanity check.*/ if (!me_src->dvert) { BKE_report(op->reports, RPT_ERROR, "Transfer failed (source mesh does not have any vertex groups)"); - return 0; + return false; } /* Create data in memory when nothing there.*/ if (!me_dst->dvert) ED_vgroup_data_create(ob_dst->data); /* Get vertex group arrays.*/ - ED_vgroup_give_parray(ob_src->data, &dv_array_src, &dv_tot_src, FALSE); + ED_vgroup_give_parray(ob_src->data, &dv_array_src, &dv_tot_src, false); ED_vgroup_give_parray(ob_dst->data, &dv_array_dst, &dv_tot_dst, use_vert_sel); /* Get indexes of vertex groups.*/ @@ -556,7 +556,7 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou if (dv_array_dst) MEM_freeN(dv_array_dst); dmesh_src->release(dmesh_src); BKE_report(op->reports, RPT_ERROR, "Transfer failed (indices are not matching)"); - return 0; + return false; } /* Loop through the vertices.*/ @@ -746,7 +746,7 @@ static int ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGrou if (dv_array_dst) MEM_freeN(dv_array_dst); dmesh_src->release(dmesh_src); - return 1; + return true; } /***********************End weight transfer (WT)***********************************/ @@ -1053,7 +1053,7 @@ static void vgroup_duplicate(Object *ob) icdg = (ob->actdef - 1); /* TODO, we might want to allow only copy selected verts here? - campbell */ - ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE); + ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, false); if (dvert_array) { for (i = 0; i < dvert_tot; i++) { @@ -1277,12 +1277,12 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in int *dwIndices = MEM_callocN(sizeof(int) * totweight, "dwIndexTracker"); float distToStart; int bestIndex = 0; - char wasChange; + bool wasChange; char wasUp; int lastIndex = -1; float originalDistToBe = distToBe; do { - wasChange = FALSE; + wasChange = false; dm = dm_deform_recalc(scene, ob); dm->getVert(dm, index, &m); copy_v3_v3(oldPos, m.co); @@ -1392,12 +1392,12 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in } } if (bestIndex != -1) { - wasChange = TRUE; + wasChange = true; /* it is a good place to stop if it tries to move the opposite direction * (relative to the plane) of last time */ if (lastIndex != -1) { if (wasUp != upDown[bestIndex]) { - wasChange = FALSE; + wasChange = false; } } lastIndex = bestIndex; @@ -1414,7 +1414,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in dw->weight = 1; } if (oldw == dw->weight) { - wasChange = FALSE; + wasChange = false; } if (dm) { dm_deform_clear(dm, ob); dm = NULL; @@ -1512,7 +1512,7 @@ static void vgroup_levels(Object *ob, float offset, float gain) } } -static void vgroup_normalize_all(Object *ob, int lock_active) +static void vgroup_normalize_all(Object *ob, const bool lock_active) { MDeformVert *dv, **dvert_array = NULL; int i, dvert_tot = 0; @@ -1530,11 +1530,11 @@ static void vgroup_normalize_all(Object *ob, int lock_active) const int defbase_tot = BLI_countlist(&ob->defbase); char *lock_flags = BKE_objdef_lock_flags_get(ob, defbase_tot); - if ((lock_active == TRUE) && + if ((lock_active == true) && (lock_flags != NULL) && (def_nr < defbase_tot)) { - lock_flags[def_nr] = TRUE; + lock_flags[def_nr] = true; } for (i = 0; i < dvert_tot; i++) { @@ -1604,7 +1604,7 @@ static void vgroup_lock_all(Object *ob, int action) } } -static void vgroup_invert(Object *ob, const short auto_assign, const short auto_remove) +static void vgroup_invert(Object *ob, const bool auto_assign, const bool auto_remove) { MDeformWeight *dw; MDeformVert *dv, **dvert_array = NULL; @@ -1796,20 +1796,20 @@ static int inv_cmp_mdef_vert_weights(const void *a1, const void *a2) /* Used for limiting the number of influencing bones per vertex when exporting * skinned meshes. if all_deform_weights is True, limit all deform modifiers * to max_weights regardless of type, otherwise, only limit the number of influencing bones per vertex*/ -static int vertex_group_limit_total(Object *ob, - const int max_weights, - const int all_deform_weights) +static bool vertex_group_limit_total(Object *ob, + const int max_weights, + const bool all_deform_weights) { MDeformVert *dv, **dvert_array = NULL; int i, dvert_tot = 0; const int use_vert_sel = vertex_group_use_vert_sel(ob); - int is_change = FALSE; + bool is_change = false; ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel); if (dvert_array) { int defbase_tot = BLI_countlist(&ob->defbase); - const char *vgroup_validmap = (all_deform_weights == FALSE) ? + const char *vgroup_validmap = (all_deform_weights == false) ? BKE_objdef_validmap_get(ob, defbase_tot) : NULL; int num_to_drop = 0; @@ -1830,7 +1830,7 @@ static int vertex_group_limit_total(Object *ob, qsort(dv->dw, dv->totweight, sizeof(MDeformWeight), inv_cmp_mdef_vert_weights); dv->dw = MEM_reallocN(dv->dw, sizeof(MDeformWeight) * max_weights); dv->totweight = max_weights; - is_change = TRUE; + is_change = true; } } else { @@ -1866,7 +1866,7 @@ static int vertex_group_limit_total(Object *ob, /* Do we want to clean/normalize here? */ MEM_freeN(dv->dw); dv->dw = MEM_reallocN(dw_temp, sizeof(MDeformWeight) * dv->totweight); - is_change = TRUE; + is_change = true; } else { MEM_freeN(dw_temp); @@ -1884,7 +1884,7 @@ static int vertex_group_limit_total(Object *ob, return is_change; } -static void vgroup_clean(Object *ob, const float epsilon, int keep_single) +static void vgroup_clean(Object *ob, const float epsilon, const bool keep_single) { MDeformWeight *dw; MDeformVert *dv, **dvert_array = NULL; @@ -1911,7 +1911,7 @@ static void vgroup_clean(Object *ob, const float epsilon, int keep_single) if (dw) { if (dw->weight <= epsilon) { - if (keep_single == FALSE || dv->totweight > 1) { + if (keep_single == false || dv->totweight > 1) { defvert_remove_group(dv, dw); /* dw can be NULL */ } } @@ -1922,7 +1922,7 @@ static void vgroup_clean(Object *ob, const float epsilon, int keep_single) } } -static void vgroup_clean_all(Object *ob, const float epsilon, const int keep_single) +static void vgroup_clean_all(Object *ob, const float epsilon, const bool keep_single) { MDeformVert **dvert_array = NULL; int i, dvert_tot = 0; @@ -1965,8 +1965,8 @@ static void vgroup_clean_all(Object *ob, const float epsilon, const int keep_sin static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr, const char sel, const char sel_mirr, const int *flip_map, const int flip_map_len, - const short mirror_weights, const short flip_vgroups, - const short all_vgroups, const int act_vgroup) + const bool mirror_weights, const bool flip_vgroups, const bool all_vgroups, + const int act_vgroup) { BLI_assert(sel || sel_mirr); @@ -2020,7 +2020,8 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr, /* TODO, vgroup locking */ /* TODO, face masking */ -void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_vgroups, const short all_vgroups) +void ED_vgroup_mirror(Object *ob, + const bool mirror_weights, const bool flip_vgroups, const bool all_vgroups) { #define VGROUP_MIRR_OP \ @@ -2033,11 +2034,11 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v BMVert *eve, *eve_mirr; MDeformVert *dvert, *dvert_mirr; - short sel, sel_mirr; + char sel, sel_mirr; int *flip_map, flip_map_len; const int def_nr = ob->actdef - 1; - if ((mirror_weights == 0 && flip_vgroups == 0) || + if ((mirror_weights == false && flip_vgroups == false) || (BLI_findlink(&ob->defbase, def_nr) == NULL)) { return; @@ -2045,8 +2046,8 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v if (flip_vgroups) { flip_map = all_vgroups ? - defgroup_flip_map(ob, &flip_map_len, FALSE) : - defgroup_flip_map_single(ob, &flip_map_len, FALSE, def_nr); + defgroup_flip_map(ob, &flip_map_len, false) : + defgroup_flip_map_single(ob, &flip_map_len, false, def_nr); BLI_assert(flip_map != NULL); @@ -2072,7 +2073,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v goto cleanup; } - EDBM_verts_mirror_cache_begin(em, FALSE); + EDBM_verts_mirror_cache_begin(em, false); /* Go through the list of editverts and assign them */ BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { @@ -2106,7 +2107,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v } if (!use_vert_sel) { - sel = sel_mirr = TRUE; + sel = sel_mirr = true; } /* tag verts we have used */ @@ -2306,7 +2307,7 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) /* only in editmode */ /* removes from active defgroup, if allverts==0 only selected vertices */ -static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGroup *dg) +static void vgroup_active_remove_verts(Object *ob, const bool allverts, bDeformGroup *dg) { MDeformVert *dv; const int def_nr = BLI_findindex(&ob->defbase, dg); @@ -2378,7 +2379,7 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) assert(dg_index > -1); /* Make sure that no verts are using this group */ - vgroup_active_remove_verts(ob, TRUE, dg); + vgroup_active_remove_verts(ob, true, dg); /* Make sure that any verts with higher indices are adjusted accordingly */ if (ob->type == OB_MESH) { @@ -2442,17 +2443,17 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) } } -static int vgroup_object_in_edit_mode(Object *ob) +static bool vgroup_object_in_edit_mode(Object *ob) { if (ob->type == OB_MESH) return (BMEdit_FromObject(ob) != NULL); else if (ob->type == OB_LATTICE) return (((Lattice *)ob->data)->editlatt != NULL); - return 0; + return false; } -static int vgroup_object_in_wpaint_vert_select(Object *ob) +static bool vgroup_object_in_wpaint_vert_select(Object *ob) { if (ob->type == OB_MESH) { Mesh *me = ob->data; @@ -2461,7 +2462,7 @@ static int vgroup_object_in_wpaint_vert_select(Object *ob) (ME_EDIT_PAINT_SEL_MODE(me) == SCE_SELECT_VERTEX) ); } - return 0; + return false; } static void vgroup_delete(Object *ob) @@ -2739,7 +2740,7 @@ static int vertex_group_remove_from_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - vgroup_active_remove_verts(ob, FALSE, dg); + vgroup_active_remove_verts(ob, false, dg); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -2914,7 +2915,7 @@ void OBJECT_OT_vertex_group_normalize(wmOperatorType *ot) static int vertex_group_normalize_all_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - int lock_active = RNA_boolean_get(op->ptr, "lock_active"); + bool lock_active = RNA_boolean_get(op->ptr, "lock_active"); vgroup_normalize_all(ob, lock_active); @@ -2940,7 +2941,7 @@ void OBJECT_OT_vertex_group_normalize_all(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "lock_active", TRUE, "Lock Active", + RNA_def_boolean(ot->srna, "lock_active", true, "Lock Active", "Keep the values of the active group while normalizing others"); } @@ -3027,8 +3028,8 @@ void OBJECT_OT_vertex_group_lock(wmOperatorType *ot) static int vertex_group_invert_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - int auto_assign = RNA_boolean_get(op->ptr, "auto_assign"); - int auto_remove = RNA_boolean_get(op->ptr, "auto_remove"); + bool auto_assign = RNA_boolean_get(op->ptr, "auto_assign"); + bool auto_remove = RNA_boolean_get(op->ptr, "auto_remove"); vgroup_invert(ob, auto_assign, auto_remove); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -3052,9 +3053,9 @@ void OBJECT_OT_vertex_group_invert(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "auto_assign", TRUE, "Add Weights", + RNA_def_boolean(ot->srna, "auto_assign", true, "Add Weights", "Add verts from groups that have zero weight before inverting"); - RNA_def_boolean(ot->srna, "auto_remove", TRUE, "Remove Weights", + RNA_def_boolean(ot->srna, "auto_remove", true, "Remove Weights", "Remove verts from groups that have zero weight after inverting"); } @@ -3080,23 +3081,23 @@ static int vertex_group_blend_poll(bContext *C) ID *data = (ob) ? ob->data : NULL; if (!(ob && !ob->id.lib && data && !data->lib)) - return FALSE; + return false; if (vgroup_object_in_edit_mode(ob)) { - return TRUE; + return true; } else if ((ob->type == OB_MESH) && (ob->mode & OB_MODE_WEIGHT_PAINT)) { if (ME_EDIT_PAINT_SEL_MODE(((Mesh *)data)) == SCE_SELECT_VERTEX) { - return TRUE; + return true; } else { CTX_wm_operator_poll_msg_set(C, "Vertex select needs to be enabled in weight paint mode"); - return FALSE; + return false; } } else { - return FALSE; + return false; } } @@ -3128,8 +3129,8 @@ static int vertex_group_clean_exec(bContext *C, wmOperator *op) Object *ob = ED_object_context(C); float limit = RNA_float_get(op->ptr, "limit"); - int all_groups = RNA_boolean_get(op->ptr, "all_groups"); - int keep_single = RNA_boolean_get(op->ptr, "keep_single"); + bool all_groups = RNA_boolean_get(op->ptr, "all_groups"); + bool keep_single = RNA_boolean_get(op->ptr, "keep_single"); if (all_groups) vgroup_clean_all(ob, limit, keep_single); else vgroup_clean(ob, limit, keep_single); @@ -3156,8 +3157,8 @@ void OBJECT_OT_vertex_group_clean(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_float(ot->srna, "limit", 0.0f, 0.0f, 1.0, "Limit", "Remove weights under this limit", 0.0f, 0.99f); - RNA_def_boolean(ot->srna, "all_groups", FALSE, "All Groups", "Clean all vertex groups"); - RNA_def_boolean(ot->srna, "keep_single", FALSE, "Keep Single", + RNA_def_boolean(ot->srna, "all_groups", false, "All Groups", "Clean all vertex groups"); + RNA_def_boolean(ot->srna, "keep_single", false, "Keep Single", "Keep verts assigned to at least one group when cleaning"); } @@ -3166,7 +3167,7 @@ static int vertex_group_limit_total_exec(bContext *C, wmOperator *op) Object *ob = ED_object_context(C); const int limit = RNA_int_get(op->ptr, "limit"); - const int all_deform_weights = RNA_boolean_get(op->ptr, "all_deform_weights"); + const bool all_deform_weights = RNA_boolean_get(op->ptr, "all_deform_weights"); if (vertex_group_limit_total(ob, limit, all_deform_weights)) { @@ -3200,7 +3201,7 @@ void OBJECT_OT_vertex_group_limit_total(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "limit", 4, 1, 32, "Limit", "Maximum number of deform weights", 1, 32); - RNA_def_boolean(ot->srna, "all_deform_weights", FALSE, "All Deform Weights", "Cull all deform weights, not just bones"); + RNA_def_boolean(ot->srna, "all_deform_weights", false, "All Deform Weights", "Cull all deform weights, not just bones"); } static int vertex_group_mirror_exec(bContext *C, wmOperator *op) @@ -3235,9 +3236,9 @@ void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_boolean(ot->srna, "mirror_weights", TRUE, "Mirror Weights", "Mirror weights"); - RNA_def_boolean(ot->srna, "flip_group_names", TRUE, "Flip Group Names", "Flip vertex group names"); - RNA_def_boolean(ot->srna, "all_groups", FALSE, "All Groups", "Mirror all vertex groups weights"); + RNA_def_boolean(ot->srna, "mirror_weights", true, "Mirror Weights", "Mirror weights"); + RNA_def_boolean(ot->srna, "flip_group_names", true, "Flip Group Names", "Flip vertex group names"); + RNA_def_boolean(ot->srna, "all_groups", false, "All Groups", "Mirror all vertex groups weights"); } diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 3469604b3dd..b6ee9254396 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -540,6 +540,13 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, if (type == GL_FLOAT) { /* need to set internal format to higher range float */ + + /* NOTE: this could fail on some drivers, like mesa, + * but currently this code is only used by color + * management stuff which already checks on whether + * it's possible to use GL_RGBA16F_ARB + */ + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, tex_w, tex_h, 0, format, GL_FLOAT, NULL); } else { @@ -1028,7 +1035,9 @@ void bglFlush(void) /* **** Color management helper functions for GLSL display/transform ***** */ /* Draw given image buffer on a screen using GLSL for display transform */ -void glaDrawImBuf_glsl_ctx(const bContext *C, ImBuf *ibuf, float x, float y, int zoomfilter) +void glaDrawImBuf_glsl(ImBuf *ibuf, float x, float y, int zoomfilter, + ColorManagedViewSettings *view_settings, + ColorManagedDisplaySettings *display_settings) { bool force_fallback = false; bool need_fallback = true; @@ -1080,10 +1089,19 @@ void glaDrawImBuf_glsl_ctx(const bContext *C, ImBuf *ibuf, float x, float y, int if (force_fallback == false) { int ok; - if (ibuf->rect_float) - ok = IMB_colormanagement_setup_glsl_draw_ctx(C, TRUE); - else - ok = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->rect_colorspace, FALSE); + if (ibuf->rect_float) { + if (ibuf->float_colorspace) { + ok = IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings, + ibuf->float_colorspace, TRUE); + } + else { + ok = IMB_colormanagement_setup_glsl_draw(view_settings, display_settings, TRUE); + } + } + else { + ok = IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings, + ibuf->rect_colorspace, FALSE); + } if (ok) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); @@ -1121,7 +1139,7 @@ void glaDrawImBuf_glsl_ctx(const bContext *C, ImBuf *ibuf, float x, float y, int unsigned char *display_buffer; void *cache_handle; - display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); + display_buffer = IMB_display_buffer_acquire(ibuf, view_settings, display_settings, &cache_handle); if (display_buffer) glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, @@ -1131,6 +1149,16 @@ void glaDrawImBuf_glsl_ctx(const bContext *C, ImBuf *ibuf, float x, float y, int } } +void glaDrawImBuf_glsl_ctx(const bContext *C, ImBuf *ibuf, float x, float y, int zoomfilter) +{ + ColorManagedViewSettings *view_settings; + ColorManagedDisplaySettings *display_settings; + + IMB_colormanagement_display_settings_from_ctx(C, &view_settings, &display_settings); + + glaDrawImBuf_glsl(ibuf, x, y, zoomfilter, view_settings, display_settings); +} + /* Transform buffer from role to scene linear space using GLSL OCIO conversion * * See IMB_colormanagement_setup_transform_from_role_glsl description for diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 40a18734948..796bb99ebaf 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -38,9 +38,11 @@ #include "BKE_context.h" #include "BKE_paint.h" #include "BKE_main.h" +#include "BKE_image.h" #include "ED_sculpt.h" #include "ED_screen.h" +#include "ED_image.h" #include "UI_resources.h" #include "WM_api.h" @@ -447,20 +449,26 @@ static void BRUSH_OT_uv_sculpt_tool_set(wmOperatorType *ot) /***** Stencil Control *****/ -enum { +typedef enum { STENCIL_TRANSLATE, STENCIL_SCALE, STENCIL_ROTATE } StencilControlMode; +typedef enum { +STENCIL_CONSTRAINT_X = 1, +STENCIL_CONSTRAINT_Y = 2 +} StencilConstraint; + typedef struct { - int init_mouse[2]; - int init_spos[2]; - int init_sdim[2]; + float init_mouse[2]; + float init_spos[2]; + float init_sdim[2]; float init_rot; float init_angle; float lenorig; - int mode; + StencilControlMode mode; + StencilConstraint constrain_mode; Brush *br; } StencilControlData; @@ -468,15 +476,16 @@ static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *ev { Paint *paint = paint_get_active_from_context(C); Brush *br = paint_brush(paint); - int mdiff[2]; + float mdiff[2]; + float mvalf[2] = {event->mval[0], event->mval[1]}; StencilControlData *scd = MEM_mallocN(sizeof(StencilControlData), "stencil_control"); - copy_v2_v2_int(scd->init_mouse, event->mval); - copy_v2_v2_int(scd->init_sdim, br->stencil_dimension); - copy_v2_v2_int(scd->init_spos, br->stencil_pos); - sub_v2_v2v2_int(mdiff, event->mval, br->stencil_pos); - scd->lenorig = sqrtf(mdiff[0] * mdiff[0] + mdiff[1] * mdiff[1]); + copy_v2_v2(scd->init_mouse, mvalf); + copy_v2_v2(scd->init_sdim, br->stencil_dimension); + copy_v2_v2(scd->init_spos, br->stencil_pos); + sub_v2_v2v2(mdiff, mvalf, br->stencil_pos); + scd->lenorig = len_v2(mdiff); scd->br = br; scd->init_rot = br->mtex.rot; scd->init_angle = atan2(mdiff[1], mdiff[0]); @@ -494,8 +503,8 @@ static int stencil_control_cancel(bContext *UNUSED(C), wmOperator *op) StencilControlData *scd = op->customdata; Brush *br = scd->br; - copy_v2_v2_int(br->stencil_dimension, scd->init_sdim); - copy_v2_v2_int(br->stencil_pos, scd->init_spos); + copy_v2_v2(br->stencil_dimension, scd->init_sdim); + copy_v2_v2(br->stencil_pos, scd->init_spos); br->mtex.rot = scd->init_rot; MEM_freeN(op->customdata); return OPERATOR_CANCELLED; @@ -508,28 +517,32 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve switch (event->type) { case MOUSEMOVE: { - int mdiff[2]; + float mdiff[2]; + float mvalf[2] = {event->mval[0], event->mval[1]}; switch (scd->mode) { case STENCIL_TRANSLATE: - sub_v2_v2v2_int(mdiff, event->mval, scd->init_mouse); - add_v2_v2v2_int(scd->br->stencil_pos, scd->init_spos, + sub_v2_v2v2(mdiff, mvalf, scd->init_mouse); + add_v2_v2v2(scd->br->stencil_pos, scd->init_spos, mdiff); break; case STENCIL_SCALE: { float len, factor; - sub_v2_v2v2_int(mdiff, event->mval, scd->br->stencil_pos); - len = sqrtf(mdiff[0] * mdiff[0] + mdiff[1] * mdiff[1]); + sub_v2_v2v2(mdiff, mvalf, scd->br->stencil_pos); + len = len_v2(mdiff); factor = len / scd->lenorig; - mdiff[0] = factor * scd->init_sdim[0]; - mdiff[1] = factor * scd->init_sdim[1]; - copy_v2_v2_int(scd->br->stencil_dimension, mdiff); + copy_v2_v2(mdiff, scd->init_sdim); + if (scd->constrain_mode != STENCIL_CONSTRAINT_Y) + mdiff[0] = factor * scd->init_sdim[0]; + if (scd->constrain_mode != STENCIL_CONSTRAINT_X) + mdiff[1] = factor * scd->init_sdim[1]; + copy_v2_v2(scd->br->stencil_dimension, mdiff); break; } case STENCIL_ROTATE: { float angle; - sub_v2_v2v2_int(mdiff, event->mval, scd->br->stencil_pos); + sub_v2_v2v2(mdiff, mvalf, scd->br->stencil_pos); angle = atan2(mdiff[1], mdiff[0]); angle = scd->init_rot + angle - scd->init_angle; if (angle < 0.0f) @@ -555,6 +568,23 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve WM_event_add_notifier(C, NC_WINDOW, NULL); return OPERATOR_CANCELLED; } + case XKEY: + if (event->val == KM_PRESS) { + + if (scd->constrain_mode == STENCIL_CONSTRAINT_X) + scd->constrain_mode = 0; + else + scd->constrain_mode = STENCIL_CONSTRAINT_X; + } + break; + case YKEY: + if (event->val == KM_PRESS) { + if (scd->constrain_mode == STENCIL_CONSTRAINT_Y) + scd->constrain_mode = 0; + else + scd->constrain_mode = STENCIL_CONSTRAINT_Y; + } + break; default: break; } @@ -597,6 +627,48 @@ static void BRUSH_OT_stencil_control(wmOperatorType *ot) RNA_def_enum(ot->srna, "mode", stencil_control_items, 0, "Tool", ""); } + +static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Paint *paint = paint_get_active_from_context(C); + Brush *br = paint_brush(paint); + Tex *tex = (br)? br->mtex.tex : NULL; + + if (tex && tex->type == TEX_IMAGE && tex->ima) { + float aspx, aspy; + Image *ima = tex->ima; + float orig_area, stencil_area, factor; + ED_image_get_uv_aspect(ima, NULL, &aspx, &aspy); + + orig_area = aspx*aspy; + stencil_area = br->stencil_dimension[0]*br->stencil_dimension[1]; + + factor = sqrt(stencil_area/orig_area); + + br->stencil_dimension[0] = factor*aspx; + br->stencil_dimension[1] = factor*aspy; + } + + return OPERATOR_FINISHED; +} + + +static void BRUSH_OT_stencil_fit_image_aspect(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Image Aspect"; + ot->description = "Adjust the stencil size to fit image aspect ratio"; + ot->idname = "BRUSH_OT_stencil_fit_image_aspect"; + + /* api callbacks */ + ot->exec = stencil_fit_image_aspect_exec; + ot->poll = stencil_control_poll; + + /* flags */ + ot->flag = 0; +} + + static void ed_keymap_stencil(wmKeyMap *keymap) { wmKeyMapItem *kmi; @@ -620,6 +692,7 @@ void ED_operatortypes_paint(void) WM_operatortype_append(BRUSH_OT_curve_preset); WM_operatortype_append(BRUSH_OT_reset); WM_operatortype_append(BRUSH_OT_stencil_control); + WM_operatortype_append(BRUSH_OT_stencil_fit_image_aspect); /* note, particle uses a different system, can be added with existing operators in wm.py */ WM_operatortype_append(PAINT_OT_brush_select); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index a51315d9a16..1c4ea8b5546 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -2734,7 +2734,7 @@ void CLIP_OT_frame_jump(wmOperatorType *ot) /* api callbacks */ ot->exec = frame_jump_exec; - ot->poll = ED_space_clip_tracking_poll; + ot->poll = ED_space_clip_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 74f776549e9..a6379e6465f 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -225,7 +225,12 @@ static void console_line_verify_length(ConsoleLine *ci, int len) { /* resize the buffer if needed */ if (len >= ci->len_alloc) { - int new_len = len * 2; /* new length */ + /* new length */ +#ifndef NDEBUG + int new_len = len + 1; +#else + int new_len = (len + 1) * 2; +#endif char *new_line = MEM_callocN(new_len, "console line"); memcpy(new_line, ci->line, ci->len); MEM_freeN(ci->line); @@ -582,7 +587,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) stride = ci->cursor - pos; if (stride) { ci->cursor -= stride; /* same as above */ - memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1); + memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - (ci->cursor + stride)) + 1); ci->len -= stride; BLI_assert(ci->len >= 0); done = TRUE; diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index d7206c9b111..cd3de834e78 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2948,8 +2948,6 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode) ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf) { float x, y; - unsigned char *display_buffer; - void *cache_handle; glMatrixMode(GL_PROJECTION); glPushMatrix(); @@ -2967,14 +2965,16 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode) x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof; y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof; - - display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); + if (ibuf->rect || ibuf->rect_float) { + unsigned char *display_buffer = NULL; + void *cache_handle = NULL; - if (display_buffer) { if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) { int ofs; + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); + #ifdef __BIG_ENDIAN__ if (snode->flag & SNODE_SHOW_R) ofs = 2; else if (snode->flag & SNODE_SHOW_G) ofs = 1; @@ -2994,6 +2994,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode) glPixelZoom(1.0f, 1.0f); } else if (snode->flag & SNODE_SHOW_ALPHA) { + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); + glPixelZoom(snode->zoom, snode->zoom); /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ #ifdef __BIG_ENDIAN__ @@ -3011,7 +3013,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPixelZoom(snode->zoom, snode->zoom); - glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer); + glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST); glPixelZoom(1.0f, 1.0f); glDisable(GL_BLEND); @@ -3019,13 +3021,14 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode) else { glPixelZoom(snode->zoom, snode->zoom); - glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer); + glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST); glPixelZoom(1.0f, 1.0f); } - } - IMB_display_buffer_release(cache_handle); + if (cache_handle) + IMB_display_buffer_release(cache_handle); + } /** @note draw selected info on backdrop */ if (snode->edittree) { diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 141af5d5ba4..3a7610cbf2a 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -920,9 +920,11 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq float col[3]; GLuint texid; GLuint last_texid; - unsigned char *display_buffer; + void *display_buffer; void *cache_handle = NULL; const int is_imbuf = ED_space_sequencer_check_show_imbuf(sseq); + int format, type; + bool glsl_used = false; if (G.is_rendering == FALSE && (scene->r.seq_flag & R_SEQ_GL_PREV) == 0) { /* stop all running jobs, except screen one. currently previews frustrate Render @@ -1040,9 +1042,46 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq } display_buffer = (unsigned char *)ibuf->rect; + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; } else { - display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); + if (ibuf->rect_float) { + display_buffer = ibuf->rect_float; + + if (ibuf->channels == 4) { + format = GL_RGBA; + } + else if (ibuf->channels == 3) { + format = GL_RGB; + } + else { + BLI_assert(!"Incompatible number of channels for float buffer in sequencer"); + format = GL_RGBA; + display_buffer = NULL; + } + + type = GL_FLOAT; + + if (ibuf->float_colorspace) { + glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->float_colorspace, TRUE); + } + else { + glsl_used = IMB_colormanagement_setup_glsl_draw_ctx(C, TRUE); + } + } + else if (ibuf->rect) { + display_buffer = ibuf->rect; + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; + + glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->rect_colorspace, FALSE); + } + else { + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; + display_buffer = NULL; + } } /* setting up the view - actual drawing starts here */ @@ -1068,7 +1107,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, format, type, display_buffer); glBegin(GL_QUADS); @@ -1105,6 +1144,9 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq glDisable(GL_BLEND); glDeleteTextures(1, &texid); + if (glsl_used) + IMB_colormanagement_finish_glsl_draw(); + if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { float x1 = v2d->tot.xmin; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index d0437c77af7..983b479f550 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1528,7 +1528,7 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, /* smart function to sample a rect spiralling outside, nice for backbuf selection */ unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int size, unsigned int min, unsigned int max, float *r_dist, short strict, - void *handle, unsigned int (*indextest)(void *handle, unsigned int index)) + void *handle, bool (*indextest)(void *handle, unsigned int index)) { struct ImBuf *buf; unsigned int *bufmin, *bufmax, *tbuf; @@ -1536,7 +1536,7 @@ unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int int a, b, rc, nr, amount, dirvec[4][2]; int distance = 0; unsigned int index = 0; - short indexok = 0; + bool indexok = false; amount = (size - 1) / 2; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index be296025624..bf4baf9ea22 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1407,12 +1407,16 @@ int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], int c t->state = TRANS_RUNNING; - t->options = CTX_NONE; + /* avoid calculating PET */ + t->options = CTX_NONE | CTX_NO_PET; t->mode = TFM_DUMMY; initTransInfo(C, t, NULL, NULL); // internal data, mouse, vectors + /* avoid doing connectivity lookups (when V3D_LOCAL is set) */ + t->around = V3D_CENTER; + createTransData(C, t); // make TransData structs from selection t->around = centerMode; // override userdefined mode diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 661d7055036..2098c4a1e27 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5182,7 +5182,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) * during cleanup - psy-fi */ freeEdgeSlideTempFaces(sld); } - EDBM_automerge(t->scene, t->obedit, TRUE); + EDBM_automerge(t->scene, t->obedit, true); } else { if (t->mode == TFM_EDGE_SLIDE) { diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index ba8b26c9083..14478db3846 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1427,9 +1427,7 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - if (!ED_mesh_uv_loop_reset(C, me)) { - return OPERATOR_CANCELLED; - } + ED_mesh_uv_loop_reset(C, me); DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h index 58b55b0f137..314daed00dd 100644 --- a/source/blender/imbuf/IMB_colormanagement.h +++ b/source/blender/imbuf/IMB_colormanagement.h @@ -95,6 +95,10 @@ struct ImBuf *IMB_colormanagement_imbuf_for_write(struct ImBuf *ibuf, int save_a /* ** Public display buffers interfaces ** */ +void IMB_colormanagement_display_settings_from_ctx(const struct bContext *C, + struct ColorManagedViewSettings **view_settings_r, + struct ColorManagedDisplaySettings **display_settings_r); + unsigned char *IMB_display_buffer_acquire(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings, void **cache_handle); unsigned char *IMB_display_buffer_acquire_ctx(const struct bContext *C, struct ImBuf *ibuf, void **cache_handle); diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index a74f28e79c9..b8de1cf75d1 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -662,8 +662,9 @@ void colormanage_cache_free(ImBuf *ibuf) } } -static void display_transform_get_from_ctx(const bContext *C, ColorManagedViewSettings **view_settings_r, - ColorManagedDisplaySettings **display_settings_r) +void IMB_colormanagement_display_settings_from_ctx(const bContext *C, + ColorManagedViewSettings **view_settings_r, + ColorManagedDisplaySettings **display_settings_r) { Scene *scene = CTX_data_scene(C); SpaceImage *sima = CTX_wm_space_image(C); @@ -1963,7 +1964,7 @@ unsigned char *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, vo ColorManagedViewSettings *view_settings; ColorManagedDisplaySettings *display_settings; - display_transform_get_from_ctx(C, &view_settings, &display_settings); + IMB_colormanagement_display_settings_from_ctx(C, &view_settings, &display_settings); return IMB_display_buffer_acquire(ibuf, view_settings, display_settings, cache_handle); } @@ -2820,7 +2821,7 @@ int IMB_colormanagement_setup_glsl_draw_from_space_ctx(const struct bContext *C, ColorManagedViewSettings *view_settings; ColorManagedDisplaySettings *display_settings; - display_transform_get_from_ctx(C, &view_settings, &display_settings); + IMB_colormanagement_display_settings_from_ctx(C, &view_settings, &display_settings); return IMB_colormanagement_setup_glsl_draw_from_space(view_settings, display_settings, from_colorspace, predivide); } diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 51c6c2fc2d9..44358d8147e 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -285,8 +285,8 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im /* exception, skip images over 100mb */ if (source == THB_SOURCE_IMAGE) { - const size_t size = BLI_file_size(path); - if (size != -1 && size > THUMB_SIZE_MAX) { + const size_t file_size = BLI_file_size(path); + if (file_size != -1 && file_size > THUMB_SIZE_MAX) { // printf("file too big: %d, skipping %s\n", (int)size, path); return NULL; } diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 11dd68bb11b..97ff24d3366 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -106,8 +106,8 @@ typedef struct Brush { float add_col[3]; float sub_col[3]; - int stencil_pos[2]; - int stencil_dimension[2]; + float stencil_pos[2]; + float stencil_dimension[2]; } Brush; /* Brush.flag */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 22259d71a2f..7d817f3dbe0 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -1112,10 +1112,11 @@ __attribute__ ((format(printf, 1, 2))) #endif ; -/* Equals test (skips pointers and collections) */ +/* Equals test (skips pointers and collections) + * is_strict false assumes uninitialized properties are equal */ -int RNA_property_equals(struct PointerRNA *a, struct PointerRNA *b, struct PropertyRNA *prop); -int RNA_struct_equals(struct PointerRNA *a, struct PointerRNA *b); +bool RNA_property_equals(struct PointerRNA *a, struct PointerRNA *b, struct PropertyRNA *prop, bool is_strict); +bool RNA_struct_equals(struct PointerRNA *a, struct PointerRNA *b, bool is_strict); #ifdef __cplusplus } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 00ee1b49da2..3d2f29b94af 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -6179,14 +6179,21 @@ void _RNA_warning(const char *format, ...) #endif } -int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop) +bool RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop, bool is_strict) { + int len, fromlen; + + /* if not strict, uninitialized properties are assumed to match */ + if (!is_strict) + if (!(RNA_property_is_set(a, prop) && RNA_property_is_set(b, prop))) + return true; + /* get the length of the array to work with */ - int len = RNA_property_array_length(a, prop); - int fromlen = RNA_property_array_length(b, prop); + len = RNA_property_array_length(a, prop); + fromlen = RNA_property_array_length(b, prop); if (len != fromlen) - return 0; + return false; /* get and set the default values as appropriate for the various types */ switch (RNA_property_type(prop)) { @@ -6195,7 +6202,7 @@ int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop) if (len) { int fixed_a[16], fixed_b[16]; int *array_a, *array_b; - int equals; + bool equals; array_a = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals") : fixed_a; array_b = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals") : fixed_b; @@ -6221,7 +6228,7 @@ int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop) if (len) { int fixed_a[16], fixed_b[16]; int *array_a, *array_b; - int equals; + bool equals; array_a = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals"): fixed_a; array_b = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals"): fixed_b; @@ -6247,7 +6254,7 @@ int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop) if (len) { float fixed_a[16], fixed_b[16]; float *array_a, *array_b; - int equals; + bool equals; array_a = (len > 16) ? MEM_callocN(sizeof(float) * len, "RNA equals") : fixed_a; array_b = (len > 16) ? MEM_callocN(sizeof(float) * len, "RNA equals") : fixed_b; @@ -6280,7 +6287,7 @@ int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop) int len_a, len_b; char *value_a = RNA_property_string_get_alloc(a, prop, fixed_a, sizeof(fixed_a), &len_a); char *value_b = RNA_property_string_get_alloc(b, prop, fixed_b, sizeof(fixed_b), &len_b); - int equals = strcmp(value_a, value_b) == 0; + bool equals = strcmp(value_a, value_b) == 0; if (value_a != fixed_a) MEM_freeN(value_a); if (value_b != fixed_b) MEM_freeN(value_b); @@ -6292,22 +6299,22 @@ int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop) break; } - return 1; + return true; } -int RNA_struct_equals(PointerRNA *a, PointerRNA *b) +bool RNA_struct_equals(PointerRNA *a, PointerRNA *b, bool is_strict) { CollectionPropertyIterator iter; // CollectionPropertyRNA *citerprop; /* UNUSED */ PropertyRNA *iterprop; - int equals = 1; + bool equals = true; if (a == NULL && b == NULL) - return 1; + return true; else if (a == NULL || b == NULL) - return 0; + return false; else if (a->type != b->type) - return 0; + return false; iterprop = RNA_struct_iterator_property(a->type); // citerprop = (CollectionPropertyRNA *)rna_ensure_property(iterprop); /* UNUSED */ @@ -6316,8 +6323,8 @@ int RNA_struct_equals(PointerRNA *a, PointerRNA *b) for (; iter.valid; RNA_property_collection_next(&iter)) { PropertyRNA *prop = iter.ptr.data; - if (!RNA_property_equals(a, b, prop)) { - equals = 0; + if (!RNA_property_equals(a, b, prop, is_strict)) { + equals = false; break; } } diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 8946274fc38..0c5b257733a 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -793,6 +793,18 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Autosmooth", "Amount of smoothing to automatically apply to each stroke"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "stencil_pos", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "stencil_pos"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Stencil Position", "Position of stencil in viewport"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop = RNA_def_property(srna, "stencil_dimension", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "stencil_dimension"); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Stencil Dimensions", "Dimensions of stencil in viewport"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + /* flag */ prop = RNA_def_property(srna, "use_airbrush", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index d504585f738..ba45e10ae08 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -313,7 +313,7 @@ Mesh *rna_Main_meshes_new_from_object( copycu->editnurb = tmpcu->editnurb; /* get updated display list, and convert to a mesh */ - BKE_displist_make_curveTypes_forRender(sce, tmpobj, &dispbase, &derivedFinal, FALSE); + BKE_displist_make_curveTypes_forRender(sce, tmpobj, &dispbase, &derivedFinal, FALSE, render); copycu->editfont = NULL; copycu->editnurb = NULL; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 16f63e31353..7ccf11af829 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -6872,6 +6872,11 @@ static void rna_def_nodetree(BlenderRNA *brna) RNA_def_struct_refine_func(srna, "rna_NodeTree_refine"); RNA_def_struct_register_funcs(srna, "rna_NodeTree_register", "rna_NodeTree_unregister", NULL); + prop = RNA_def_property(srna, "view_center", PROP_FLOAT, PROP_XYZ); + RNA_def_property_array(prop, 2); + RNA_def_property_float_sdna(prop, NULL, "view_center"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + /* AnimData */ rna_def_animdata_common(srna); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e036bb1c999..7a69f3c6b7c 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3357,7 +3357,8 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); /* the mx/my "cursor" in the node editor is used only by operators to store the mouse position */ - prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ); + RNA_def_property_array(prop, 2); RNA_def_property_float_sdna(prop, NULL, "cursor"); RNA_def_property_ui_text(prop, "Cursor Location", "Location for adding new nodes"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 50ef122fe60..c9b18009b71 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -272,10 +272,12 @@ void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec) void ntreeShaderEndExecTree(bNodeTreeExec *exec) { if (exec) { + /* exec may get freed, so assign ntree */ + bNodeTree *ntree = exec->nodetree; ntreeShaderEndExecTree_internal(exec); /* XXX clear nodetree backpointer to exec data, same problem as noted in ntreeBeginExecTree */ - exec->nodetree->execdata = NULL; + ntree->execdata = NULL; } } diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index a591b41db98..6aaa58f0ed4 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -423,6 +423,15 @@ static PyObject *bpy_bmedge_is_contiguous_get(BPy_BMEdge *self) return PyBool_FromLong(BM_edge_is_contiguous(self->e)); } +PyDoc_STRVAR(bpy_bmedge_is_convex_doc, +"True when this edge joins 2 convex faces, depends on a valid face normal (read-only).\n\n:type: boolean" +); +static PyObject *bpy_bmedge_is_convex_get(BPy_BMEdge *self) +{ + BPY_BM_CHECK_OBJ(self); + return PyBool_FromLong(BM_edge_is_convex(self->e)); +} + PyDoc_STRVAR(bpy_bmedge_is_wire_doc, "True when this edge is not connected to any faces (read-only).\n\n:type: boolean" ); @@ -652,10 +661,10 @@ static PyObject *bpy_bmloop_link_loop_radial_prev_get(BPy_BMLoop *self) return BPy_BMLoop_CreatePyObject(self->bm, self->l->radial_prev); } -PyDoc_STRVAR(bpy_bm_is_convex_doc, -"True when this loop is at the convex corner of a face, depends on a valid face normal (read-only).\n\n:type: :class:`BMLoop`" +PyDoc_STRVAR(bpy_bmloop_is_convex_doc, +"True when this loop is at the convex corner of a face, depends on a valid face normal (read-only).\n\n:type: boolean" ); -static PyObject *bpy_bm_is_convex_get(BPy_BMLoop *self) +static PyObject *bpy_bmloop_is_convex_get(BPy_BMLoop *self) { BPY_BM_CHECK_OBJ(self); return PyBool_FromLong(BM_loop_is_convex(self->l)); @@ -777,6 +786,7 @@ static PyGetSetDef bpy_bmedge_getseters[] = { /* readonly checks */ {(char *)"is_manifold", (getter)bpy_bmedge_is_manifold_get, (setter)NULL, (char *)bpy_bmedge_is_manifold_doc, NULL}, {(char *)"is_contiguous", (getter)bpy_bmedge_is_contiguous_get, (setter)NULL, (char *)bpy_bmedge_is_contiguous_doc, NULL}, + {(char *)"is_convex", (getter)bpy_bmedge_is_convex_get, (setter)NULL, (char *)bpy_bmedge_is_convex_doc, NULL}, {(char *)"is_wire", (getter)bpy_bmedge_is_wire_get, (setter)NULL, (char *)bpy_bmedge_is_wire_doc, NULL}, {(char *)"is_boundary", (getter)bpy_bmedge_is_boundary_get, (setter)NULL, (char *)bpy_bmedge_is_boundary_doc, NULL}, {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, @@ -832,8 +842,8 @@ static PyGetSetDef bpy_bmloop_getseters[] = { {(char *)"link_loop_radial_prev", (getter)bpy_bmloop_link_loop_radial_prev_get, (setter)NULL, (char *)bpy_bmloop_link_loop_radial_prev_doc, NULL}, /* readonly checks */ - {(char *)"is_convex", (getter)bpy_bm_is_convex_get, (setter)NULL, (char *)bpy_bm_is_convex_doc, NULL}, - {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, + {(char *)"is_convex", (getter)bpy_bmloop_is_convex_get, (setter)NULL, (char *)bpy_bmloop_is_convex_doc, NULL}, + {(char *)"is_valid", (getter)bpy_bm_is_valid_get, (setter)NULL, (char *)bpy_bm_is_valid_doc, NULL}, {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; @@ -1489,6 +1499,18 @@ static PyObject *bpy_bmedge_calc_face_angle(BPy_BMEdge *self) return PyFloat_FromDouble(BM_edge_calc_face_angle(self->e)); } +PyDoc_STRVAR(bpy_bmedge_calc_face_angle_signed_doc, +".. method:: calc_face_angle_signed()\n" +"\n" +" :return: The angle between 2 connected faces in radians (negative for concave join).\n" +" :rtype: float\n" +); +static PyObject *bpy_bmedge_calc_face_angle_signed(BPy_BMEdge *self) +{ + BPY_BM_CHECK_OBJ(self); + return PyFloat_FromDouble(BM_edge_calc_face_angle_signed(self->e)); +} + PyDoc_STRVAR(bpy_bmedge_calc_tangent_doc, ".. method:: calc_tangent(loop)\n" "\n" @@ -2531,6 +2553,7 @@ static struct PyMethodDef bpy_bmedge_methods[] = { {"calc_length", (PyCFunction)bpy_bmedge_calc_length, METH_NOARGS, bpy_bmedge_calc_length_doc}, {"calc_face_angle", (PyCFunction)bpy_bmedge_calc_face_angle, METH_NOARGS, bpy_bmedge_calc_face_angle_doc}, + {"calc_face_angle_signed", (PyCFunction)bpy_bmedge_calc_face_angle_signed, METH_NOARGS, bpy_bmedge_calc_face_angle_signed_doc}, {"calc_tangent", (PyCFunction)bpy_bmedge_calc_tangent, METH_VARARGS, bpy_bmedge_calc_tangent_doc}, {"normal_update", (PyCFunction)bpy_bmedge_normal_update, METH_NOARGS, bpy_bmedge_normal_update_doc}, @@ -3711,7 +3734,8 @@ char *BPy_BMElem_StringFromHType_ex(const char htype, char ret[32]) if (htype & BM_FACE) ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMFace_Type.tp_name); if (htype & BM_LOOP) ret_ptr += sprintf(ret_ptr, "/%s", BPy_BMLoop_Type.tp_name); ret[0] = '('; - *ret_ptr = ')'; + *ret_ptr++ = ')'; + *ret_ptr = '\0'; return ret; } char *BPy_BMElem_StringFromHType(const char htype) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index d6a82ce43ea..df66ef92316 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3324,6 +3324,40 @@ static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self) return ret; } +PyDoc_STRVAR(pyrna_prop_as_bytes_doc, +".. method:: as_bytes()\n" +"\n" +" Returns this string property as a byte rather then a python string.\n" +"\n" +" :return: The string as bytes.\n" +" :rtype: bytes\n" +); +static PyObject *pyrna_prop_as_bytes(BPy_PropertyRNA *self) +{ + + if (RNA_property_type(self->prop) != PROP_STRING) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s.as_bytes() must be a string", + RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop)); + return NULL; + } + else { + PyObject *ret; + char buf_fixed[256], *buf; + int buf_len; + + buf = RNA_property_string_get_alloc(&self->ptr, self->prop, buf_fixed, sizeof(buf_fixed), &buf_len); + + ret = PyBytes_FromStringAndSize(buf, buf_len); + + if (buf_fixed != buf) { + MEM_freeN(buf); + } + + return ret; + } +} + PyDoc_STRVAR(pyrna_struct_type_recast_doc, ".. method:: type_recast()\n" "\n" @@ -4685,6 +4719,7 @@ static struct PyMethodDef pyrna_struct_methods[] = { static struct PyMethodDef pyrna_prop_methods[] = { {"path_from_id", (PyCFunction)pyrna_prop_path_from_id, METH_NOARGS, pyrna_prop_path_from_id_doc}, + {"as_bytes", (PyCFunction)pyrna_prop_as_bytes, METH_NOARGS, pyrna_prop_as_bytes_doc}, {"__dir__", (PyCFunction)pyrna_prop_dir, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL} }; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 31d1fb93477..0d7e3e66946 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -2802,11 +2802,11 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) if (ob->parent && (ob->parent->type==OB_LATTICE)) need_orco= 1; - BKE_displist_make_surf(re->scene, ob, &displist, &dm, 1, 0); + BKE_displist_make_surf(re->scene, ob, &displist, &dm, 1, 0, 1); if (dm) { if (need_orco) { - orco= BKE_displist_make_orco(re->scene, ob, dm, 1); + orco= BKE_displist_make_orco(re->scene, ob, dm, 1, 1); if (orco) { set_object_orco(re, ob, orco); } @@ -2852,7 +2852,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) if (ob->type==OB_FONT && cu->str==NULL) return; else if (ob->type==OB_CURVE && cu->nurb.first==NULL) return; - BKE_displist_make_curveTypes_forRender(re->scene, ob, &disp, &dm, 0); + BKE_displist_make_curveTypes_forRender(re->scene, ob, &disp, &dm, 0, 1); dl= disp.first; if (dl==NULL) return; @@ -2877,7 +2877,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) if (dm) { if (need_orco) { - orco= BKE_displist_make_orco(re->scene, ob, dm, 1); + orco= BKE_displist_make_orco(re->scene, ob, dm, 1, 1); if (orco) { set_object_orco(re, ob, orco); } diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 2af513cebe6..a395d535907 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -119,7 +119,7 @@ void WM_cursor_set (struct wmWindow *win, int curs); void WM_cursor_modal (struct wmWindow *win, int curs); void WM_cursor_restore (struct wmWindow *win); void WM_cursor_wait (bool val); -void WM_cursor_grab_enable(struct wmWindow *win, int wrap, int hide, int bounds[4]); +void WM_cursor_grab_enable(struct wmWindow *win, bool wrap, bool hide, int bounds[4]); void WM_cursor_grab_disable(struct wmWindow *win, int mouse_ungrab_xy[2]); void WM_cursor_time (struct wmWindow *win, int nr); @@ -154,7 +154,7 @@ struct wmEventHandler *WM_event_add_ui_handler( void WM_event_remove_ui_handler(ListBase *handlers, int (*func)(struct bContext *C, const struct wmEvent *event, void *userdata), void (*remove)(struct bContext *C, void *userdata), - void *userdata, int postpone); + void *userdata, const bool postpone); void WM_event_remove_area_handler(struct ListBase *handlers, void *area); struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op); @@ -386,7 +386,6 @@ void WM_jobs_kill_all_except(struct wmWindowManager *wm, void *owner); void WM_jobs_kill_type(struct wmWindowManager *wm, int job_type); int WM_jobs_has_running(struct wmWindowManager *wm); -int WM_jobs_has_running_except(struct wmWindowManager *wm, int job_type); /* clipboard */ char *WM_clipboard_text_get(int selection); diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index 49ee759bbf2..6f3b90c00a1 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -94,7 +94,7 @@ void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *key const char *WM_key_event_string(short type); int WM_key_event_operator_id(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, int hotkey, struct wmKeyMap **keymap_r); -char *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, const short sloppy, char *str, int len); +char *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, const bool sloppy, char *str, int len); #ifdef __cplusplus } diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index f8081cb8012..bf48d9e6561 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -184,7 +184,7 @@ void WM_cursor_wait(bool val) /** * \param bounds can be NULL */ -void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int bounds[4]) +void WM_cursor_grab_enable(wmWindow *win, bool wrap, bool hide, int bounds[4]) { /* Only grab cursor when not running debug. * It helps not to get a stuck WM when hitting a breakpoint diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index d7b642fc5cf..626eeeadfe4 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -987,7 +987,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, } } - WM_cursor_grab_enable(CTX_wm_window(C), wrap, FALSE, bounds); + WM_cursor_grab_enable(CTX_wm_window(C), wrap, false, bounds); } /* cancel UI handlers, typically tooltips that can hang around @@ -2403,9 +2403,17 @@ wmEventHandler *WM_event_add_ui_handler(const bContext *C, ListBase *handlers, handler->ui_handle = func; handler->ui_remove = remove; handler->ui_userdata = userdata; - handler->ui_area = (C) ? CTX_wm_area(C) : NULL; - handler->ui_region = (C) ? CTX_wm_region(C) : NULL; - handler->ui_menu = (C) ? CTX_wm_menu(C) : NULL; + if (C) { + handler->ui_area = CTX_wm_area(C); + handler->ui_region = CTX_wm_region(C); + handler->ui_menu = CTX_wm_menu(C); + } + else { + handler->ui_area = NULL; + handler->ui_region = NULL; + handler->ui_menu = NULL; + } + BLI_addhead(handlers, handler); @@ -2414,7 +2422,7 @@ wmEventHandler *WM_event_add_ui_handler(const bContext *C, ListBase *handlers, /* set "postpone" for win->modalhandlers, this is in a running for () loop in wm_handlers_do() */ void WM_event_remove_ui_handler(ListBase *handlers, - wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata, int postpone) + wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata, const bool postpone) { wmEventHandler *handler; diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index e5963840261..c637b77738e 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -591,16 +591,3 @@ int WM_jobs_has_running(wmWindowManager *wm) return FALSE; } - -int WM_jobs_has_running_except(wmWindowManager *wm, int job_type) -{ - wmJob *wm_job; - - for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { - if (wm_job->running && wm_job->job_type != job_type) { - return TRUE; - } - } - - return FALSE; -} diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index ff711c5ca4d..aa9af4af154 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -101,7 +101,7 @@ static int wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b) if (strcmp(a->idname, b->idname) != 0) return 0; - if (!RNA_struct_equals(a->ptr, b->ptr)) + if (!RNA_struct_equals(a->ptr, b->ptr, true)) return 0; if ((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE)) @@ -874,9 +874,14 @@ static wmKeyMapItem *wm_keymap_item_find_handlers( } #endif - if (kmi->ptr && IDP_EqualsProperties_ex(properties, kmi->ptr->data, is_strict)) { - if (keymap_r) *keymap_r = keymap; - return kmi; + if (kmi->ptr) { + PointerRNA properties_ptr; + RNA_pointer_create(NULL, kmi->ptr->type, properties, &properties_ptr); + + if (RNA_struct_equals(&properties_ptr, kmi->ptr, is_strict)) { + if (keymap_r) *keymap_r = keymap; + return kmi; + } } } else { @@ -958,7 +963,12 @@ static wmKeyMapItem *wm_keymap_item_find( RNA_pointer_create(NULL, ot->srna, properties_default, &opptr); - if (WM_operator_properties_default(&opptr, true)) { + if (WM_operator_properties_default(&opptr, true) || + (ot->prop && RNA_property_is_set(&opptr, ot->prop))) { + /* for operator that has enum menu, unset it so it always matches */ + if (ot->prop) + RNA_property_unset(&opptr, ot->prop); + found = wm_keymap_item_find_props(C, opname, opcontext, properties_default, 0, hotkey, keymap_r); } @@ -972,7 +982,7 @@ static wmKeyMapItem *wm_keymap_item_find( char *WM_key_event_operator_string( const bContext *C, const char *opname, int opcontext, - IDProperty *properties, const short sloppy, char *str, int len) + IDProperty *properties, const bool sloppy, char *str, int len) { wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, 0, sloppy, NULL); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d0f258dc375..1fac48259c1 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -333,7 +333,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event) } } - WM_cursor_grab_enable(CTX_wm_window(C), wrap, FALSE, bounds); + WM_cursor_grab_enable(CTX_wm_window(C), wrap, false, bounds); } } } @@ -1700,7 +1700,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/credits"); uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", - "http://www.blender.org/development/release-logs/blender-266"); + "http://www.blender.org/development/release-logs/blender-267"); uiItemStringO(col, IFACE_("Manual"), ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.6/Manual"); uiItemStringO(col, IFACE_("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org"); diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 40eb9c673e2..5c4ebfcaac7 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -260,6 +260,7 @@ struct ImBuf *ED_space_image_buffer(struct SpaceImage *sima) {return (struct ImB void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSettings *settings) {} void ED_screen_set_scene(struct bContext *C, struct Scene *scene) {} +struct MovieClip *ED_space_clip_get_clip(struct SpaceClip *sc) {return (struct MovieClip *) NULL;} void ED_space_clip_set_clip(struct bContext *C, struct SpaceClip *sc, struct MovieClip *clip) {} void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask) {} void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask) {} diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 450ae1a16b5..426392305ab 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -182,7 +182,7 @@ static int BL_KetsjiNextFrame(KX_KetsjiEngine *ketsjiengine, bContext *C, wmWind return exitrequested; } -struct BL_KetsjiNextFrameState { +static struct BL_KetsjiNextFrameState { class KX_KetsjiEngine* ketsjiengine; struct bContext *C; struct wmWindow* win; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index e51daf615b8..e15b8ac942f 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -32,6 +32,7 @@ #include "KX_BlenderCanvas.h" #include "DNA_screen_types.h" +#include "DNA_windowmanager_types.h" #include <stdio.h> #include <assert.h> @@ -256,5 +257,5 @@ void KX_BlenderCanvas::MakeScreenShot(const char *filename) area_dummy.totrct.ymin = m_frame_rect.GetBottom(); area_dummy.totrct.ymax = m_frame_rect.GetTop(); - BL_MakeScreenShot(&area_dummy, filename); + BL_MakeScreenShot(m_win->screen, &area_dummy, filename); } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index f808b1b7272..ebf788024c5 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -60,6 +60,7 @@ #include "DNA_image_types.h" #include "DNA_view3d_types.h" #include "DNA_material_types.h" +#include "DNA_space_types.h" #include "DNA_windowmanager_types.h" #include "BKE_global.h" @@ -68,6 +69,7 @@ #include "BKE_image.h" #include "BLI_path_util.h" +#include "BLI_string.h" extern "C" { #include "IMB_imbuf_types.h" @@ -270,8 +272,6 @@ void BL_NormalMouse(wmWindow *win) { WM_cursor_set(win, CURSOR_STD); } -#define MAX_FILE_LENGTH 512 - /* get shot from frontbuffer sort of a copy from screendump.c */ static unsigned int *screenshot(ScrArea *curarea, int *dumpsx, int *dumpsy) { @@ -296,27 +296,36 @@ static unsigned int *screenshot(ScrArea *curarea, int *dumpsx, int *dumpsy) } /* based on screendump.c::screenshot_exec */ -void BL_MakeScreenShot(ScrArea *curarea, const char *filename) +void BL_MakeScreenShot(bScreen *screen, ScrArea *curarea, const char *filename) { - char path[MAX_FILE_LENGTH]; - strcpy(path,filename); - unsigned int *dumprect; int dumpsx, dumpsy; - dumprect= screenshot(curarea, &dumpsx, &dumpsy); + dumprect = screenshot(curarea, &dumpsx, &dumpsy); + if (dumprect) { - ImBuf *ibuf; + /* initialize image file format data */ + Scene *scene = (screen)? screen->scene: NULL; + ImageFormatData im_format; + + if(scene) + im_format = scene->r.im_format; + else + BKE_imformat_defaults(&im_format); + + /* create file path */ + char path[FILE_MAX]; + BLI_strncpy(path, filename, sizeof(path)); BLI_path_abs(path, G.main->name); - /* BKE_add_image_extension() checks for if extension was already set */ - BKE_add_image_extension_from_type(path, R_IMF_IMTYPE_PNG); /* scene->r.im_format.imtype */ - ibuf= IMB_allocImBuf(dumpsx, dumpsy, 24, 0); - ibuf->rect= dumprect; - ibuf->ftype= PNG; + BKE_add_image_extension_from_type(path, im_format.imtype); + + /* create and save imbuf */ + ImBuf *ibuf = IMB_allocImBuf(dumpsx, dumpsy, 24, 0); + ibuf->rect = dumprect; - IMB_saveiff(ibuf, path, IB_rect); + BKE_imbuf_write_as(ibuf, path, &im_format, false); - ibuf->rect= NULL; + ibuf->rect = NULL; IMB_freeImBuf(ibuf); MEM_freeN(dumprect); } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h index 2545cd34acb..0f35494c73a 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h @@ -38,13 +38,14 @@ extern "C" { struct wmWindow; struct ARegion; +struct bScreen; // special swapbuffers, that takes care of which area (viewport) needs to be swapped void BL_SwapBuffers(struct wmWindow *win); void BL_warp_pointer(struct wmWindow *win,int x,int y); -void BL_MakeScreenShot(struct ScrArea *curarea, const char *filename); +void BL_MakeScreenShot(struct bScreen *screen, struct ScrArea *curarea, const char *filename); void BL_HideMouse(struct wmWindow *win); void BL_NormalMouse(struct wmWindow *win); diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index 20c66bd7bc9..abab40cbe67 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -293,7 +293,7 @@ static PyObject *listvalue_buffer_item(PyObject *self, Py_ssize_t index) CValue *cval; if (list==NULL) { - PyErr_SetString(PyExc_SystemError, "val = CList[i], "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "val = CList[i], " BGE_PROXY_ERROR_MSG); return NULL; } @@ -350,7 +350,7 @@ static PyObject *listvalue_mapping_subscript(PyObject *self, PyObject *key) { CListValue *list= static_cast<CListValue *>(BGE_PROXY_REF(self)); if (list==NULL) { - PyErr_SetString(PyExc_SystemError, "value = CList[i], "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "value = CList[i], " BGE_PROXY_ERROR_MSG); return NULL; } @@ -398,7 +398,7 @@ static PyObject *listvalue_buffer_concat(PyObject *self, PyObject *other) Py_ssize_t i, numitems, numitems_orig; if (listval==NULL) { - PyErr_SetString(PyExc_SystemError, "CList+other, "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "CList+other, " BGE_PROXY_ERROR_MSG); return NULL; } @@ -447,7 +447,7 @@ static PyObject *listvalue_buffer_concat(PyObject *self, PyObject *other) CListValue* otherval = static_cast<CListValue *>(BGE_PROXY_REF(other)); if (otherval==NULL) { listval_new->Release(); - PyErr_SetString(PyExc_SystemError, "CList+other, "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "CList+other, " BGE_PROXY_ERROR_MSG); return NULL; } @@ -471,7 +471,7 @@ static int listvalue_buffer_contains(PyObject *self_v, PyObject *value) CListValue *self = static_cast<CListValue *>(BGE_PROXY_REF(self_v)); if (self == NULL) { - PyErr_SetString(PyExc_SystemError, "val in CList, "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "val in CList, " BGE_PROXY_ERROR_MSG); return -1; } diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp index 058454ca352..8a6a41f3f99 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp @@ -41,6 +41,18 @@ #include "RAS_IPolygonMaterial.h" #include "GPC_Canvas.h" +#include "BLI_string.h" + +#include "DNA_scene_types.h" +#include "DNA_space_types.h" + +#include "BKE_image.h" + +extern "C" { +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +} + GPC_Canvas::TBannerId GPC_Canvas::s_bannerId = 0; @@ -425,114 +437,35 @@ GPC_Canvas:: MakeScreenShot( const char* filename ) { - png_structp png_ptr; - png_infop info_ptr; - unsigned char *pixels = 0; - png_bytepp row_pointers = 0; - int i, bytesperpixel = 3, color_type = PNG_COLOR_TYPE_RGB; - FILE *fp = 0; - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - { - std::cout << "Cannot png_create_write_struct." << std::endl; - return; - } - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - std::cout << "Cannot png_create_info_struct." << std::endl; - return; - } - - if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_write_struct(&png_ptr, &info_ptr); - delete [] pixels; - delete [] row_pointers; - // printf("Aborting\n"); - if (fp) { - fflush(fp); - fclose(fp); - } - return; - } - // copy image data + unsigned char *pixels = new unsigned char[GetWidth() * GetHeight() * 4]; - pixels = new unsigned char[GetWidth() * GetHeight() * bytesperpixel * sizeof(unsigned char)]; if (!pixels) { std::cout << "Cannot allocate pixels array" << std::endl; return; } - glReadPixels(0, 0, GetWidth(), GetHeight(), GL_RGB, GL_UNSIGNED_BYTE, pixels); - - fp = fopen(filename, "wb"); - if (!fp) - { - std::cout << "Couldn't open " << filename << " for writing." << std::endl; - longjmp(png_jmpbuf(png_ptr), 1); - } - - png_init_io(png_ptr, fp); + glReadPixels(0, 0, GetWidth(), GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, pixels); -#if 0 - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); - - png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); -#endif + // initialize image file format data + ImageFormatData im_format; + BKE_imformat_defaults(&im_format); - // png image settings - png_set_IHDR(png_ptr, - info_ptr, - GetWidth(), - GetHeight(), - 8, - color_type, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); - - // write the file header information - png_write_info(png_ptr, info_ptr); - - // allocate memory for an array of row-pointers - row_pointers = new png_bytep [(GetHeight() * sizeof(png_bytep))]; - if (!row_pointers) - { - std::cout << "Cannot allocate row-pointers array" << std::endl; - longjmp(png_jmpbuf(png_ptr), 1); - } + // create file path + char path[FILE_MAX]; + BLI_strncpy(path, filename, sizeof(path)); + BKE_add_image_extension_from_type(path, im_format.imtype); - // set the individual row-pointers to point at the correct offsets - for (i = 0; i < GetHeight(); i++) { - row_pointers[GetHeight()-1-i] = (png_bytep) - ((unsigned char *)pixels + (i * GetWidth()) * bytesperpixel * sizeof(unsigned char)); - } + // create and save imbuf + ImBuf *ibuf = IMB_allocImBuf(GetWidth(), GetHeight(), 24, 0); + ibuf->rect = (unsigned int*)pixels; - // write out the entire image data in one call - png_write_image(png_ptr, row_pointers); + BKE_imbuf_write_as(ibuf, path, &im_format, false); - // write the additional chunks to the PNG file (not really needed) - png_write_end(png_ptr, info_ptr); + ibuf->rect = NULL; + IMB_freeImBuf(ibuf); // clean up delete [] (pixels); - delete [] (row_pointers); - png_destroy_write_struct(&png_ptr, &info_ptr); - - if (fp) - { - fflush(fp); - fclose(fp); - } } diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 98da18dcc68..172440cfcb6 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1572,7 +1572,7 @@ static int mathutils_kxgameob_vector_set_index(BaseMathObject *bmo, int subtype, return mathutils_kxgameob_vector_set(bmo, subtype); } -Mathutils_Callback mathutils_kxgameob_vector_cb = { +static Mathutils_Callback mathutils_kxgameob_vector_cb = { mathutils_kxgameob_generic_check, mathutils_kxgameob_vector_get, mathutils_kxgameob_vector_set, @@ -1628,7 +1628,7 @@ static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype) return 0; } -Mathutils_Callback mathutils_kxgameob_matrix_cb = { +static Mathutils_Callback mathutils_kxgameob_matrix_cb = { mathutils_kxgameob_generic_check, mathutils_kxgameob_matrix_get, mathutils_kxgameob_matrix_set, @@ -1800,7 +1800,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) PyObject *pyconvert; if (self == NULL) { - PyErr_SetString(PyExc_SystemError, "val = gameOb[key]: KX_GameObject, "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "val = gameOb[key]: KX_GameObject, " BGE_PROXY_ERROR_MSG); return NULL; } @@ -1834,7 +1834,7 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) PyErr_Clear(); if (self == NULL) { - PyErr_SetString(PyExc_SystemError, "gameOb[key] = value: KX_GameObject, "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "gameOb[key] = value: KX_GameObject, " BGE_PROXY_ERROR_MSG); return -1; } @@ -1919,7 +1919,7 @@ static int Seq_Contains(PyObject *self_v, PyObject *value) KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); if (self == NULL) { - PyErr_SetString(PyExc_SystemError, "val in gameOb: KX_GameObject, "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "val in gameOb: KX_GameObject, " BGE_PROXY_ERROR_MSG); return -1; } diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index d02554e185e..9d6c8d250c7 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -496,7 +496,7 @@ static int mathutils_obactu_vector_set_index(BaseMathObject *bmo, int subtype, i return mathutils_obactu_vector_set(bmo, subtype); } -Mathutils_Callback mathutils_obactu_vector_cb = { +static Mathutils_Callback mathutils_obactu_vector_cb = { mathutils_obactu_generic_check, mathutils_obactu_vector_get, mathutils_obactu_vector_set, diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index 840ffdde165..eaedc752201 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -103,7 +103,7 @@ KX_PolyProxy::~KX_PolyProxy() // stuff for cvalue related things CValue* KX_PolyProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;} CValue* KX_PolyProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;} -STR_String sPolyName="polygone"; +static STR_String sPolyName = "polygone"; const STR_String & KX_PolyProxy::GetText() {return sPolyName;}; double KX_PolyProxy::GetNumber() { return -1;} STR_String& KX_PolyProxy::GetName() { return sPolyName;} diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp index edbb0537559..fb3e6c58027 100644 --- a/source/gameengine/Ketsji/KX_PythonSeq.cpp +++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp @@ -74,7 +74,7 @@ static Py_ssize_t KX_PythonSeq_len( PyObject *self ) PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); if (self_plus==NULL) { - PyErr_SetString(PyExc_SystemError, "len(seq): "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "len(seq): " BGE_PROXY_ERROR_MSG); return -1; } @@ -105,7 +105,7 @@ static PyObject *KX_PythonSeq_getIndex(PyObject *self, Py_ssize_t index) PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); if (self_plus==NULL) { - PyErr_SetString(PyExc_SystemError, "val = seq[i]: "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "val = seq[i]: " BGE_PROXY_ERROR_MSG); return NULL; } @@ -269,7 +269,7 @@ static PyObject *KX_PythonSeq_subscript(PyObject *self, PyObject *key) PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); if (self_plus==NULL) { - PyErr_SetString(PyExc_SystemError, "val = seq[key], KX_PythonSeq: "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "val = seq[key], KX_PythonSeq: " BGE_PROXY_ERROR_MSG); return NULL; } @@ -299,7 +299,7 @@ static int KX_PythonSeq_contains(PyObject *self, PyObject *key) PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); if (self_plus==NULL) { - PyErr_SetString(PyExc_SystemError, "key in seq, KX_PythonSeq: "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "key in seq, KX_PythonSeq: " BGE_PROXY_ERROR_MSG); return -1; } if (!PyUnicode_Check(key)) { @@ -362,7 +362,7 @@ PyMethodDef KX_PythonSeq_methods[] = { static PyObject *KX_PythonSeq_getIter(KX_PythonSeq *self) { if (BGE_PROXY_REF(self->base)==NULL) { - PyErr_SetString(PyExc_SystemError, "for i in seq: "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "for i in seq: " BGE_PROXY_ERROR_MSG); return NULL; } diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 92e064c6e91..adc0aa194af 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -2064,7 +2064,7 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) PyObject *pyconvert; if (self == NULL) { - PyErr_SetString(PyExc_SystemError, "val = scene[key]: KX_Scene, "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "val = scene[key]: KX_Scene, " BGE_PROXY_ERROR_MSG); return NULL; } @@ -2094,7 +2094,7 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) PyErr_Clear(); if (self == NULL) { - PyErr_SetString(PyExc_SystemError, "scene[key] = value: KX_Scene, "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "scene[key] = value: KX_Scene, " BGE_PROXY_ERROR_MSG); return -1; } @@ -2141,7 +2141,7 @@ static int Seq_Contains(PyObject *self_v, PyObject *value) KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v); if (self == NULL) { - PyErr_SetString(PyExc_SystemError, "val in scene: KX_Scene, "BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "val in scene: KX_Scene, " BGE_PROXY_ERROR_MSG); return -1; } diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index e093b7cd722..79ce8538210 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -24,7 +24,6 @@ * \ingroup bgerast */ - #define STRINGIFY(A) #A #include "RAS_OpenGLFilters/RAS_Blur2DFilter.h" diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h index c2595fb0d26..3f1644a5c60 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h @@ -32,7 +32,7 @@ #ifndef __RAS_BLUR2DFILTER_H__ #define __RAS_BLUR2DFILTER_H__ -const char * BlurFragmentShader=STRINGIFY( +static const char *BlurFragmentShader = STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h index 12b815a1519..4e863cb6f8d 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h @@ -32,7 +32,7 @@ #ifndef __RAS_DILATION2DFILTER_H__ #define __RAS_DILATION2DFILTER_H__ -const char * DilationFragmentShader=STRINGIFY( +static const char *DilationFragmentShader = STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h index eaefd5c13fa..56e2c22fe2e 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h @@ -32,9 +32,9 @@ #ifndef __RAS_EROSION2DFILTER_H__ #define __RAS_EROSION2DFILTER_H__ -const char * ErosionFragmentShader = STRINGIFY( - uniform sampler2D bgl_RenderedTexture; - uniform vec2 bgl_TextureCoordinateOffset[9]; +static const char *ErosionFragmentShader = STRINGIFY( +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h index f3c3aece7d5..932d5b16fed 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h @@ -32,7 +32,7 @@ #ifndef __RAS_GRAYSCALE2DFILTER_H__ #define __RAS_GRAYSCALE2DFILTER_H__ -const char * GrayScaleFragmentShader=STRINGIFY( +static const char *GrayScaleFragmentShader = STRINGIFY( uniform sampler2D bgl_RenderedTexture; void main(void) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h index c04d9543e89..dce303916ea 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h @@ -32,7 +32,7 @@ #ifndef __RAS_INVERT2DFILTER_H__ #define __RAS_INVERT2DFILTER_H__ -const char * InvertFragmentShader=STRINGIFY( +static const char *InvertFragmentShader = STRINGIFY( uniform sampler2D bgl_RenderedTexture; void main(void) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h index 47f7d80d9d7..9ec5092817d 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h @@ -32,7 +32,7 @@ #ifndef __RAS_LAPLACIAN2DFILTER_H__ #define __RAS_LAPLACIAN2DFILTER_H__ -const char * LaplacionFragmentShader=STRINGIFY( +static const char *LaplacionFragmentShader = STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h index 8b2fdc71cfb..4ae6009fdeb 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h @@ -32,7 +32,7 @@ #ifndef __RAS_PREWITT2DFILTER_H__ #define __RAS_PREWITT2DFILTER_H__ -const char * PrewittFragmentShader=STRINGIFY( +static const char *PrewittFragmentShader = STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h index b38d14a3746..16b4e71dfdb 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h @@ -32,7 +32,7 @@ #ifndef __RAS_SEPIA2DFILTER_H__ #define __RAS_SEPIA2DFILTER_H__ -const char * SepiaFragmentShader=STRINGIFY( +static const char *SepiaFragmentShader = STRINGIFY( uniform sampler2D bgl_RenderedTexture; void main(void) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h index 2e0edae61c4..7512393815b 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h @@ -32,7 +32,7 @@ #ifndef __RAS_SHARPEN2DFILTER_H__ #define __RAS_SHARPEN2DFILTER_H__ -const char * SharpenFragmentShader=STRINGIFY( +static const char *SharpenFragmentShader = STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; @@ -53,4 +53,3 @@ void main(void) } ); #endif - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h index ba30e497923..088ac10a56a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h @@ -32,7 +32,7 @@ #ifndef __RAS_SOBEL2DFILTER_H__ #define __RAS_SOBEL2DFILTER_H__ -const char * SobelFragmentShader=STRINGIFY( +static const char *SobelFragmentShader = STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp index 3de77951fa7..c7779c209ba 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.cpp @@ -35,7 +35,7 @@ VBO::VBO(RAS_DisplayArray *data, unsigned int indices) this->data = data; this->size = data->m_vertex.size(); this->indices = indices; - this->stride = 32*sizeof(GLfloat); // ATI cards really like 32byte aligned VBOs, so we add a little padding + this->stride = sizeof(RAS_TexVert); // Determine drawmode if (data->m_type == data->QUAD) @@ -54,11 +54,11 @@ VBO::VBO(RAS_DisplayArray *data, unsigned int indices) UpdateData(); // Establish offsets - this->vertex_offset = 0; - this->normal_offset = (void*)(3*sizeof(GLfloat)); - this->tangent_offset = (void*)(6*sizeof(GLfloat)); - this->color_offset = (void*)(10*sizeof(GLfloat)); - this->uv_offset = (void*)(11*sizeof(GLfloat)); + this->vertex_offset = (void*)(((RAS_TexVert*)0)->getXYZ()); + this->normal_offset = (void*)(((RAS_TexVert*)0)->getNormal()); + this->tangent_offset = (void*)(((RAS_TexVert*)0)->getTangent()); + this->color_offset = (void*)(((RAS_TexVert*)0)->getRGBA());; + this->uv_offset = (void*)(((RAS_TexVert*)0)->getUV(0)); } VBO::~VBO() @@ -69,36 +69,15 @@ VBO::~VBO() void VBO::UpdateData() { - unsigned int i, j, k; - glBindBufferARB(GL_ARRAY_BUFFER_ARB, this->vbo_id); - glBufferData(GL_ARRAY_BUFFER, this->stride*this->size, NULL, GL_STATIC_DRAW); - - // Map the buffer - GLfloat *vbo_map = (GLfloat*)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); - - // Gather data - for (i = 0, j = 0; i < data->m_vertex.size(); i++, j += this->stride/sizeof(GLfloat)) - { - memcpy(&vbo_map[j], data->m_vertex[i].getXYZ(), sizeof(float)*3); - memcpy(&vbo_map[j+3], data->m_vertex[i].getNormal(), sizeof(float)*3); - memcpy(&vbo_map[j+6], data->m_vertex[i].getTangent(), sizeof(float)*4); - memcpy(&vbo_map[j+10], data->m_vertex[i].getRGBA(), sizeof(char)*4); - - for (k = 0; k < RAS_TexVert::MAX_UNIT; k++) - memcpy(&vbo_map[j+11+(k*2)], data->m_vertex[i].getUV(k), sizeof(float)*2); - } - - glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); + glBufferData(GL_ARRAY_BUFFER, this->stride*this->size, &this->data->m_vertex[0], GL_STATIC_DRAW); } void VBO::UpdateIndices() { - int space = data->m_index.size() * sizeof(GLushort); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, this->ibo); - - // Upload Data to VBO - glBufferData(GL_ELEMENT_ARRAY_BUFFER, space, &data->m_index[0], GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, data->m_index.size() * sizeof(GLushort), + &data->m_index[0], GL_STATIC_DRAW); } void VBO::Draw(int texco_num, RAS_IRasterizer::TexCoGen* texco, int attrib_num, RAS_IRasterizer::TexCoGen* attrib, int *attrib_layer, bool multi) diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h index a91d2c7f848..8d08549d97e 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.h +++ b/source/gameengine/Rasterizer/RAS_TexVert.h @@ -56,9 +56,10 @@ class RAS_TexVert short m_softBodyIndex; //2 unsigned int m_unit; // 4 unsigned int m_origindex; // 4 + char m_padding[8]; // 8 //--------- - // 120 - // 32 bytes total size, fits nice = 120 = not fit nice. + // 128 + // 32 bytes alignment improves performance on ATI cards. public: enum { diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 016020048e9..d251f4f7bcb 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -288,9 +288,9 @@ inline ImageRender * getImageRender (PyImage *self) // python methods // Blender Scene type -BlendType<KX_Scene> sceneType ("KX_Scene"); +static BlendType<KX_Scene> sceneType ("KX_Scene"); // Blender Camera type -BlendType<KX_Camera> cameraType ("KX_Camera"); +static BlendType<KX_Camera> cameraType ("KX_Camera"); // object initialization @@ -398,8 +398,7 @@ static PyGetSetDef imageRenderGetSets[] = // define python type -PyTypeObject ImageRenderType = -{ +PyTypeObject ImageRenderType = { PyVarObject_HEAD_INIT(NULL, 0) "VideoTexture.ImageRender", /*tp_name*/ sizeof(PyImage), /*tp_basicsize*/ @@ -733,8 +732,7 @@ ImageRender::ImageRender (KX_Scene *scene, KX_GameObject *observer, KX_GameObjec // define python type -PyTypeObject ImageMirrorType = -{ +PyTypeObject ImageMirrorType = { PyVarObject_HEAD_INIT(NULL, 0) "VideoTexture.ImageMirror", /*tp_name*/ sizeof(PyImage), /*tp_basicsize*/ diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index 19d0289be20..18095ea631d 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -358,8 +358,7 @@ static PyGetSetDef imageViewportGetSets[] = // define python type -PyTypeObject ImageViewportType = -{ +PyTypeObject ImageViewportType = { PyVarObject_HEAD_INIT(NULL, 0) "VideoTexture.ImageViewport", /*tp_name*/ sizeof(PyImage), /*tp_basicsize*/ diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index ebad7a92437..aebc2aeef01 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -63,8 +63,8 @@ // Blender GameObject type -BlendType<KX_GameObject> gameObjectType ("KX_GameObject"); -BlendType<KX_LightObject> lightObjectType ("KX_LightObject"); +static BlendType<KX_GameObject> gameObjectType ("KX_GameObject"); +static BlendType<KX_LightObject> lightObjectType ("KX_LightObject"); // load texture diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h index 157eea56c09..c85b1228864 100644 --- a/source/gameengine/VideoTexture/Texture.h +++ b/source/gameengine/VideoTexture/Texture.h @@ -94,7 +94,4 @@ short getMaterialID(PyObject *obj, const char *name); // Exceptions extern ExceptionID MaterialNotAvail; -// object type -extern BlendType<KX_GameObject> gameObjectType; - #endif diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h index 8d64980c9c2..51f025909fd 100644 --- a/source/gameengine/VideoTexture/VideoBase.h +++ b/source/gameengine/VideoTexture/VideoBase.h @@ -199,6 +199,9 @@ int Video_setRepeat(PyImage *self, PyObject *value, void *closure); PyObject *Video_getFrameRate(PyImage *self, void *closure); int Video_setFrameRate(PyImage *self, PyObject *value, void *closure); +/* py api */ +extern PyTypeObject ImageRenderType; +extern PyTypeObject ImageMirrorType; +extern PyTypeObject ImageViewportType; -#endif - +#endif /* __VIDEOBASE_H__ */ diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index e23bd1a3231..ab6dca0958f 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -134,11 +134,6 @@ extern PyTypeObject FilterRGBA32Type; extern PyTypeObject FilterBGR24Type; extern PyTypeObject ImageBuffType; extern PyTypeObject ImageMixType; -extern PyTypeObject ImageRenderType; -extern PyTypeObject ImageMirrorType; -extern PyTypeObject ImageViewportType; -extern PyTypeObject ImageViewportType; - static void registerAllTypes(void) { |