Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BKE_crazyspace.hh « blenkernel « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: adebf0b7884b24a3bbfe541702e5e9c5a9f2f3e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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