/** * Special hack for MESH_OT_loopcut_slide so we get back to the selection mode */ static void transformops_loopsel_hack(bContext *C, wmOperator *op) { if (op->type->idname == OP_EDGE_SLIDE) { if (op->opm && op->opm->opm && op->opm->opm->prev) { wmOperator *op_prev = op->opm->opm->prev; Scene *scene = CTX_data_scene(C); int mesh_select_mode[3]; PropertyRNA *prop = RNA_struct_find_property(op_prev->ptr, "mesh_select_mode_init"); if (prop && RNA_property_is_set(op_prev->ptr, prop)) { ToolSettings *ts = scene->toolsettings; short selectmode_orig; RNA_property_boolean_get_array(op_prev->ptr, prop, mesh_select_mode); selectmode_orig = ((mesh_select_mode[0] ? SCE_SELECT_VERTEX : 0) | (mesh_select_mode[1] ? SCE_SELECT_EDGE : 0) | (mesh_select_mode[2] ? SCE_SELECT_FACE : 0)); /* still switch if we were originally in face select mode */ if ((ts->selectmode != selectmode_orig) && (selectmode_orig != SCE_SELECT_FACE)) { BMEditMesh *em = BKE_editmesh_from_object(scene->obedit); em->selectmode = ts->selectmode = selectmode_orig; EDBM_selectmode_set(em); } } } } }
/* TODO, multi-dimensional arrays */ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) { int len = RNA_property_array_length(ptr, prop); int type; int i; if (len == 0) /* possible with dynamic arrays */ return 0; if (RNA_property_array_dimension(ptr, prop, NULL) > 1) { PyErr_SetString(PyExc_TypeError, "PropertyRNA - multi dimensional arrays not supported yet"); return -1; } type = RNA_property_type(prop); switch (type) { case PROP_FLOAT: { float value_f = PyFloat_AsDouble(value); if (value_f == -1 && PyErr_Occurred()) { PyErr_Clear(); return 0; } else { float tmp[32]; float *tmp_arr; if (len * sizeof(float) > sizeof(tmp)) { tmp_arr = PyMem_MALLOC(len * sizeof(float)); } else { tmp_arr = tmp; } RNA_property_float_get_array(ptr, prop, tmp_arr); for (i = 0; i < len; i++) { if (tmp_arr[i] == value_f) { break; } } if (tmp_arr != tmp) PyMem_FREE(tmp_arr); return i < len ? 1 : 0; } break; } case PROP_BOOLEAN: case PROP_INT: { int value_i = PyLong_AsSsize_t(value); if (value_i == -1 && PyErr_Occurred()) { PyErr_Clear(); return 0; } else { int tmp[32]; int *tmp_arr; if (len * sizeof(int) > sizeof(tmp)) { tmp_arr = PyMem_MALLOC(len * sizeof(int)); } else { tmp_arr = tmp; } if (type == PROP_BOOLEAN) RNA_property_boolean_get_array(ptr, prop, tmp_arr); else RNA_property_int_get_array(ptr, prop, tmp_arr); for (i = 0; i < len; i++) { if (tmp_arr[i] == value_i) { break; } } if (tmp_arr != tmp) PyMem_FREE(tmp_arr); return i < len ? 1 : 0; } break; } } /* should never reach this */ PyErr_SetString(PyExc_TypeError, "PropertyRNA - type not in float/bool/int"); return -1; }