Cleanup: some moar DM kicking, in armature edit code.
This commit is contained in:
parent
04f8929271
commit
3eff6f7a5e
|
@ -62,4 +62,6 @@ void BKE_mesh_foreach_mapped_face_center(
|
|||
void *userData,
|
||||
MeshForeachFlag flag);
|
||||
|
||||
void BKE_mesh_foreach_mapped_vert_coords_get(struct Mesh *me_eval, float (*r_cos)[3], const int totcos);
|
||||
|
||||
#endif /* __BKE_MESH_ITERATORS_H__ */
|
||||
|
|
|
@ -33,6 +33,10 @@
|
|||
#include "BKE_mesh.h"
|
||||
#include "BKE_mesh_iterators.h"
|
||||
|
||||
#include "BLI_bitmap.h"
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
/* Copied from cdDM_foreachMappedVert */
|
||||
void BKE_mesh_foreach_mapped_vert(
|
||||
|
@ -152,3 +156,36 @@ void BKE_mesh_foreach_mapped_face_center(
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Helpers based on above foreach loopers> */
|
||||
|
||||
typedef struct MappedVCosData {
|
||||
float (*vertexcos)[3];
|
||||
BLI_bitmap *vertex_visit;
|
||||
} MappedVCosData;
|
||||
|
||||
static void get_vertexcos__mapFunc(
|
||||
void *user_data, int index, const float co[3],
|
||||
const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
|
||||
{
|
||||
MappedVCosData *mapped_vcos_data = (MappedVCosData *)user_data;
|
||||
|
||||
if (BLI_BITMAP_TEST(mapped_vcos_data->vertex_visit, index) == 0) {
|
||||
/* We need coord from prototype vertex, not from copies,
|
||||
* we assume they stored in the beginning of vertex array stored in evaluated mesh
|
||||
* (mirror modifier for eg does this). */
|
||||
copy_v3_v3(mapped_vcos_data->vertexcos[index], co);
|
||||
BLI_BITMAP_ENABLE(mapped_vcos_data->vertex_visit, index);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_mesh_foreach_mapped_vert_coords_get(Mesh *me_eval, float (*r_cos)[3], const int totcos)
|
||||
{
|
||||
MappedVCosData user_data;
|
||||
memset(r_cos, 0, sizeof(*r_cos) * totcos);
|
||||
user_data.vertexcos = r_cos;
|
||||
user_data.vertex_visit = BLI_BITMAP_NEW(totcos, __func__);
|
||||
BKE_mesh_foreach_mapped_vert(me_eval, get_vertexcos__mapFunc, &user_data, MESH_FOREACH_NOP);
|
||||
MEM_freeN(user_data.vertex_visit);
|
||||
}
|
||||
|
|
|
@ -45,11 +45,12 @@
|
|||
#include "BKE_armature.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_mesh_iterators.h"
|
||||
#include "BKE_mesh_runtime.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object_deform.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_subsurf.h"
|
||||
#include "BKE_modifier.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
|
@ -259,7 +260,7 @@ static void add_verts_to_dgroups(
|
|||
* into account and vertex weights can be mirrored.
|
||||
*
|
||||
* The mesh vertex positions used are either the final deformed coords
|
||||
* from the derivedmesh in weightpaint mode, the final subsurf coords
|
||||
* from the evaluated mesh in weightpaint mode, the final subsurf coords
|
||||
* when parenting, or simply the original mesh coords.
|
||||
*/
|
||||
|
||||
|
@ -373,15 +374,11 @@ static void add_verts_to_dgroups(
|
|||
verts = MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts");
|
||||
|
||||
if (wpmode) {
|
||||
/* if in weight paint mode, use final verts from derivedmesh */
|
||||
DerivedMesh *dm = mesh_get_derived_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
|
||||
/* if in weight paint mode, use final verts from evaluated mesh */
|
||||
Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
|
||||
|
||||
if (dm->foreachMappedVert) {
|
||||
mesh_get_mapped_verts_coords(dm, verts, mesh->totvert);
|
||||
vertsfilled = 1;
|
||||
}
|
||||
|
||||
dm->release(dm);
|
||||
BKE_mesh_foreach_mapped_vert_coords_get(me_eval, verts, mesh->totvert);
|
||||
vertsfilled = 1;
|
||||
}
|
||||
else if (modifiers_findByType(ob, eModifierType_Subsurf)) {
|
||||
/* is subsurf on? Lets use the verts on the limit surface then.
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
|
@ -39,10 +40,10 @@
|
|||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "BKE_DerivedMesh.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_bvhutils.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_mesh_runtime.h"
|
||||
#include "BKE_modifier.h"
|
||||
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_armature.h"
|
||||
|
|
Loading…
Reference in New Issue