AMFP Enhanced
C++ reference: the code this unofficial fork added
Toggle main menu visibility
Loading...
Searching...
No Matches
FbxAnimTimes.h
Go to the documentation of this file.
1
/*
2
* AMFP-2026: FBX animation key times as the original Autodesk FBX SDK loader saw them.
3
* The SDK loader read every key time as whole milliseconds (KTime::GetMilliSeconds truncates),
4
* merged the translation / rotation / scale keys of a bone into one sorted set and sampled
5
* the bone at each of those times. The ufbx loader (MeshLoaderFBX.cpp) does the same so its
6
* output matches the .anm files the original loader cached. Pure, unit tested in
7
* tests/cpp/test_fbx_anim_times.cpp.
8
*/
9
#ifndef HPL_FBX_ANIM_TIMES_H
10
#define HPL_FBX_ANIM_TIMES_H
11
12
#include <cmath>
13
#include <set>
14
15
namespace
hpl
{
16
17
/** Seconds -> whole milliseconds, truncated like KTime::GetMilliSeconds. A tiny tolerance keeps
18
* times stored as 0.99999999 s on 999 ms's right side (1000). */
19
inline
long
long
FbxTimeToMs
(
double
afSeconds)
20
{
21
return
(
long
long
)std::floor(afSeconds * 1000.0 + 1e-6);
22
}
23
24
/** The time the SDK loader stored for a key: its whole milliseconds, in seconds. */
25
inline
float
FbxKeyTime
(
double
afSeconds)
26
{
27
return
(
float
)
FbxTimeToMs
(afSeconds) / 1000.0f;
28
}
29
30
/** Adds key times (seconds) to the bone's sorted set of sample times. */
31
template
<
class
tIt>
32
inline
void
FbxAddKeyTimes
(std::set<float>& aTimes, tIt aBegin, tIt aEnd)
33
{
34
for
(tIt it = aBegin; it != aEnd; ++it) aTimes.insert(
FbxKeyTime
(*it));
35
}
36
37
/** Length the SDK loader gave an animation: the take's end in whole milliseconds, in seconds. */
38
inline
float
FbxAnimLength
(
double
afEndSeconds)
39
{
40
return
(
float
)
FbxTimeToMs
(afEndSeconds) / 1000.0f;
41
}
42
43
/** The SDK loader used the first take whose span is at least one millisecond. */
44
inline
bool
FbxTakeHasLength
(
double
afBeginSeconds,
double
afEndSeconds)
45
{
46
return
FbxTimeToMs
(afEndSeconds) -
FbxTimeToMs
(afBeginSeconds) > 0;
47
}
48
49
}
50
51
#endif
hpl
Definition
ShadowMapSizes.h:8
hpl::FbxAddKeyTimes
void FbxAddKeyTimes(std::set< float > &aTimes, tIt aBegin, tIt aEnd)
Adds key times (seconds) to the bone's sorted set of sample times.
Definition
FbxAnimTimes.h:32
hpl::FbxTimeToMs
long long FbxTimeToMs(double afSeconds)
Seconds -> whole milliseconds, truncated like KTime::GetMilliSeconds.
Definition
FbxAnimTimes.h:19
hpl::FbxTakeHasLength
bool FbxTakeHasLength(double afBeginSeconds, double afEndSeconds)
The SDK loader used the first take whose span is at least one millisecond.
Definition
FbxAnimTimes.h:44
hpl::FbxKeyTime
float FbxKeyTime(double afSeconds)
The time the SDK loader stored for a key: its whole milliseconds, in seconds.
Definition
FbxAnimTimes.h:25
hpl::FbxAnimLength
float FbxAnimLength(double afEndSeconds)
Length the SDK loader gave an animation: the take's end in whole milliseconds, in seconds.
Definition
FbxAnimTimes.h:38
HPL2
core
include
resources
FbxAnimTimes.h
Generated by
1.18.0