Skip to content

Commit

Permalink
Merge pull request #59 from Live2D/develop
Browse files Browse the repository at this point in the history
Update to Cubism 5 SDK for Native R2
  • Loading branch information
itoh-at-live2d-com authored Dec 19, 2024
2 parents bf7d7ff + 5a5e492 commit 0b5951b
Show file tree
Hide file tree
Showing 72 changed files with 2,564 additions and 5,752 deletions.
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,60 @@ 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.2] - 2024-12-19

### Added

* Add copy constructor to `csmMap`.
* Add functions to get `CombinedParameters` listed in `cdi3.json`.
* Add the functionality to call a function when motion playback starts.
* Add updates to the OpenGL rendering code for HarmonyOS compatibility.
* Add Linux support for the Vulkan renderer.
* Add an API to `CubismMotionJson` for verifying the consistency of `motion3.json`. by [@pillowtrucker](https://github.com/Live2D/CubismNativeFramework/pull/57)
* Add dedicated resource destruction functions for some platforms

### Changed

* Change to permit to overwrite motion fade by the value specified in .model3.json on `CubismUserModel::LoadMotion()`.
* Change the threshold for enabling anisotropic filtering in all renderers.
* Change `CubismJson` to not use character masking.
* Resources in Vulkan have been changed to support multi-buffering.
* Change the `ACubismMotion::UpdateFadeWeight()` function to return an error code of `-1` when the argument is NULL. by [@Coloryr](https://github.com/Live2D/CubismNativeFramework/pull/56)
* Change the access level of the private members in the `CubismModelSettingJson` class to protected.
* Change the value of pi used in the calculation of `CubismBreath::UpdateParameters()` to `CubismMath.PI`.

### Deprecated

* Deprecate the following elements because a priority value is not actually used during expression motion playback:
* `CubismExpressionMotionManager::_currentPriority`
* `CubismExpressionMotionManager::_reservePriority`
* `CubismExpressionMotionManager::StartMotionPriority()`
* `CubismExpressionMotionManager::GetCurrentPriority()`
* `CubismExpressionMotionManager::GetReservePriority()`
* `CubismExpressionMotionManager::SetReservePriority()`

Please use the `CubismMotionQueueManager::StartMotion()` instead of `CubismExpressionMotionManager::StartMotionPriority()`.

### Fixed

* Fix an issue where already registered keys could be added on `csmMap.appendKey()`.
* Fix JSON parser to work even when locale is set.
* Fix memory leak in Vulkan.
* Fix the Anisotropy processing of Vulkan to match the Sample.
* Fix D3D11 anisotropic filtering to allow filtering with the specified settings.
* Fix anisotropic filtering in D3D9.
* Improved the rendering quality by setting the appropriate filter settings.
* Anisotropic filtering is now properly processed.
* Fix a bug that caused an error when playing CubismExpresionMotion with CubismMotionQueueManager::StartMotion().
* Fix a potential problem with division by 0 when a pose fade time is set to 0 seconds.
* Fix an issue where calling `+=` on `csmString` would throw an exception if the character count exceeded 64.

### Removed

* Remove the Cocos2d-x renderer.


## [5-r.1] - 2024-03-26

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


[5-r.2]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1...5-r.2
[5-r.1]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1-beta.4...5-r.1
[5-r.1-beta.4]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1-beta.3...5-r.1-beta.4
[5-r.1-beta.3]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1-beta.2...5-r.1-beta.3
Expand Down
40 changes: 20 additions & 20 deletions TRANSLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Please see the table below for progress.
| Module | Path | Status |
| ---: | :--- | :---: |
| Framework Systems | ./src/ | Done |
| Effect | ./src/Effect/ | - |
| Id | ./src/Id/ | - |
| Math | ./src/Math/ | - |
| Model | ./src/Model/ | - |
| Effect | ./src/Effect/ | Done |
| Id | ./src/Id/ | Done |
| Math | ./src/Math/ | Done |
| Model | ./src/Model/ | Done |
| Physics | ./src/Physics/ | - |
| Utils | ./src/Utils/ | - |
| Rendering | ./src/Rendering/ | - |
Expand All @@ -36,37 +36,37 @@ Please see the table below for progress.

| File | Completion Date |
| :--- | :--- |
| ./Effect/CubismBreath.hpp | - |
| ./Effect/CubismEyeBlink.hpp | - |
| ./Effect/CubismPose.hpp | - |
| ./Effect/CubismBreath.hpp | 2024-10-08 |
| ./Effect/CubismEyeBlink.hpp | 2024-10-08 |
| ./Effect/CubismPose.hpp | 2024-10-08 |

## Id

| File | Completion Date |
| :--- | :--- |
| ./Id/CubismId.hpp | - |
| ./Id/CubismIdManager.hpp | - |
| ./Id/CubismId.hpp | 2024-10-08 |
| ./Id/CubismIdManager.hpp | 2024-10-08 |

## Math

| File | Completion Date |
| :--- | :--- |
| ./Math/CubismMath.hpp | - |
| ./Math/CubismMatrix44.hpp | - |
| ./Math/CubismModelMatrix.hpp | - |
| ./Math/CubismTargetPoint.hpp | - |
| ./Math/CubismVector2.hpp | - |
| ./Math/CubismViewMatrix.hpp | - |
| ./Math/CubismMath.hpp | 2024-10-08 |
| ./Math/CubismMatrix44.hpp | 2024-10-08 |
| ./Math/CubismModelMatrix.hpp | 2024-10-08 |
| ./Math/CubismTargetPoint.hpp | 2024-10-08 |
| ./Math/CubismVector2.hpp | 2024-10-08 |
| ./Math/CubismViewMatrix.hpp | 2024-10-08 |

## Model

| File | Completion Date |
| :--- | :--- |
| ./Model/CubismMoc.hpp | - |
| ./Model/CubismModel.hpp | - |
| ./Model/CubismModelUserData.hpp | - |
| ./Model/CubismModelUserDataJson.hpp | - |
| ./Model/CubismUserModel.hpp | - |
| ./Model/CubismMoc.hpp | 2024-10-08 |
| ./Model/CubismModel.hpp | 2024-10-08 |
| ./Model/CubismModelUserData.hpp | 2024-10-08 |
| ./Model/CubismModelUserDataJson.hpp | 2024-10-08 |
| ./Model/CubismUserModel.hpp | 2024-10-08 |

## Physics

Expand Down
19 changes: 19 additions & 0 deletions src/CubismCdiJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const csmChar* Version = "Version";
const csmChar* Parameters = "Parameters";
const csmChar* ParameterGroups = "ParameterGroups";
const csmChar* Parts = "Parts";
const csmChar* CombinedParameters = "CombinedParameters";
const csmChar* Id = "Id";
const csmChar* GroupId = "GroupId";
const csmChar* Name = "Name";
Expand Down Expand Up @@ -50,6 +51,12 @@ csmBool CubismCdiJson::IsExistParts() const
return !node.IsNull() && !node.IsError();
}

csmBool CubismCdiJson::IsExistCombinedParameters() const
{
Utils::Value& node = (_json->GetRoot()[CombinedParameters]);
return !node.IsNull() && !node.IsError();
}

// パラメータについて
csmInt32 CubismCdiJson::GetParametersCount()
{
Expand Down Expand Up @@ -111,4 +118,16 @@ const csmChar* CubismCdiJson::GetPartsName(csmInt32 index)
return _json->GetRoot()[Parts][index][Name].GetRawString();
}

// 結合パラメータについて
csmInt32 CubismCdiJson::GetCombinedParametersCount()
{
if (!IsExistCombinedParameters()) return 0;
return _json->GetRoot()[CombinedParameters].GetSize();
}

const csmVector<Utils::Value*>* CubismCdiJson::GetCombinedParameters(csmInt32 index)
{
return _json->GetRoot()[CombinedParameters][index].GetVector();
}

}}}
22 changes: 22 additions & 0 deletions src/CubismCdiJson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ class CubismCdiJson : public CubismJsonHolder
*/
const csmChar* GetPartsName(csmInt32 index);

/**
* Returns the number of combined parameters.
*
* @return Number of combined parameters
*/
csmInt32 GetCombinedParametersCount();

/**
* Returns the pair list of the combined parameters.
*
* @param index Index to the desired combined parameter
*
* @return Pair list of the combined parameter
*/
const csmVector<Utils::Value*>* GetCombinedParameters(csmInt32 index);

private:
/**
Expand All @@ -148,6 +163,13 @@ class CubismCdiJson : public CubismJsonHolder
* @return true if parts exist; otherwise false.
*/
csmBool IsExistParts() const;

/**
* Returns whether the combined parameters exist in the Display Information File.
*
* @return true if combined parameters exist; otherwise false.
*/
csmBool IsExistCombinedParameters() const;
};

}}}
2 changes: 1 addition & 1 deletion src/CubismJsonHolder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Live2D { namespace Cubism { namespace Framework {
*
* @return true if valid; otherwise false
*/
csmBool IsValid()
csmBool IsValid() const
{
return _json;
}
Expand Down
2 changes: 1 addition & 1 deletion src/CubismModelSettingJson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class CubismModelSettingJson : public ICubismModelSetting, public CubismJsonHold
*/
CubismIdHandle GetLipSyncParameterId(csmInt32 index);

private:
protected:

enum FrequentNode
{
Expand Down
3 changes: 2 additions & 1 deletion src/Effect/CubismBreath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "CubismBreath.hpp"
#include <math.h>
#include "Math/CubismMath.hpp"

namespace Live2D { namespace Cubism { namespace Framework {

Expand Down Expand Up @@ -41,7 +42,7 @@ void CubismBreath::UpdateParameters(CubismModel* model, csmFloat32 deltaTimeSeco
{
_currentTime += deltaTimeSeconds;

const csmFloat32 t = _currentTime * 2.0f * 3.14159f;
const csmFloat32 t = _currentTime * 2.0f * CubismMath::Pi;

for (csmUint32 i = 0; i < _breathParameters.GetSize(); ++i)
{
Expand Down
81 changes: 30 additions & 51 deletions src/Effect/CubismBreath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,18 @@
namespace Live2D { namespace Cubism { namespace Framework {

/**
* @brief 呼吸機能
*
* 呼吸機能を提供する。
* Handles the breathing effect
*/
class CubismBreath
{
public:
/**
* @brief 呼吸のパラメータ情報
*
* 呼吸のパラメータ情報。
* Data attached to the parameters of breathing
*/
struct BreathParameterData
{
/**
* @brief コンストラクタ
*
* コンストラクタ。
* Constructor
*/
BreathParameterData()
: ParameterId(NULL)
Expand All @@ -42,15 +36,16 @@ class CubismBreath
{ }

/**
* @brief コンストラクタ
* Constructor<br>
* Sets the data.
*
* コンストラクタ。
* @param parameterId ID of the breath parameter to attach
* @param offset offset of the sine wave
* @param peak peak value of the sine wave
* @param cycle cycle of the sine wave
* @param weight weight of the parameter
*
* @param[in] parameterId 呼吸をひもづけるパラメータID
* @param[in] offset 呼吸を正弦波としたときの、波のオフセット
* @param[in] peak 呼吸を正弦波としたときの、波の高さ
* @param[in] cycle 呼吸を正弦波としたときの、波の周期
* @param[in] weight パラメータへの重み
* @note The cyclic motion of breathing is set entirely by sine waves.
*/
BreathParameterData(CubismIdHandle parameterId, csmFloat32 offset, csmFloat32 peak, csmFloat32 cycle, csmFloat32 weight)
: ParameterId(parameterId)
Expand All @@ -60,77 +55,61 @@ class CubismBreath
, Weight(weight)
{ }

CubismIdHandle ParameterId; ///< 呼吸をひもづけるパラメータID
csmFloat32 Offset; ///< 呼吸を正弦波としたときの、波のオフセット
csmFloat32 Peak; ///< 呼吸を正弦波としたときの、波の高さ
csmFloat32 Cycle; ///< 呼吸を正弦波としたときの、波の周期
csmFloat32 Weight; ///< パラメータへの重み
CubismIdHandle ParameterId; ///< ID of the breath parameter to attach
csmFloat32 Offset; ///< Offset of the sine wave
csmFloat32 Peak; ///< Peak value of the sine wave
csmFloat32 Cycle; ///< Cycle of the sine wave
csmFloat32 Weight; ///< Weight of the parameter
};

/**
* @brief インスタンスの作成
* Makes an instance of CubismBreath.
*
* インスタンスを作成する。
* @return Maked instance of CubismBreath
*/
static CubismBreath* Create();


/**
* @brief インスタンスの破棄
* Destroys an instance of CubismBreath.
*
* インスタンスを破棄する。
*
* @param[in] instance 対象のCubismBreath
* @param instance Instance of CubismBreath to destroy
*/
static void Delete(CubismBreath* instance);

/**
* @brief 呼吸のパラメータのひもづけ
*
* 呼吸のパラメータをひもづける。
* Attaches the parameters of breathing.
*
* @param[in] breathParameters 呼吸をひもづけたいパラメータのリスト
* @param breathParameters Collection of breathing parameters to attach
*/
void SetParameters(const csmVector<BreathParameterData>& breathParameters);


/**
* @brief 呼吸にひもづいているパラメータの取得
*
* 呼吸にひもづいているパラメータを取得する。
* Returns parameters attached to breathing.
*
* @return 呼吸にひもづいているパラメータのリスト
* @return Attached collection of breathing parameters
*/
const csmVector<BreathParameterData>& GetParameters() const;


/**
* @brief モデルのパラメータの更新
* Updates the parameters of the model.
*
* モデルのパラメータを更新する。
* @param model Model to update
* @param deltaTimeSeconds Current time in seconds
*
* @param[in] model 対象のモデル
* @param[in] deltaTimeSeconds デルタ時間[秒]
* @note Execute after making an instance with #Create() and binding parameters with #setParameters().
*/
void UpdateParameters(CubismModel* model, csmFloat32 deltaTimeSeconds);

private:
/**
* @brief コンストラクタ
*
* コンストラクタ。
*/
CubismBreath();

/**
* @brief デストラクタ
*
* デストラクタ。
*/
virtual ~CubismBreath();

csmVector<BreathParameterData> _breathParameters; ///< 呼吸にひもづいているパラメータのリスト
csmFloat32 _currentTime; ///< 積算時間[秒]
csmVector<BreathParameterData> _breathParameters;
csmFloat32 _currentTime;
};

}}}
Loading

0 comments on commit 0b5951b

Please sign in to comment.