Upgrade to Cubism 4 Release R5.1. No incompatible API changes.
authorAdrian Iain Lam <adrianiainlam@users.noreply.github.com>
Tue, 11 Oct 2022 19:40:58 +0000 (20:40 +0100)
committerAdrian Iain Lam <adrianiainlam@users.noreply.github.com>
Tue, 11 Oct 2022 19:40:58 +0000 (20:40 +0100)
README.md
example/build.sh
example/demo.patch
example/generate_patch.sh

index 0a1a8d6..a734ed0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -50,17 +50,17 @@ if you don't have C++17 support.
 
 To build the example program:
 
-4. Download "Cubism 4 SDK for Native R4" from the Live2D website:
+4. Download "Cubism 4 SDK for Native R5.1" from the Live2D website:
    <https://www.live2d.com/en/download/cubism-sdk/download-native/>.
 
-   Extract the archive -- put the "CubismSdkForNative-4-r.4" folder under
+   Extract the archive -- put the "CubismSdkForNative-4-r.5.1" folder under
    the "example" folder of this repo.
 
    Note: The Cubism SDK is the property of Live2D and is not part of this
    project. You must agree to Live2D's license agreements to use it.
 
 5. Go into the
-   "example/CubismSdkForNative-4-r.4/Samples/OpenGL/thirdParty/scripts"
+   "example/CubismSdkForNative-4-r.5.1/Samples/OpenGL/thirdParty/scripts"
    directory and run
 
        ./setup_glew_glfw
index 25dcfb2..b1b789e 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh -e
 
 mkdir -p demo_build
-cp -r CubismSdkForNative-4-r.4/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_build/
+cp -r CubismSdkForNative-4-r.5.1/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_build/
 patch -d demo_build -p2 < demo.patch
 ./demo_build/scripts/make_gcc
index cb40cc9..0bd80ae 100644 (file)
@@ -1,12 +1,12 @@
 diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt
---- ./demo_clean/CMakeLists.txt        2022-01-02 01:49:06.929909588 +0000
-+++ ./demo_dev/CMakeLists.txt  2022-01-02 01:49:31.334289944 +0000
+--- ./demo_clean/CMakeLists.txt        2022-09-14 12:08:43.000000000 +0100
++++ ./demo_dev/CMakeLists.txt  2022-10-11 20:33:48.181071509 +0100
 @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.16)
  # Set app name.
  set(APP_NAME Demo)
  # Set directory paths.
 -set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
-+set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../CubismSdkForNative-4-r.4)
++set(SDK_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../CubismSdkForNative-4-r.5.1)
  set(CORE_PATH ${SDK_ROOT_PATH}/Core)
  set(FRAMEWORK_PATH ${SDK_ROOT_PATH}/Framework)
  set(THIRD_PARTY_PATH ${SDK_ROOT_PATH}/Samples/OpenGL/thirdParty)
@@ -54,7 +54,7 @@ diff -pruN --exclude build ./demo_clean/CMakeLists.txt ./demo_dev/CMakeLists.txt
  # Copy resource directory to build directory.
  add_custom_command(
 diff -pruN --exclude build ./demo_clean/scripts/make_gcc ./demo_dev/scripts/make_gcc
---- ./demo_clean/scripts/make_gcc      2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/scripts/make_gcc      2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/scripts/make_gcc        2021-04-28 12:18:50.948333190 +0100
 @@ -5,41 +5,9 @@ set -ue
  SCRIPT_PATH=$(cd $(dirname $0) && pwd)
@@ -101,7 +101,7 @@ diff -pruN --exclude build ./demo_clean/scripts/make_gcc ./demo_dev/scripts/make
 +  -D CMAKE_BUILD_TYPE=Release
 +cd "$BUILD_PATH" && make -j4
 diff -pruN --exclude build ./demo_clean/src/CMakeLists.txt ./demo_dev/src/CMakeLists.txt
---- ./demo_clean/src/CMakeLists.txt    2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/CMakeLists.txt    2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/CMakeLists.txt      2021-04-28 12:21:56.795134807 +0100
 @@ -1,49 +1,22 @@
 -if (CSM_MINIMUM_DEMO)
@@ -167,9 +167,9 @@ diff -pruN --exclude build ./demo_clean/src/CMakeLists.txt ./demo_dev/src/CMakeL
 +    ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
 +)
 diff -pruN --exclude build ./demo_clean/src/LAppDefine.cpp ./demo_dev/src/LAppDefine.cpp
---- ./demo_clean/src/LAppDefine.cpp    2022-01-02 01:49:06.929909588 +0000
-+++ ./demo_dev/src/LAppDefine.cpp      2021-04-28 12:18:50.948333190 +0100
-@@ -64,11 +64,11 @@ namespace LAppDefine {
+--- ./demo_clean/src/LAppDefine.cpp    2022-09-14 12:08:43.000000000 +0100
++++ ./demo_dev/src/LAppDefine.cpp      2022-10-11 20:35:25.046676464 +0100
+@@ -65,11 +65,11 @@ namespace LAppDefine {
      const csmInt32 PriorityForce = 3;
  
      // デバッグ用ログの表示オプション
@@ -184,7 +184,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppDefine.cpp ./demo_dev/src/LAppDe
      // デフォルトのレンダーターゲットサイズ
      const csmInt32 RenderTargetWidth = 1900;
 diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LAppDelegate.cpp
---- ./demo_clean/src/LAppDelegate.cpp  2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/LAppDelegate.cpp  2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/LAppDelegate.cpp    2021-04-28 12:18:50.948333190 +0100
 @@ -45,7 +45,8 @@ void LAppDelegate::ReleaseInstance()
      s_instance = NULL;
@@ -328,7 +328,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.cpp ./demo_dev/src/LApp
  
  Csm::csmVector<string> LAppDelegate::Split(const std::string& baseString, char delimiter)
 diff -pruN --exclude build ./demo_clean/src/LAppDelegate.hpp ./demo_dev/src/LAppDelegate.hpp
---- ./demo_clean/src/LAppDelegate.hpp  2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/LAppDelegate.hpp  2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/LAppDelegate.hpp    2021-04-28 12:18:50.948333190 +0100
 @@ -40,7 +40,8 @@ public:
      /**
@@ -404,8 +404,8 @@ diff -pruN --exclude build ./demo_clean/src/LAppDelegate.hpp ./demo_dev/src/LApp
 -
 -};
 diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src/LAppLive2DManager.cpp
---- ./demo_clean/src/LAppLive2DManager.cpp     2022-01-02 01:49:06.929909588 +0000
-+++ ./demo_dev/src/LAppLive2DManager.cpp       2021-04-28 12:24:45.405646016 +0100
+--- ./demo_clean/src/LAppLive2DManager.cpp     2022-09-14 12:08:43.000000000 +0100
++++ ./demo_dev/src/LAppLive2DManager.cpp       2022-10-11 20:35:42.982973401 +0100
 @@ -52,11 +52,11 @@ void LAppLive2DManager::ReleaseInstance(
  
  LAppLive2DManager::LAppLive2DManager()
@@ -448,7 +448,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
  }
  
  void LAppLive2DManager::OnUpdate() const
-@@ -127,21 +107,24 @@ void LAppLive2DManager::OnUpdate() const
+@@ -127,10 +107,10 @@ void LAppLive2DManager::OnUpdate() const
      int width, height;
      glfwGetWindowSize(LAppDelegate::GetInstance()->GetWindow(), &width, &height);
  
@@ -458,7 +458,9 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
      {
 -        CubismMatrix44 projection;
          LAppModel* model = GetModel(i);
-         if (model->GetModel()->GetCanvasWidth() > 1.0f && width < height)
+         if (model->GetModel() == NULL)
+@@ -143,12 +123,15 @@ void LAppLive2DManager::OnUpdate() const
          {
              // 横に長いモデルを縦長ウィンドウに表示する際モデルの横サイズでscaleを算出する
              model->GetModelMatrix()->SetWidth(2.0f);
@@ -476,7 +478,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
  
          // 必要があればここで乗算
          if (_viewMatrix != NULL)
-@@ -158,30 +141,14 @@ void LAppLive2DManager::OnUpdate() const
+@@ -165,30 +148,14 @@ void LAppLive2DManager::OnUpdate() const
      }
  }
  
@@ -511,7 +513,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
      _models[0]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
  
      /*
-@@ -203,7 +170,7 @@ void LAppLive2DManager::ChangeScene(Csm:
+@@ -210,7 +177,7 @@ void LAppLive2DManager::ChangeScene(Csm:
  
  #if defined(USE_RENDER_TARGET) || defined(USE_MODEL_RENDER_TARGET)
          // モデル個別にαを付けるサンプルとして、もう1体モデルを作成し、少し位置をずらす
@@ -520,7 +522,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
          _models[1]->LoadAssets(modelPath.c_str(), modelJsonName.c_str());
          _models[1]->GetModelMatrix()->TranslateX(0.2f);
  #endif
-@@ -232,3 +199,20 @@ void LAppLive2DManager::SetViewMatrix(Cu
+@@ -239,3 +206,20 @@ void LAppLive2DManager::SetViewMatrix(Cu
          _viewMatrix->GetArray()[i] = m->GetArray()[i];
      }
  }
@@ -542,7 +544,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.cpp ./demo_dev/src
 +    _translateY = translateY;
 +}
 diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.hpp ./demo_dev/src/LAppLive2DManager.hpp
---- ./demo_clean/src/LAppLive2DManager.hpp     2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/LAppLive2DManager.hpp     2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/LAppLive2DManager.hpp       2021-04-28 12:18:50.948333190 +0100
 @@ -6,12 +6,15 @@
   */
@@ -621,7 +623,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppLive2DManager.hpp ./demo_dev/src
 +    float _translateY;
  };
 diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppModel.cpp
---- ./demo_clean/src/LAppModel.cpp     2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/LAppModel.cpp     2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/LAppModel.cpp       2021-04-28 12:26:56.699586813 +0100
 @@ -21,6 +21,10 @@
  #include "LAppTextureManager.hpp"
@@ -666,7 +668,20 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
  }
  
  LAppModel::~LAppModel()
-@@ -190,7 +196,7 @@ void LAppModel::SetupModel(ICubismModelS
+@@ -96,12 +102,6 @@ void LAppModel::LoadAssets(const csmChar
+     SetupModel(setting);
+-    if (_model == NULL)
+-    {
+-        LAppPal::PrintLog("Failed to LoadAssets().");
+-        return;
+-    }
+-
+     CreateRenderer();
+     SetupTextures();
+@@ -196,7 +196,7 @@ void LAppModel::SetupModel(ICubismModelS
          breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamAngleY, 0.0f, 8.0f, 3.5345f, 0.5f));
          breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamAngleZ, 0.0f, 10.0f, 5.5345f, 0.5f));
          breathParameters.PushBack(CubismBreath::BreathParameterData(_idParamBodyAngleX, 0.0f, 4.0f, 15.5345f, 0.5f));
@@ -675,7 +690,20 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
  
          _breath->SetParameters(breathParameters);
      }
-@@ -335,83 +341,118 @@ void LAppModel::Update()
+@@ -229,12 +229,6 @@ void LAppModel::SetupModel(ICubismModelS
+         }
+     }
+-    if (_modelSetting == NULL || _modelMatrix == NULL)
+-    {
+-        LAppPal::PrintLog("Failed to SetupModel().");
+-        return;
+-    }
+-
+     //Layout
+     csmMap<csmString, csmFloat32> layout;
+     _modelSetting->GetLayoutMap(layout);
+@@ -347,83 +341,118 @@ void LAppModel::Update()
      const csmFloat32 deltaTimeSeconds = LAppPal::GetDeltaTime();
      _userTimeSeconds += deltaTimeSeconds;
  
@@ -689,13 +717,13 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
 -    //-----------------------------------------------------------------
 -    _model->LoadParameters(); // 前回セーブされた状態をロード
 -    if (_motionManager->IsFinished())
--    {
++    if (_tracker)
+     {
 -        // モーションの再生がない場合、待機モーションの中からランダムで再生する
 -        StartRandomMotion(MotionGroupIdle, PriorityIdle);
 -    }
 -    else
-+    if (_tracker)
-     {
+-    {
 -        motionUpdated = _motionManager->UpdateMotion(_model, deltaTimeSeconds); // モーションを更新
 -    }
 -    _model->SaveParameters(); // 状態を保存
@@ -803,15 +831,10 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
 +        {
 +            _model->SetParameterValue(idMan->GetId(_("ParamEyeROpen")), 1);
 +        }
--        // 状態更新/RMS値取得
--        _wavFileHandler.Update(deltaTimeSeconds);
--        value = _wavFileHandler.GetRms();
--        for (csmUint32 i = 0; i < _lipSyncIds.GetSize(); ++i)
++
++
 +        if (params.useLipSync && _lipSync)
-         {
--            _model->AddParameterValue(_lipSyncIds[i], value, 0.8f);
++        {
 +            csmFloat32 value = params.lipSyncParam; // 0 to 1
 +
 +            for (csmUint32 i = 0; i < _lipSyncIds.GetSize(); ++i)
@@ -829,16 +852,21 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
 +        {
 +            std::string key = entry.first;
 +            double val = entry.second;
-+
+-        // 状態更新/RMS値取得
+-        _wavFileHandler.Update(deltaTimeSeconds);
+-        value = _wavFileHandler.GetRms();
 +            if (key != "ParamEyeLOpen" && key != "ParamEyeROpen" &&
 +                key != "ParamMouthOpenY")
 +            {
 +                _model->SetParameterValue(idMan->GetId(_(key)), val);
 +            }
 +        }
-+
+-        for (csmUint32 i = 0; i < _lipSyncIds.GetSize(); ++i)
 +        if (params.autoBreath && _breath)
-+        {
+         {
+-            _model->AddParameterValue(_lipSyncIds[i], value, 0.8f);
 +            // Note: _model->LoadParameters and SaveParameters is needed
 +            // before - see above.
 +            _breath->UpdateParameters(_model, deltaTimeSeconds);
@@ -854,7 +882,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
      // ポーズの設定
      if (_pose != NULL)
      {
-@@ -480,7 +521,6 @@ CubismMotionQueueEntryHandle LAppModel::
+@@ -492,7 +521,6 @@ CubismMotionQueueEntryHandle LAppModel::
      {
          csmString path = voice;
          path = _modelHomeDir + path;
@@ -862,7 +890,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
      }
  
      if (_debugMode)
-@@ -632,3 +672,42 @@ Csm::Rendering::CubismOffscreenFrame_Ope
+@@ -644,3 +672,42 @@ Csm::Rendering::CubismOffscreenFrame_Ope
  {
      return _renderBuffer;
  }
@@ -906,7 +934,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.cpp ./demo_dev/src/LAppMod
 +}
 +
 diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppModel.hpp
---- ./demo_clean/src/LAppModel.hpp     2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/LAppModel.hpp     2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/LAppModel.hpp       2021-04-28 12:27:55.836457680 +0100
 @@ -13,7 +13,7 @@
  #include <Type/csmRectF.hpp>
@@ -977,7 +1005,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppModel.hpp ./demo_dev/src/LAppMod
  
  
 diff -pruN --exclude build ./demo_clean/src/LAppPal.cpp ./demo_dev/src/LAppPal.cpp
---- ./demo_clean/src/LAppPal.cpp       2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/LAppPal.cpp       2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/LAppPal.cpp 2021-04-28 12:18:50.952333251 +0100
 @@ -6,6 +6,7 @@
   */
@@ -1008,7 +1036,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppPal.cpp ./demo_dev/src/LAppPal.c
      }
      file.read(buf, size);
 diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.cpp ./demo_dev/src/LAppTextureManager.cpp
---- ./demo_clean/src/LAppTextureManager.cpp    2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/LAppTextureManager.cpp    2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/LAppTextureManager.cpp      2021-04-28 12:18:50.952333251 +0100
 @@ -96,6 +96,46 @@ LAppTextureManager::TextureInfo* LAppTex
  
@@ -1058,7 +1086,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.cpp ./demo_dev/sr
  {
      for (Csm::csmUint32 i = 0; i < _textures.GetSize(); i++)
 diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.hpp ./demo_dev/src/LAppTextureManager.hpp
---- ./demo_clean/src/LAppTextureManager.hpp    2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/LAppTextureManager.hpp    2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/LAppTextureManager.hpp      2021-04-28 12:18:50.952333251 +0100
 @@ -72,6 +72,8 @@ public:
      */
@@ -1070,7 +1098,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppTextureManager.hpp ./demo_dev/sr
      * @brief 画像の解放
      *
 diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView.cpp
---- ./demo_clean/src/LAppView.cpp      2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/LAppView.cpp      2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/LAppView.cpp        2021-04-28 12:18:50.952333251 +0100
 @@ -13,7 +13,6 @@
  #include "LAppLive2DManager.hpp"
@@ -1247,7 +1275,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.cpp ./demo_dev/src/LAppView
 -    }
  }
 diff -pruN --exclude build ./demo_clean/src/LAppView.hpp ./demo_dev/src/LAppView.hpp
---- ./demo_clean/src/LAppView.hpp      2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/LAppView.hpp      2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/LAppView.hpp        2021-04-28 12:18:50.952333251 +0100
 @@ -14,7 +14,6 @@
  #include "CubismFramework.hpp"
@@ -1303,7 +1331,7 @@ diff -pruN --exclude build ./demo_clean/src/LAppView.hpp ./demo_dev/src/LAppView
      // レンダリング先を別ターゲットにする方式の場合に使用
      LAppSprite* _renderSprite;                                  ///< モードによっては_renderBufferのテクスチャを描画
 diff -pruN --exclude build ./demo_clean/src/main.cpp ./demo_dev/src/main.cpp
---- ./demo_clean/src/main.cpp  2022-01-02 01:49:06.929909588 +0000
+--- ./demo_clean/src/main.cpp  2022-09-14 12:08:43.000000000 +0100
 +++ ./demo_dev/src/main.cpp    2021-04-28 12:28:55.845339613 +0100
 @@ -5,18 +5,188 @@
   * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
index 73bb563..1c822b6 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
 
 mkdir -p demo_clean
-cp -p -r CubismSdkForNative-4-r.4/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_clean/
+cp -p -r CubismSdkForNative-4-r.5.1/Samples/OpenGL/Demo/proj.linux.cmake/* ./demo_clean/
 diff -pruN --exclude build ./demo_clean ./demo_dev > ./demo.patch