mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Merge branch '4.1' into 4.2-beta
This commit is contained in:
commit
95487552dc
@ -149,6 +149,7 @@
|
|||||||
* Added outline shader parameter `Advanced - Opaque Alpha` which can be used to exclude problematic semi-transparent areas, which may receive an undesired large outline color overlay otherwise.
|
* Added outline shader parameter `Advanced - Opaque Alpha` which can be used to exclude problematic semi-transparent areas, which may receive an undesired large outline color overlay otherwise.
|
||||||
* Added Spine Preferences setting `Prefabs` - `Optimize Preview Meshes`. When enabled, Spine prefab preview meshes will be removed in a pre-build step to reduce build size. This increases build time as all prefabs in the project will be processed. Defaults to false to not slow down builds substantially every time.
|
* Added Spine Preferences setting `Prefabs` - `Optimize Preview Meshes`. When enabled, Spine prefab preview meshes will be removed in a pre-build step to reduce build size. This increases build time as all prefabs in the project will be processed. Defaults to false to not slow down builds substantially every time.
|
||||||
* Added Spine Preferences setting `Reload SkeletonData after Play`. When enabled, the shared `SkeletonData` of all skeletons in the active scene is reloaded (from the `.json` or `.skel.bytes` file) after exiting play-mode. You can disable this setting to avoid the reloading delay if you can ensure that there are no (accidental) modifications to the shared `SkeletonData` during play-mode (otherwise it would carry over its effect into subsequent plays). Defaults to `true` (the safe setting), which maintains existing behaviour.
|
* Added Spine Preferences setting `Reload SkeletonData after Play`. When enabled, the shared `SkeletonData` of all skeletons in the active scene is reloaded (from the `.json` or `.skel.bytes` file) after exiting play-mode. You can disable this setting to avoid the reloading delay if you can ensure that there are no (accidental) modifications to the shared `SkeletonData` during play-mode (otherwise it would carry over its effect into subsequent plays). Defaults to `true` (the safe setting), which maintains existing behaviour.
|
||||||
|
* Added `SkeletonAnimationMulti` sample component methods `SetActiveSkeleton(int index)` and getter property `SkeletonAnimations` to more easily apply changes at all SkeletonAnimation instances instead of only the active one.
|
||||||
|
|
||||||
* **Breaking changes**
|
* **Breaking changes**
|
||||||
* Made `SkeletonGraphic.unscaledTime` parameter protected, use the new property `UnscaledTime` instead.
|
* Made `SkeletonGraphic.unscaledTime` parameter protected, use the new property `UnscaledTime` instead.
|
||||||
|
|||||||
@ -2016,7 +2016,8 @@ void _spSequenceTimeline_apply(spTimeline *timeline, spSkeleton *skeleton, float
|
|||||||
|
|
||||||
slotAttachment = slot->attachment;
|
slotAttachment = slot->attachment;
|
||||||
if (slotAttachment != self->attachment) {
|
if (slotAttachment != self->attachment) {
|
||||||
switch (slot->attachment->type) {
|
if (slotAttachment == NULL) return;
|
||||||
|
switch (slotAttachment->type) {
|
||||||
case SP_ATTACHMENT_BOUNDING_BOX:
|
case SP_ATTACHMENT_BOUNDING_BOX:
|
||||||
case SP_ATTACHMENT_CLIPPING:
|
case SP_ATTACHMENT_CLIPPING:
|
||||||
case SP_ATTACHMENT_MESH:
|
case SP_ATTACHMENT_MESH:
|
||||||
|
|||||||
@ -72,7 +72,7 @@ void SequenceTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vec
|
|||||||
if (!slot->getBone().isActive()) return;
|
if (!slot->getBone().isActive()) return;
|
||||||
Attachment *slotAttachment = slot->getAttachment();
|
Attachment *slotAttachment = slot->getAttachment();
|
||||||
if (slotAttachment != _attachment) {
|
if (slotAttachment != _attachment) {
|
||||||
if (!slotAttachment->getRTTI().instanceOf(VertexAttachment::rtti) || ((VertexAttachment *) slotAttachment)->getTimelineAttachment() != _attachment) return;
|
if (slotAttachment == NULL || !slotAttachment->getRTTI().instanceOf(VertexAttachment::rtti) || ((VertexAttachment *) slotAttachment)->getTimelineAttachment() != _attachment) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<float> &frames = this->_frames;
|
Vector<float> &frames = this->_frames;
|
||||||
|
|||||||
@ -62,6 +62,7 @@ install(FILES ${INCLUDES} DESTINATION dist/include)
|
|||||||
|
|
||||||
# Define spine-sfml example executable
|
# Define spine-sfml example executable
|
||||||
add_executable(spine-sfml-cpp-example example/main.cpp)
|
add_executable(spine-sfml-cpp-example example/main.cpp)
|
||||||
|
add_executable(spine-sfml-cpp-test example/test.cpp)
|
||||||
|
|
||||||
# Link in SFML libraries and OS dependencies like OpenGL
|
# Link in SFML libraries and OS dependencies like OpenGL
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
@ -70,8 +71,10 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|||||||
find_library(SFML_WINDOW sfml-window PATHS ${SFML_DIR}/Frameworks)
|
find_library(SFML_WINDOW sfml-window PATHS ${SFML_DIR}/Frameworks)
|
||||||
find_library(SFML_GRAPHICS sfml-graphics PATHS ${SFML_DIR}/Frameworks)
|
find_library(SFML_GRAPHICS sfml-graphics PATHS ${SFML_DIR}/Frameworks)
|
||||||
target_link_libraries(spine-sfml-cpp-example ${SFML} ${SFML_SYSTEM} ${SFML_WINDOW} ${SFML_GRAPHICS})
|
target_link_libraries(spine-sfml-cpp-example ${SFML} ${SFML_SYSTEM} ${SFML_WINDOW} ${SFML_GRAPHICS})
|
||||||
|
target_link_libraries(spine-sfml-cpp-test ${SFML} ${SFML_SYSTEM} ${SFML_WINDOW} ${SFML_GRAPHICS})
|
||||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
target_link_libraries(spine-sfml-cpp-example sfml-graphics sfml-window sfml-system)
|
target_link_libraries(spine-sfml-cpp-example sfml-graphics sfml-window sfml-system)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test sfml-graphics sfml-window sfml-system)
|
||||||
else()
|
else()
|
||||||
set(SFML_LIBS ${SFML_DIR}/lib)
|
set(SFML_LIBS ${SFML_DIR}/lib)
|
||||||
target_link_libraries(spine-sfml-cpp-example ${SFML_LIBS}/sfml-main-d.lib)
|
target_link_libraries(spine-sfml-cpp-example ${SFML_LIBS}/sfml-main-d.lib)
|
||||||
@ -83,6 +86,15 @@ else()
|
|||||||
target_link_libraries(spine-sfml-cpp-example opengl32)
|
target_link_libraries(spine-sfml-cpp-example opengl32)
|
||||||
target_link_libraries(spine-sfml-cpp-example gdi32)
|
target_link_libraries(spine-sfml-cpp-example gdi32)
|
||||||
target_link_libraries(spine-sfml-cpp-example winmm)
|
target_link_libraries(spine-sfml-cpp-example winmm)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test ${SFML_LIBS}/sfml-main-d.lib)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test ${SFML_LIBS}/sfml-graphics-s-d.lib)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test ${SFML_LIBS}/sfml-window-s-d.lib)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test ${SFML_LIBS}/sfml-system-s-d.lib)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test ${SFML_LIBS}/freetype.lib)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test ${SFML_LIBS}/jpeg.lib)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test opengl32)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test gdi32)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test winmm)
|
||||||
add_definitions(-DSFML_STATIC)
|
add_definitions(-DSFML_STATIC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -90,6 +102,12 @@ endif()
|
|||||||
add_custom_command(TARGET spine-sfml-cpp-example PRE_BUILD
|
add_custom_command(TARGET spine-sfml-cpp-example PRE_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||||
${CMAKE_CURRENT_LIST_DIR}/data $<TARGET_FILE_DIR:spine-sfml-cpp-example>/data)
|
${CMAKE_CURRENT_LIST_DIR}/data $<TARGET_FILE_DIR:spine-sfml-cpp-example>/data)
|
||||||
|
add_custom_command(TARGET spine-sfml-cpp-test PRE_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/data $<TARGET_FILE_DIR:spine-sfml-cpp-example>/data)
|
||||||
|
|
||||||
target_link_libraries(spine-sfml-cpp-example spine-cpp)
|
target_link_libraries(spine-sfml-cpp-example spine-cpp)
|
||||||
target_link_libraries(spine-sfml-cpp-example spine-sfml-cpp)
|
target_link_libraries(spine-sfml-cpp-example spine-sfml-cpp)
|
||||||
|
|
||||||
|
target_link_libraries(spine-sfml-cpp-test spine-cpp)
|
||||||
|
target_link_libraries(spine-sfml-cpp-test spine-sfml-cpp)
|
||||||
|
|||||||
78
spine-sfml/cpp/example/test.cpp
Normal file
78
spine-sfml/cpp/example/test.cpp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Spine Runtimes License Agreement
|
||||||
|
* Last updated September 24, 2021. Replaces all prior versions.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2021, Esoteric Software LLC
|
||||||
|
*
|
||||||
|
* Integration of the Spine Runtimes into software or otherwise creating
|
||||||
|
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||||
|
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||||
|
* http://esotericsoftware.com/spine-editor-license
|
||||||
|
*
|
||||||
|
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||||
|
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||||
|
* "Products"), provided that each user of the Products must obtain their own
|
||||||
|
* Spine Editor license and redistribution of the Products in any form must
|
||||||
|
* include this license and copyright notice.
|
||||||
|
*
|
||||||
|
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||||
|
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
#include <spine/Debug.h>
|
||||||
|
#include <spine/Log.h>
|
||||||
|
#include <spine/spine-sfml.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace spine;
|
||||||
|
|
||||||
|
DebugExtension dbgExtension(SpineExtension::getInstance());
|
||||||
|
|
||||||
|
void test() {
|
||||||
|
SFMLTextureLoader textureLoader;
|
||||||
|
Atlas atlas("data/bomb.atlas", &textureLoader);
|
||||||
|
SkeletonBinary loader(&atlas);
|
||||||
|
SkeletonData *skeletonData = loader.readSkeletonDataFile("data/bomb.skel");
|
||||||
|
|
||||||
|
SkeletonDrawable drawable(skeletonData);
|
||||||
|
drawable.setUsePremultipliedAlpha(true);
|
||||||
|
drawable.skeleton->setPosition(320, 590);
|
||||||
|
drawable.state->setAnimation(0, "expl", false);
|
||||||
|
drawable.skeleton->setSkin("mdl");
|
||||||
|
|
||||||
|
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - Test");
|
||||||
|
window.setFramerateLimit(60);
|
||||||
|
sf::Event event;
|
||||||
|
sf::Clock deltaClock;
|
||||||
|
while (window.isOpen()) {
|
||||||
|
while (window.pollEvent(event))
|
||||||
|
if (event.type == sf::Event::Closed) window.close();
|
||||||
|
|
||||||
|
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||||
|
deltaClock.restart();
|
||||||
|
|
||||||
|
drawable.update(delta);
|
||||||
|
|
||||||
|
window.clear();
|
||||||
|
window.draw(drawable);
|
||||||
|
window.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete skeletonData;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
SpineExtension::setInstance(&dbgExtension);
|
||||||
|
test();
|
||||||
|
dbgExtension.reportLeaks();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -56,17 +56,24 @@ namespace Spine.Unity {
|
|||||||
SkeletonAnimation currentSkeletonAnimation;
|
SkeletonAnimation currentSkeletonAnimation;
|
||||||
|
|
||||||
void Clear () {
|
void Clear () {
|
||||||
foreach (var s in skeletonAnimations)
|
foreach (SkeletonAnimation skeletonAnimation in skeletonAnimations)
|
||||||
Destroy(s.gameObject);
|
Destroy(skeletonAnimation.gameObject);
|
||||||
|
|
||||||
skeletonAnimations.Clear();
|
skeletonAnimations.Clear();
|
||||||
animationNameTable.Clear();
|
animationNameTable.Clear();
|
||||||
animationSkeletonTable.Clear();
|
animationSkeletonTable.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetActiveSkeleton (int index) {
|
||||||
|
if (index < 0 || index >= skeletonAnimations.Count)
|
||||||
|
SetActiveSkeleton(null);
|
||||||
|
else
|
||||||
|
SetActiveSkeleton(skeletonAnimations[index]);
|
||||||
|
}
|
||||||
|
|
||||||
void SetActiveSkeleton (SkeletonAnimation skeletonAnimation) {
|
void SetActiveSkeleton (SkeletonAnimation skeletonAnimation) {
|
||||||
foreach (var sa in skeletonAnimations)
|
foreach (SkeletonAnimation iter in skeletonAnimations)
|
||||||
sa.gameObject.SetActive(sa == skeletonAnimation);
|
iter.gameObject.SetActive(iter == skeletonAnimation);
|
||||||
|
|
||||||
currentSkeletonAnimation = skeletonAnimation;
|
currentSkeletonAnimation = skeletonAnimation;
|
||||||
}
|
}
|
||||||
@ -81,34 +88,35 @@ namespace Spine.Unity {
|
|||||||
public Dictionary<Animation, SkeletonAnimation> AnimationSkeletonTable { get { return this.animationSkeletonTable; } }
|
public Dictionary<Animation, SkeletonAnimation> AnimationSkeletonTable { get { return this.animationSkeletonTable; } }
|
||||||
public Dictionary<string, Animation> AnimationNameTable { get { return this.animationNameTable; } }
|
public Dictionary<string, Animation> AnimationNameTable { get { return this.animationNameTable; } }
|
||||||
public SkeletonAnimation CurrentSkeletonAnimation { get { return this.currentSkeletonAnimation; } }
|
public SkeletonAnimation CurrentSkeletonAnimation { get { return this.currentSkeletonAnimation; } }
|
||||||
|
public List<SkeletonAnimation> SkeletonAnimations { get { return skeletonAnimations; } }
|
||||||
|
|
||||||
public void Initialize (bool overwrite) {
|
public void Initialize (bool overwrite) {
|
||||||
if (skeletonAnimations.Count != 0 && !overwrite) return;
|
if (skeletonAnimations.Count != 0 && !overwrite) return;
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
var settings = this.meshGeneratorSettings;
|
MeshGenerator.Settings settings = this.meshGeneratorSettings;
|
||||||
Transform thisTransform = this.transform;
|
Transform thisTransform = this.transform;
|
||||||
foreach (var sda in skeletonDataAssets) {
|
foreach (SkeletonDataAsset dataAsset in skeletonDataAssets) {
|
||||||
var sa = SkeletonAnimation.NewSkeletonAnimationGameObject(sda);
|
SkeletonAnimation newSkeletonAnimation = SkeletonAnimation.NewSkeletonAnimationGameObject(dataAsset);
|
||||||
sa.transform.SetParent(thisTransform, false);
|
newSkeletonAnimation.transform.SetParent(thisTransform, false);
|
||||||
|
|
||||||
sa.SetMeshSettings(settings);
|
newSkeletonAnimation.SetMeshSettings(settings);
|
||||||
sa.initialFlipX = this.initialFlipX;
|
newSkeletonAnimation.initialFlipX = this.initialFlipX;
|
||||||
sa.initialFlipY = this.initialFlipY;
|
newSkeletonAnimation.initialFlipY = this.initialFlipY;
|
||||||
var skeleton = sa.skeleton;
|
Skeleton skeleton = newSkeletonAnimation.skeleton;
|
||||||
skeleton.ScaleX = this.initialFlipX ? -1 : 1;
|
skeleton.ScaleX = this.initialFlipX ? -1 : 1;
|
||||||
skeleton.ScaleY = this.initialFlipY ? -1 : 1;
|
skeleton.ScaleY = this.initialFlipY ? -1 : 1;
|
||||||
|
|
||||||
sa.Initialize(false);
|
newSkeletonAnimation.Initialize(false);
|
||||||
skeletonAnimations.Add(sa);
|
skeletonAnimations.Add(newSkeletonAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build cache
|
// Build cache
|
||||||
var animationNameTable = this.animationNameTable;
|
Dictionary<string, Animation> animationNameTable = this.animationNameTable;
|
||||||
var animationSkeletonTable = this.animationSkeletonTable;
|
Dictionary<Animation, SkeletonAnimation> animationSkeletonTable = this.animationSkeletonTable;
|
||||||
foreach (var skeletonAnimation in skeletonAnimations) {
|
foreach (SkeletonAnimation skeletonAnimation in skeletonAnimations) {
|
||||||
foreach (var animationObject in skeletonAnimation.Skeleton.Data.Animations) {
|
foreach (Animation animationObject in skeletonAnimation.Skeleton.Data.Animations) {
|
||||||
animationNameTable[animationObject.Name] = animationObject;
|
animationNameTable[animationObject.Name] = animationObject;
|
||||||
animationSkeletonTable[animationObject] = skeletonAnimation;
|
animationSkeletonTable[animationObject] = skeletonAnimation;
|
||||||
}
|
}
|
||||||
@ -119,7 +127,6 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Animation FindAnimation (string animationName) {
|
public Animation FindAnimation (string animationName) {
|
||||||
// Analysis disable once LocalVariableHidesMember
|
|
||||||
Animation animation;
|
Animation animation;
|
||||||
animationNameTable.TryGetValue(animationName, out animation);
|
animationNameTable.TryGetValue(animationName, out animation);
|
||||||
return animation;
|
return animation;
|
||||||
@ -138,11 +145,10 @@ namespace Spine.Unity {
|
|||||||
if (skeletonAnimation != null) {
|
if (skeletonAnimation != null) {
|
||||||
SetActiveSkeleton(skeletonAnimation);
|
SetActiveSkeleton(skeletonAnimation);
|
||||||
skeletonAnimation.skeleton.SetToSetupPose();
|
skeletonAnimation.skeleton.SetToSetupPose();
|
||||||
var trackEntry = skeletonAnimation.state.SetAnimation(MainTrackIndex, animation, loop);
|
TrackEntry trackEntry = skeletonAnimation.state.SetAnimation(MainTrackIndex, animation, loop);
|
||||||
skeletonAnimation.Update(0);
|
skeletonAnimation.Update(0);
|
||||||
return trackEntry;
|
return trackEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user