Skip to content

Commit

Permalink
Merge pull request #28 from Live2D/develop
Browse files Browse the repository at this point in the history
Update to Cubism 4 SDK for Native beta2
  • Loading branch information
itoh-at-live2d-com authored Nov 14, 2019
2 parents badbaa8 + f6031b4 commit 6261f6a
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 83 deletions.
10 changes: 6 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
end_of_line = lf
# TODO: Specify character set
charset = unset
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{c,cpp,h,hpp}]
charset = utf-8-bom
12 changes: 1 addition & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
# Auto detect text files and perform LF normalization
* text=auto

# Explicitly declare files as LF
*.cpp text eol=lf
*.hpp text eol=lf
*.txt text eol=lf
*.md text eol=lf
.editorconfig text eol=lf
.gitattributes text eol=lf
*.gitignore text eol=lf
* text=auto eol=lf
33 changes: 25 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,40 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [4-beta.2] - 2019-11-14

### Added

* Add the includes to `Framework` for Linux build.

### Changed

* Refactoring `CMakeLists.txt`

### Fixed

* Fix renderer for DirectX 9 / 11.
* Add missing implementation: Check the dynamic flags.


## [4-beta.1] - 2019-09-04

### Added

- Support new Inverted Masking features.
- Add `.editorconfig` and `.gitattributes` to manage file formats.
- Add `.gitignore`.
- Add `CHANGELOG.md`.
* Support new Inverted Masking features.
* Add `.editorconfig` and `.gitattributes` to manage file formats.
* Add `.gitignore`.
* Add `CHANGELOG.md`.

### Changed

- Convert all file formats according to `.editorconfig`.
* Convert all file formats according to `.editorconfig`.

### Fixed

- Fix typo of `CubismCdiJson`.
- Fix invalid expressions of `CubismCdiJson`.
* Fix typo of `CubismCdiJson`.
* Fix invalid expressions of `CubismCdiJson`.


[4-beta.1]: https://github.com/Live2D/CubismNativeFramework/compare/0f5da4981cc636fe3892bb94d5c60137c9cf1eb1...4-beta.1
[4-beta.2]: https://github.com/Live2D/CubismNativeFramework/compare/4-beta.1...4-beta.2
[4-beta.1]: https://github.com/Live2D/CubismNativeFramework/compare/0f5da4981cc636fe3892bb94d5c60137c9cf1eb1...4-beta.
104 changes: 45 additions & 59 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,117 +1,103 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.15)

# includeパスの追加
include_directories(src)
include_directories(../Core/include)


# 各プラットフォーム共通ファイル
# 各プラットフォーム共通ファイル
set(commonfiles

src/Effect/CubismBreath.cpp
src/Effect/CubismEyeBlink.cpp
src/Effect/CubismPose.cpp

src/Id/CubismId.cpp
src/Id/CubismIdManager.cpp

src/Math/CubismMath.cpp
src/Math/CubismMatrix44.cpp
src/Math/CubismModelMatrix.cpp
src/Math/CubismTargetPoint.cpp
src/Math/CubismVector2.cpp
src/Math/CubismViewMatrix.cpp

src/Model/CubismModel.cpp
src/Model/CubismModelUserData.cpp
src/Model/CubismModelUserDataJson.cpp
src/Model/CubismUserModel.cpp
src/Model/CubismMoc.cpp

src/Motion/CubismExpressionMotion.cpp
src/Motion/CubismMotion.cpp
src/Motion/CubismMotionJson.cpp
src/Motion/CubismMotionManager.cpp
src/Motion/CubismMotionQueueEntry.cpp
src/Motion/CubismMotionQueueManager.cpp
src/Motion/ACubismMotion.cpp

src/Physics/CubismPhysicsJson.cpp
src/Physics/CubismPhysics.cpp

src/Rendering/CubismRenderer.cpp

src/Type/csmRectF.cpp
src/Type/csmString.cpp

src/Utils/CubismDebug.cpp
src/Utils/CubismJson.cpp
src/Utils/CubismString.cpp

src/CubismDefaultParameterId.cpp
src/CubismFramework.cpp
src/CubismModelSettingJson.cpp
src/CubismCdiJson.cpp

)

if (${FRAMEWORK_SOURCE} MATCHES "D3D9" )

# ここにプロジェクトに追加するソースファイルを追加 DirectX9

# アプリケーション側で設定したgl系のincludeパスをセットする
include_directories("${FRAMEWORK_DX9_INCLUDE_PATH}")

set(Framework

${commonfiles}

src/Rendering/D3D9/CubismRenderer_D3D9.cpp
src/Rendering/D3D9/CubismRenderState_D3D9.cpp
src/Rendering/D3D9/CubismShader_D3D9.cpp
src/Rendering/D3D9/CubismOffscreenSurface_D3D9.cpp
src/CubismCdiJson.cpp)

)
if(${FRAMEWORK_SOURCE} MATCHES "D3D9")
# ここにプロジェクトに追加するソースファイルを追加 DirectX9

elseif (${FRAMEWORK_SOURCE} MATCHES "D3D11" )
# アプリケーション側で設定したgl系のincludeパスをセットする
include_directories(${FRAMEWORK_DX9_INCLUDE_PATH})

# ここにプロジェクトに追加するソースファイルを追加 DirectX11
set(Framework

# アプリケーション側で設定したgl系のincludeパスをセットする
include_directories("${FRAMEWORK_DX11_INCLUDE_PATH}")
${commonfiles}

set(Framework

${commonfiles}

src/Rendering/D3D11/CubismOffscreenSurface_D3D11.cpp
src/Rendering/D3D11/CubismRenderer_D3D11.cpp
src/Rendering/D3D11/CubismRenderState_D3D11.cpp
src/Rendering/D3D11/CubismShader_D3D11.cpp
src/Rendering/D3D9/CubismRenderer_D3D9.cpp
src/Rendering/D3D9/CubismRenderState_D3D9.cpp
src/Rendering/D3D9/CubismShader_D3D9.cpp
src/Rendering/D3D9/CubismOffscreenSurface_D3D9.cpp)

)
elseif(${FRAMEWORK_SOURCE} MATCHES "D3D11")
# ここにプロジェクトに追加するソースファイルを追加 DirectX11

else ()
# アプリケーション側で設定したgl系のincludeパスをセットする
include_directories(${FRAMEWORK_DX11_INCLUDE_PATH})

# ここにプロジェクトに追加するソースファイルを追加 OpenGL
set(Framework

# アプリケーション側で設定したgl系のincludeパスをセットする
include_directories("${FRAMEWORK_GLFW_PATH}")
include_directories("${FRAMEWORK_GLEW_PATH}")
${commonfiles}

# プリプロセッサ定義の追加
add_definitions(${FRAMEWORK_DEFINITIOINS})
src/Rendering/D3D11/CubismOffscreenSurface_D3D11.cpp
src/Rendering/D3D11/CubismRenderer_D3D11.cpp
src/Rendering/D3D11/CubismRenderState_D3D11.cpp
src/Rendering/D3D11/CubismShader_D3D11.cpp)
else()
# ここにプロジェクトに追加するソースファイルを追加 OpenGL

set(Framework
# アプリケーション側で設定したgl系のincludeパスをセットする
include_directories(${FRAMEWORK_GLFW_PATH})
include_directories(${FRAMEWORK_GLEW_PATH})

${commonfiles}
# プリプロセッサ定義の追加
add_definitions(${FRAMEWORK_DEFINITIOINS})

src/Rendering/OpenGL/CubismRenderer_OpenGLES2.cpp
src/Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.cpp
set(Framework

)
${commonfiles}

endif ()
src/Rendering/OpenGL/CubismRenderer_OpenGLES2.cpp
src/Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.cpp)
endif()

# staticライブラリとして追加
add_library (Framework STATIC ${Framework})
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cubism Native Framework
# Cubism Native Framework

Live2D Cubism 4 Editorで出力したモデルをアプリケーションで利用するためのフレームワークです。

Expand Down
4 changes: 4 additions & 0 deletions src/CubismFramework.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <new>
#include "ICubismAllocator.hpp"

#ifdef linux
#include <cstdlib>
#endif

namespace Live2D { namespace Cubism { namespace Framework {

class CubismAllocationTag
Expand Down
18 changes: 18 additions & 0 deletions src/Rendering/D3D11/CubismRenderer_D3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ void CubismClippingManager_D3D11::SetupClippingContext(ID3D11DeviceContext* rend
{
const csmInt32 clipDrawIndex = clipContext->_clippingIdList[i];

// 頂点情報が更新されておらず、信頼性がない場合は描画をパスする
if (!model.GetDrawableDynamicFlagVertexPositionsDidChange(clipDrawIndex))
{
continue;
}

renderer->IsCulling(model.GetDrawableCulling(clipDrawIndex) != 0);

// 今回専用の変換を適用して描く
Expand Down Expand Up @@ -940,6 +946,12 @@ void CubismRenderer_D3D11::DoDrawModel()
{
const csmInt32 drawableIndex = _sortedDrawableIndexList[i];

// Drawableが表示状態でなければ処理をパスする
if (!GetModel()->GetDrawableDynamicFlagIsVisible(drawableIndex))
{
continue;
}

// クリッピングマスクをセットする
CubismClippingContext* clipContext = (_clippingManager != NULL)
? (*_clippingManager->GetClippingContextListForDraw())[drawableIndex]
Expand All @@ -965,6 +977,12 @@ void CubismRenderer_D3D11::DoDrawModel()
{
const csmInt32 clipDrawIndex = clipContext->_clippingIdList[ctx];

// 頂点情報が更新されておらず、信頼性がない場合は描画をパスする
if (!GetModel()->GetDrawableDynamicFlagVertexPositionsDidChange(clipDrawIndex))
{
continue;
}

IsCulling(GetModel()->GetDrawableCulling(clipDrawIndex) != 0);

// 今回専用の変換を適用して描く
Expand Down
18 changes: 18 additions & 0 deletions src/Rendering/D3D9/CubismRenderer_D3D9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ void CubismClippingManager_DX9::SetupClippingContext(LPDIRECT3DDEVICE9 device, C
{
const csmInt32 clipDrawIndex = clipContext->_clippingIdList[i];

// 頂点情報が更新されておらず、信頼性がない場合は描画をパスする
if (!model.GetDrawableDynamicFlagVertexPositionsDidChange(clipDrawIndex))
{
continue;
}

renderer->IsCulling(model.GetDrawableCulling(clipDrawIndex) != 0);

// 今回専用の変換を適用して描く
Expand Down Expand Up @@ -869,6 +875,12 @@ void CubismRenderer_D3D9::DoDrawModel()
{
const csmInt32 drawableIndex = _sortedDrawableIndexList[i];

// Drawableが表示状態でなければ処理をパスする
if (!GetModel()->GetDrawableDynamicFlagIsVisible(drawableIndex))
{
continue;
}

// クリッピングマスクをセットする
CubismClippingContext* clipContext = (_clippingManager != NULL)
? (*_clippingManager->GetClippingContextListForDraw())[drawableIndex]
Expand All @@ -894,6 +906,12 @@ void CubismRenderer_D3D9::DoDrawModel()
{
const csmInt32 clipDrawIndex = clipContext->_clippingIdList[ctx];

// 頂点情報が更新されておらず、信頼性がない場合は描画をパスする
if (!GetModel()->GetDrawableDynamicFlagVertexPositionsDidChange(clipDrawIndex))
{
continue;
}

IsCulling(GetModel()->GetDrawableCulling(clipDrawIndex) != 0);

// 今回専用の変換を適用して描く
Expand Down
5 changes: 5 additions & 0 deletions src/Rendering/OpenGL/CubismOffscreenSurface_OpenGLES2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
#include <OpenGL/gl.h>
#endif

#ifdef CSM_TARGET_LINUX_GL
#include <GL/glew.h>
#include <GL/gl.h>
#endif

//------------ LIVE2D NAMESPACE ------------
namespace Live2D { namespace Cubism { namespace Framework { namespace Rendering {

Expand Down
5 changes: 5 additions & 0 deletions src/Rendering/OpenGL/CubismRenderer_OpenGLES2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
#include <OpenGL/gl.h>
#endif

#ifdef CSM_TARGET_LINUX_GL
#include <GL/glew.h>
#include <GL/gl.h>
#endif

//------------ LIVE2D NAMESPACE ------------
namespace Live2D { namespace Cubism { namespace Framework { namespace Rendering {

Expand Down

0 comments on commit 6261f6a

Please sign in to comment.