diff options
author | Jacques Lucke <jacques@blender.org> | 2022-07-22 16:39:41 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-07-22 16:39:41 +0300 |
commit | 1f94b56d774440d08eb92f2a7a47b9a6a7aa7b84 (patch) | |
tree | 06928c94d524852c7031aa310d578691735dc0a8 /source/blender/blenkernel/BKE_crazyspace.hh | |
parent | 98bf714b37c1f1b05a162b6ffdaca367b312de1f (diff) |
Curves: support sculpting on deformed curves
Previously, curves sculpt tools only worked on original data. This was
very limiting, because one could effectively only sculpt the curves when
all procedural effects were turned off. This patch adds support for curves
sculpting while looking the result of procedural effects (like deformation
based on the surface mesh). This functionality is also known as "crazy space"
support in Blender.
For more details see D15407.
Differential Revision: https://developer.blender.org/D15407
Diffstat (limited to 'source/blender/blenkernel/BKE_crazyspace.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_crazyspace.hh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_crazyspace.hh b/source/blender/blenkernel/BKE_crazyspace.hh new file mode 100644 index 00000000000..adebf0b7884 --- /dev/null +++ b/source/blender/blenkernel/BKE_crazyspace.hh @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup bke + */ + +#pragma once + +#include "BLI_float3x3.hh" +#include "BLI_math_vec_types.hh" +#include "BLI_span.hh" + +struct Depsgraph; +struct Object; + +namespace blender::bke::crazyspace { + +/** + * Contains information about how points have been deformed during evaluation. + * This allows mapping edits on evaluated data back to original data in some cases. + */ +struct GeometryDeformation { + /** + * Positions of the deformed points. This may also point to the original position if no + * deformation data is available. + */ + Span<float3> positions; + /** + * Matrices that transform point translations on original data into corresponding translations in + * evaluated data. This may be empty if not available. + */ + Span<float3x3> deform_mats; + + float3 translation_from_deformed_to_original(const int position_i, + const float3 &translation) const + { + if (this->deform_mats.is_empty()) { + return translation; + } + const float3x3 &deform_mat = this->deform_mats[position_i]; + return deform_mat.inverted() * translation; + } +}; + +/** + * During evaluation of the object, deformation data may have been generated for this object. This + * function either retrieves the deformation data from the evaluated object, or falls back to + * returning the original data. + */ +GeometryDeformation get_evaluated_curves_deformation(const Depsgraph &depsgraph, + const Object &ob_orig); + +} // namespace blender::bke::crazyspace |