Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/lattice.c
| Context not available. | |||||
| float (*vertexCos)[3], int numVerts, const char *vgroup, float fac) | float (*vertexCos)[3], int numVerts, const char *vgroup, float fac) | ||||
| { | { | ||||
| LatticeDeformData *lattice_deform_data; | LatticeDeformData *lattice_deform_data; | ||||
| MDeformVert *dvert = NULL; | |||||
| int defgrp_index = -1; | |||||
| int a; | int a; | ||||
| bool use_vgroups; | |||||
| if (laOb->type != OB_LATTICE) | if (laOb->type != OB_LATTICE) | ||||
| return; | return; | ||||
| lattice_deform_data = init_latt_deform(laOb, target); | lattice_deform_data = init_latt_deform(laOb, target); | ||||
| /* check whether to use vertex groups (only possible if target is a Mesh) | /* Check whether to use vertex groups (only possible if target is a Mesh or Lattice). | ||||
| * we want either a Mesh with no derived data, or derived data with | * We want either a Mesh/Lattice with no derived data, or derived data with deformverts. | ||||
| * deformverts | |||||
| */ | */ | ||||
| if (target && target->type == OB_MESH) { | if (vgroup && vgroup[0] && target && ELEM(target->type, OB_MESH, OB_LATTICE)) { | ||||
| /* if there's derived data without deformverts, don't use vgroups */ | defgrp_index = defgroup_name_index(target, vgroup); | ||||
| if (dm) { | |||||
| use_vgroups = (dm->getVertDataArray(dm, CD_MDEFORMVERT) != NULL); | if (defgrp_index != -1) { | ||||
| } | /* if there's derived data without deformverts, don't use vgroups */ | ||||
| else { | if (dm) { | ||||
| Mesh *me = target->data; | dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); | ||||
| use_vgroups = (me->dvert != NULL); | } | ||||
| else if (target->type == OB_LATTICE) { | |||||
| dvert = ((Lattice *)target->data)->dvert; | |||||
| } | |||||
| else { | |||||
| dvert = ((Mesh *)target->data)->dvert; | |||||
| } | |||||
mont29: You forgot to check target is not NULL... | |||||
| } | } | ||||
| } | } | ||||
| else { | if (dvert) { | ||||
Not Done Inline ActionsThis should probably rather use modifier_get_vgroup() from MOD_util ? mont29: This should probably rather use `modifier_get_vgroup()` from MOD_util ? | |||||
Not Done Inline ActionsNot sure I can include MOD_util in blenderkernel? Or should I move modifier_get_vgroup() somewhere I can include it? lichtwerk: Not sure I can include MOD_util in blenderkernel? Or should I move `modifier_get_vgroup()`… | |||||
Not Done Inline ActionsOuch right, did not saw it was in BKE… then guess patch is OK. mont29: Ouch right, did not saw it was in BKE… then guess patch is OK. | |||||
| use_vgroups = false; | MDeformVert *dvert_iter; | ||||
| } | for (a = 0, dvert_iter = dvert; a < numVerts; a++, dvert_iter++) { | ||||
| const float weight = defvert_find_weight(dvert_iter, defgrp_index); | |||||
| if (vgroup && vgroup[0] && use_vgroups) { | if (weight > 0.0f) { | ||||
| Mesh *me = target->data; | calc_latt_deform(lattice_deform_data, vertexCos[a], weight * fac); | ||||
| const int defgrp_index = defgroup_name_index(target, vgroup); | |||||
| float weight; | |||||
| if (defgrp_index >= 0 && (me->dvert || dm)) { | |||||
| MDeformVert *dvert = me->dvert; | |||||
| for (a = 0; a < numVerts; a++, dvert++) { | |||||
| if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); | |||||
| weight = defvert_find_weight(dvert, defgrp_index); | |||||
| if (weight > 0.0f) | |||||
| calc_latt_deform(lattice_deform_data, vertexCos[a], weight * fac); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
You forgot to check target is not NULL...