forked from bartvdbraak/blender
code cleanup: use booleans and const's for operator vars.
This commit is contained in:
parent
e537fae726
commit
dd0e2da784
@ -464,7 +464,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tri
|
||||
|
||||
/* displacement method */
|
||||
if(cmesh.data) {
|
||||
int method = RNA_enum_get(&cmesh, "displacement_method");
|
||||
const int method = RNA_enum_get(&cmesh, "displacement_method");
|
||||
|
||||
if(method == 0 || !experimental)
|
||||
mesh->displacement_method = Mesh::DISPLACE_BUMP;
|
||||
|
@ -120,8 +120,8 @@ void RenderLayersBaseProg::executePixel(float output[4], float x, float y, Pixel
|
||||
/* see comment in executeRegion describing coordinate mapping,
|
||||
* here it simply goes other way around
|
||||
*/
|
||||
int full_width = rd->xsch * rd->size / 100;
|
||||
int full_height =rd->ysch * rd->size / 100;
|
||||
int full_width = rd->xsch * rd->size / 100;
|
||||
int full_height = rd->ysch * rd->size / 100;
|
||||
|
||||
dx = rd->border.xmin * full_width - (full_width - this->getWidth()) / 2.0f;
|
||||
dy = rd->border.ymin * full_height - (full_height - this->getHeight()) / 2.0f;
|
||||
|
@ -533,7 +533,7 @@ static bool edbm_rip_call_edgesplit(BMEditMesh *em, wmOperator *op)
|
||||
*/
|
||||
static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
const int do_fill = RNA_boolean_get(op->ptr, "use_fill");
|
||||
const bool do_fill = RNA_boolean_get(op->ptr, "use_fill");
|
||||
UnorderedLoopPair *fill_uloop_pairs = NULL;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
@ -855,7 +855,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve
|
||||
*/
|
||||
static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
const int do_fill = RNA_boolean_get(op->ptr, "use_fill");
|
||||
const bool do_fill = RNA_boolean_get(op->ptr, "use_fill");
|
||||
UnorderedLoopPair *fill_uloop_pairs = NULL;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
@ -799,7 +799,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
|
||||
BMOperator bmop;
|
||||
/* get the type from RNA */
|
||||
const int type = RNA_enum_get(op->ptr, "type");
|
||||
float thresh = RNA_float_get(op->ptr, "threshold");
|
||||
const float thresh = RNA_float_get(op->ptr, "threshold");
|
||||
const int compare = RNA_enum_get(op->ptr, "compare");
|
||||
|
||||
/* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */
|
||||
@ -919,10 +919,10 @@ void MESH_OT_select_similar(wmOperatorType *ot)
|
||||
|
||||
static int edbm_select_mode_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
const int type = RNA_enum_get(op->ptr, "type");
|
||||
const int action = RNA_enum_get(op->ptr, "action");
|
||||
const int use_extend = RNA_boolean_get(op->ptr, "use_extend");
|
||||
const int use_expand = RNA_boolean_get(op->ptr, "use_expand");
|
||||
const int type = RNA_enum_get(op->ptr, "type");
|
||||
const int action = RNA_enum_get(op->ptr, "action");
|
||||
const bool use_extend = RNA_boolean_get(op->ptr, "use_extend");
|
||||
const bool use_expand = RNA_boolean_get(op->ptr, "use_expand");
|
||||
|
||||
if (EDBM_selectmode_toggle(C, type, action, use_extend, use_expand)) {
|
||||
return OPERATOR_FINISHED;
|
||||
@ -1017,7 +1017,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op)
|
||||
BMEdge *eed;
|
||||
BMEdge **edarray;
|
||||
int edindex;
|
||||
int looptype = RNA_boolean_get(op->ptr, "ring");
|
||||
const bool is_ring = RNA_boolean_get(op->ptr, "ring");
|
||||
|
||||
BMIter iter;
|
||||
int totedgesel = 0;
|
||||
@ -1038,7 +1038,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
if (looptype) {
|
||||
if (is_ring) {
|
||||
for (edindex = 0; edindex < totedgesel; edindex += 1) {
|
||||
eed = edarray[edindex];
|
||||
walker_select(em, BMW_EDGERING, eed, true);
|
||||
@ -2712,7 +2712,7 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
BMEditMesh *em = BMEdit_FromObject(obedit);
|
||||
int nth = RNA_int_get(op->ptr, "nth");
|
||||
const int nth = RNA_int_get(op->ptr, "nth");
|
||||
int offset = RNA_int_get(op->ptr, "offset");
|
||||
|
||||
/* so input of offset zero ends up being (nth - 1) */
|
||||
@ -2827,7 +2827,7 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op)
|
||||
BMFace *f, **stack = NULL;
|
||||
BLI_array_declare(stack);
|
||||
BMLoop *l, *l2;
|
||||
float sharp = RNA_float_get(op->ptr, "sharpness");
|
||||
const float sharp = RNA_float_get(op->ptr, "sharpness");
|
||||
int i;
|
||||
|
||||
BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
|
||||
@ -2965,7 +2965,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op)
|
||||
BMEdge *eed;
|
||||
BMFace *efa;
|
||||
BMIter iter;
|
||||
float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
|
||||
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
|
||||
|
||||
BLI_srand(BLI_rand()); /* random seed */
|
||||
|
||||
@ -3332,15 +3332,15 @@ static int edbm_loop_to_region_exec(bContext *C, wmOperator *op)
|
||||
BMEditMesh *em = BMEdit_FromObject(obedit);
|
||||
BMIter iter;
|
||||
BMFace *f;
|
||||
int selbigger = RNA_boolean_get(op->ptr, "select_bigger");
|
||||
const bool select_bigger = RNA_boolean_get(op->ptr, "select_bigger");
|
||||
int a, b;
|
||||
|
||||
/* find the set of regions with smallest number of total faces */
|
||||
a = loop_find_regions(em, selbigger);
|
||||
b = loop_find_regions(em, !selbigger);
|
||||
a = loop_find_regions(em, select_bigger);
|
||||
b = loop_find_regions(em, !select_bigger);
|
||||
|
||||
if ((a <= b) ^ selbigger) {
|
||||
loop_find_regions(em, selbigger);
|
||||
if ((a <= b) ^ select_bigger) {
|
||||
loop_find_regions(em, select_bigger);
|
||||
}
|
||||
|
||||
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
|
||||
|
@ -1737,7 +1737,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
|
||||
((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0))
|
||||
{
|
||||
if (bone->layer & arm->layer) {
|
||||
int use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM);
|
||||
const bool use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM);
|
||||
glPushMatrix();
|
||||
|
||||
if (use_custom && pchan->custom_tx) {
|
||||
|
@ -372,7 +372,7 @@ typedef struct ViewOpsData {
|
||||
|
||||
/* use for orbit selection and auto-dist */
|
||||
float ofs[3], dyn_ofs[3];
|
||||
short use_dyn_ofs;
|
||||
bool use_dyn_ofs;
|
||||
|
||||
int origx, origy, oldx, oldy;
|
||||
int origkey; /* the key that triggered the operator */
|
||||
@ -432,7 +432,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even
|
||||
vod->origx = vod->oldx = event->x;
|
||||
vod->origy = vod->oldy = event->y;
|
||||
vod->origkey = event->type; /* the key that triggered the operator. */
|
||||
vod->use_dyn_ofs = (U.uiflag & USER_ORBIT_SELECTION) ? 1 : 0;
|
||||
vod->use_dyn_ofs = (U.uiflag & USER_ORBIT_SELECTION) != 0;
|
||||
copy_v3_v3(vod->ofs, rv3d->ofs);
|
||||
|
||||
if (vod->use_dyn_ofs) {
|
||||
@ -454,10 +454,11 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even
|
||||
negate_v3_v3(vod->dyn_ofs, lastofs);
|
||||
}
|
||||
else if (U.uiflag & USER_ZBUF_ORBIT) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
view3d_operator_needs_opengl(C); /* needed for zbuf drawing */
|
||||
|
||||
if ((vod->use_dyn_ofs = ED_view3d_autodist(CTX_data_scene(C), vod->ar, vod->v3d, event->mval, vod->dyn_ofs, true))) {
|
||||
if ((vod->use_dyn_ofs = ED_view3d_autodist(scene, vod->ar, vod->v3d, event->mval, vod->dyn_ofs, true))) {
|
||||
if (rv3d->is_persp) {
|
||||
float my_origin[3]; /* original G.vd->ofs */
|
||||
float my_pivot[3]; /* view */
|
||||
@ -1703,7 +1704,7 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my)
|
||||
static void viewzoom_apply(ViewOpsData *vod, const int x, const int y, const short viewzoom, const short zoom_invert)
|
||||
{
|
||||
float zfac = 1.0;
|
||||
short use_cam_zoom;
|
||||
bool use_cam_zoom;
|
||||
|
||||
use_cam_zoom = (vod->rv3d->persp == RV3D_CAMOB) && !(vod->rv3d->is_persp && ED_view3d_camera_lock_check(vod->v3d, vod->rv3d));
|
||||
|
||||
@ -1845,9 +1846,9 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
|
||||
RegionView3D *rv3d;
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
short use_cam_zoom;
|
||||
bool use_cam_zoom;
|
||||
|
||||
int delta = RNA_int_get(op->ptr, "delta");
|
||||
const int delta = RNA_int_get(op->ptr, "delta");
|
||||
int mx, my;
|
||||
|
||||
if (op->customdata) {
|
||||
@ -2108,7 +2109,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
|
||||
ARegion *ar;
|
||||
float mousevec[3];
|
||||
|
||||
int delta = RNA_int_get(op->ptr, "delta");
|
||||
const int delta = RNA_int_get(op->ptr, "delta");
|
||||
|
||||
if (op->customdata) {
|
||||
ViewOpsData *vod = op->customdata;
|
||||
@ -2350,11 +2351,11 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Base *base;
|
||||
float *curs;
|
||||
const short use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions");
|
||||
const short skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) ||
|
||||
/* any one of the regions may be locked */
|
||||
(use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA));
|
||||
int center = RNA_boolean_get(op->ptr, "center");
|
||||
const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions");
|
||||
const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) ||
|
||||
/* any one of the regions may be locked */
|
||||
(use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA));
|
||||
const bool center = RNA_boolean_get(op->ptr, "center");
|
||||
|
||||
float min[3], max[3];
|
||||
bool change = false;
|
||||
@ -2435,10 +2436,10 @@ static int viewselected_exec(bContext *C, wmOperator *op)
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
float min[3], max[3];
|
||||
bool ok = false, ok_dist = true;
|
||||
const short use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions");
|
||||
const short skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) ||
|
||||
/* any one of the regions may be locked */
|
||||
(use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA));
|
||||
const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions");
|
||||
const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) ||
|
||||
/* any one of the regions may be locked */
|
||||
(use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA));
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
@ -2722,7 +2723,7 @@ static int render_border_exec(bContext *C, wmOperator *op)
|
||||
rcti rect;
|
||||
rctf vb, border;
|
||||
|
||||
int camera_only = RNA_boolean_get(op->ptr, "camera_only");
|
||||
const bool camera_only = RNA_boolean_get(op->ptr, "camera_only");
|
||||
|
||||
if (camera_only && rv3d->persp != RV3D_CAMOB)
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
@ -3581,7 +3582,7 @@ void VIEW3D_OT_background_image_add(wmOperatorType *ot)
|
||||
static int background_image_remove_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
int index = RNA_int_get(op->ptr, "index");
|
||||
const int index = RNA_int_get(op->ptr, "index");
|
||||
BGpic *bgpic_rem = BLI_findlink(&v3d->bgpicbase, index);
|
||||
|
||||
if (bgpic_rem) {
|
||||
|
@ -147,7 +147,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op)
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
int nr = RNA_int_get(op->ptr, "nr");
|
||||
int toggle = RNA_boolean_get(op->ptr, "toggle");
|
||||
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
|
||||
|
||||
if (nr < 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
@ -218,7 +218,7 @@ static int view3d_layers_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
||||
RNA_boolean_set(op->ptr, "extend", false);
|
||||
|
||||
if (event->alt) {
|
||||
int nr = RNA_int_get(op->ptr, "nr") + 10;
|
||||
const int nr = RNA_int_get(op->ptr, "nr") + 10;
|
||||
RNA_int_set(op->ptr, "nr", nr);
|
||||
}
|
||||
view3d_layers_exec(C, op);
|
||||
|
@ -1031,8 +1031,8 @@ static EnumPropertyItem *object_select_menu_enum_itemf(bContext *C, PointerRNA *
|
||||
|
||||
static int object_select_menu_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
int name_index = RNA_enum_get(op->ptr, "name");
|
||||
short toggle = RNA_boolean_get(op->ptr, "toggle");
|
||||
const int name_index = RNA_enum_get(op->ptr, "name");
|
||||
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
|
||||
bool change = false;
|
||||
const char *name = object_mouse_select_menu_data[name_index].idname;
|
||||
|
||||
@ -2762,8 +2762,8 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
int radius = RNA_int_get(op->ptr, "radius");
|
||||
int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
|
||||
const int radius = RNA_int_get(op->ptr, "radius");
|
||||
const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
|
||||
int select;
|
||||
const int mval[2] = {RNA_int_get(op->ptr, "x"),
|
||||
RNA_int_get(op->ptr, "y")};
|
||||
|
@ -581,10 +581,9 @@ static bool ConvertMaterial(
|
||||
{
|
||||
material->Initialize();
|
||||
int texalpha = 0;
|
||||
bool validmat = (mat!=0);
|
||||
bool validface = (tface!=0);
|
||||
|
||||
const bool use_vcol = GetMaterialUseVColor(mat, glslmat);
|
||||
const bool validmat = (mat != NULL);
|
||||
const bool validface = (tface != NULL);
|
||||
const bool use_vcol = GetMaterialUseVColor(mat, glslmat);
|
||||
|
||||
material->IdMode = DEFAULT_BLENDER;
|
||||
material->glslmat = (validmat) ? glslmat: false;
|
||||
@ -1025,9 +1024,9 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace
|
||||
}
|
||||
|
||||
// only zsort alpha + add
|
||||
bool alpha = ELEM3(alpha_blend, GEMAT_ALPHA, GEMAT_ADD, GEMAT_ALPHA_SORT);
|
||||
bool zsort = (alpha_blend == GEMAT_ALPHA_SORT);
|
||||
bool light = (ma)?(ma->mode & MA_SHLESS)==0:default_light_mode;
|
||||
const bool alpha = ELEM3(alpha_blend, GEMAT_ALPHA, GEMAT_ADD, GEMAT_ALPHA_SORT);
|
||||
const bool zsort = (alpha_blend == GEMAT_ALPHA_SORT);
|
||||
const bool light = (ma)?(ma->mode & MA_SHLESS)==0:default_light_mode;
|
||||
|
||||
// don't need zort anymore, deal as if it it's alpha blend
|
||||
if (alpha_blend == GEMAT_ALPHA_SORT) alpha_blend = GEMAT_ALPHA;
|
||||
|
Loading…
Reference in New Issue
Block a user