From 9762da09cd6dba89fded009011ce376858653b15 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 30 May 2022 13:57:10 +0200 Subject: [PATCH] [c] Removed VertexEffect, see #2076 --- spine-c/spine-c/include/spine/VertexEffect.h | 84 -------------- spine-c/spine-c/include/spine/spine.h | 1 - spine-c/spine-c/src/spine/VertexEffect.c | 112 ------------------- spine-sfml/c/example/main.cpp | 11 -- spine-sfml/c/src/spine/spine-sfml.cpp | 54 ++------- spine-sfml/c/src/spine/spine-sfml.h | 1 - 6 files changed, 7 insertions(+), 256 deletions(-) delete mode 100644 spine-c/spine-c/include/spine/VertexEffect.h delete mode 100644 spine-c/spine-c/src/spine/VertexEffect.c diff --git a/spine-c/spine-c/include/spine/VertexEffect.h b/spine-c/spine-c/include/spine/VertexEffect.h deleted file mode 100644 index 5ef4d12c9..000000000 --- a/spine-c/spine-c/include/spine/VertexEffect.h +++ /dev/null @@ -1,84 +0,0 @@ -/****************************************************************************** - * 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. - *****************************************************************************/ - -#ifndef SPINE_VERTEXEFFECT_H_ -#define SPINE_VERTEXEFFECT_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct spVertexEffect; - -typedef void (*spVertexEffectBegin)(struct spVertexEffect *self, spSkeleton *skeleton); - -typedef void (*spVertexEffectTransform)(struct spVertexEffect *self, float *x, float *y, float *u, float *v, - spColor *light, spColor *dark); - -typedef void (*spVertexEffectEnd)(struct spVertexEffect *self); - -typedef struct spVertexEffect { - spVertexEffectBegin begin; - spVertexEffectTransform transform; - spVertexEffectEnd end; -} spVertexEffect; - -typedef struct spJitterVertexEffect { - spVertexEffect super; - float jitterX; - float jitterY; -} spJitterVertexEffect; - -typedef struct spSwirlVertexEffect { - spVertexEffect super; - float centerX; - float centerY; - float radius; - float angle; - float worldX; - float worldY; -} spSwirlVertexEffect; - -SP_API spJitterVertexEffect *spJitterVertexEffect_create(float jitterX, float jitterY); - -SP_API void spJitterVertexEffect_dispose(spJitterVertexEffect *effect); - -SP_API spSwirlVertexEffect *spSwirlVertexEffect_create(float radius); - -SP_API void spSwirlVertexEffect_dispose(spSwirlVertexEffect *effect); - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_VERTEX_EFFECT_H_ */ diff --git a/spine-c/spine-c/include/spine/spine.h b/spine-c/spine-c/include/spine/spine.h index 1e6dd9687..458c21f12 100644 --- a/spine-c/spine-c/include/spine/spine.h +++ b/spine-c/spine-c/include/spine/spine.h @@ -58,6 +58,5 @@ #include #include #include -#include #endif /* SPINE_SPINE_H_ */ diff --git a/spine-c/spine-c/src/spine/VertexEffect.c b/spine-c/spine-c/src/spine/VertexEffect.c deleted file mode 100644 index 01591f978..000000000 --- a/spine-c/spine-c/src/spine/VertexEffect.c +++ /dev/null @@ -1,112 +0,0 @@ -/****************************************************************************** - * 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 -#include - -void _spJitterVertexEffect_begin(spVertexEffect *self, spSkeleton *skeleton) { - UNUSED(self); - UNUSED(skeleton); -} - -void _spJitterVertexEffect_transform(spVertexEffect *self, float *x, float *y, float *u, float *v, spColor *light, - spColor *dark) { - spJitterVertexEffect *internal = (spJitterVertexEffect *) self; - float jitterX = internal->jitterX; - float jitterY = internal->jitterY; - (*x) += _spMath_randomTriangular(-jitterX, jitterY); - (*y) += _spMath_randomTriangular(-jitterX, jitterY); - UNUSED(u); - UNUSED(v); - UNUSED(light); - UNUSED(dark); -} - -void _spJitterVertexEffect_end(spVertexEffect *self) { - UNUSED(self); -} - -spJitterVertexEffect *spJitterVertexEffect_create(float jitterX, float jitterY) { - spJitterVertexEffect *effect = CALLOC(spJitterVertexEffect, 1); - effect->super.begin = _spJitterVertexEffect_begin; - effect->super.transform = _spJitterVertexEffect_transform; - effect->super.end = _spJitterVertexEffect_end; - effect->jitterX = jitterX; - effect->jitterY = jitterY; - return effect; -} - -void spJitterVertexEffect_dispose(spJitterVertexEffect *effect) { - FREE(effect); -} - -void _spSwirlVertexEffect_begin(spVertexEffect *self, spSkeleton *skeleton) { - spSwirlVertexEffect *internal = (spSwirlVertexEffect *) self; - internal->worldX = skeleton->x + internal->centerX; - internal->worldY = skeleton->y + internal->centerY; -} - -void _spSwirlVertexEffect_transform(spVertexEffect *self, float *positionX, float *positionY, float *u, float *v, - spColor *light, spColor *dark) { - spSwirlVertexEffect *internal = (spSwirlVertexEffect *) self; - float radAngle = internal->angle * DEG_RAD; - float x = *positionX - internal->worldX; - float y = *positionY - internal->worldY; - float dist = SQRT(x * x + y * y); - if (dist < internal->radius) { - float theta = _spMath_interpolate(_spMath_pow2_apply, 0, radAngle, - (internal->radius - dist) / internal->radius); - float cosine = COS(theta); - float sine = SIN(theta); - (*positionX) = cosine * x - sine * y + internal->worldX; - (*positionY) = sine * x + cosine * y + internal->worldY; - } - UNUSED(self); - UNUSED(u); - UNUSED(v); - UNUSED(light); - UNUSED(dark); -} - -void _spSwirlVertexEffect_end(spVertexEffect *self) { - UNUSED(self); -} - -spSwirlVertexEffect *spSwirlVertexEffect_create(float radius) { - spSwirlVertexEffect *effect = CALLOC(spSwirlVertexEffect, 1); - effect->super.begin = _spSwirlVertexEffect_begin; - effect->super.transform = _spSwirlVertexEffect_transform; - effect->super.end = _spSwirlVertexEffect_end; - effect->radius = radius; - return effect; -} - -void spSwirlVertexEffect_dispose(spSwirlVertexEffect *effect) { - FREE(effect); -} diff --git a/spine-sfml/c/example/main.cpp b/spine-sfml/c/example/main.cpp index e55e510ee..d3f17bb34 100644 --- a/spine-sfml/c/example/main.cpp +++ b/spine-sfml/c/example/main.cpp @@ -279,10 +279,6 @@ void raptor(spSkeletonData *skeletonData, spAtlas *atlas) { drawable->timeScale = 1; drawable->setUsePremultipliedAlpha(true); - spSwirlVertexEffect *effect = spSwirlVertexEffect_create(400); - effect->centerY = -200; - drawable->vertexEffect = &effect->super; - spSkeleton *skeleton = drawable->skeleton; skeleton->x = 320; skeleton->y = 590; @@ -295,7 +291,6 @@ void raptor(spSkeletonData *skeletonData, spAtlas *atlas) { window.setFramerateLimit(60); sf::Event event; sf::Clock deltaClock; - float swirlTime = 0; while (window.isOpen()) { while (window.pollEvent(event)) if (event.type == sf::Event::Closed) window.close(); @@ -303,18 +298,12 @@ void raptor(spSkeletonData *skeletonData, spAtlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - swirlTime += delta; - float percent = (float) fmod(swirlTime, 2); - if (percent > 1) percent = 1 - (percent - 1); - effect->angle = _spMath_interpolate(_spMath_pow2_apply, -60, 60, percent); - drawable->update(delta); window.clear(); window.draw(*drawable); window.display(); } - spSwirlVertexEffect_dispose(effect); } void tank(spSkeletonData *skeletonData, spAtlas *atlas) { diff --git a/spine-sfml/c/src/spine/spine-sfml.cpp b/spine-sfml/c/src/spine/spine-sfml.cpp index cbaeeb82a..71615b672 100644 --- a/spine-sfml/c/src/spine/spine-sfml.cpp +++ b/spine-sfml/c/src/spine/spine-sfml.cpp @@ -123,7 +123,6 @@ namespace spine { SkeletonDrawable::SkeletonDrawable(spSkeletonData *skeletonData, spAnimationStateData *stateData) : timeScale(1), vertexArray(new VertexArray(Triangles, skeletonData->bonesCount * 4)), - vertexEffect(0), worldVertices(0), clipper(0) { spBone_setYDown(true); worldVertices = MALLOC(float, SPINE_MESH_VERTEX_COUNT_MAX); @@ -164,8 +163,6 @@ namespace spine { // Early out if skeleton is invisible if (skeleton->color.a == 0) return; - if (vertexEffect != 0) vertexEffect->begin(vertexEffect, skeleton); - sf::Vertex vertex; Texture *texture = 0; for (int i = 0; i < skeleton->slotsCount; ++i) { @@ -300,56 +297,19 @@ namespace spine { Vector2u size = texture->getSize(); - if (vertexEffect != 0) { - spFloatArray_clear(tempUvs); - spColorArray_clear(tempColors); - for (int j = 0; j < verticesCount; j++) { - spColor vertexColor = light; - spColor dark; - dark.r = dark.g = dark.b = dark.a = 0; - int index = j << 1; - float x = vertices[index]; - float y = vertices[index + 1]; - float u = uvs[index]; - float v = uvs[index + 1]; - vertexEffect->transform(vertexEffect, &x, &y, &u, &v, &vertexColor, &dark); - vertices[index] = x; - vertices[index + 1] = y; - spFloatArray_add(tempUvs, u); - spFloatArray_add(tempUvs, v); - spColorArray_add(tempColors, vertexColor); - } - - for (int j = 0; j < indicesCount; ++j) { - int index = indices[j] << 1; - vertex.position.x = vertices[index]; - vertex.position.y = vertices[index + 1]; - vertex.texCoords.x = uvs[index] * size.x; - vertex.texCoords.y = uvs[index + 1] * size.y; - spColor vertexColor = tempColors->items[index >> 1]; - vertex.color.r = static_cast(vertexColor.r * 255); - vertex.color.g = static_cast(vertexColor.g * 255); - vertex.color.b = static_cast(vertexColor.b * 255); - vertex.color.a = static_cast(vertexColor.a * 255); - vertexArray->append(vertex); - } - } else { - for (int j = 0; j < indicesCount; ++j) { - int index = indices[j] << 1; - vertex.position.x = vertices[index]; - vertex.position.y = vertices[index + 1]; - vertex.texCoords.x = uvs[index] * size.x; - vertex.texCoords.y = uvs[index + 1] * size.y; - vertexArray->append(vertex); - } + for (int j = 0; j < indicesCount; ++j) { + int index = indices[j] << 1; + vertex.position.x = vertices[index]; + vertex.position.y = vertices[index + 1]; + vertex.texCoords.x = uvs[index] * size.x; + vertex.texCoords.y = uvs[index + 1] * size.y; + vertexArray->append(vertex); } spSkeletonClipping_clipEnd(clipper, slot); } target.draw(*vertexArray, states); spSkeletonClipping_clipEnd2(clipper); - - if (vertexEffect != 0) vertexEffect->end(vertexEffect); } } /* namespace spine */ diff --git a/spine-sfml/c/src/spine/spine-sfml.h b/spine-sfml/c/src/spine/spine-sfml.h index 22fabb81e..b1de165b3 100644 --- a/spine-sfml/c/src/spine/spine-sfml.h +++ b/spine-sfml/c/src/spine/spine-sfml.h @@ -48,7 +48,6 @@ namespace spine { spAnimationState *state; float timeScale; sf::VertexArray *vertexArray; - spVertexEffect *vertexEffect; SkeletonDrawable(spSkeletonData *skeleton, spAnimationStateData *stateData = 0); ~SkeletonDrawable();