RavEngine
Loading...
Searching...
No Matches
local_to_model_job.h
1//----------------------------------------------------------------------------//
2// //
3// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
4// and distributed under the MIT License (MIT). //
5// //
6// Copyright (c) Guillaume Blanc //
7// //
8// Permission is hereby granted, free of charge, to any person obtaining a //
9// copy of this software and associated documentation files (the "Software"), //
10// to deal in the Software without restriction, including without limitation //
11// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
12// and/or sell copies of the Software, and to permit persons to whom the //
13// Software is furnished to do so, subject to the following conditions: //
14// //
15// The above copyright notice and this permission notice shall be included in //
16// all copies or substantial portions of the Software. //
17// //
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
21// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
24// DEALINGS IN THE SOFTWARE. //
25// //
26//----------------------------------------------------------------------------//
27
28#ifndef OZZ_OZZ_ANIMATION_RUNTIME_LOCAL_TO_MODEL_JOB_H_
29#define OZZ_OZZ_ANIMATION_RUNTIME_LOCAL_TO_MODEL_JOB_H_
30
31#include "ozz/animation/runtime/export.h"
32#include "ozz/base/platform.h"
33#include "ozz/base/span.h"
34
35namespace ozz {
36
37// Forward declaration math structures.
38namespace math {
39struct SoaTransform;
40}
41namespace math {
42struct Float4x4;
43}
44
45namespace animation {
46
47// Forward declares the Skeleton object used to describe joint hierarchy.
48class Skeleton;
49
50// Computes model-space joint matrices from local-space SoaTransform.
51// This job uses the skeleton to define joints parent-child hierarchy. The job
52// iterates through all joints to compute their transform relatively to the
53// skeleton root.
54// Job inputs is an array of SoaTransform objects (in local-space), ordered like
55// skeleton's joints. Job output is an array of matrices (in model-space),
56// ordered like skeleton's joints. Output are matrices, because the combination
57// of affine transformations can contain shearing or complex transformation
58// that cannot be represented as Transform object.
59struct OZZ_ANIMATION_DLL LocalToModelJob {
60 // Default constructor, initializes default values.
62
63 // Validates job parameters. Returns true for a valid job, or false otherwise:
64 // -if any input pointer, including ranges, is nullptr.
65 // -if the size of the input is smaller than the skeleton's number of joints.
66 // Note that this input has a SoA format.
67 // -if the size of of the output is smaller than the skeleton's number of
68 // joints.
69 bool Validate() const;
70
71 // Runs job's local-to-model task.
72 // The job is validated before any operation is performed, see Validate() for
73 // more details.
74 // Returns false if job is not valid. See Validate() function.
75 bool Run() const;
76
77 // Job input.
78
79 // The Skeleton object describing the joint hierarchy used for local to
80 // model space conversion.
81 const Skeleton* skeleton;
82
83 // The root matrix will multiply to every model space matrices, default nullptr
84 // means an identity matrix. This can be used to directly compute world-space
85 // transforms for example.
86 const ozz::math::Float4x4* root;
87
88 // Defines "from" which joint the local-to-model conversion should start.
89 // Default value is ozz::Skeleton::kNoParent, meaning the whole hierarchy is
90 // updated. This parameter can be used to optimize update by limiting
91 // conversion to part of the joint hierarchy. Note that "from" parent should
92 // be a valid matrix, as it is going to be used as part of "from" joint
93 // hierarchy update.
94 int from;
95
96 // Defines "to" which joint the local-to-model conversion should go, "to"
97 // included. Update will end before "to" joint is reached if "to" is not part
98 // of the hierarchy starting from "from". Default value is
99 // ozz::animation::Skeleton::kMaxJoints, meaning the hierarchy (starting from
100 // "from") is updated to the last joint.
101 int to;
102
103 // If true, "from" joint is not updated during job execution. Update starts
104 // with all children of "from". This can be used to update a model-space
105 // transform independently from the local-space one. To do so: set "from"
106 // joint model-space transform matrix, and run this Job with "from_excluded"
107 // to update all "from" children.
108 // Default value is false.
109 bool from_excluded;
110
111 // The input range that store local transforms.
113
114 // Job output.
115
116 // The output range to be filled with model-space matrices.
118};
119} // namespace animation
120} // namespace ozz
121#endif // OZZ_OZZ_ANIMATION_RUNTIME_LOCAL_TO_MODEL_JOB_H_
Definition skeleton.h:61
Definition local_to_model_job.h:59
Definition simd_math.h:1066
Definition span.h:37