Skip to content

Commit

Permalink
Update to Cubism 5 SDK for Native R1 beta3
Browse files Browse the repository at this point in the history
  • Loading branch information
wada-at-live2d-com committed Oct 12, 2023
1 parent 465335e commit 19d1875
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [5-r.1-beta.3] - 2023-10-12

### Added

* Add `clamp()` to CubismMath.


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

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


[5-r.1-beta.3]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1-beta.2...5-r.1-beta.3
[5-r.1-beta.2]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1-beta.1...5-r.1-beta.2
[5-r.1-beta.1]: https://github.com/Live2D/CubismNativeFramework/compare/4-r.7...5-r.1-beta.1
[4-r.7]: https://github.com/Live2D/CubismNativeFramework/compare/4-r.6.2...4-r.7
Expand Down
28 changes: 28 additions & 0 deletions src/Math/CubismMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,34 @@ namespace Live2D {namespace Cubism {namespace Framework {
const csmFloat32 CubismMath::Pi = 3.1415926535897932384626433832795f;
const csmFloat32 CubismMath::Epsilon = 0.00001f;

csmInt32 CubismMath::Clamp(csmInt32 val, csmInt32 min, csmInt32 max)
{
if (val < min)
{
return min;
}
else if (max < val)
{
return max;
}

return val;
}

csmFloat32 CubismMath::ClampF(csmFloat32 val, csmFloat32 min, csmFloat32 max)
{
if (val < min)
{
return min;
}
else if (max < val)
{
return max;
}

return val;
}

csmFloat32 CubismMath::DegreesToRadian(csmFloat32 degrees)
{
return (degrees / 180.0f) * Pi;
Expand Down
20 changes: 20 additions & 0 deletions src/Math/CubismMath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,26 @@ class CubismMath
return (l > r) ? r : l;
}

/**
* @brief 値を範囲内に納めて返す
*
* @param val -> 範囲内か確認する値
* @param min -> 最小値
* @param max -> 最大値
* @return 範囲内に収まった値
*/
static csmInt32 Clamp(csmInt32 val, csmInt32 min, csmInt32 max);

/**
* @brief 値を範囲内に納めて返す
*
* @param val -> 範囲内か確認する値
* @param min -> 最小値
* @param max -> 最大値
* @return 範囲内に収まった値
*/
static csmFloat32 ClampF(csmFloat32 val, csmFloat32 min, csmFloat32 max);

/**
* @brief 角度値をラジアン値に変換します。
*
Expand Down

0 comments on commit 19d1875

Please sign in to comment.