Loading...
Searching...
No Matches
MorphTargets.hpp
1#pragma once
2#include <ossia/dataflow/geometry_port.hpp>
3
4#include <span>
5
6namespace Threedim
7{
8
9// Morph targets (glTF) / shape keys (Blender), blended on the CPU: the
10// renderer only knows vertex buffers.
11//
12// Layout convention for ossia::mesh_component::morph_targets: target t's
13// position_deltas (and normal_deltas, when present) hold float3 deltas for
14// every vertex of every primitive, primitive after primitive in the order of
15// mesh_component::primitives, each over its vertex_count. A null buffer means
16// that target does not move that attribute.
17//
18// mesh_component::morph_weights are the weights the primitives' POSITION and
19// NORMAL buffers are currently blended with.
20
21// The mesh with its POSITION and NORMAL buffers blended to `weights` instead
22// of mesh.morph_weights, its bounds recomputed and morph_weights set to
23// `weights`. Missing weights count as 0. Buffers that no target touches are
24// shared with `mesh`; everything else in it is copied as is.
25//
26// Blending is relative to the mesh's current weights, so passing the same
27// source mesh with successive weights never accumulates rounding error.
28std::shared_ptr<ossia::mesh_component>
29blendMorphTargets(const ossia::mesh_component& mesh, std::span<const float> weights);
30
31}