Fix T61184 linked curves with curve modifiers arent drawn correctly

Force Displist to Mesh conversion if there is any modifier.

This is until we find a better way to store the batches per objects.

Also fix draw cache functions that were not returning final mesh edges.
This commit is contained in:
Clément Foucault 2019-04-24 19:11:28 +02:00
parent c265e25bb1
commit a14735d11d
Notes: blender-bot 2023-02-14 08:06:35 +01:00
Referenced by issue #71055, Modifiers which deform spline points propagate across all users of the same data unexpectedly
Referenced by issue #61184, linked curves with curve modifiers arent drawn correctly
2 changed files with 27 additions and 6 deletions

View File

@ -1028,7 +1028,10 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
}
/* If we need normals, no choice, have to convert to mesh now. */
if (mti->dependsOnNormals != NULL && mti->dependsOnNormals(md) && modified == NULL) {
bool need_normal = mti->dependsOnNormals != NULL && mti->dependsOnNormals(md);
/* XXX 2.8 : now that batch cache is stored inside the ob->data
* we need to create a Mesh for each curve that uses modifiers. */
if (modified == NULL /* && need_normal */) {
if (vertCos != NULL) {
displist_apply_allverts(dispbase, vertCos);
}
@ -1046,7 +1049,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
if (!vertCos) {
vertCos = BKE_mesh_vertexCos_get(modified, &totvert);
}
if (mti->dependsOnNormals != NULL && mti->dependsOnNormals(md)) {
if (need_normal) {
BKE_mesh_ensure_normals(modified);
}
mti->deformVerts(md, &mectx_deform, modified, vertCos, totvert);
@ -1095,7 +1098,7 @@ static void curve_calc_modifiers_post(Depsgraph *depsgraph,
vertCos = NULL;
}
if (mti->dependsOnNormals != NULL && mti->dependsOnNormals(md)) {
if (need_normal) {
BKE_mesh_ensure_normals(modified);
}
mesh_applied = mti->applyModifier(md, &mectx_apply, modified);

View File

@ -3302,7 +3302,13 @@ GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_CURVE);
struct Curve *cu = ob->data;
return DRW_curve_batch_cache_get_wire_edge(cu);
struct Mesh *mesh_eval = ob->runtime.mesh_eval;
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
else {
return DRW_curve_batch_cache_get_wire_edge(cu);
}
}
GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob)
@ -3448,7 +3454,13 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
return DRW_curve_batch_cache_get_wire_edge(cu);
struct Mesh *mesh_eval = ob->runtime.mesh_eval;
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
else {
return DRW_curve_batch_cache_get_wire_edge(cu);
}
}
GPUBatch *DRW_cache_text_surface_get(Object *ob)
@ -3560,7 +3572,13 @@ GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_SURF);
struct Curve *cu = ob->data;
return DRW_curve_batch_cache_get_wire_edge(cu);
struct Mesh *mesh_eval = ob->runtime.mesh_eval;
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
else {
return DRW_curve_batch_cache_get_wire_edge(cu);
}
}
GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob)