Skip to content

Commit 6d59742

Browse files
Merge pull request #53 from Live2D/develop
Update to Cubism 5 SDK for Native R1 beta3
2 parents 51e6006 + 19d1875 commit 6d59742

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77

8+
## [5-r.1-beta.3] - 2023-10-12
9+
10+
### Added
11+
12+
* Add `clamp()` to CubismMath.
13+
814

915
## [5-r.1-beta.2] - 2023-09-28
1016

@@ -320,6 +326,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
320326
* Fix invalid expressions of `CubismCdiJson`.
321327

322328

329+
[5-r.1-beta.3]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1-beta.2...5-r.1-beta.3
323330
[5-r.1-beta.2]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1-beta.1...5-r.1-beta.2
324331
[5-r.1-beta.1]: https://github.com/Live2D/CubismNativeFramework/compare/4-r.7...5-r.1-beta.1
325332
[4-r.7]: https://github.com/Live2D/CubismNativeFramework/compare/4-r.6.2...4-r.7

src/Math/CubismMath.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@ namespace Live2D {namespace Cubism {namespace Framework {
1212
const csmFloat32 CubismMath::Pi = 3.1415926535897932384626433832795f;
1313
const csmFloat32 CubismMath::Epsilon = 0.00001f;
1414

15+
csmInt32 CubismMath::Clamp(csmInt32 val, csmInt32 min, csmInt32 max)
16+
{
17+
if (val < min)
18+
{
19+
return min;
20+
}
21+
else if (max < val)
22+
{
23+
return max;
24+
}
25+
26+
return val;
27+
}
28+
29+
csmFloat32 CubismMath::ClampF(csmFloat32 val, csmFloat32 min, csmFloat32 max)
30+
{
31+
if (val < min)
32+
{
33+
return min;
34+
}
35+
else if (max < val)
36+
{
37+
return max;
38+
}
39+
40+
return val;
41+
}
42+
1543
csmFloat32 CubismMath::DegreesToRadian(csmFloat32 degrees)
1644
{
1745
return (degrees / 180.0f) * Pi;

src/Math/CubismMath.hpp

+20
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,26 @@ class CubismMath
122122
return (l > r) ? r : l;
123123
}
124124

125+
/**
126+
* @brief 値を範囲内に納めて返す
127+
*
128+
* @param val -> 範囲内か確認する値
129+
* @param min -> 最小値
130+
* @param max -> 最大値
131+
* @return 範囲内に収まった値
132+
*/
133+
static csmInt32 Clamp(csmInt32 val, csmInt32 min, csmInt32 max);
134+
135+
/**
136+
* @brief 値を範囲内に納めて返す
137+
*
138+
* @param val -> 範囲内か確認する値
139+
* @param min -> 最小値
140+
* @param max -> 最大値
141+
* @return 範囲内に収まった値
142+
*/
143+
static csmFloat32 ClampF(csmFloat32 val, csmFloat32 min, csmFloat32 max);
144+
125145
/**
126146
* @brief 角度値をラジアン値に変換します。
127147
*

0 commit comments

Comments
 (0)