Loading...
Searching...
No Matches
tangentConversions.h
1//
2// Copyright 2024 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_BASE_TS_TANGENT_CONVERSION_H
9#define PXR_BASE_TS_TANGENT_CONVERSION_H
10
11#include "pxr/pxr.h"
12#include "pxr/base/ts/types.h"
13#include "pxr/base/vt/value.h"
14
15PXR_NAMESPACE_OPEN_SCOPE
16
17template <typename T>
18bool TsConvertToStandardTangent(
19 TsTime widthIn,
20 T slopeOrHeightIn,
21 bool convertHeightToSlope,
22 bool divideValuesByThree,
23 bool negateHeight,
24 TsTime* widthOut,
25 T* slopeOut);
26
27TS_API
28bool TsConvertToStandardTangent(
29 TsTime widthIn,
30 const VtValue& slopeOrHeightIn,
31 bool convertHeightToSlope,
32 bool divideValuesByThree,
33 bool negateHeight,
34 TsTime* widthOut,
35 VtValue* slopeOut);
36
37template <typename T>
38bool TsConvertFromStandardTangent(
39 TsTime widthIn,
40 T slopeIn,
41 bool convertSlopeToHeight,
42 bool multiplyValuesByThree,
43 bool negateHeight,
44 TsTime* widthOut,
45 T* slopeOrHeightOut);
46
47TS_API
48bool TsConvertFromStandardTangent(
49 TsTime widthIn,
50 const VtValue& slopeIn,
51 bool convertSlopeToHeight,
52 bool multiplyValuesByThree,
53 bool negateHeight,
54 TsTime* widthOut,
55 VtValue* slopeOrHeightOut);
56
58// TEMPLATE HELPERS
59template <typename T>
60bool Ts_ConvertToStandardHelper(
61 const TsTime widthIn,
62 const T slopeOrHeightIn,
63 bool convertHeightToSlope,
64 bool divideValuesByThree,
65 bool negateHeight,
66 TsTime* widthOut,
67 T* slopeOut);
68
69template <typename T>
70bool Ts_ConvertFromStandardHelper(
71 TsTime widthIn,
72 T slopeIn,
73 bool convertSlopeToHeight,
74 bool multiplyValuesByThree,
75 bool negateHeight,
76 TsTime* widthOut,
77 T* slopeOrHeightOut);
78
80// TEMPLATE DEFINITIONS
81
82#define _MAKE_CLAUSE(unused, tuple) \
83 std::is_same_v<NonVolatileT, TS_SPLINE_VALUE_CPP_TYPE(tuple)> ||
84
85template <typename T>
86bool TsConvertToStandardTangent(
87 const TsTime widthIn,
88 const T slopeOrHeightIn,
89 bool convertHeightToSlope,
90 bool divideValuesByThree,
91 bool negateHeight,
92 TsTime* widthOut,
93 T* slopeOut)
94{
95 using NonVolatileT = typename std::remove_volatile<T>::type;
96
97 static_assert((
98 TF_PP_SEQ_FOR_EACH(_MAKE_CLAUSE, ~, TS_SPLINE_SUPPORTED_VALUE_TYPES) \
99 false), "Can only use the values supported by the spline system.");
100
101 return Ts_ConvertToStandardHelper(
102 widthIn, slopeOrHeightIn, convertHeightToSlope, divideValuesByThree,
103 negateHeight, widthOut, slopeOut);
104}
105
106template <typename T>
107bool TsConvertFromStandardTangent(
108 const TsTime widthIn,
109 const T slopeIn,
110 bool convertSlopeToHeight,
111 bool multiplyValuesByThree,
112 bool negateHeight,
113 TsTime* widthOut,
114 T* slopeOrHeightOut)
115{
116 using NonVolatileT = typename std::remove_volatile<T>::type;
117
118 static_assert((
119 TF_PP_SEQ_FOR_EACH(_MAKE_CLAUSE, ~, TS_SPLINE_SUPPORTED_VALUE_TYPES) \
120 false), "Can only use the values supported by the spline system.");
121
122 return Ts_ConvertFromStandardHelper(
123 widthIn, slopeIn, convertSlopeToHeight, multiplyValuesByThree,
124 negateHeight, widthOut, slopeOrHeightOut);
125}
126
127#undef _MAKE_CLAUSE
128
129PXR_NAMESPACE_CLOSE_SCOPE
130
131#endif
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:152