Skip to content

Commit beb377f

Browse files
committed
Created a template class for time key values.
1 parent 12f8c15 commit beb377f

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

include/vsg/animation/TransformSampler.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
1313
</editor-fold> */
1414

1515
#include <vsg/animation/Animation.h>
16+
#include <vsg/animation/time_value.h>
1617
#include <vsg/app/ViewMatrix.h>
1718
#include <vsg/maths/transform.h>
1819

1920
namespace vsg
2021
{
2122

22-
struct VectorKey
23-
{
24-
double time;
25-
dvec3 value;
26-
27-
bool operator<(const VectorKey& rhs) const { return time < rhs.time; }
28-
};
29-
30-
struct QuatKey
31-
{
32-
double time;
33-
dquat value;
34-
35-
bool operator<(const QuatKey& rhs) const { return time < rhs.time; }
36-
};
23+
using VectorKey = time_dvec3;
24+
using QuatKey = time_dquat;
3725

3826
class VSG_DECLSPEC TransformKeyframes : public Inherit<Object, TransformKeyframes>
3927
{

include/vsg/animation/time_value.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#pragma once
2+
3+
/* <editor-fold desc="MIT License">
4+
5+
Copyright(c) 2024 Robert Osfield
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
9+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12+
13+
</editor-fold> */
14+
15+
#include <vsg/animation/Animation.h>
16+
#include <vsg/app/ViewMatrix.h>
17+
#include <vsg/maths/transform.h>
18+
19+
namespace vsg
20+
{
21+
22+
template<typename T>
23+
struct time_value
24+
{
25+
using value_type = T;
26+
double time;
27+
value_type value;
28+
29+
bool operator<(const time_value& rhs) const { return time < rhs.time; }
30+
};
31+
32+
using time_double = time_value<double>;
33+
using time_dvec2 = time_value<dvec2>;
34+
using time_dvec3 = time_value<dvec3>;
35+
using time_dvec4 = time_value<dvec4>;
36+
using time_dquat = time_value<dquat>;
37+
38+
} // namespace vsg

0 commit comments

Comments
 (0)