From ac27bd16dbfc302ed34034f5c16d331caadea5e6 Mon Sep 17 00:00:00 2001 From: Pratik Borhade Date: Tue, 4 Feb 2025 11:12:40 +0100 Subject: [PATCH] Fix: Grease Pencil: Debug build error when armature is parent Error is about accessing value of nullopt optional `vert_coords_prev`. This occurs when armature is parented to grease pencil object. Pull Request: https://projects.blender.org/blender/blender/pulls/134016 --- source/blender/blenkernel/intern/armature_deform.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/armature_deform.cc b/source/blender/blenkernel/intern/armature_deform.cc index 6347e5eb10f..92e0dae79eb 100644 --- a/source/blender/blenkernel/intern/armature_deform.cc +++ b/source/blender/blenkernel/intern/armature_deform.cc @@ -621,8 +621,11 @@ void BKE_armature_deform_coords_with_curves( * used for Grease Pencil layers as well. */ BLI_assert(dverts.size() == vert_coords.size()); - /* const_cast for old positions for the C API, these are not actually written. */ - blender::float3 *vert_coords_prev_data = const_cast(vert_coords_prev->data()); + blender::float3 *vert_coords_prev_data = nullptr; + if (vert_coords_prev.has_value()) { + /* const_cast for old positions for the C API, these are not actually written. */ + vert_coords_prev_data = const_cast(vert_coords_prev->data()); + } armature_deform_coords_impl( &ob_arm, @@ -632,7 +635,7 @@ void BKE_armature_deform_coords_with_curves( vert_deform_mats ? reinterpret_cast(vert_deform_mats->data()) : nullptr, vert_coords.size(), deformflag, - vert_coords_prev ? reinterpret_cast(vert_coords_prev_data) : nullptr, + reinterpret_cast(vert_coords_prev_data), defgrp_name.c_str(), dverts, nullptr,