Fix T86871: Mesh.mesh_from_object creates empty mesh from curve
Regression in 2b723abea0
This commit is contained in:
parent
7ab7ae80c5
commit
d18be66a54
Notes:
blender-bot
2023-02-13 19:10:35 +01:00
Referenced by issue #87944, Python API Function `bpy.data.meshes.mesh_from_object()` No Longer Works Referenced by issue #86871, Crash with to_mesh() on tapered bezier curve
|
@ -1061,6 +1061,9 @@ static Object *object_for_curve_to_mesh_create(Object *object)
|
|||
return temp_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate `object->runtime.curve_cache` which is then used to create the mesh.
|
||||
*/
|
||||
static void curve_to_mesh_eval_ensure(Object *object)
|
||||
{
|
||||
Curve *curve = (Curve *)object->data;
|
||||
|
@ -1070,10 +1073,13 @@ static void curve_to_mesh_eval_ensure(Object *object)
|
|||
|
||||
remapped_object.data = &remapped_curve;
|
||||
|
||||
if (remapped_object.runtime.curve_cache == NULL) {
|
||||
remapped_object.runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
|
||||
if (object->runtime.curve_cache == NULL) {
|
||||
object->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
|
||||
}
|
||||
|
||||
/* Temporarily share the curve-cache with the temporary object, owned by `object`. */
|
||||
remapped_object.runtime.curve_cache = object->runtime.curve_cache;
|
||||
|
||||
/* Clear all modifiers for the bevel object.
|
||||
*
|
||||
* This is because they can not be reliably evaluated for an original object (at least because
|
||||
|
@ -1116,6 +1122,9 @@ static void curve_to_mesh_eval_ensure(Object *object)
|
|||
BKE_object_eval_assign_data(&remapped_object, &mesh_eval->id, true);
|
||||
}
|
||||
|
||||
/* Owned by `object` & needed by the caller to create the mesh. */
|
||||
remapped_object.runtime.curve_cache = NULL;
|
||||
|
||||
BKE_object_runtime_free_data(&remapped_object);
|
||||
BKE_object_runtime_free_data(&taper_object);
|
||||
BKE_object_runtime_free_data(&taper_object);
|
||||
|
|
Loading…
Reference in New Issue