Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_vgroup.c
| Show All 22 Lines | |||||
| #include <math.h> | #include <math.h> | ||||
| #include <stddef.h> | #include <stddef.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_curve_types.h" | #include "DNA_curve_types.h" | ||||
| #include "DNA_gpencil_types.h" | |||||
| #include "DNA_lattice_types.h" | #include "DNA_lattice_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "DNA_modifier_types.h" | #include "DNA_modifier_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "BLI_alloca.h" | #include "BLI_alloca.h" | ||||
| #include "BLI_array.h" | #include "BLI_array.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_listbase.h" | |||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_utildefines_stack.h" | #include "BLI_utildefines_stack.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_customdata.h" | #include "BKE_customdata.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| ▲ Show 20 Lines • Show All 4,028 Lines • ▼ Show 20 Lines | if (ob->mode == OB_MODE_EDIT) { | ||||
| else { | else { | ||||
| BKE_report(op->reports, RPT_ERROR, "Editmode lattice is not supported yet"); | BKE_report(op->reports, RPT_ERROR, "Editmode lattice is not supported yet"); | ||||
| MEM_freeN(sort_map_update); | MEM_freeN(sort_map_update); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| int dvert_tot = 0; | int dvert_tot = 0; | ||||
| /* Grease pencil stores vertex groups separately for each stroke, | |||||
HooglyBoogly: It would be nice to have a comment here describing why the special case is necessary, like… | |||||
| * so remap each stroke's weights separately. */ | |||||
| if (ob->type == OB_GPENCIL) { | |||||
| bGPdata *gpd = ob->data; | |||||
| LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { | |||||
| LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { | |||||
| LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { | |||||
| dvert = gps->dvert; | |||||
Not Done Inline ActionsDon't think this dvert_tot > 0 check is necessary, since the while loop won't execute if it's condition is false before it starts. For bonus points this could just be a for loop ;) HooglyBoogly: Don't think this `dvert_tot > 0` check is necessary, since the while loop won't execute if it's… | |||||
| dvert_tot = gps->totpoints; | |||||
| if (dvert) { | |||||
| while (dvert_tot--) { | |||||
| if (dvert->totweight) { | |||||
| BKE_defvert_remap(dvert, sort_map, defbase_tot); | |||||
| } | |||||
| dvert++; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| else { | |||||
| BKE_object_defgroup_array_get(ob->data, &dvert, &dvert_tot); | BKE_object_defgroup_array_get(ob->data, &dvert, &dvert_tot); | ||||
| /* Create as necessary. */ | /* Create as necessary. */ | ||||
| if (dvert) { | if (dvert) { | ||||
| while (dvert_tot--) { | while (dvert_tot--) { | ||||
| if (dvert->totweight) { | if (dvert->totweight) { | ||||
| BKE_defvert_remap(dvert, sort_map, defbase_tot); | BKE_defvert_remap(dvert, sort_map, defbase_tot); | ||||
| } | } | ||||
| dvert++; | dvert++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| /* update users */ | /* update users */ | ||||
| for (i = 0; i < defbase_tot; i++) { | for (i = 0; i < defbase_tot; i++) { | ||||
| sort_map[i]++; | sort_map[i]++; | ||||
| } | } | ||||
| sort_map_update[0] = 0; | sort_map_update[0] = 0; | ||||
| BKE_object_defgroup_remap_update_users(ob, sort_map_update); | BKE_object_defgroup_remap_update_users(ob, sort_map_update); | ||||
| ▲ Show 20 Lines • Show All 486 Lines • Show Last 20 Lines | |||||
It would be nice to have a comment here describing why the special case is necessary, like Grease pencil stores vertex groups separately for each stroke, so remap each stroke's weights separately.