Skip to content

Commit bebb8e0

Browse files
Update to Cubism 5 SDK for Native R1 beta4
1 parent 19d1875 commit bebb8e0

28 files changed

+284
-161
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ 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.4] - 2024-01-25
9+
10+
### Fixed
11+
12+
* Fix memory leak in DX11.
13+
* Fix an issue where models with a specific number of masks could not be drawn correctly.
14+
* Fix to check for null when reading json.
15+
* Fix an issue that caused some graphics drivers to not render correctly in Vulkan.
16+
* Fix errors related to semaphore waiting stages.
17+
* Fix errors that occurs when building with x86 in vulkan.
18+
19+
820
## [5-r.1-beta.3] - 2023-10-12
921

1022
### Added
@@ -326,6 +338,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
326338
* Fix invalid expressions of `CubismCdiJson`.
327339

328340

341+
[5-r.1-beta.4]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1-beta.3...5-r.1-beta.4
329342
[5-r.1-beta.3]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1-beta.2...5-r.1-beta.3
330343
[5-r.1-beta.2]: https://github.com/Live2D/CubismNativeFramework/compare/5-r.1-beta.1...5-r.1-beta.2
331344
[5-r.1-beta.1]: https://github.com/Live2D/CubismNativeFramework/compare/4-r.7...5-r.1-beta.1

src/CubismFramework.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ csmBool CubismFramework::StartUp(ICubismAllocator* allocator, const Option* opti
8383
const csmUint32 major = static_cast<csmUint32>((version & 0xFF000000) >> 24);
8484
const csmUint32 minor = static_cast<csmUint32>((version & 0x00FF0000) >> 16);
8585
const csmUint32 patch = static_cast<csmUint32>((version & 0x0000FFFF));
86-
const csmUint32 vesionNumber = version;
86+
const csmUint32 versionNumber = version;
8787

88-
CubismLogInfo("Live2D Cubism Core version: %02d.%02d.%04d (%d)", major, minor, patch, vesionNumber);
88+
CubismLogInfo("Live2D Cubism Core version: %02d.%02d.%04d (%d)", major, minor, patch, versionNumber);
8989
}
9090

9191
CubismLogInfo("CubismFramework::StartUp() is complete.");

src/Effect/CubismPose.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,12 @@ CubismPose::~CubismPose()
7070

7171
CubismPose* CubismPose::Create(const csmByte* pose3json, csmSizeInt size)
7272
{
73-
CubismPose* ret = CSM_NEW CubismPose();
7473
Utils::CubismJson* json = Utils::CubismJson::Create(pose3json, size);
74+
if (!json)
75+
{
76+
return NULL;
77+
}
78+
CubismPose* ret = CSM_NEW CubismPose();
7579
Utils::Value& root = json->GetRoot();
7680

7781
// フェード時間の指定

src/Model/CubismModelUserData.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ void CubismModelUserData::ParseUserData(const csmByte* buffer, const csmSizeInt
4747
{
4848
CubismModelUserDataJson* json = CSM_NEW CubismModelUserDataJson(buffer, size);
4949

50+
if (!json->IsValid())
51+
{
52+
CSM_DELETE(json);
53+
return;
54+
}
55+
5056
const ModelUserDataType typeOfArtMesh = CubismFramework::GetIdManager()->GetId(ArtMesh);
5157

5258
const csmUint32 nodeCount = json->GetUserDataCount();

src/Model/CubismUserModel.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,41 @@ void CubismUserModel::LoadModel(const csmByte* buffer, csmSizeInt size, csmBool
102102

103103
ACubismMotion* CubismUserModel::LoadExpression(const csmByte* buffer, csmSizeInt size, const csmChar* name)
104104
{
105+
if (!buffer)
106+
{
107+
CubismLogError("Failed to LoadExpression().");
108+
return NULL;
109+
}
110+
105111
return CubismExpressionMotion::Create(buffer, size);
106112
}
107113

108114
void CubismUserModel::LoadPose(const csmByte* buffer, csmSizeInt size)
109115
{
110116
_pose = CubismPose::Create(buffer, size);
117+
if (!_pose)
118+
{
119+
CubismLogError("Failed to LoadPose().");
120+
}
111121
}
112122

113123
void CubismUserModel::LoadPhysics(const csmByte* buffer, csmSizeInt size)
114124
{
115125
_physics = CubismPhysics::Create(buffer, size);
126+
if (!_physics)
127+
{
128+
CubismLogError("Failed to LoadPhysics().");
129+
}
116130
}
117131

118132
void CubismUserModel::LoadUserData(const csmByte* buffer, csmSizeInt size)
119133
{
134+
if (!buffer)
135+
{
136+
CubismLogError("Failed to LoadUserData().");
137+
return;
138+
}
139+
120140
_modelUserData = CubismModelUserData::Create(buffer, size);
121141
}
122142
csmBool CubismUserModel::IsHit(CubismIdHandle drawableId, csmFloat32 pointX, csmFloat32 pointY)
@@ -170,6 +190,11 @@ csmBool CubismUserModel::IsHit(CubismIdHandle drawableId, csmFloat32 pointX, csm
170190

171191
ACubismMotion* CubismUserModel::LoadMotion(const csmByte* buffer, csmSizeInt size, const csmChar* name, ACubismMotion::FinishedMotionCallback onFinishedMotionHandler)
172192
{
193+
if (!buffer)
194+
{
195+
CubismLogError("Failed to LoadMotion().");
196+
return NULL;
197+
}
173198
return CubismMotion::Create(buffer, size, onFinishedMotionHandler);
174199
}
175200

src/Motion/CubismExpressionMotion.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ csmFloat32 CubismExpressionMotion::GetFadeWeight()
198198
void CubismExpressionMotion::Parse(const csmByte* buffer, csmSizeInt size)
199199
{
200200
Utils::CubismJson* json = Utils::CubismJson::Create(buffer, size);
201+
if (!json)
202+
{
203+
return;
204+
}
205+
201206
Utils::Value& root = json->GetRoot();
202207

203208
SetFadeInTime(root[ExpressionKeyFadeIn].ToFloat(DefaultFadeTime)); // フェードイン

src/Motion/CubismMotion.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,12 @@ void CubismMotion::Parse(const csmByte* motionJson, const csmSizeInt size)
527527

528528
CubismMotionJson* json = CSM_NEW CubismMotionJson(motionJson, size);
529529

530+
if (!json->IsValid())
531+
{
532+
CSM_DELETE(json);
533+
return;
534+
}
535+
530536
_motionData->Duration = json->GetMotionDuration();
531537
_motionData->Loop = json->IsMotionLoop();
532538
_motionData->CurveCount = json->GetMotionCurveCount();

src/Rendering/Cocos2d/CubismRenderer_Cocos2dx.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,9 @@ void CubismRenderer_Cocos2dx::RestoreProfile()
639639
_rendererProfile.Restore();
640640
}
641641

642-
void CubismRenderer_Cocos2dx::BindTexture(csmUint32 modelTextureNo, cocos2d::Texture2D* texture)
642+
void CubismRenderer_Cocos2dx::BindTexture(csmUint32 modelTextureIndex, cocos2d::Texture2D* texture)
643643
{
644-
_textures[modelTextureNo] = texture;
644+
_textures[modelTextureIndex] = texture;
645645
}
646646

647647
const csmMap<csmInt32, cocos2d::Texture2D*>& CubismRenderer_Cocos2dx::GetBindedTextures() const
@@ -712,9 +712,9 @@ const csmBool CubismRenderer_Cocos2dx::IsGeneratingMask() const
712712
return GetClippingContextBufferForMask() != NULL;
713713
}
714714

715-
cocos2d::Texture2D* CubismRenderer_Cocos2dx::GetBindedTexture(csmInt32 textureNo)
715+
cocos2d::Texture2D* CubismRenderer_Cocos2dx::GetBindedTexture(csmInt32 textureIndex)
716716
{
717-
return _textures[textureNo];
717+
return _textures[textureIndex];
718718
}
719719

720720
}}}}

src/Rendering/Cocos2d/CubismRenderer_Cocos2dx.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ class CubismRenderer_Cocos2dx : public CubismRenderer
170170
* @brief OpenGLテクスチャのバインド処理<br>
171171
* CubismRendererにテクスチャを設定し、CubismRenderer中でその画像を参照するためのIndex値を戻り値とする
172172
*
173-
* @param[in] modelTextureNo -> セットするモデルテクスチャの番号
173+
* @param[in] modelTextureIndex -> セットするモデルテクスチャの番号
174174
* @param[in] texture -> バックエンドテクスチャ
175175
*
176176
*/
177-
void BindTexture(csmUint32 modelTextureNo, cocos2d::Texture2D* texture);
177+
void BindTexture(csmUint32 modelTextureIndex, cocos2d::Texture2D* texture);
178178

179179
/**
180180
* @brief OpenGLにバインドされたテクスチャのリストを取得する
@@ -340,7 +340,7 @@ class CubismRenderer_Cocos2dx : public CubismRenderer
340340
*
341341
* @return バインドされたテクスチャ
342342
*/
343-
cocos2d::Texture2D* GetBindedTexture(csmInt32 textureNo);
343+
cocos2d::Texture2D* GetBindedTexture(csmInt32 textureIndex);
344344

345345

346346
csmMap<csmInt32, cocos2d::Texture2D*> _textures; ///< モデルが参照するテクスチャとレンダラでバインドしているテクスチャとのマップ

src/Rendering/Cocos2d/CubismShader_Cocos2dx.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,8 @@ void CubismShader_Cocos2dx::SetupShaderProgramForMask(CubismCommandBuffer_Cocos2
784784

785785

786786
//テクスチャ設定
787-
const csmInt32 textureNo = model.GetDrawableTextureIndex(index);
788-
cocos2d::Texture2D* texture = renderer->GetBindedTexture(textureNo);
787+
const csmInt32 textureIndex = model.GetDrawableTextureIndex(index);
788+
cocos2d::Texture2D* texture = renderer->GetBindedTexture(textureIndex);
789789
programState->setTexture(shaderSet->SamplerTexture0Location, 0, texture->getBackendTexture());
790790

791791
// 頂点配列の設定
@@ -794,8 +794,8 @@ void CubismShader_Cocos2dx::SetupShaderProgramForMask(CubismCommandBuffer_Cocos2
794794
programState->getVertexLayout()->setAttribute("a_texCoord", shaderSet->AttributeTexCoordLocation, cocos2d::backend::VertexFormat::FLOAT2, sizeof(csmFloat32) * 2, false);
795795

796796
// チャンネル
797-
const csmInt32 channelNo = renderer->GetClippingContextBufferForMask()->_layoutChannelNo;
798-
CubismRenderer::CubismTextureColor* colorChannel = renderer->GetClippingContextBufferForMask()->GetClippingManager()->GetChannelFlagAsColor(channelNo);
797+
const csmInt32 channelIndex = renderer->GetClippingContextBufferForMask()->_layoutChannelIndex;
798+
CubismRenderer::CubismTextureColor* colorChannel = renderer->GetClippingContextBufferForMask()->GetClippingManager()->GetChannelFlagAsColor(channelIndex);
799799
csmFloat32 colorFlag[4] = { colorChannel->R, colorChannel->G, colorChannel->B, colorChannel->A };
800800
programState->setUniform(shaderSet->UnifromChannelFlagLocation, colorFlag, sizeof(float) * 4);
801801

@@ -901,15 +901,15 @@ void CubismShader_Cocos2dx::SetupShaderProgramForDraw(CubismCommandBuffer_Cocos2
901901
sizeof(float) * 16);
902902

903903
// 使用するカラーチャンネルを設定
904-
const csmInt32 channelNo = renderer->GetClippingContextBufferForDraw()->_layoutChannelNo;
905-
CubismRenderer::CubismTextureColor* colorChannel = renderer->GetClippingContextBufferForDraw()->GetClippingManager()->GetChannelFlagAsColor(channelNo);
904+
const csmInt32 channelIndex = renderer->GetClippingContextBufferForDraw()->_layoutChannelIndex;
905+
CubismRenderer::CubismTextureColor* colorChannel = renderer->GetClippingContextBufferForDraw()->GetClippingManager()->GetChannelFlagAsColor(channelIndex);
906906
csmFloat32 colorFlag[4] = { colorChannel->R, colorChannel->G, colorChannel->B, colorChannel->A };
907907
programState->setUniform(shaderSet->UnifromChannelFlagLocation, colorFlag, sizeof(float) * 4);
908908
}
909909

910910
//テクスチャ設定
911-
const csmInt32 textureNo = model.GetDrawableTextureIndex(index);
912-
cocos2d::Texture2D* texture = renderer->GetBindedTexture(textureNo);
911+
const csmInt32 textureIndex = model.GetDrawableTextureIndex(index);
912+
cocos2d::Texture2D* texture = renderer->GetBindedTexture(textureIndex);
913913
programState->setTexture(shaderSet->SamplerTexture0Location, 0, texture->getBackendTexture());
914914

915915
//座標変換

0 commit comments

Comments
 (0)