Changeset View
Changeset View
Standalone View
Standalone View
source/blender/bmesh/intern/bmesh_operators.c
| Context not available. | |||||
| /* operator slot type information - size of one element of the type given. */ | /* operator slot type information - size of one element of the type given. */ | ||||
| const int BMO_OPSLOT_TYPEINFO[BMO_OP_SLOT_TOTAL_TYPES] = { | const int BMO_OPSLOT_TYPEINFO[BMO_OP_SLOT_TOTAL_TYPES] = { | ||||
| 0, /* 0: BMO_OP_SLOT_SENTINEL */ | 0, /* 0: BMO_OP_SLOT_SENTINEL */ | ||||
| sizeof(int), /* 1: BMO_OP_SLOT_BOOL */ | sizeof(int), /* 1: BMO_OP_SLOT_BOOL */ | ||||
| sizeof(int), /* 2: BMO_OP_SLOT_INT */ | sizeof(int), /* 2: BMO_OP_SLOT_INT */ | ||||
| sizeof(float), /* 3: BMO_OP_SLOT_FLT */ | sizeof(float), /* 3: BMO_OP_SLOT_FLT */ | ||||
| sizeof(void *), /* 4: BMO_OP_SLOT_PNT */ | sizeof(void *), /* 4: BMO_OP_SLOT_PNT */ | ||||
| sizeof(void *), /* 5: BMO_OP_SLOT_PNT */ | sizeof(void *), /* 5: BMO_OP_SLOT_PNT */ | ||||
| 0, /* 6: unused */ | 0, /* 6: unused */ | ||||
| 0, /* 7: unused */ | 0, /* 7: unused */ | ||||
| Context not available. | |||||
| op->type = opcode; | op->type = opcode; | ||||
| op->type_flag = bmo_opdefines[opcode]->type_flag; | op->type_flag = bmo_opdefines[opcode]->type_flag; | ||||
| op->flag = flag; | op->flag = flag; | ||||
| /* initialize the operator slot types */ | /* initialize the operator slot types */ | ||||
| bmo_op_slots_init(bmo_opdefines[opcode]->slot_types_in, op->slots_in); | bmo_op_slots_init(bmo_opdefines[opcode]->slot_types_in, op->slots_in); | ||||
| bmo_op_slots_init(bmo_opdefines[opcode]->slot_types_out, op->slots_out); | bmo_op_slots_init(bmo_opdefines[opcode]->slot_types_out, op->slots_out); | ||||
| Context not available. | |||||
| if (bm->stackdepth == 2) | if (bm->stackdepth == 2) | ||||
| bmesh_edit_begin(bm, op->type_flag); | bmesh_edit_begin(bm, op->type_flag); | ||||
| op->exec(bm, op); | op->exec(bm, op); | ||||
| if (bm->stackdepth == 2) | if (bm->stackdepth == 2) | ||||
| bmesh_edit_end(bm, op->type_flag); | bmesh_edit_end(bm, op->type_flag); | ||||
| BMO_pop(bm); | BMO_pop(bm); | ||||
| } | } | ||||
| Context not available. | |||||
| slot->len = 4; | slot->len = 4; | ||||
| slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float) * 4 * 4); | slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float) * 4 * 4); | ||||
| if (size == 4) { | if (size == 4) { | ||||
| copy_m4_m4(slot->data.p, (float (*)[4])mat); | copy_m4_m4(slot->data.p, (float (*)[4])mat); | ||||
| } | } | ||||
| Context not available. | |||||
| { | { | ||||
| BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); | BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); | ||||
| BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); | BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); | ||||
| /* check if its actually a buffer */ | /* check if its actually a buffer */ | ||||
| if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) | if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) | ||||
| return 0; | return 0; | ||||
| Context not available. | |||||
| BMOpSlot *slot = &op->slots[slot_code]; | BMOpSlot *slot = &op->slots[slot_code]; | ||||
| void *tmp; | void *tmp; | ||||
| ssize_t allocsize; | ssize_t allocsize; | ||||
| BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); | BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); | ||||
| /* check if its actually a buffer */ | /* check if its actually a buffer */ | ||||
| Context not available. | |||||
| /* check if its actually a buffer */ | /* check if its actually a buffer */ | ||||
| if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) | if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) | ||||
| return NULL; | return NULL; | ||||
| slot->len = len; | slot->len = len; | ||||
| if (len) { | if (len) { | ||||
| slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slot_type] * len); | slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slot_type] * len); | ||||
| Context not available. | |||||
| void *BMO_slot_buffer_get_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) | void *BMO_slot_buffer_get_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name) | ||||
| { | { | ||||
| BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); | BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); | ||||
| if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) | if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) | ||||
| return NULL; | return NULL; | ||||
| Context not available. | |||||
| void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg) | void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg) | ||||
| { | { | ||||
| BMOpError *err = MEM_callocN(sizeof(BMOpError), "bmop_error"); | BMOpError *err = MEM_callocN(sizeof(BMOpError), "bmop_error"); | ||||
| err->errorcode = errcode; | err->errorcode = errcode; | ||||
| if (!msg) { | if (!msg) { | ||||
| msg = bmo_error_messages[errcode]; | msg = bmo_error_messages[errcode]; | ||||
| } | } | ||||
| err->msg = msg; | err->msg = msg; | ||||
| err->op = owner; | err->op = owner; | ||||
| BLI_addhead(&bm->errorstack, err); | BLI_addhead(&bm->errorstack, err); | ||||
| } | } | ||||
| Context not available. | |||||
| if (msg) *msg = err->msg; | if (msg) *msg = err->msg; | ||||
| if (op) *op = err->op; | if (op) *op = err->op; | ||||
| return err->errorcode; | return err->errorcode; | ||||
| } | } | ||||
| int BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op) | int BMO_error_pop(BMesh *bm, const char **msg, BMOperator **op) | ||||
| { | { | ||||
| int errorcode = BMO_error_get(bm, msg, op); | int errorcode = BMO_error_get(bm, msg, op); | ||||
| if (errorcode) { | if (errorcode) { | ||||
| BMOpError *err = bm->errorstack.first; | BMOpError *err = bm->errorstack.first; | ||||
| BLI_remlink(&bm->errorstack, bm->errorstack.first); | BLI_remlink(&bm->errorstack, bm->errorstack.first); | ||||
| MEM_freeN(err); | MEM_freeN(err); | ||||
| } | } | ||||
| Context not available. | |||||
| /* we muck around in here, so dup it */ | /* we muck around in here, so dup it */ | ||||
| fmt = ofmt = BLI_strdup(_fmt); | fmt = ofmt = BLI_strdup(_fmt); | ||||
| /* find operator name */ | /* find operator name */ | ||||
| i = strcspn(fmt, " "); | i = strcspn(fmt, " "); | ||||
| Context not available. | |||||
| opname[i] = '\0'; | opname[i] = '\0'; | ||||
| fmt += i + (noslot ? 0 : 1); | fmt += i + (noslot ? 0 : 1); | ||||
| i = BMO_opcode_from_opname_check(opname); | i = BMO_opcode_from_opname_check(opname); | ||||
| if (i == -1) { | if (i == -1) { | ||||
| Context not available. | |||||
| BMO_op_init(bm, op, flag, opname); | BMO_op_init(bm, op, flag, opname); | ||||
| // def = bmo_opdefines[i]; | // def = bmo_opdefines[i]; | ||||
| i = 0; | i = 0; | ||||
| state = true; /* false: not inside slot_code name, true: inside slot_code name */ | state = true; /* false: not inside slot_code name, true: inside slot_code name */ | ||||
| Context not available. | |||||
| /* jump past leading whitespace */ | /* jump past leading whitespace */ | ||||
| i = strspn(fmt, " "); | i = strspn(fmt, " "); | ||||
| fmt += i; | fmt += i; | ||||
| /* ignore trailing whitespace */ | /* ignore trailing whitespace */ | ||||
| if (!fmt[i]) | if (!fmt[i]) | ||||
| break; | break; | ||||
| Context not available. | |||||
| if (bmo_name_to_slotcode_check(op->slots_in, fmt) < 0) { | if (bmo_name_to_slotcode_check(op->slots_in, fmt) < 0) { | ||||
| GOTO_ERROR("name to slot code check failed"); | GOTO_ERROR("name to slot code check failed"); | ||||
| } | } | ||||
| BLI_strncpy(slot_name, fmt, sizeof(slot_name)); | BLI_strncpy(slot_name, fmt, sizeof(slot_name)); | ||||
| state = false; | state = false; | ||||
| fmt += i; | fmt += i; | ||||
| } | } | ||||
| Context not available. | |||||