From da45e32ada483fd5efd8fa7e2c369f26603c1c8c Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 31 May 2018 17:58:35 +0800 Subject: [PATCH] Removes unused files and code. (#1277) --- .../cocos2d_libs.xcodeproj/project.pbxproj | 148 +- native/cocos/Android.mk | 5 - native/cocos/base/CCNS.cpp | 187 --- native/cocos/base/CCNS.h | 81 - native/cocos/base/CCUserDefault-android.cpp | 527 ------- native/cocos/base/CCUserDefault-apple.mm | 551 ------- native/cocos/base/CCUserDefault.cpp | 528 ------- native/cocos/base/CCUserDefault.h | 265 ---- native/cocos/base/ccUTF8.cpp | 129 -- native/cocos/base/ccUTF8.h | 92 -- native/cocos/base/ccUtils.cpp | 5 +- native/cocos/base/ccUtils.h | 2 - native/cocos/base/firePngData.h | 53 - native/cocos/cocos2d.h | 3 - .../cocos/editor-support/creator/Android.mk | 29 - .../editor-support/creator/CCCameraNode.cpp | 175 --- .../editor-support/creator/CCCameraNode.h | 78 - .../editor-support/creator/CCGraphicsNode.cpp | 1347 ----------------- .../creator/CCGraphicsNode.frag | 23 - .../editor-support/creator/CCGraphicsNode.h | 315 ---- .../creator/CCGraphicsNode.vert | 18 - .../editor-support/creator/CCScale9Sprite.cpp | 1172 -------------- .../editor-support/creator/CCScale9Sprite.h | 178 --- .../editor-support/creator/Triangulate.cpp | 140 -- .../editor-support/creator/Triangulate.h | 69 - .../physics/CCPhysicsAABBQueryCallback.cpp | 84 - .../physics/CCPhysicsAABBQueryCallback.h | 57 - .../physics/CCPhysicsContactImpulse.cpp | 56 - .../creator/physics/CCPhysicsContactImpulse.h | 51 - .../physics/CCPhysicsContactListener.cpp | 138 -- .../physics/CCPhysicsContactListener.h | 78 - .../creator/physics/CCPhysicsDebugDraw.cpp | 134 -- .../creator/physics/CCPhysicsDebugDraw.h | 67 - .../creator/physics/CCPhysicsDefine.h | 31 - .../physics/CCPhysicsManifoldWrapper.cpp | 80 - .../physics/CCPhysicsManifoldWrapper.h | 59 - .../physics/CCPhysicsRayCastCallback.cpp | 103 -- .../physics/CCPhysicsRayCastCallback.h | 62 - .../creator/physics/CCPhysicsUtils.cpp | 126 -- .../creator/physics/CCPhysicsUtils.h | 64 - .../physics/CCPhysicsWorldManifoldWrapper.cpp | 68 - .../physics/CCPhysicsWorldManifoldWrapper.h | 56 - .../dragonbones/DragonBonesHeaders.h | 50 - .../dragonbones/animation/Animation.cpp | 513 ------- .../dragonbones/animation/Animation.h | 103 -- .../dragonbones/animation/AnimationState.cpp | 619 -------- .../dragonbones/animation/AnimationState.h | 143 -- .../dragonbones/animation/BaseTimelineState.h | 388 ----- .../dragonbones/animation/IAnimateble.h | 18 - .../dragonbones/animation/TimelineState.cpp | 724 --------- .../dragonbones/animation/TimelineState.h | 133 -- .../dragonbones/animation/WorldClock.cpp | 111 -- .../dragonbones/animation/WorldClock.h | 35 - .../dragonbones/armature/Armature.cpp | 510 ------- .../dragonbones/armature/Armature.h | 145 -- .../dragonbones/armature/Bone.cpp | 448 ------ .../dragonbones/armature/Bone.h | 101 -- .../dragonbones/armature/IArmatureDisplay.h | 26 - .../dragonbones/armature/Slot.cpp | 533 ------- .../dragonbones/armature/Slot.h | 171 --- .../dragonbones/armature/TransformObject.h | 80 - .../cocos2dx/CCArmatureDisplay.cpp | 216 --- .../dragonbones/cocos2dx/CCArmatureDisplay.h | 106 -- .../cocos2dx/CCDragonBonesHeaders.h | 9 - .../dragonbones/cocos2dx/CCFactory.cpp | 269 ---- .../dragonbones/cocos2dx/CCFactory.h | 41 - .../dragonbones/cocos2dx/CCSlot.cpp | 454 ------ .../dragonbones/cocos2dx/CCSlot.h | 43 - .../dragonbones/cocos2dx/CCTextureData.cpp | 52 - .../dragonbones/cocos2dx/CCTextureData.h | 46 - .../dragonbones/core/BaseObject.cpp | 143 -- .../dragonbones/core/BaseObject.h | 78 - .../dragonbones/core/DragonBones.h | 148 -- .../dragonbones/events/EventObject.cpp | 42 - .../dragonbones/events/EventObject.h | 74 - .../dragonbones/factories/BaseFactory.cpp | 451 ------ .../dragonbones/factories/BaseFactory.h | 98 -- .../dragonbones/geom/ColorTransform.h | 60 - .../editor-support/dragonbones/geom/Matrix.h | 106 -- .../editor-support/dragonbones/geom/Point.h | 41 - .../dragonbones/geom/Rectangle.h | 48 - .../dragonbones/geom/Transform.h | 141 -- .../dragonbones/model/AnimationData.cpp | 127 -- .../dragonbones/model/AnimationData.h | 87 -- .../dragonbones/model/ArmatureData.cpp | 403 ----- .../dragonbones/model/ArmatureData.h | 332 ---- .../dragonbones/model/DragonBonesData.cpp | 44 - .../dragonbones/model/DragonBonesData.h | 50 - .../dragonbones/model/FrameData.cpp | 128 -- .../dragonbones/model/FrameData.h | 258 ---- .../dragonbones/model/TimelineData.cpp | 144 -- .../dragonbones/model/TimelineData.h | 129 -- .../dragonbones/parsers/DataParser.cpp | 515 ------- .../dragonbones/parsers/DataParser.h | 162 -- .../dragonbones/parsers/JSONDataParser.cpp | 1065 ------------- .../dragonbones/parsers/JSONDataParser.h | 293 ---- .../dragonbones/proj.android/Android.mk | 45 - .../proj.win32/libDragonBones.vcxproj | 160 -- .../proj.win32/libDragonBones.vcxproj.filters | 205 --- .../dragonbones/textures/TextureData.cpp | 61 - .../dragonbones/textures/TextureData.h | 65 - native/cocos/editor-support/spine/Android.mk | 56 - native/cocos/editor-support/spine/Animation.c | 1341 ---------------- native/cocos/editor-support/spine/Animation.h | 545 ------- .../editor-support/spine/AnimationState.c | 871 ----------- .../editor-support/spine/AnimationState.h | 179 --- .../editor-support/spine/AnimationStateData.c | 151 -- .../editor-support/spine/AnimationStateData.h | 76 - native/cocos/editor-support/spine/Atlas.c | 353 ----- native/cocos/editor-support/spine/Atlas.h | 172 --- .../spine/AtlasAttachmentLoader.c | 96 -- .../spine/AtlasAttachmentLoader.h | 57 - .../cocos/editor-support/spine/Attachment.c | 57 - .../cocos/editor-support/spine/Attachment.h | 79 - .../editor-support/spine/AttachmentLoader.c | 98 -- .../editor-support/spine/AttachmentLoader.h | 78 - .../spine/AttachmentVertices.cpp | 52 - .../editor-support/spine/AttachmentVertices.h | 49 - native/cocos/editor-support/spine/Bone.c | 301 ---- native/cocos/editor-support/spine/Bone.h | 126 -- native/cocos/editor-support/spine/BoneData.c | 48 - native/cocos/editor-support/spine/BoneData.h | 83 - .../spine/BoundingBoxAttachment.c | 50 - .../spine/BoundingBoxAttachment.h | 60 - .../cocos/editor-support/spine/CMakeLists.txt | 42 - .../spine/Cocos2dAttachmentLoader.cpp | 107 -- .../spine/Cocos2dAttachmentLoader.h | 48 - native/cocos/editor-support/spine/Event.c | 44 - native/cocos/editor-support/spine/Event.h | 71 - native/cocos/editor-support/spine/EventData.c | 44 - native/cocos/editor-support/spine/EventData.h | 67 - .../cocos/editor-support/spine/IkConstraint.c | 216 --- .../cocos/editor-support/spine/IkConstraint.h | 86 -- .../editor-support/spine/IkConstraintData.c | 46 - .../editor-support/spine/IkConstraintData.h | 75 - native/cocos/editor-support/spine/Json.c | 426 ------ native/cocos/editor-support/spine/Json.h | 83 - .../editor-support/spine/MeshAttachment.c | 105 -- .../editor-support/spine/MeshAttachment.h | 92 -- .../editor-support/spine/PathAttachment.c | 55 - .../editor-support/spine/PathAttachment.h | 64 - .../editor-support/spine/PathConstraint.c | 459 ------ .../editor-support/spine/PathConstraint.h | 112 -- .../editor-support/spine/PathConstraintData.c | 44 - .../editor-support/spine/PathConstraintData.h | 96 -- .../editor-support/spine/RegionAttachment.c | 113 -- .../editor-support/spine/RegionAttachment.h | 87 -- native/cocos/editor-support/spine/Skeleton.c | 565 ------- native/cocos/editor-support/spine/Skeleton.h | 173 --- .../spine/SkeletonAnimation.cpp | 304 ---- .../editor-support/spine/SkeletonAnimation.h | 126 -- .../editor-support/spine/SkeletonBatch.cpp | 117 -- .../editor-support/spine/SkeletonBatch.h | 70 - .../editor-support/spine/SkeletonBinary.c | 1046 ------------- .../editor-support/spine/SkeletonBinary.h | 71 - .../editor-support/spine/SkeletonBounds.c | 205 --- .../editor-support/spine/SkeletonBounds.h | 112 -- .../cocos/editor-support/spine/SkeletonData.c | 147 -- .../cocos/editor-support/spine/SkeletonData.h | 116 -- .../cocos/editor-support/spine/SkeletonJson.c | 1058 ------------- .../cocos/editor-support/spine/SkeletonJson.h | 72 - .../editor-support/spine/SkeletonRenderer.cpp | 450 ------ .../editor-support/spine/SkeletonRenderer.h | 137 -- native/cocos/editor-support/spine/Skin.c | 106 -- native/cocos/editor-support/spine/Skin.h | 94 -- native/cocos/editor-support/spine/Slot.c | 81 - native/cocos/editor-support/spine/Slot.h | 90 -- native/cocos/editor-support/spine/SlotData.c | 58 - native/cocos/editor-support/spine/SlotData.h | 86 -- .../spine/TransformConstraint.c | 121 -- .../spine/TransformConstraint.h | 80 - .../spine/TransformConstraintData.c | 44 - .../spine/TransformConstraintData.h | 82 - .../editor-support/spine/VertexAttachment.c | 111 -- .../editor-support/spine/VertexAttachment.h | 67 - native/cocos/editor-support/spine/extension.c | 78 - native/cocos/editor-support/spine/extension.h | 297 ---- native/cocos/editor-support/spine/kvec.h | 92 -- .../spine/proj.win32/libSpine.vcxproj | 181 --- .../spine/proj.win32/libSpine.vcxproj.filters | 248 --- .../editor-support/spine/spine-cocos2dx.cpp | 108 -- .../editor-support/spine/spine-cocos2dx.h | 47 - native/cocos/editor-support/spine/spine.h | 58 - native/cocos/math/CCAffineTransform.cpp | 176 --- native/cocos/math/CCAffineTransform.h | 121 -- native/cocos/math/TransformUtils.cpp | 53 - native/cocos/math/TransformUtils.h | 57 - .../lib/Cocos2dxAudioFocusManager.java | 5 - .../src/org/cocos2dx/lib/Cocos2dxHelper.java | 252 +-- .../src/org/cocos2dx/lib/Cocos2dxMusic.java | 316 ---- .../src/org/cocos2dx/lib/Cocos2dxSound.java | 406 ----- native/cocos/platform/apple/CCLock-apple.cpp | 50 - native/cocos/platform/apple/CCLock-apple.h | 53 - .../jsb_cocos2dx_experimental_video_auto.cpp | 441 ------ .../jsb_cocos2dx_experimental_video_auto.hpp | 32 - ...jsb_cocos2dx_experimental_webView_auto.cpp | 643 -------- ...jsb_cocos2dx_experimental_webView_auto.hpp | 37 - .../js-bindings/manual/jsb_box2d_manual.cpp | 1154 -------------- .../js-bindings/manual/jsb_box2d_manual.hpp | 40 - .../js-bindings/manual/jsb_classtype.cpp | 25 + .../js-bindings/manual/jsb_classtype.hpp | 25 + .../manual/jsb_cocos2dx_extension_manual.cpp | 8 - .../manual/jsb_cocos2dx_manual.cpp | 31 +- .../manual/jsb_cocos2dx_manual.hpp | 25 + .../js-bindings/manual/jsb_conversions.cpp | 31 +- .../js-bindings/manual/jsb_conversions.hpp | 25 + .../js-bindings/manual/jsb_gfx_manual.cpp | 31 +- .../js-bindings/manual/jsb_gfx_manual.hpp | 25 + .../js-bindings/manual/jsb_global.cpp | 27 +- .../scripting/js-bindings/manual/jsb_global.h | 25 + .../manual/jsb_platform_android.cpp | 25 + .../js-bindings/manual/jsb_platfrom_apple.mm | 25 + .../js-bindings/manual/jsb_platfrom_ios.mm | 25 + .../manual/jsb_renderer_manual.cpp | 26 +- .../manual/jsb_renderer_manual.hpp | 25 + native/tools/tojs/box2d.ini | 65 - native/tools/tojs/cocos2dx_dragonbones.ini | 72 - .../tojs/cocos2dx_experimental_video.ini | 58 - .../tojs/cocos2dx_experimental_webView.ini | 59 - native/tools/tojs/creator.ini | 68 - native/tools/tojs/creator_camera.ini | 68 - native/tools/tojs/creator_graphics.ini | 68 - native/tools/tojs/creator_physics.ini | 74 - 223 files changed, 420 insertions(+), 38034 deletions(-) delete mode 100644 native/cocos/base/CCNS.cpp delete mode 100644 native/cocos/base/CCNS.h delete mode 100644 native/cocos/base/CCUserDefault-android.cpp delete mode 100644 native/cocos/base/CCUserDefault-apple.mm delete mode 100644 native/cocos/base/CCUserDefault.cpp delete mode 100644 native/cocos/base/CCUserDefault.h delete mode 100644 native/cocos/base/firePngData.h delete mode 100644 native/cocos/editor-support/creator/Android.mk delete mode 100644 native/cocos/editor-support/creator/CCCameraNode.cpp delete mode 100644 native/cocos/editor-support/creator/CCCameraNode.h delete mode 100644 native/cocos/editor-support/creator/CCGraphicsNode.cpp delete mode 100755 native/cocos/editor-support/creator/CCGraphicsNode.frag delete mode 100644 native/cocos/editor-support/creator/CCGraphicsNode.h delete mode 100755 native/cocos/editor-support/creator/CCGraphicsNode.vert delete mode 100755 native/cocos/editor-support/creator/CCScale9Sprite.cpp delete mode 100755 native/cocos/editor-support/creator/CCScale9Sprite.h delete mode 100644 native/cocos/editor-support/creator/Triangulate.cpp delete mode 100644 native/cocos/editor-support/creator/Triangulate.h delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsAABBQueryCallback.cpp delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsAABBQueryCallback.h delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsContactImpulse.cpp delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsContactImpulse.h delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsContactListener.cpp delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsContactListener.h delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsDebugDraw.cpp delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsDebugDraw.h delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsDefine.h delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsManifoldWrapper.cpp delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsManifoldWrapper.h delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsRayCastCallback.cpp delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsRayCastCallback.h delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsUtils.cpp delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsUtils.h delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsWorldManifoldWrapper.cpp delete mode 100644 native/cocos/editor-support/creator/physics/CCPhysicsWorldManifoldWrapper.h delete mode 100644 native/cocos/editor-support/dragonbones/DragonBonesHeaders.h delete mode 100644 native/cocos/editor-support/dragonbones/animation/Animation.cpp delete mode 100644 native/cocos/editor-support/dragonbones/animation/Animation.h delete mode 100644 native/cocos/editor-support/dragonbones/animation/AnimationState.cpp delete mode 100644 native/cocos/editor-support/dragonbones/animation/AnimationState.h delete mode 100644 native/cocos/editor-support/dragonbones/animation/BaseTimelineState.h delete mode 100644 native/cocos/editor-support/dragonbones/animation/IAnimateble.h delete mode 100644 native/cocos/editor-support/dragonbones/animation/TimelineState.cpp delete mode 100644 native/cocos/editor-support/dragonbones/animation/TimelineState.h delete mode 100644 native/cocos/editor-support/dragonbones/animation/WorldClock.cpp delete mode 100644 native/cocos/editor-support/dragonbones/animation/WorldClock.h delete mode 100644 native/cocos/editor-support/dragonbones/armature/Armature.cpp delete mode 100644 native/cocos/editor-support/dragonbones/armature/Armature.h delete mode 100644 native/cocos/editor-support/dragonbones/armature/Bone.cpp delete mode 100644 native/cocos/editor-support/dragonbones/armature/Bone.h delete mode 100644 native/cocos/editor-support/dragonbones/armature/IArmatureDisplay.h delete mode 100644 native/cocos/editor-support/dragonbones/armature/Slot.cpp delete mode 100644 native/cocos/editor-support/dragonbones/armature/Slot.h delete mode 100644 native/cocos/editor-support/dragonbones/armature/TransformObject.h delete mode 100644 native/cocos/editor-support/dragonbones/cocos2dx/CCArmatureDisplay.cpp delete mode 100644 native/cocos/editor-support/dragonbones/cocos2dx/CCArmatureDisplay.h delete mode 100644 native/cocos/editor-support/dragonbones/cocos2dx/CCDragonBonesHeaders.h delete mode 100644 native/cocos/editor-support/dragonbones/cocos2dx/CCFactory.cpp delete mode 100644 native/cocos/editor-support/dragonbones/cocos2dx/CCFactory.h delete mode 100644 native/cocos/editor-support/dragonbones/cocos2dx/CCSlot.cpp delete mode 100644 native/cocos/editor-support/dragonbones/cocos2dx/CCSlot.h delete mode 100644 native/cocos/editor-support/dragonbones/cocos2dx/CCTextureData.cpp delete mode 100644 native/cocos/editor-support/dragonbones/cocos2dx/CCTextureData.h delete mode 100644 native/cocos/editor-support/dragonbones/core/BaseObject.cpp delete mode 100644 native/cocos/editor-support/dragonbones/core/BaseObject.h delete mode 100644 native/cocos/editor-support/dragonbones/core/DragonBones.h delete mode 100644 native/cocos/editor-support/dragonbones/events/EventObject.cpp delete mode 100644 native/cocos/editor-support/dragonbones/events/EventObject.h delete mode 100644 native/cocos/editor-support/dragonbones/factories/BaseFactory.cpp delete mode 100644 native/cocos/editor-support/dragonbones/factories/BaseFactory.h delete mode 100644 native/cocos/editor-support/dragonbones/geom/ColorTransform.h delete mode 100644 native/cocos/editor-support/dragonbones/geom/Matrix.h delete mode 100644 native/cocos/editor-support/dragonbones/geom/Point.h delete mode 100644 native/cocos/editor-support/dragonbones/geom/Rectangle.h delete mode 100644 native/cocos/editor-support/dragonbones/geom/Transform.h delete mode 100644 native/cocos/editor-support/dragonbones/model/AnimationData.cpp delete mode 100644 native/cocos/editor-support/dragonbones/model/AnimationData.h delete mode 100644 native/cocos/editor-support/dragonbones/model/ArmatureData.cpp delete mode 100644 native/cocos/editor-support/dragonbones/model/ArmatureData.h delete mode 100644 native/cocos/editor-support/dragonbones/model/DragonBonesData.cpp delete mode 100644 native/cocos/editor-support/dragonbones/model/DragonBonesData.h delete mode 100644 native/cocos/editor-support/dragonbones/model/FrameData.cpp delete mode 100644 native/cocos/editor-support/dragonbones/model/FrameData.h delete mode 100644 native/cocos/editor-support/dragonbones/model/TimelineData.cpp delete mode 100644 native/cocos/editor-support/dragonbones/model/TimelineData.h delete mode 100644 native/cocos/editor-support/dragonbones/parsers/DataParser.cpp delete mode 100644 native/cocos/editor-support/dragonbones/parsers/DataParser.h delete mode 100644 native/cocos/editor-support/dragonbones/parsers/JSONDataParser.cpp delete mode 100644 native/cocos/editor-support/dragonbones/parsers/JSONDataParser.h delete mode 100644 native/cocos/editor-support/dragonbones/proj.android/Android.mk delete mode 100644 native/cocos/editor-support/dragonbones/proj.win32/libDragonBones.vcxproj delete mode 100644 native/cocos/editor-support/dragonbones/proj.win32/libDragonBones.vcxproj.filters delete mode 100644 native/cocos/editor-support/dragonbones/textures/TextureData.cpp delete mode 100644 native/cocos/editor-support/dragonbones/textures/TextureData.h delete mode 100644 native/cocos/editor-support/spine/Android.mk delete mode 100644 native/cocos/editor-support/spine/Animation.c delete mode 100644 native/cocos/editor-support/spine/Animation.h delete mode 100644 native/cocos/editor-support/spine/AnimationState.c delete mode 100644 native/cocos/editor-support/spine/AnimationState.h delete mode 100644 native/cocos/editor-support/spine/AnimationStateData.c delete mode 100644 native/cocos/editor-support/spine/AnimationStateData.h delete mode 100644 native/cocos/editor-support/spine/Atlas.c delete mode 100644 native/cocos/editor-support/spine/Atlas.h delete mode 100644 native/cocos/editor-support/spine/AtlasAttachmentLoader.c delete mode 100644 native/cocos/editor-support/spine/AtlasAttachmentLoader.h delete mode 100644 native/cocos/editor-support/spine/Attachment.c delete mode 100644 native/cocos/editor-support/spine/Attachment.h delete mode 100644 native/cocos/editor-support/spine/AttachmentLoader.c delete mode 100644 native/cocos/editor-support/spine/AttachmentLoader.h delete mode 100644 native/cocos/editor-support/spine/AttachmentVertices.cpp delete mode 100644 native/cocos/editor-support/spine/AttachmentVertices.h delete mode 100644 native/cocos/editor-support/spine/Bone.c delete mode 100644 native/cocos/editor-support/spine/Bone.h delete mode 100644 native/cocos/editor-support/spine/BoneData.c delete mode 100644 native/cocos/editor-support/spine/BoneData.h delete mode 100644 native/cocos/editor-support/spine/BoundingBoxAttachment.c delete mode 100644 native/cocos/editor-support/spine/BoundingBoxAttachment.h delete mode 100644 native/cocos/editor-support/spine/CMakeLists.txt delete mode 100644 native/cocos/editor-support/spine/Cocos2dAttachmentLoader.cpp delete mode 100644 native/cocos/editor-support/spine/Cocos2dAttachmentLoader.h delete mode 100644 native/cocos/editor-support/spine/Event.c delete mode 100644 native/cocos/editor-support/spine/Event.h delete mode 100644 native/cocos/editor-support/spine/EventData.c delete mode 100644 native/cocos/editor-support/spine/EventData.h delete mode 100644 native/cocos/editor-support/spine/IkConstraint.c delete mode 100644 native/cocos/editor-support/spine/IkConstraint.h delete mode 100644 native/cocos/editor-support/spine/IkConstraintData.c delete mode 100644 native/cocos/editor-support/spine/IkConstraintData.h delete mode 100644 native/cocos/editor-support/spine/Json.c delete mode 100644 native/cocos/editor-support/spine/Json.h delete mode 100644 native/cocos/editor-support/spine/MeshAttachment.c delete mode 100644 native/cocos/editor-support/spine/MeshAttachment.h delete mode 100644 native/cocos/editor-support/spine/PathAttachment.c delete mode 100644 native/cocos/editor-support/spine/PathAttachment.h delete mode 100644 native/cocos/editor-support/spine/PathConstraint.c delete mode 100644 native/cocos/editor-support/spine/PathConstraint.h delete mode 100644 native/cocos/editor-support/spine/PathConstraintData.c delete mode 100644 native/cocos/editor-support/spine/PathConstraintData.h delete mode 100644 native/cocos/editor-support/spine/RegionAttachment.c delete mode 100644 native/cocos/editor-support/spine/RegionAttachment.h delete mode 100644 native/cocos/editor-support/spine/Skeleton.c delete mode 100644 native/cocos/editor-support/spine/Skeleton.h delete mode 100644 native/cocos/editor-support/spine/SkeletonAnimation.cpp delete mode 100644 native/cocos/editor-support/spine/SkeletonAnimation.h delete mode 100644 native/cocos/editor-support/spine/SkeletonBatch.cpp delete mode 100644 native/cocos/editor-support/spine/SkeletonBatch.h delete mode 100644 native/cocos/editor-support/spine/SkeletonBinary.c delete mode 100644 native/cocos/editor-support/spine/SkeletonBinary.h delete mode 100644 native/cocos/editor-support/spine/SkeletonBounds.c delete mode 100644 native/cocos/editor-support/spine/SkeletonBounds.h delete mode 100644 native/cocos/editor-support/spine/SkeletonData.c delete mode 100644 native/cocos/editor-support/spine/SkeletonData.h delete mode 100644 native/cocos/editor-support/spine/SkeletonJson.c delete mode 100644 native/cocos/editor-support/spine/SkeletonJson.h delete mode 100644 native/cocos/editor-support/spine/SkeletonRenderer.cpp delete mode 100644 native/cocos/editor-support/spine/SkeletonRenderer.h delete mode 100644 native/cocos/editor-support/spine/Skin.c delete mode 100644 native/cocos/editor-support/spine/Skin.h delete mode 100644 native/cocos/editor-support/spine/Slot.c delete mode 100644 native/cocos/editor-support/spine/Slot.h delete mode 100644 native/cocos/editor-support/spine/SlotData.c delete mode 100644 native/cocos/editor-support/spine/SlotData.h delete mode 100644 native/cocos/editor-support/spine/TransformConstraint.c delete mode 100644 native/cocos/editor-support/spine/TransformConstraint.h delete mode 100644 native/cocos/editor-support/spine/TransformConstraintData.c delete mode 100644 native/cocos/editor-support/spine/TransformConstraintData.h delete mode 100644 native/cocos/editor-support/spine/VertexAttachment.c delete mode 100644 native/cocos/editor-support/spine/VertexAttachment.h delete mode 100644 native/cocos/editor-support/spine/extension.c delete mode 100644 native/cocos/editor-support/spine/extension.h delete mode 100644 native/cocos/editor-support/spine/kvec.h delete mode 100644 native/cocos/editor-support/spine/proj.win32/libSpine.vcxproj delete mode 100755 native/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters delete mode 100644 native/cocos/editor-support/spine/spine-cocos2dx.cpp delete mode 100644 native/cocos/editor-support/spine/spine-cocos2dx.h delete mode 100644 native/cocos/editor-support/spine/spine.h delete mode 100644 native/cocos/math/CCAffineTransform.cpp delete mode 100644 native/cocos/math/CCAffineTransform.h delete mode 100644 native/cocos/math/TransformUtils.cpp delete mode 100644 native/cocos/math/TransformUtils.h delete mode 100644 native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java delete mode 100644 native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java delete mode 100644 native/cocos/platform/apple/CCLock-apple.cpp delete mode 100644 native/cocos/platform/apple/CCLock-apple.h delete mode 100644 native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp delete mode 100644 native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp delete mode 100644 native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp delete mode 100644 native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.hpp delete mode 100644 native/cocos/scripting/js-bindings/manual/jsb_box2d_manual.cpp delete mode 100644 native/cocos/scripting/js-bindings/manual/jsb_box2d_manual.hpp delete mode 100644 native/tools/tojs/box2d.ini delete mode 100644 native/tools/tojs/cocos2dx_dragonbones.ini delete mode 100644 native/tools/tojs/cocos2dx_experimental_video.ini delete mode 100644 native/tools/tojs/cocos2dx_experimental_webView.ini delete mode 100644 native/tools/tojs/creator.ini delete mode 100644 native/tools/tojs/creator_camera.ini delete mode 100644 native/tools/tojs/creator_graphics.ini delete mode 100644 native/tools/tojs/creator_physics.ini diff --git a/native/build/cocos2d_libs.xcodeproj/project.pbxproj b/native/build/cocos2d_libs.xcodeproj/project.pbxproj index 1e83a3aa32..13f2bc5ed0 100644 --- a/native/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/native/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -610,14 +610,10 @@ 46FDDBB6202ADDCE00931238 /* uthash.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB1F202ADDCE00931238 /* uthash.h */; }; 46FDDBB7202ADDCE00931238 /* ccUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB20202ADDCE00931238 /* ccUtils.h */; }; 46FDDBB8202ADDCE00931238 /* ccUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB20202ADDCE00931238 /* ccUtils.h */; }; - 46FDDBB9202ADDCE00931238 /* CCNS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB21202ADDCE00931238 /* CCNS.cpp */; }; - 46FDDBBA202ADDCE00931238 /* CCNS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB21202ADDCE00931238 /* CCNS.cpp */; }; 46FDDBBB202ADDCE00931238 /* CCRefPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB22202ADDCE00931238 /* CCRefPtr.h */; }; 46FDDBBC202ADDCE00931238 /* CCRefPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB22202ADDCE00931238 /* CCRefPtr.h */; }; 46FDDBC3202ADDCE00931238 /* ccConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB26202ADDCE00931238 /* ccConfig.h */; }; 46FDDBC4202ADDCE00931238 /* ccConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB26202ADDCE00931238 /* ccConfig.h */; }; - 46FDDBC9202ADDCE00931238 /* ccFPSImages.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB29202ADDCE00931238 /* ccFPSImages.h */; }; - 46FDDBCA202ADDCE00931238 /* ccFPSImages.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB29202ADDCE00931238 /* ccFPSImages.h */; }; 46FDDBCB202ADDCE00931238 /* ZipUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB2A202ADDCE00931238 /* ZipUtils.h */; }; 46FDDBCC202ADDCE00931238 /* ZipUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB2A202ADDCE00931238 /* ZipUtils.h */; }; 46FDDBCF202ADDCE00931238 /* CCMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB2C202ADDCE00931238 /* CCMap.h */; }; @@ -628,8 +624,6 @@ 46FDDBDE202ADDCE00931238 /* TGAlib.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB33202ADDCE00931238 /* TGAlib.h */; }; 46FDDBE3202ADDCE00931238 /* CCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB36202ADDCE00931238 /* CCData.cpp */; }; 46FDDBE4202ADDCE00931238 /* CCData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB36202ADDCE00931238 /* CCData.cpp */; }; - 46FDDBE7202ADDCE00931238 /* CCNS.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB38202ADDCE00931238 /* CCNS.h */; }; - 46FDDBE8202ADDCE00931238 /* CCNS.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB38202ADDCE00931238 /* CCNS.h */; }; 46FDDBE9202ADDCE00931238 /* CCAutoreleasePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB39202ADDCE00931238 /* CCAutoreleasePool.h */; }; 46FDDBEA202ADDCE00931238 /* CCAutoreleasePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB39202ADDCE00931238 /* CCAutoreleasePool.h */; }; 46FDDBF9202ADDCE00931238 /* etc1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB41202ADDCE00931238 /* etc1.cpp */; }; @@ -638,8 +632,6 @@ 46FDDBFC202ADDCE00931238 /* ccCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB42202ADDCE00931238 /* ccCArray.cpp */; }; 46FDDBFD202ADDCE00931238 /* CCValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB43202ADDCE00931238 /* CCValue.cpp */; }; 46FDDBFE202ADDCE00931238 /* CCValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB43202ADDCE00931238 /* CCValue.cpp */; }; - 46FDDBFF202ADDCE00931238 /* firePngData.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB44202ADDCE00931238 /* firePngData.h */; }; - 46FDDC00202ADDCE00931238 /* firePngData.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB44202ADDCE00931238 /* firePngData.h */; }; 46FDDC01202ADDCE00931238 /* ccCArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB45202ADDCE00931238 /* ccCArray.h */; }; 46FDDC02202ADDCE00931238 /* ccCArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB45202ADDCE00931238 /* ccCArray.h */; }; 46FDDC63202D502F00931238 /* CCApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDC62202D502E00931238 /* CCApplication.h */; }; @@ -854,10 +846,6 @@ 50643BE219BFCF1800EF68ED /* CCPlatformConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 50643BE019BFCF1800EF68ED /* CCPlatformConfig.h */; }; 50643BE319BFCF1800EF68ED /* CCPlatformConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 50643BE019BFCF1800EF68ED /* CCPlatformConfig.h */; }; 5091A7A319BFABA800AC8789 /* CCPlatformDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 5091A7A219BFABA800AC8789 /* CCPlatformDefine.h */; }; - 50ABBD381925AB0000A911A9 /* CCAffineTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBD1B1925AB0000A911A9 /* CCAffineTransform.cpp */; }; - 50ABBD391925AB0000A911A9 /* CCAffineTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBD1B1925AB0000A911A9 /* CCAffineTransform.cpp */; }; - 50ABBD3A1925AB0000A911A9 /* CCAffineTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBD1C1925AB0000A911A9 /* CCAffineTransform.h */; }; - 50ABBD3B1925AB0000A911A9 /* CCAffineTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBD1C1925AB0000A911A9 /* CCAffineTransform.h */; }; 50ABBD3C1925AB0000A911A9 /* CCGeometry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBD1D1925AB0000A911A9 /* CCGeometry.cpp */; }; 50ABBD3D1925AB0000A911A9 /* CCGeometry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBD1D1925AB0000A911A9 /* CCGeometry.cpp */; }; 50ABBD3E1925AB0000A911A9 /* CCGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBD1E1925AB0000A911A9 /* CCGeometry.h */; }; @@ -882,10 +870,6 @@ 50ABBD511925AB0000A911A9 /* Quaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBD2A1925AB0000A911A9 /* Quaternion.cpp */; }; 50ABBD521925AB0000A911A9 /* Quaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBD2B1925AB0000A911A9 /* Quaternion.h */; }; 50ABBD531925AB0000A911A9 /* Quaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBD2B1925AB0000A911A9 /* Quaternion.h */; }; - 50ABBD541925AB0000A911A9 /* TransformUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBD2D1925AB0000A911A9 /* TransformUtils.cpp */; }; - 50ABBD551925AB0000A911A9 /* TransformUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBD2D1925AB0000A911A9 /* TransformUtils.cpp */; }; - 50ABBD561925AB0000A911A9 /* TransformUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBD2E1925AB0000A911A9 /* TransformUtils.h */; }; - 50ABBD571925AB0000A911A9 /* TransformUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBD2E1925AB0000A911A9 /* TransformUtils.h */; }; 50ABBD581925AB0000A911A9 /* Vec2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBD2F1925AB0000A911A9 /* Vec2.cpp */; }; 50ABBD591925AB0000A911A9 /* Vec2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBD2F1925AB0000A911A9 /* Vec2.cpp */; }; 50ABBD5A1925AB0000A911A9 /* Vec2.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBD301925AB0000A911A9 /* Vec2.h */; }; @@ -902,10 +886,6 @@ 50ABBFFE1926664800A911A9 /* CCFileUtils-apple.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF1B1926664700A911A9 /* CCFileUtils-apple.h */; }; 50ABBFFF1926664800A911A9 /* CCFileUtils-apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBF1C1926664700A911A9 /* CCFileUtils-apple.mm */; }; 50ABC0001926664800A911A9 /* CCFileUtils-apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBF1C1926664700A911A9 /* CCFileUtils-apple.mm */; }; - 50ABC0011926664800A911A9 /* CCLock-apple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBF1D1926664700A911A9 /* CCLock-apple.cpp */; }; - 50ABC0021926664800A911A9 /* CCLock-apple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBF1D1926664700A911A9 /* CCLock-apple.cpp */; }; - 50ABC0031926664800A911A9 /* CCLock-apple.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF1E1926664700A911A9 /* CCLock-apple.h */; }; - 50ABC0041926664800A911A9 /* CCLock-apple.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF1E1926664700A911A9 /* CCLock-apple.h */; }; 50ABC00B1926664800A911A9 /* CCDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF221926664700A911A9 /* CCDevice.h */; }; 50ABC00C1926664800A911A9 /* CCDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF221926664700A911A9 /* CCDevice.h */; }; 50ABC00D1926664800A911A9 /* CCFileUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ABBF231926664700A911A9 /* CCFileUtils.cpp */; }; @@ -1328,21 +1308,17 @@ 46FDDB16202ADDCE00931238 /* pvr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pvr.cpp; sourceTree = ""; }; 46FDDB1F202ADDCE00931238 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; 46FDDB20202ADDCE00931238 /* ccUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccUtils.h; sourceTree = ""; }; - 46FDDB21202ADDCE00931238 /* CCNS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNS.cpp; sourceTree = ""; }; 46FDDB22202ADDCE00931238 /* CCRefPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCRefPtr.h; sourceTree = ""; }; 46FDDB26202ADDCE00931238 /* ccConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccConfig.h; sourceTree = ""; }; - 46FDDB29202ADDCE00931238 /* ccFPSImages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccFPSImages.h; sourceTree = ""; }; 46FDDB2A202ADDCE00931238 /* ZipUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZipUtils.h; sourceTree = ""; }; 46FDDB2C202ADDCE00931238 /* CCMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMap.h; sourceTree = ""; }; 46FDDB2D202ADDCE00931238 /* ccUTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccUTF8.h; sourceTree = ""; }; 46FDDB33202ADDCE00931238 /* TGAlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGAlib.h; sourceTree = ""; }; 46FDDB36202ADDCE00931238 /* CCData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCData.cpp; sourceTree = ""; }; - 46FDDB38202ADDCE00931238 /* CCNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNS.h; sourceTree = ""; }; 46FDDB39202ADDCE00931238 /* CCAutoreleasePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAutoreleasePool.h; sourceTree = ""; }; 46FDDB41202ADDCE00931238 /* etc1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = etc1.cpp; sourceTree = ""; }; 46FDDB42202ADDCE00931238 /* ccCArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccCArray.cpp; sourceTree = ""; }; 46FDDB43202ADDCE00931238 /* CCValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCValue.cpp; sourceTree = ""; }; - 46FDDB44202ADDCE00931238 /* firePngData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = firePngData.h; sourceTree = ""; }; 46FDDB45202ADDCE00931238 /* ccCArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccCArray.h; sourceTree = ""; }; 46FDDC62202D502E00931238 /* CCApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCApplication.h; path = ../CCApplication.h; sourceTree = ""; }; 46FDDC65202D504D00931238 /* CCApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCApplication.h; sourceTree = ""; }; @@ -1458,8 +1434,6 @@ 50643BD819BFAF4400EF68ED /* CCStdC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCStdC.h; sourceTree = ""; }; 50643BE019BFCF1800EF68ED /* CCPlatformConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPlatformConfig.h; sourceTree = ""; }; 5091A7A219BFABA800AC8789 /* CCPlatformDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPlatformDefine.h; sourceTree = ""; }; - 50ABBD1B1925AB0000A911A9 /* CCAffineTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAffineTransform.cpp; sourceTree = ""; }; - 50ABBD1C1925AB0000A911A9 /* CCAffineTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAffineTransform.h; sourceTree = ""; }; 50ABBD1D1925AB0000A911A9 /* CCGeometry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGeometry.cpp; sourceTree = ""; }; 50ABBD1E1925AB0000A911A9 /* CCGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGeometry.h; sourceTree = ""; }; 50ABBD1F1925AB0000A911A9 /* CCMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMath.h; sourceTree = ""; }; @@ -1476,8 +1450,6 @@ 50ABBD2A1925AB0000A911A9 /* Quaternion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Quaternion.cpp; sourceTree = ""; }; 50ABBD2B1925AB0000A911A9 /* Quaternion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Quaternion.h; sourceTree = ""; }; 50ABBD2C1925AB0000A911A9 /* Quaternion.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Quaternion.inl; sourceTree = ""; }; - 50ABBD2D1925AB0000A911A9 /* TransformUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformUtils.cpp; sourceTree = ""; }; - 50ABBD2E1925AB0000A911A9 /* TransformUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformUtils.h; sourceTree = ""; }; 50ABBD2F1925AB0000A911A9 /* Vec2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Vec2.cpp; sourceTree = ""; }; 50ABBD301925AB0000A911A9 /* Vec2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vec2.h; sourceTree = ""; }; 50ABBD311925AB0000A911A9 /* Vec2.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Vec2.inl; sourceTree = ""; }; @@ -1489,8 +1461,6 @@ 50ABBD371925AB0000A911A9 /* Vec4.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Vec4.inl; sourceTree = ""; }; 50ABBF1B1926664700A911A9 /* CCFileUtils-apple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CCFileUtils-apple.h"; sourceTree = ""; }; 50ABBF1C1926664700A911A9 /* CCFileUtils-apple.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "CCFileUtils-apple.mm"; sourceTree = ""; }; - 50ABBF1D1926664700A911A9 /* CCLock-apple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "CCLock-apple.cpp"; sourceTree = ""; }; - 50ABBF1E1926664700A911A9 /* CCLock-apple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CCLock-apple.h"; sourceTree = ""; }; 50ABBF221926664700A911A9 /* CCDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDevice.h; sourceTree = ""; }; 50ABBF231926664700A911A9 /* CCFileUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFileUtils.cpp; sourceTree = ""; }; 50ABBF241926664700A911A9 /* CCFileUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFileUtils.h; sourceTree = ""; }; @@ -2060,8 +2030,6 @@ 46A170851807CE87005B8026 /* math */ = { isa = PBXGroup; children = ( - 50ABBD1B1925AB0000A911A9 /* CCAffineTransform.cpp */, - 50ABBD1C1925AB0000A911A9 /* CCAffineTransform.h */, 50ABBD1D1925AB0000A911A9 /* CCGeometry.cpp */, 50ABBD1E1925AB0000A911A9 /* CCGeometry.h */, 50ABBD1F1925AB0000A911A9 /* CCMath.h */, @@ -2080,8 +2048,6 @@ 50ABBD2A1925AB0000A911A9 /* Quaternion.cpp */, 50ABBD2B1925AB0000A911A9 /* Quaternion.h */, 50ABBD2C1925AB0000A911A9 /* Quaternion.inl */, - 50ABBD2D1925AB0000A911A9 /* TransformUtils.cpp */, - 50ABBD2E1925AB0000A911A9 /* TransformUtils.h */, 50ABBD2F1925AB0000A911A9 /* Vec2.cpp */, 50ABBD301925AB0000A911A9 /* Vec2.h */, 50ABBD311925AB0000A911A9 /* Vec2.inl */, @@ -2215,59 +2181,55 @@ 46FDDAE9202ADDCE00931238 /* base */ = { isa = PBXGroup; children = ( - 4648882420AC2BC900CD1E4A /* CCRenderTexture.cpp */, - 4648882320AC2BC800CD1E4A /* CCRenderTexture.h */, - 1A52DAF5205BB81400350EE3 /* CCThreadPool.cpp */, - 1A52DAF4205BB81400350EE3 /* CCThreadPool.h */, - 1A29D7792056667700168D9A /* csscolorparser.cpp */, - 1A29D77A2056667800168D9A /* csscolorparser.hpp */, - 461786522052301A008256E1 /* CCScheduler.cpp */, - 461786512052301A008256E1 /* CCScheduler.h */, - 46930465204FE20F004A3D6C /* CCLog.cpp */, - 46930464204FE20F004A3D6C /* CCLog.h */, + 46FDDAFD202ADDCE00931238 /* base64.cpp */, + 46FDDAFA202ADDCE00931238 /* base64.h */, + 46FDDB0A202ADDCE00931238 /* CCAutoreleasePool.cpp */, + 46FDDB39202ADDCE00931238 /* CCAutoreleasePool.h */, + 46FDDB42202ADDCE00931238 /* ccCArray.cpp */, + 46FDDB45202ADDCE00931238 /* ccCArray.h */, + 46FDDB26202ADDCE00931238 /* ccConfig.h */, 469301CE203FC695004A3D6C /* CCConfiguration.cpp */, 469301CD203FC695004A3D6C /* CCConfiguration.h */, - 46FDDAEB202ADDCE00931238 /* pvr.h */, - 46FDDAEC202ADDCE00931238 /* CCValue.h */, - 46FDDAEE202ADDCE00931238 /* utlist.h */, - 46FDDAF2202ADDCE00931238 /* CCData.h */, - 46FDDAF3202ADDCE00931238 /* ccMacros.h */, - 46FDDAF7202ADDCE00931238 /* ccRandom.cpp */, - 46FDDAFA202ADDCE00931238 /* base64.h */, - 46FDDAFB202ADDCE00931238 /* etc1.h */, - 46FDDAFC202ADDCE00931238 /* ZipUtils.cpp */, - 46FDDAFD202ADDCE00931238 /* base64.cpp */, - 46FDDB02202ADDCE00931238 /* CCRef.cpp */, - 46FDDB05202ADDCE00931238 /* ccTypes.h */, - 46FDDB06202ADDCE00931238 /* ccRandom.h */, - 46FDDB09202ADDCE00931238 /* CCRef.h */, - 46FDDB0A202ADDCE00931238 /* CCAutoreleasePool.cpp */, - 46FDDB0B202ADDCE00931238 /* ccTypes.cpp */, - 46FDDB0C202ADDCE00931238 /* ccUtils.cpp */, - 46FDDB0E202ADDCE00931238 /* TGAlib.cpp */, - 46FDDB11202ADDCE00931238 /* ccUTF8.cpp */, - 46FDDB14202ADDCE00931238 /* CCVector.h */, - 46FDDB16202ADDCE00931238 /* pvr.cpp */, - 46FDDB1F202ADDCE00931238 /* uthash.h */, - 46FDDB20202ADDCE00931238 /* ccUtils.h */, - 46FDDB21202ADDCE00931238 /* CCNS.cpp */, - 46FDDB22202ADDCE00931238 /* CCRefPtr.h */, - 46FDDB26202ADDCE00931238 /* ccConfig.h */, - 46FDDB29202ADDCE00931238 /* ccFPSImages.h */, - 46FDDB2A202ADDCE00931238 /* ZipUtils.h */, - 46FDDB2C202ADDCE00931238 /* CCMap.h */, - 46FDDB2D202ADDCE00931238 /* ccUTF8.h */, - 46FDDB33202ADDCE00931238 /* TGAlib.h */, 46FDDB36202ADDCE00931238 /* CCData.cpp */, - 46FDDB38202ADDCE00931238 /* CCNS.h */, - 46FDDB39202ADDCE00931238 /* CCAutoreleasePool.h */, - 46FDDB41202ADDCE00931238 /* etc1.cpp */, - 46FDDB42202ADDCE00931238 /* ccCArray.cpp */, - 46FDDB43202ADDCE00931238 /* CCValue.cpp */, - 46FDDB44202ADDCE00931238 /* firePngData.h */, - 46FDDB45202ADDCE00931238 /* ccCArray.h */, + 46FDDAF2202ADDCE00931238 /* CCData.h */, 1A14FD8F2080B4E300E10ABE /* CCGLUtils.cpp */, 1A14FD902080B4E300E10ABE /* CCGLUtils.h */, + 46930465204FE20F004A3D6C /* CCLog.cpp */, + 46930464204FE20F004A3D6C /* CCLog.h */, + 46FDDAF3202ADDCE00931238 /* ccMacros.h */, + 46FDDB2C202ADDCE00931238 /* CCMap.h */, + 46FDDAF7202ADDCE00931238 /* ccRandom.cpp */, + 46FDDB06202ADDCE00931238 /* ccRandom.h */, + 46FDDB02202ADDCE00931238 /* CCRef.cpp */, + 46FDDB09202ADDCE00931238 /* CCRef.h */, + 46FDDB22202ADDCE00931238 /* CCRefPtr.h */, + 4648882420AC2BC900CD1E4A /* CCRenderTexture.cpp */, + 4648882320AC2BC800CD1E4A /* CCRenderTexture.h */, + 461786522052301A008256E1 /* CCScheduler.cpp */, + 461786512052301A008256E1 /* CCScheduler.h */, + 1A52DAF5205BB81400350EE3 /* CCThreadPool.cpp */, + 1A52DAF4205BB81400350EE3 /* CCThreadPool.h */, + 46FDDB0B202ADDCE00931238 /* ccTypes.cpp */, + 46FDDB05202ADDCE00931238 /* ccTypes.h */, + 46FDDB11202ADDCE00931238 /* ccUTF8.cpp */, + 46FDDB2D202ADDCE00931238 /* ccUTF8.h */, + 46FDDB0C202ADDCE00931238 /* ccUtils.cpp */, + 46FDDB20202ADDCE00931238 /* ccUtils.h */, + 46FDDB43202ADDCE00931238 /* CCValue.cpp */, + 46FDDAEC202ADDCE00931238 /* CCValue.h */, + 46FDDB14202ADDCE00931238 /* CCVector.h */, + 1A29D7792056667700168D9A /* csscolorparser.cpp */, + 1A29D77A2056667800168D9A /* csscolorparser.hpp */, + 46FDDB41202ADDCE00931238 /* etc1.cpp */, + 46FDDAFB202ADDCE00931238 /* etc1.h */, + 46FDDB16202ADDCE00931238 /* pvr.cpp */, + 46FDDAEB202ADDCE00931238 /* pvr.h */, + 46FDDB0E202ADDCE00931238 /* TGAlib.cpp */, + 46FDDB33202ADDCE00931238 /* TGAlib.h */, + 46FDDB1F202ADDCE00931238 /* uthash.h */, + 46FDDAEE202ADDCE00931238 /* utlist.h */, + 46FDDAFC202ADDCE00931238 /* ZipUtils.cpp */, + 46FDDB2A202ADDCE00931238 /* ZipUtils.h */, ); name = base; path = ../cocos/base; @@ -2495,8 +2457,6 @@ 294D7D991D0E93A2002CE7B7 /* CCDevice-apple.mm */, 50ABBF1B1926664700A911A9 /* CCFileUtils-apple.h */, 50ABBF1C1926664700A911A9 /* CCFileUtils-apple.mm */, - 50ABBF1D1926664700A911A9 /* CCLock-apple.cpp */, - 50ABBF1E1926664700A911A9 /* CCLock-apple.h */, ); path = apple; sourceTree = ""; @@ -2670,7 +2630,6 @@ 46FDDBC3202ADDCE00931238 /* ccConfig.h in Headers */, 46FDDA77202ACC6A00931238 /* Light.h in Headers */, 1A28FF5D1F20AFAB007A1D9D /* SRProxyConnect.h in Headers */, - 46FDDBFF202ADDCE00931238 /* firePngData.h in Headers */, 1A52DB5F205BCDC700350EE3 /* HelperMacros.h in Headers */, 46FDDACF202ACC6A00931238 /* RenderBuffer.h in Headers */, 46FDDAAF202ACC6A00931238 /* Texture2D.h in Headers */, @@ -2716,7 +2675,6 @@ 1AAAC8F5205CB6E9005321B9 /* Export.h in Headers */, 4DED48181DFFA4AF0070C5C4 /* b2Timer.h in Headers */, 1A28FF5B1F20AFAB007A1D9D /* NSURLRequest+SRWebSocketPrivate.h in Headers */, - 46FDDBE7202ADDCE00931238 /* CCNS.h in Headers */, 46FDDAAB202ACC6A00931238 /* Types.h in Headers */, ED30577D1BEC76C90083C3ED /* crypt.h in Headers */, 1A9F0F991F301DE200A499E1 /* b2ObjectDestroyNotifier.h in Headers */, @@ -2806,7 +2764,6 @@ 1A28FF9B1F20AFAB007A1D9D /* SRWebSocket.h in Headers */, 50643BE219BFCF1800EF68ED /* CCPlatformConfig.h in Headers */, 1A28FF611F20AFAB007A1D9D /* SRRunLoopThread.h in Headers */, - 50ABBD561925AB0000A911A9 /* TransformUtils.h in Headers */, 469303D22046AE05004A3D6C /* jsb_gfx_auto.hpp in Headers */, 1A52DB5E205BCDC700350EE3 /* Class.hpp in Headers */, 4693039C2046AE05004A3D6C /* PlatformUtils.h in Headers */, @@ -2873,7 +2830,6 @@ 46AE3FEB2092F3A600F3A228 /* node_mutex.h in Headers */, 4617864320522469008256E1 /* HttpRequest.h in Headers */, 1A28FF651F20AFAB007A1D9D /* SRPinningSecurityPolicy.h in Headers */, - 46FDDBC9202ADDCE00931238 /* ccFPSImages.h in Headers */, 46FDDA85202ACC6A00931238 /* View.h in Headers */, 46AE3FF72092F3A600F3A228 /* util-inl.h in Headers */, 4DED484E1DFFA4AF0070C5C4 /* b2EdgeAndPolygonContact.h in Headers */, @@ -2884,7 +2840,6 @@ 46AE40012092F3A600F3A228 /* SHA1.h in Headers */, 46178670205262BC008256E1 /* jsb_conversions.hpp in Headers */, 469303A82046AE05004A3D6C /* SeApi.h in Headers */, - 50ABBD3A1925AB0000A911A9 /* CCAffineTransform.h in Headers */, 50ABBD5A1925AB0000A911A9 /* Vec2.h in Headers */, 1A37E9C7200DDFC70078AF72 /* CCReachability.h in Headers */, 46FDDB81202ADDCE00931238 /* ccTypes.h in Headers */, @@ -2907,7 +2862,6 @@ 4617866D2052609B008256E1 /* jsb_cocos2dx_network_auto.hpp in Headers */, 50ABC00F1926664800A911A9 /* CCFileUtils.h in Headers */, 1A28FF4D1F20AFAB007A1D9D /* SRDelegateController.h in Headers */, - 50ABC0031926664800A911A9 /* CCLock-apple.h in Headers */, 46FDDB9F202ADDCE00931238 /* CCVector.h in Headers */, 50ABBD5E1925AB0000A911A9 /* Vec3.h in Headers */, 4617863120522469008256E1 /* SocketIO.h in Headers */, @@ -2948,7 +2902,6 @@ 469303892046AE05004A3D6C /* HandleObject.hpp in Headers */, 503DD8EF1926736A00CD74DD /* CCPlatformDefine-ios.h in Headers */, 1A28FF921F20AFAB007A1D9D /* NSURLRequest+SRWebSocket.h in Headers */, - 50ABBD3B1925AB0000A911A9 /* CCAffineTransform.h in Headers */, 46FDDB5C202ADDCE00931238 /* CCData.h in Headers */, 469303832046AE05004A3D6C /* Value.hpp in Headers */, 1A28FF961F20AFAB007A1D9D /* SocketRocket.h in Headers */, @@ -2956,7 +2909,6 @@ 4617864620522469008256E1 /* HttpAsynConnection-apple.h in Headers */, 46FDDAA8202ACC6A00931238 /* ForwardRenderer.h in Headers */, 1A29D79B205666F500168D9A /* jsb_opengl_utils.hpp in Headers */, - 50ABC0041926664800A911A9 /* CCLock-apple.h in Headers */, 1A28FF8E1F20AFAB007A1D9D /* NSRunLoop+SRWebSocket.h in Headers */, 46FDDBA0202ADDCE00931238 /* CCVector.h in Headers */, 46FDDB54202ADDCE00931238 /* utlist.h in Headers */, @@ -3011,7 +2963,6 @@ 46FDDA98202ACC6A00931238 /* Model.h in Headers */, 4DED482F1DFFA4AF0070C5C4 /* b2World.h in Headers */, 469304112046AE06004A3D6C /* jsb_helper.hpp in Headers */, - 50ABBD571925AB0000A911A9 /* TransformUtils.h in Headers */, 1A52DAF7205BB81400350EE3 /* CCThreadPool.h in Headers */, 50ABBD5B1925AB0000A911A9 /* Vec2.h in Headers */, 50ABBD411925AB0000A911A9 /* CCMath.h in Headers */, @@ -3046,14 +2997,12 @@ 469304012046AE06004A3D6C /* jsb_global.h in Headers */, 4DED47E91DFFA4AF0070C5C4 /* b2DynamicTree.h in Headers */, 46AE3FF82092F3A600F3A228 /* util-inl.h in Headers */, - 46FDDBCA202ADDCE00931238 /* ccFPSImages.h in Headers */, 46FDDADE202ACC6A00931238 /* VertexBuffer.h in Headers */, 1A28FF621F20AFAB007A1D9D /* SRRunLoopThread.h in Headers */, 4DED48031DFFA4AF0070C5C4 /* b2BlockAllocator.h in Headers */, 46FDDA86202ACC6A00931238 /* View.h in Headers */, 46FDDAD8202ACC6A00931238 /* GFXUtils.h in Headers */, 46FDDB82202ADDCE00931238 /* ccTypes.h in Headers */, - 46FDDC00202ADDCE00931238 /* firePngData.h in Headers */, 50ABC00C1926664800A911A9 /* CCDevice.h in Headers */, 4DED483B1DFFA4AF0070C5C4 /* b2ChainAndPolygonContact.h in Headers */, 4DED48071DFFA4AF0070C5C4 /* b2Draw.h in Headers */, @@ -3127,7 +3076,6 @@ 4DED487F1DFFA4AF0070C5C4 /* b2RopeJoint.h in Headers */, 50ABBD4B1925AB0000A911A9 /* Mat4.h in Headers */, 50ABBD531925AB0000A911A9 /* Quaternion.h in Headers */, - 46FDDBE8202ADDCE00931238 /* CCNS.h in Headers */, 4617863E20522469008256E1 /* HttpResponse.h in Headers */, 4DED484B1DFFA4AF0070C5C4 /* b2EdgeAndCircleContact.h in Headers */, 461786542052301A008256E1 /* CCScheduler.h in Headers */, @@ -3267,7 +3215,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 46FDDBB9202ADDCE00931238 /* CCNS.cpp in Sources */, 1A29D794205666F500168D9A /* jsb_opengl_manual.cpp in Sources */, 4693038C2046AE05004A3D6C /* config.cpp in Sources */, 46FDDA7D202ACC6A00931238 /* Light.cpp in Sources */, @@ -3407,7 +3354,6 @@ 4617862F20522469008256E1 /* HttpClient-apple.mm in Sources */, 4617862B20522469008256E1 /* WebSocket-apple.mm in Sources */, 46FDDAE3202ACC6A00931238 /* GFX.cpp in Sources */, - 50ABC0011926664800A911A9 /* CCLock-apple.cpp in Sources */, ED30579C1BEC77B70083C3ED /* ConvertUTFWrapper.cpp in Sources */, 4DED48261DFFA4AF0070C5C4 /* b2Island.cpp in Sources */, 46AE3FF12092F3A600F3A228 /* SHA1.cpp in Sources */, @@ -3435,7 +3381,6 @@ 50ABC0631926664800A911A9 /* CCDevice-mac.mm in Sources */, 461786552052301A008256E1 /* CCScheduler.cpp in Sources */, 4DED48781DFFA4AF0070C5C4 /* b2RevoluteJoint.cpp in Sources */, - 50ABBD541925AB0000A911A9 /* TransformUtils.cpp in Sources */, 46FDDAD5202ACC6A00931238 /* GraphicsHandle.cpp in Sources */, BA68D77D1D62F4A500B7A3F9 /* shapes.cc in Sources */, 46FDDA9D202ACC6A00931238 /* BaseRenderer.cpp in Sources */, @@ -3479,7 +3424,6 @@ 46FDDA93202ACC6A00931238 /* Technique.cpp in Sources */, 46FDDBFD202ADDCE00931238 /* CCValue.cpp in Sources */, ED3057A11BEC77D50083C3ED /* xxhash.c in Sources */, - 50ABBD381925AB0000A911A9 /* CCAffineTransform.cpp in Sources */, 46FDDA6F202ACC6A00931238 /* Pass.cpp in Sources */, 4617863520522469008256E1 /* HttpAsynConnection-apple.m in Sources */, 461786612052607E008256E1 /* jsb_socketio.cpp in Sources */, @@ -3548,7 +3492,6 @@ 46FDDAB2202ACC6A00931238 /* DeviceGraphics.cpp in Sources */, 46FDDBFA202ADDCE00931238 /* etc1.cpp in Sources */, 46FDDA88202ACC6A00931238 /* View.cpp in Sources */, - 50ABBD551925AB0000A911A9 /* TransformUtils.cpp in Sources */, 4DED480B1DFFA4AF0070C5C4 /* b2Math.cpp in Sources */, 50ABBD591925AB0000A911A9 /* Vec2.cpp in Sources */, 4DED487D1DFFA4AF0070C5C4 /* b2RopeJoint.cpp in Sources */, @@ -3597,7 +3540,6 @@ 46FDDA70202ACC6A00931238 /* Pass.cpp in Sources */, 1A52DB7A205BCDD000350EE3 /* ScriptEngine.cpp in Sources */, 1A14FD922080B4E300E10ABE /* CCGLUtils.cpp in Sources */, - 46FDDBBA202ADDCE00931238 /* CCNS.cpp in Sources */, 1A28FF741F20AFAB007A1D9D /* SRHash.m in Sources */, 46FDDB70202ADDCE00931238 /* ZipUtils.cpp in Sources */, 50ABBD511925AB0000A911A9 /* Quaternion.cpp in Sources */, @@ -3661,7 +3603,6 @@ 469303BF2046AE05004A3D6C /* jsb_renderer_auto.cpp in Sources */, 4DED48391DFFA4AF0070C5C4 /* b2ChainAndPolygonContact.cpp in Sources */, 4617864F205224D6008256E1 /* HttpAsynConnection-apple.m in Sources */, - 50ABBD391925AB0000A911A9 /* CCAffineTransform.cpp in Sources */, 4DED480F1DFFA4AF0070C5C4 /* b2Settings.cpp in Sources */, 1A52DB8E2060DEF500350EE3 /* jsb_platfrom_apple.mm in Sources */, 503DD8E71926736A00CD74DD /* CCEAGLView-ios.mm in Sources */, @@ -3695,7 +3636,6 @@ 46FDDABC202ACC6A00931238 /* VertexFormat.cpp in Sources */, 50ABBD5D1925AB0000A911A9 /* Vec3.cpp in Sources */, 46AE3FF62092F3A600F3A228 /* util.cc in Sources */, - 50ABC0021926664800A911A9 /* CCLock-apple.cpp in Sources */, 4DED48451DFFA4AF0070C5C4 /* b2ContactSolver.cpp in Sources */, BA68D7921D62F4A500B7A3F9 /* sweep_context.cc in Sources */, 461786662052607E008256E1 /* jsb_websocket.cpp in Sources */, diff --git a/native/cocos/Android.mk b/native/cocos/Android.mk index 535da58504..c8999aad32 100644 --- a/native/cocos/Android.mk +++ b/native/cocos/Android.mk @@ -19,22 +19,17 @@ platform/CCFileUtils.cpp \ platform/CCImage.cpp \ platform/CCSAXParser.cpp \ $(MATHNEONFILE) \ -math/CCAffineTransform.cpp \ math/CCGeometry.cpp \ math/CCVertex.cpp \ math/Mat4.cpp \ math/Quaternion.cpp \ -math/TransformUtils.cpp \ math/Vec2.cpp \ math/Vec3.cpp \ math/Vec4.cpp \ base/CCAutoreleasePool.cpp \ base/CCConfiguration.cpp \ base/CCData.cpp \ -base/CCNS.cpp \ base/CCRef.cpp \ -base/CCUserDefault-android.cpp \ -base/CCUserDefault.cpp \ base/CCValue.cpp \ base/CCThreadPool.cpp \ base/TGAlib.cpp \ diff --git a/native/cocos/base/CCNS.cpp b/native/cocos/base/CCNS.cpp deleted file mode 100644 index cebd248db4..0000000000 --- a/native/cocos/base/CCNS.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#include "base/CCNS.h" -#include -#include -#include -#include - -#include "base/ccUtils.h" - -using namespace std; - -NS_CC_BEGIN - -typedef std::vector strArray; - -// string toolkit -static inline void split(const std::string& src, const std::string& token, strArray& vect) -{ - size_t nend = 0; - size_t nbegin = 0; - size_t tokenSize = token.size(); - while(nend != std::string::npos) - { - nend = src.find(token, nbegin); - if(nend == std::string::npos) - vect.push_back(src.substr(nbegin, src.length()-nbegin)); - else - vect.push_back(src.substr(nbegin, nend-nbegin)); - nbegin = nend + tokenSize; - } -} - -// first, judge whether the form of the string like this: {x,y} -// if the form is right,the string will be split into the parameter strs; -// or the parameter strs will be empty. -// if the form is right return true,else return false. -static bool splitWithForm(const std::string& content, strArray& strs) -{ - bool bRet = false; - - do - { - CC_BREAK_IF(content.empty()); - - size_t nPosLeft = content.find('{'); - size_t nPosRight = content.find('}'); - - // don't have '{' and '}' - CC_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos); - // '}' is before '{' - CC_BREAK_IF(nPosLeft > nPosRight); - - const std::string pointStr = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1); - // nothing between '{' and '}' - CC_BREAK_IF(pointStr.length() == 0); - - size_t nPos1 = pointStr.find('{'); - size_t nPos2 = pointStr.find('}'); - // contain '{' or '}' - CC_BREAK_IF(nPos1 != std::string::npos || nPos2 != std::string::npos); - - split(pointStr, ",", strs); - if (strs.size() != 2 || strs[0].length() == 0 || strs[1].length() == 0) - { - strs.clear(); - break; - } - - bRet = true; - } while (0); - - return bRet; -} - -// implement the functions - -Rect RectFromString(const std::string& str) -{ - Rect result = Rect::ZERO; - - do - { - CC_BREAK_IF(str.empty()); - std::string content = str; - - // find the first '{' and the third '}' - size_t nPosLeft = content.find('{'); - size_t nPosRight = content.find('}'); - for (int i = 1; i < 3; ++i) - { - if (nPosRight == std::string::npos) - { - break; - } - nPosRight = content.find('}', nPosRight + 1); - } - CC_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos); - - content = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1); - size_t nPointEnd = content.find('}'); - CC_BREAK_IF(nPointEnd == std::string::npos); - nPointEnd = content.find(',', nPointEnd); - CC_BREAK_IF(nPointEnd == std::string::npos); - - // get the point string and size string - const std::string pointStr = content.substr(0, nPointEnd); - const std::string sizeStr = content.substr(nPointEnd + 1, content.length() - nPointEnd); - - // split the string with ',' - strArray pointInfo; - CC_BREAK_IF(!splitWithForm(pointStr, pointInfo)); - strArray sizeInfo; - CC_BREAK_IF(!splitWithForm(sizeStr, sizeInfo)); - - float x = (float) utils::atof(pointInfo[0].c_str()); - float y = (float) utils::atof(pointInfo[1].c_str()); - float width = (float) utils::atof(sizeInfo[0].c_str()); - float height = (float) utils::atof(sizeInfo[1].c_str()); - - result = Rect(x, y, width, height); - } while (0); - - return result; -} - -Vec2 PointFromString(const std::string& str) -{ - Vec2 ret; - - do - { - strArray strs; - CC_BREAK_IF(!splitWithForm(str, strs)); - - float x = (float) utils::atof(strs[0].c_str()); - float y = (float) utils::atof(strs[1].c_str()); - - ret.set(x, y); - } while (0); - - return ret; -} - -Size SizeFromString(const std::string& pszContent) -{ - Size ret = Size::ZERO; - - do - { - strArray strs; - CC_BREAK_IF(!splitWithForm(pszContent, strs)); - - float width = (float) utils::atof(strs[0].c_str()); - float height = (float) utils::atof(strs[1].c_str()); - - ret = Size(width, height); - } while (0); - - return ret; -} - -NS_CC_END - diff --git a/native/cocos/base/CCNS.h b/native/cocos/base/CCNS.h deleted file mode 100644 index 337c55b9db..0000000000 --- a/native/cocos/base/CCNS.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __PLATFOMR_CCNS_H__ -#define __PLATFOMR_CCNS_H__ - -#include "math/CCGeometry.h" - -NS_CC_BEGIN - -/** - * @addtogroup base - * @{ - */ - -/** - * @brief Returns a Core Graphics rectangle structure corresponding to the data in a given string. - * @param str A string object whose contents are of the form "{{x,y},{w, h}}", - * where x is the x coordinate, y is the y coordinate, w is the width, and h is the height. - * These components can represent integer or float values. - * An example of a valid string is "{{3,2},{4,5}}". - * The string is not localized, so items are always separated with a comma. - * @return A Core Graphics structure that represents a rectangle. - * If the string is not well-formed, the function returns Rect::ZERO. - */ -Rect CC_DLL RectFromString(const std::string& str); - -/** - * @brief Returns a Core Graphics point structure corresponding to the data in a given string. - * @param str A string object whose contents are of the form "{x,y}", - * where x is the x coordinate and y is the y coordinate. - * The x and y values can represent integer or float values. - * An example of a valid string is "{3.0,2.5}". - * The string is not localized, so items are always separated with a comma. - * @return A Core Graphics structure that represents a point. - * If the string is not well-formed, the function returns Vec2::ZERO. - */ -Vec2 CC_DLL PointFromString(const std::string& str); - -/** - * @brief Returns a Core Graphics size structure corresponding to the data in a given string. - * @param str A string object whose contents are of the form "{w, h}", - * where w is the width and h is the height. - * The w and h values can be integer or float values. - * An example of a valid string is "{3.0,2.5}". - * The string is not localized, so items are always separated with a comma. - * @return A Core Graphics structure that represents a size. - * If the string is not well-formed, the function returns Size::ZERO. - */ -Size CC_DLL SizeFromString(const std::string& str); - -// end of data_structure group -/** @} */ - -NS_CC_END - -#endif // __PLATFOMR_CCNS_H__ - diff --git a/native/cocos/base/CCUserDefault-android.cpp b/native/cocos/base/CCUserDefault-android.cpp deleted file mode 100644 index 0ba86b1a75..0000000000 --- a/native/cocos/base/CCUserDefault-android.cpp +++ /dev/null @@ -1,527 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#include "base/CCUserDefault.h" -#include "platform/CCPlatformConfig.h" -#include "base/ccUtils.h" -#include "base/base64.h" - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) -#include "platform/android/jni/JniHelper.h" - -// root name of xml -#define USERDEFAULT_ROOT_NAME "userDefaultRoot" - -#define KEEP_COMPATABILITY - -#define XML_FILE_NAME "UserDefault.xml" - -#ifdef KEEP_COMPATABILITY -#include "platform/CCFileUtils.h" -#include "tinyxml2/tinyxml2.h" -#endif - -static const std::string helperClassName = "org/cocos2dx/lib/Cocos2dxHelper"; - -using namespace std; - -NS_CC_BEGIN - -/** - * implements of UserDefault - */ - -UserDefault* UserDefault::_userDefault = nullptr; -string UserDefault::_filePath = string(""); -bool UserDefault::_isFilePathInitialized = false; - -#ifdef KEEP_COMPATABILITY -static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDocument **doc) -{ - tinyxml2::XMLElement* curNode = nullptr; - tinyxml2::XMLElement* rootNode = nullptr; - - if (! UserDefault::isXMLFileExist()) - { - return nullptr; - } - - // check the key value - if (! pKey) - { - return nullptr; - } - - do - { - tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument(); - *doc = xmlDoc; - ssize_t size; - - std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath()); - - if (xmlBuffer.empty()) - { - CCLOG("can not read xml file"); - break; - } - xmlDoc->Parse(xmlBuffer.c_str()); - - // get root node - rootNode = xmlDoc->RootElement(); - if (nullptr == rootNode) - { - CCLOG("read root node error"); - break; - } - // find the node - curNode = rootNode->FirstChildElement(); - if (!curNode) - { - // There is not xml node, delete xml file. - remove(UserDefault::getInstance()->getXMLFilePath().c_str()); - - return nullptr; - } - - while (nullptr != curNode) - { - const char* nodeName = curNode->Value(); - if (!strcmp(nodeName, pKey)) - { - // delete the node - break; - } - - curNode = curNode->NextSiblingElement(); - } - } while (0); - - return curNode; -} - -static void deleteNode(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* node) -{ - if (node) - { - doc->DeleteNode(node); - doc->SaveFile(UserDefault::getInstance()->getXMLFilePath().c_str()); - delete doc; - } -} - -static void deleteNodeByKey(const char *pKey) -{ - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - deleteNode(doc, node); -} -#endif - -UserDefault::~UserDefault() -{ -} - -UserDefault::UserDefault() -{ -} - -void UserDefault::destroyInstance() -{ - CC_SAFE_DELETE(_userDefault); -} - -bool UserDefault::getBoolForKey(const char* pKey) -{ - return getBoolForKey(pKey, false); -} - -bool UserDefault::getBoolForKey(const char* pKey, bool defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - const char* value = (const char*)node->FirstChild()->Value(); - bool ret = (! strcmp(value, "true")); - - // set value in NSUserDefaults - setBoolForKey(pKey, ret); - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - return JniHelper::callStaticBooleanMethod(helperClassName, "getBoolForKey", pKey, defaultValue); -} - -int UserDefault::getIntegerForKey(const char* pKey) -{ - return getIntegerForKey(pKey, 0); -} - -int UserDefault::getIntegerForKey(const char* pKey, int defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - int ret = atoi((const char*)node->FirstChild()->Value()); - - // set value in NSUserDefaults - setIntegerForKey(pKey, ret); - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - return JniHelper::callStaticIntMethod(helperClassName, "getIntegerForKey", pKey, defaultValue); -} - -float UserDefault::getFloatForKey(const char* pKey) -{ - return getFloatForKey(pKey, 0.0f); -} - -float UserDefault::getFloatForKey(const char* pKey, float defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - float ret = utils::atof((const char*)node->FirstChild()->Value()); - - // set value in NSUserDefaults - setFloatForKey(pKey, ret); - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - return JniHelper::callStaticFloatMethod(helperClassName, "getFloatForKey", pKey, defaultValue); -} - -double UserDefault::getDoubleForKey(const char* pKey) -{ - return getDoubleForKey(pKey, 0.0); -} - -double UserDefault::getDoubleForKey(const char* pKey, double defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - double ret = utils::atof((const char*)node->FirstChild()->Value()); - - // set value in NSUserDefaults - setDoubleForKey(pKey, ret); - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - return JniHelper::callStaticDoubleMethod(helperClassName, "getDoubleForKey", pKey, defaultValue); -} - -std::string UserDefault::getStringForKey(const char* pKey) -{ - return getStringForKey(pKey, ""); -} - -string UserDefault::getStringForKey(const char* pKey, const std::string & defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - string ret = (const char*)node->FirstChild()->Value(); - - // set value in NSUserDefaults - setStringForKey(pKey, ret); - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - return JniHelper::callStaticStringMethod(helperClassName, "getStringForKey", pKey, defaultValue); -} - -Data UserDefault::getDataForKey(const char* pKey) -{ - return getDataForKey(pKey, Data::Null); -} - -Data UserDefault::getDataForKey(const char* pKey, const Data& defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - const char * encodedData = node->FirstChild()->Value(); - - unsigned char * decodedData; - int decodedDataLen = base64Decode((unsigned char*)encodedData, (unsigned int)strlen(encodedData), &decodedData); - - if (decodedData) { - Data ret; - ret.fastSet(decodedData, decodedDataLen); - - // set value in NSUserDefaults - setDataForKey(pKey, ret); - - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - char * encodedDefaultData = NULL; - unsigned int encodedDefaultDataLen = !defaultValue.isNull() ? base64Encode(defaultValue.getBytes(), defaultValue.getSize(), &encodedDefaultData) : 0; - - string encodedStr = JniHelper::callStaticStringMethod(helperClassName, "getStringForKey", pKey, (const char*)encodedDefaultData); - - if (encodedDefaultData) - free(encodedDefaultData); - - CCLOG("ENCODED STRING: --%s--%d", encodedStr.c_str(), encodedStr.length()); - - unsigned char * decodedData = NULL; - int decodedDataLen = base64Decode((unsigned char*)encodedStr.c_str(), (unsigned int)encodedStr.length(), &decodedData); - - CCLOG("DECODED DATA: %s %d", decodedData, decodedDataLen); - - if (decodedData && decodedDataLen) { - Data ret; - ret.fastSet(decodedData, decodedDataLen); - return ret; - } - - return defaultValue; -} - - -void UserDefault::setBoolForKey(const char* pKey, bool value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - JniHelper::callStaticVoidMethod(helperClassName, "setBoolForKey", pKey, value); -} - -void UserDefault::setIntegerForKey(const char* pKey, int value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - JniHelper::callStaticVoidMethod(helperClassName, "setIntegerForKey", pKey, value); -} - -void UserDefault::setFloatForKey(const char* pKey, float value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - JniHelper::callStaticVoidMethod(helperClassName, "setFloatForKey", pKey, value); -} - -void UserDefault::setDoubleForKey(const char* pKey, double value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - JniHelper::callStaticVoidMethod(helperClassName, "setDoubleForKey", pKey, value); -} - -void UserDefault::setStringForKey(const char* pKey, const std::string & value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - JniHelper::callStaticVoidMethod(helperClassName, "setStringForKey", pKey, value); -} - -void UserDefault::setDataForKey(const char* pKey, const Data& value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - CCLOG("SET DATA FOR KEY: --%s--%d", value.getBytes(), (int)(value.getSize())); - char * encodedData = nullptr; - unsigned int encodedDataLen = base64Encode(value.getBytes(), value.getSize(), &encodedData); - - CCLOG("SET DATA ENCODED: --%s", encodedData); - - JniHelper::callStaticVoidMethod(helperClassName, "setStringForKey", pKey, (const char*)encodedData); - - if (encodedData) - free(encodedData); -} - -UserDefault* UserDefault::getInstance() -{ - if (! _userDefault) - { -#ifdef KEEP_COMPATABILITY - initXMLFilePath(); -#endif - _userDefault = new (std::nothrow) UserDefault(); - } - - return _userDefault; -} - -bool UserDefault::isXMLFileExist() -{ - return FileUtils::getInstance()->isFileExist(_filePath); -} - -void UserDefault::initXMLFilePath() -{ -#ifdef KEEP_COMPATABILITY - if (! _isFilePathInitialized) - { - // UserDefault.xml is stored in /data/data// before v2.1.2 - std::string packageName = JniHelper::callStaticStringMethod(helperClassName, "getCocos2dxPackageName"); - _filePath += "/data/data/" + packageName + "/" + XML_FILE_NAME; - _isFilePathInitialized = true; - } -#endif -} - -// create new xml file -bool UserDefault::createXMLFile() -{ - return false; -} - -const string& UserDefault::getXMLFilePath() -{ - return _filePath; -} - -void UserDefault::flush() -{ -} - -void UserDefault::deleteValueForKey(const char* key) -{ - // check the params - if (!key) - { - CCLOG("the key is invalid"); - } - - JniHelper::callStaticVoidMethod(helperClassName, "deleteValueForKey", key); - - flush(); -} -NS_CC_END - -#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) diff --git a/native/cocos/base/CCUserDefault-apple.mm b/native/cocos/base/CCUserDefault-apple.mm deleted file mode 100644 index cc33f4b57a..0000000000 --- a/native/cocos/base/CCUserDefault-apple.mm +++ /dev/null @@ -1,551 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "platform/CCPlatformConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) - -#import - -#include - -#import "base/CCUserDefault.h" -#import "tinyxml2/tinyxml2.h" -#import "platform/CCPlatformConfig.h" -#import "platform/CCPlatformMacros.h" -#import "base/base64.h" -#import "platform/CCFileUtils.h" - -#define XML_FILE_NAME "UserDefault.xml" - -// root name of xml -#define USERDEFAULT_ROOT_NAME "userDefaultRoot" - -#define KEEP_COMPATABILITY - -using namespace std; - -NS_CC_BEGIN - -/** - * implements of UserDefault - */ - -UserDefault* UserDefault::_userDefault = nullptr; -string UserDefault::_filePath = string(""); -bool UserDefault::_isFilePathInitialized = false; - -#ifdef KEEP_COMPATABILITY -static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDocument **doc) -{ - tinyxml2::XMLElement* curNode = nullptr; - tinyxml2::XMLElement* rootNode = nullptr; - - if (! UserDefault::isXMLFileExist()) - { - return nullptr; - } - - // check the key value - if (! pKey) - { - return nullptr; - } - - do - { - tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument(); - *doc = xmlDoc; - - std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath()); - - if (xmlBuffer.empty()) - { - NSLog(@"can not read xml file"); - break; - } - xmlDoc->Parse(xmlBuffer.c_str(), xmlBuffer.size()); - - // get root node - rootNode = xmlDoc->RootElement(); - if (nullptr == rootNode) - { - NSLog(@"read root node error"); - break; - } - // find the node - curNode = rootNode->FirstChildElement(); - if (!curNode) - { - // There is not xml node, delete xml file. - remove(UserDefault::getInstance()->getXMLFilePath().c_str()); - - return nullptr; - } - - while (nullptr != curNode) - { - const char* nodeName = curNode->Value(); - if (!strcmp(nodeName, pKey)) - { - // delete the node - break; - } - - curNode = curNode->NextSiblingElement(); - } - } while (0); - - return curNode; -} - -static void deleteNode(tinyxml2::XMLDocument* doc, tinyxml2::XMLElement* node) -{ - if (node) - { - doc->DeleteNode(node); - doc->SaveFile(UserDefault::getInstance()->getXMLFilePath().c_str()); - delete doc; - } -} - -static void deleteNodeByKey(const char *pKey) -{ - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - deleteNode(doc, node); -} -#endif - -UserDefault::~UserDefault() -{ -} - -UserDefault::UserDefault() -{ -} - -bool UserDefault::getBoolForKey(const char* pKey) -{ - return getBoolForKey(pKey, false); -} - -bool UserDefault::getBoolForKey(const char* pKey, bool defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - const char* value = (const char*)node->FirstChild()->Value(); - bool ret = (! strcmp(value, "true")); - - // set value in NSUserDefaults - setBoolForKey(pKey, ret); - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - bool ret = defaultValue; - - NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:pKey]]; - if (value) - { - ret = [value boolValue]; - } - - return ret; -} - -int UserDefault::getIntegerForKey(const char* pKey) -{ - return getIntegerForKey(pKey, 0); -} - -int UserDefault::getIntegerForKey(const char* pKey, int defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - int ret = atoi((const char*)node->FirstChild()->Value()); - - // set value in NSUserDefaults - setIntegerForKey(pKey, ret); - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - int ret = defaultValue; - - NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:pKey]]; - if (value) - { - ret = [value intValue]; - } - - return ret; -} - -float UserDefault::getFloatForKey(const char* pKey) -{ - return getFloatForKey(pKey, 0); -} - -float UserDefault::getFloatForKey(const char* pKey, float defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - float ret = atof((const char*)node->FirstChild()->Value()); - - // set value in NSUserDefaults - setFloatForKey(pKey, ret); - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - float ret = defaultValue; - - NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:pKey]]; - if (value) - { - ret = [value floatValue]; - } - - return ret; -} - -double UserDefault::getDoubleForKey(const char* pKey) -{ - return getDoubleForKey(pKey, 0); -} - -double UserDefault::getDoubleForKey(const char* pKey, double defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - double ret = atof((const char*)node->FirstChild()->Value()); - - // set value in NSUserDefaults - setDoubleForKey(pKey, ret); - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - double ret = defaultValue; - - NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:pKey]]; - if (value) - { - ret = [value doubleValue]; - } - - return ret; -} - -std::string UserDefault::getStringForKey(const char* pKey) -{ - return getStringForKey(pKey, ""); -} - -string UserDefault::getStringForKey(const char* pKey, const std::string & defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - string ret = (const char*)node->FirstChild()->Value(); - - // set value in NSUserDefaults - setStringForKey(pKey, ret); - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } -#endif - - NSString *str = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithUTF8String:pKey]]; - if (! str) - { - return defaultValue; - } - else - { - return [str UTF8String]; - } -} - -Data UserDefault::getDataForKey(const char* pKey) -{ - return getDataForKey(pKey, Data::Null); -} - -Data UserDefault::getDataForKey(const char* pKey, const Data& defaultValue) -{ -#ifdef KEEP_COMPATABILITY - tinyxml2::XMLDocument* doc = nullptr; - tinyxml2::XMLElement* node = getXMLNodeForKey(pKey, &doc); - if (node) - { - if (node->FirstChild()) - { - const char * encodedData = node->FirstChild()->Value(); - unsigned char * decodedData; - int decodedDataLen = base64Decode((unsigned char*)encodedData, (unsigned int)strlen(encodedData), &decodedData); - - if (decodedData) { - Data ret; - ret.fastSet(decodedData, decodedDataLen); - - // set value in NSUserDefaults - setDataForKey(pKey, ret); - - flush(); - - // delete xmle node - deleteNode(doc, node); - - return ret; - } - } - else - { - // delete xmle node - deleteNode(doc, node); - } - } else { - delete doc; - } -#endif - - NSData *data = [[NSUserDefaults standardUserDefaults] dataForKey:[NSString stringWithUTF8String:pKey]]; - if (! data) - { - return defaultValue; - } - else - { - Data ret; - ret.copy((unsigned char*)data.bytes, data.length); - return ret; - } -} - -void UserDefault::setBoolForKey(const char* pKey, bool value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:value] forKey:[NSString stringWithUTF8String:pKey]]; -} - -void UserDefault::setIntegerForKey(const char* pKey, int value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:value] forKey:[NSString stringWithUTF8String:pKey]]; -} - -void UserDefault::setFloatForKey(const char* pKey, float value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithFloat:value] forKey:[NSString stringWithUTF8String:pKey]]; -} - -void UserDefault::setDoubleForKey(const char* pKey, double value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithDouble:value] forKey:[NSString stringWithUTF8String:pKey]]; -} - -void UserDefault::setStringForKey(const char* pKey, const std::string & value) -{ -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithUTF8String:value.c_str()] forKey:[NSString stringWithUTF8String:pKey]]; -} - -void UserDefault::setDataForKey(const char* pKey, const Data& value) { -#ifdef KEEP_COMPATABILITY - deleteNodeByKey(pKey); -#endif - - [[NSUserDefaults standardUserDefaults] setObject:[NSData dataWithBytes: value.getBytes() length: value.getSize()] forKey:[NSString stringWithUTF8String:pKey]]; -} - -UserDefault* UserDefault::getInstance() -{ - if (! _userDefault) - { -#ifdef KEEP_COMPATABILITY - initXMLFilePath(); -#endif - _userDefault = new (std::nothrow) UserDefault(); - } - - return _userDefault; -} - -void UserDefault::destroyInstance() -{ - CC_SAFE_DELETE(_userDefault); -} - -bool UserDefault::isXMLFileExist() -{ - return FileUtils::getInstance()->isFileExist(_filePath); -} - -void UserDefault::initXMLFilePath() -{ -#ifdef KEEP_COMPATABILITY - if (! _isFilePathInitialized) - { - // xml file is stored in cache directory before 2.1.2 - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - NSString *documentsDirectory = [paths objectAtIndex:0]; - _filePath = [documentsDirectory UTF8String]; - _filePath.append("/"); - - _filePath += XML_FILE_NAME; - _isFilePathInitialized = true; - } -#endif -} - -// create new xml file -bool UserDefault::createXMLFile() -{ - return false; -} - -const string& UserDefault::getXMLFilePath() -{ - return _filePath; -} - -void UserDefault::flush() -{ - [[NSUserDefaults standardUserDefaults] synchronize]; -} - -void UserDefault::deleteValueForKey(const char* key) -{ - // check the params - if (!key) - { - CCLOG("the key is invalid"); - } - - [[NSUserDefaults standardUserDefaults] removeObjectForKey:[NSString stringWithUTF8String:key]]; - - flush(); -} - -NS_CC_END - -#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) diff --git a/native/cocos/base/CCUserDefault.cpp b/native/cocos/base/CCUserDefault.cpp deleted file mode 100644 index 16c450e06f..0000000000 --- a/native/cocos/base/CCUserDefault.cpp +++ /dev/null @@ -1,528 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#include "base/CCUserDefault.h" -#include "platform/CCFileUtils.h" -#include "tinyxml2/tinyxml2.h" -#include "base/base64.h" -#include "base/ccUtils.h" - -#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_MAC && CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) - -// root name of xml -#define USERDEFAULT_ROOT_NAME "userDefaultRoot" - -#define XML_FILE_NAME "UserDefault.xml" - -using namespace std; - -NS_CC_BEGIN - -/** - * define the functions here because we don't want to - * export xmlNodePtr and other types in "CCUserDefault.h" - */ - -static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLElement** rootNode, tinyxml2::XMLDocument **doc) -{ - tinyxml2::XMLElement* curNode = nullptr; - - // check the key value - if (! pKey) - { - return nullptr; - } - - do - { - tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument(); - *doc = xmlDoc; - - std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath()); - - if (xmlBuffer.empty()) - { - CCLOG("can not read xml file"); - break; - } - xmlDoc->Parse(xmlBuffer.c_str(), xmlBuffer.size()); - - // get root node - *rootNode = xmlDoc->RootElement(); - if (nullptr == *rootNode) - { - CCLOG("read root node error"); - break; - } - // find the node - curNode = (*rootNode)->FirstChildElement(); - while (nullptr != curNode) - { - const char* nodeName = curNode->Value(); - if (!strcmp(nodeName, pKey)) - { - break; - } - - curNode = curNode->NextSiblingElement(); - } - } while (0); - - return curNode; -} - -static void setValueForKey(const char* pKey, const char* pValue) -{ - tinyxml2::XMLElement* rootNode; - tinyxml2::XMLDocument* doc; - tinyxml2::XMLElement* node; - // check the params - if (! pKey || ! pValue) - { - return; - } - // find the node - node = getXMLNodeForKey(pKey, &rootNode, &doc); - // if node exist, change the content - if (node) - { - if (node->FirstChild()) - { - node->FirstChild()->SetValue(pValue); - } - else - { - tinyxml2::XMLText* content = doc->NewText(pValue); - node->LinkEndChild(content); - } - } - else - { - if (rootNode) - { - tinyxml2::XMLElement* tmpNode = doc->NewElement(pKey);//new tinyxml2::XMLElement(pKey); - rootNode->LinkEndChild(tmpNode); - tinyxml2::XMLText* content = doc->NewText(pValue);//new tinyxml2::XMLText(pValue); - tmpNode->LinkEndChild(content); - } - } - - // save file and free doc - if (doc) - { - doc->SaveFile(FileUtils::getInstance()->getSuitableFOpen(UserDefault::getInstance()->getXMLFilePath()).c_str()); - delete doc; - } -} - -/** - * implements of UserDefault - */ - -UserDefault* UserDefault::_userDefault = nullptr; -string UserDefault::_filePath = string(""); -bool UserDefault::_isFilePathInitialized = false; - -UserDefault::~UserDefault() -{ -} - -UserDefault::UserDefault() -{ -} - -bool UserDefault::getBoolForKey(const char* pKey) -{ - return getBoolForKey(pKey, false); -} - -bool UserDefault::getBoolForKey(const char* pKey, bool defaultValue) -{ - const char* value = nullptr; - tinyxml2::XMLElement* rootNode; - tinyxml2::XMLDocument* doc; - tinyxml2::XMLElement* node; - node = getXMLNodeForKey(pKey, &rootNode, &doc); - // find the node - if (node && node->FirstChild()) - { - value = (const char*)(node->FirstChild()->Value()); - } - - bool ret = defaultValue; - - if (value) - { - ret = (! strcmp(value, "true")); - } - - if (doc) delete doc; - - return ret; -} - -int UserDefault::getIntegerForKey(const char* pKey) -{ - return getIntegerForKey(pKey, 0); -} - -int UserDefault::getIntegerForKey(const char* pKey, int defaultValue) -{ - const char* value = nullptr; - tinyxml2::XMLElement* rootNode; - tinyxml2::XMLDocument* doc; - tinyxml2::XMLElement* node; - node = getXMLNodeForKey(pKey, &rootNode, &doc); - // find the node - if (node && node->FirstChild()) - { - value = (const char*)(node->FirstChild()->Value()); - } - - int ret = defaultValue; - - if (value) - { - ret = atoi(value); - } - - if(doc) - { - delete doc; - } - - - return ret; -} - -float UserDefault::getFloatForKey(const char* pKey) -{ - return getFloatForKey(pKey, 0.0f); -} - -float UserDefault::getFloatForKey(const char* pKey, float defaultValue) -{ - float ret = (float)getDoubleForKey(pKey, (double)defaultValue); - - return ret; -} - -double UserDefault::getDoubleForKey(const char* pKey) -{ - return getDoubleForKey(pKey, 0.0); -} - -double UserDefault::getDoubleForKey(const char* pKey, double defaultValue) -{ - const char* value = nullptr; - tinyxml2::XMLElement* rootNode; - tinyxml2::XMLDocument* doc; - tinyxml2::XMLElement* node; - node = getXMLNodeForKey(pKey, &rootNode, &doc); - // find the node - if (node && node->FirstChild()) - { - value = (const char*)(node->FirstChild()->Value()); - } - - double ret = defaultValue; - - if (value) - { - ret = utils::atof(value); - } - - if (doc) delete doc; - - return ret; -} - -std::string UserDefault::getStringForKey(const char* pKey) -{ - return getStringForKey(pKey, ""); -} - -string UserDefault::getStringForKey(const char* pKey, const std::string & defaultValue) -{ - const char* value = nullptr; - tinyxml2::XMLElement* rootNode; - tinyxml2::XMLDocument* doc; - tinyxml2::XMLElement* node; - node = getXMLNodeForKey(pKey, &rootNode, &doc); - // find the node - if (node && node->FirstChild()) - { - value = (const char*)(node->FirstChild()->Value()); - } - - string ret = defaultValue; - - if (value) - { - ret = string(value); - } - - if (doc) delete doc; - - return ret; -} - -Data UserDefault::getDataForKey(const char* pKey) -{ - return getDataForKey(pKey, Data::Null); -} - -Data UserDefault::getDataForKey(const char* pKey, const Data& defaultValue) -{ - const char* encodedData = nullptr; - tinyxml2::XMLElement* rootNode; - tinyxml2::XMLDocument* doc; - tinyxml2::XMLElement* node; - node = getXMLNodeForKey(pKey, &rootNode, &doc); - // find the node - if (node && node->FirstChild()) - { - encodedData = (const char*)(node->FirstChild()->Value()); - } - - Data ret = defaultValue; - - if (encodedData) - { - unsigned char * decodedData = nullptr; - int decodedDataLen = base64Decode((unsigned char*)encodedData, (unsigned int)strlen(encodedData), &decodedData); - - if (decodedData) { - ret.fastSet(decodedData, decodedDataLen); - } - } - - if (doc) delete doc; - - return ret; -} - - -void UserDefault::setBoolForKey(const char* pKey, bool value) -{ - // save bool value as string - - if (true == value) - { - setStringForKey(pKey, "true"); - } - else - { - setStringForKey(pKey, "false"); - } -} - -void UserDefault::setIntegerForKey(const char* pKey, int value) -{ - // check key - if (! pKey) - { - return; - } - - // format the value - char tmp[50]; - memset(tmp, 0, 50); - sprintf(tmp, "%d", value); - - setValueForKey(pKey, tmp); -} - -void UserDefault::setFloatForKey(const char* pKey, float value) -{ - setDoubleForKey(pKey, value); -} - -void UserDefault::setDoubleForKey(const char* pKey, double value) -{ - // check key - if (! pKey) - { - return; - } - - // format the value - char tmp[50]; - memset(tmp, 0, 50); - sprintf(tmp, "%f", value); - - setValueForKey(pKey, tmp); -} - -void UserDefault::setStringForKey(const char* pKey, const std::string & value) -{ - // check key - if (! pKey) - { - return; - } - - setValueForKey(pKey, value.c_str()); -} - -void UserDefault::setDataForKey(const char* pKey, const Data& value) { - // check key - if (! pKey) - { - return; - } - - char *encodedData = nullptr; - - base64Encode(value.getBytes(), static_cast(value.getSize()), &encodedData); - - setValueForKey(pKey, encodedData); - - if (encodedData) - free(encodedData); -} - -UserDefault* UserDefault::getInstance() -{ - if (!_userDefault) - { - initXMLFilePath(); - - // only create xml file one time - // the file exists after the program exit - if ((!isXMLFileExist()) && (!createXMLFile())) - { - return nullptr; - } - - _userDefault = new (std::nothrow) UserDefault(); - } - - return _userDefault; -} - -void UserDefault::destroyInstance() -{ - CC_SAFE_DELETE(_userDefault); -} - -void UserDefault::setDelegate(UserDefault *delegate) -{ - if (_userDefault) - delete _userDefault; - - _userDefault = delegate; -} - -bool UserDefault::isXMLFileExist() -{ - return FileUtils::getInstance()->isFileExist(_filePath); -} - -void UserDefault::initXMLFilePath() -{ - if (! _isFilePathInitialized) - { - _filePath += FileUtils::getInstance()->getWritablePath() + XML_FILE_NAME; - _isFilePathInitialized = true; - } -} - -// create new xml file -bool UserDefault::createXMLFile() -{ - bool bRet = false; - tinyxml2::XMLDocument *pDoc = new (std::nothrow) tinyxml2::XMLDocument(); - if (nullptr==pDoc) - { - return false; - } - tinyxml2::XMLDeclaration *pDeclaration = pDoc->NewDeclaration(nullptr); - if (nullptr==pDeclaration) - { - return false; - } - pDoc->LinkEndChild(pDeclaration); - tinyxml2::XMLElement *pRootEle = pDoc->NewElement(USERDEFAULT_ROOT_NAME); - if (nullptr==pRootEle) - { - return false; - } - pDoc->LinkEndChild(pRootEle); - bRet = tinyxml2::XML_SUCCESS == pDoc->SaveFile(FileUtils::getInstance()->getSuitableFOpen(_filePath).c_str()); - - if(pDoc) - { - delete pDoc; - } - - return bRet; -} - -const string& UserDefault::getXMLFilePath() -{ - return _filePath; -} - -void UserDefault::flush() -{ -} - -void UserDefault::deleteValueForKey(const char* key) -{ - tinyxml2::XMLElement* rootNode; - tinyxml2::XMLDocument* doc; - tinyxml2::XMLElement* node; - - // check the params - if (!key) - { - CCLOG("the key is invalid"); - return; - } - - // find the node - node = getXMLNodeForKey(key, &rootNode, &doc); - - // if node not exist, don't need to delete - if (!node) - { - return; - } - - // save file and free doc - if (doc) - { - doc->DeleteNode(node); - doc->SaveFile(FileUtils::getInstance()->getSuitableFOpen(UserDefault::getInstance()->getXMLFilePath()).c_str()); - delete doc; - } - - flush(); -} - -NS_CC_END - -#endif // (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_PLATFORM != CC_PLATFORM_ANDROID) diff --git a/native/cocos/base/CCUserDefault.h b/native/cocos/base/CCUserDefault.h deleted file mode 100644 index 430289d92a..0000000000 --- a/native/cocos/base/CCUserDefault.h +++ /dev/null @@ -1,265 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#ifndef __SUPPORT_CCUSERDEFAULT_H__ -#define __SUPPORT_CCUSERDEFAULT_H__ - -#include "base/ccMacros.h" -#include -#include "base/CCData.h" - -/** - * @addtogroup base - * @{ - */ -NS_CC_BEGIN - - -/** - * UserDefault acts as a tiny database. You can save and get base type values by it. - * For example, setBoolForKey("played", true) will add a bool value true into the database. - * Its key is "played". You can get the value of the key by getBoolForKey("played"). - * - * It supports the following base types: - * bool, int, float, double, string - */ -class CC_DLL UserDefault -{ -public: - // get value methods - - /** - * Get bool value by key, if the key doesn't exist, will return false. - * You can set the default value, or it is false. - * @param key The key to get value. - * @return Bool value by `key`. - * @js NA - */ - bool getBoolForKey(const char* key); - - /** - * Get bool value by key, if the key doesn't exist, will return passed default value. - * @param key The key to get value. - * @param defaultValue The default value to return if the key doesn't exist. - * @js NA - */ - virtual bool getBoolForKey(const char* key, bool defaultValue); - - /** - * Get integer value by key, if the key doesn't exist, will return 0. - * You can set the default value, or it is 0. - * @param key The key to get value. - * @return Integer value of the key. - * @js NA - */ - int getIntegerForKey(const char* key); - - /** - * Get bool value by key, if the key doesn't exist, will return passed default value. - * @param key The key to get value. - * @param defaultValue The default value to return if the key doesn't exist. - * @return Integer value of the key. - * @js NA - */ - virtual int getIntegerForKey(const char* key, int defaultValue); - - /** - * Get float value by key, if the key doesn't exist, will return 0.0. - * @param key The key to get value. - * @return Float value of the key. - * @js NA - */ - float getFloatForKey(const char* key); - - /** - * Get float value by key, if the key doesn't exist, will return passed default value. - * @param key The key to get value. - * @param defaultValue The default value to return if the key doesn't exist. - * @return Float value of the key. - * @js NA - */ - virtual float getFloatForKey(const char* key, float defaultValue); - - /** - * Get double value by key, if the key doesn't exist, will return 0.0. - * @param key The key to get value. - * @return Double value of the key. - * @js NA - */ - double getDoubleForKey(const char* key); - - /** - * Get double value by key, if the key doesn't exist, will return passed default value. - * @param key The key to get value. - * @param defaultValue The default value to return if the key doesn't exist. - * @return Double value of the key. - * @js NA - */ - virtual double getDoubleForKey(const char* key, double defaultValue); - - /** - * Get string value by key, if the key doesn't exist, will return an empty string. - * @param key The key to get value. - * @return String value of the key. - * @js NA - */ - std::string getStringForKey(const char* key); - - /** - * Get string value by key, if the key doesn't exist, will return passed default value. - * @param key The key to get value. - * @param defaultValue The default value to return if the key doesn't exist. - * @return String value of the key. - * @js NA - */ - virtual std::string getStringForKey(const char* key, const std::string & defaultValue); - - /** - * Get Data value by key, if the key doesn't exist, will return an empty Data. - * @param key The key to get value. - * @return Data value of the key. - * @js NA - */ - Data getDataForKey(const char* key); - - /** - * Get Data value by key, if the key doesn't exist, will return an empty Data. - * @param key The key to get value. - * @param defaultValue The default value to return if the key doesn't exist. - * @return Data value of the key. - * @js NA - */ - virtual Data getDataForKey(const char* key, const Data& defaultValue); - - // set value methods - - /** - * Set bool value by key. - * @param key The key to set. - * @param value A bool value to set to the key. - * @js NA - */ - virtual void setBoolForKey(const char* key, bool value); - /** - * Set integer value by key. - * @param key The key to set. - * @param value A integer value to set to the key. - * @js NA - */ - virtual void setIntegerForKey(const char* key, int value); - /** - * Set float value by key. - * @param key The key to set. - * @param value A float value to set to the key. - * @js NA - */ - virtual void setFloatForKey(const char* key, float value); - /** - * Set double value by key. - * @param key The key to set. - * @param value A double value to set to the key. - * @js NA - */ - virtual void setDoubleForKey(const char* key, double value); - /** - * Set string value by key. - * @param key The key to set. - * @param value A string value to set to the key. - * @js NA - */ - virtual void setStringForKey(const char* key, const std::string & value); - /** - * Set Data value by key. - * @param key The key to set. - * @param value A Data value to set to the key. - * @js NA - */ - virtual void setDataForKey(const char* key, const Data& value); - /** - * You should invoke this function to save values set by setXXXForKey(). - * @js NA - */ - virtual void flush(); - - /** - * delete any value by key, - * @param key The key to delete value. - * @js NA - */ - virtual void deleteValueForKey(const char* key); - - /** Returns the singleton. - * @js NA - * @lua NA - */ - static UserDefault* getInstance(); - /** - * @js NA - */ - static void destroyInstance(); - - /** - * You can inherit from platform dependent implementation of UserDefault, such as UserDefaultAndroid, - * and use this function to set delegate, then UserDefault will invoke delegate's implementation. - * For example, your store native data base or other format store. - * - * If you don't want to system default implementation after setting delegate, you can just pass nullptr - * to this function. - * - * @warm It will delete previous delegate - */ - static void setDelegate(UserDefault *delegate); - - /** All supported platforms other iOS & Android use xml file to save values. This function is return the file path of the xml path. - * @js NA - */ - static const std::string& getXMLFilePath(); - /** All supported platforms other iOS & Android and CC_PLATFORM_WINRT use xml file to save values. This function checks whether the xml file exists or not. - * @return True if the xml file exists, false if not. - * @js NA - */ - static bool isXMLFileExist(); - -protected: - UserDefault(); - virtual ~UserDefault(); - -private: - - static bool createXMLFile(); - static void initXMLFilePath(); - - static UserDefault* _userDefault; - static std::string _filePath; - static bool _isFilePathInitialized; -}; - - -NS_CC_END -// end of base group -/** @} */ - -#endif // __SUPPORT_CCUSERDEFAULT_H__ - diff --git a/native/cocos/base/ccUTF8.cpp b/native/cocos/base/ccUTF8.cpp index a11b99628e..6cefc52e7c 100644 --- a/native/cocos/base/ccUTF8.cpp +++ b/native/cocos/base/ccUTF8.cpp @@ -377,134 +377,5 @@ bool StringUTF8::insert(std::size_t pos, const StringUTF8& insertStr) } //namespace StringUtils { -namespace { - inline int wcslen_internal(const unsigned short* str) - { - if (str == nullptr) - return -1; - int i=0; - while(*str++) i++; - return i; - } -} - - -int cc_wcslen(const unsigned short* str) -{ - return wcslen_internal(str); -} - -void cc_utf8_trim_ws(std::vector* str) -{ - if (str == nullptr) - return; - // unsigned short and char16_t are both 2 bytes - std::vector* ret = reinterpret_cast*>(str); - StringUtils::trimUTF16Vector(*ret); -} - -bool isspace_unicode(unsigned short ch) -{ - return StringUtils::isUnicodeSpace(ch); -} - - -bool iscjk_unicode(unsigned short ch) -{ - return StringUtils::isCJKUnicode(ch); -} - - -long cc_utf8_strlen (const char * p, int max) -{ - CC_UNUSED_PARAM(max); - if (p == nullptr) - return -1; - return StringUtils::getCharacterCountInUTF8String(p); -} - -unsigned int cc_utf8_find_last_not_char(const std::vector& str, unsigned short c) -{ - std::vector char16Vector; - for (const auto& e : str) - { - char16Vector.push_back(e); - } - - return StringUtils::getIndexOfLastNotChar16(char16Vector, c); -} - -std::vector cc_utf16_vec_from_utf16_str(const unsigned short* str) -{ - std::vector str_new; - - if (str == nullptr) - return str_new; - - int len = wcslen_internal(str); - - for (int i = 0; i < len; ++i) - { - str_new.push_back(str[i]); - } - return str_new; -} - -unsigned short* cc_utf8_to_utf16(const char* str_old, int length/* = -1*/, int* rUtf16Size/* = nullptr*/) -{ - if (str_old == nullptr) - return nullptr; - - unsigned short* ret = nullptr; - - std::u16string outUtf16; - std::string inUtf8 = length == -1 ? std::string(str_old) : std::string(str_old, length); - bool succeed = StringUtils::UTF8ToUTF16(inUtf8, outUtf16); - - if (succeed) - { - ret = new (std::nothrow) unsigned short[outUtf16.length() + 1]; - ret[outUtf16.length()] = 0; - memcpy(ret, outUtf16.data(), outUtf16.length() * sizeof(unsigned short)); - if (rUtf16Size) - { - *rUtf16Size = static_cast(outUtf16.length()); - } - } - - return ret; -} - -char * cc_utf16_to_utf8 (const unsigned short *str, - int len, - long *items_read, - long *items_written) -{ - if (str == nullptr) - return nullptr; - - - std::u16string utf16; - int utf16Len = len < 0 ? wcslen_internal(str) : len; - - for (int i = 0; i < utf16Len; ++i) - { - utf16.push_back(str[i]); - } - - char* ret = nullptr; - std::string outUtf8; - bool succeed = StringUtils::UTF16ToUTF8(utf16, outUtf8); - - if (succeed) - { - ret = new (std::nothrow) char[outUtf8.length() + 1]; - ret[outUtf8.length()] = '\0'; - memcpy(ret, outUtf8.data(), outUtf8.length()); - } - - return ret; -} - NS_CC_END diff --git a/native/cocos/base/ccUTF8.h b/native/cocos/base/ccUTF8.h index d7527855ff..468c29a79c 100644 --- a/native/cocos/base/ccUTF8.h +++ b/native/cocos/base/ccUTF8.h @@ -217,98 +217,6 @@ private: } // namespace StringUtils { -/** - * Returns the character count in UTF16 string. - * @param str Pointer to the start of a UTF-16 encoded string. It must be an NULL terminal UTF8 string. - * @deprecated Please use c++11 `std::u16string::length` instead, don't use `unsigned short*` directly. - */ -CC_DEPRECATED_ATTRIBUTE CC_DLL int cc_wcslen(const unsigned short* str); - -/** Trims the space characters at the end of UTF8 string. - * @deprecated Please use `StringUtils::trimUTF16Vector` instead. - */ - -CC_DEPRECATED_ATTRIBUTE CC_DLL void cc_utf8_trim_ws(std::vector* str); - -/** - * Whether the character is a whitespace character. - * - * @param ch The unicode character. - * @returns Whether the character is a white space character. - * @deprecated Please use `StringUtils::isUnicodeSpace` instead. - * - * @see http://en.wikipedia.org/wiki/Whitespace_character#Unicode - */ -CC_DEPRECATED_ATTRIBUTE CC_DLL bool isspace_unicode(unsigned short ch); - -/** - * Whether the character is a Chinese/Japanese/Korean character. - * - * @param ch The unicode character - * @returns Whether the character is a Chinese character. - * @deprecated Please use `StringUtils::isCJKUnicode` instead. - * - * @see http://www.searchtb.com/2012/04/chinese_encode.html - * @see http://tieba.baidu.com/p/748765987 - */ -CC_DEPRECATED_ATTRIBUTE CC_DLL bool iscjk_unicode(unsigned short ch); - -/** - * Returns the length of the string in characters. - * - * @param p Pointer to the start of a UTF-8 encoded string. It must be an NULL terminal UTF8 string. - * @param max Not used from 3.1, just keep it for backward compatibility. - * @deprecated Please use `StringUtils::getCharacterCountInUTF8String` instead. - * @returns The length of the string in characters. - **/ -CC_DEPRECATED_ATTRIBUTE CC_DLL long cc_utf8_strlen (const char * p, int max = -1); - -/** - * Find the last character that is not equal to the character given. - * - * @param str The string to be searched. - * @param c The character to be searched for. - * @deprecated Please use `StringUtils::getIndexOfLastNotChar16` instead. - * @returns The index of the last character that is not \p c. - */ -CC_DEPRECATED_ATTRIBUTE CC_DLL unsigned int cc_utf8_find_last_not_char(const std::vector& str, unsigned short c); - -/** - * @brief Gets `unsigned short` vector from a given utf16 string. - * @param str A given utf16 string. - * @deprecated Please use `StringUtils::getChar16VectorFromUTF16String` instead. - */ -CC_DEPRECATED_ATTRIBUTE CC_DLL std::vector cc_utf16_vec_from_utf16_str(const unsigned short* str); - -/** - * Creates an utf8 string from a c string. The result will be null terminated. - * - * @param str_old Pointer to the start of a C string. It must be an NULL terminal UTF8 string. - * @param length Not used from 3.1, keep it just for backward compatibility. - * @param rUtf16Size The character count in the return UTF16 string. - * @deprecated Please use `StringUtils::UTF8ToUTF16` instead. - * @returns The newly created utf16 string, it must be released with `delete[]`, - * If an error occurs, %NULL will be returned. - */ -CC_DEPRECATED_ATTRIBUTE CC_DLL unsigned short* cc_utf8_to_utf16(const char* str_old, int length = -1, int* rUtf16Size = nullptr); - -/** - * Converts a string from UTF-16 to UTF-8. The result will be null terminated. - * - * @param utf16 An UTF-16 encoded string, It must be an NULL terminal UTF16 string. - * @param len Not used from 3.1, keep it just for backward compatibility. - * @param items_read Not used from 3.1, keep it just for backward compatibility. - * @param items_written Not used from 3.1, keep it just for backward compatibility. - * @deprecated Please use `StringUtils::UTF16ToUTF8` instead. - * @returns A pointer to a newly allocated UTF-8 string. This value must be - * released with `delete[]`. If an error occurs, %NULL will be returned. - */ -CC_DEPRECATED_ATTRIBUTE CC_DLL char * cc_utf16_to_utf8 (const unsigned short *str, - int len = -1, - long *items_read = nullptr, - long *items_written = nullptr); - - NS_CC_END #endif /** defined(__cocos2dx__ccUTF8__) */ diff --git a/native/cocos/base/ccUtils.cpp b/native/cocos/base/ccUtils.cpp index c478217c14..f49e0b55cf 100644 --- a/native/cocos/base/ccUtils.cpp +++ b/native/cocos/base/ccUtils.cpp @@ -25,13 +25,12 @@ THE SOFTWARE. ****************************************************************************/ #include "base/ccUtils.h" +#include "base/base64.h" +#include "platform/CCFileUtils.h" #include #include -#include "base/base64.h" -#include "platform/CCFileUtils.h" - NS_CC_BEGIN namespace diff --git a/native/cocos/base/ccUtils.h b/native/cocos/base/ccUtils.h index 1f00dcf0ba..6a1e8d503a 100644 --- a/native/cocos/base/ccUtils.h +++ b/native/cocos/base/ccUtils.h @@ -49,8 +49,6 @@ Examples: @since v0.99.5 */ -class Image; - namespace utils { CC_DLL int nextPOT(int x); diff --git a/native/cocos/base/firePngData.h b/native/cocos/base/firePngData.h deleted file mode 100644 index 6ffa8f9492..0000000000 --- a/native/cocos/base/firePngData.h +++ /dev/null @@ -1,53 +0,0 @@ -/// @cond DO_NOT_SHOW - -const unsigned char __firePngData[] = { -0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, -0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x08, 0x06, 0x00, 0x00, 0x00, 0x73, 0x7A, 0x7A, -0xF4, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4D, 0x41, 0x00, 0x00, 0xAF, 0xC8, 0x37, 0x05, 0x8A, -0xE9, 0x00, 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, -0x65, 0x00, 0x41, 0x64, 0x6F, 0x62, 0x65, 0x20, 0x49, 0x6D, 0x61, 0x67, 0x65, 0x52, 0x65, 0x61, -0x64, 0x79, 0x71, 0xC9, 0x65, 0x3C, 0x00, 0x00, 0x02, 0x64, 0x49, 0x44, 0x41, 0x54, 0x78, 0xDA, -0xC4, 0x97, 0x89, 0x6E, 0xEB, 0x20, 0x10, 0x45, 0xBD, 0xE1, 0x2D, 0x4B, 0xFF, 0xFF, 0x37, 0x5F, -0x5F, 0x0C, 0xD8, 0xC4, 0xAE, 0x2D, 0xDD, 0xA9, 0x6E, 0xA7, 0x38, 0xC1, 0x91, 0xAA, 0x44, 0xBA, -0xCA, 0x06, 0xCC, 0x99, 0x85, 0x01, 0xE7, 0xCB, 0xB2, 0x64, 0xEF, 0x7C, 0x55, 0x2F, 0xCC, 0x69, -0x56, 0x15, 0xAB, 0x72, 0x68, 0x81, 0xE6, 0x55, 0xFE, 0xE8, 0x62, 0x79, 0x62, 0x04, 0x36, 0xA3, -0x06, 0xC0, 0x9B, 0xCA, 0x08, 0xC0, 0x7D, 0x55, 0x80, 0xA6, 0x54, 0x98, 0x67, 0x11, 0xA8, 0xA1, -0x86, 0x3E, 0x0B, 0x44, 0x41, 0x00, 0x33, 0x19, 0x1F, 0x21, 0x43, 0x9F, 0x5F, 0x02, 0x68, 0x49, -0x1D, 0x20, 0x1A, 0x82, 0x28, 0x09, 0xE0, 0x4E, 0xC6, 0x3D, 0x64, 0x57, 0x39, 0x80, 0xBA, 0xA3, -0x00, 0x1D, 0xD4, 0x93, 0x3A, 0xC0, 0x34, 0x0F, 0x00, 0x3C, 0x8C, 0x59, 0x4A, 0x99, 0x44, 0xCA, -0xA6, 0x02, 0x88, 0xC7, 0xA7, 0x55, 0x67, 0xE8, 0x44, 0x10, 0x12, 0x05, 0x0D, 0x30, 0x92, 0xE7, -0x52, 0x33, 0x32, 0x26, 0xC3, 0x38, 0xF7, 0x0C, 0xA0, 0x06, 0x40, 0x0F, 0xC3, 0xD7, 0x55, 0x17, -0x05, 0xD1, 0x92, 0x77, 0x02, 0x20, 0x85, 0xB7, 0x19, 0x18, 0x28, 0x4D, 0x05, 0x19, 0x9F, 0xA1, -0xF1, 0x08, 0xC0, 0x05, 0x10, 0x57, 0x7C, 0x4F, 0x01, 0x10, 0xEF, 0xC5, 0xF8, 0xAC, 0x76, 0xC8, -0x2E, 0x80, 0x14, 0x99, 0xE4, 0xFE, 0x44, 0x51, 0xB8, 0x52, 0x14, 0x3A, 0x32, 0x22, 0x00, 0x13, -0x85, 0xBF, 0x52, 0xC6, 0x05, 0x8E, 0xE5, 0x63, 0x00, 0x86, 0xB6, 0x9C, 0x86, 0x38, 0xAB, 0x54, -0x74, 0x18, 0x5B, 0x50, 0x58, 0x6D, 0xC4, 0xF3, 0x89, 0x6A, 0xC3, 0x61, 0x8E, 0xD9, 0x03, 0xA8, -0x08, 0xA0, 0x55, 0xBB, 0x40, 0x40, 0x3E, 0x00, 0xD2, 0x53, 0x47, 0x94, 0x0E, 0x38, 0xD0, 0x7A, -0x73, 0x64, 0x57, 0xF0, 0x16, 0xFE, 0x95, 0x82, 0x86, 0x1A, 0x4C, 0x4D, 0xE9, 0x68, 0xD5, 0xAE, -0xB8, 0x00, 0xE2, 0x8C, 0xDF, 0x4B, 0xE4, 0xD7, 0xC1, 0xB3, 0x4C, 0x75, 0xC2, 0x36, 0xD2, 0x3F, -0x2A, 0x7C, 0xF7, 0x0C, 0x50, 0x60, 0xB1, 0x4A, 0x81, 0x18, 0x88, 0xD3, 0x22, 0x75, 0xD1, 0x63, -0x5C, 0x80, 0xF7, 0x19, 0x15, 0xA2, 0xA5, 0xB9, 0xB5, 0x5A, 0xB7, 0xA4, 0x34, 0x7D, 0x03, 0x48, -0x5F, 0x17, 0x90, 0x52, 0x01, 0x19, 0x95, 0x9E, 0x1E, 0xD1, 0x30, 0x30, 0x9A, 0x21, 0xD7, 0x0D, -0x81, 0xB3, 0xC1, 0x92, 0x0C, 0xE7, 0xD4, 0x1B, 0xBE, 0x49, 0xF2, 0x04, 0x15, 0x2A, 0x52, 0x06, -0x69, 0x31, 0xCA, 0xB3, 0x22, 0x71, 0xBD, 0x1F, 0x00, 0x4B, 0x82, 0x66, 0xB5, 0xA7, 0x37, 0xCF, -0x6F, 0x78, 0x0F, 0xF8, 0x5D, 0xC6, 0xA4, 0xAC, 0xF7, 0x23, 0x05, 0x6C, 0xE4, 0x4E, 0xE2, 0xE3, -0x95, 0xB7, 0xD3, 0x40, 0xF3, 0xA5, 0x06, 0x1C, 0xFE, 0x1F, 0x09, 0x2A, 0xA8, 0xF5, 0xE6, 0x3D, -0x00, 0xDD, 0xAD, 0x02, 0x2D, 0xC4, 0x4D, 0x66, 0xA0, 0x6A, 0x1F, 0xD5, 0x2E, 0xF8, 0x8F, 0xFF, -0x2D, 0xC6, 0x4F, 0x04, 0x1E, 0x14, 0xD0, 0xAC, 0x01, 0x3C, 0xAA, 0x5C, 0x1F, 0xA9, 0x2E, 0x72, -0xBA, 0x49, 0xB5, 0xC7, 0xFA, 0xC0, 0x27, 0xD2, 0x62, 0x69, 0xAE, 0xA7, 0xC8, 0x04, 0xEA, 0x0F, -0xBF, 0x1A, 0x51, 0x50, 0x61, 0x16, 0x8F, 0x1B, 0xD5, 0x5E, 0x03, 0x75, 0x35, 0xDD, 0x09, 0x6F, -0x88, 0xC4, 0x0D, 0x73, 0x07, 0x82, 0x61, 0x88, 0xE8, 0x59, 0x30, 0x45, 0x8E, 0xD4, 0x7A, 0xA7, -0xBD, 0xDA, 0x07, 0x67, 0x81, 0x40, 0x30, 0x88, 0x55, 0xF5, 0x11, 0x05, 0xF0, 0x58, 0x94, 0x9B, -0x48, 0xEC, 0x60, 0xF1, 0x09, 0xC7, 0xF1, 0x66, 0xFC, 0xDF, 0x0E, 0x84, 0x7F, 0x74, 0x1C, 0x8F, -0x58, 0x44, 0x77, 0xAC, 0x59, 0xB5, 0xD7, 0x67, 0x00, 0x12, 0x85, 0x4F, 0x2A, 0x4E, 0x17, 0xBB, -0x1F, 0xC6, 0x00, 0xB8, 0x99, 0xB0, 0xE7, 0x23, 0x9D, 0xF7, 0xCF, 0x6E, 0x44, 0x83, 0x4A, 0x45, -0x32, 0x40, 0x86, 0x81, 0x7C, 0x8D, 0xBA, 0xAB, 0x1C, 0xA7, 0xDE, 0x09, 0x87, 0x48, 0x21, 0x26, -0x5F, 0x4A, 0xAD, 0xBA, 0x6E, 0x4F, 0xCA, 0xFB, 0x23, 0xB7, 0x62, 0xF7, 0xCA, 0xAD, 0x58, 0x22, -0xC1, 0x00, 0x47, 0x9F, 0x0B, 0x7C, 0xCA, 0x73, 0xC1, 0xDB, 0x9F, 0x8C, 0xF2, 0x17, 0x1E, 0x4E, -0xDF, 0xF2, 0x6C, 0xF8, 0x67, 0xAF, 0x22, 0x7B, 0xF3, 0xEB, 0x4B, 0x80, 0x01, 0x00, 0xB8, 0x21, -0x72, 0x89, 0x08, 0x10, 0x07, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, -0x60, 0x82 -}; - -/// @endcond - diff --git a/native/cocos/cocos2d.h b/native/cocos/cocos2d.h index c5bb84bbef..cb316aad06 100644 --- a/native/cocos/cocos2d.h +++ b/native/cocos/cocos2d.h @@ -42,10 +42,8 @@ THE SOFTWARE. #include "base/CCAutoreleasePool.h" #include "base/CCData.h" #include "base/CCMap.h" -#include "base/CCNS.h" #include "base/CCRef.h" #include "base/CCRefPtr.h" -#include "base/CCUserDefault.h" #include "base/CCValue.h" #include "base/CCVector.h" #include "base/ZipUtils.h" @@ -58,7 +56,6 @@ THE SOFTWARE. // math -#include "math/CCAffineTransform.h" #include "math/CCGeometry.h" #include "math/CCVertex.h" #include "math/Mat4.h" diff --git a/native/cocos/editor-support/creator/Android.mk b/native/cocos/editor-support/creator/Android.mk deleted file mode 100644 index dd3f045050..0000000000 --- a/native/cocos/editor-support/creator/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := creator_static - -LOCAL_MODULE_FILENAME := libcreator - -LOCAL_SRC_FILES := CCScale9Sprite.cpp \ - CCGraphicsNode.cpp \ - Triangulate.cpp \ - physics/CCPhysicsDebugDraw.cpp \ - physics/CCPhysicsUtils.cpp \ - physics/CCPhysicsAABBQueryCallback.cpp \ - physics/CCPhysicsContactListener.cpp \ - physics/CCPhysicsRayCastCallback.cpp \ - physics/CCPhysicsManifoldWrapper.cpp \ - physics/CCPhysicsWorldManifoldWrapper.cpp \ - physics/CCPhysicsContactImpulse.cpp \ - CCCameraNode.cpp - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \ - $(LOCAL_PATH)/../.. \ - $(LOCAL_PATH)/../../../external/sources - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. \ - $(LOCAL_PATH)/../.. \ - $(LOCAL_PATH)/../../../external/sources - -include $(BUILD_STATIC_LIBRARY) diff --git a/native/cocos/editor-support/creator/CCCameraNode.cpp b/native/cocos/editor-support/creator/CCCameraNode.cpp deleted file mode 100644 index 9359147239..0000000000 --- a/native/cocos/editor-support/creator/CCCameraNode.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -// -// CCCameraNode.cpp -// cocos2d_libs -// -// Created by youyou on 17/3/23. -// -// - -#include "CCCameraNode.h" -#include "base/CCDirector.h" -#include "renderer/CCRenderer.h" - -using namespace cocos2d; - -namespace creator { - static CameraNode* _cameraInstance = nullptr; - - - CameraNode::CameraNode() - { - _mat.setIdentity(); - visitingIndex = 0; - } - - CameraNode::~CameraNode() - { - if (!_commands.empty()) - { - for (const auto& c : _commands) - { - delete c.beforeVisitCommand; - delete c.afterVisitCommand; - } - _commands.clear(); - } - } - - void CameraNode::setEnable(bool enable) - { - if (enable) { - _cameraInstance = this; - } - else { - _cameraInstance = nullptr; - } - } - - CameraNode* CameraNode::getInstance() { - return _cameraInstance; - } - - void CameraNode::setTransform(float a, float b, float c, float d, float tx, float ty) - { - float* m = _mat.m; - m[0] = a; - m[1] = b; - m[4] = c; - m[5] = d; - m[12] = tx; - m[13] = ty; - - _inverseMat = _mat; - _inverseMat.inverse(); - - _visibleRect.origin = Director::getInstance()->getVisibleOrigin(); - _visibleRect.size = Director::getInstance()->getVisibleSize(); - - _visibleRect = RectApplyTransform(_visibleRect, _inverseMat); - } - - const cocos2d::Rect& CameraNode::getVisibleRect() - { - return _visibleRect; - } - - bool CameraNode::containsNode(cocos2d::Node* node) - { - while (node) { - if (std::find(_nodes.begin(), _nodes.end(), node) !=_nodes.end()) { - return true; - } - node = node->getParent(); - } - - return false; - } - - void CameraNode::addTarget(Node* target) - { - if (std::find(_nodes.begin(), _nodes.end(), target) !=_nodes.end()) { - return; - } - - _nodes.push_back(target); - target->setCameraMask(1, false); - - CustomCommand* beforeVisitCommand = new CustomCommand(); - CustomCommand* afterVisitCommand = new CustomCommand(); - - target->setBeforeVisitCallback([this, beforeVisitCommand](Renderer* renderer) { - beforeVisitCommand->init(_globalZOrder); - beforeVisitCommand->func = CC_CALLBACK_0(CameraNode::beforeVisit, this); - renderer->addCommand(beforeVisitCommand); - }); - target->setAfterVisitCallback([this, afterVisitCommand](Renderer* renderer) { - afterVisitCommand->init(_globalZOrder); - afterVisitCommand->func = CC_CALLBACK_0(CameraNode::afterVisit, this); - renderer->addCommand(afterVisitCommand); - }); - - CameraCommand c = {target, beforeVisitCommand, afterVisitCommand}; - _commands.push_back(c); - } - - void CameraNode::removeTarget(Node* target) - { - target->setBeforeVisitCallback(nullptr); - target->setAfterVisitCallback(nullptr); - target->setCameraMask(0, false); - - for (auto i = _commands.begin(); i != _commands.end(); i++) - { - if (i->target == target) - { - delete i->beforeVisitCommand; - delete i->afterVisitCommand; - - _commands.erase(i); - break; - } - } - - for (auto i = _nodes.begin(); i != _nodes.end(); i++) { - if (*i == target) { - _nodes.erase(i); - break; - } - } - } - - void CameraNode::beforeVisit() - { - _director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, _mat); - } - - void CameraNode::afterVisit() - { - _director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, _mat.getInversed()); - } -} diff --git a/native/cocos/editor-support/creator/CCCameraNode.h b/native/cocos/editor-support/creator/CCCameraNode.h deleted file mode 100644 index f8ef080e73..0000000000 --- a/native/cocos/editor-support/creator/CCCameraNode.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CREATOR_CCCAMERANODE_H__ -#define __CREATOR_CCCAMERANODE_H__ - -#include "2d/CCNode.h" -#include "renderer/CCCustomCommand.h" - - -namespace creator { - struct CameraCommand - { - cocos2d::Node* target; - cocos2d::CustomCommand* beforeVisitCommand; - cocos2d::CustomCommand* afterVisitCommand; - }; - - // This class implements debug drawing callbacks that are invoked - // inside b2World::Step. - class CC_DLL CameraNode : public cocos2d::Node - { - public: - CameraNode(); - ~CameraNode(); - - static CameraNode* getInstance(); - - void setEnable(bool enable); - - void setTransform(float a, float b, float c, float d, float tx, float ty); - - bool containsNode(cocos2d::Node* node); - - void addTarget(cocos2d::Node* target); - void removeTarget(cocos2d::Node* target); - - const cocos2d::Rect& getVisibleRect(); - - int visitingIndex; - public: - void beforeVisit(); - void afterVisit(); - - protected: - cocos2d::Mat4 _mat; - cocos2d::Mat4 _inverseMat; - cocos2d::Rect _visibleRect; - - std::vector _commands; - std::vector _nodes; - }; - -} - -#endif diff --git a/native/cocos/editor-support/creator/CCGraphicsNode.cpp b/native/cocos/editor-support/creator/CCGraphicsNode.cpp deleted file mode 100644 index 0d85a1b529..0000000000 --- a/native/cocos/editor-support/creator/CCGraphicsNode.cpp +++ /dev/null @@ -1,1347 +0,0 @@ - -/**************************************************************************** - Copyright (c) 2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - - ****************************************************************************/ - -#include "CCGraphicsNode.h" -#include "base/CCDirector.h" -#include "renderer/CCRenderer.h" -#include "renderer/ccGLStateCache.h" -#include "renderer/CCGLProgram.h" -#include "renderer/CCGLProgramState.h" - -#define STRINGIFY(A) #A -#include "CCGraphicsNode.vert" -#include "CCGraphicsNode.frag" - -#include "Triangulate.h" - - -#define PI 3.14159265358979323846264338327f -#define PI_2 (PI * 2) -#define PI_HALF (PI * 0.5) - -#define VECTOR_INIT_VERTS_SIZE 256 - -#define VECTOR_KAPPA90 0.5522847493f // Length proportional to radius of a cubic bezier handle for 90deg arcs. - -#define EPSILON 0.0000000001f - -#define MAX_BUFFER_SIZE 65535 - -USING_NS_CC; - -namespace creator { - -GraphicsBuffer::GraphicsBuffer() -: vertsDirty(false) -, indicesDirty(false) -, vertsOffset(0) -, nVerts(VECTOR_INIT_VERTS_SIZE) -, indicesOffset(0) -, nIndices(VECTOR_INIT_VERTS_SIZE*3) -{ - verts = (VecVertex*)malloc(sizeof(VecVertex) * nVerts); - indices = (GLushort*)malloc(sizeof(GLushort) * nIndices); - - glGenBuffers(2, buffersVBO); -} - -GraphicsBuffer::~GraphicsBuffer() -{ - CC_SAFE_FREE(verts); - CC_SAFE_FREE(indices); -} - -bool GraphicsBuffer::allocVerts(int vertsCount) -{ - int dnverts = vertsOffset + vertsCount; - if (dnverts > MAX_BUFFER_SIZE) { - return false; - } - - if (dnverts > nVerts) { - while (dnverts > nVerts) { - nVerts *= 2; - } - verts = (VecVertex*)realloc(verts, sizeof(VecVertex) * nVerts); - } - - return true; -} - -void GraphicsBuffer::allocIndices(int indicesCount) -{ - int dnIndices = indicesOffset + indicesCount; - - if (dnIndices > nIndices) { - while (dnIndices > nIndices) { - nIndices *= 2; - } - indices = (GLushort*)realloc(indices, sizeof(GLushort) * nIndices); - } -} - -void GraphicsBuffer::clear() -{ - vertsOffset = 0; - indicesOffset = 0; -} - -GraphicsNode* GraphicsNode::create() -{ - GraphicsNode * ret = new (std::nothrow) GraphicsNode(); - if (ret && ret->init()) { - ret->autorelease(); - } - else { - CC_SAFE_DELETE(ret); - } - return ret; -} - -GraphicsNode::GraphicsNode() -: _needUpdatePathOffset(false) -, _lineWidth(1) -, _lineCap(CAP_BUTT) -, _lineJoin(JOIN_MITER) -, _nPoints(0) -, _nPath(0) -, _pathOffset(0) - -, _nCommands(0) -, _curPath(nullptr) - -, _buffer(nullptr) -{ - _miterLimit = 10.0f; - - setDeviceRatio(1); - - _strokeColor = Color4F::BLACK; - _fillColor = Color4F::WHITE; - - auto glprogram = GLProgram::createWithByteArrays(ccGraphicsVert, ccGraphicsFrag); - auto glprogramstate = GLProgramState::getOrCreateWithGLProgram(glprogram); - - // shader state - setGLProgramState(glprogramstate); - - - CHECK_GL_ERROR_DEBUG(); -} - -GraphicsNode::~GraphicsNode() -{ - clear(true); -} - -void GraphicsNode::moveTo(float x, float y) -{ - if (_needUpdatePathOffset) { - _pathOffset = _nPath; - _needUpdatePathOffset = false; - } - - addPath(); - addPoint(_curPath, x, y, PT_CORNER); - - _commandx = x; - _commandy = y; -} - -void GraphicsNode::lineTo(float x, float y) -{ - addPoint(_curPath, x, y, PT_CORNER); - - _commandx = x; - _commandy = y; -} - -void GraphicsNode::bezierCurveTo(float c1x, float c1y, float c2x, float c2y, float x, float y) -{ - VecPoint* last = _curPath->points.back(); - - if (last->x == c1x && last->y == c1y && c2x == x && c2y == y) { - this->lineTo(x, y); - return; - } - - tesselateBezier(last->x,last->y, c1x,c1y, c2x,c2y, x,y, 0, PT_CORNER); - - _commandx = x; - _commandy = y; -} - -void GraphicsNode::quadraticCurveTo(float cx, float cy, float x, float y) -{ - float x0 = _commandx; - float y0 = _commandy; - bezierCurveTo(x0 + 2.0f/3.0f*(cx - x0), y0 + 2.0f/3.0f*(cy - y0), - x + 2.0f/3.0f*(cx - x), y + 2.0f/3.0f*(cy - y), - x, y); -} - -void GraphicsNode::arcTo(float x1, float y1, float x2, float y2, float radius) -{ - float x0 = _commandx; - float y0 = _commandy; - float dx0,dy0, dx1,dy1, a, d, cx,cy, a0,a1; - bool counterclockwise; - - // Handle degenerate cases. - if (ptEquals(x0,y0, x1,y1, _distTol) || - ptEquals(x1,y1, x2,y2, _distTol) || - distPtSeg(x1,y1, x0,y0, x2,y2) < _distTol*_distTol || - radius < _distTol) { - lineTo(x1,y1); - return; - } - - // Calculate tangential circle to lines (x0,y0)-(x1,y1) and (x1,y1)-(x2,y2). - dx0 = x0-x1; - dy0 = y0-y1; - dx1 = x2-x1; - dy1 = y2-y1; - normalize(&dx0,&dy0); - normalize(&dx1,&dy1); - a = acosf(dx0*dx1 + dy0*dy1); - d = radius / tanf(a/2.0f); - - // printf("a=%f° d=%f\n", a/NVG_PI*180.0f, d); - - if (d > 10000.0f) { - lineTo(x1,y1); - return; - } - - if (cross(dx0,dy0, dx1,dy1) > 0.0f) { - cx = x1 + dx0*d + dy0*radius; - cy = y1 + dy0*d + -dx0*radius; - a0 = atan2f(dx0, -dy0); - a1 = atan2f(-dx1, dy1); - counterclockwise = false; - } else { - cx = x1 + dx0*d + -dy0*radius; - cy = y1 + dy0*d + dx0*radius; - a0 = atan2f(-dx0, dy0); - a1 = atan2f(dx1, -dy1); - counterclockwise = true; - } - - arc(cx, cy, radius, a0, a1, counterclockwise); -} - - -void GraphicsNode::arc(float cx, float cy, float r, float startAngle, float endAngle, bool counterclockwise) -{ - float a = 0, da = 0, hda = 0, kappa = 0; - float dx = 0, dy = 0, x = 0, y = 0, tanx = 0, tany = 0; - float px = 0, py = 0, ptanx = 0, ptany = 0; - int i, ndivs; - - // Clamp angles - da = endAngle - startAngle; - if (counterclockwise) { - if (absf(da) >= PI_2) { - da = PI_2; - } else { - while (da < 0.0f) da += PI_2; - } - } else { - if (absf(da) >= PI_2) { - da = -PI_2; - } else { - while (da > 0.0f) da -= PI_2; - } - } - - // Split arc into max 90 degree segments. - ndivs = maxi(1, mini((int)(absf(da) / PI_HALF + 0.5f), 5)); - hda = (da / (float)ndivs) / 2.0f; - kappa = absf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda)); - - if (!counterclockwise) { - kappa = -kappa; - } - - for (i = 0; i <= ndivs; i++) { - a = startAngle + da * (i/(float)ndivs); - dx = cosf(a); - dy = sinf(a); - x = cx + dx*r; - y = cy + dy*r; - tanx = -dy*r*kappa; - tany = dx*r*kappa; - - if (i == 0) { - moveTo(x, y); - } else { - bezierCurveTo(px+ptanx, py+ptany, x-tanx, y-tany, x, y); - } - px = x; - py = y; - ptanx = tanx; - ptany = tany; - } - - // _curPath->complex = false; -} - -void GraphicsNode::rect(float x, float y, float w, float h) -{ - moveTo(x, y); - lineTo(x, y+h); - lineTo(x+w, y+h); - lineTo(x+w, y); - close(); - - _curPath->complex = false; -} - -void GraphicsNode::roundRect(float x, float y, float w, float h, float r) -{ - if (r < 0.1f) { - rect(x,y,w,h); - return; - } - else { - float rx = minf(r, absf(w)*0.5f) * signf(w), ry = minf(r, absf(h)*0.5f) * signf(h); - - moveTo(x, y+ry); - lineTo(x, y+h-ry); - bezierCurveTo(x, y+h-ry*(1-VECTOR_KAPPA90), x+rx*(1-VECTOR_KAPPA90), y+h, x+rx, y+h); - lineTo(x+w-rx, y+h); - bezierCurveTo(x+w-rx*(1-VECTOR_KAPPA90), y+h, x+w, y+h-ry*(1-VECTOR_KAPPA90), x+w, y+h-ry); - lineTo(x+w, y+ry); - bezierCurveTo(x+w, y+ry*(1-VECTOR_KAPPA90), x+w-rx*(1-VECTOR_KAPPA90), y, x+w-rx, y); - lineTo(x+rx, y); - bezierCurveTo(x+rx*(1-VECTOR_KAPPA90), y, x, y+ry*(1-VECTOR_KAPPA90), x, y+ry); - close(); - - _curPath->complex = false; - } -} - -void GraphicsNode::ellipse(float cx, float cy, float rx, float ry) -{ - moveTo(cx-rx, cy); - bezierCurveTo(cx-rx, cy+ry*VECTOR_KAPPA90, cx-rx*VECTOR_KAPPA90, cy+ry, cx, cy+ry); - bezierCurveTo(cx+rx*VECTOR_KAPPA90, cy+ry, cx+rx, cy+ry*VECTOR_KAPPA90, cx+rx, cy); - bezierCurveTo(cx+rx, cy-ry*VECTOR_KAPPA90, cx+rx*VECTOR_KAPPA90, cy-ry, cx, cy-ry); - bezierCurveTo(cx-rx*VECTOR_KAPPA90, cy-ry, cx-rx, cy-ry*VECTOR_KAPPA90, cx-rx, cy); - - close(); - - _curPath->complex = false; -} - -void GraphicsNode::circle(float cx, float cy, float r) -{ - int divs = curveDivs(r, PI_2, _tessTol); - float step = PI_2 / divs; - - moveTo(cx, cy + r); - - for (int i = 1; i < divs; i++) { - float angle = step * i; - float x = r * sin(angle); - float y = r * cos(angle); - - lineTo(cx + x, cy + y); - } - - close(); - _curPath->complex = false; -} - -void GraphicsNode::fillRect(float x, float y, float w, float h) -{ - rect(x, y, w, h); - fill(); -} - -void GraphicsNode::close() -{ - _curPath->closed = true; -} -void GraphicsNode::beginPath() -{ - _pathOffset = _nPath; -} - - -void GraphicsNode::stroke() -{ - float scale = (_scaleX + _scaleY) / 2; - float strokeWidth = _lineWidth * scale; - - flattenPaths(); - - expandStroke(strokeWidth*0.5f + _fringeWidth*0.5f, _lineCap, _lineJoin, _miterLimit); - - _buffer->vertsDirty = true; - _buffer->indicesDirty = true; - _needUpdatePathOffset = true; -} - -void GraphicsNode::fill() -{ - flattenPaths(); - - expandFill(_fringeWidth, JOIN_MITER, 2.4f); - - _buffer->vertsDirty = true; - _buffer->indicesDirty = true; - _needUpdatePathOffset = true; -} - -void GraphicsNode::clear(bool clean) -{ - if (clean) { - for (int i = (int)_paths.size() - 1; i >= 0; i--) { - Path* path = _paths[i]; - _paths.pop_back(); - delete path; - } - - for (int i = (int)_points.size() - 1; i >=0; i--) { - VecPoint* p = _points[i]; - _points.pop_back(); - delete p; - } - - for (int i = (int)_commands.size() - 1; i >=0; i--) { - Command* c = _commands[i]; - _commands.pop_back(); - delete c; - } - - for (int i = (int)_buffers.size() - 1; i >=0; i--) { - GraphicsBuffer* b = _buffers[i]; - _buffers.pop_back(); - delete b; - } - - _buffer = nullptr; - } - else if (_buffers.size() > 0) { - for (int i = (int)_buffers.size() - 1; i >=0; i--) { - GraphicsBuffer* b = _buffers[i]; - b->clear(); - } - - _buffer = _buffers[0]; - } - - _nPoints = 0; - - _nPath = 0; - _pathOffset = 0; - - _curPath = nullptr; - - _nCommands = 0; -} - -// static function - -int GraphicsNode::ptEquals(float x1, float y1, float x2, float y2, float tol) -{ - float dx = x2 - x1; - float dy = y2 - y1; - return dx*dx + dy*dy < tol*tol; -} -float GraphicsNode::distPtSeg(float x, float y, float px, float py, float qx, float qy) -{ - float pqx, pqy, dx, dy, d, t; - pqx = qx-px; - pqy = qy-py; - dx = x-px; - dy = y-py; - d = pqx*pqx + pqy*pqy; - t = pqx*dx + pqy*dy; - if (d > 0) t /= d; - if (t < 0) t = 0; - else if (t > 1) t = 1; - dx = px + t*pqx - x; - dy = py + t*pqy - y; - return dx*dx + dy*dy; -} - -float GraphicsNode::normalize(float *x, float* y) -{ - float d = sqrtf((*x)*(*x) + (*y)*(*y)); - if (d > 1e-6f) { - float id = 1.0f / d; - *x *= id; - *y *= id; - } - return d; -} - -int GraphicsNode::curveDivs(float r, float arc, float tol) -{ - float da = acosf(r / (r + tol)) * 2.0f; - return maxi(2, (int)ceilf(arc / da)); -} - -void GraphicsNode::chooseBevel(int bevel, VecPoint* p0, VecPoint* p1, float w, - float* x0, float* y0, float* x1, float* y1) -{ - if (bevel) { - *x0 = p1->x + p0->dy * w; - *y0 = p1->y - p0->dx * w; - *x1 = p1->x + p1->dy * w; - *y1 = p1->y - p1->dx * w; - } else { - *x0 = p1->x + p1->dmx * w; - *y0 = p1->y + p1->dmy * w; - *x1 = p1->x + p1->dmx * w; - *y1 = p1->y + p1->dmy * w; - } -} - - -// protected function - -void GraphicsNode::tesselateBezier(float x1, float y1, float x2, float y2, - float x3, float y3, float x4, float y4, - int level, int type) -{ - float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234; - float dx,dy,d2,d3; - - if (level > 10) return; - - x12 = (x1+x2)*0.5f; - y12 = (y1+y2)*0.5f; - x23 = (x2+x3)*0.5f; - y23 = (y2+y3)*0.5f; - x34 = (x3+x4)*0.5f; - y34 = (y3+y4)*0.5f; - x123 = (x12+x23)*0.5f; - y123 = (y12+y23)*0.5f; - - dx = x4 - x1; - dy = y4 - y1; - d2 = absf(((x2 - x4) * dy - (y2 - y4) * dx)); - d3 = absf(((x3 - x4) * dy - (y3 - y4) * dx)); - - if ((d2 + d3)*(d2 + d3) < _tessTol * (dx*dx + dy*dy)) { - addPoint(_curPath, x4, y4, type == 0 ? type | PT_BEVEL : type); - return; - } - - x234 = (x23+x34)*0.5f; - y234 = (y23+y34)*0.5f; - x1234 = (x123+x234)*0.5f; - y1234 = (y123+y234)*0.5f; - - tesselateBezier(x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0); - tesselateBezier(x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type); -} - -void GraphicsNode::addPoint(Path* path, float x, float y, int flags) -{ - VecPoint* pt; - if (path == NULL) return; - - if (path->points.size() > 0) { - pt = path->points.back(); - if (pt->equals(Vec2(x, y))) { - pt->flags |= flags; - return; - } - } - - _nPoints ++; - if (_nPoints > _points.size()) { - pt = new VecPoint(x, y); - _points.push_back(pt); - } - else { - pt = _points[_nPoints - 1]; - pt->reset(); - pt->x = x; - pt->y = y; - } - - pt->flags = (unsigned char)flags; - path->points.push_back(pt); -} - -Path* GraphicsNode::addPath() -{ - if (!(_curPath && _curPath->points.size() <= 1)) { - _nPath ++; - } - - Path* path = nullptr; - - - if (_nPath > _paths.size()) { - path = new Path(); - _paths.push_back(path); - } - else { - - path = _paths[_nPath - 1]; - path->points.clear(); - } - - path->closed = false; - path->complex = true; - - _curPath = path; - - return path; -} - -void GraphicsNode::expandStroke(float w, int lineCap, int lineJoin, float miterLimit) -{ - - int cverts, i, j; - float aa = _fringeWidth; - int ncap = curveDivs(w, PI, _tessTol); - - calculateJoins(w, lineJoin, miterLimit); - - // Calculate max vertex usage. - cverts = 0; - for (i = _pathOffset; i < _nPath; i++) { - Path* path = _paths[i]; - int pathSize = (int)path->points.size(); - - int loop = (path->closed == 0) ? 0 : 1; - if (lineJoin == JOIN_ROUND) -// cverts += (pathSize + path->nbevel*(ncap+2) + 1) * 2; - cverts += (pathSize*(ncap+2) + 1) * 2; // plus one for loop - else - cverts += (pathSize + path->nbevel*5 + 1) * 2; // plus one for loop - if (loop == 0) { - // space for caps - if (lineCap == CAP_ROUND) { - cverts += (ncap*2 + 2)*2; - } else { - cverts += (3+3)*2; - } - } - } - - if (!_buffer || !_buffer->allocVerts(cverts)) { - allocBuffer(); - _buffer->allocVerts(cverts); - } - - _buffer->allocIndices((cverts - 2*(_nPath-_pathOffset)) * 3); - - for (i = _pathOffset; i < _nPath; i++) { - VecVertex* verts = _buffer->verts + _buffer->vertsOffset; - int offset = _buffer->vertsOffset; - - Path* path = _paths[i]; - - VecPointVector& pts = path->points; - int pathSize = (int)path->points.size(); - - VecPoint* p0; - VecPoint* p1; - int s, e, loop; - float dx, dy; - - // Calculate fringe or stroke - loop = (path->closed == 0) ? 0 : 1; - - if (loop) { - // Looping - p0 = pts.back(); - p1 = pts.front(); - s = 0; - e = pathSize; - } else { - // Add cap - p0 = pts[0]; - p1 = pts[1]; - s = 1; - e = pathSize-1; - } - - if (loop == 0) { - // Add cap - dx = p1->x - p0->x; - dy = p1->y - p0->y; - normalize(&dx, &dy); - if (lineCap == CAP_BUTT) - buttCapStart(p0, dx, dy, w, -aa*0.5f, aa); - else if (lineCap == CAP_BUTT || lineCap == CAP_SQUARE) - buttCapStart(p0, dx, dy, w, w-aa, aa); - else if (lineCap == CAP_ROUND) - roundCapStart(p0, dx, dy, w, ncap, aa); - } - - for (j = s; j < e; ++j) { - if (lineJoin == JOIN_ROUND) { - roundJoin(p0, p1, w, w, 0, 1, ncap, aa); - } - else if ((p1->flags & (PT_BEVEL | PT_INNERBEVEL)) != 0) { - bevelJoin(p0, p1, w, w, 0, 1, aa); - } else { - vset(p1->x + (p1->dmx * w), p1->y + (p1->dmy * w), 0,1); - vset(p1->x - (p1->dmx * w), p1->y - (p1->dmy * w), 1,1); - } - if (!loop || (loop && j < (e - 1))) { - p0 = p1; - p1 = pts[j + 1]; - } - } - - if (loop) { - // Loop it - vset(verts[0].x, verts[0].y, 0,1); - vset(verts[1].x, verts[1].y, 1,1); - } else { - // Add cap - dx = p1->x - p0->x; - dy = p1->y - p0->y; - normalize(&dx, &dy); - if (lineCap == CAP_BUTT) - buttCapEnd(p1, dx, dy, w, -aa*0.5f, aa); - else if (lineCap == CAP_BUTT || lineCap == CAP_SQUARE) - buttCapEnd(p1, dx, dy, w, w-aa, aa); - else if (lineCap == CAP_ROUND) - roundCapEnd(p1, dx, dy, w, ncap, aa); - } - - // stroke indices - int indicesOffset = _buffer->indicesOffset; - - for (int start = offset+2, end = _buffer->vertsOffset; start < end; start++) { - _buffer->indices[_buffer->indicesOffset++] = start - 2; - _buffer->indices[_buffer->indicesOffset++] = start - 1; - _buffer->indices[_buffer->indicesOffset++] = start; - } - - float strokeMult = (_lineWidth*0.5f + _fringeWidth*0.5f) / _fringeWidth; - pushCommand(_strokeColor, strokeMult, offset, _buffer->vertsOffset - offset, indicesOffset, _buffer->indicesOffset - indicesOffset); - } -} - -void GraphicsNode::expandFill(float w, int lineJoin, float miterLimit) -{ - int cverts, convex, i, j; - float aa = _fringeWidth; - int fringe = w > 0.0f; - - calculateJoins(w, lineJoin, miterLimit); - - // Calculate max vertex usage. - cverts = 0; - for (i = _pathOffset; i < _nPath; i++) { - Path* path = _paths[i]; - int pathSize = (int)path->points.size(); - - cverts += pathSize;// + path->nbevel + 1; - if (fringe) { - cverts += (pathSize + path->nbevel*5 + 1) * 2; // plus one for loop -// cverts += (pathSize + 1) * 2; - } - } - - if (!_buffer || !_buffer->allocVerts(cverts)) { - allocBuffer(); - _buffer->allocVerts(cverts); - } - - convex = _nPath == 1 && _paths[_pathOffset]->convex; - - for (i = _pathOffset; i < _nPath; i++) { - Path* path = _paths[i]; - - VecVertex* verts = _buffer->verts + _buffer->vertsOffset; - int offset = _buffer->vertsOffset; - - VecPointVector& pts = path->points; - int pathSize = (int)pts.size(); - - VecPoint* p0; - VecPoint* p1; - float woff; - - // Calculate shape vertices. - woff = 0.5f*aa; - - if (fringe) { - // Looping - p0 = pts[pathSize-1]; - p1 = pts[0]; - for (j = 0; j < pathSize; ++j) { - if (p1->flags & PT_BEVEL) { - float dlx0 = p0->dy; - float dly0 = -p0->dx; - float dlx1 = p1->dy; - float dly1 = -p1->dx; - if (p1->flags & PT_LEFT) { - float lx = p1->x + p1->dmx * woff; - float ly = p1->y + p1->dmy * woff; - vset(lx, ly, 0.5f,1); - } else { - float lx0 = p1->x + dlx0 * woff; - float ly0 = p1->y + dly0 * woff; - float lx1 = p1->x + dlx1 * woff; - float ly1 = p1->y + dly1 * woff; - vset(lx0, ly0, 0.5f,1); - vset(lx1, ly1, 0.5f,1); - } - } else { - vset(p1->x + (p1->dmx * woff), p1->y + (p1->dmy * woff), 0.5f,1); - } - - if (j < (pathSize - 1)) { - p0 = p1; - p1 = pts[j + 1]; - } - } - } else { - for (j = 0; j < pathSize; ++j) { - vset(pts[j]->x, pts[j]->y, 0.5f,1); - } - } - - int nVerts = _buffer->vertsOffset - offset; - int indicesOffset = _buffer->indicesOffset; - - if (path->complex) { - // indices - std::vector indices; - Triangulate::process(verts, 0, _buffer->vertsOffset - offset, indices); - int nIndices = (int)indices.size(); - - _buffer->allocIndices(nIndices); - - for (j = 0; j < nIndices; j++) { - _buffer->indices[j + _buffer->indicesOffset] = indices[j] + offset; - } - - _buffer->indicesOffset += nIndices; - } - else { - _buffer->allocIndices((nVerts - 2) * 3); - - int first = offset; - for (int start = offset+2, end = _buffer->vertsOffset; start < end; start++) { - _buffer->indices[_buffer->indicesOffset++] = first; - _buffer->indices[_buffer->indicesOffset++] = start - 1; - _buffer->indices[_buffer->indicesOffset++] = start; - } - } - - pushCommand(_fillColor, 1, offset, _buffer->vertsOffset - offset, indicesOffset, _buffer->indicesOffset - indicesOffset); - - // Calculate fringe - if (fringe) { - verts = _buffer->verts + _buffer->vertsOffset; - offset = _buffer->vertsOffset; - - float lw = w + woff; - float rw = w - woff; - float lu = 0; - float ru = 1; - - // Create only half a fringe for convex shapes so that - // the shape can be rendered without stenciling. - if (convex) { - lw = woff; // This should generate the same vertex as fill inset above. - lu = 0.5f; // Set outline fade at middle. - } - - // Looping - p0 = pts[pathSize-1]; - p1 = pts[0]; - - for (j = 0; j < pathSize; ++j) { - if ((p1->flags & (PT_BEVEL | PT_INNERBEVEL)) != 0) { - bevelJoin(p0, p1, lw, rw, lu, ru, _fringeWidth); - } else { - vset(p1->x + (p1->dmx * lw), p1->y + (p1->dmy * lw), lu,1); - vset(p1->x - (p1->dmx * rw), p1->y - (p1->dmy * rw), ru,1); - } - - if (j < (pathSize - 1)) { - p0 = p1; - p1 = pts[j + 1]; - } - } - - // Loop it - vset(verts[0].x, verts[0].y, lu,1); - vset(verts[1].x, verts[1].y, ru,1); - - // fill stroke indices - nVerts = _buffer->vertsOffset - offset; - indicesOffset = _buffer->indicesOffset; - - _buffer->allocIndices((nVerts - 2) * 3); - - for (int start = offset+2, end = _buffer->vertsOffset; start < end; start++) { - _buffer->indices[_buffer->indicesOffset++] = start - 2; - _buffer->indices[_buffer->indicesOffset++] = start - 1; - _buffer->indices[_buffer->indicesOffset++] = start; - } - - pushCommand(_fillColor, 1, offset, nVerts, indicesOffset, _buffer->indicesOffset - indicesOffset); - } - } -} - -void GraphicsNode::flattenPaths() -{ - if (_curPath && _curPath->points.size() <= 1) { - _nPath --; - _curPath = _nPath > 0 ? _paths[_nPath - 1] : nullptr; - } - - for (int i = _pathOffset; i < _nPath; i++) { - Path* path = _paths[i]; - VecPointVector& pts = path->points; - - VecPoint* p0 = pts.back(); - VecPoint* p1 = pts.front(); - - if(p0->equals(*p1)) { - path->closed = true; - pts.pop_back(); - p0 = pts.back(); - } - - for (int j = 0, size = (int)pts.size(); j < size; j++) { - // Calculate segment direction and length - p0->dx = p1->x - p0->x; - p0->dy = p1->y - p0->y; - p0->len = normalize(&p0->dx, &p0->dy); - - // Advance - if (j < (size - 1)) { - p0 = p1; - p1 = pts[j + 1]; - } - } - } -} - - -void GraphicsNode::calculateJoins(float w, int lineJoin, float miterLimit) -{ - int i, j, ii, jj; - float iw = 0.0f; - - if (w > 0.0f) - iw = 1.0f / w; - - // Calculate which joins needs extra vertices to append, and gather vertex count. - for (i = _pathOffset, ii = _nPath; i < ii; i++) { - Path* path = _paths[i]; - - VecPointVector& pts = path->points; - VecPoint* p0 = pts[pts.size()-1]; - VecPoint* p1 = pts[0]; - int nleft = 0; - - path->nbevel = 0; - - for (j = 0, jj = (int)pts.size(); j < jj; j++) { - float dlx0, dly0, dlx1, dly1, dmr2, cross, limit; - dlx0 = p0->dy; - dly0 = -p0->dx; - dlx1 = p1->dy; - dly1 = -p1->dx; - // Calculate extrusions - p1->dmx = (dlx0 + dlx1) * 0.5f; - p1->dmy = (dly0 + dly1) * 0.5f; - dmr2 = p1->dmx*p1->dmx + p1->dmy*p1->dmy; - if (dmr2 > 0.000001f) { - float scale = 1.0f / dmr2; - if (scale > 600.0f) { - scale = 600.0f; - } - p1->dmx *= scale; - p1->dmy *= scale; - } - - // Clear flags, but keep the corner. - p1->flags = (p1->flags & PT_CORNER) ? PT_CORNER : 0; - - // Keep track of left turns. - cross = p1->dx * p0->dy - p0->dx * p1->dy; - if (cross > 0.0f) { - nleft++; - p1->flags |= PT_LEFT; - } - - // Calculate if we should use bevel or miter for inner join. - limit = maxf(1.01f, minf(p0->len, p1->len) * iw); - if ((dmr2 * limit*limit) < 1.0f) - p1->flags |= PT_INNERBEVEL; - - // Check to see if the corner needs to be beveled. - if (p1->flags & PT_CORNER) { - if ((dmr2 * miterLimit*miterLimit) < 1.0f || lineJoin == JOIN_BEVEL || lineJoin == JOIN_ROUND) { - p1->flags |= PT_BEVEL; - } - } - - if ((p1->flags & (PT_BEVEL | PT_INNERBEVEL)) != 0) - path->nbevel++; - - if (j < (jj - 1)) { - p0 = p1; - p1 = pts[j + 1]; - } - } - - path->convex = nleft == pts.size(); - } -} - -void GraphicsNode::allocBuffer() -{ - if (_buffer) { - const auto iterator = std::find(_buffers.begin(), _buffers.end(), _buffer); - if (iterator != _buffers.end() && (*iterator) != _buffers.back()) { - _buffer = *(iterator+1); - return; - } - } - - GraphicsBuffer* buffer = new GraphicsBuffer(); - _buffer = buffer; - _buffers.push_back(buffer); -} - - -void GraphicsNode::vset(float x, float y, float u, float v) -{ - VecVertex* vtx = &_buffer->verts[_buffer->vertsOffset]; - - vtx->x = x; - vtx->y = y; - vtx->u = u; - vtx->v = v; - - _buffer->vertsOffset ++; -} - -void GraphicsNode::pushCommand(cocos2d::Color4F& color, float strokeMult, int vertsOffset, int nVerts, int indicesOffset, int nIndices) -{ - Command* lastCmd = nullptr; - if (_commands.size() >= _nCommands && _nCommands > 0) { - lastCmd = _commands[_nCommands - 1]; - } - - if (lastCmd && - ((lastCmd->vertsOffset + lastCmd->nVerts) == vertsOffset) && - ((lastCmd->indicesOffset + lastCmd->nIndices) == indicesOffset) && - lastCmd->color.equals(color) && - lastCmd->strokeMult == strokeMult && - lastCmd->buffer == _buffer) { - lastCmd->nVerts += nVerts; - lastCmd->nIndices += nIndices; - } - else { - Command* cmd; - - _nCommands ++; - if (_nCommands > _commands.size()) { - cmd = new Command(); - _commands.push_back(cmd); - } - else { - cmd = _commands[_nCommands - 1]; - } - - cmd->color = color; - cmd->strokeMult = strokeMult; - cmd->vertsOffset = vertsOffset; - cmd->nVerts = nVerts; - cmd->indicesOffset = indicesOffset; - cmd->nIndices = nIndices; - cmd->buffer = _buffer; - } -} - -void GraphicsNode::buttCapStart(VecPoint* p, float dx, float dy, float w, float d, float aa) -{ - float px = p->x - dx*d; - float py = p->y - dy*d; - float dlx = dy; - float dly = -dx; - vset(px + dlx*w - dx*aa, py + dly*w - dy*aa, 0,0); - vset(px - dlx*w - dx*aa, py - dly*w - dy*aa, 1,0); - vset(px + dlx*w, py + dly*w, 0,1); - vset(px - dlx*w, py - dly*w, 1,1); -} - -void GraphicsNode::buttCapEnd(VecPoint* p, float dx, float dy, float w, float d, float aa) -{ - float px = p->x + dx*d; - float py = p->y + dy*d; - float dlx = dy; - float dly = -dx; - vset(px + dlx*w, py + dly*w, 0,1); - vset(px - dlx*w, py - dly*w, 1,1); - vset(px + dlx*w + dx*aa, py + dly*w + dy*aa, 0,0); - vset(px - dlx*w + dx*aa, py - dly*w + dy*aa, 1,0); -} - -void GraphicsNode::roundCapStart(VecPoint* p, float dx, float dy, float w, int ncap, float aa) -{ - int i; - float px = p->x; - float py = p->y; - float dlx = dy; - float dly = -dx; - - for (i = 0; i < ncap; i++) { - float a = i/(float)(ncap-1) * PI; - float ax = cosf(a) * w, ay = sinf(a) * w; - vset(px - dlx*ax - dx*ay, py - dly*ax - dy*ay, 0,1); - vset(px, py, 0.5f,1); - } - vset(px + dlx*w, py + dly*w, 0,1); - vset(px - dlx*w, py - dly*w, 1,1); -} - -void GraphicsNode::roundCapEnd(VecPoint* p, float dx, float dy, float w, int ncap, float aa) -{ - int i; - float px = p->x; - float py = p->y; - float dlx = dy; - float dly = -dx; - - vset(px + dlx*w, py + dly*w, 0,1); - vset(px - dlx*w, py - dly*w, 1,1); - for (i = 0; i < ncap; i++) { - float a = i/(float)(ncap-1)*PI; - float ax = cosf(a) * w, ay = sinf(a) * w; - vset(px, py, 0.5f,1); - vset(px - dlx*ax + dx*ay, py - dly*ax + dy*ay, 0,1); - } -} - -void GraphicsNode::roundJoin(VecPoint* p0, VecPoint* p1, float lw, float rw, float lu, float ru, int ncap, float fringe) -{ - int i, n; - float dlx0 = p0->dy; - float dly0 = -p0->dx; - float dlx1 = p1->dy; - float dly1 = -p1->dx; - - if (p1->flags & PT_LEFT) { - float lx0,ly0,lx1,ly1,a0,a1; - chooseBevel(p1->flags & PT_INNERBEVEL, p0, p1, lw, &lx0,&ly0, &lx1,&ly1); - a0 = atan2f(-dly0, -dlx0); - a1 = atan2f(-dly1, -dlx1); - if (a1 > a0) a1 -= PI_2; - - vset(lx0, ly0, lu,1); - vset(p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); - - n = clampi((int)ceilf(((a0 - a1) / PI) * ncap), 2, ncap); - for (i = 0; i < n; i++) { - float u = i/(float)(n-1); - float a = a0 + u*(a1-a0); - float rx = p1->x + cosf(a) * rw; - float ry = p1->y + sinf(a) * rw; - vset(p1->x, p1->y, 0.5f,1); - vset(rx, ry, ru,1); - } - - vset(lx1, ly1, lu,1); - vset(p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); - - } else { - float rx0,ry0,rx1,ry1,a0,a1; - chooseBevel(p1->flags & PT_INNERBEVEL, p0, p1, -rw, &rx0,&ry0, &rx1,&ry1); - a0 = atan2f(dly0, dlx0); - a1 = atan2f(dly1, dlx1); - if (a1 < a0) a1 += PI_2; - - vset(p1->x + dlx0*rw, p1->y + dly0*rw, lu,1); - vset(rx0, ry0, ru,1); - - n = clampi((int)ceilf(((a1 - a0) / PI) * ncap), 2, ncap); - for (i = 0; i < n; i++) { - float u = i/(float)(n-1); - float a = a0 + u*(a1-a0); - float lx = p1->x + cosf(a) * lw; - float ly = p1->y + sinf(a) * lw; - vset(lx, ly, lu,1); - vset(p1->x, p1->y, 0.5f,1); - } - - vset(p1->x + dlx1*rw, p1->y + dly1*rw, lu,1); - vset(rx1, ry1, ru,1); - - } -} - - -void GraphicsNode::bevelJoin(VecPoint* p0, VecPoint* p1, float lw, float rw, float lu, float ru, float fringe) -{ - float rx0,ry0,rx1,ry1; - float lx0,ly0,lx1,ly1; - float dlx0 = p0->dy; - float dly0 = -p0->dx; - float dlx1 = p1->dy; - float dly1 = -p1->dx; - - if (p1->flags & PT_LEFT) { - chooseBevel(p1->flags & PT_INNERBEVEL, p0, p1, lw, &lx0,&ly0, &lx1,&ly1); - - vset(lx0, ly0, lu,1); - vset(p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); - -// if (p1->flags & PT_BEVEL) { -// vset(lx0, ly0, lu,1); -// vset(p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); -// -// vset(lx1, ly1, lu,1); -// vset(p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); -// } else { -// rx0 = p1->x - p1->dmx * rw; -// ry0 = p1->y - p1->dmy * rw; -// -// vset(p1->x, p1->y, 0.5f,1); -// vset(p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); -// -// vset(rx0, ry0, ru,1); -// vset(rx0, ry0, ru,1); -// -// vset(p1->x, p1->y, 0.5f,1); -// vset(p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); -// } - - vset(lx1, ly1, lu,1); - vset(p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); - - } else { - chooseBevel(p1->flags & PT_INNERBEVEL, p0, p1, -rw, &rx0,&ry0, &rx1,&ry1); - - vset(p1->x + dlx0*lw, p1->y + dly0*lw, lu,1); - vset(rx0, ry0, ru,1); - -// if (p1->flags & PT_BEVEL) { -// vset(p1->x + dlx0*lw, p1->y + dly0*lw, lu,1); -// vset(rx0, ry0, ru,1); -// -// vset(p1->x + dlx1*lw, p1->y + dly1*lw, lu,1); -// vset(rx1, ry1, ru,1); -// } else { -// lx0 = p1->x + p1->dmx * lw; -// ly0 = p1->y + p1->dmy * lw; -// -// vset(p1->x + dlx0*lw, p1->y + dly0*lw, lu,1); -// vset(p1->x, p1->y, 0.5f,1); -// -// vset(lx0, ly0, lu,1); -// vset(lx0, ly0, lu,1); -// -// vset(p1->x + dlx1*lw, p1->y + dly1*lw, lu,1); -// vset(p1->x, p1->y, 0.5f,1); -// } - - vset(p1->x + dlx1*lw, p1->y + dly1*lw, lu,1); - vset(rx1, ry1, ru,1); - } -} - - -void GraphicsNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) -{ - _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(GraphicsNode::onDraw, this, transform, flags); - renderer->addCommand(&_customCommand); -} - - -void GraphicsNode::onDraw(const Mat4 &transform, uint32_t flags) -{ - if (_nCommands <=0) return; - - auto program = getGLProgram(); - program->use(); - program->setUniformsForBuiltins(transform); - - glBlendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED.src, BlendFunc::ALPHA_NON_PREMULTIPLIED.dst); - - - GLint colorLocation = program->getUniformLocation("color"); - GLint strokeMultLocation = program->getUniformLocation("strokeMult"); - - // draw paths - for (int i = 0; i < _nCommands; i++) { - Command* cmd = _commands[i]; - - GraphicsBuffer* buffer = cmd->buffer; - - glBindBuffer(GL_ARRAY_BUFFER, buffer->buffersVBO[0]); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer->buffersVBO[1]); - - if (buffer->vertsDirty) { - glBufferData(GL_ARRAY_BUFFER, sizeof(VecVertex) * buffer->vertsOffset, buffer->verts, GL_DYNAMIC_DRAW); - - buffer->vertsDirty = false; - } - - if (buffer->indicesDirty) { - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(buffer->indices[0]) * buffer->indicesOffset, buffer->indices, GL_STREAM_DRAW); - - buffer->indicesDirty = false; - } - - GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORD); - - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(VecVertex), (const GLvoid*)(size_t)0); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(VecVertex), (const GLvoid*)(0 + 2*sizeof(float))); - - if (cmd->nIndices) { - Color4F& color = cmd->color; - program->setUniformLocationWith4f(colorLocation, color.r, color.g, color.b, color.a); - program->setUniformLocationWith1f(strokeMultLocation, cmd->strokeMult); - - glDrawElements(GL_TRIANGLES, (GLsizei)cmd->nIndices, GL_UNSIGNED_SHORT, (const GLvoid *)((size_t)cmd->indicesOffset*2)); - - CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, cmd->nVerts); - } - } - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - - CHECK_GL_ERROR_DEBUG(); -} - -} diff --git a/native/cocos/editor-support/creator/CCGraphicsNode.frag b/native/cocos/editor-support/creator/CCGraphicsNode.frag deleted file mode 100755 index 19d6a067d1..0000000000 --- a/native/cocos/editor-support/creator/CCGraphicsNode.frag +++ /dev/null @@ -1,23 +0,0 @@ - -const char* ccGraphicsFrag = STRINGIFY( -//\n#ifdef GL_ES\n -//precision mediump float; -//\n#endif\n - -varying vec2 v_texCoord; -uniform float strokeMult; -uniform vec4 color; - -// Stroke - from [0..1] to clipped pyramid, where the slope is 1px. -float strokeMask() { - return min(1.0, (1.0-abs(v_texCoord.x*2.0-1.0))*strokeMult) * min(1.0, v_texCoord.y); -} - -void main(void) { - - float strokeAlpha = strokeMask(); - - gl_FragColor = vec4(color.rgb, color.a * strokeAlpha); -} - -); \ No newline at end of file diff --git a/native/cocos/editor-support/creator/CCGraphicsNode.h b/native/cocos/editor-support/creator/CCGraphicsNode.h deleted file mode 100644 index 9ed21f0ae8..0000000000 --- a/native/cocos/editor-support/creator/CCGraphicsNode.h +++ /dev/null @@ -1,315 +0,0 @@ - -/**************************************************************************** - Copyright (c) 2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - - ****************************************************************************/ - -#ifndef __CREATOR_CCGRAPHICSNODE_H__ -#define __CREATOR_CCGRAPHICSNODE_H__ - -#include "2d/CCNode.h" -#include "renderer/CCCustomCommand.h" - -namespace creator { - -// join: bevel, round, miter -// cap : butt, round, square -enum LineCap -{ - CAP_BUTT, - CAP_ROUND, - CAP_SQUARE, -}; - -enum LineJoin -{ - JOIN_BEVEL, - JOIN_ROUND, - JOIN_MITER, -}; - -enum PointFlags -{ - PT_CORNER = 0x01, - PT_LEFT = 0x02, - PT_BEVEL = 0x04, - PT_INNERBEVEL = 0x08, -}; - -struct VecVertex { - float x,y,u,v; -}; -typedef struct VecVertex VecVertex; - -class VecPoint: public cocos2d::Vec2 -{ -public: - VecPoint() - { - reset(); - } - - VecPoint(float x, float y) - : Vec2(x, y) - { - reset(); - } - - void reset () { - dx = 0; - dy = 0; - dmx = 0; - dmy = 0; - flags = 0; - len = 0; - } - - float dx; - float dy; - float dmx; - float dmy; - unsigned char flags; - float len; -}; - -typedef std::vector< VecPoint* > VecPointVector; - - -struct Path -{ - VecPointVector points; - bool closed; - bool convex; - int nbevel; - - bool complex; -}; -typedef struct Path Path; - -class GraphicsBuffer -{ -public: - GraphicsBuffer(); - ~GraphicsBuffer(); - - bool allocVerts(int vertsCount); - void allocIndices(int indicesCount); - - void clear(); - - // verts - int nVerts; - int vertsOffset; - VecVertex* verts; - bool vertsDirty; - - // indices - int nIndices; - int indicesOffset; - GLushort* indices; - bool indicesDirty; - - GLuint buffersVBO[2]; -}; - -struct Command -{ - cocos2d::Color4F color; - float strokeMult; - - int nVerts; - int vertsOffset; - int nIndices; - int indicesOffset; - - GraphicsBuffer* buffer; -}; -typedef struct Command Command; -typedef std::vector< Command* > CommandVector; - - -class CC_DLL GraphicsNode : public cocos2d::Node -{ -public: - - static GraphicsNode* create(); - - void setLineCap(LineCap cap) { _lineCap = cap; } - LineCap getLineCap() { return _lineCap; } - - void setLineJoin(LineJoin join) { _lineJoin = join; } - LineJoin getLineJoin() { return _lineJoin; } - - void setLineWidth(float width) { _lineWidth = width; } - float getLineWidth() { return _lineWidth; } - - void setMiterLimit(float miterLimit) { _miterLimit = miterLimit; } - float getMiterLimit() { return _miterLimit; } - - void setStrokeColor(const cocos2d::Color4F& color) { - _strokeColor = color; - } - cocos2d::Color4F getStrokeColor() { return _strokeColor; } - - void setFillColor(const cocos2d::Color4F& color) { _fillColor = color; } - cocos2d::Color4F getFillColor() { return _fillColor; } - - void setDeviceRatio(float ratio) { - _ratio = ratio; - _fringeWidth = 1.0f / _ratio; - _tessTol = 0.25f / _ratio; - _distTol = 0.01f / _ratio; - } - float getDeviceRatio() { return _ratio; } - - // draw command - void moveTo(float x, float y); - void lineTo(float x, float y); - void bezierCurveTo(float c1x, float c1y, float c2x, float c2y, float x, float y); - void quadraticCurveTo(float cx, float cy, float x, float y); - void arcTo(float x1, float y1, float x2, float y2, float radius); - - void arc(float cx, float cy, float r, float startAngle, float endAngle, bool counterclockwise); - void rect(float x, float y, float w, float h); - void roundRect(float x, float y, float w, float h, float r); - void ellipse(float cx, float cy, float rx, float ry); - void circle(float cx, float cy, float r); - - void fillRect(float x, float y, float w, float h); - - void close(); - - void beginPath(); - - void stroke(); - void fill(); - - void clear(bool clean=false); -public: - - void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags); - void onDraw(const cocos2d::Mat4 &transform, uint32_t flags); - -public: - - GraphicsNode(); - virtual ~GraphicsNode(); - -protected: - - static int mini(int a, int b) { return a < b ? a : b; } - static int maxi(int a, int b) { return a > b ? a : b; } - static int clampi(int a, int mn, int mx) { return a < mn ? mn : (a > mx ? mx : a); } - static float minf(float a, float b) { return a < b ? a : b; } - static float maxf(float a, float b) { return a > b ? a : b; } - static float absf(float a) { return a >= 0.0f ? a : -a; } - static float signf(float a) { return a >= 0.0f ? 1.0f : -1.0f; } - static float clampf(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); } - static float cross(float dx0, float dy0, float dx1, float dy1) { return dx1*dy0 - dx0*dy1; } - - static int ptEquals(float x1, float y1, float x2, float y2, float tol); - static float distPtSeg(float x, float y, float px, float py, float qx, float qy); - - static float normalize(float *x, float* y); - static int curveDivs(float r, float arc, float tol); - - static void chooseBevel(int bevel, VecPoint* p0, VecPoint* p1, float w, - float* x0, float* y0, float* x1, float* y1); - -protected: - void tesselateBezier(float x1, float y1, float x2, float y2, - float x3, float y3, float x4, float y4, - int level, int type); - - void addPoint(Path* path, float x, float y, int flags); - Path* addPath(); - - void flattenPaths(); - - void expandStroke(float w, int lineCap, int lineJoin, float miterLimit); - void expandFill(float w, int lineJoin, float miterLimit); - - void calculateJoins(float w, int lineJoin, float miterLimit); - - void allocBuffer(); - - void vset(float x, float y, float u, float v); - - void pushCommand(cocos2d::Color4F& color, float strokeMult, int vertsOffset, int nVerts, int indicesOffset, int nIndices); - - void buttCapStart(VecPoint* p, float dx, float dy, float w, float d, float aa); - void buttCapEnd(VecPoint* p, float dx, float dy, float w, float d, float aa); - void roundCapStart(VecPoint* p, float dx, float dy, float w, int ncap, float aa); - void roundCapEnd(VecPoint* p, float dx, float dy, float w, int ncap, float aa); - - void roundJoin(VecPoint* p0, VecPoint* p1, float lw, float rw, float lu, float ru, int ncap, float fringe); - void bevelJoin(VecPoint* p0, VecPoint* p1, float lw, float rw, float lu, float ru, float fringe); -protected: - - cocos2d::CustomCommand _customCommand; - - bool _needUpdatePathOffset; - - - float _ratio; - - float _lineWidth; - float _miterLimit; - LineCap _lineCap; - LineJoin _lineJoin; - cocos2d::Color4F _strokeColor; - cocos2d::Color4F _fillColor; - - float _fringeWidth; - - float _tessTol; - float _distTol; - - float _commandx; - float _commandy; - - // points - int _nPoints; - VecPointVector _points; - - // commands - int _nCommands; - CommandVector _commands; - - - // path - int _nPath; - int _pathOffset; - std::vector _paths; - - // buffer - std::vector _buffers; - GraphicsBuffer* _buffer; - - Path* _curPath; -}; - -} - -#endif /* defined(__CREATOR_CCGRAPHICSNODE_H__) */ diff --git a/native/cocos/editor-support/creator/CCGraphicsNode.vert b/native/cocos/editor-support/creator/CCGraphicsNode.vert deleted file mode 100755 index 2d66ab4465..0000000000 --- a/native/cocos/editor-support/creator/CCGraphicsNode.vert +++ /dev/null @@ -1,18 +0,0 @@ - -const char* ccGraphicsVert = STRINGIFY( -attribute vec4 a_position; -attribute vec2 a_texCoord; - -\n#ifdef GL_ES\n -varying mediump vec2 v_texCoord; -\n#else\n -varying vec2 v_texCoord; -\n#endif\n - -void main() -{ - gl_Position = CC_MVPMatrix * a_position; - v_texCoord = a_texCoord; -} - -); diff --git a/native/cocos/editor-support/creator/CCScale9Sprite.cpp b/native/cocos/editor-support/creator/CCScale9Sprite.cpp deleted file mode 100755 index 1567c52aeb..0000000000 --- a/native/cocos/editor-support/creator/CCScale9Sprite.cpp +++ /dev/null @@ -1,1172 +0,0 @@ -/**************************************************************************** - Copyright (c) 2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - - ****************************************************************************/ - -#include "CCScale9Sprite.h" -#include "renderer/CCTextureCache.h" -#include "base/CCDirector.h" -#include "2d/CCSpriteFrameCache.h" -#include "renderer/CCRenderer.h" -#include "renderer/CCGLProgramCache.h" -#include "renderer/ccShaders.h" - -namespace creator { - using namespace cocos2d; - -class simpleQuadGenerator -{ -public: - std::vector _rebuildQuads_base(cocos2d::SpriteFrame* spriteFrame, const cocos2d::Size& contentSize, const cocos2d::Color4B& colorOpacity, bool isTrimmedContentSize) { - std::vector quads; - //build vertices - auto vertices = this->_calculateVertices(spriteFrame, contentSize, isTrimmedContentSize); - - //build uvs - auto uvs = this->_calculateUVs(spriteFrame); - - //build quads - quads.resize(1); - auto& quad = quads[0]; - - quad.bl.colors = colorOpacity; - quad.br.colors = colorOpacity; - quad.tl.colors = colorOpacity; - quad.tr.colors = colorOpacity; - - quad.bl.vertices = cocos2d::Vec3(vertices[0].x, vertices[0].y, 0); - quad.br.vertices = cocos2d::Vec3(vertices[1].x, vertices[0].y, 0); - quad.tl.vertices = cocos2d::Vec3(vertices[0].x, vertices[1].y, 0); - quad.tr.vertices = cocos2d::Vec3(vertices[1].x, vertices[1].y, 0); - - if (!spriteFrame->isRotated()) { - quad.bl.texCoords = cocos2d::Tex2F(uvs[0].x, uvs[0].y); - quad.br.texCoords = cocos2d::Tex2F(uvs[1].x, uvs[0].y); - quad.tl.texCoords = cocos2d::Tex2F(uvs[0].x, uvs[1].y); - quad.tr.texCoords = cocos2d::Tex2F(uvs[1].x, uvs[1].y); - } else { - quad.bl.texCoords = cocos2d::Tex2F(uvs[0].x, uvs[1].y); - quad.br.texCoords = cocos2d::Tex2F(uvs[0].x, uvs[0].y); - quad.tl.texCoords = cocos2d::Tex2F(uvs[1].x, uvs[1].y); - quad.tr.texCoords = cocos2d::Tex2F(uvs[1].x, uvs[0].y); - } - - return quads; - } - - std::vector _calculateVertices(cocos2d::SpriteFrame* spriteFrame, const cocos2d::Size& contentSize, bool isTrimmedContentSize) { - float x0, x3; - float y0, y3; - if (isTrimmedContentSize) { - x0 = 0; - x3 = contentSize.width; - - y0 = 0; - y3 = contentSize.height; - } else { - auto originalSize = spriteFrame->getOriginalSize(); - auto rect = spriteFrame->getRect(); - auto offset = spriteFrame->getOffset(); - auto scaleX = contentSize.width / originalSize.width; - auto scaleY = contentSize.height / originalSize.height; - auto trimmLeft = offset.x + (originalSize.width - rect.size.width) / 2; - auto trimmRight = offset.x - (originalSize.width - rect.size.width) / 2; - auto trimmedBottom = offset.y + (originalSize.height - rect.size.height) / 2; - auto trimmedTop = offset.y - (originalSize.height - rect.size.height) / 2; - - x0 = trimmLeft * scaleX; - x3 = contentSize.width + trimmRight * scaleX; - y0 = trimmedBottom * scaleY; - y3 = contentSize.height + trimmedTop * scaleY; - } - - std::vector vertices(2); - vertices[0] = cocos2d::Vec2(x0,y0); - vertices[1] = cocos2d::Vec2(x3,y3); - - return vertices; - }; - - std::vector _calculateUVs(cocos2d::SpriteFrame* spriteFrame) { - auto atlasWidth = spriteFrame->getTexture()->getPixelsWide(); - auto atlasHeight = spriteFrame->getTexture()->getPixelsHigh(); - - auto textureRect = spriteFrame->getRectInPixels(); - - //uv computation should take spritesheet into account. - float u0, u3; - float v0, v3; - float texStrech = 0; -#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - texStrech = 0.5; -#endif - if (spriteFrame->isRotated()) { - u0 = (textureRect.origin.x + texStrech) / atlasWidth; - u3 = (textureRect.origin.x + textureRect.size.height - texStrech) / atlasWidth; - - v0 = (textureRect.origin.y + texStrech) / atlasHeight; - v3 = (textureRect.origin.y + textureRect.size.width - texStrech) / atlasHeight; - } - else { - u0 = (textureRect.origin.x + texStrech) / atlasWidth; - u3 = (textureRect.origin.x + textureRect.size.width - texStrech) / atlasWidth; - - v0 = (textureRect.origin.y + texStrech) / atlasHeight; - v3 = (textureRect.origin.y + textureRect.size.height - texStrech) / atlasHeight; - } - - std::vector uvCoordinates(2); - uvCoordinates[0] = cocos2d::Vec2(u0, v3); - uvCoordinates[1] = cocos2d::Vec2(u3, v0); - - return uvCoordinates; - } -}; - -class scale9QuadGenerator -{ -public: - std::vector _rebuildQuads_base(cocos2d::SpriteFrame* spriteFrame, const cocos2d::Size& contentSize, const cocos2d::Color4B& colorOpacity, float insetLeft, float insetRight, float insetTop, float insetBottom) { - std::vector quads(9); - //build vertices - auto vertices = this->_calculateVertices(spriteFrame, contentSize, insetLeft, insetRight, insetTop, insetBottom); - - //build uvs - auto uvs = this->_calculateUVs(spriteFrame, insetLeft, insetRight, insetTop, insetBottom); - - //build quads - int quadIndex(0); - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < 3; ++j) { - auto& quad = quads[quadIndex++]; - quad.bl.colors = colorOpacity; - quad.br.colors = colorOpacity; - quad.tl.colors = colorOpacity; - quad.tr.colors = colorOpacity; - - quad.bl.vertices = cocos2d::Vec3(vertices[i].x, vertices[j].y, 0); - quad.br.vertices = cocos2d::Vec3(vertices[i + 1].x, vertices[j].y, 0); - quad.tl.vertices = cocos2d::Vec3(vertices[i].x, vertices[j + 1].y, 0); - quad.tr.vertices = cocos2d::Vec3(vertices[i + 1].x, vertices[j + 1].y, 0); - - if (!spriteFrame->isRotated()) { - quad.bl.texCoords = cocos2d::Tex2F(uvs[i].x, uvs[j].y); - quad.br.texCoords = cocos2d::Tex2F(uvs[i + 1].x, uvs[j].y); - quad.tl.texCoords = cocos2d::Tex2F(uvs[i].x, uvs[j + 1].y); - quad.tr.texCoords = cocos2d::Tex2F(uvs[i + 1].x, uvs[j + 1].y); - } else { - quad.bl.texCoords = cocos2d::Tex2F(uvs[j].x, uvs[3 - i].y); - quad.br.texCoords = cocos2d::Tex2F(uvs[j].x, uvs[3 - (i + 1)].y); - quad.tl.texCoords = cocos2d::Tex2F(uvs[j + 1].x, uvs[3 - i].y); - quad.tr.texCoords = cocos2d::Tex2F(uvs[j + 1].x, uvs[3 - (i + 1)].y); - } - } - } - - return quads; - } - - std::vector _calculateVertices(cocos2d::SpriteFrame* spriteFrame, const cocos2d::Size& contentSize, float insetLeft, float insetRight, float insetTop, float insetBottom) { - float leftWidth, rightWidth; - float topHeight, bottomHeight; - - auto rect = spriteFrame->getRect(); - leftWidth = insetLeft; - rightWidth = insetRight; - - topHeight = insetTop; - bottomHeight = insetBottom; - - auto preferSize = contentSize; - auto sizableWidth = preferSize.width - leftWidth - rightWidth; - auto sizableHeight = preferSize.height - topHeight - bottomHeight; - auto xScale = preferSize.width / (leftWidth + rightWidth); - auto yScale = preferSize.height / (topHeight + bottomHeight); - xScale = xScale > 1 ? 1 : xScale; - yScale = yScale > 1 ? 1 : yScale; - sizableWidth = sizableWidth < 0 ? 0 : sizableWidth; - sizableHeight = sizableHeight < 0 ? 0 : sizableHeight; - float x0, x1, x2, x3; - float y0, y1, y2, y3; - x0 = 0; - x1 = leftWidth * xScale; - x2 = x1 + sizableWidth; - x3 = preferSize.width; - - y0 = 0; - y1 = bottomHeight * yScale; - y2 = y1 + sizableHeight; - y3 = preferSize.height; - - std::vector vertices(4); - vertices[0] = cocos2d::Vec2(x0,y0); - vertices[1] = cocos2d::Vec2(x1,y1); - vertices[2] = cocos2d::Vec2(x2,y2); - vertices[3] = cocos2d::Vec2(x3,y3); - - return vertices; - } - - std::vector _calculateUVs(cocos2d::SpriteFrame* spriteFrame, float insetLeft, float insetRight, float insetTop, float insetBottom) { - auto rect = spriteFrame->getRect(); - auto atlasWidth = spriteFrame->getTexture()->getPixelsWide(); - auto atlasHeight = spriteFrame->getTexture()->getPixelsHigh(); - - //caculate texture coordinate - float leftWidth, centerWidth, rightWidth; - float topHeight, centerHeight, bottomHeight; - leftWidth = insetLeft; - rightWidth = insetRight; - centerWidth = rect.size.width - leftWidth - rightWidth; - - topHeight = insetTop; - bottomHeight = insetBottom; - centerHeight = rect.size.height - topHeight - bottomHeight; - - auto textureRect = spriteFrame->getRectInPixels(); - - //uv computation should take spritesheet into account. - float u0, u1, u2, u3; - float v0, v1, v2, v3; - float texStrech = 0; -#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - texStrech = 0.5; -#endif - - if (spriteFrame->isRotated()) { - u0 = (textureRect.origin.x + texStrech) / atlasWidth; - u1 = (bottomHeight + textureRect.origin.x) / atlasWidth; - u2 = (bottomHeight + centerHeight + textureRect.origin.x) / atlasWidth; - u3 = (textureRect.origin.x + textureRect.size.height - texStrech) / atlasWidth; - - v0 = (textureRect.origin.y + texStrech) / atlasHeight; - v1 = (leftWidth + textureRect.origin.y) / atlasHeight; - v2 = (leftWidth + centerWidth + textureRect.origin.y) / atlasHeight; - v3 = (textureRect.origin.y + textureRect.size.width - texStrech) / atlasHeight; - } - else { - u0 = (textureRect.origin.x + texStrech) / atlasWidth; - u1 = (leftWidth + textureRect.origin.x) / atlasWidth; - u2 = (leftWidth + centerWidth + textureRect.origin.x) / atlasWidth; - u3 = (textureRect.origin.x + textureRect.size.width - texStrech) / atlasWidth; - - v0 = (textureRect.origin.y + texStrech) / atlasHeight; - v1 = (topHeight + textureRect.origin.y) / atlasHeight; - v2 = (topHeight + centerHeight + textureRect.origin.y) / atlasHeight; - v3 = (textureRect.origin.y + textureRect.size.height - texStrech) / atlasHeight; - } - - std::vector uvCoordinates(4); - uvCoordinates[0] = cocos2d::Vec2(u0, v3); - uvCoordinates[1] = cocos2d::Vec2(u1, v2); - uvCoordinates[2] = cocos2d::Vec2(u2, v1); - uvCoordinates[3] = cocos2d::Vec2(u3, v0); - - return uvCoordinates; - } -}; - -class tiledQuadGenerator -{ -public: - std::vector _rebuildQuads_base(cocos2d::SpriteFrame* spriteFrame, const cocos2d::Size& contentSize, const cocos2d::Color4B& colorOpacity) { - std::vector quads; - - //build uvs - auto uvs = this->_calculateUVs(spriteFrame); - auto u0 = uvs[0].x; - auto v0 = uvs[0].y; - auto u1 = uvs[1].x; - auto v1 = uvs[1].y; - auto rectWidth = spriteFrame->getRect().size.width; - auto rectHeight = spriteFrame->getRect().size.height; - //build quads - auto hRepeat = contentSize.width / rectWidth; - auto vRepeat = contentSize.height / rectHeight; - - int quadIndex = 0; - if(ceilf(hRepeat) * ceilf(vRepeat) > (65536 / 4)) { - CCLOGERROR("too many tiles, only 16384 tiles will be show"); - } - quads.resize(fminf(ceilf(hRepeat) * ceilf(vRepeat), 65536 / 4)); - for (int hindex = 0; hindex < ceilf(hRepeat); ++hindex) { - for (int vindex = 0; vindex < ceilf(vRepeat); ++vindex) { - auto& quad = quads[quadIndex++]; - - quad.bl.colors = colorOpacity; - quad.br.colors = colorOpacity; - quad.tl.colors = colorOpacity; - quad.tr.colors = colorOpacity; - - quad.bl.vertices = cocos2d::Vec3(rectWidth * hindex, rectHeight * vindex, 0); - quad.br.vertices = cocos2d::Vec3(rectWidth * fminf(hindex + 1, hRepeat), rectHeight * vindex, 0); - quad.tl.vertices = cocos2d::Vec3(rectWidth * hindex, rectHeight * fminf(vindex + 1, vRepeat), 0); - quad.tr.vertices = cocos2d::Vec3(rectWidth * fminf(hindex + 1, hRepeat), rectHeight * fminf(vindex + 1, vRepeat), 0); - - if (!spriteFrame->isRotated()) { - quad.bl.texCoords = cocos2d::Tex2F(u0, v0); - quad.br.texCoords = cocos2d::Tex2F(u0 + (u1 - u0) * fminf(1, hRepeat - hindex), v0); - quad.tl.texCoords = cocos2d::Tex2F(u0, v0 + (v1 - v0) * fminf(1, vRepeat - vindex)); - quad.tr.texCoords = cocos2d::Tex2F(u0 + (u1 - u0) * fminf(1, hRepeat - hindex), v0 + (v1 - v0) * fminf(1, vRepeat - vindex)); - } else { - quad.bl.texCoords = cocos2d::Tex2F(u0, v1); - quad.br.texCoords = cocos2d::Tex2F(u0, v1 + (v0 - v1) * fminf(1, hRepeat - hindex)); - quad.tl.texCoords = cocos2d::Tex2F(u0 + (u1 - u0) * fminf(1, vRepeat - vindex), v1); - quad.tr.texCoords = cocos2d::Tex2F(u0 + (u1 - u0) * fminf(1, vRepeat - vindex), v1 + (v0 - v1) * fminf(1, hRepeat - hindex)); - - } - if(quadIndex >= quads.size()) break; - } - } - return quads; - } - - std::vector _calculateUVs (cocos2d::SpriteFrame* spriteFrame) { - auto atlasWidth = spriteFrame->getTexture()->getPixelsWide(); - auto atlasHeight = spriteFrame->getTexture()->getPixelsHigh(); - - auto textureRect = spriteFrame->getRectInPixels(); - - //uv computation should take spritesheet into account. - float u0, u3; - float v0, v3; - - float texStrech = 0; -#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - texStrech = 0.5; -#endif - - if (spriteFrame->isRotated()) { - u0 = (textureRect.origin.x + texStrech) / atlasWidth; - u3 = (textureRect.origin.x + textureRect.size.height - texStrech) / atlasWidth; - - v0 = (textureRect.origin.y + texStrech) / atlasHeight; - v3 = (textureRect.origin.y + textureRect.size.width - texStrech) / atlasHeight; - } - else { - u0 = (textureRect.origin.x + texStrech)/ atlasWidth; - u3 = (textureRect.origin.x + textureRect.size.width - texStrech) / atlasWidth; - - v0 = (textureRect.origin.y + texStrech) / atlasHeight; - v3 = (textureRect.origin.y + textureRect.size.height - texStrech) / atlasHeight; - } - - std::vector uvCoordinates(2); - uvCoordinates[0] = cocos2d::Vec2(u0, v3); - uvCoordinates[1] = cocos2d::Vec2(u3, v0); - - return uvCoordinates; - } -}; - -class fillQuadGeneratorBar -{ -public: - //percentage from 0 to 1; - std::vector _rebuildQuads_base(cocos2d::SpriteFrame* spriteFrame, const cocos2d::Size& contentSize, const cocos2d::Color4B& colorOpacity, Scale9SpriteV2::FillType fillType, float fillStart, float fillRange) { - float fillEnd; - //build vertices - auto vertices = this->_calculateVertices(spriteFrame, contentSize); - - //build uvs - auto uvs = this->_calculateUVs(spriteFrame); - - //build quads - std::vector quads(1); - auto& quad = quads[0]; - - quad.bl.colors = colorOpacity; - quad.br.colors = colorOpacity; - quad.tl.colors = colorOpacity; - quad.tr.colors = colorOpacity; - - quad.bl.vertices.x = quad.tl.vertices.x = vertices[0].x; - quad.br.vertices.x = quad.tr.vertices.x = vertices[1].x; - - quad.bl.vertices.y = quad.br.vertices.y = vertices[0].y; - quad.tl.vertices.y = quad.tr.vertices.y = vertices[1].y; - - cocos2d::Tex2F quadUV[4]; - - if (!spriteFrame->isRotated()) { - quadUV[0] = cocos2d::Tex2F(uvs[0].x, uvs[0].y); - quadUV[1] = cocos2d::Tex2F(uvs[1].x, uvs[0].y); - quadUV[2] = cocos2d::Tex2F(uvs[0].x, uvs[1].y); - quadUV[3] = cocos2d::Tex2F(uvs[1].x, uvs[1].y); - } else { - quadUV[0] = cocos2d::Tex2F(uvs[0].x, uvs[1].y); - quadUV[1] = cocos2d::Tex2F(uvs[0].x, uvs[0].y); - quadUV[2]= cocos2d::Tex2F(uvs[1].x, uvs[1].y); - quadUV[3]= cocos2d::Tex2F(uvs[1].x, uvs[0].y); - } - - //do clamp - fillStart = fillStart > 1 ? 1 : fillStart; - fillStart = fillStart < 0 ? 0 : fillStart; - - fillRange = fillRange < 0 ? 0 : fillRange; - - fillEnd = fillStart + fillRange; - - fillEnd = fillEnd > 1 ? 1 : fillEnd; - - float progressStart, progressEnd; - switch (fillType) { - case Scale9SpriteV2::FillType::HORIZONTAL: - progressStart = vertices[0].x + (vertices[1].x - vertices[0].x) * fillStart; - progressEnd = vertices[0].x + (vertices[1].x - vertices[0].x) * fillEnd; - - quad.bl.vertices.x = progressStart; - quad.tl.vertices.x = progressStart; - - quad.br.vertices.x = progressEnd; - quad.tr.vertices.x = progressEnd; - - quad.bl.texCoords.u = quadUV[0].u + (quadUV[1].u - quadUV[0].u) * fillStart; - quad.bl.texCoords.v = quadUV[0].v + (quadUV[1].v - quadUV[0].v) * fillStart; - - quad.tl.texCoords.u = quadUV[2].u + (quadUV[3].u - quadUV[2].u) * fillStart; - quad.tl.texCoords.v = quadUV[2].v + (quadUV[3].v - quadUV[2].v) * fillStart; - - quad.br.texCoords.u = quadUV[0].u + (quadUV[1].u - quadUV[0].u) * fillEnd; - quad.br.texCoords.v = quadUV[0].v + (quadUV[1].v - quadUV[0].v) * fillEnd; - - quad.tr.texCoords.u = quadUV[2].u + (quadUV[3].u - quadUV[2].u) * fillEnd; - quad.tr.texCoords.v = quadUV[2].v + (quadUV[3].v - quadUV[2].v) * fillEnd; - break; - case Scale9SpriteV2::FillType::VERTICAL: - progressStart = vertices[0].y + (vertices[1].y - vertices[0].y) * fillStart; - progressEnd = vertices[0].y + (vertices[1].y - vertices[0].y) * fillEnd; - - quad.bl.vertices.y = progressStart; - quad.br.vertices.y = progressStart; - - quad.tl.vertices.y = progressEnd; - quad.tr.vertices.y = progressEnd; - - quad.bl.texCoords.u = quadUV[0].u + (quadUV[2].u - quadUV[0].u) * fillStart; - quad.bl.texCoords.v = quadUV[0].v + (quadUV[2].v - quadUV[0].v) * fillStart; - - quad.br.texCoords.u = quadUV[1].u + (quadUV[3].u - quadUV[1].u) * fillStart; - quad.br.texCoords.v = quadUV[1].v + (quadUV[3].v - quadUV[1].v) * fillStart; - - quad.tl.texCoords.u = quadUV[0].u + (quadUV[2].u - quadUV[0].u) * fillEnd; - quad.tl.texCoords.v = quadUV[0].v + (quadUV[2].v - quadUV[0].v) * fillEnd; - - quad.tr.texCoords.u = quadUV[1].u + (quadUV[3].u - quadUV[1].u) * fillEnd; - quad.tr.texCoords.v = quadUV[1].v + (quadUV[3].v - quadUV[1].v) * fillEnd; - break; - default: - cocos2d::log("Unrecognized fill type in bar fill"); - break; - } - - return quads; - } - - std::vector _calculateVertices (cocos2d::SpriteFrame* spriteFrame, const cocos2d::Size& contentSize) { - - float x0,x3; - float y0,y3; - x0 = 0; - x3 = contentSize.width; - - y0 = 0; - y3 = contentSize.height; - std::vector vertices(2); - vertices[0] = cocos2d::Vec2(x0,y0); - vertices[1] = cocos2d::Vec2(x3,y3); - return vertices; - } - - std::vector _calculateUVs(cocos2d::SpriteFrame* spriteFrame) { - auto atlasWidth = spriteFrame->getTexture()->getPixelsWide(); - auto atlasHeight = spriteFrame->getTexture()->getPixelsHigh(); - - auto textureRect = spriteFrame->getRectInPixels(); - - //uv computation should take spritesheet into account. - float u0, u3; - float v0, v3; - - float texStrech = 0; -#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - texStrech = 0.5; -#endif - - if (spriteFrame->isRotated()) { - u0 = (textureRect.origin.x + texStrech)/ atlasWidth; - u3 = (textureRect.origin.x + textureRect.size.height - texStrech) / atlasWidth; - - v0 = (textureRect.origin.y + texStrech) / atlasHeight; - v3 = (textureRect.origin.y + textureRect.size.width - texStrech) / atlasHeight; - } - else { - u0 = (textureRect.origin.x + texStrech) / atlasWidth; - u3 = (textureRect.origin.x + textureRect.size.width - texStrech) / atlasWidth; - - v0 = (textureRect.origin.y + texStrech) / atlasHeight; - v3 = (textureRect.origin.y + textureRect.size.height - texStrech) / atlasHeight; - } - std::vector uvs(2); - uvs[0] = cocos2d::Vec2(u0,v3); - uvs[1] = cocos2d::Vec2(u3,v0); - return uvs; - } -}; - -class fillQuadGeneratorRadial -{ -private: - cocos2d::Vec2 _vertPos[4]; - cocos2d::Vec2 _vertices[2]; - cocos2d::Vec2 _uvs[2]; - std::vector _intersectPoint_1; - std::vector _intersectPoint_2; -public: - fillQuadGeneratorRadial() { - _intersectPoint_1.resize(4); - _intersectPoint_2.resize(4); - - } - - std::vector _rebuildQuads_base(cocos2d::SpriteFrame* spriteFrame, const cocos2d::Size& contentSize, const cocos2d::Color4B& colorOpacity, const cocos2d::Vec2& fillCenter, float fillStart, float fillRange, cocos2d::V3F_C4B_T2F_Quad& rawQuad) { - - //do round fill start [0,1), include 0, exclude 1 - while (fillStart >= 1.0) fillStart -= 1.0; - while (fillStart < 0.0) fillStart += 1.0; - - auto center = cocos2d::Vec2(fillCenter); - - center.x *= contentSize.width; - center.y *= contentSize.height; - - fillStart *= M_PI * 2; - fillRange *= M_PI * 2; - float fillEnd = fillStart + fillRange; - - //build vertices - this->_calculateVertices(spriteFrame, contentSize); - //build uvs - this->_calculateUVs(spriteFrame); - - this->_vertPos[0].x = this->_vertPos[3].x = this->_vertices[0].x; - this->_vertPos[1].x = this->_vertPos[2].x = this->_vertices[1].x; - this->_vertPos[0].y = this->_vertPos[1].y = this->_vertices[0].y; - this->_vertPos[2].y = this->_vertPos[3].y = this->_vertices[1].y; - - //fallback - //todo remove it if outside is implemented - if(center.x > this->_vertices[1].x) { - center.x = this->_vertices[1].x; - } - if(center.x < this->_vertices[0].x) { - center.x = this->_vertices[0].x; - } - if(center.y < this->_vertices[0].y) { - center.y = this->_vertices[0].y; - } - if(center.y > this->_vertices[1].y) { - center.y = this->_vertices[1].y; - } - - rawQuad.bl.colors = colorOpacity; - rawQuad.br.colors = colorOpacity; - rawQuad.tl.colors = colorOpacity; - rawQuad.tr.colors = colorOpacity; - - rawQuad.bl.vertices.x = rawQuad.tl.vertices.x = this->_vertices[0].x; - rawQuad.br.vertices.x = rawQuad.tr.vertices.x = this->_vertices[1].x; - - rawQuad.bl.vertices.y = rawQuad.br.vertices.y = this->_vertices[0].y; - rawQuad.tl.vertices.y = rawQuad.tr.vertices.y = this->_vertices[1].y; - - - if (!spriteFrame->isRotated()) { - rawQuad.bl.texCoords.u = rawQuad.tl.texCoords.u = this->_uvs[0].x; - rawQuad.bl.texCoords.v = rawQuad.br.texCoords.v = this->_uvs[0].y; - rawQuad.br.texCoords.u = rawQuad.tr.texCoords.u = this->_uvs[1].x; - rawQuad.tl.texCoords.v = rawQuad.tr.texCoords.v = this->_uvs[1].y; - - } else { - rawQuad.bl.texCoords.u = rawQuad.br.texCoords.u = this->_uvs[0].x; - rawQuad.tl.texCoords.u = rawQuad.tr.texCoords.u = this->_uvs[1].x; - rawQuad.br.texCoords.v = rawQuad.tr.texCoords.v = this->_uvs[0].y; - rawQuad.bl.texCoords.v = rawQuad.tl.texCoords.v = this->_uvs[1].y; - - } - - int triangles[4][2] = {{-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}}; - - if(center.x != this->_vertices[0].x) { - triangles[0][0] = 3; - triangles[0][1] = 0; - } - if(center.x != this->_vertices[1].x) { - triangles[2][0] = 1; - triangles[2][1] = 2; - } - if(center.y != this->_vertices[0].y) { - triangles[1][0] = 0; - triangles[1][1] = 1; - } - if(center.y != this->_vertices[1].y) { - triangles[3][0] = 2; - triangles[3][1] = 3; - - } - - this->_getInsectedPoints(this->_vertices[0].x, this->_vertices[1].x, this->_vertices[0].y, this->_vertices[1].y, center, fillStart, this->_intersectPoint_1); - this->_getInsectedPoints(this->_vertices[0].x, this->_vertices[1].x, this->_vertices[0].y, this->_vertices[1].y, center, fillStart + fillRange, this->_intersectPoint_2); - - std::vector quads; - - for(int triangleIndex = 0; triangleIndex < 4; ++triangleIndex ) { - auto& triangle = triangles[triangleIndex]; - if(triangle[0] == -1 || triangle[1] == -1) { - continue; - } - //all in - if(fillRange >= M_PI * 2) { - quads.push_back(this->_generateTriangle(rawQuad, center, this->_vertPos[triangle[0]], this->_vertPos[triangle[1]],colorOpacity)); - continue; - } - //test against - auto startAngle = this->_getVertAngle(center,this->_vertPos[triangle[0]]); - auto endAngle = this->_getVertAngle(center,this->_vertPos[triangle[1]]); - if(endAngle < startAngle) endAngle += M_PI * 2; - startAngle -= M_PI * 2; - endAngle -= M_PI * 2; - //testing - for(int testIndex = 0; testIndex < 3; ++testIndex) { - if(startAngle >= fillEnd) { - //all out - } else if (startAngle >= fillStart) { - if(endAngle >= fillEnd) { - //startAngle to fillEnd - quads.push_back(this->_generateTriangle(rawQuad, center, this->_vertPos[triangle[0]], this->_intersectPoint_2[triangleIndex],colorOpacity)); - } else { - //startAngle to endAngle - quads.push_back(this->_generateTriangle(rawQuad, center, this->_vertPos[triangle[0]], this->_vertPos[triangle[1]],colorOpacity)); - } - } else { - //startAngle < fillStart - if(endAngle <= fillStart) { - //all out - } else if(endAngle <= fillEnd) { - //fillStart to endAngle - quads.push_back(this->_generateTriangle(rawQuad, center, this->_intersectPoint_1[triangleIndex], this->_vertPos[triangle[1]],colorOpacity)); - } else { - //fillStart to fillEnd - quads.push_back(this->_generateTriangle(rawQuad, center, this->_intersectPoint_1[triangleIndex], this->_intersectPoint_2[triangleIndex],colorOpacity)); - } - } - - //add 2 * PI - startAngle += M_PI * 2; - endAngle += M_PI * 2; - } - - } - - return quads; - } - - cocos2d::V3F_C4B_T2F_Quad _generateTriangle(const cocos2d::V3F_C4B_T2F_Quad& rawQuad, const cocos2d::Vec2& vert0, const cocos2d::Vec2& vert1, const cocos2d::Vec2& vert2 , const cocos2d::Color4B& colorOpacity) { - const auto& rawQuad_bl = rawQuad.bl; - const auto& rawQuad_br = rawQuad.br; - const auto& rawQuad_tl = rawQuad.tl; - const auto& rawQuad_tr = rawQuad.tr; - - auto v0x = rawQuad_bl.vertices.x; - auto v0y = rawQuad_bl.vertices.y; - auto v1x = rawQuad_tr.vertices.x; - auto v1y = rawQuad_tr.vertices.y; - float progressX, progressY; - cocos2d::V3F_C4B_T2F_Quad quad; - quad.tl.vertices.x = vert0.x; - quad.tl.vertices.y = vert0.y; - - quad.bl.vertices.x = vert1.x; - quad.bl.vertices.y = vert1.y; - - quad.tr.vertices.x = vert2.x; - quad.tr.vertices.y = vert2.y; - quad.tl.colors = colorOpacity; - quad.bl.colors = colorOpacity; - quad.tr.colors = colorOpacity; - - progressX = (vert0.x - v0x) / (v1x - v0x); - progressY = (vert0.y - v0y) / (v1y - v0y); - this->_generateUV(progressX, progressY, rawQuad_bl.texCoords,rawQuad_br.texCoords,rawQuad_tr.texCoords,rawQuad_tl.texCoords, quad.tl.texCoords); - - progressX = (vert1.x - v0x) / (v1x - v0x); - progressY = (vert1.y - v0y) / (v1y - v0y); - this->_generateUV(progressX, progressY, rawQuad_bl.texCoords,rawQuad_br.texCoords,rawQuad_tr.texCoords,rawQuad_tl.texCoords,quad.bl.texCoords); - - progressX = (vert2.x - v0x) / (v1x - v0x); - progressY = (vert2.y - v0y) / (v1y - v0y); - this->_generateUV(progressX, progressY, rawQuad_bl.texCoords,rawQuad_br.texCoords,rawQuad_tr.texCoords,rawQuad_tl.texCoords,quad.tr.texCoords); - - return quad; - } - - bool _isAngleIn (float angle, float start, float rangeAngle) { - auto pi_2 = M_PI * 2; - while(angle < start || angle >= start + pi_2) { - if(angle < start) { - angle += pi_2; - } - if(angle >= start + pi_2) { - angle -= pi_2; - } - } - - return angle <= start + rangeAngle; - } - - //[0,PI * 2) - float _getVertAngle(const cocos2d::Vec2& start, const cocos2d::Vec2& end) { - float placementX, placementY; - placementX = end.x - start.x; - placementY = end.y - start.y; - - if(placementX == 0 && placementY == 0) { - return FLT_MAX; - } else if(placementX == 0) { - if(placementY > 0) { - return M_PI * 0.5; - } else { - return M_PI * 1.5; - } - } else { - float angle = atanf(placementY / placementX); - if(placementX < 0) { - angle += M_PI; - } - - return angle; - } - } - - void _getInsectedPoints(float left, float right, float bottom, float top, const cocos2d::Vec2& center, float angle, std::vector &intersectPoints) { - //left bottom, right, top - auto sinAngle = sinf(angle); - auto cosAngle = cosf(angle); - float tanAngle,cotAngle; - if(cosf(angle) != 0) { - tanAngle = sinAngle / cosAngle; - //calculate right and left - if((left - center.x) * cosAngle > 0) { - auto yleft = center.y + tanAngle * (left - center.x); - intersectPoints[0].x = left; - intersectPoints[0].y = yleft; - } - if((right - center.x) * cosAngle > 0) { - auto yright = center.y + tanAngle * (right - center.x); - - intersectPoints[2].x = right; - intersectPoints[2].y = yright; - } - - } - - if(sinf(angle) != 0) { - cotAngle = cosAngle / sinAngle; - //calculate top and bottom - if((top - center.y) * sinAngle > 0) { - auto xtop = center.x + cotAngle * (top-center.y); - intersectPoints[3].x = xtop; - intersectPoints[3].y = top; - } - if((bottom - center.y) * sinAngle > 0) { - auto xbottom = center.x + cotAngle * (bottom-center.y); - intersectPoints[1].x = xbottom; - intersectPoints[1].y = bottom; - } - - } - } - - void _generateUV (float progressX, float progressY, const cocos2d::Tex2F& uvbl, const cocos2d::Tex2F& uvbr, const cocos2d::Tex2F& uvtr, const cocos2d::Tex2F& uvtl, cocos2d::Tex2F& result) { - auto px1 = uvbl.u + (uvbr.u-uvbl.u) * progressX; - auto px2 = uvtl.u + (uvtr.u-uvtl.u) * progressX; - auto py1 = uvbl.v + (uvbr.v-uvbl.v) * progressX; - auto py2 = uvtl.v + (uvtr.v-uvtl.v) * progressX; - result.u = px1 + (px2 - px1) * progressY; - result.v = py1 + (py2 - py1) * progressY; - } - - - void _calculateVertices(cocos2d::SpriteFrame* spriteFrame, const cocos2d::Size& contentSize) { - - float x0,x3; - float y0,y3; - x0 = 0; - x3 = contentSize.width; - - y0 = 0; - y3 = contentSize.height; - - this->_vertices[0].x = x0; - this->_vertices[0].y = y0; - this->_vertices[1].x = x3; - this->_vertices[1].y = y3; - } - - void _calculateUVs(cocos2d::SpriteFrame* spriteFrame) { - auto atlasWidth = spriteFrame->getTexture()->getPixelsWide(); - auto atlasHeight = spriteFrame->getTexture()->getPixelsHigh(); - - auto textureRect = spriteFrame->getRectInPixels(); - - //uv computation should take spritesheet into account. - float u0, u3; - float v0, v3; - - float texStrech = 0; -#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - texStrech = 0.5; -#endif - - if (spriteFrame->isRotated()) { - u0 = (textureRect.origin.x + texStrech) / atlasWidth; - u3 = (textureRect.origin.x + textureRect.size.height - texStrech) / atlasWidth; - - v0 = (textureRect.origin.y + texStrech) / atlasHeight; - v3 = (textureRect.origin.y + textureRect.size.width - texStrech) / atlasHeight; - } - else { - u0 = (textureRect.origin.x + texStrech) / atlasWidth; - u3 = (textureRect.origin.x + textureRect.size.width - texStrech) / atlasWidth; - - v0 = (textureRect.origin.y + texStrech) / atlasHeight; - v3 = (textureRect.origin.y + textureRect.size.height - texStrech) / atlasHeight; - } - - this->_uvs[0].x = u0; - this->_uvs[0].y = v3; - this->_uvs[1].x = u3; - this->_uvs[1].y = v0; - - } -}; - -static std::string distortionProgramKey = "cocos2d_creator_Scale9SpriteV2_distortionProgram"; - -//begin of Scale9 sprite implementation -Scale9SpriteV2::Scale9SpriteV2() : -_spriteFrame(nullptr), -_insetLeft(0), -_insetRight(0), -_insetTop(0), -_insetBottom(0), -_blendFunc(cocos2d::BlendFunc::ALPHA_NON_PREMULTIPLIED), -_renderingType(Scale9SpriteV2::RenderingType::SIMPLE), -_brightState(Scale9SpriteV2::State::NORMAL), -_quadsDirty(true), -_isTriangle(false), -_isTrimmedContentSize(true), -_fillType(Scale9SpriteV2::FillType::HORIZONTAL), -_fillCenter(cocos2d::Vec2::ZERO), -_distortionOffset(cocos2d::Vec2::ZERO), -_distortionTiling(cocos2d::Vec2::ONE), -_fillStart(0), -_fillRange(0), -_needRebuildRenderCommand(true), -_insideBounds(true) -{ - this->setAnchorPoint(Vec2::ANCHOR_MIDDLE); - this->setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); -} - -Scale9SpriteV2::~Scale9SpriteV2() { - CC_SAFE_RELEASE(this->_spriteFrame); -} - -bool Scale9SpriteV2::setTexture(const std::string &textureFile) -{ - auto texture = cocos2d::Director::getInstance()->getTextureCache()->addImage(textureFile); - return texture && this->setTexture(texture); -} -// -bool Scale9SpriteV2::setTexture(cocos2d::Texture2D* texture) -{ - auto spriteFrame = cocos2d::SpriteFrame::createWithTexture(texture, cocos2d::Rect(0,0,texture->getPixelsWide(),texture->getPixelsHigh())); - return spriteFrame && this->setSpriteFrame(spriteFrame); -} - -bool Scale9SpriteV2::setSpriteFrame(const std::string& sfName) -{ - auto spriteFrame = cocos2d::SpriteFrameCache::getInstance()->getSpriteFrameByName(sfName); - return spriteFrame && this->setSpriteFrame(spriteFrame); -} - -bool Scale9SpriteV2::setSpriteFrame(cocos2d::SpriteFrame* spriteFrame) -{ - if(!spriteFrame) return false; - CC_SAFE_RELEASE(this->_spriteFrame); - this->_spriteFrame = spriteFrame; - CC_SAFE_RETAIN(spriteFrame); - this->_quadsDirty = true; - if(this->_contentSize.equals(cocos2d::Size::ZERO)) - { - this->setContentSize(spriteFrame->getRect().size); - } - return true; -} - -void Scale9SpriteV2::setBlendFunc(const cocos2d::BlendFunc& blendFunc) { - this->setBlendFunc(blendFunc.src, blendFunc.dst); -} - -void Scale9SpriteV2::setBlendFunc(GLenum src, GLenum dst) { - this->_blendFunc.src = src; - this->_blendFunc.dst = dst; -} - -const cocos2d::BlendFunc& Scale9SpriteV2::getBlendFunc() const { - return this->_blendFunc; -} - -void Scale9SpriteV2::setContentSize(const cocos2d::Size &contentSize) { - if(contentSize.equals(this->_contentSize)) return; - Node::setContentSize(contentSize); - this->_quadsDirty = true; -} - -void Scale9SpriteV2::enableTrimmedContentSize(bool isTrimmed) { - if (this->_isTrimmedContentSize != isTrimmed) { - this->_isTrimmedContentSize = isTrimmed; - this->_quadsDirty = true; - } -} - -void Scale9SpriteV2::setState(State state) { - this->_brightState = state; - - if(State::DISTORTION == state) { - auto glProgramState = GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_SPRITE_DISTORTION); - glProgramState->setUniformVec2("u_offset", this->_distortionOffset); - glProgramState->setUniformVec2("u_offset_tiling", this->_distortionTiling); - this->setGLProgramState(glProgramState); - } else if (State::GRAY == state) { - this->setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_GRAYSCALE)); - } else { - this->setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); - } - - - -} - -void Scale9SpriteV2::setRenderingType(RenderingType type) { - if(this->_renderingType == type) return; - this->_renderingType = type; - this->_quadsDirty = true; -} - -void Scale9SpriteV2::setInsetLeft(float value) { - this->_insetLeft = value; - this->_quadsDirty = true; -} - -void Scale9SpriteV2::setInsetTop(float value) { - this->_insetTop = value; - this->_quadsDirty = true; -} - -void Scale9SpriteV2::setInsetRight(float value) { - this->_insetRight = value; - this->_quadsDirty = true; -} - -void Scale9SpriteV2::setInsetBottom(float value) { - this->_insetBottom = value; - this->_quadsDirty = true; -} - -void Scale9SpriteV2::setFillType(FillType value) { - if(this->_fillType == value) return; - this->_fillType = value; - if(this->_renderingType == RenderingType::FILLED) this->_quadsDirty = true; -} - -void Scale9SpriteV2::setFillCenter(const cocos2d::Vec2& center) { - setFillCenter(center.x, center.y); -} - -void Scale9SpriteV2::setFillCenter(float x, float y) { - this->_fillCenter.x = x; - this->_fillCenter.y = y; - if(this->_renderingType == RenderingType::FILLED && this->_fillType == FillType::RADIAL) this->_quadsDirty = true; -} - -void Scale9SpriteV2::setFillStart(float value) { - this->_fillStart = value; - if(this->_renderingType == RenderingType::FILLED) this->_quadsDirty = true; -} - -void Scale9SpriteV2::setFillRange(float value) { - this->_fillRange = value; - if(this->_renderingType == RenderingType::FILLED) this->_quadsDirty = true; -} - -void Scale9SpriteV2::_rebuildQuads() -{ - if (this->_quadsDirty == false) return; - cocos2d::Color4B color(this->getDisplayedColor()); - color.a = this->getDisplayedOpacity(); - this->_isTriangle = false; - if (this->_renderingType == RenderingType::SIMPLE) { - this->_quads = simpleQuadGenerator()._rebuildQuads_base(this->_spriteFrame, this->getContentSize(), color, this->_isTrimmedContentSize); - } else if (this->_renderingType == RenderingType::SLICED) { - this->_quads = scale9QuadGenerator()._rebuildQuads_base(this->_spriteFrame, this->getContentSize(), color, this->_insetLeft, this->_insetRight, this->_insetTop, this->_insetBottom); - } else if (this->_renderingType == RenderingType::TILED) { - this->_quads = tiledQuadGenerator()._rebuildQuads_base(this->_spriteFrame, this->getContentSize(), color); - } else if (this->_renderingType == RenderingType::FILLED) { - auto fillstart = this->_fillStart; - auto fillRange = this->_fillRange; - if(fillRange < 0) { - fillstart += fillRange; - fillRange = -fillRange; - } - if(this->_fillType != FillType::RADIAL) { - fillRange = fillstart + fillRange; - fillstart = fillstart > 1.0 ? 1.0 : fillstart; - fillstart = fillstart < 0.0 ? 0.0 : fillstart; - - fillRange = fillRange > 1.0 ? 1.0 : fillRange; - fillRange = fillRange < 0.0 ? 0.0 : fillRange; - fillRange = fillRange - fillstart; - this->_quads = fillQuadGeneratorBar()._rebuildQuads_base(this->_spriteFrame, this->getContentSize(), color, this->_fillType, fillstart,fillRange); - } else { - this->_isTriangle = true; - this->_quads = fillQuadGeneratorRadial()._rebuildQuads_base(this->_spriteFrame, this->getContentSize(), color,this->_fillCenter,fillstart,fillRange, this->_rawQuad); - } - } else { - this->_quads.clear(); - cocos2d::log("Can not generate quad"); - } - this->_quadsDirty = false; -} - -void Scale9SpriteV2::updateColor() { - cocos2d::Color4B color(this->getDisplayedColor()); - color.a = this->getDisplayedOpacity(); - for (int index = 0; index < this->_quads.size(); ++index) { - this->_quads[index].bl.colors = color; - this->_quads[index].br.colors = color; - this->_quads[index].tl.colors = color; - this->_quads[index].tr.colors = color; - } - - this->_needRebuildRenderCommand = true; -} - -void Scale9SpriteV2::setDistortionOffset(const cocos2d::Vec2& v) { - this->_distortionOffset = v; - if(this->_brightState == Scale9SpriteV2::State::DISTORTION ) { - _glProgramState->setUniformVec2("u_offset", v); - } -} - -void Scale9SpriteV2::setDistortionTiling(const cocos2d::Vec2& v) { - this->_distortionTiling = v; - if(this->_brightState == Scale9SpriteV2::State::DISTORTION ) { - _glProgramState->setUniformVec2("u_offset_tiling", v); - } -} - -void Scale9SpriteV2::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) { - if (!this->_spriteFrame || !this->_spriteFrame->getTexture()) { - return; - } - - if (_director->isCullingEnabled()) { - // Don't calculate the culling if the transform was not updated - if (flags & FLAGS_TRANSFORM_DIRTY || flags & FLAGS_CULLING_DIRTY) { - _insideBounds = renderer->checkVisibility(transform, _contentSize); - } - } - else { - _insideBounds = true; - } - - if (_insideBounds) - { - if (this->_quadsDirty) { - //rebuild quads - this->_rebuildQuads(); - this->_needRebuildRenderCommand = true; - } - if (this->_needRebuildRenderCommand) { - //fill triangles - int vertsStep = this->_isTriangle ? 3 : 4; - int indicesStep = this->_isTriangle ? 3 : 6; - this->_verts.resize(_quads.size() * vertsStep); - this->_indices.resize(_quads.size() * indicesStep); - unsigned short indices[6]; - for (int index = 0; index < _quads.size(); ++index) { - memcpy(&this->_verts[vertsStep * index], &this->_quads[index], sizeof(cocos2d::V3F_C4B_T2F) * vertsStep); - if (this->_isTriangle) { - indices[0] = indicesStep * index; - indices[1] = indicesStep * index + 1; - indices[2] = indicesStep * index + 2; - - } - else { - indices[0] = vertsStep * index; - indices[1] = vertsStep * index + 1; - indices[2] = vertsStep * index + 2; - indices[3] = vertsStep * index + 3; - indices[4] = vertsStep * index + 2; - indices[5] = vertsStep * index + 1; - - } - - memcpy(&this->_indices[indicesStep * index], indices, sizeof(unsigned short) * indicesStep); - - } - - this->_needRebuildRenderCommand = false; - - } - - if (!_indices.empty() && !_verts.empty()) { - cocos2d::TrianglesCommand::Triangles triangles; - triangles.indices = &this->_indices[0]; - triangles.verts = &this->_verts[0]; - triangles.vertCount = (int)this->_verts.size(); - triangles.indexCount = (int)this->_indices.size(); - auto texture = this->_spriteFrame->getTexture(); - this->_renderCommand.init(_globalZOrder, texture->getName(), _glProgramState, _blendFunc, triangles, transform, 0); - renderer->addCommand(&this->_renderCommand); - } - } - - -} - -} diff --git a/native/cocos/editor-support/creator/CCScale9Sprite.h b/native/cocos/editor-support/creator/CCScale9Sprite.h deleted file mode 100755 index 4121e5f287..0000000000 --- a/native/cocos/editor-support/creator/CCScale9Sprite.h +++ /dev/null @@ -1,178 +0,0 @@ - -/**************************************************************************** - Copyright (c) 2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - - ****************************************************************************/ - - -#ifndef __CREATOR_CCSCALE9SPRITE_H__ -#define __CREATOR_CCSCALE9SPRITE_H__ - -#include "2d/CCNode.h" -#include "2d/CCSpriteFrame.h" -#include "renderer/CCTrianglesCommand.h" - -#include - -namespace creator { - -class CC_DLL Scale9SpriteV2 : public cocos2d::Node -{ -public: - enum class FillType - { - HORIZONTAL = 0, - VERTICAL = 1, - RADIAL = 2, - }; - - enum class RenderingType - { - SIMPLE = 0, - SLICED = 1, - TILED = 2, - FILLED = 3, - }; - - enum class State - { - NORMAL = 0, - GRAY = 1, - DISTORTION = 2, - }; - -public: - Scale9SpriteV2(); - virtual ~Scale9SpriteV2(); - - bool initWithTexture (cocos2d::Texture2D* texture) { - return this->setTexture(texture); - } - - bool initWithTexture (const std::string& textureFile) { - return this->setTexture(textureFile); - } - - bool initWithSpriteFrame (cocos2d::SpriteFrame* spriteFrame) { - return this->setSpriteFrame(spriteFrame); - } - - bool initWithSpriteFrame (const std::string& sfName) { - return this->setSpriteFrame(sfName); - } - - bool setTexture (const std::string& textureFile); - bool setTexture (cocos2d::Texture2D* texture); - bool setSpriteFrame(const std::string& sfName); - bool setSpriteFrame(cocos2d::SpriteFrame* spriteFrame); - - void setBlendFunc(const cocos2d::BlendFunc& blendFunc); - void setBlendFunc(GLenum src, GLenum dst); - const cocos2d::BlendFunc& getBlendFunc() const; - - virtual void setContentSize(const cocos2d::Size& contentSize) override; - - void enableTrimmedContentSize (bool isTrimmed); - bool isTrimmedContentSizeEnabled() const { return this->_isTrimmedContentSize; } - - void setState(State state); - State getState() const { return this->_brightState; } - - void setRenderingType(RenderingType type); - RenderingType getRenderingType() const { return this->_renderingType; } - - void setInsetLeft(float value); - void setInsetTop(float value); - void setInsetRight(float value); - void setInsetBottom(float value); - - float getInsetLeft() const { return this->_insetLeft; } - float getInsetTop() const { return this->_insetTop; } - float getInsetRight() const { return this->_insetRight; } - float getInsetBottom() const { return this->_insetBottom; } - - void setFillType(FillType value); - void setFillCenter(const cocos2d::Vec2& center); - void setFillCenter(float x, float y); - void setFillStart(float value); - void setFillRange(float value); - - FillType getFillType() const { return this->_fillType; } - const cocos2d::Vec2& getFillCenter() const { return this->_fillCenter; } - float getFillStart() const { return this->_fillStart; } - float getFillRange() const { return this->_fillRange; } - - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override; -public: - //for distortion sprite - void setDistortionOffset(const cocos2d::Vec2& v); - void setDistortionTiling(const cocos2d::Vec2& v); -protected: - virtual void updateColor() override; - -private: - void _rebuildQuads (); - //resource data - cocos2d::SpriteFrame* _spriteFrame; - - //scale 9 data - float _insetLeft; - float _insetRight; - float _insetTop; - float _insetBottom; - //blend function - cocos2d::BlendFunc _blendFunc; - //sliced or simple - RenderingType _renderingType; - //bright or not - State _brightState; - //rendering quads - std::vector _quads; - bool _quadsDirty; - cocos2d::V3F_C4B_T2F_Quad _rawQuad; - bool _isTriangle; - bool _isTrimmedContentSize; - //fill type - FillType _fillType; - //for fill radial - cocos2d::Vec2 _fillCenter; - //normalized filled start and range - float _fillStart; - float _fillRange; - //indicate that rendercommand need to be rebuild or not; - bool _needRebuildRenderCommand; - - std::vector _verts; - std::vector _indices; - cocos2d::TrianglesCommand _renderCommand; - - cocos2d::Vec2 _distortionOffset; - cocos2d::Vec2 _distortionTiling; - bool _insideBounds; - -}; - -} - -#endif diff --git a/native/cocos/editor-support/creator/Triangulate.cpp b/native/cocos/editor-support/creator/Triangulate.cpp deleted file mode 100644 index 43795cbe3b..0000000000 --- a/native/cocos/editor-support/creator/Triangulate.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include -#include -#include -#include - -#include "Triangulate.h" - -#define EPSILON 0.0000000001f - -float Triangulate::area(const VecVertex *contour, int offset, int n) { - float A=0.0f; - - for(int p=n-1,q=offset; q= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f)); -}; - -bool Triangulate::snip(const VecVertex *contour, int offset, int n, int u, int v, int w, int *V) -{ - int p; - float Ax, Ay, Bx, By, Cx, Cy, Px, Py; - - Ax = contour[V[u]].x; - Ay = contour[V[u]].y; - - Bx = contour[V[v]].x; - By = contour[V[v]].y; - - Cx = contour[V[w]].x; - Cy = contour[V[w]].y; - - if ( EPSILON > (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax))) ) { - return false; - } - - for (p = offset; p < n; p++) { - if ( (p == u) || (p == v) || (p == w) ) { - continue; - } - Px = contour[V[p]].x; - Py = contour[V[p]].y; - if ( insideTriangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py) ) { - return false; - } - } - - return true; -} - -bool Triangulate::process(const VecVertex *contour, int offset, int n, std::vector &result) -{ - /* allocate and initialize list of Vertices in polygon */ - - if ( n < 3 ) return false; - - int *V = new int[n]; - - /* we want a counter-clockwise polygon in V */ - - if ( 0.0f < area(contour, offset, n) ) - for (int v=0; v2; ) - { - /* if we loop, it is probably a non-simple polygon */ - if (0 >= (count--)) - { - //** Triangulate: ERROR - probable bad polygon! - delete []V; - return false; - } - - /* three consecutive vertices in current polygon, */ - int u = v ; if (nv <= u) u = 0; /* previous */ - v = u+1; if (nv <= v) v = 0; /* new v */ - int w = v+1; if (nv <= w) w = 0; /* next */ - - if ( snip(contour, offset, nv, u, v, w, V) ) - { - int a,b,c,s,t; - - /* true names of the vertices */ - a = V[u]; b = V[v]; c = V[w]; - - /* output Triangle */ - result.push_back( a ); - result.push_back( b ); - result.push_back( c ); - - m++; - - /* remove v from remaining polygon */ - for(s=v,t=v+1;t // Include STL vector class. -#include "CCGraphicsNode.h" - -using namespace creator; - -class Triangulate -{ - public: - - // triangulate a contour/polygon, places results in STL vector - // as series of triangles. - static bool process(const VecVertex *contour, int offset, int n, std::vector &result); - - // compute area of a contour/polygon - static float area(const VecVertex *contour, int offset, int n); - - // decide if point Px/Py is inside triangle defined by - // (Ax,Ay) (Bx,By) (Cx,Cy) - static bool insideTriangle(float Ax, float Ay, - float Bx, float By, - float Cx, float Cy, - float Px, float Py); - - - private: - static bool snip(const VecVertex *contour, int offset, int n, int u, int v, int w, int *V); - -}; - - -#endif \ No newline at end of file diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsAABBQueryCallback.cpp b/native/cocos/editor-support/creator/physics/CCPhysicsAABBQueryCallback.cpp deleted file mode 100644 index e72504da37..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsAABBQueryCallback.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsAABBQueryCallback.h" - -using namespace cocos2d; - -namespace creator { - -PhysicsAABBQueryCallback::PhysicsAABBQueryCallback() -: _isPoint(false) -{ -} - -void PhysicsAABBQueryCallback::init() -{ - _isPoint = false; - _fixtures.clear(); -} - -void PhysicsAABBQueryCallback::init(const b2Vec2& p) -{ - _isPoint = true; - _point = p; - _fixtures.clear(); -} - -PhysicsAABBQueryCallback::~PhysicsAABBQueryCallback() -{ -} - -bool PhysicsAABBQueryCallback::ReportFixture(b2Fixture* fixture) -{ - b2Body* body = fixture->GetBody(); - if (body->GetType() == b2_dynamicBody) { - if (_isPoint) { - if (fixture->TestPoint(_point)) { - _fixtures.push_back(fixture); - // We are done, terminate the query. - return false; - } - } - else { - _fixtures.push_back(fixture); - } - } - - // Continue the query. - return true; -} - -b2Fixture* PhysicsAABBQueryCallback::getFixture() const -{ - return _fixtures.size() > 0 ? _fixtures[0] : nullptr; -} - -const std::vector& PhysicsAABBQueryCallback::getFixtures() const -{ - return _fixtures; -} - -} diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsAABBQueryCallback.h b/native/cocos/editor-support/creator/physics/CCPhysicsAABBQueryCallback.h deleted file mode 100644 index 712ce8d525..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsAABBQueryCallback.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef CCPhysicsAABBQueryCallback_h -#define CCPhysicsAABBQueryCallback_h - -#include "Box2D/Box2D.h" -#include "cocos2d.h" - -namespace creator { - -class CC_DLL PhysicsAABBQueryCallback : public b2QueryCallback -{ -public: - PhysicsAABBQueryCallback(); - - void init(); - void init(const b2Vec2& p); - - ~PhysicsAABBQueryCallback(); - - virtual bool ReportFixture(b2Fixture* fixture); - - b2Fixture* getFixture() const; - const std::vector& getFixtures() const; - -protected: - b2Vec2 _point; - std::vector _fixtures; - bool _isPoint; -}; - -} - -#endif /* CCPhysicsAABBQueryCallback_h */ diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsContactImpulse.cpp b/native/cocos/editor-support/creator/physics/CCPhysicsContactImpulse.cpp deleted file mode 100644 index 45dff709bb..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsContactImpulse.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsContactImpulse.h" -#include "CCPhysicsDefine.h" - -namespace creator { - PhysicsContactImpulse::PhysicsContactImpulse() - { - } - PhysicsContactImpulse::~PhysicsContactImpulse() - { - } - - void PhysicsContactImpulse::init(const b2ContactImpulse* impulse) - { - _impulse = *impulse; - } - - int PhysicsContactImpulse::getCount() - { - return _impulse.count; - } - - float32 PhysicsContactImpulse::getNormalImpulse(int index) - { - return _impulse.normalImpulses[index] * CC_PTM_RATIO; - } - float32 PhysicsContactImpulse::getTangentImpulse(int index) - { - return _impulse.tangentImpulses[index]; - } -} - diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsContactImpulse.h b/native/cocos/editor-support/creator/physics/CCPhysicsContactImpulse.h deleted file mode 100644 index eb6c5b9675..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsContactImpulse.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef CCPhysicsContactImpulse_h -#define CCPhysicsContactImpulse_h - -#include "Box2D/Box2D.h" -#include "cocos2d.h" - -namespace creator { - class CC_DLL PhysicsContactImpulse - { - public: - PhysicsContactImpulse(); - ~PhysicsContactImpulse(); - - void init(const b2ContactImpulse* impulse); - - int getCount(); - float32 getNormalImpulse(int index); - float32 getTangentImpulse(int index); - - protected: - b2ContactImpulse _impulse; - }; -} - - -#endif /* CCPhysicsContactImpulse_h */ diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.cpp b/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.cpp deleted file mode 100644 index f655909639..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsContactListener.h" -#include "cocos2d.h" - -using namespace cocos2d; - -namespace creator { - -std::vector PhysicsContactListener::__allInstances; - -const std::vector& PhysicsContactListener::getAllInstances() -{ - return __allInstances; -} - -PhysicsContactListener::PhysicsContactListener() -{ - __allInstances.push_back(this); -} - -PhysicsContactListener::~PhysicsContactListener() -{ - auto iter = std::find(__allInstances.begin(), __allInstances.end(), this); - if (iter != __allInstances.end()) - { - __allInstances.erase(iter); - } -} - -void PhysicsContactListener::setBeginContact(const std::function& callback) -{ - _beginContact = callback; -} - -void PhysicsContactListener::setEndContact(const std::function& callback) -{ - _endContact = callback; -} - -void PhysicsContactListener::setPreSolve(const std::function& callback) -{ - _preSolve = callback; -} - -void PhysicsContactListener::setPostSolve(const std::function& callback) -{ - _postSolve = callback; -} - - -void PhysicsContactListener::BeginContact(b2Contact* contact) -{ - if (!_beginContact) return; - - b2Fixture* fixtureA = contact->GetFixtureA(); - b2Fixture* fixtureB = contact->GetFixtureB(); - - if (find(_contactFixtures.begin(), _contactFixtures.end(), fixtureA) != _contactFixtures.end() || - find(_contactFixtures.begin(), _contactFixtures.end(), fixtureB) != _contactFixtures.end()) - { - _contactMap[contact] = true; - _beginContact(contact); - } - -} - -void PhysicsContactListener::EndContact(b2Contact* contact) -{ - if (!_endContact) return; - - auto i = _contactMap.find(contact); - if (i != _contactMap.end()) - { - _endContact(contact); - _contactMap.erase(i); - } -} - -void PhysicsContactListener::PreSolve(b2Contact* contact, const b2Manifold* oldManifold) -{ - if (!_preSolve) return; - - if (_contactMap.find(contact) != _contactMap.end()) - { - _preSolve(contact); - } -} - -void PhysicsContactListener::PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) -{ - if (!_postSolve) return; - - if (_contactMap.find(contact) != _contactMap.end()) - { - _impulse.init(impulse); - _postSolve(contact, &_impulse); - } -} - -void PhysicsContactListener::registerContactFixture(b2Fixture* fixture) -{ - _contactFixtures.push_back(fixture); -} - -void PhysicsContactListener::unregisterContactFixture(b2Fixture* fixture) -{ - auto result = find(_contactFixtures.begin(), _contactFixtures.end(), fixture); - if (result != _contactFixtures.end()) - { - _contactFixtures.erase(result); - } -} - -} diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.h b/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.h deleted file mode 100644 index 9727100314..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsContactListener.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef PhysicsContactListener_H -#define PhysicsContactListener_H - -#include "Box2D/Box2D.h" -#include "cocos2d.h" -#include "CCPhysicsContactImpulse.h" - -#include -#include - - -namespace creator { - -class CC_DLL PhysicsContactListener : public b2ContactListener -{ -public: - - static const std::vector& getAllInstances(); - - PhysicsContactListener(); - virtual ~PhysicsContactListener(); - - void setBeginContact(const std::function& callback); - void setEndContact(const std::function& callback); - void setPreSolve(const std::function& callback); - void setPostSolve(const std::function& callback); - - - virtual void BeginContact(b2Contact* contact) override; - virtual void EndContact(b2Contact* contact) override; - virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) override; - virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) override; - - void registerContactFixture(b2Fixture* fixture); - void unregisterContactFixture(b2Fixture* fixture); - -protected: - std::function _beginContact; - std::function _endContact; - std::function _preSolve; - std::function _postSolve; - - std::vector _contactFixtures; - PhysicsContactImpulse _impulse; - - std::unordered_map _contactMap; - - static std::vector __allInstances; -}; - -} - -#endif diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsDebugDraw.cpp b/native/cocos/editor-support/creator/physics/CCPhysicsDebugDraw.cpp deleted file mode 100644 index de12ba0c5b..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsDebugDraw.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsDebugDraw.h" -#include "CCPhysicsDefine.h" - -#include "cocos2d.h" - -using namespace cocos2d; - -namespace creator { - -PhysicsDebugDraw::PhysicsDebugDraw() -{ - _drawer = GraphicsNode::create(); - _drawer->retain(); -} - -PhysicsDebugDraw::~PhysicsDebugDraw() -{ - _drawer->release(); -} - -creator::GraphicsNode* PhysicsDebugDraw::getDrawer() -{ - return _drawer; -} - -void PhysicsDebugDraw::ClearDraw() -{ - _drawer->clear(); -} - -void PhysicsDebugDraw::AddDrawerToNode(cocos2d::Node *node) -{ - _drawer->removeFromParent(); - node->addChild(_drawer); -} - -void PhysicsDebugDraw::DrawPolygon(const b2Vec2* old_vertices, int vertexCount, const b2Color& color) -{ - Color4F c(color.r, color.g, color.b, /*color.a*/0.5); - _drawer->setStrokeColor(c); - - for( int i=0;imoveTo(old_vertices[i].x * CC_PTM_RATIO, old_vertices[i].y * CC_PTM_RATIO); - else { - _drawer->lineTo(old_vertices[i].x * CC_PTM_RATIO, old_vertices[i].y * CC_PTM_RATIO); - } - } - _drawer->close(); - _drawer->stroke(); -} - -void PhysicsDebugDraw::DrawSolidPolygon(const b2Vec2* old_vertices, int vertexCount, const b2Color& color) -{ - Color4F c(color.r, color.g, color.b, /*color.a*/0.5); - _drawer->setFillColor(c); - - for( int i=0;imoveTo(old_vertices[i].x * CC_PTM_RATIO, old_vertices[i].y * CC_PTM_RATIO); - else { - _drawer->lineTo(old_vertices[i].x * CC_PTM_RATIO, old_vertices[i].y * CC_PTM_RATIO); - } - } - _drawer->close(); - _drawer->fill(); -} - -void PhysicsDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) -{ - Color4F c(color.r, color.g, color.b, /*color.a*/0.5); - _drawer->setStrokeColor(c); - - _drawer->circle(center.x * CC_PTM_RATIO, center.y * CC_PTM_RATIO, radius * CC_PTM_RATIO); - _drawer->stroke(); -} - -void PhysicsDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) -{ - Color4F c(color.r, color.g, color.b, /*color.a*/0.5); - _drawer->setFillColor(c); - - _drawer->circle(center.x * CC_PTM_RATIO, center.y * CC_PTM_RATIO, radius * CC_PTM_RATIO); - _drawer->fill(); -} - -void PhysicsDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) -{ - Color4F c(color.r, color.g, color.b, /*color.a*/0.5); - _drawer->setStrokeColor(c); - - _drawer->moveTo(p1.x * CC_PTM_RATIO, p1.y * CC_PTM_RATIO); - _drawer->lineTo(p2.x * CC_PTM_RATIO, p2.y * CC_PTM_RATIO); - _drawer->stroke(); -} - -void PhysicsDebugDraw::DrawTransform(const b2Transform& xf) -{ - // b2Vec2 p1 = xf.p, p2; - // const float32 k_axisScale = 0.4f; - // - // p2 = p1 + k_axisScale * xf.R.col1; - // DrawSegment(p1,p2,b2Color(1,0,0)); - // - // p2 = p1 + k_axisScale * xf.R.col2; - // DrawSegment(p1,p2,b2Color(0,1,0)); -} - -} diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsDebugDraw.h b/native/cocos/editor-support/creator/physics/CCPhysicsDebugDraw.h deleted file mode 100644 index 35ad7b21a5..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsDebugDraw.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef PhysicsDebugDraw_H -#define PhysicsDebugDraw_H - -#include "Box2D/Box2D.h" -#include "editor-support/creator/CCGraphicsNode.h" - -namespace creator { - -// This class implements debug drawing callbacks that are invoked -// inside b2World::Step. -class CC_DLL PhysicsDebugDraw : public b2Draw -{ -public: - PhysicsDebugDraw(); - ~PhysicsDebugDraw(); - - creator::GraphicsNode* getDrawer(); - - void ClearDraw(); - - void AddDrawerToNode(cocos2d::Node* node); - - void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); - - void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color); - - void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color); - - void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color); - - void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color); - - void DrawTransform(const b2Transform& xf); - -protected: - creator::GraphicsNode* _drawer; - -}; - -} - -#endif diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsDefine.h b/native/cocos/editor-support/creator/physics/CCPhysicsDefine.h deleted file mode 100644 index 678cb908ae..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsDefine.h +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef CCPhysicsDefine_h -#define CCPhysicsDefine_h - -#define CC_PTM_RATIO 32 - -#endif /* CCPhysicsDefine_h */ diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsManifoldWrapper.cpp b/native/cocos/editor-support/creator/physics/CCPhysicsManifoldWrapper.cpp deleted file mode 100644 index 5faba7df85..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsManifoldWrapper.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com - * - * iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - */ - - -#include "CCPhysicsManifoldWrapper.h" -#include "CCPhysicsDefine.h" - -namespace creator { - PhysicsManifoldWrapper::PhysicsManifoldWrapper() - { - } - PhysicsManifoldWrapper::~PhysicsManifoldWrapper() - { - } - - void PhysicsManifoldWrapper::init(b2Contact* contact) - { - _contact = contact; - _manifold = _contact->GetManifold(); - } - - int PhysicsManifoldWrapper::getCount() - { - return _manifold->pointCount; - } - int PhysicsManifoldWrapper::getType() - { - return _manifold->type; - } - - float32 PhysicsManifoldWrapper::getX(int index) - { - return _manifold->points[index].localPoint.x * CC_PTM_RATIO; - } - float32 PhysicsManifoldWrapper::getY(int index) - { - return _manifold->points[index].localPoint.y * CC_PTM_RATIO; - } - float32 PhysicsManifoldWrapper::getNormalImpulse(int index) - { - return _manifold->points[index].normalImpulse * CC_PTM_RATIO; - } - float32 PhysicsManifoldWrapper::getTangentImpulse(int index) - { - return _manifold->points[index].tangentImpulse; - } - float32 PhysicsManifoldWrapper::getLocalNormalX() - { - return _manifold->localNormal.x; - } - float32 PhysicsManifoldWrapper::getLocalNormalY() - { - return _manifold->localNormal.y; - } - float32 PhysicsManifoldWrapper::getLocalPointX() - { - return _manifold->localPoint.x * CC_PTM_RATIO; - } - float32 PhysicsManifoldWrapper::getLocalPointY() - { - return _manifold->localPoint.y * CC_PTM_RATIO; - } -} diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsManifoldWrapper.h b/native/cocos/editor-support/creator/physics/CCPhysicsManifoldWrapper.h deleted file mode 100644 index 9af78a9c1e..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsManifoldWrapper.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef CCPhysicsManifoldWrapper_h -#define CCPhysicsManifoldWrapper_h - -#include "Box2D/Box2D.h" -#include "cocos2d.h" - -namespace creator { - class CC_DLL PhysicsManifoldWrapper - { - public: - PhysicsManifoldWrapper(); - ~PhysicsManifoldWrapper(); - - void init(b2Contact* contact); - - int getCount(); - int getType(); - float32 getX(int index); - float32 getY(int index); - float32 getNormalImpulse(int index); - float32 getTangentImpulse(int index); - float32 getLocalNormalX(); - float32 getLocalNormalY(); - float32 getLocalPointX(); - float32 getLocalPointY(); - - protected: - b2Contact* _contact; - b2Manifold* _manifold; - }; -} - - -#endif /* CCPhysicsWorldManifoldWrapper_h */ diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsRayCastCallback.cpp b/native/cocos/editor-support/creator/physics/CCPhysicsRayCastCallback.cpp deleted file mode 100644 index 9db9c20ec8..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsRayCastCallback.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCPhysicsRayCastCallback.h" - -using namespace cocos2d; - -namespace creator { - -PhysicsRayCastCallback::PhysicsRayCastCallback() -{ -} - -PhysicsRayCastCallback::~PhysicsRayCastCallback() { -} - -void PhysicsRayCastCallback::init(int type) -{ - _rayCastType = type; - - _fixtures.clear(); - _normals.clear(); - _points.clear(); - _fractions.clear(); -} - -float32 PhysicsRayCastCallback::ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction) -{ - if (_rayCastType == 0) { - if (_fixtures.size() > 0) { - _fixtures[0] = fixture; - _normals[0] = normal; - _points[0] = point; - _fractions[0] = fraction; - } - else { - _fixtures.push_back(fixture); - _normals.push_back(normal); - _points.push_back(point); - _fractions.push_back(fraction); - } - - return fraction; - } - - _fixtures.push_back(fixture); - _normals.push_back(normal); - _points.push_back(point); - _fractions.push_back(fraction); - - if (_rayCastType == 1) { - return 0; - } - else { - return 1; - } - - return fraction; -} - -const std::vector& PhysicsRayCastCallback::getFixtures() const { - return _fixtures; -} - -const std::vector& PhysicsRayCastCallback::getPoints() const { - return _points; -} - -const std::vector& PhysicsRayCastCallback::getNormals() const { - return _normals; -} - -const std::vector& PhysicsRayCastCallback::getFractions() const { - return _fractions; -} - -int PhysicsRayCastCallback::getType() const { - return _rayCastType; -} - -} diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsRayCastCallback.h b/native/cocos/editor-support/creator/physics/CCPhysicsRayCastCallback.h deleted file mode 100644 index 0f85e74d55..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsRayCastCallback.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef CCPhysicsRayCastCallback_h -#define CCPhysicsRayCastCallback_h - -#include "Box2D/Box2D.h" -#include "cocos2d.h" - -namespace creator { - -class CC_DLL PhysicsRayCastCallback : public b2RayCastCallback -{ -public: - PhysicsRayCastCallback(); - ~PhysicsRayCastCallback(); - - void init(int type); - - virtual float32 ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction); - - const std::vector& getFixtures() const; - const std::vector& getPoints() const; - const std::vector& getNormals() const; - const std::vector& getFractions() const; - - int getType() const; - -protected: - int _rayCastType; - - std::vector _fixtures; - std::vector _points; - std::vector _normals; - std::vector _fractions; -}; - -} - -#endif /* CCPhysicsRayCastCallback_h */ diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsUtils.cpp b/native/cocos/editor-support/creator/physics/CCPhysicsUtils.cpp deleted file mode 100644 index 33ac89d3f2..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsUtils.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -// -// CCPhysicsUtils.cpp -// cocos2d_libs -// -// Created by youyou on 16/12/22. -// -// - -#include "CCPhysicsUtils.h" -#include "CCPhysicsDefine.h" - -using namespace cocos2d; - -namespace creator { - -static PhysicsWorldManifoldWrapper _worldManifoldWrapper; -static PhysicsManifoldWrapper _manifoldWrapper; - -PhysicsUtils::PhysicsUtils() -{ - -} - -PhysicsUtils::~PhysicsUtils() -{ - -} - -void PhysicsUtils::addB2Body(b2Body* body) -{ - _bodies.push_back(body); -} - -void PhysicsUtils::removeB2Body(b2Body *body) -{ - const auto iterator = std::find(_bodies.begin(), _bodies.end(), body); - if (iterator != _bodies.end()) - { - _bodies.erase(iterator); - } -} - -void PhysicsUtils::syncNode() -{ - for (auto begin = _bodies.begin(); begin != _bodies.end(); begin++) - { - b2Body* body = *begin; - Node* node = (Node*)body->GetUserData(); - - const b2Vec2& pos = body->GetPosition(); - - Vec2 position(pos.x*CC_PTM_RATIO, pos.y*CC_PTM_RATIO); - float angle = -CC_RADIANS_TO_DEGREES(body->GetAngle()); - - if (node->getParent() && node->getParent()->getParent()) { - node->setPosition( _convertToNodePosition(node->getParent(), position) ); - node->setRotation( _convertToNodeRotation(node->getParent(), angle) ); - } - else { - node->setPosition(position); - node->setRotation(angle); - } - } -} - -const PhysicsWorldManifoldWrapper* PhysicsUtils::getContactWorldManifoldWrapper(b2Contact* contact) -{ - _worldManifoldWrapper.init(contact); - contact->GetWorldManifold(_worldManifoldWrapper.getb2WorldManifold()); - return &_worldManifoldWrapper; -} - -const PhysicsManifoldWrapper* PhysicsUtils::getContactManifoldWrapper(b2Contact* contact) -{ - _manifoldWrapper.init(contact); - return &_manifoldWrapper; -} - -cocos2d::Vec2 PhysicsUtils::_convertToNodePosition(cocos2d::Node* node, cocos2d::Vec2& position) -{ - if (node->isIgnoreAnchorPointForPosition()) { - // see https://github.com/cocos-creator/engine/pull/391 - return node->convertToNodeSpace(position); - } - else { - return node->convertToNodeSpaceAR(position); - } -} - -float PhysicsUtils::_convertToNodeRotation(cocos2d::Node* node, float rotation) -{ - rotation -= node->getRotation(); - Node* parent = node->getParent(); - while(parent->getParent()){ - rotation -= parent->getRotation(); - parent = parent->getParent(); - } - return rotation; -} - -} diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsUtils.h b/native/cocos/editor-support/creator/physics/CCPhysicsUtils.h deleted file mode 100644 index 45f9ca36a2..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsUtils.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef PhysicsUtils_H -#define PhysicsUtils_H - -#include - -#include "Box2D/Box2D.h" -#include "cocos2d.h" - -#include "CCPhysicsWorldManifoldWrapper.h" -#include "CCPhysicsManifoldWrapper.h" - -namespace creator { - -// This class implements debug drawing callbacks that are invoked -// inside b2World::Step. -class CC_DLL PhysicsUtils -{ -public: - PhysicsUtils(); - ~PhysicsUtils(); - -public: - void addB2Body(b2Body* body); - void removeB2Body(b2Body* body); - - void syncNode(); -public: - static const PhysicsWorldManifoldWrapper* getContactWorldManifoldWrapper(b2Contact* contact); - static const PhysicsManifoldWrapper* getContactManifoldWrapper(b2Contact* contact); -protected: - cocos2d::Vec2 _convertToNodePosition(cocos2d::Node* node, cocos2d::Vec2& position); - float _convertToNodeRotation(cocos2d::Node* node, float rotation); - - std::vector _bodies; -}; - -} - -#endif diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsWorldManifoldWrapper.cpp b/native/cocos/editor-support/creator/physics/CCPhysicsWorldManifoldWrapper.cpp deleted file mode 100644 index 7d8b7fc6f1..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsWorldManifoldWrapper.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com - * - * iPhone port by Simon Oliver - http://www.simonoliver.com - http://www.handcircus.com - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - */ - - -#include "CCPhysicsWorldManifoldWrapper.h" -#include "CCPhysicsDefine.h" - -namespace creator { - PhysicsWorldManifoldWrapper::PhysicsWorldManifoldWrapper() - { - } - PhysicsWorldManifoldWrapper::~PhysicsWorldManifoldWrapper() - { - } - - void PhysicsWorldManifoldWrapper::init(b2Contact* contact) - { - _contact = contact; - } - b2WorldManifold* PhysicsWorldManifoldWrapper::getb2WorldManifold() - { - return &_manifold; - } - - int PhysicsWorldManifoldWrapper::getCount() - { - b2Manifold* m = _contact->GetManifold(); - return m->pointCount; - } - - float32 PhysicsWorldManifoldWrapper::getX(int index) - { - return _manifold.points[index].x * CC_PTM_RATIO; - } - float32 PhysicsWorldManifoldWrapper::getY(int index) - { - return _manifold.points[index].y * CC_PTM_RATIO; - } - float32 PhysicsWorldManifoldWrapper::getSeparation(int index) - { - return _manifold.separations[index] * CC_PTM_RATIO; - } - float32 PhysicsWorldManifoldWrapper::getNormalX() - { - return _manifold.normal.x; - } - float32 PhysicsWorldManifoldWrapper::getNormalY() - { - return _manifold.normal.y; - } -} diff --git a/native/cocos/editor-support/creator/physics/CCPhysicsWorldManifoldWrapper.h b/native/cocos/editor-support/creator/physics/CCPhysicsWorldManifoldWrapper.h deleted file mode 100644 index bc6902da49..0000000000 --- a/native/cocos/editor-support/creator/physics/CCPhysicsWorldManifoldWrapper.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef CCPhysicsWorldManifoldWrapper_h -#define CCPhysicsWorldManifoldWrapper_h - -#include "Box2D/Box2D.h" -#include "cocos2d.h" - -namespace creator { - class CC_DLL PhysicsWorldManifoldWrapper - { - public: - PhysicsWorldManifoldWrapper(); - ~PhysicsWorldManifoldWrapper(); - - void init(b2Contact* contact); - b2WorldManifold* getb2WorldManifold(); - - int getCount(); - float32 getX(int index); - float32 getY(int index); - float32 getSeparation(int index); - float32 getNormalX(); - float32 getNormalY(); - - protected: - b2WorldManifold _manifold; - b2Contact* _contact; - }; -} - - -#endif /* CCPhysicsWorldManifoldWrapper_h */ diff --git a/native/cocos/editor-support/dragonbones/DragonBonesHeaders.h b/native/cocos/editor-support/dragonbones/DragonBonesHeaders.h deleted file mode 100644 index 7fbbcf79b4..0000000000 --- a/native/cocos/editor-support/dragonbones/DragonBonesHeaders.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef DRAGONBONES_HEADERS_H -#define DRAGONBONES_HEADERS_H - -// core -#include "core/DragonBones.h" -#include "core/BaseObject.h" - -// geom -#include "geom/ColorTransform.h" -#include "geom/Matrix.h" -#include "geom/Point.h" -#include "geom/Rectangle.h" -#include "geom/Transform.h" - -// textures -#include "textures/TextureData.h" - -// model -#include "model/FrameData.h" -#include "model/DragonBonesData.h" -#include "model/ArmatureData.h" -#include "model/AnimationData.h" -#include "model/TimelineData.h" - -// parsers -#include "parsers/DataParser.h" -#include "parsers/JSONDataParser.h" - -// factories -#include "factories/BaseFactory.h" - -// armature -#include "armature/IArmatureDisplay.h" -#include "armature/Armature.h" -#include "armature/TransformObject.h" -#include "armature/Bone.h" -#include "armature/Slot.h" - -// animation -#include "animation/IAnimateble.h" -#include "animation/WorldClock.h" -#include "animation/Animation.h" -#include "animation/AnimationState.h" -#include "animation/BaseTimelineState.h" -#include "animation/TimelineState.h" - -// events -#include "events/EventObject.h" - -#endif // DRAGONBONES_HEADERS_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/animation/Animation.cpp b/native/cocos/editor-support/dragonbones/animation/Animation.cpp deleted file mode 100644 index 23e49e9272..0000000000 --- a/native/cocos/editor-support/dragonbones/animation/Animation.cpp +++ /dev/null @@ -1,513 +0,0 @@ -#include "Animation.h" -#include "../armature/Armature.h" -#include "../armature/Slot.h" -#include "AnimationState.h" - -DRAGONBONES_NAMESPACE_BEGIN - -bool Animation::_sortAnimationState(AnimationState* a, AnimationState* b) -{ - return a->getLayer() > b->getLayer(); -} - -Animation::Animation() -{ - _onClear(); -} -Animation::~Animation() -{ - _onClear(); -} - -void Animation::_onClear() -{ - for (const auto animationState : _animationStates) - { - animationState->returnToPool(); - } - - timeScale = 1.f; - - _timelineStateDirty = false; - _animationStateDirty = false; - _armature = nullptr; - - _isPlaying = false; - _time = 0.f; - _lastAnimationState = nullptr; - - _animations.clear(); - _animationNames.clear(); - _animationStates.clear(); -} - -void Animation::_fadeOut(float fadeOutTime, int layer, const std::string& group, AnimationFadeOutMode fadeOutMode, bool pauseFadeOut) -{ - switch (fadeOutMode) - { - case AnimationFadeOutMode::SameLayer: - for (const auto animationState : _animationStates) - { - if (animationState->getLayer() == layer) - { - animationState->fadeOut(fadeOutTime, pauseFadeOut); - } - } - break; - - case AnimationFadeOutMode::SameGroup: - for (const auto animationState : _animationStates) - { - if (animationState->getGroup() == group) - { - animationState->fadeOut(fadeOutTime, pauseFadeOut); - } - } - break; - - case AnimationFadeOutMode::All: - for (const auto animationState : _animationStates) - { - if (fadeOutTime == 0.f) - { - animationState->returnToPool(); - } - else - { - animationState->fadeOut(fadeOutTime, pauseFadeOut); - } - } - - if (fadeOutTime == 0.f) - { - _animationStates.clear(); - } - break; - - case AnimationFadeOutMode::SameLayerAndGroup: - for (const auto animationState : _animationStates) - { - if (animationState->getLayer() == layer && animationState->getGroup() == group) - { - animationState->fadeOut(fadeOutTime, pauseFadeOut); - } - } - break; - - case AnimationFadeOutMode::None: - default: - break; - - } -} - -void Animation::_updateFFDTimelineStates() -{ - for (const auto animationState : _animationStates) - { - animationState->_updateFFDTimelineStates(); - } -} - -void Animation::_advanceTime(float passedTime) -{ - if (!_isPlaying) - { - return; - } - - if (passedTime < 0.f) - { - passedTime = -passedTime; - } - - const auto animationStateCount = _animationStates.size(); - if (animationStateCount == 1) - { - const auto animationState = _animationStates[0]; - if (animationState->_isFadeOutComplete) - { - animationState->returnToPool(); - _animationStates.clear(); - _animationStateDirty = true; - _lastAnimationState = nullptr; - } - else - { - if (_timelineStateDirty) - { - animationState->_updateTimelineStates(); - } - - animationState->_advanceTime(passedTime, 1.f, 0); - } - } - else if (animationStateCount > 1) - { - auto prevLayer = _animationStates[0]->_layer; - auto weightLeft = 1.f; - auto layerTotalWeight = 0.f; - unsigned animationIndex = 1; - - for (std::size_t i = 0, r = 0; i < animationStateCount; ++i) - { - const auto animationState = _animationStates[i]; - if (animationState->_isFadeOutComplete) - { - r++; - animationState->returnToPool(); - _animationStateDirty = true; - - if (_lastAnimationState == animationState) - { - if (i >= r) - { - _lastAnimationState = _animationStates[i - r]; - } - else - { - _lastAnimationState = nullptr; - } - } - } - else - { - if (r > 0) - { - _animationStates[i - r] = animationState; - } - - if (prevLayer != animationState->_layer) - { - prevLayer = animationState->_layer; - - if (layerTotalWeight >= weightLeft) - { - weightLeft = 0.f; - } - else - { - weightLeft -= layerTotalWeight; - } - - layerTotalWeight = 0.f; - } - - if (_timelineStateDirty) - { - animationState->_updateTimelineStates(); - } - - animationState->_advanceTime(passedTime, weightLeft, animationIndex); - - if (animationState->_weightResult != 0.f) - { - layerTotalWeight += animationState->_weightResult; - animationIndex++; - } - } - - if (i == animationStateCount - 1 && r > 0) - { - _animationStates.resize(animationStateCount - r); - } - } - } - - _timelineStateDirty = false; -} - -void Animation::reset() -{ - for (const auto animationState : _animationStates) - { - animationState->returnToPool(); - } - - _isPlaying = false; - _lastAnimationState = nullptr; - _animationStates.clear(); -} - -void Animation::stop(const std::string& animationName) -{ - if (!animationName.empty()) - { - const auto animationState = getState(animationName); - if (animationState) - { - animationState->stop(); - } - } - else - { - _isPlaying = false; - } -} - -AnimationState* Animation::play(const std::string& animationName, int playTimes) -{ - AnimationState* animationState = nullptr; - if (!animationName.empty()) - { - animationState = fadeIn(animationName, 0.f, playTimes, 0, "", AnimationFadeOutMode::All); - } - else if (!_lastAnimationState) - { - const auto defaultAnimation = _armature->getArmatureData().getDefaultAnimation(); - if (defaultAnimation) - { - animationState = fadeIn(_armature->getArmatureData().getDefaultAnimation()->name, 0.f, playTimes, 0, "", AnimationFadeOutMode::All); - } - } - else if (!_isPlaying || !_lastAnimationState->isPlaying()) - { - _isPlaying = true; - _lastAnimationState->play(); - } - else - { - animationState = fadeIn(_lastAnimationState->getName(), 0.f, playTimes, 0, "", AnimationFadeOutMode::All); - } - - return animationState; -} - -AnimationState* Animation::fadeIn( - const std::string& animationName, float fadeInTime, int playTimes, - int layer, const std::string& group, AnimationFadeOutMode fadeOutMode, - bool additiveBlending, bool displayControl, - bool pauseFadeOut, bool pauseFadeIn -) -{ - const auto animationData = mapFind(_animations, animationName); - if (!animationData) - { - _time = 0.f; - DRAGONBONES_ASSERT( - false, - "Non-existent animation." + - " DragonBones: " + this->_armature->getArmatureData().parent->name + - " Armature: " + this->_armature->name + - " Animation: " + animationName - ); - return nullptr; - } - - if (_time != _time) - { - _time = 0; - } - - _isPlaying = true; - - if (fadeInTime != fadeInTime || fadeInTime < 0.f) - { - if (_lastAnimationState) - { - fadeInTime = animationData->fadeInTime; - } - else - { - fadeInTime = 0.f; - } - } - - if (playTimes < 0) - { - playTimes = animationData->playTimes; - } - - _fadeOut(fadeInTime, layer, group, fadeOutMode, pauseFadeOut); - - _lastAnimationState = BaseObject::borrowObject(); - _lastAnimationState->_layer = layer; - _lastAnimationState->_group = group; - _lastAnimationState->additiveBlending = additiveBlending; - _lastAnimationState->displayControl = displayControl; - _lastAnimationState->_fadeIn( - _armature, animationData->animation ? animationData->animation : animationData, animationName, - playTimes, animationData->position, animationData->duration, _time, 1.f / animationData->scale, fadeInTime, - pauseFadeIn - ); - _animationStates.push_back(_lastAnimationState); - _animationStateDirty = true; - _time = 0.f; - _armature->_cacheFrameIndex = -1; - - if (_animationStates.size() > 1) - { - std::sort(_animationStates.begin(), _animationStates.end(), _sortAnimationState); - } - - for (const auto slot : _armature->getSlots()) - { - if (slot->inheritAnimation) - { - const auto childArmature = slot->getChildArmature(); - if ( - childArmature && - childArmature->getAnimation().hasAnimation(animationName) && - !childArmature->getAnimation().getState(animationName) - ) - { - childArmature->getAnimation().fadeIn(animationName); - } - } - } - - if (fadeInTime <= 0.f) - { - _armature->advanceTime(0.f); - } - - return _lastAnimationState; -} - -AnimationState* Animation::gotoAndPlayByTime(const std::string& animationName, float time, int playTimes) -{ - _time = time; - - return fadeIn(animationName, 0.f, playTimes, 0, "", AnimationFadeOutMode::All); -} - -AnimationState* Animation::gotoAndPlayByFrame(const std::string& animationName, unsigned frame, int playTimes) -{ - const auto clipData = _animations[animationName]; - if (clipData) - { - _time = clipData->duration * frame / clipData->frameCount; - } - - return fadeIn(animationName, 0.f, playTimes, 0, "", AnimationFadeOutMode::All); -} - -AnimationState* Animation::gotoAndPlayByProgress(const std::string& animationName, float progress, int playTimes) -{ - const auto clipData = _animations[animationName]; - if (clipData) - { - _time = clipData->duration * std::max(progress, 0.f); - } - - return fadeIn(animationName, 0.f, playTimes, 0, "", AnimationFadeOutMode::All); -} - -AnimationState* Animation::gotoAndStopByTime(const std::string& animationName, float time) -{ - const auto animationState = gotoAndPlayByTime(animationName, time, 1); - if (animationState) - { - animationState->stop(); - } - - return animationState; -} - -AnimationState* Animation::gotoAndStopByFrame(const std::string& animationName, unsigned frame) -{ - const auto animationState = gotoAndPlayByFrame(animationName, frame, 1); - if (animationState) - { - animationState->stop(); - } - - return animationState; -} - -AnimationState* Animation::gotoAndStopByProgress(const std::string& animationName, float progress) -{ - const auto animationState = gotoAndPlayByProgress(animationName, progress, 1); - if (animationState) - { - animationState->stop(); - } - - return animationState; -} - -AnimationState* Animation::getState(const std::string& animationName) const -{ - for (std::size_t i = 0, l = _animationStates.size(); i < l; ++i) - { - const auto animationState = _animationStates[i]; - if (animationState->getName() == animationName) - { - return animationState; - } - } - - return nullptr; -} - -bool Animation::hasAnimation(const std::string& animationName) const -{ - return _animations.find(animationName) != _animations.end(); -} - -bool Animation::isPlaying() const -{ - if (_animationStates.size() > 1) - { - return _isPlaying && !isCompleted(); - } - else if (_lastAnimationState) - { - return _isPlaying && _lastAnimationState->isPlaying(); - } - - return _isPlaying; -} - -bool Animation::isCompleted() const -{ - if (_lastAnimationState) - { - if (!_lastAnimationState->isCompleted()) - { - return false; - } - - for (const auto animationState : _animationStates) - { - if (!animationState->isCompleted()) - { - return false; - } - } - - return true; - } - - return false; -} - -std::string Animation::getLastAnimationName() const -{ - if (_lastAnimationState) - { - return _lastAnimationState->getName(); - } - - static const std::string DEFAULT_NAME = ""; - return DEFAULT_NAME; -} - -void Animation::setAnimations(const std::map& value) -{ - if (_animations == value) - { - return; - } - - _animations.clear(); - _animationNames.clear(); - - for (const auto& pair : value) - { - _animations[pair.first] = pair.second; - _animationNames.push_back(pair.first); - } -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/animation/Animation.h b/native/cocos/editor-support/dragonbones/animation/Animation.h deleted file mode 100644 index be3d59ea18..0000000000 --- a/native/cocos/editor-support/dragonbones/animation/Animation.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef DRAGONBONES_ANIMATION_H -#define DRAGONBONES_ANIMATION_H - -#include "../core/BaseObject.h" -#include "../model/AnimationData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -enum class AnimationFadeOutMode { - None = 0, - SameLayer = 1, - SameGroup = 2, - SameLayerAndGroup = 3, - All = 4 -}; - -class Armature; -class AnimationState; - -class Animation final : public BaseObject -{ - BIND_CLASS_TYPE(Animation); - -private: - static bool _sortAnimationState(AnimationState* a, AnimationState* b); - -public: - float timeScale; - -public: - /** @private */ - bool _animationStateDirty; - /** @private */ - bool _timelineStateDirty; - /** @private */ - Armature* _armature; - -private: - bool _isPlaying; - float _time; - AnimationState* _lastAnimationState; - std::map _animations; - std::vector _animationNames; - std::vector _animationStates; - -public: - Animation(); - ~Animation(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(Animation); - -protected: - void _onClear() override; - void _fadeOut(float fadeOutTime, int layer, const std::string& group, AnimationFadeOutMode fadeOutMode, bool pauseFadeOut); - -public: - /** @private */ - void _updateFFDTimelineStates(); - /** @private */ - void _advanceTime(float passedTime); - -public: - void reset(); - void stop(const std::string& animationName); - AnimationState* play(const std::string& animationName = "", int playTimes = -1); - AnimationState* fadeIn( - const std::string& animationName, float fadeInTime = -1.f, int playTimes = -1, - int layer = 0, const std::string& group = "", AnimationFadeOutMode fadeOutMode = AnimationFadeOutMode::SameLayerAndGroup, - bool additiveBlending = false, bool displayControl = true, - bool pauseFadeOut = true, bool pauseFadeIn = true - ); - AnimationState* gotoAndPlayByTime(const std::string& animationName, float time = 0.f, int playTimes = -1); - AnimationState* gotoAndPlayByFrame(const std::string& animationName, unsigned frame = 0, int playTimes = -1); - AnimationState* gotoAndPlayByProgress(const std::string& animationName, float progress = 0.f, int playTimes = -1); - AnimationState* gotoAndStopByTime(const std::string& animationName, float time = 0.f); - AnimationState* gotoAndStopByFrame(const std::string& animationName, unsigned frame = 0); - AnimationState* gotoAndStopByProgress(const std::string& animationName, float progress = 0.f); - AnimationState* getState(const std::string& animationName) const; - bool hasAnimation(const std::string& animationName) const; - bool isPlaying() const; - bool isCompleted() const; - std::string getLastAnimationName() const; - void setAnimations(const std::map& value); - - inline AnimationState* getLastAnimationState() const - { - return _lastAnimationState; - } - - inline const std::map& getAnimations() const - { - return _animations; - } - - inline const std::vector& getAnimationNames() const - { - return _animationNames; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_ANIMATION_H diff --git a/native/cocos/editor-support/dragonbones/animation/AnimationState.cpp b/native/cocos/editor-support/dragonbones/animation/AnimationState.cpp deleted file mode 100644 index b4bd19ee28..0000000000 --- a/native/cocos/editor-support/dragonbones/animation/AnimationState.cpp +++ /dev/null @@ -1,619 +0,0 @@ -#include "AnimationState.h" -#include "TimelineState.h" -#include "../armature/Armature.h" -#include "../armature/Bone.h" -#include "../armature/Slot.h" -#include "../animation/Animation.h" - -DRAGONBONES_NAMESPACE_BEGIN - -bool AnimationState::stateActionEnabled = true; - -AnimationState::AnimationState() : - _timeline(nullptr) -{ - _onClear(); -} -AnimationState::~AnimationState() -{ - _onClear(); -} - -void AnimationState::_onClear() -{ - for (const auto boneTimelineState : _boneTimelines) - { - boneTimelineState->returnToPool(); - } - - for (const auto slotTimelineState : _slotTimelines) - { - slotTimelineState->returnToPool(); - } - - for (const auto ffdTimelineState : _ffdTimelines) - { - ffdTimelineState->returnToPool(); - } - - displayControl = true; - additiveBlending = false; - actionEnabled = false; - playTimes = 1; - timeScale = 1.f; - weight = 1.f; - autoFadeOutTime = -1.f; - fadeTotalTime = 0.f; - - _isFadeOutComplete = false; - _layer = 0; - _position = 0.f; - _duration = 0.f; - _weightResult = 0.f; - _fadeProgress = 0.f; - _group.clear(); - - if (_timeline) - { - _timeline->returnToPool(); - _timeline = nullptr; - } - - _isPlaying = true; - _isPausePlayhead = false; - _isFadeOut = false; - _fadeTime = 0.f; - _time = 0.f; - _name.clear(); - _armature = nullptr; - _animationData = nullptr; - _boneMask.clear(); - _boneTimelines.clear(); - _slotTimelines.clear(); - _ffdTimelines.clear(); -} - -void AnimationState::_advanceFadeTime(float passedTime) -{ - if (passedTime < 0.f) - { - passedTime = -passedTime; - } - - _fadeTime += passedTime; - - auto fadeProgress = 0.f; - if (_fadeTime >= fadeTotalTime) - { - fadeProgress = _isFadeOut? 0.f : 1.f; - } - else if (_fadeTime > 0.f) - { - fadeProgress = _isFadeOut ? (1.f - _fadeTime / fadeTotalTime) : (_fadeTime / fadeTotalTime); - } - else - { - fadeProgress = _isFadeOut ? 1.f : 0.f; - } - - if (_fadeProgress != fadeProgress) - { - _fadeProgress = fadeProgress; - - const auto eventDispatcher = _armature->_display; - - if (_fadeTime <= passedTime) - { - if (_isFadeOut) - { - if (eventDispatcher->hasEvent(EventObject::FADE_OUT)) - { - auto event = BaseObject::borrowObject(); - event->animationState = this; - _armature->_bufferEvent(event, EventObject::FADE_OUT); - } - } - else - { - if (eventDispatcher->hasEvent(EventObject::FADE_IN)) - { - auto event = BaseObject::borrowObject(); - event->animationState = this; - _armature->_bufferEvent(event, EventObject::FADE_IN); - } - } - } - - if (_fadeTime >= fadeTotalTime) - { - if (_isFadeOut) - { - _isFadeOutComplete = true; - - if (eventDispatcher->hasEvent(EventObject::FADE_OUT_COMPLETE)) - { - auto event = BaseObject::borrowObject(); - event->animationState = this; - _armature->_bufferEvent(event, EventObject::FADE_OUT_COMPLETE); - } - } - else - { - _isPausePlayhead = false; - - if (eventDispatcher->hasEvent(EventObject::FADE_IN_COMPLETE)) - { - auto event = BaseObject::borrowObject(); - event->animationState = this; - _armature->_bufferEvent(event, EventObject::FADE_IN_COMPLETE); - } - } - } - } -} - -bool AnimationState::_isDisabled(const Slot& slot) const -{ - if ( - displayControl && - ( - slot.displayController.empty() || - slot.displayController == _name || - slot.displayController == _group - ) - ) - { - return false; - } - - return true; -} - -void AnimationState::_fadeIn( - Armature* armature, AnimationData* clip, const std::string& animationName, - unsigned playTimes, float position, float duration, float time, float timeScale, float fadeInTime, - bool pausePlayhead -) -{ - _armature = armature; - _animationData = clip; - _name = animationName; - - actionEnabled = AnimationState::stateActionEnabled; - this->playTimes = playTimes; - this->timeScale = timeScale; - fadeTotalTime = fadeInTime; - - _position = position; - _duration = duration; - _time = time; - _isPausePlayhead = pausePlayhead; - if (fadeTotalTime <= 0.f) - { - _fadeProgress = 0.999999f; - } - - _timeline = BaseObject::borrowObject(); - _timeline->fadeIn(_armature, this, _animationData, _time); - - _updateTimelineStates(); -} - -void AnimationState::_updateTimelineStates() -{ - auto time = _time; - if (!_animationData->hasAsynchronyTimeline) - { - time = _timeline->_currentTime; - } - - std::map boneTimelineStates; - std::map slotTimelineStates; - - // - for (const auto boneTimelineState : _boneTimelines) - { - boneTimelineStates[boneTimelineState->bone->name] = boneTimelineState; - } - - const auto& bones = _armature->getBones(); - for (const auto bone : bones) - { - const auto& boneTimelineName = bone->name; - const auto boneTimelineData = _animationData->getBoneTimeline(boneTimelineName); - - if (boneTimelineData && containsBoneMask(boneTimelineName)) - { - const auto iterator = boneTimelineStates.find(boneTimelineName); - if (iterator != boneTimelineStates.end()) - { - boneTimelineStates.erase(iterator); - } - else - { - const auto boneTimelineState = BaseObject::borrowObject(); - boneTimelineState->bone = bone; - boneTimelineState->fadeIn(_armature, this, boneTimelineData, time); - _boneTimelines.push_back(boneTimelineState); - } - } - } - - for (const auto& pair : boneTimelineStates) - { - const auto boneTimelineState = pair.second; - boneTimelineState->bone->invalidUpdate(); - _boneTimelines.erase(std::find(_boneTimelines.begin(), _boneTimelines.end(), boneTimelineState)); - boneTimelineState->returnToPool(); - } - - // - for (const auto slotTimelineState : _slotTimelines) - { - slotTimelineStates[slotTimelineState->slot->name] = slotTimelineState; - } - - for (const auto slot : _armature->getSlots()) - { - const auto& timelineName = slot->name; - const auto& parentTimelineName = slot->getParent()->name; - const auto slotTimelineData = _animationData->getSlotTimeline(timelineName); - - if (slotTimelineData && containsBoneMask(parentTimelineName) && !_isFadeOut) - { - const auto iterator = slotTimelineStates.find(timelineName); - if (iterator != slotTimelineStates.end()) - { - slotTimelineStates.erase(iterator); - } - else - { - const auto slotTimelineState = BaseObject::borrowObject(); - slotTimelineState->slot = slot; - slotTimelineState->fadeIn(_armature, this, slotTimelineData, time); - _slotTimelines.push_back(slotTimelineState); - } - } - } - - for (const auto& pair : slotTimelineStates) - { - const auto timelineState = pair.second; - _slotTimelines.erase(std::find(_slotTimelines.begin(), _slotTimelines.end(), timelineState)); - timelineState->returnToPool(); - } - - _updateFFDTimelineStates(); -} - -void AnimationState::_updateFFDTimelineStates() -{ - auto time = _time; - if (!_animationData->hasAsynchronyTimeline) - { - time = _timeline->_currentTime; - } - - std::map ffdTimelineStates; - - for (const auto ffdTimelineState : _ffdTimelines) - { - ffdTimelineStates[ffdTimelineState->slot->name] = ffdTimelineState; - } - - for (const auto slot : _armature->getSlots()) - { - const auto& timelineName = slot->name; - const auto& parentTimelineName = slot->getParent()->name; - - if (slot->_meshData) - { - const auto displayIndex = slot->getDisplayIndex(); - const auto rawMeshData = displayIndex < slot->_displayDataSet->displays.size() ? slot->_displayDataSet->displays[displayIndex]->mesh : nullptr; - - if (slot->_meshData == rawMeshData) - { - const auto ffdTimelineData = _animationData->getFFDTimeline(_armature->_skinData->name, timelineName, displayIndex); - if (ffdTimelineData && containsBoneMask(parentTimelineName)) // && !_isFadeOut - { - const auto iterator = ffdTimelineStates.find(timelineName); - if (iterator != ffdTimelineStates.end()) - { - ffdTimelineStates.erase(iterator); - } - else - { - const auto timelineState = BaseObject::borrowObject(); - timelineState->slot = slot; - timelineState->fadeIn(_armature, this, ffdTimelineData, time); - _ffdTimelines.push_back(timelineState); - } - } - else - { - const auto totalCount = slot->_ffdVertices.size(); - slot->_ffdVertices.clear(); - slot->_ffdVertices.resize(totalCount, 0.f); - slot->_ffdDirty = true; - } - } - } - } - - for (const auto& pair : ffdTimelineStates) - { - const auto ffdTimelineState = pair.second; - //ffdTimelineState->slot->_ffdDirty = true; - _ffdTimelines.erase(std::find(_ffdTimelines.begin(), _ffdTimelines.end(), ffdTimelineState)); - ffdTimelineState->returnToPool(); - } -} - -void AnimationState::_advanceTime(float passedTime, float weightLeft, int index) -{ - _advanceFadeTime(passedTime); - - passedTime *= timeScale; - - if (passedTime != 0.f && _isPlaying && !_isPausePlayhead) - { - _time += passedTime; - } - - _weightResult = weight * _fadeProgress * weightLeft; - - if (_weightResult != 0.f) - { - const auto isCacheEnabled = _fadeProgress >= 1.f && index == 0 && _armature->getCacheFrameRate() > 0; - const auto cacheTimeToFrameScale = _animationData->cacheTimeToFrameScale; - auto isUpdatesTimeline = true; - auto isUpdatesBoneTimeline = true; - auto time = cacheTimeToFrameScale * 2; - time = isCacheEnabled ? ((unsigned)(_time * time) / time) : _time; - _timeline->update(time); - if (!_animationData->hasAsynchronyTimeline) - { - time = _timeline->_currentTime; - } - - if (isCacheEnabled) - { - const auto cacheFrameIndex = (unsigned)(_timeline->_currentTime * cacheTimeToFrameScale); - if (_armature->_cacheFrameIndex == cacheFrameIndex) - { - isUpdatesTimeline = false; - isUpdatesBoneTimeline = false; - } - else - { - _armature->_cacheFrameIndex = cacheFrameIndex; - - if (_armature->_animation->_animationStateDirty) - { - _armature->_animation->_animationStateDirty = false; - - for (const auto boneTimelineState : _boneTimelines) - { - boneTimelineState->bone->_cacheFrames = &(boneTimelineState->_timeline->cachedFrames); - } - - for (const auto slotTimelineState : _slotTimelines) - { - slotTimelineState->slot->_cacheFrames = &(slotTimelineState->_timeline->cachedFrames); - } - } - - if (_animationData->cachedFrames[cacheFrameIndex]) - { - isUpdatesBoneTimeline = false; - } - else - { - _animationData->cachedFrames[cacheFrameIndex] = true; - } - } - } - else - { - _armature->_cacheFrameIndex = -1; - } - - if (isUpdatesTimeline) - { - if (isUpdatesBoneTimeline) - { - for (const auto boneTimelineState : _boneTimelines) - { - boneTimelineState->update(time); - } - } - - for (const auto slotTimelineState : _slotTimelines) - { - slotTimelineState->update(time); - } - - for (const auto ffdTimelineState : _ffdTimelines) - { - ffdTimelineState->update(time); - } - } - } - - if (autoFadeOutTime >= 0.f && _fadeProgress >= 1.f && _timeline->_isCompleted) - { - fadeOut(autoFadeOutTime); - } -} - -void AnimationState::play() -{ - _isPlaying = true; -} - -void AnimationState::stop() -{ - _isPlaying = false; -} - -void AnimationState::fadeOut(float fadeOutTime, bool pausePlayhead) -{ - if (fadeOutTime < 0.f || fadeOutTime != fadeOutTime) - { - fadeOutTime = 0.f; - } - - _isPausePlayhead = pausePlayhead; - - if (_isFadeOut) - { - if (fadeOutTime > fadeOutTime - _fadeTime) - { - return; - } - } - else - { - _isFadeOut = true; - - if (fadeOutTime <= 0.f || _fadeProgress <= 0.f) - { - _fadeProgress = 0.000001f; - } - - for (const auto boneTimelineState : _boneTimelines) - { - boneTimelineState->fadeOut(); - } - - for (const auto slotTimelineState : _slotTimelines) - { - slotTimelineState->fadeOut(); - } - } - - displayControl = false; - fadeTotalTime = _fadeProgress > 0.000001f ? fadeOutTime / _fadeProgress : 0.f; - _fadeTime = fadeTotalTime * (1.f - _fadeProgress); -} - -void AnimationState::addBoneMask(const std::string& name, bool recursive) -{ - const auto currentBone = _armature->getBone(name); - if (!currentBone) - { - return; - } - - if ( - std::find(_boneMask.cbegin(), _boneMask.cend(), name) == _boneMask.cend() && - _animationData->getBoneTimeline(name) - ) - { - _boneMask.push_back(name); - } - - if (recursive) - { - for (const auto bone : _armature->getBones()) - { - const auto& boneName = bone->name; - if ( - std::find(_boneMask.cbegin(), _boneMask.cend(), boneName) == _boneMask.cend() && - _animationData->getBoneTimeline(boneName) && - currentBone->contains(bone) - ) - { - _boneMask.push_back(boneName); - } - } - } - - _updateTimelineStates(); -} - -void AnimationState::removeBoneMask(const std::string& name, bool recursive) -{ - auto iterator = std::find(_boneMask.begin(), _boneMask.end(), name); - if (iterator != _boneMask.cend()) - { - _boneMask.erase(iterator); - } - - if (recursive) - { - const auto currentBone = _armature->getBone(name); - if (currentBone) - { - for (const auto bone : _armature->getBones()) - { - const auto boneName = bone->name; - auto iterator = std::find(_boneMask.begin(), _boneMask.end(), boneName); - if ( - iterator != _boneMask.cend() && - currentBone->contains(bone) - ) - { - _boneMask.erase(iterator); - } - } - } - } - - _updateTimelineStates(); -} - -void AnimationState::removeAllBoneMask() -{ - _boneMask.clear(); - _updateTimelineStates(); -} - -bool AnimationState::isCompleted() const -{ - return _timeline->_isCompleted; -} - -float AnimationState::getCurrentTime() const -{ - return _timeline->_currentTime; -} - -void AnimationState::setCurrentTime(float value) -{ - if (value < 0 || value != value) - { - value = 0; - } - - const auto currentPlayTimes = _timeline->_currentPlayTimes - (_timeline->_isCompleted ? 1 : 0); - value = std::fmod(value, _duration) + currentPlayTimes * _duration; - if (_time == value) { - return; - } - - _time = value; - _timeline->setCurrentTime(_time); - - for (const auto boneTimelineState : _boneTimelines) - { - boneTimelineState->_isCompleted = false; - } - - for (const auto slotTimelineState : _slotTimelines) - { - slotTimelineState->_isCompleted = false; - } - - for (const auto ffdTimelineState : _ffdTimelines) - { - ffdTimelineState->_isCompleted = false; - } -} - -unsigned AnimationState::getCurrentPlayTimes() const -{ - return _timeline->_currentPlayTimes; -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/animation/AnimationState.h b/native/cocos/editor-support/dragonbones/animation/AnimationState.h deleted file mode 100644 index 1d299d1c1b..0000000000 --- a/native/cocos/editor-support/dragonbones/animation/AnimationState.h +++ /dev/null @@ -1,143 +0,0 @@ -#ifndef DRAGONBONES_ANIMATION_STATE_H -#define DRAGONBONES_ANIMATION_STATE_H - -#include "../core/BaseObject.h" -#include "../model/AnimationData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class Armature; -class Bone; -class Slot; -class AnimationTimelineState; -class BoneTimelineState; -class SlotTimelineState; -class FFDTimelineState; - -class AnimationState final : public BaseObject -{ - BIND_CLASS_TYPE(AnimationState); - -public: - static bool stateActionEnabled; - -public: - bool displayControl; - bool additiveBlending; - bool actionEnabled; - unsigned playTimes; - float timeScale; - float weight; - float autoFadeOutTime; - float fadeTotalTime; - -public: - /** @private */ - bool _isFadeOutComplete; - /** @private */ - int _layer; - /** @private */ - float _position; - /** @private */ - float _duration; - /** @private */ - float _weightResult; - /** @private */ - float _fadeProgress; - /** @private */ - std::string _group; - /** @private */ - AnimationTimelineState* _timeline; - -private: - bool _isPlaying; - bool _isPausePlayhead; - bool _isFadeOut; - float _fadeTime; - float _time; - std::string _name; - Armature* _armature; - AnimationData* _animationData; - std::vector _boneMask; - std::vector _boneTimelines; - std::vector _slotTimelines; - std::vector _ffdTimelines; - -public: - AnimationState(); - ~AnimationState(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(AnimationState); - - void _advanceFadeTime(float passedTime); - -protected: - void _onClear() override; - -public: - /** @private */ - bool _isDisabled(const Slot& slot) const; - /** @private */ - void _fadeIn(Armature* armature, AnimationData* clip, const std::string& animationName, - unsigned playTimes, float position, float duration, float time, float timeScale, float fadeInTime, - bool pausePlayhead - ); - /** @private */ - void _updateTimelineStates(); - /** @private */ - void _updateFFDTimelineStates(); - /** @private */ - void _advanceTime(float passedTime, float weightLeft, int index); - -public: - void play(); - void stop(); - void fadeOut(float fadeOutTime, bool pausePlayhead = true); - void addBoneMask(const std::string& name, bool recursive = true); - void removeBoneMask(const std::string& name, bool recursive = true); - void removeAllBoneMask(); - - bool isCompleted() const; - float getCurrentTime() const; - void setCurrentTime(float value); - unsigned getCurrentPlayTimes() const; - - bool containsBoneMask(const std::string& name) - { - return _boneMask.empty() || std::find(_boneMask.cbegin(), _boneMask.cend(), name) != _boneMask.cend(); - } - - inline int getLayer() const - { - return _layer; - } - - inline std::string getName() const - { - return _name; - } - - inline const std::string& getGroup() const - { - return _group; - } - - inline const AnimationData& getAnimationData() const - { - return *_animationData; - } - - inline bool isPlaying() const - { - return (_isPlaying && !isCompleted()); - } - - inline float getTotalTime() const - { - return _duration; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_ANIMATION_STATE_H diff --git a/native/cocos/editor-support/dragonbones/animation/BaseTimelineState.h b/native/cocos/editor-support/dragonbones/animation/BaseTimelineState.h deleted file mode 100644 index 4f98f6f10a..0000000000 --- a/native/cocos/editor-support/dragonbones/animation/BaseTimelineState.h +++ /dev/null @@ -1,388 +0,0 @@ -#ifndef DRAGONBONES_BASE_TIMELINE_STATE_H -#define DRAGONBONES_BASE_TIMELINE_STATE_H - -#include "../core/BaseObject.h" -#include "../model/FrameData.h" -#include "../model/TimelineData.h" -#include "../model/AnimationData.h" -#include "../armature/Armature.h" -#include "../armature/Slot.h" -#include "AnimationState.h" - -DRAGONBONES_NAMESPACE_BEGIN - -/** @private */ -template -class TimelineState : public BaseObject -{ -public: - bool _isCompleted; - unsigned _currentPlayTimes; - float _currentTime; - M* _timeline; - -protected: - bool _isReverse; - bool _hasAsynchronyTimeline; - unsigned _frameRate; - unsigned _keyFrameCount; - unsigned _frameCount; - float _position; - float _duration; - float _animationiDutation; - float _timeScale; - float _timeOffset; - T* _currentFrame; - Armature* _armature; - AnimationState* _animationState; - -public: - TimelineState() {} - virtual ~TimelineState() {} - -protected: - virtual void _onClear() override - { - _isCompleted = false; - _currentPlayTimes = 0; - _currentTime = -1.f; - _timeline = nullptr; - - _isReverse = false; - _hasAsynchronyTimeline = false; - _keyFrameCount = 0; - _frameCount = 0; - _position = 0.f; - _duration = 0.f; - _animationiDutation = 0.f; - _timeScale = 1.f; - _timeOffset = 0.f; - _currentFrame = nullptr; - _armature = nullptr; - _animationState = nullptr; - } - - virtual void _onUpdateFrame(bool isUpdate) {} - virtual void _onArriveAtFrame(bool isUpdate) {} - - bool _setCurrentTime(float value) - { - unsigned currentPlayTimes = 0; - - if (_keyFrameCount == 1 && (void*)this != (void*)_animationState->_timeline) - { - _isCompleted = true; - currentPlayTimes = 1; - } - else if (_hasAsynchronyTimeline) - { - const auto playTimes = _animationState->playTimes; - const auto totalTimes = playTimes * _duration; - - value *= _timeScale; - if (_timeOffset != 0.f) - { - value += _timeOffset * _animationiDutation; - } - - if (playTimes > 0 && (value >= totalTimes || value <= -totalTimes)) - { - _isCompleted = true; - currentPlayTimes = playTimes; - - if (value < 0.f) - { - value = 0.f; - } - else - { - value = _duration; - } - } - else - { - _isCompleted = false; - - if (value < 0.f) - { - currentPlayTimes = (unsigned)(-value / _duration); - value = _duration - std::fmod(-value, _duration); - } - else - { - currentPlayTimes = (unsigned)(value / _duration); - value = std::fmod(value, _duration); - } - - if (playTimes > 0 && currentPlayTimes > playTimes) - { - currentPlayTimes = playTimes; - } - } - - value += _position; - } - else - { - //_isCompleted = _animationState->_timeline->_isCompleted; // TODO - //_currentPlayTimes = _animationState->_timeline->_currentPlayTimes; - } - - if (_currentTime == value) - { - return false; - } - - _isReverse = _currentTime > value && _currentPlayTimes == currentPlayTimes; - _currentTime = value; - _currentPlayTimes = currentPlayTimes; - - return true; - } - -public: - virtual void fadeIn(Armature* armature, AnimationState* animationState, M* timelineData, float time) - { - _armature = armature; - _animationState = animationState; - _timeline = timelineData; - - const auto isMainTimeline = (void*)this == (void*)_animationState->_timeline; - - _hasAsynchronyTimeline = isMainTimeline || _animationState->getAnimationData().hasAsynchronyTimeline; - _frameRate = _armature->getArmatureData().frameRate; - _keyFrameCount = _timeline->frames.size(); - _frameCount = _animationState->getAnimationData().frameCount; - _position = _animationState->_position; - _duration = _animationState->_duration; - _animationiDutation = _animationState->getAnimationData().duration; - _timeScale = isMainTimeline ? 1.f : (1.f / _timeline->scale); - _timeOffset = isMainTimeline ? 0.f : _timeline->offset; - } - - virtual void fadeOut() {} - - virtual void update(float time) - { - if (!_isCompleted && _setCurrentTime(time)) - { - const unsigned currentFrameIndex = _keyFrameCount > 1 ? unsigned(_currentTime * _frameRate) : 0; - const auto currentFrame = _timeline->frames[currentFrameIndex]; - - if (_currentFrame != currentFrame) - { - _currentFrame = currentFrame; - _onArriveAtFrame(true); - } - - _onUpdateFrame(true); - } - } -}; - -/** @private */ -template -class TweenTimelineState : public TimelineState -{ -public: // private - /** @private */ - static float _getEasingValue(float progress, float easing) - { - if (progress <= 0.f) { - return 0.f; - } - else if (progress >= 1.f) - { - return 1.f; - } - - auto value = 1.f; - if (easing > 2.f) - { - return progress; - } - else if (easing > 1.f) // Ease in out - { - value = 0.5f * (1.f - std::cos(progress * PI)); - easing -= 1.f; - } - else if (easing > 0.f) // Ease out - { - value = 1.f - std::pow(1.f - progress, 2); - } - else if (easing >= -1.f) // Ease in - { - easing *= -1.f; - value = std::pow(progress, 2); - } - else if (easing >= -2.f) // Ease out in - { - easing *= -1.f; - value = std::acos(1.f - progress * 2.f) / PI; - easing -= 1.f; - } - else - { - return progress; - } - - return (value - progress) * easing + progress; - } - - /** @private */ - static float _getCurveEasingValue(float progress, const std::vector& sampling) - { - if (progress <= 0.f) { - return 0.f; - } - else if (progress >= 1.f) - { - return 1.f; - } - - auto x = 0.f; - auto y = 0.f; - - for (std::size_t i = 0, l = sampling.size(); i < l; i += 2) - { - x = sampling[i]; - y = sampling[i + 1]; - if (x >= progress) - { - if (i == 0) - { - return y * progress / x; - } - else - { - const auto xP = sampling[i - 2]; - const auto yP = sampling[i - 1]; // i - 2 + 1 - return yP + (y - yP) * (progress - xP) / (x - xP); - } - } - } - - return y + (1.f - y) * (progress - x) / (1.f - x); - } - -protected: - enum class TweenType - { - None = 0, - Once = 1, - Always = 2 - }; - - float _tweenProgress; - float _tweenEasing; - std::vector* _curve; - -public: - TweenTimelineState() {} - virtual ~TweenTimelineState() {} - -protected: - virtual void _onClear() override - { - TimelineState::_onClear(); - - _tweenProgress = 0.f; - _tweenEasing = NO_TWEEN; - _curve = nullptr; - } - - virtual void _onArriveAtFrame(bool isUpdate) override - { - _tweenEasing = this->_currentFrame->tweenEasing; - _curve = this->_currentFrame->curve.empty() ? nullptr : &this->_currentFrame->curve; - - if ( - this->_keyFrameCount == 1 || - ( - this->_currentFrame->next == this->_timeline->frames[0] && - (_tweenEasing != NO_TWEEN || _curve) && - this->_animationState->playTimes > 0 && - this->_animationState->getCurrentPlayTimes() == this->_animationState->playTimes - 1 - ) - ) - { - _tweenEasing = NO_TWEEN; - _curve = nullptr; - } - } - - virtual void _onUpdateFrame(bool isUpdate) override - { - if (_tweenEasing != NO_TWEEN) - { - _tweenProgress = (float)(this->_currentTime - this->_currentFrame->position + this->_position) / this->_currentFrame->duration; - if (_tweenEasing != 0.f) - { - _tweenProgress = _getEasingValue(_tweenProgress, _tweenEasing); - } - } - else if (_curve) - { - _tweenProgress = (float)(this->_currentTime - this->_currentFrame->position + this->_position) / this->_currentFrame->duration; - _tweenProgress = _getCurveEasingValue(_tweenProgress, *_curve); - } - else - { - _tweenProgress = 0.f; - } - } - - TweenType _updateExtensionKeyFrame(const ExtensionFrameData& current, const ExtensionFrameData& next, ExtensionFrameData& result) - { - auto tweenType = TweenType::None; - if (current.type == next.type) - { - for (std::size_t i = 0, l = current.tweens.size(); i < l; ++i) - { - const auto tweenDuration = next.tweens[i] - current.tweens[i]; - result.tweens[i] = tweenDuration; - - if (tweenDuration > 0.f) - { - tweenType = TweenType::Always; - } - } - } - - if (tweenType == TweenType::None) - { - if (result.type != current.type) - { - tweenType = TweenType::Once; - result.type = current.type; - } - - if (result.tweens.size() != current.tweens.size()) - { - tweenType = TweenType::Once; - result.tweens.resize(current.tweens.size(), 0.f); - } - - if (result.keys.size() != current.keys.size()) - { - tweenType = TweenType::Once; - result.keys.resize(current.keys.size(), 0.f); - } - - for (std::size_t i = 0, l = current.keys.size(); i < l; ++i) - { - const auto key = current.keys[i]; - if (result.keys[i] != key) - { - tweenType = TweenType::Once; - result.keys[i] = key; - } - } - } - - return tweenType; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_BASE_TIMELINE_STATE_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/animation/IAnimateble.h b/native/cocos/editor-support/dragonbones/animation/IAnimateble.h deleted file mode 100644 index 70f7f92a52..0000000000 --- a/native/cocos/editor-support/dragonbones/animation/IAnimateble.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef DRAGONBONES_ANIMATEBLE_H -#define DRAGONBONES_ANIMATEBLE_H - -#include "../core/DragonBones.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class IAnimateble -{ -public: - IAnimateble() {} - virtual ~IAnimateble() {} - - virtual void advanceTime(float passedTime) = 0; -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_ANIMATEBLE_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/animation/TimelineState.cpp b/native/cocos/editor-support/dragonbones/animation/TimelineState.cpp deleted file mode 100644 index 2d8181ca1b..0000000000 --- a/native/cocos/editor-support/dragonbones/animation/TimelineState.cpp +++ /dev/null @@ -1,724 +0,0 @@ -#include "TimelineState.h" -#include "AnimationState.h" -#include "../armature/Armature.h" -#include "../armature/Bone.h" -#include "../armature/Slot.h" - -DRAGONBONES_NAMESPACE_BEGIN - -AnimationTimelineState::AnimationTimelineState() -{ - this->_onClear(); -} -AnimationTimelineState::~AnimationTimelineState() -{ - this->_onClear(); -} - -void AnimationTimelineState::_onClear() -{ - TimelineState::_onClear(); - - _isStarted = false; -} - -void AnimationTimelineState::_onCrossFrame(AnimationFrameData* frame) -{ - if (this->_animationState->actionEnabled) - { - for (const auto actionData : frame->actions) - { - this->_armature->_bufferAction(actionData); - } - } - - const auto eventDispatcher = this->_armature->_display; - - for (const auto eventData : frame->events) - { - std::string eventType; - switch (eventData->type) - { - case EventType::Frame: - eventType = EventObject::FRAME_EVENT; - break; - - case EventType::Sound: - eventType = EventObject::SOUND_EVENT; - break; - } - - if ( - (eventData->type == EventType::Sound ? - (EventObject::_soundEventManager ? EventObject::_soundEventManager : eventDispatcher) : - eventDispatcher - )->hasEvent(eventType) - ) - { - const auto eventObject = BaseObject::borrowObject(); - eventObject->animationState = this->_animationState; - - if (eventData->bone) - { - eventObject->bone = this->_armature->getBone(eventData->bone->name); - } - - if (eventData->slot) - { - eventObject->slot = this->_armature->getSlot(eventData->slot->name); - } - - eventObject->name = eventData->name; - //eventObject->data = eventData->data; // TODO - - this->_armature->_bufferEvent(eventObject, eventType); - } - } -} - -void AnimationTimelineState::fadeIn(Armature* armature, AnimationState* animationState, AnimationData* timelineData, float time) -{ - TimelineState::fadeIn(armature, animationState, timelineData, time); - - this->_currentTime = time; -} - -void AnimationTimelineState::update(float time) -{ - const auto prevTime = this->_currentTime; - const auto prevPlayTimes = this->_currentPlayTimes; - - if (!this->_isCompleted && this->_setCurrentTime(time)) - { - const auto eventDispatcher = this->_armature->_display; - - if (!_isStarted) - { - _isStarted = true; - - if (eventDispatcher->hasEvent(EventObject::START)) - { - const auto eventObject = BaseObject::borrowObject(); - eventObject->animationState = this->_animationState; - this->_armature->_bufferEvent(eventObject, EventObject::START); - } - } - - if (this->_keyFrameCount) - { - const auto currentFrameIndex = this->_keyFrameCount > 1 ? (unsigned)(this->_currentTime * this->_frameRate) : 0; - const auto currentFrame = this->_timeline->frames[currentFrameIndex]; - if (this->_currentFrame != currentFrame) - { - if (this->_keyFrameCount > 1) - { - auto crossedFrame = this->_currentFrame; - this->_currentFrame = currentFrame; - - if (!crossedFrame) - { - const auto prevFrameIndex = (unsigned)(prevTime * this->_frameRate); - crossedFrame = this->_timeline->frames[prevFrameIndex]; - - if (this->_isReverse) - { - } - else - { - if ( - prevTime <= crossedFrame->position || - prevPlayTimes != this->_currentPlayTimes - ) - { - crossedFrame = crossedFrame->prev; - } - } - } - - if (this->_isReverse) - { - while (crossedFrame != currentFrame) - { - this->_onCrossFrame(crossedFrame); - crossedFrame = crossedFrame->prev; - } - } - else - { - while (crossedFrame != currentFrame) - { - crossedFrame = crossedFrame->next; - this->_onCrossFrame(crossedFrame); - } - } - } - else - { - this->_currentFrame = currentFrame; - this->_onCrossFrame(this->_currentFrame); - } - } - } - - if (prevPlayTimes != this->_currentPlayTimes) - { - if (eventDispatcher->hasEvent(EventObject::LOOP_COMPLETE)) - { - const auto eventObject = BaseObject::borrowObject(); - eventObject->animationState = this->_animationState; - this->_armature->_bufferEvent(eventObject, EventObject::LOOP_COMPLETE); - } - - if (this->_isCompleted && eventDispatcher->hasEvent(EventObject::COMPLETE)) - { - const auto eventObject = BaseObject::borrowObject(); - eventObject->animationState = this->_animationState; - this->_armature->_bufferEvent(eventObject, EventObject::COMPLETE); - } - - this->_currentFrame = nullptr; - } - } -} - -void AnimationTimelineState::setCurrentTime(float value) -{ - this->_setCurrentTime(value); - this->_currentFrame = nullptr; -} - -BoneTimelineState::BoneTimelineState() -{ - _onClear(); -} -BoneTimelineState::~BoneTimelineState() -{ - _onClear(); -} - -void BoneTimelineState::_onClear() -{ - TweenTimelineState::_onClear(); - - bone = nullptr; - - _tweenTransform = TweenType::None; - _tweenRotate = TweenType::None; - _tweenScale = TweenType::None; - _boneTransform = nullptr; - _originTransform = nullptr; - _transform.identity(); - _currentTransform.identity(); - _durationTransform.identity(); -} - -void BoneTimelineState::_onArriveAtFrame(bool isUpdate) -{ - TweenTimelineState::_onArriveAtFrame(isUpdate); - - _currentTransform = this->_currentFrame->transform; - _tweenTransform = TweenType::Once; - _tweenRotate = TweenType::Once; - _tweenScale = TweenType::Once; - - if (this->_keyFrameCount > 1 && (this->_tweenEasing != NO_TWEEN || this->_curve)) - { - const auto& nextFrame = *static_cast(this->_currentFrame->next); - const auto& nextTransform = nextFrame.transform; - - // Transform - _durationTransform.x = nextTransform.x - _currentTransform.x; - _durationTransform.y = nextTransform.y - _currentTransform.y; - if (_durationTransform.x != 0.f || _durationTransform.y != 0.f) - { - _tweenTransform = TweenType::Always; - } - - // Rotate - const auto tweenRotate = this->_currentFrame->tweenRotate; - if (tweenRotate == tweenRotate) // TODO - { - if (tweenRotate) - { - if (tweenRotate > 0 ? nextTransform.skewY >= _currentTransform.skewY : nextTransform.skewY <= _currentTransform.skewY) { - const auto rotate = tweenRotate > 0 ? tweenRotate - 1 : tweenRotate + 1; - _durationTransform.skewX = nextTransform.skewX - _currentTransform.skewX + PI_D * rotate; - _durationTransform.skewY = nextTransform.skewY - _currentTransform.skewY + PI_D * rotate; - } - else - { - _durationTransform.skewX = nextTransform.skewX - _currentTransform.skewX + PI_D * tweenRotate; - _durationTransform.skewY = nextTransform.skewY - _currentTransform.skewY + PI_D * tweenRotate; - } - } - else - { - _durationTransform.skewX = Transform::normalizeRadian(nextTransform.skewX - _currentTransform.skewX); - _durationTransform.skewY = Transform::normalizeRadian(nextTransform.skewY - _currentTransform.skewY); - } - - if (_durationTransform.skewX != 0.f || _durationTransform.skewY != 0.f) - { - _tweenRotate = TweenType::Always; - } - } - else - { - _durationTransform.skewX = 0.f; - _durationTransform.skewY = 0.f; - } - - // Scale - if (this->_currentFrame->tweenScale) - { - _durationTransform.scaleX = nextTransform.scaleX - _currentTransform.scaleX; - _durationTransform.scaleY = nextTransform.scaleY - _currentTransform.scaleY; - if (_durationTransform.scaleX != 0.f || _durationTransform.scaleY != 0.f) - { - _tweenScale = TweenType::Always; - } - } - else - { - _durationTransform.scaleX = 0.f; - _durationTransform.scaleY = 0.f; - } - } - else - { - _durationTransform.x = 0.f; - _durationTransform.y = 0.f; - _durationTransform.skewX = 0.f; - _durationTransform.skewY = 0.f; - _durationTransform.scaleX = 0.f; - _durationTransform.scaleY = 0.f; - } -} - -void BoneTimelineState::_onUpdateFrame(bool isUpdate) -{ - if (_tweenTransform != TweenType::None || _tweenRotate != TweenType::None || _tweenScale != TweenType::None) - { - TweenTimelineState::_onUpdateFrame(isUpdate); - - if (_tweenTransform != TweenType::None) - { - if (_tweenTransform == TweenType::Once) - { - _tweenTransform = TweenType::None; - } - - if (this->_animationState->additiveBlending) // Additive blending - { - _transform.x = _currentTransform.x + _durationTransform.x * this->_tweenProgress; - _transform.y = _currentTransform.y + _durationTransform.y * this->_tweenProgress; - } - else // Normal blending - { - _transform.x = _originTransform->x + _currentTransform.x + _durationTransform.x * this->_tweenProgress; - _transform.y = _originTransform->y + _currentTransform.y + _durationTransform.y * this->_tweenProgress; - } - } - - if (_tweenRotate != TweenType::None) - { - if (_tweenRotate == TweenType::Once) - { - _tweenRotate = TweenType::None; - } - - if (this->_animationState->additiveBlending) // Additive blending - { - _transform.skewX = _currentTransform.skewX + _durationTransform.skewX * this->_tweenProgress; - _transform.skewY = _currentTransform.skewY + _durationTransform.skewY * this->_tweenProgress; - } - else // Normal blending - { - _transform.skewX = _originTransform->skewX + _currentTransform.skewX + _durationTransform.skewX * this->_tweenProgress; - _transform.skewY = _originTransform->skewY + _currentTransform.skewY + _durationTransform.skewY * this->_tweenProgress; - } - } - - if (_tweenScale != TweenType::None) - { - if (_tweenScale == TweenType::Once) - { - _tweenScale = TweenType::None; - } - - if (this->_animationState->additiveBlending) // Additive blending - { - _transform.scaleX = _currentTransform.scaleX + _durationTransform.scaleX * this->_tweenProgress; - _transform.scaleY = _currentTransform.scaleY + _durationTransform.scaleY * this->_tweenProgress; - } - else // Normal blending - { - _transform.scaleX = _originTransform->scaleX * (_currentTransform.scaleX + _durationTransform.scaleX * this->_tweenProgress); - _transform.scaleY = _originTransform->scaleY * (_currentTransform.scaleY + _durationTransform.scaleY * this->_tweenProgress); - } - } - - bone->invalidUpdate(); - } -} - -void BoneTimelineState::fadeIn(Armature* armature, AnimationState* animationState, BoneTimelineData* timelineData, float time) -{ - TimelineState::fadeIn(armature, animationState, timelineData, time); - - _originTransform = &this->_timeline->originTransform; - _boneTransform = &bone->_animationPose; -} - -void BoneTimelineState::fadeOut() -{ - _transform.skewX = Transform::normalizeRadian(_transform.skewX); - _transform.skewY = Transform::normalizeRadian(_transform.skewY); -} - -void BoneTimelineState::update(float time) -{ - TweenTimelineState::update(time); - - const auto weight = this->_animationState->_weightResult; - if (weight > 0.f) - { - if (bone->_blendIndex == 0) - { - _boneTransform->x = _transform.x * weight; - _boneTransform->y = _transform.y * weight; - _boneTransform->skewX = _transform.skewX * weight; - _boneTransform->skewY = _transform.skewY * weight; - _boneTransform->scaleX = (_transform.scaleX - 1.f) * weight + 1.f; - _boneTransform->scaleY = (_transform.scaleY - 1.f) * weight + 1.f; - } - else - { - _boneTransform->x += _transform.x * weight; - _boneTransform->y += _transform.y * weight; - _boneTransform->skewX += _transform.skewX * weight; - _boneTransform->skewY += _transform.skewY * weight; - _boneTransform->scaleX += (_transform.scaleX - 1.f) * weight; - _boneTransform->scaleY += (_transform.scaleY - 1.f) * weight; - } - - bone->_blendIndex++; - - const auto fadeProgress = this->_animationState->_fadeProgress; - if (fadeProgress < 1.f) - { - bone->invalidUpdate(); - } - } -} - -SlotTimelineState::SlotTimelineState() -{ - _onClear(); -} -SlotTimelineState::~SlotTimelineState() -{ - _onClear(); -} - -void SlotTimelineState::_onClear() -{ - TweenTimelineState::_onClear(); - - slot = nullptr; - - _colorDirty = false; - _tweenColor = TweenType::None; - _slotColor = nullptr; - _color.identity(); - _durationColor.identity(); -} - -void SlotTimelineState::_onArriveAtFrame(bool isUpdate) -{ - TweenTimelineState::_onArriveAtFrame(isUpdate); - - if (this->_animationState->_isDisabled(*slot)) - { - this->_tweenEasing = NO_TWEEN; - this->_curve = nullptr; - _tweenColor = TweenType::None; - return; - } - - if (slot->_displayDataSet) - { - const auto displayIndex = this->_currentFrame->displayIndex; - if (slot->getDisplayIndex() >= 0 && displayIndex >= 0) - { - if (slot->_displayDataSet->displays.size() > 1) - { - slot->_setDisplayIndex(displayIndex); - } - } - else - { - slot->_setDisplayIndex(displayIndex); - } - - slot->_updateMeshData(true); - } - - if (this->_currentFrame->displayIndex >= 0) - { - _tweenColor = TweenType::None; - - const auto& currentColor = *this->_currentFrame->color; - - if (this->_keyFrameCount > 1 && (this->_tweenEasing != NO_TWEEN || this->_curve)) - { - const auto& nextFrame = *static_cast(this->_currentFrame->next); - if (this->_currentFrame->color != nextFrame.color && nextFrame.displayIndex >= 0) - { - const auto& nextColor = *nextFrame.color; - _durationColor.alphaMultiplier = nextColor.alphaMultiplier - currentColor.alphaMultiplier; - _durationColor.redMultiplier = nextColor.redMultiplier - currentColor.redMultiplier; - _durationColor.greenMultiplier = nextColor.greenMultiplier - currentColor.greenMultiplier; - _durationColor.blueMultiplier = nextColor.blueMultiplier - currentColor.blueMultiplier; - _durationColor.alphaOffset = nextColor.alphaOffset - currentColor.alphaOffset; - _durationColor.redOffset = nextColor.redOffset - currentColor.redOffset; - _durationColor.greenOffset = nextColor.greenOffset - currentColor.greenOffset; - _durationColor.blueOffset = nextColor.blueOffset - currentColor.blueOffset; - - if ( - _durationColor.alphaMultiplier != 0.f || - _durationColor.redMultiplier != 0.f || - _durationColor.greenMultiplier != 0.f || - _durationColor.blueMultiplier != 0.f || - _durationColor.alphaOffset != 0.f || - _durationColor.redOffset != 0.f || - _durationColor.greenOffset != 0.f || - _durationColor.blueOffset != 0.f - ) - { - _tweenColor = TweenType::Always; - } - } - } - - if (_tweenColor == TweenType::None) - { - if ( - currentColor.alphaMultiplier - _slotColor->alphaMultiplier != 0.f || - currentColor.redMultiplier - _slotColor->redMultiplier != 0.f || - currentColor.greenMultiplier - _slotColor->greenMultiplier != 0.f || - currentColor.blueMultiplier - _slotColor->blueMultiplier != 0.f || - currentColor.alphaOffset - _slotColor->alphaOffset != 0.f || - currentColor.redOffset - _slotColor->redOffset != 0.f || - currentColor.greenOffset - _slotColor->greenOffset != 0.f || - currentColor.blueOffset - _slotColor->blueOffset != 0.f - ) - { - _tweenColor = TweenType::Once; - } - } - } - else - { - this->_tweenEasing = NO_TWEEN; - this->_curve = nullptr; - _tweenColor = TweenType::None; - } -} - -void SlotTimelineState::_onUpdateFrame(bool isUpdate) -{ - TweenTimelineState::_onUpdateFrame(isUpdate); - - if (_tweenColor != TweenType::None) - { - if (_tweenColor == TweenType::Once) - { - _tweenColor = TweenType::None; - } - - const auto& currentColor = *this->_currentFrame->color; - _color.alphaMultiplier = currentColor.alphaMultiplier + _durationColor.alphaMultiplier * this->_tweenProgress; - _color.redMultiplier = currentColor.redMultiplier + _durationColor.redMultiplier * this->_tweenProgress; - _color.greenMultiplier = currentColor.greenMultiplier + _durationColor.greenMultiplier * this->_tweenProgress; - _color.blueMultiplier = currentColor.blueMultiplier + _durationColor.blueMultiplier * this->_tweenProgress; - _color.alphaOffset = currentColor.alphaOffset + _durationColor.alphaOffset * this->_tweenProgress; - _color.redOffset = currentColor.redOffset + _durationColor.redOffset * this->_tweenProgress; - _color.greenOffset = currentColor.greenOffset + _durationColor.greenOffset * this->_tweenProgress; - _color.blueOffset = currentColor.blueOffset + _durationColor.blueOffset * this->_tweenProgress; - - _colorDirty = true; - } -} - -void SlotTimelineState::fadeIn(Armature* armature, AnimationState* animationState, SlotTimelineData* timelineData, float time) -{ - TimelineState::fadeIn(armature, animationState, timelineData, time); - - _slotColor = &slot->_colorTransform; -} - -void SlotTimelineState::fadeOut() -{ - _tweenColor = TweenType::None; -} - -void SlotTimelineState::update(float time) -{ - TweenTimelineState::update(time); - - if (_tweenColor != TweenType::None || _colorDirty) - { - const auto weight = this->_animationState->_weightResult; - if (weight > 0.f) - { - const auto fadeProgress = this->_animationState->_fadeProgress; - if (fadeProgress < 1.f) - { - _slotColor->alphaMultiplier += (_color.alphaMultiplier - _slotColor->alphaMultiplier) * fadeProgress; - _slotColor->redMultiplier += (_color.alphaMultiplier - _slotColor->redMultiplier) * fadeProgress; - _slotColor->greenMultiplier += (_color.alphaMultiplier - _slotColor->greenMultiplier) * fadeProgress; - _slotColor->blueMultiplier += (_color.alphaMultiplier - _slotColor->blueMultiplier) * fadeProgress; - _slotColor->alphaOffset += (_color.alphaMultiplier - _slotColor->alphaOffset) * fadeProgress; - _slotColor->redOffset += (_color.alphaMultiplier - _slotColor->redOffset) * fadeProgress; - _slotColor->greenOffset += (_color.alphaMultiplier - _slotColor->greenOffset) * fadeProgress; - _slotColor->blueOffset += (_color.alphaMultiplier - _slotColor->blueOffset) * fadeProgress; - - slot->_colorDirty = true; - } - else if (_colorDirty) - { - _colorDirty = false; - _slotColor->alphaMultiplier = _color.alphaMultiplier; - _slotColor->redMultiplier = _color.redMultiplier; - _slotColor->greenMultiplier = _color.greenMultiplier; - _slotColor->blueMultiplier = _color.blueMultiplier; - _slotColor->alphaOffset = _color.alphaOffset; - _slotColor->redOffset = _color.redOffset; - _slotColor->greenOffset = _color.greenOffset; - _slotColor->blueOffset = _color.blueOffset; - - slot->_colorDirty = true; - } - } - } -} - -FFDTimelineState::FFDTimelineState() : - _durationFFDFrame(nullptr) -{ - _onClear(); -} -FFDTimelineState::~FFDTimelineState() -{ - _onClear(); -} - -void FFDTimelineState::_onClear() -{ - TweenTimelineState::_onClear(); - - slot = nullptr; - - _tweenFFD = TweenType::None; - _slotFFDVertices = nullptr; - - if (_durationFFDFrame) - { - _durationFFDFrame->returnToPool(); - _durationFFDFrame = nullptr; - } - - _ffdVertices.clear(); -} - -void FFDTimelineState::_onArriveAtFrame(bool isUpdate) -{ - TweenTimelineState::_onArriveAtFrame(isUpdate); - - _tweenFFD = TweenType::None; - - if (this->_tweenEasing != NO_TWEEN || this->_curve) - { - _tweenFFD = this->_updateExtensionKeyFrame(*this->_currentFrame, *this->_currentFrame->next, *_durationFFDFrame); - } - - if (_tweenFFD == TweenType::None) - { - const auto& currentFFDVertices = this->_currentFrame->tweens; - for (std::size_t i = 0, l = currentFFDVertices.size(); i < l; ++i) - { - if ((*_slotFFDVertices)[i] != currentFFDVertices[i]) - { - _tweenFFD = TweenType::Once; - break; - } - } - } -} - -void FFDTimelineState::_onUpdateFrame(bool isUpdate) -{ - TweenTimelineState::_onUpdateFrame(isUpdate); - - if (_tweenFFD != TweenType::None) - { - if (_tweenFFD == TweenType::Once) - { - _tweenFFD = TweenType::None; - } - - const auto& currentFFDVertices = this->_currentFrame->tweens; - const auto& nextFFDVertices = _durationFFDFrame->tweens; - for (std::size_t i = 0, l = currentFFDVertices.size(); i < l; ++i) - { - _ffdVertices[i] = currentFFDVertices[i] + nextFFDVertices[i] * this->_tweenProgress; - } - - slot->_ffdDirty = true; - } -} - -void FFDTimelineState::fadeIn(Armature* armature, AnimationState* animationState, FFDTimelineData* timelineData, float time) -{ - TimelineState::fadeIn(armature, animationState, timelineData, time); - - _slotFFDVertices = &slot->_ffdVertices; - _durationFFDFrame = BaseObject::borrowObject(); - _durationFFDFrame->tweens.resize(_slotFFDVertices->size(), 0.f); - _ffdVertices.resize(_slotFFDVertices->size(), 0.f); -} - -void FFDTimelineState::update(float time) -{ - TweenTimelineState::update(time); - - const auto weight = this->_animationState->_weightResult; - if (weight > 0.f) - { - if (slot->_blendIndex == 0) - { - for (std::size_t i = 0, l = _ffdVertices.size(); i < l; ++i) - { - (*_slotFFDVertices)[i] = _ffdVertices[i] * weight; - } - } - else - { - for (std::size_t i = 0, l = _ffdVertices.size(); i < l; ++i) - { - (*_slotFFDVertices)[i] += _ffdVertices[i] * weight; - } - } - - slot->_blendIndex++; - - const auto fadeProgress = this->_animationState->_fadeProgress; - if (fadeProgress < 1.f) - { - slot->_ffdDirty = true; - } - } -} - -DRAGONBONES_NAMESPACE_END \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/animation/TimelineState.h b/native/cocos/editor-support/dragonbones/animation/TimelineState.h deleted file mode 100644 index 359c275d12..0000000000 --- a/native/cocos/editor-support/dragonbones/animation/TimelineState.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef DRAGONBONES_TIMELINE_STATE_H -#define DRAGONBONES_TIMELINE_STATE_H - -#include "BaseTimelineState.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class Bone; -class Slot; - -class AnimationTimelineState final : public TimelineState -{ - BIND_CLASS_TYPE(AnimationTimelineState); - -private: - bool _isStarted; - -public: - AnimationTimelineState(); - ~AnimationTimelineState(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(AnimationTimelineState); - -protected: - void _onClear() override; - void _onCrossFrame(AnimationFrameData* frame); - -public: - void fadeIn(Armature* armature, AnimationState* animationState, AnimationData* timelineData, float time) override; - void update(float time) override; - void setCurrentTime(float value); -}; - -class BoneTimelineState final : public TweenTimelineState -{ - BIND_CLASS_TYPE(BoneTimelineState); - -public: - Bone* bone; - -private: - TweenType _tweenTransform; - TweenType _tweenRotate; - TweenType _tweenScale; - Transform* _boneTransform; - Transform* _originTransform; - Transform _transform; - Transform _currentTransform; - Transform _durationTransform; - -public: - BoneTimelineState(); - ~BoneTimelineState(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(BoneTimelineState); - -protected: - void _onClear() override; - void _onArriveAtFrame(bool isUpdate) override; - void _onUpdateFrame(bool isUpdate) override; - -public: - void fadeIn(Armature* armature, AnimationState* animationState, BoneTimelineData* timelineData, float time) override; - void fadeOut() override; - void update(float time) override; -}; - -class SlotTimelineState final : public TweenTimelineState -{ - BIND_CLASS_TYPE(SlotTimelineState); - -public: - Slot* slot; - -private: - bool _colorDirty; - TweenType _tweenColor; - ColorTransform* _slotColor; - ColorTransform _color; - ColorTransform _durationColor; - -public: - SlotTimelineState(); - ~SlotTimelineState(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(SlotTimelineState); - -protected: - void _onClear() override; - void _onArriveAtFrame(bool isUpdate) override; - void _onUpdateFrame(bool isUpdate) override; - -public: - void fadeIn(Armature* armature, AnimationState* animationState, SlotTimelineData* timelineData, float time) override; - void fadeOut() override; - void update(float time) override; -}; - -class FFDTimelineState final : public TweenTimelineState -{ - BIND_CLASS_TYPE(FFDTimelineState); - -public: - Slot* slot; - -private: - TweenType _tweenFFD; - std::vector* _slotFFDVertices; - ExtensionFrameData* _durationFFDFrame; - std::vector _ffdVertices; - -public: - FFDTimelineState(); - ~FFDTimelineState(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(FFDTimelineState); - -protected: - void _onClear() override; - void _onArriveAtFrame(bool isUpdate) override; - void _onUpdateFrame(bool isUpdate) override; - -public: - void fadeIn(Armature* armature, AnimationState* animationState, FFDTimelineData* timelineData, float time) override; - void update(float time) override; -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_TIMELINE_STATE_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/animation/WorldClock.cpp b/native/cocos/editor-support/dragonbones/animation/WorldClock.cpp deleted file mode 100644 index d1c8a0a149..0000000000 --- a/native/cocos/editor-support/dragonbones/animation/WorldClock.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include "WorldClock.h" - -DRAGONBONES_NAMESPACE_BEGIN - -WorldClock WorldClock::clock; - -WorldClock::WorldClock(): - time(0.f), - timeScale(1.f), - _animatebles() -{ -} -WorldClock::~WorldClock() -{ - clear(); -} - -void WorldClock::advanceTime(float passedTime) -{ - if (passedTime < 0 || passedTime != passedTime) - { - passedTime = 0; - } - - passedTime *= timeScale; - - if (passedTime < 0) - { - time -= passedTime; - } - else - { - time += passedTime; - } - - if (passedTime) - { - std::size_t i = 0, r = 0, l = _animatebles.size(); - - for (; i < l; ++i) - { - const auto animateble = _animatebles[i]; - if (animateble) - { - if (r > 0) - { - _animatebles[i - r] = animateble; - _animatebles[i] = nullptr; - } - - animateble->advanceTime(passedTime); - } - else - { - r++; - } - } - - if (r > 0) - { - l = _animatebles.size(); - - for (; i < l; ++i) - { - const auto animateble = _animatebles[i]; - if (animateble) - { - _animatebles[i - r] = animateble; - } - else - { - r++; - } - } - - _animatebles.resize(l - r); - } - } -} - -bool WorldClock::contains(const IAnimateble* value) const -{ - return std::find(_animatebles.cbegin(), _animatebles.cend(), value) != _animatebles.cend(); -} - -void WorldClock::add(IAnimateble* value) -{ - if (std::find(_animatebles.begin(), _animatebles.end(), value) == _animatebles.end()) - { - _animatebles.push_back(value); - } -} - -void WorldClock::remove(IAnimateble* value) -{ - const auto iterator = std::find(_animatebles.begin(), _animatebles.end(), value); - if (iterator != _animatebles.end()) - { - *iterator = nullptr; - } -} - -void WorldClock::clear() -{ - for (auto& animateble : _animatebles) - { - animateble = nullptr; - } -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/animation/WorldClock.h b/native/cocos/editor-support/dragonbones/animation/WorldClock.h deleted file mode 100644 index 697de4fd09..0000000000 --- a/native/cocos/editor-support/dragonbones/animation/WorldClock.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef DRAGONBONES_WORLD_CLOCK_H -#define DRAGONBONES_WORLD_CLOCK_H - -#include "../core/DragonBones.h" -#include "IAnimateble.h" - -DRAGONBONES_NAMESPACE_BEGIN -class WorldClock final : public IAnimateble -{ -public: - static WorldClock clock; - -public: - float time; - float timeScale; - -private: - std::vector _animatebles; - -public: - WorldClock(); - ~WorldClock(); - - virtual void advanceTime(float passedTime) override; - bool contains(const IAnimateble* value) const; - void add(IAnimateble* value); - void remove(IAnimateble* value); - void clear(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(WorldClock); -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_WORLD_CLOCK_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/armature/Armature.cpp b/native/cocos/editor-support/dragonbones/armature/Armature.cpp deleted file mode 100644 index df3a2a0b8a..0000000000 --- a/native/cocos/editor-support/dragonbones/armature/Armature.cpp +++ /dev/null @@ -1,510 +0,0 @@ -#include "Armature.h" -#include "Bone.h" -#include "Slot.h" -#include "../animation/Animation.h" -#include "../events/EventObject.h" - -DRAGONBONES_NAMESPACE_BEGIN - -Armature::Armature() : - _animation(nullptr), - _display(nullptr) -{ - _onClear(); -} -Armature::~Armature() -{ - _onClear(); -} - -void Armature::_onClear() -{ - for (const auto bone : _bones) - { - bone->returnToPool(); - } - - for (const auto slot : _slots) - { - slot->returnToPool(); - } - - for (const auto event : _events) - { - event->returnToPool(); - } - - userData = nullptr; - - _bonesDirty = false; - _cacheFrameIndex = -1; - _delayAdvanceTime = -1.f; - _armatureData = nullptr; - _skinData = nullptr; - - if (_animation) - { - _animation->returnToPool(); - _animation = nullptr; - } - - if (_display) - { - _display->_onClear(); - _display = nullptr; - } - - _replacedTexture = nullptr; - _parent = nullptr; - - _delayDispose = false; - _lockDispose = false; - _lockActionAndEvent = false; - _slotsDirty = false; - _bones.clear(); - _slots.clear(); - _actions.clear(); - _events.clear(); -} - -void Armature::_sortBones() -{ - if (_bones.empty()) - { - return; - } - - const auto total = _bones.size(); - const auto sortHelper = _bones; - std::size_t index = 0; - std::size_t count = 0; - - _bones.clear(); - - while (count < total) - { - const auto bone = sortHelper[index++]; - - if (index >= total) - { - index = 0; - } - - if (std::find(_bones.cbegin(), _bones.cend(), bone) != _bones.cend()) - { - continue; - } - - if (bone->getParent() && std::find(_bones.cbegin(), _bones.cend(), bone->getParent()) == _bones.cend()) - { - continue; - } - - if (bone->getIK() && std::find(_bones.cbegin(), _bones.cend(), bone->getIK()) == _bones.cend()) - { - continue; - } - - if (bone->getIK() && bone->getIKChain() > 0 && bone->getIKChainIndex() == bone->getIKChain()) - { - auto parentInerator = std::find(_bones.begin(), _bones.end(), bone->getParent()); - _bones.insert(parentInerator + 1, bone); - } - else - { - _bones.push_back(bone); - } - - count++; - } -} - -void Armature::_sortSlots() -{ -} - -void Armature::_doAction(const ActionData& value) -{ - const auto& ints = std::get<0>(value.data); - const auto& floats = std::get<1>(value.data); - const auto& strings = std::get<2>(value.data); - - switch (value.type) - { - case ActionType::Play: - _animation->play(strings[0], ints[0]); - break; - - case ActionType::Stop: - _animation->stop(strings[0]); - break; - - case ActionType::GotoAndPlay: - _animation->gotoAndPlayByTime(strings[0], floats[0], ints[0]); - break; - - case ActionType::GotoAndStop: - _animation->gotoAndStopByTime(strings[0], floats[0]); - break; - - case ActionType::FadeIn: - _animation->fadeIn(strings[0], floats[0], ints[0]); - break; - - case ActionType::FadeOut: - // TODO fade out - break; - - default: - break; - } -} - -void Armature::_addBoneToBoneList(Bone* value) -{ - if (std::find(_bones.begin(), _bones.end(), value) == _bones.end()) - { - _bonesDirty = true; - _bones.push_back(value); - _animation->_timelineStateDirty = true; - } -} - -void Armature::_removeBoneFromBoneList(Bone* value) -{ - const auto iterator = std::find(_bones.begin(), _bones.end(), value); - if (iterator != _bones.end()) - { - _bones.erase(iterator); - _animation->_timelineStateDirty = true; - } -} - -void Armature::_addSlotToSlotList(Slot* value) -{ - if (std::find(_slots.begin(), _slots.end(), value) == _slots.end()) - { - _slotsDirty = true; - _slots.push_back(value); - _animation->_timelineStateDirty = true; - } -} - -void Armature::_removeSlotFromSlotList(Slot* value) -{ - const auto iterator = std::find(_slots.begin(), _slots.end(), value); - if (iterator != _slots.end()) - { - _slots.erase(iterator); - _animation->_timelineStateDirty = true; - } -} - -void Armature::_bufferAction(ActionData* value) -{ - _actions.push_back(value); -} - -void Armature::_bufferEvent(EventObject* value, const std::string& type) -{ - value->type = type; - value->armature = this; - _events.push_back(value); -} - -void Armature::dispose() -{ - _delayDispose = true; - - if (!_lockDispose && _animation) - { - this->returnToPool(); - } -} - -void Armature::advanceTime(float passedTime) -{ - if (!_animation) - { - DRAGONBONES_ASSERT(false, "The armature has been disposed."); - } - - const auto scaledPassedTime = passedTime * _animation->timeScale; - - // - _animation->_advanceTime(scaledPassedTime); - - // - if (_bonesDirty) - { - _bonesDirty = false; - _sortBones(); - } - - if (_slotsDirty) - { - _slotsDirty = false; - _sortSlots(); - } - - // - for (const auto bone : _bones) - { - bone->_update(_cacheFrameIndex); - } - - for (const auto slot : _slots) - { - slot->_update(_cacheFrameIndex); - - const auto childArmature = slot->getChildArmature(); - if (childArmature) - { - if (slot->inheritAnimation) - { - childArmature->advanceTime(scaledPassedTime); - } - else - { - childArmature->advanceTime(passedTime); - } - } - } - - // - - if (!_lockDispose) - { - _lockDispose = true; - - if (!_events.empty()) - { - for (const auto event : _events) - { - if (EventObject::_soundEventManager && event->type == EventObject::SOUND_EVENT) - { - EventObject::_soundEventManager->_dispatchEvent(event); - } - else - { - _display->_dispatchEvent(event); - } - - event->returnToPool(); - } - - _events.clear(); - } - - if (!_actions.empty()) - { - for (const auto action : _actions) - { - if (action->slot) - { - const auto slot = getSlot(action->slot->name); - if (slot) - { - const auto childArmature = slot->getChildArmature(); - if (childArmature) - { - childArmature->_doAction(*action); - } - } - } - else if (action->bone) - { - for (const auto slot : _slots) - { - const auto childArmature = slot->getChildArmature(); - if (childArmature) - { - childArmature->_doAction(*action); - } - } - } - else - { - _doAction(*action); - } - } - - _actions.clear(); - } - - _lockDispose = false; - } - - if (_delayDispose) - { - this->returnToPool(); - } -} - -void Armature::invalidUpdate(const std::string& boneName, bool updateSlotDisplay) -{ - if (!boneName.empty()) - { - const auto bone = getBone(boneName); - if (bone) - { - bone->invalidUpdate(); - - if (updateSlotDisplay) - { - for (const auto slot : _slots) - { - if (slot->getParent() == bone) - { - slot->invalidUpdate(); - } - } - } - } - } - else - { - for (const auto bone : _bones) - { - bone->invalidUpdate(); - } - - if (updateSlotDisplay) - { - for (const auto slot : _slots) - { - slot->invalidUpdate(); - } - } - } -} - -Slot* Armature::getSlot(const std::string& name) const -{ - for (const auto slot : _slots) - { - if (slot->name == name) - { - return slot; - } - } - - return nullptr; -} - -Slot* Armature::getSlotByDisplay(void* display) const -{ - if (display) - { - for (const auto slot : _slots) - { - if (slot->getDisplay() == display) - { - return slot; - } - } - } - - return nullptr; -} - -void Armature::addSlot(Slot* value, const std::string& boneName) -{ - const auto bone = getBone(boneName); - if (bone) - { - value->_setArmature(this); - value->_setParent(bone); - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -void Armature::removeSlot(Slot* value) -{ - if (value && value->getArmature() == this) - { - value->_setParent(nullptr); - value->_setArmature(nullptr); - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -Bone* Armature::getBone(const std::string& name) const -{ - for (const auto bone : _bones) - { - if (bone->name == name) - { - return bone; - } - } - - return nullptr; -} - -Bone* Armature::getBoneByDisplay(void* display) const -{ - const auto slot = getSlotByDisplay(display); - - return slot ? slot->getParent() : nullptr; -} - -void Armature::addBone(Bone* value, const std::string& parentName) -{ - if (value) - { - value->_setArmature(this); - value->_setParent(parentName.empty() ? nullptr : getBone(parentName)); - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -void Armature::removeBone(Bone* value) -{ - if (value && value->getArmature() == this) - { - value->_setParent(nullptr); - value->_setArmature(nullptr); - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -void Armature::replaceTexture(void* texture) -{ - _replacedTexture = texture; - for (auto const slot : _slots) - { - slot->invalidUpdate(); - } -} - -void Armature::setCacheFrameRate(unsigned value) -{ - if (_armatureData->cacheFrameRate != value) - { - _armatureData->cacheFrames(value); - - for (const auto slot : _slots) - { - const auto childArmature = slot->getChildArmature(); - if (childArmature && childArmature->getCacheFrameRate() == 0) - { - childArmature->setCacheFrameRate(value); - } - } - } -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/armature/Armature.h b/native/cocos/editor-support/dragonbones/armature/Armature.h deleted file mode 100644 index 78f6176b30..0000000000 --- a/native/cocos/editor-support/dragonbones/armature/Armature.h +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef DRAGONBONES_ARMATURE_H -#define DRAGONBONES_ARMATURE_H - -#include "../core/BaseObject.h" -#include "../model/ArmatureData.h" -#include "../animation/IAnimateble.h" -#include "../events/EventObject.h" -#include "IArmatureDisplay.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class Bone; -class Slot; -class Animation; - -class Armature : public BaseObject, public IAnimateble -{ - BIND_CLASS_TYPE(Armature); - -public: - void* userData; - -public: // private - /** @private */ - bool _bonesDirty; - /** @private */ - int _cacheFrameIndex; - /** @private */ - float _delayAdvanceTime; - /** @private */ - ArmatureData* _armatureData; - /** @private */ - SkinData* _skinData; - /** @private */ - Animation* _animation; - /** @private */ - IArmatureDisplay* _display; - /** @private */ - void* _replacedTexture; - /** @private */ - Slot* _parent; - -protected: - bool _delayDispose; - bool _lockDispose; - bool _lockActionAndEvent; - bool _slotsDirty; - std::vector _bones; - std::vector _slots; - std::vector _actions; - std::vector _events; - -public: - /** @private */ - Armature(); - /** @private */ - ~Armature(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(Armature); - void _sortBones(); - void _sortSlots(); - void _doAction(const ActionData& value); - -protected: - void _onClear() override; - -public: - /** @private */ - void _addBoneToBoneList(Bone* value); - /** @private */ - void _removeBoneFromBoneList(Bone* value); - /** @private */ - void _addSlotToSlotList(Slot* value); - /** @private */ - void _removeSlotFromSlotList(Slot* value); - /** @private */ - void _bufferAction(ActionData* value); - /** @private */ - void _bufferEvent(EventObject* value, const std::string& type); - -public: - void dispose(); - void advanceTime(float passedTime) override; - void invalidUpdate(const std::string& boneName = "", bool updateSlotDisplay = false); - Slot* getSlot(const std::string& name) const; - Slot* getSlotByDisplay(void* display) const; - void addSlot(Slot* value, const std::string& boneName); - void removeSlot(Slot* value); - Bone* getBone(const std::string& name) const; - Bone* getBoneByDisplay(void* display) const; - void addBone(Bone* value, const std::string& parentName = ""); - void removeBone(Bone* value); - void replaceTexture(void* texture); - - inline const std::vector& getBones() const - { - return _bones; - } - - inline const std::vector& getSlots() const - { - return _slots; - } - - inline const std::string& getName() const - { - if(_armatureData) - { - return _armatureData->name; - } - - static const std::string DEFAULT_NAME = ""; - return DEFAULT_NAME; - } - - inline const ArmatureData& getArmatureData() const - { - return *_armatureData; - } - - inline IArmatureDisplay* getDisplay() const - { - return _display; - } - - inline Slot* getParent() const - { - return _parent; - } - - inline Animation& getAnimation() const - { - return *_animation; - } - - inline unsigned getCacheFrameRate() - { - return _armatureData->cacheFrameRate; - } - void setCacheFrameRate(unsigned value); -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_ARMATURE_H diff --git a/native/cocos/editor-support/dragonbones/armature/Bone.cpp b/native/cocos/editor-support/dragonbones/armature/Bone.cpp deleted file mode 100644 index 53a0ecc295..0000000000 --- a/native/cocos/editor-support/dragonbones/armature/Bone.cpp +++ /dev/null @@ -1,448 +0,0 @@ -#include "Armature.h" -#include "Bone.h" -#include "Slot.h" -#include "../model/TimelineData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -Bone::Bone() -{ - _onClear(); -} -Bone::~Bone() -{ - _onClear(); -} - -void Bone::_onClear() -{ - TransformObject::_onClear(); - - inheritTranslation = false; - inheritRotation = false; - inheritScale = false; - ikBendPositive = false; - ikWeight = 0.f; - length = 0.f; - - _transformDirty = BoneTransformDirty::All; - _blendIndex = 0; - _cacheFrames = nullptr; - _animationPose.identity(); - - _visible = true; - _ikChain = 0; - _ikChainIndex = 0; - _ik = nullptr; - - _bones.clear(); - _slots.clear(); -} - -void Bone::_updateGlobalTransformMatrix() -{ - if (this->_parent) - { - const auto parentRotation = this->_parent->global.skewY; - const auto& parentMatrix = *this->_parent->globalTransformMatrix; - - if (inheritScale) - { - if (!inheritRotation) - { - this->global.skewX -= parentRotation; - this->global.skewY -= parentRotation; - } - - this->global.toMatrix(*this->globalTransformMatrix); - this->globalTransformMatrix->concat(parentMatrix); - - if (!inheritTranslation) - { - this->globalTransformMatrix->tx = this->global.x; - this->globalTransformMatrix->ty = this->global.y; - } - - this->global.fromMatrix(*this->globalTransformMatrix); - } - else - { - if (inheritTranslation) - { - const auto x = this->global.x; - const auto y = this->global.y; - this->global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - this->global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty; - } - - if (inheritRotation) - { - this->global.skewX += parentRotation; - this->global.skewY += parentRotation; - } - - this->global.toMatrix(*this->globalTransformMatrix); - } - } - else - { - this->global.toMatrix(*this->globalTransformMatrix); - } -} - -void Bone::_computeIKA() -{ - const auto& ikGlobal = _ik->global; - const auto x = this->globalTransformMatrix->a * length; - const auto y = this->globalTransformMatrix->b * length; - - const auto ikRadian = - ( - std::atan2(ikGlobal.y - this->global.y, ikGlobal.x - this->global.x) + - this->offset.skewY - - this->global.skewY * 2.f + - std::atan2(y, x) - ) * ikWeight; - - this->global.skewX += ikRadian; - this->global.skewY += ikRadian; - this->global.toMatrix(*this->globalTransformMatrix); -} - -void Bone::_computeIKB() -{ - auto& parentGlobal = this->_parent->global; - const auto& ikGlobal = _ik->global; - - const auto x = this->globalTransformMatrix->a * length; - const auto y = this->globalTransformMatrix->b * length; - - const auto lLL = x * x + y * y; - const auto lL = std::sqrt(lLL); - - auto dX = this->global.x - parentGlobal.x; - auto dY = this->global.y - parentGlobal.y; - const auto lPP = dX * dX + dY * dY; - const auto lP = std::sqrt(lPP); - - dX = ikGlobal.x - parentGlobal.x; - dY = ikGlobal.y - parentGlobal.y; - const auto lTT = dX * dX + dY * dY; - const auto lT = std::sqrt(lTT); - - auto ikRadianA = 0.f; - if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) - { - ikRadianA = std::atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x) + this->_parent->offset.skewY; - if (lL + lP <= lT) - { - } - else if (lP < lL) - { - ikRadianA += PI; - } - } - else - { - const auto h = (lPP - lLL + lTT) / (2.f * lTT); - const auto r = std::sqrt(lPP - h * h * lTT) / lT; - const auto hX = parentGlobal.x + (dX * h); - const auto hY = parentGlobal.y + (dY * h); - const auto rX = -dY * r; - const auto rY = dX * r; - - if (ikBendPositive) - { - this->global.x = hX - rX; - this->global.y = hY - rY; - } - else - { - this->global.x = hX + rX; - this->global.y = hY + rY; - } - - ikRadianA = std::atan2(this->global.y - parentGlobal.y, this->global.x - parentGlobal.x) + this->_parent->offset.skewY; - } - - ikRadianA = (ikRadianA - parentGlobal.skewY) * ikWeight; - - parentGlobal.skewX += ikRadianA; - parentGlobal.skewY += ikRadianA; - parentGlobal.toMatrix(*this->_parent->globalTransformMatrix); - - this->global.x = parentGlobal.x + std::cos(parentGlobal.skewY) * lP; - this->global.y = parentGlobal.y + std::sin(parentGlobal.skewY) * lP; - - const auto ikRadianB = - ( - std::atan2(ikGlobal.y - this->global.y, ikGlobal.x - this->global.x) + this->offset.skewY - - this->global.skewY * 2.f + std::atan2(y, x) - ) * ikWeight; - - this->global.skewX += ikRadianB; - this->global.skewY += ikRadianB; - - this->global.toMatrix(*this->globalTransformMatrix); -} - -void Bone::_setArmature(Armature* value) -{ - if (this->_armature == value) - { - return; - } - - std::vector oldSlots; - std::vector oldBones; - - _ik = nullptr; - - if (this->_armature) - { - oldSlots = getSlots(); - oldBones = getBones(); - this->_armature->_removeBoneFromBoneList(this); - } - - this->_armature = value; - - if (this->_armature) - { - this->_armature->_addBoneToBoneList(this); - } - - if (!oldSlots.empty()) { - for (const auto slot : oldSlots) - { - if (slot->getParent() == this) - { - slot->_setArmature(this->_armature); - } - } - } - - if (!oldBones.empty()) { - for (const auto bone : oldBones) - { - if (bone->getParent() == this) - { - bone->_setArmature(this->_armature); - } - } - } -} - -void Bone::_setIK(Bone* value, unsigned chain, int chainIndex) -{ - if (value) - { - if (chain == chainIndex) - { - auto chainEnd = this->_parent; - if (chain && chainEnd) - { - chain = 1; - } - else - { - chain = 0; - chainIndex = 0; - chainEnd = this; - } - - if (chainEnd == value || chainEnd->contains(value)) - { - value = nullptr; - chain = 0; - chainIndex = 0; - } - else - { - auto ancestor = value; - while (ancestor->getIK() && ancestor->getIKChain()) - { - if (chainEnd->contains(ancestor->getIK())) - { - value = nullptr; - chain = 0; - chainIndex = 0; - break; - } - - ancestor = ancestor->getParent(); - } - } - } - } - else - { - chain = 0; - chainIndex = 0; - } - - _ik = value; - _ikChain = chain; - _ikChainIndex = chainIndex; - - if (this->_armature) - { - this->_armature->_bonesDirty = true; - } -} - -void Bone::_update(int cacheFrameIndex) -{ - _blendIndex = 0; - - if (cacheFrameIndex >= 0) - { - const auto cacheFrame = (*_cacheFrames)[cacheFrameIndex]; - - if (this->globalTransformMatrix == cacheFrame) - { - _transformDirty = BoneTransformDirty::None; - } - else if (cacheFrame) - { - _transformDirty = BoneTransformDirty::All; - this->globalTransformMatrix = cacheFrame; - } - else if ( - _transformDirty == BoneTransformDirty::All || - (this->_parent && this->_parent->_transformDirty != BoneTransformDirty::None) || - (_ik && _ik->_transformDirty != BoneTransformDirty::None) - ) - { - _transformDirty = BoneTransformDirty::All; - this->globalTransformMatrix = &this->_globalTransformMatrix; - } - else if (this->globalTransformMatrix != &this->_globalTransformMatrix) - { - _transformDirty = BoneTransformDirty::None; - (*_cacheFrames)[cacheFrameIndex] = this->globalTransformMatrix; - } - else - { - _transformDirty = BoneTransformDirty::All; - this->globalTransformMatrix = &this->_globalTransformMatrix; - } - } - else if ( - _transformDirty == BoneTransformDirty::All || - (this->_parent && this->_parent->_transformDirty != BoneTransformDirty::None) || - (_ik && _ik->_transformDirty != BoneTransformDirty::None) - ) - { - _transformDirty = BoneTransformDirty::All; - this->globalTransformMatrix = &this->_globalTransformMatrix; - } - - if (_transformDirty != BoneTransformDirty::None) - { - if (_transformDirty == BoneTransformDirty::All) - { - _transformDirty = BoneTransformDirty::Self; - - if (this->globalTransformMatrix == &this->_globalTransformMatrix) - { - this->global = this->origin; // copy - this->global.add(this->offset).add(_animationPose); - - _updateGlobalTransformMatrix(); - - if (_ik && _ikChainIndex == _ikChain && ikWeight > 0.f) - { - if (this->inheritTranslation && _ikChain > 0 && this->_parent) - { - _computeIKB(); - } - else - { - _computeIKA(); - } - } - - if (cacheFrameIndex >= 0 && !(*_cacheFrames)[cacheFrameIndex]) - { - this->globalTransformMatrix = BoneTimelineData::cacheFrame(*_cacheFrames, cacheFrameIndex, this->_globalTransformMatrix); - } - } - } - else - { - _transformDirty = BoneTransformDirty::None; - } - } -} - -bool Bone::contains(const TransformObject* child) const -{ - if (child) - { - if (child == this) - { - return false; - } - - auto ancestor = child; - while (ancestor != this && ancestor) - { - ancestor = ancestor->getParent(); - } - - return ancestor == this; - } - - return false; -} - -void Bone::setVisible(bool value) -{ - if (_visible == value) - { - return; - } - - _visible = value; - - for (const auto slot : this->_armature->getSlots()) - { - if (slot->_parent == this) - { - slot->_updateVisible(); - } - } -} - -const std::vector& Bone::getBones() const -{ - _bones.clear(); - - for (const auto bone : _armature->getBones()) - { - if (bone->getParent() == this) - { - _bones.push_back(bone); - } - } - - return _bones; -} - -const std::vector& Bone::getSlots() const -{ - _slots.clear(); - - for (const auto slot : _armature->getSlots()) - { - if (slot->getParent() == this) - { - _slots.push_back(slot); - } - } - - return _slots; -} - -DRAGONBONES_NAMESPACE_END \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/armature/Bone.h b/native/cocos/editor-support/dragonbones/armature/Bone.h deleted file mode 100644 index 96df39414b..0000000000 --- a/native/cocos/editor-support/dragonbones/armature/Bone.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef DRAGONBONES_BONE_H -#define DRAGONBONES_BONE_H - -#include "TransformObject.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class Bone final : public TransformObject -{ - BIND_CLASS_TYPE(Bone); - -public: - /** @private */ - enum class BoneTransformDirty - { - None = 0, - Self = 1, - All = 2 - }; - - bool inheritTranslation; - bool inheritRotation; - bool inheritScale; - bool ikBendPositive; - float ikWeight; - float length; - -public: - /** @private */ - BoneTransformDirty _transformDirty; - /** @private */ - int _blendIndex; - /** @private */ - std::vector* _cacheFrames; - /** @private */ - Transform _animationPose; - -private: - bool _visible; - unsigned _ikChain; - int _ikChainIndex; - Bone* _ik; - mutable std::vector _bones; - mutable std::vector _slots; - -public: - Bone(); - ~Bone(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(Bone); - - void _updateGlobalTransformMatrix(); - void _computeIKA(); - void _computeIKB(); - -protected: - void _onClear() override; - -public: - /** @private */ - virtual void _setArmature(Armature* value) override; - /** @private */ - void _setIK(Bone* value, unsigned chain, int chainIndex); - /** @private */ - void _update(int cacheFrameIndex); - -public: - bool contains(const TransformObject* child) const; - void setVisible(bool value); - const std::vector& getBones() const; - const std::vector& getSlots() const; - - inline void invalidUpdate() - { - _transformDirty = BoneTransformDirty::All; - } - - inline unsigned getIKChain() const - { - return _ikChain; - } - - inline unsigned getIKChainIndex() const - { - return _ikChainIndex; - } - - inline Bone* getIK() const - { - return _ik; - } - - inline bool getVisible() const - { - return _visible; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_BONE_H diff --git a/native/cocos/editor-support/dragonbones/armature/IArmatureDisplay.h b/native/cocos/editor-support/dragonbones/armature/IArmatureDisplay.h deleted file mode 100644 index 4023ff5d6d..0000000000 --- a/native/cocos/editor-support/dragonbones/armature/IArmatureDisplay.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef DRAGONBONES_ARMATURE_DISPLAY_CONTAINER_H -#define DRAGONBONES_ARMATURE_DISPLAY_CONTAINER_H - -#include "../core/DragonBones.h" -#include "../events/EventObject.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class Armature; -class Animation; - -class IArmatureDisplay : public IEventDispatcher -{ -protected: - IArmatureDisplay() {}; - virtual ~IArmatureDisplay() {}; - -public: - virtual void dispose() = 0; - virtual void advanceTimeBySelf(bool on) = 0; - virtual Armature* getArmature() const = 0; - virtual Animation& getAnimation() const = 0; -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_ARMATURE_DISPLAY_CONTAINER_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/armature/Slot.cpp b/native/cocos/editor-support/dragonbones/armature/Slot.cpp deleted file mode 100644 index dc5e64fcd4..0000000000 --- a/native/cocos/editor-support/dragonbones/armature/Slot.cpp +++ /dev/null @@ -1,533 +0,0 @@ -#include "Slot.h" -#include "Armature.h" -#include "../model/TimelineData.h" -#include "../animation/Animation.h" - -DRAGONBONES_NAMESPACE_BEGIN - -Slot::Slot() : - _rawDisplay(nullptr), - _meshDisplay(nullptr) -{} -Slot::~Slot() {} - -void Slot::_onClear() -{ - TransformObject::_onClear(); - - std::vector> disposeDisplayList; - for (const auto& pair : this->_displayList) - { - if ( - pair.first != _rawDisplay && pair.first != _meshDisplay && - std::find(disposeDisplayList.cbegin(), disposeDisplayList.cend(), pair) == disposeDisplayList.cend() - ) - { - disposeDisplayList.push_back(pair); - } - } - - for (const auto& pair : disposeDisplayList) - { - if (pair.second == DisplayType::Armature) - { - static_cast(pair.first)->returnToPool(); - } - else - { - _disposeDisplay(pair.first); - } - } - - if (_meshDisplay && _meshDisplay != _rawDisplay) - { - _disposeDisplay(_meshDisplay); - } - - if (_rawDisplay) { - _disposeDisplay(_rawDisplay); - } - - inheritAnimation = true; - displayController.clear(); - - _colorDirty = false; - _ffdDirty = false; - _blendIndex = 0; - _zOrder = 0; - _blendMode = BlendMode::Normal; - _pivotX = 0.f; - _pivotY = 0.f; - _displayDataSet = nullptr; - _meshData = nullptr; - _cacheFrames = nullptr; - _rawDisplay = nullptr; - _meshDisplay = nullptr; - _colorTransform.identity(); - _ffdVertices.clear(); - _replacedDisplayDataSet.clear(); - - _displayDirty = false; - _blendModeDirty = false; - _originDirty = false; - _transformDirty = false; - _displayIndex = 0; - _display = nullptr; - _childArmature = nullptr; - _localMatrix.identity(); - _displayList.clear(); - _meshBones.clear(); -} - -void Slot::_updateDisplay() -{ - const auto prevDisplay = _display ? _display : _rawDisplay; - const auto prevChildArmature = _childArmature; - - if (_displayIndex >= 0 && (std::size_t)_displayIndex < _displayList.size()) - { - const auto& displayPair = _displayList[_displayIndex]; - if (displayPair.second == DisplayType::Armature) - { - _childArmature = static_cast(displayPair.first); - _display = _childArmature->_display; - } - else - { - _display = displayPair.first; - _childArmature = nullptr; - } - } - else - { - _display = nullptr; - _childArmature = nullptr; - } - - const auto currentDisplay = _display ? _display : _rawDisplay; - - if (currentDisplay != prevDisplay) - { - _onUpdateDisplay(); - - if (prevDisplay) - { - _replaceDisplay(prevDisplay, prevChildArmature != nullptr); - } - else - { - _addDisplay(); - } - - _blendModeDirty = true; - _colorDirty = true; - } - - if (_displayDataSet && _displayIndex >= 0 && (std::size_t)_displayIndex < _displayDataSet->displays.size()) - { - this->origin = _displayDataSet->displays[_displayIndex]->transform; // copy - _originDirty = true; - } - - _updateMeshData(false); - - if (currentDisplay == _rawDisplay || currentDisplay == _meshDisplay) - { - _updateFrame(); - } - - if (_childArmature != prevChildArmature) - { - if (prevChildArmature) - { - prevChildArmature->_parent = nullptr; - if (inheritAnimation) - { - prevChildArmature->getAnimation().reset(); - } - } - - if (_childArmature) - { - _childArmature->_parent = this; - if (inheritAnimation) - { - if (_childArmature->getCacheFrameRate() == 0) - { - const auto chacheFrameRate = this->_armature->getCacheFrameRate(); - if (chacheFrameRate != 0) - { - _childArmature->setCacheFrameRate(chacheFrameRate); - } - } - - const auto slotData = this->_armature->getArmatureData().getSlot(this->name); - const auto& actions = !slotData->actions.empty() ? slotData->actions : _childArmature->getArmatureData().actions; - if (!actions.empty()) - { - for (const auto action : actions) - { - _childArmature->_bufferAction(action); - } - } - else - { - _childArmature->getAnimation().play(); - } - } - } - } -} - -void Slot::_setArmature(Armature* value) -{ - if (this->_armature == value) - { - return; - } - - if (this->_armature) - { - this->_armature->_removeSlotFromSlotList(this); - } - - this->_armature = value; - - _onUpdateDisplay(); - - if (this->_armature) - { - this->_armature->_addSlotToSlotList(this); - _addDisplay(); - } - else - { - _removeDisplay(); - } -} - -void Slot::_updateMeshData(bool isTimelineUpdate) -{ - const auto prevMeshData = _meshData; - auto rawMeshData = (MeshData*)nullptr; - if (_display && _display == _meshDisplay && _displayIndex >= 0) - { - rawMeshData = (_displayDataSet && _displayIndex < _displayDataSet->displays.size()) ? _displayDataSet->displays[_displayIndex]->mesh : nullptr; - const auto replaceDisplayData = (_displayIndex < _replacedDisplayDataSet.size()) ? _replacedDisplayDataSet[_displayIndex] : nullptr; - const auto replaceMeshData = replaceDisplayData ? replaceDisplayData->mesh : nullptr; - _meshData = replaceMeshData? replaceMeshData: rawMeshData; - } - else - { - _meshData = nullptr; - } - - if (_meshData != prevMeshData) - { - if (_meshData && _meshData == rawMeshData) - { - if (_meshData->skinned) - { - _meshBones.resize(_meshData->bones.size(), nullptr); - - for (std::size_t i = 0, l = _meshBones.size(); i < l; ++i) - { - _meshBones[i] = this->_armature->getBone(_meshData->bones[i]->name); - } - - std::size_t ffdVerticesCount = 0; - for (std::size_t i = 0, l = _meshData->boneIndices.size(); i < l; ++i) - { - ffdVerticesCount += _meshData->boneIndices[i].size(); - } - - _ffdVertices.resize(ffdVerticesCount * 2.f, 0.f); - } - else - { - _meshBones.clear(); - _ffdVertices.resize(_meshData->vertices.size(), 0.f); - } - - _ffdDirty = true; - } - else - { - _meshBones.clear(); - _ffdVertices.clear(); - } - - if (isTimelineUpdate) - { - _armature->getAnimation()._updateFFDTimelineStates(); - } - } -} - -void Slot::_update(int cacheFrameIndex) -{ - _blendIndex = 0; - - if (_displayDirty) - { - _displayDirty = false; - _updateDisplay(); - } - - if (!_display) - { - return; - } - - if (_blendModeDirty) - { - _blendModeDirty = false; - _updateBlendMode(); - } - - if (_colorDirty) - { - _colorDirty = false; - _updateColor(); - } - - if (_meshData) - { - if (_ffdDirty || (_meshData->skinned && _isMeshBonesUpdate())) - { - _ffdDirty = false; - _updateMesh(); - } - - if (_meshData->skinned) - { - return; - } - } - - if (_originDirty) - { - _originDirty = false; - _transformDirty = true; - _updateLocalTransformMatrix(); - } - - if (cacheFrameIndex >= 0) - { - const auto cacheFrame = (*_cacheFrames)[cacheFrameIndex]; - if (this->globalTransformMatrix == cacheFrame) - { - _transformDirty = false; - } - else if (cacheFrame) - { - _transformDirty = true; - this->globalTransformMatrix = cacheFrame; - } - else if (_transformDirty || this->_parent->_transformDirty != Bone::BoneTransformDirty::None) - { - _transformDirty = true; - this->globalTransformMatrix = &this->_globalTransformMatrix; - } - else if (this->globalTransformMatrix != &this->_globalTransformMatrix) - { - _transformDirty = false; - (*_cacheFrames)[cacheFrameIndex] = this->globalTransformMatrix; - } - else - { - _transformDirty = true; - this->globalTransformMatrix = &this->_globalTransformMatrix; - } - } - else if (_transformDirty || this->_parent->_transformDirty != Bone::BoneTransformDirty::None) - { - _transformDirty = true; - this->globalTransformMatrix = &this->_globalTransformMatrix; - } - - if (_transformDirty) - { - _transformDirty = false; - - if (this->globalTransformMatrix == &this->_globalTransformMatrix) - { - _updateGlobalTransformMatrix(); - - if (cacheFrameIndex >= 0 && !(*_cacheFrames)[cacheFrameIndex]) - { - this->globalTransformMatrix = SlotTimelineData::cacheFrame(*_cacheFrames, cacheFrameIndex, this->_globalTransformMatrix); - } - } - - _updateTransform(); - } -} - -bool Slot::_setDisplayList(const std::vector>& value) -{ - if (!value.empty()) - { - if (_displayList.size() != value.size()) - { - _displayList.resize(value.size()); - } - - for (std::size_t i = 0, l = value.size(); i < l; ++i) - { - const auto& eachPair = value[i]; - if ( - eachPair.first && eachPair.first != _rawDisplay && eachPair.first != _meshDisplay && - eachPair.second != DisplayType::Armature && std::find(_displayList.cbegin(), _displayList.cend(), eachPair) == _displayList.cend() - ) - { - _initDisplay(eachPair.first); - } - - _displayList[i].first = eachPair.first; - _displayList[i].second = eachPair.second; - } - } - else if (!_displayList.empty()) - { - _displayList.clear(); - } - - if (_displayIndex >= 0 && (std::size_t)_displayIndex < _displayList.size()) - { - _displayDirty = _display != _displayList[_displayIndex].first; - } - else - { - _displayDirty = _display != nullptr; - } - - return _displayDirty; -} - -bool Slot::_setDisplayIndex(int value) -{ - if (_displayIndex == value) - { - return false; - } - - _displayIndex = value; - _displayDirty = true; - - return _displayDirty; -} - -bool Slot::_setBlendMode(BlendMode value) -{ - if (_blendMode == value) - { - return false; - } - - _blendMode = value; - _blendModeDirty = true; - - return true; -} - -bool Slot::_setColor(const ColorTransform& value) -{ - _colorTransform = value; // copy - _colorDirty = true; - - return true; -} - -void Slot::setDisplayIndex(int value) -{ - if (_setDisplayIndex(value)) - { - _update(-1); - } -} - -void Slot::setDisplayList(const std::vector>& value) -{ - const auto backupDisplayList = _displayList; // copy - auto disposeDisplayList = backupDisplayList; // copy - disposeDisplayList.clear(); - - if (_setDisplayList(value)) - { - _update(-1); - } - - for (const auto& pair : backupDisplayList) - { - if ( - pair.first && pair.first != _rawDisplay && pair.first != _meshDisplay && - std::find(_displayList.cbegin(), _displayList.cend(), pair) == _displayList.cend() && - std::find(disposeDisplayList.cbegin(), disposeDisplayList.cend(), pair) == disposeDisplayList.cend() - ) - { - disposeDisplayList.push_back(pair); - } - } - - for (const auto& pair : disposeDisplayList) - { - if (pair.second == DisplayType::Armature) - { - static_cast(pair.first)->returnToPool(); - } - else - { - _disposeDisplay(pair.first); - } - } -} - -void Slot::setDisplay(void* value, DisplayType displayType) -{ - if (_display == value) - { - return; - } - - const auto displayListLength = _displayList.size(); - if (_displayIndex < 0 && displayListLength == 0) // Emprty - { - _displayIndex = 0; - } - - if (_displayIndex < 0) - { - return; - } - else - { - auto relpaceDisplayList = _displayList; // copy - if (displayListLength <= (std::size_t)_displayIndex) - { - relpaceDisplayList.resize(_displayIndex + 1); - } - - relpaceDisplayList[_displayIndex].first = value; - relpaceDisplayList[_displayIndex].second = displayType; - - setDisplayList(relpaceDisplayList); - } -} - -void Slot::setChildArmature(Armature* value) -{ - if (_childArmature == value) - { - return; - } - - if (value) - { - (value->getDisplay())->advanceTimeBySelf(false); - } - - setDisplay(value, DisplayType::Armature); -} - -DRAGONBONES_NAMESPACE_END \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/armature/Slot.h b/native/cocos/editor-support/dragonbones/armature/Slot.h deleted file mode 100644 index 0338ba0f8e..0000000000 --- a/native/cocos/editor-support/dragonbones/armature/Slot.h +++ /dev/null @@ -1,171 +0,0 @@ -#ifndef DRAGONBONES_SLOT_H -#define DRAGONBONES_SLOT_H - -#include "TransformObject.h" -#include "../model/ArmatureData.h" -#include "Bone.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class Slot : public TransformObject -{ -public: - bool inheritAnimation; - std::string displayController; - -public: // private friend class - /** @private */ - bool _colorDirty; - /** @private */ - bool _ffdDirty; - /** @private */ - int _blendIndex; - /** @private */ - int _zOrder; - /** @private */ - BlendMode _blendMode; - /** @private */ - float _pivotX; - /** @private */ - float _pivotY; - /** @private */ - SlotDisplayDataSet* _displayDataSet; - /** @private */ - MeshData* _meshData; - /** @private */ - std::vector* _cacheFrames; - /** @private */ - void* _rawDisplay; - /** @private */ - void* _meshDisplay; - /** @private */ - ColorTransform _colorTransform; - /** @private */ - std::vector _ffdVertices; - /** @private */ - std::vector _replacedDisplayDataSet; - -protected: - bool _displayDirty; - bool _blendModeDirty; - bool _originDirty; - bool _transformDirty; - int _displayIndex; - void* _display; - Armature* _childArmature; - Matrix _localMatrix; - std::vector> _displayList; - std::vector _meshBones; - -public: - /** @private */ - Slot(); - /** @private */ - virtual ~Slot() = 0; - -protected: - void _onClear() override; - - virtual void _initDisplay(void* value) = 0; - virtual void _disposeDisplay(void* value) = 0; - virtual void _onUpdateDisplay() = 0; - virtual void _addDisplay() = 0; - virtual void _replaceDisplay(void* value, bool isArmatureDisplayContainer) = 0; - virtual void _removeDisplay() = 0; - virtual void _updateColor() = 0; - virtual void _updateFilters() = 0; - virtual void _updateFrame() = 0; - virtual void _updateMesh() = 0; - virtual void _updateTransform() = 0; - void _updateDisplay(); - - inline bool _isMeshBonesUpdate() const - { - for (auto bone : _meshBones) - { - if (bone->_transformDirty != Bone::BoneTransformDirty::None) - { - return true; - } - } - - return false; - } - - inline void _updateLocalTransformMatrix() - { - this->global = this->origin; - this->global.add(this->offset).toMatrix(_localMatrix); - } - - inline void _updateGlobalTransformMatrix() - { - *this->globalTransformMatrix = _localMatrix; // copy - this->globalTransformMatrix->concat(*this->_parent->globalTransformMatrix); - this->global.fromMatrix(*this->globalTransformMatrix); - } - -public: - /** @private */ - virtual void _updateVisible() = 0; - /** @private */ - virtual void _updateBlendMode() = 0; - - /** @private */ - virtual void _setArmature(Armature* value) override; - /** @private */ - void _updateMeshData(bool isTimelineUpdate); - /** @private */ - void _update(int cacheFrameIndex); - /** @private */ - bool _setDisplayList(const std::vector>& value); - /** @private */ - bool _setDisplayIndex(int value); - /** @private */ - bool _setBlendMode(BlendMode value); - /** @private */ - bool _setColor(const ColorTransform& value); - -public: - inline void invalidUpdate() - { - _displayDirty = true; - } - - inline void* getRawDisplay() const - { - return _rawDisplay; - } - - inline void* getMeshDisplay() const - { - return _meshDisplay; - } - - inline int getDisplayIndex() const - { - return _displayIndex; - } - void setDisplayIndex(int value); - - inline const std::vector>& getDisplayList() const - { - return _displayList; - } - void setDisplayList(const std::vector>& value); - - inline void* getDisplay() const - { - return _display; - } - void setDisplay(void* value, DisplayType displayType); - - inline Armature* getChildArmature() const - { - return _childArmature; - } - void setChildArmature(Armature* value); -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_SLOT_H diff --git a/native/cocos/editor-support/dragonbones/armature/TransformObject.h b/native/cocos/editor-support/dragonbones/armature/TransformObject.h deleted file mode 100644 index 886daa6534..0000000000 --- a/native/cocos/editor-support/dragonbones/armature/TransformObject.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef DRAGONBONES_TRANSFORM_OBJECT_H -#define DRAGONBONES_TRANSFORM_OBJECT_H - -#include "../core/BaseObject.h" -#include "../geom/Matrix.h" -#include "../geom/Transform.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class Armature; -class Bone; -class Slot; - -class TransformObject : public BaseObject // ABSTRACT -{ -public: - void* userData; - std::string name; - Matrix* globalTransformMatrix; - Transform global; - Transform origin; - Transform offset; - -public: - /** @private */ - Armature* _armature; - /** @private */ - Bone* _parent; - -protected: - Matrix _globalTransformMatrix; - -public: - /** @private */ - TransformObject() {} - /** @private */ - virtual ~TransformObject() {}; - -protected: - void _onClear() override - { - userData = nullptr; - name.clear(); - globalTransformMatrix = &_globalTransformMatrix; - global.identity(); - origin.identity(); - offset.identity(); - - _armature = nullptr; - _parent = nullptr; - _globalTransformMatrix.identity(); - } - -public: - /** @private */ - virtual void _setArmature(Armature* value) - { - _armature = value; - } - - /** @private */ - virtual void _setParent(Bone* value) - { - _parent = value; - } - -public: - inline Armature* getArmature() const - { - return _armature; - } - - inline Bone* getParent() const - { - return _parent; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_TRANSFORM_OBJECT_H diff --git a/native/cocos/editor-support/dragonbones/cocos2dx/CCArmatureDisplay.cpp b/native/cocos/editor-support/dragonbones/cocos2dx/CCArmatureDisplay.cpp deleted file mode 100644 index adfa819531..0000000000 --- a/native/cocos/editor-support/dragonbones/cocos2dx/CCArmatureDisplay.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include "CCArmatureDisplay.h" -#include "editor-support/creator/CCCameraNode.h" - -DRAGONBONES_NAMESPACE_BEGIN - -CCArmatureDisplay* CCArmatureDisplay::create() -{ - CCArmatureDisplay* displayContainer = new (std::nothrow) CCArmatureDisplay(); - - if (displayContainer && displayContainer->init()) - { - displayContainer->autorelease(); - } - else - { - CC_SAFE_DELETE(displayContainer); - } - - return displayContainer; -} - -CCArmatureDisplay::CCArmatureDisplay() : - _armature(nullptr), - _dispatcher(nullptr), - _eventCallback(nullptr) -{ - _dispatcher = new cocos2d::EventDispatcher(); - this->setEventDispatcher(_dispatcher); - _dispatcher->setEnabled(true); -} -CCArmatureDisplay::~CCArmatureDisplay() {} - -// cleared by armature -void CCArmatureDisplay::_onClear() -{ - this->setEventDispatcher(cocos2d::Director::getInstance()->getEventDispatcher()); - clearEventCallback(); - _armature = nullptr; - this->release(); -} - -void CCArmatureDisplay::_dispatchEvent(EventObject* value) -{ - if (_eventCallback) { - _eventCallback(value); - } - - if (_dispatcher->isEnabled()) { - _dispatcher->dispatchCustomEvent(value->type, value); - } -} - -void CCArmatureDisplay::dispose() -{ - if (_armature) - { - advanceTimeBySelf(false); - _armature->dispose(); - _armature = nullptr; - } -} - -void CCArmatureDisplay::update(float passedTime) -{ - _armature->advanceTime(passedTime); -} - -void CCArmatureDisplay::advanceTimeBySelf(bool on) -{ - if (on) - { - scheduleUpdate(); - } - else - { - unscheduleUpdate(); - } -} - -void CCArmatureDisplay::addEvent(const std::string& type, const std::function& callback) -{ - auto lambda = [callback](cocos2d::EventCustom* event) -> void { - callback(static_cast(event->getUserData())); - }; - _dispatcher->addCustomEventListener(type, lambda); -} - -void CCArmatureDisplay::removeEvent(const std::string& type) -{ - _dispatcher->removeCustomEventListeners(type); -} - -DBCCSprite* DBCCSprite::create() -{ - DBCCSprite* sprite = new (std::nothrow) DBCCSprite(); - - if (sprite && sprite->init()) - { - sprite->autorelease(); - } - else - { - CC_SAFE_DELETE(sprite); - } - - return sprite; -} - -DBCCSprite::DBCCSprite() -{ -} -DBCCSprite::~DBCCSprite() {} - -cocos2d::Vec2 DBCCSprite::projectGL(const cocos2d::Vec3& src) const -{ - cocos2d::Vec2 screenPos; - - auto director = cocos2d::Director::getInstance(); - auto viewport = director->getWinSize(); - cocos2d::Vec4 clipPos; - auto projMatrix = director->getMatrix(cocos2d::MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - projMatrix.transformVector(cocos2d::Vec4(src.x, src.y, src.z, 1.0f), &clipPos); - - CCASSERT(clipPos.w != 0.0f, "clipPos.w can't be 0.0f!"); - float ndcX = clipPos.x / clipPos.w; - float ndcY = clipPos.y / clipPos.w; - - screenPos.x = (ndcX + 1.0f) * 0.5f * viewport.width; - screenPos.y = (ndcY + 1.0f) * 0.5f * viewport.height; - return screenPos; -} - -bool DBCCSprite::_checkVisibility(const cocos2d::Mat4& transform, const cocos2d::Size& size, const cocos2d::Rect& rect) -{ - auto director = cocos2d::Director::getInstance(); - - creator::CameraNode* camera = creator::CameraNode::getInstance(); - cocos2d::Rect visibleRect; - if (!camera || camera->visitingIndex <= 0) { - visibleRect.origin = director->getVisibleOrigin(); - visibleRect.size = director->getVisibleSize(); - } - else { - visibleRect = camera->getVisibleRect(); - } - - // transform center point to screen space - float hSizeX = size.width / 2; - float hSizeY = size.height / 2; - - cocos2d::Vec3 v3p(hSizeX + rect.origin.x, hSizeY + rect.origin.y, 0); - - transform.transformPoint(&v3p); - cocos2d::Vec2 v2p = projectGL(v3p); - - // convert content size to world coordinates - float wshw = std::max(fabsf(hSizeX * transform.m[0] + hSizeY * transform.m[4]), fabsf(hSizeX * transform.m[0] - hSizeY * transform.m[4])); - float wshh = std::max(fabsf(hSizeX * transform.m[1] + hSizeY * transform.m[5]), fabsf(hSizeX * transform.m[1] - hSizeY * transform.m[5])); - - // enlarge visible rect half size in screen coord - visibleRect.origin.x -= wshw; - visibleRect.origin.y -= wshh; - visibleRect.size.width += wshw * 2; - visibleRect.size.height += wshh * 2; - bool ret = visibleRect.containsPoint(v2p); - return ret; -} - -void DBCCSprite::draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) -{ - if (_director->isCullingEnabled()) { - // Don't calculate the culling if the transform was not updated - if (flags & FLAGS_TRANSFORM_DIRTY || flags & FLAGS_CULLING_DIRTY) - { - _insideBounds = _checkVisibility(transform, _contentSize, this->_polyInfo.rect); - } - } - else { - _insideBounds = true; - } - - if (_insideBounds) - { - _trianglesCommand.init(_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, _polyInfo.triangles, transform, flags); - renderer->addCommand(&_trianglesCommand); - -#if CC_SPRITE_DEBUG_DRAW - _debugDrawNode->clear(); - auto count = _polyInfo.triangles.indexCount / 3; - auto indices = _polyInfo.triangles.indices; - auto verts = _polyInfo.triangles.verts; - for (ssize_t i = 0; i < count; i++) - { - //draw 3 lines - auto from = verts[indices[i * 3]].vertices; - auto to = verts[indices[i * 3 + 1]].vertices; - _debugDrawNode->drawLine(cocos2d::Vec2(from.x, from.y), cocos2d::Vec2(to.x, to.y), cocos2d::Color4F::WHITE); - - from = verts[indices[i * 3 + 1]].vertices; - to = verts[indices[i * 3 + 2]].vertices; - _debugDrawNode->drawLine(cocos2d::Vec2(from.x, from.y), cocos2d::Vec2(to.x, to.y), cocos2d::Color4F::WHITE); - - from = verts[indices[i * 3 + 2]].vertices; - to = verts[indices[i * 3]].vertices; - _debugDrawNode->drawLine(cocos2d::Vec2(from.x, from.y), cocos2d::Vec2(to.x, to.y), cocos2d::Color4F::WHITE); - } -#endif //CC_SPRITE_DEBUG_DRAW - } -} - -cocos2d::PolygonInfo& DBCCSprite::getPolygonInfoModify() -{ - return this->_polyInfo; -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/cocos2dx/CCArmatureDisplay.h b/native/cocos/editor-support/dragonbones/cocos2dx/CCArmatureDisplay.h deleted file mode 100644 index e6ca45efe4..0000000000 --- a/native/cocos/editor-support/dragonbones/cocos2dx/CCArmatureDisplay.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef DRAGONBONES_CC_ARMATURE_DISPLAY_CONTAINER_H -#define DRAGONBONES_CC_ARMATURE_DISPLAY_CONTAINER_H - -#include "dragonbones/DragonBonesHeaders.h" -#include "cocos2d.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class CCArmatureDisplay : public cocos2d::Node, public IArmatureDisplay -{ -public: - /** @private */ - static CCArmatureDisplay* create(); - -public: - /** @private */ - Armature* _armature; - -protected: - cocos2d::EventDispatcher* _dispatcher; - -protected: - CCArmatureDisplay(); - virtual ~CCArmatureDisplay(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(CCArmatureDisplay); - -public: - /** @private */ - virtual void _onClear() override; - /** @private */ - virtual void _dispatchEvent(EventObject* value) override; - /** @private */ - virtual void dispose() override; - /** @private */ - virtual void update(float passedTime) override; - -public: - virtual void advanceTimeBySelf(bool on) override; - - void addEvent(const std::string& type, const std::function& callback); - void removeEvent(const std::string& type); - - inline bool hasEvent(const std::string& type) const override - { - return _eventCallback || _dispatcher->isEnabled(); - } - - inline Armature* getArmature() const override - { - return _armature; - } - - virtual Animation& getAnimation() const override - { - return _armature->getAnimation(); - } - -CC_CONSTRUCTOR_ACCESS: - // methods added for js bindings - void setEventCallback(const std::function& callback) { - this->_eventCallback = callback; - } - inline bool hasEventCallback() { return this->_eventCallback ? true : false; } - inline void clearEventCallback() { this->_eventCallback = nullptr; } - -private: - // added for js bindings - std::function _eventCallback; -}; - -/** @private */ -class DBCCSprite : public cocos2d::Sprite -{ -public: - /** @private */ - static DBCCSprite* create(); - -protected: - DBCCSprite(); - virtual ~DBCCSprite(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(DBCCSprite); - - /** - * Modify for polyInfo rect - */ - bool _checkVisibility(const cocos2d::Mat4& transform, const cocos2d::Size& size, const cocos2d::Rect& rect); - - cocos2d::Vec2 projectGL(const cocos2d::Vec3& src) const; - -public: - /** - * Modify for polyInfo rect - */ - virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) override; - /** - * Modify for cocos2dx 3.7, 3.8, 3.9 - */ - cocos2d::PolygonInfo& getPolygonInfoModify(); -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_CC_ARMATURE_DISPLAY_CONTAINER_H diff --git a/native/cocos/editor-support/dragonbones/cocos2dx/CCDragonBonesHeaders.h b/native/cocos/editor-support/dragonbones/cocos2dx/CCDragonBonesHeaders.h deleted file mode 100644 index 7b6126e3b5..0000000000 --- a/native/cocos/editor-support/dragonbones/cocos2dx/CCDragonBonesHeaders.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef DRAGONBONES_CC_HEADERS_H -#define DRAGONBONES_CC_HEADERS_H - -#include "CCTextureData.h" -#include "CCArmatureDisplay.h" -#include "CCSlot.h" -#include "CCFactory.h" - -#endif // DRAGONBONES_CC_HEADERS_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/cocos2dx/CCFactory.cpp b/native/cocos/editor-support/dragonbones/cocos2dx/CCFactory.cpp deleted file mode 100644 index dc5f6c42f9..0000000000 --- a/native/cocos/editor-support/dragonbones/cocos2dx/CCFactory.cpp +++ /dev/null @@ -1,269 +0,0 @@ -#include "CCFactory.h" -#include "CCTextureData.h" -#include "CCArmatureDisplay.h" -#include "CCSlot.h" - -DRAGONBONES_NAMESPACE_BEGIN - -CCFactory CCFactory::factory; - -CCFactory::CCFactory() -{ - if (!EventObject::_soundEventManager) - { - const auto display = CCArmatureDisplay::create(); - display->retain(); - - EventObject::_soundEventManager = display; - } -} -CCFactory::~CCFactory() -{ - clear(); -} - -TextureAtlasData * CCFactory::_generateTextureAtlasData(TextureAtlasData* textureAtlasData, void* textureAtlas) const -{ - if (textureAtlasData) - { - static_cast(textureAtlasData)->texture = (cocos2d::Texture2D*)textureAtlas; - } - else - { - textureAtlasData = BaseObject::borrowObject(); - } - - return textureAtlasData; -} - -Armature * CCFactory::_generateArmature(const BuildArmaturePackage & dataPackage) const -{ - const auto armature = BaseObject::borrowObject(); - const auto armatureDisplay = CCArmatureDisplay::create(); - - armature->_armatureData = dataPackage.armature; - armature->_skinData = dataPackage.skin; - armature->_animation = BaseObject::borrowObject(); - armature->_display = armatureDisplay; - - armatureDisplay->retain(); - armatureDisplay->setCascadeOpacityEnabled(true); - armatureDisplay->setCascadeColorEnabled(true); - armatureDisplay->_armature = armature; - armature->_animation->_armature = armature; - - armature->getAnimation().setAnimations(dataPackage.armature->animations); - - return armature; -} - -Slot * CCFactory::_generateSlot(const BuildArmaturePackage& dataPackage, const SlotDisplayDataSet& slotDisplayDataSet) const -{ - const auto slot = BaseObject::borrowObject(); - const auto slotData = slotDisplayDataSet.slot; - std::vector> displayList; - const auto rawDisplay = DBCCSprite::create(); - - slot->name = slotData->name; - slot->_rawDisplay = rawDisplay; - slot->_meshDisplay = slot->_rawDisplay; - - displayList.reserve(slotDisplayDataSet.displays.size()); - rawDisplay->retain(); - rawDisplay->setCascadeOpacityEnabled(true); - rawDisplay->setCascadeColorEnabled(true); - rawDisplay->setAnchorPoint(cocos2d::Vec2::ZERO); - - for (const auto displayData : slotDisplayDataSet.displays) - { - switch (displayData->type) - { - case DisplayType::Image: - if (!displayData->texture) - { - displayData->texture = this->_getTextureData(dataPackage.dataName, displayData->name); - } - - displayList.push_back(std::make_pair(slot->_rawDisplay, DisplayType::Image)); - break; - - case DisplayType::Mesh: - if (!displayData->texture) - { - displayData->texture = this->_getTextureData(dataPackage.dataName, displayData->name); - } - - displayList.push_back(std::make_pair(slot->_meshDisplay, DisplayType::Mesh)); - break; - - case DisplayType::Armature: - { - const auto childArmature = buildArmature(displayData->name, dataPackage.dataName); - if (childArmature) - { - childArmature->getAnimation().play(); - } - - displayList.push_back(std::make_pair(childArmature, DisplayType::Armature)); - break; - } - - default: - displayList.push_back(std::make_pair(nullptr, DisplayType::Image)); - break; - } - } - - slot->_setDisplayList(displayList); - - rawDisplay->setLocalZOrder(slotData->zOrder); - - return slot; -} - -DragonBonesData* CCFactory::loadDragonBonesData(const std::string& filePath, const std::string& dragonBonesName) -{ - if (!dragonBonesName.empty()) - { - const auto existedData = this->getDragonBonesData(dragonBonesName); - if (existedData) - { - return existedData; - } - } - - const auto fullpath = cocos2d::FileUtils::getInstance()->fullPathForFilename(filePath); - const auto data = cocos2d::FileUtils::getInstance()->getStringFromFile(fullpath); - if (data.empty()) - { - return nullptr; - } - - const auto scale = cocos2d::Director::getInstance()->getContentScaleFactor(); - return this->parseDragonBonesData(data.c_str(), dragonBonesName, 1.f / scale); -} - -TextureAtlasData* CCFactory::loadTextureAtlasData(const std::string& filePath, const std::string& dragonBonesName, float scale) -{ - const auto fullpath = cocos2d::FileUtils::getInstance()->fullPathForFilename(filePath); - const auto data = cocos2d::FileUtils::getInstance()->getStringFromFile(fullpath); - if (data.empty()) - { - return nullptr; - } - - const auto textureAtlasData = static_cast(BaseFactory::parseTextureAtlasData(data.c_str(), nullptr, dragonBonesName, scale)); - - const auto pos = filePath.find_last_of("/"); - if (std::string::npos != pos) - { - const auto basePath = filePath.substr(0, pos + 1); - textureAtlasData->imagePath = basePath + textureAtlasData->imagePath; - } - - _initTextureAtlasData(textureAtlasData); - - return textureAtlasData; -} - -TextureAtlasData* CCFactory::parseTextureAtlasData(const std::string& atlasData, cocos2d::Texture2D* texture, const std::string& dragonBonesName, float scale) -{ - return static_cast(BaseFactory::parseTextureAtlasData(atlasData.c_str(), texture, dragonBonesName, scale)); -} - -TextureAtlasData* CCFactory::parseTextureAtlasData(const std::string& atlasData, const std::string& texturePath, const std::string& dragonBonesName, float scale) -{ - const auto textureAtlasData = static_cast(BaseFactory::parseTextureAtlasData(atlasData.c_str(), nullptr, dragonBonesName, scale)); - textureAtlasData->imagePath = texturePath; - _initTextureAtlasData(textureAtlasData); - - return textureAtlasData; - -} - -void CCFactory::_initTextureAtlasData(TextureAtlasData* atlasData) -{ - const auto textureCache = cocos2d::Director::getInstance()->getTextureCache(); - auto texture = textureCache->getTextureForKey(atlasData->imagePath); - if (!texture) - { - const auto defaultPixelFormat = cocos2d::Texture2D::getDefaultAlphaPixelFormat(); - auto pixelFormat = defaultPixelFormat; - switch (atlasData->format) - { - case TextureFormat::RGBA8888: - pixelFormat = cocos2d::Texture2D::PixelFormat::RGBA8888; - break; - - case TextureFormat::BGRA8888: - pixelFormat = cocos2d::Texture2D::PixelFormat::BGRA8888; - break; - - case TextureFormat::RGBA4444: - pixelFormat = cocos2d::Texture2D::PixelFormat::RGBA4444; - break; - - case TextureFormat::RGB888: - pixelFormat = cocos2d::Texture2D::PixelFormat::RGB888; - break; - - case TextureFormat::RGB565: - pixelFormat = cocos2d::Texture2D::PixelFormat::RGB565; - break; - - case TextureFormat::RGBA5551: - pixelFormat = cocos2d::Texture2D::PixelFormat::RGB5A1; - break; - - case TextureFormat::DEFAULT: - default: - break; - } - - cocos2d::Texture2D::setDefaultAlphaPixelFormat(pixelFormat); - texture = textureCache->addImage(atlasData->imagePath); - cocos2d::Texture2D::setDefaultAlphaPixelFormat(defaultPixelFormat); - } - - static_cast(atlasData)->texture = texture; -} - -CCArmatureDisplay * CCFactory::buildArmatureDisplay(const std::string& armatureName, const std::string& dragonBonesName, const std::string& skinName) const -{ - const auto armature = this->buildArmature(armatureName, dragonBonesName, skinName); - const auto armatureDisplay = armature ? dynamic_cast(armature->_display) : nullptr; - if (armatureDisplay) - { - armatureDisplay->advanceTimeBySelf(true); - } - - return armatureDisplay; -} - -cocos2d::Sprite* CCFactory::getTextureDisplay(const std::string& textureName, const std::string& dragonBonesName) const -{ - const auto textureData = static_cast(this->_getTextureData(dragonBonesName, textureName)); - if (textureData) - { - if (!textureData->texture) - { - const auto textureAtlasTexture = static_cast(textureData->parent)->texture; - cocos2d::Rect rect(textureData->region.x, textureData->region.y, textureData->region.width, textureData->region.height); - cocos2d::Vec2 offset(0.f, 0.f); - cocos2d::Size originSize(textureData->region.width, textureData->region.height); - textureData->texture = cocos2d::SpriteFrame::createWithTexture(textureAtlasTexture, rect, textureData->rotated, offset, originSize); // TODO multiply textureAtlas - textureData->texture->retain(); - } - - return cocos2d::Sprite::createWithSpriteFrame(textureData->texture); - } - - return nullptr; -} - -CCArmatureDisplay* CCFactory::getSoundEventManater() const -{ - return dynamic_cast(static_cast(EventObject::_soundEventManager)); -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/cocos2dx/CCFactory.h b/native/cocos/editor-support/dragonbones/cocos2dx/CCFactory.h deleted file mode 100644 index 3b73259dc8..0000000000 --- a/native/cocos/editor-support/dragonbones/cocos2dx/CCFactory.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef DRAGONBONES_CC_FACTORY_H -#define DRAGONBONES_CC_FACTORY_H - -#include "dragonbones/DragonBonesHeaders.h" -#include "cocos2d.h" -#include "CCArmatureDisplay.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class CCFactory : public BaseFactory -{ -public: - static CCFactory factory; - -public: - CCFactory(); - ~CCFactory(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(CCFactory); - -protected: - virtual TextureAtlasData* _generateTextureAtlasData(TextureAtlasData* textureAtlasData, void* textureAtlas) const override; - virtual Armature* _generateArmature(const BuildArmaturePackage& dataPackage) const override; - virtual Slot* _generateSlot(const BuildArmaturePackage& dataPackage, const SlotDisplayDataSet& slotDisplayDataSet) const override; - -public: - virtual DragonBonesData* loadDragonBonesData(const std::string& filePath, const std::string& dragonBonesName = ""); - virtual TextureAtlasData* loadTextureAtlasData(const std::string& filePath, const std::string& dragonBonesName = "", float scale = 0.f); - virtual TextureAtlasData* parseTextureAtlasData(const std::string& atlasData, cocos2d::Texture2D* texture, const std::string& dragonBonesName = "", float scale = 0.f); - virtual TextureAtlasData* parseTextureAtlasData(const std::string& atlasData, const std::string& texturePath, const std::string& dragonBonesName = "", float scale = 0.f); - virtual CCArmatureDisplay* buildArmatureDisplay(const std::string& armatureName, const std::string& dragonBonesName = "", const std::string& skinName = "") const; - virtual cocos2d::Sprite* getTextureDisplay(const std::string& textureName, const std::string& dragonBonesName = "") const; - virtual CCArmatureDisplay* getSoundEventManater() const; - -private: - void _initTextureAtlasData(TextureAtlasData* atlasData); -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_CC_FACTORY_H diff --git a/native/cocos/editor-support/dragonbones/cocos2dx/CCSlot.cpp b/native/cocos/editor-support/dragonbones/cocos2dx/CCSlot.cpp deleted file mode 100644 index 3a2cd84ff9..0000000000 --- a/native/cocos/editor-support/dragonbones/cocos2dx/CCSlot.cpp +++ /dev/null @@ -1,454 +0,0 @@ -#include "CCSlot.h" -#include "CCTextureData.h" -#include "CCArmatureDisplay.h" - -DRAGONBONES_NAMESPACE_BEGIN - -CCSlot::CCSlot() -{ - _onClear(); -} -CCSlot::~CCSlot() -{ - _onClear(); -} - -void CCSlot::_onClear() -{ - Slot::_onClear(); - - _renderDisplay = nullptr; -} - -void CCSlot::_initDisplay(void* value) -{ - const auto renderDisplay = static_cast(value); - renderDisplay->retain(); -} - -void CCSlot::_disposeDisplay(void* value) -{ - const auto renderDisplay = static_cast(value); - renderDisplay->release(); -} - -void CCSlot::_onUpdateDisplay() -{ - if (!this->_rawDisplay) - { - // TODO - } - - if (this->_display) - { - if (this->_childArmature) - { - _renderDisplay = dynamic_cast(static_cast(this->_display)); - } - else - { - _renderDisplay = static_cast(this->_display); - } - } - else - { - _renderDisplay = static_cast(this->_rawDisplay); - } -} - -void CCSlot::_addDisplay() -{ - const auto container = dynamic_cast(this->_armature->_display); - container->addChild(_renderDisplay); -} - -void CCSlot::_replaceDisplay(void* value, bool isArmatureDisplayContainer) -{ - const auto container = dynamic_cast(this->_armature->_display); - const auto prevDisplay = isArmatureDisplayContainer ? dynamic_cast(static_cast(value)) : static_cast(value); // static_cast(isArmatureDisplayContainer ? static_cast(value) : value); // WTF - container->addChild(_renderDisplay, prevDisplay->getLocalZOrder()); - container->removeChild(prevDisplay); -} - -void CCSlot::_removeDisplay() -{ - _renderDisplay->removeFromParent(); -} - -void CCSlot::_updateVisible() -{ - this->_renderDisplay->setVisible(this->_parent->getVisible()); -} - -void CCSlot::_updateBlendMode() -{ - cocos2d::Sprite* spriteDisplay = dynamic_cast(_renderDisplay); - if (spriteDisplay) - { - switch (this->_blendMode) - { - case BlendMode::Normal: - //spriteDisplay->setBlendFunc(cocos2d::BlendFunc::DISABLE); - break; - - case BlendMode::Add: - { - const auto texture = spriteDisplay->getTexture(); - if (texture && texture->hasPremultipliedAlpha()) - { - cocos2d::BlendFunc blendFunc = { GL_ONE, GL_ONE }; - spriteDisplay->setBlendFunc(blendFunc); - } - else - { - spriteDisplay->setBlendFunc(cocos2d::BlendFunc::ADDITIVE); - } - break; - } - - default: - break; - } - } - else if (this->_childArmature) - { - for (const auto slot : this->_childArmature->getSlots()) - { - slot->_blendMode = this->_blendMode; - slot->_updateBlendMode(); - } - } -} - -void CCSlot::_updateColor() -{ - _renderDisplay->setOpacity(this->_colorTransform.alphaMultiplier * 255.f); - static cocos2d::Color3B helpColor; - helpColor.r = this->_colorTransform.redMultiplier * 255.f; - helpColor.g = this->_colorTransform.greenMultiplier * 255.f; - helpColor.b = this->_colorTransform.blueMultiplier * 255.f; - _renderDisplay->setColor(helpColor); -} - -void CCSlot::_updateFilters() -{ -} - -void CCSlot::_updateFrame() -{ - const auto frameDisplay = (DBCCSprite*)(this->_rawDisplay); - - if (this->_display && this->_displayIndex >= 0) - { - const unsigned displayIndex = this->_displayIndex; - const auto rawDisplayData = displayIndex < this->_displayDataSet->displays.size() ? this->_displayDataSet->displays[displayIndex] : nullptr; - const auto replacedDisplayData = displayIndex < this->_replacedDisplayDataSet.size() ? this->_replacedDisplayDataSet[displayIndex] : nullptr; - const auto currentDisplayData = replacedDisplayData ? replacedDisplayData : rawDisplayData; - const auto currentTextureData = static_cast(currentDisplayData->texture); - - if (currentTextureData) - { - const auto textureAtlasTexture = static_cast(currentTextureData->parent)->texture; - if (!currentTextureData->texture && textureAtlasTexture) - { - cocos2d::Rect rect(currentTextureData->region.x, currentTextureData->region.y, currentTextureData->region.width, currentTextureData->region.height); - cocos2d::Vec2 offset(0.f, 0.f); - cocos2d::Size originSize(currentTextureData->region.width, currentTextureData->region.height); - - currentTextureData->texture = cocos2d::SpriteFrame::createWithTexture(textureAtlasTexture, rect, currentTextureData->rotated, offset, originSize); // TODO multiply textureAtlas - currentTextureData->texture->retain(); - } - - const auto texture = this->_armature->_replacedTexture ? static_cast(this->_armature->_replacedTexture) : (currentTextureData->texture ? currentTextureData->texture->getTexture() : nullptr); - - if (this->_meshData && this->_display == this->_meshDisplay) - { - const auto& region = currentTextureData->region; - const auto& textureAtlasSize = currentTextureData->texture->getTexture()->getContentSizeInPixels(); - auto displayVertices = new cocos2d::V3F_C4B_T2F[(unsigned)(this->_meshData->uvs.size() / 2)]; // does cocos2dx release it? - auto vertexIndices = new unsigned short[this->_meshData->vertexIndices.size()]; // does cocos2dx release it? - cocos2d::Rect boundsRect(999999.f, 999999.f, -999999.f, -999999.f); - - if (this->_meshData != rawDisplayData->mesh && rawDisplayData && rawDisplayData != currentDisplayData) - { - this->_pivotX = rawDisplayData->transform.x - currentDisplayData->transform.x; - this->_pivotY = rawDisplayData->transform.y - currentDisplayData->transform.y; - } - else - { - this->_pivotX = 0.f; - this->_pivotY = 0.f; - } - - for (std::size_t i = 0, l = this->_meshData->uvs.size(); i < l; i += 2) - { - const auto iH = (unsigned)(i / 2); - const auto x = this->_meshData->vertices[i]; - const auto y = this->_meshData->vertices[i + 1]; - cocos2d::V3F_C4B_T2F vertexData; - vertexData.vertices.set(x, -y, 0.f); - vertexData.texCoords.u = (region.x + this->_meshData->uvs[i] * region.width) / textureAtlasSize.width; - vertexData.texCoords.v = (region.y + this->_meshData->uvs[i + 1] * region.height) / textureAtlasSize.height; - vertexData.colors = cocos2d::Color4B::WHITE; - displayVertices[iH] = vertexData; - - if (boundsRect.origin.x > x) - { - boundsRect.origin.x = x; - } - - if (boundsRect.size.width < x) - { - boundsRect.size.width = x; - } - - if (boundsRect.origin.y > -y) - { - boundsRect.origin.y = -y; - } - - if (boundsRect.size.height < -y) - { - boundsRect.size.height = -y; - } - } - - boundsRect.size.width -= boundsRect.origin.x; - boundsRect.size.height -= boundsRect.origin.y; - - for (std::size_t i = 0, l = this->_meshData->vertexIndices.size(); i < l; ++i) - { - vertexIndices[i] = this->_meshData->vertexIndices[i]; - } - - // In cocos2dx render meshDisplay and frameDisplay are the same display - if (currentTextureData->texture) - { - frameDisplay->setSpriteFrame(currentTextureData->texture); // polygonInfo will be override - if (texture != currentTextureData->texture->getTexture()) - { - frameDisplay->setTexture(texture); // Relpace texture // polygonInfo will be override - } - } - - // - cocos2d::PolygonInfo polygonInfo; - auto& triangles = polygonInfo.triangles; - triangles.verts = displayVertices; - triangles.indices = vertexIndices; - triangles.vertCount = (unsigned)(this->_meshData->uvs.size() / 2); - triangles.indexCount = (unsigned)(this->_meshData->vertexIndices.size()); -#if COCOS2D_VERSION >= 0x00031400 - polygonInfo.setRect(boundsRect); -#else - polygonInfo.rect = boundsRect; // Copy -#endif - frameDisplay->setContentSize(boundsRect.size); - frameDisplay->setPolygonInfo(polygonInfo); - frameDisplay->setColor(frameDisplay->getColor()); // Backup - - if (this->_meshData->skinned) - { - frameDisplay->setPosition(0.f, 0.f); - frameDisplay->setRotation(0.f); - frameDisplay->setRotationSkewX(0.f); - frameDisplay->setRotationSkewY(0.f); - frameDisplay->setScale(1.f, 1.f); - } - } - else - { - const auto scale = this->_armature->getArmatureData().scale; - this->_pivotX = currentDisplayData->pivot.x; - this->_pivotY = currentDisplayData->pivot.y; - - if (currentDisplayData->isRelativePivot) - { - const auto& rectData = currentTextureData->frame ? *currentTextureData->frame : currentTextureData->region; - auto width = rectData.width * scale; - auto height = rectData.height * scale; - if (!currentTextureData->frame && currentTextureData->rotated) - { - width = rectData.height; - height = rectData.width; - } - - this->_pivotX *= width; - this->_pivotY *= height; - } - - if (currentTextureData->frame) - { - this->_pivotX += currentTextureData->frame->x * scale; - this->_pivotY += currentTextureData->frame->y * scale; - } - - if (rawDisplayData && rawDisplayData != currentDisplayData) - { - this->_pivotX += rawDisplayData->transform.x - currentDisplayData->transform.x; - this->_pivotY += rawDisplayData->transform.y - currentDisplayData->transform.y; - } - - this->_pivotY -= currentTextureData->region.height * this->_armature->getArmatureData().scale; - - frameDisplay->setSpriteFrame(currentTextureData->texture); // polygonInfo will be override - - if (texture != currentTextureData->texture->getTexture()) - { - frameDisplay->setTexture(texture); // Relpace texture // polygonInfo will be override - } - - this->_blendModeDirty = true; // Relpace texture // blendMode will be override - } - - this->_updateVisible(); - - return; - } - } - - this->_pivotX = 0.f; - this->_pivotY = 0.f; - - frameDisplay->setTexture(nullptr); - frameDisplay->setTextureRect(cocos2d::Rect::ZERO); - frameDisplay->setVisible(false); - frameDisplay->setPosition(this->origin.x, this->origin.y); -} - -void CCSlot::_updateMesh() -{ - const auto meshDisplay = static_cast(this->_meshDisplay); - const auto hasFFD = !this->_ffdVertices.empty(); - const auto displayVertices = meshDisplay->getPolygonInfoModify().triangles.verts; - cocos2d::Rect boundsRect(999999.f, 999999.f, -999999.f, -999999.f); - - if (this->_meshData->skinned) - { - std::size_t iF = 0; - for (std::size_t i = 0, l = this->_meshData->vertices.size(); i < l; i += 2) - { - const auto iH = unsigned(i / 2); - - const auto& boneIndices = this->_meshData->boneIndices[iH]; - const auto& boneVertices = this->_meshData->boneVertices[iH]; - const auto& weights = this->_meshData->weights[iH]; - - float xG = 0.f, yG = 0.f; - for (std::size_t iB = 0, lB = boneIndices.size(); iB < lB; ++iB) - { - const auto bone = this->_meshBones[boneIndices[iB]]; - const auto matrix = bone->globalTransformMatrix; - const auto weight = weights[iB]; - - float xL = 0.f, yL = 0.f; - if (hasFFD) - { - xL = boneVertices[iB * 2] + this->_ffdVertices[iF]; - yL = boneVertices[iB * 2 + 1] + this->_ffdVertices[iF + 1]; - } - else - { - xL = boneVertices[iB * 2]; - yL = boneVertices[iB * 2 + 1]; - } - - xG += (matrix->a * xL + matrix->c * yL + matrix->tx) * weight; - yG += (matrix->b * xL + matrix->d * yL + matrix->ty) * weight; - - iF += 2; - } - - auto& vertices = displayVertices[iH]; - auto& vertex = vertices.vertices; - - vertex.set(xG, -yG, 0.f); - - if (boundsRect.origin.x > xG) - { - boundsRect.origin.x = xG; - } - - if (boundsRect.size.width < xG) - { - boundsRect.size.width = xG; - } - - if (boundsRect.origin.y > -yG) - { - boundsRect.origin.y = -yG; - } - - if (boundsRect.size.height < -yG) - { - boundsRect.size.height = -yG; - } - } - } - else if (hasFFD) - { - const auto& vertices = _meshData->vertices; - for (std::size_t i = 0, l = this->_meshData->vertices.size(); i < l; i += 2) - { - const auto iH = unsigned(i / 2); - const auto xG = vertices[i] + _ffdVertices[i]; - const auto yG = vertices[i + 1] + _ffdVertices[i + 1]; - - auto& vertices = displayVertices[iH]; - auto& vertex = vertices.vertices; - - vertex.set(xG, -yG, 0.f); - - if (boundsRect.origin.x > xG) - { - boundsRect.origin.x = xG; - } - - if (boundsRect.size.width < xG) - { - boundsRect.size.width = xG; - } - - if (boundsRect.origin.y > -yG) - { - boundsRect.origin.y = -yG; - } - - if (boundsRect.size.height < -yG) - { - boundsRect.size.height = -yG; - } - } - } - - boundsRect.size.width -= boundsRect.origin.x; - boundsRect.size.height -= boundsRect.origin.y; - - - auto polygonInfo = meshDisplay->getPolygonInfo(); -#if COCOS2D_VERSION >= 0x00031400 - polygonInfo.setRect(boundsRect); -#else - polygonInfo.rect = boundsRect; // Copy -#endif - const auto& transform = meshDisplay->getNodeToParentTransform(); - meshDisplay->setContentSize(boundsRect.size); - meshDisplay->setPolygonInfo(polygonInfo); - - _renderDisplay->setNodeToParentTransform(transform); -} - -void CCSlot::_updateTransform() -{ - static cocos2d::Mat4 transform; - transform.m[0] = this->globalTransformMatrix->a; - transform.m[1] = -this->globalTransformMatrix->b; - transform.m[4] = -this->globalTransformMatrix->c; - transform.m[5] = this->globalTransformMatrix->d; - transform.m[12] = this->globalTransformMatrix->tx - (this->globalTransformMatrix->a * this->_pivotX + this->globalTransformMatrix->c * this->_pivotY); - transform.m[13] = -(this->globalTransformMatrix->ty - (this->globalTransformMatrix->b * this->_pivotX + this->globalTransformMatrix->d * this->_pivotY)); - - _renderDisplay->setNodeToParentTransform(transform); -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/cocos2dx/CCSlot.h b/native/cocos/editor-support/dragonbones/cocos2dx/CCSlot.h deleted file mode 100644 index 999025fc3f..0000000000 --- a/native/cocos/editor-support/dragonbones/cocos2dx/CCSlot.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef DRAGONBONES_CC_SLOT_H -#define DRAGONBONES_CC_SLOT_H - -#include "dragonbones/DragonBonesHeaders.h" -#include "cocos2d.h" - -DRAGONBONES_NAMESPACE_BEGIN -class CCSlot : public Slot -{ - BIND_CLASS_TYPE(CCSlot); - -private: - cocos2d::Node* _renderDisplay; - -public: - CCSlot(); - ~CCSlot(); - - virtual void _onClear() override; - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(CCSlot); - -protected: - virtual void _initDisplay(void* value) override; - virtual void _disposeDisplay(void* value) override; - virtual void _onUpdateDisplay() override; - virtual void _addDisplay() override; - virtual void _replaceDisplay(void* value, bool isArmatureDisplayContainer) override; - virtual void _removeDisplay() override; - virtual void _updateColor() override; - virtual void _updateFilters() override; - virtual void _updateFrame() override; - virtual void _updateMesh() override; - virtual void _updateTransform() override; - -public: - virtual void _updateVisible() override; - virtual void _updateBlendMode() override; -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_CC_SLOT_H diff --git a/native/cocos/editor-support/dragonbones/cocos2dx/CCTextureData.cpp b/native/cocos/editor-support/dragonbones/cocos2dx/CCTextureData.cpp deleted file mode 100644 index 2482181d1a..0000000000 --- a/native/cocos/editor-support/dragonbones/cocos2dx/CCTextureData.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "CCTextureData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -CCTextureData::CCTextureData() : - texture(nullptr) -{ - _onClear(); -} -CCTextureData::~CCTextureData() -{ - _onClear(); -} - -void CCTextureData::_onClear() -{ - TextureData::_onClear(); - - if (texture) - { - texture->release(); - texture = nullptr; - } -} - -CCTextureAtlasData::CCTextureAtlasData() : - texture(nullptr) -{ - _onClear(); -} -CCTextureAtlasData::~CCTextureAtlasData() -{ - _onClear(); -} - -void CCTextureAtlasData::_onClear() -{ - TextureAtlasData::_onClear(); - - if (texture) - { - //texture->release(); - texture = nullptr; - } -} - -TextureData * CCTextureAtlasData::generateTexture() const -{ - return BaseObject::borrowObject(); -} - -DRAGONBONES_NAMESPACE_END \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/cocos2dx/CCTextureData.h b/native/cocos/editor-support/dragonbones/cocos2dx/CCTextureData.h deleted file mode 100644 index 8977c0956e..0000000000 --- a/native/cocos/editor-support/dragonbones/cocos2dx/CCTextureData.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef DRAGONBONES_CC_TEXTURE_DATA_H -#define DRAGONBONES_CC_TEXTURE_DATA_H - -#include "dragonbones/DragonBonesHeaders.h" -#include "cocos2d.h" - -DRAGONBONES_NAMESPACE_BEGIN -class CCTextureData final : public TextureData -{ - BIND_CLASS_TYPE(CCTextureData); - -public: - cocos2d::SpriteFrame* texture; - - CCTextureData(); - ~CCTextureData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(CCTextureData); - -protected: - virtual void _onClear() override; -}; - -class CCTextureAtlasData final : public TextureAtlasData -{ - BIND_CLASS_TYPE(CCTextureAtlasData); - -public: - cocos2d::Texture2D* texture; - - CCTextureAtlasData(); - ~CCTextureAtlasData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(CCTextureAtlasData); - -protected: - virtual void _onClear() override; - -public: - virtual TextureData* generateTexture() const override; -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_CC_TEXTURE_DATA_H diff --git a/native/cocos/editor-support/dragonbones/core/BaseObject.cpp b/native/cocos/editor-support/dragonbones/core/BaseObject.cpp deleted file mode 100644 index 7c0dd6be47..0000000000 --- a/native/cocos/editor-support/dragonbones/core/BaseObject.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "BaseObject.h" -DRAGONBONES_NAMESPACE_BEGIN - -std::size_t BaseObject::_hashCode = 0; -std::size_t BaseObject::_defaultMaxCount = 5000; -std::unordered_map BaseObject::_maxCountMap; -std::unordered_map> BaseObject::_poolsMap; -BaseObject::RecycleOrDestroyCallback BaseObject::_recycleOrDestroyCallback = nullptr; - -void BaseObject::_returnObject(BaseObject* object) -{ - const auto classTypeIndex = object->getClassTypeIndex(); - const auto maxCountIterator = _maxCountMap.find(classTypeIndex); - const auto maxCount = maxCountIterator != _maxCountMap.end() ? maxCountIterator->second : _defaultMaxCount; - - auto& pool = _poolsMap[classTypeIndex]; - if (pool.size() < maxCount) - { - if (std::find(pool.cbegin(), pool.cend(), object) == pool.cend()) - { - pool.push_back(object); - } - else - { - DRAGONBONES_ASSERT(false, "The object aleady in pool."); - } - - if (_recycleOrDestroyCallback != nullptr) - _recycleOrDestroyCallback(object, 0); - } - else - { - if (_recycleOrDestroyCallback != nullptr) - _recycleOrDestroyCallback(object, 1); - - delete object; - } -} - -void BaseObject::setObjectRecycleOrDestroyCallback(const std::function& cb) -{ - _recycleOrDestroyCallback = cb; -} - -void BaseObject::setMaxCount(std::size_t classTypeIndex, std::size_t maxCount) -{ - if (classTypeIndex) - { - _maxCountMap[classTypeIndex] = maxCount; - const auto iterator = _poolsMap.find(classTypeIndex); - if (iterator != _poolsMap.end()) - { - auto& pool = iterator->second; - if (pool.size() > maxCount) - { - for (auto i = maxCount, l = pool.size(); i < l; ++i) - { - delete pool[i]; - } - - pool.resize(maxCount); - } - } - } - else - { - _defaultMaxCount = maxCount; - for (auto& pair : _poolsMap) - { - if (_maxCountMap.find(pair.first) == _maxCountMap.end()) - { - continue; - } - - _maxCountMap[pair.first] = maxCount; - - auto& pool = pair.second; - if (pool.size() > maxCount) - { - for (auto i = maxCount, l = pool.size(); i < l; ++i) - { - delete pool[i]; - } - - pool.resize(maxCount); - } - } - } -} - -void BaseObject::clearPool(std::size_t classTypeIndex) -{ - if (classTypeIndex) - { - const auto iterator = _poolsMap.find(classTypeIndex); - if (iterator != _poolsMap.end()) - { - auto& pool = iterator->second; - if (!pool.empty()) - { - for (auto object : pool) - { - delete object; - } - - pool.clear(); - } - } - } - else - { - for (auto& pair : _poolsMap) - { - auto& pool = pair.second; - if (!pool.empty()) - { - for (auto object : pool) - { - delete object; - } - - pool.clear(); - } - } - } -} - -BaseObject::BaseObject() : - hashCode(BaseObject::_hashCode++) -{} -BaseObject::~BaseObject() -{ - int i = 0; - ++i; -} - -void BaseObject::returnToPool() -{ - _onClear(); - _returnObject(this); -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/core/BaseObject.h b/native/cocos/editor-support/dragonbones/core/BaseObject.h deleted file mode 100644 index b80b237c78..0000000000 --- a/native/cocos/editor-support/dragonbones/core/BaseObject.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef DRAGONBONES_BASE_OBJECT_H -#define DRAGONBONES_BASE_OBJECT_H - -#include "DragonBones.h" - -#define BIND_CLASS_TYPE(CLASS) \ -public:\ -static std::size_t getTypeIndex()\ -{\ - static const auto typeIndex = typeid(CLASS).hash_code();\ - return typeIndex;\ -}\ -virtual std::size_t getClassTypeIndex() const override\ -{\ - return CLASS::getTypeIndex();\ -}\ - -DRAGONBONES_NAMESPACE_BEGIN - -class BaseObject -{ -public: - typedef std::function RecycleOrDestroyCallback; -private: - static std::size_t _hashCode; - static std::size_t _defaultMaxCount; - static std::unordered_map _maxCountMap; - static std::unordered_map> _poolsMap; - - static RecycleOrDestroyCallback _recycleOrDestroyCallback; - static void _returnObject(BaseObject *object); -public: - - static void setObjectRecycleOrDestroyCallback(const RecycleOrDestroyCallback& cb); - static void setMaxCount(std::size_t classTypeIndex, std::size_t maxCount); - static void clearPool(std::size_t classTypeIndex); - - template - static T* borrowObject() - { - const auto classTypeIndex = T::getTypeIndex(); - const auto iterator = _poolsMap.find(classTypeIndex); - if (iterator != _poolsMap.end()) - { - auto& pool = iterator->second; - if (!pool.empty()) - { - const auto object = dynamic_cast(pool.back()); - pool.pop_back(); - - return object; - } - } - - return new (std::nothrow) T(); - } - -public: - const std::size_t hashCode; - -public: - /** @private */ - BaseObject(); - /** @private */ - virtual ~BaseObject(); - -protected: - virtual void _onClear() = 0; - -public: - /** @private */ - virtual std::size_t getClassTypeIndex() const = 0; - - void returnToPool(); -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_BASE_OBJECT_H diff --git a/native/cocos/editor-support/dragonbones/core/DragonBones.h b/native/cocos/editor-support/dragonbones/core/DragonBones.h deleted file mode 100644 index 02216750c7..0000000000 --- a/native/cocos/editor-support/dragonbones/core/DragonBones.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef DRAGONBONES_H -#define DRAGONBONES_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// dragonBones assert -#ifndef DRAGONBONES_ASSERT -#define DRAGONBONES_ASSERT(cond, msg) do { \ - assert(cond); \ - } while (0) -#endif - -// namespace dragonBones {} -#define DRAGONBONES_NAMESPACE_BEGIN namespace dragonBones { -#define DRAGONBONES_NAMESPACE_END } - -// using dragonBones namespace -#define DRAGONBONES_USING_NAME_SPACE using namespace dragonBones - -/** - * A macro to disallow the copy constructor and operator= functions - * This should be used in the private: declarations for a class - */ -#define DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(CLASS)\ - CLASS(const CLASS&);\ - void operator=(const CLASS&)\ - -DRAGONBONES_NAMESPACE_BEGIN - -enum class TextureFormat -{ - DEFAULT, - RGBA8888, - BGRA8888, - RGBA4444, - RGB888, - RGB565, - RGBA5551 -}; - -enum class DisplayType -{ - Image = 0, - Armature = 1, - Mesh = 2 -}; - -enum class ArmatureType -{ - Armature = 0, - MovieClip = 1, - Stage = 2 -}; - -enum class ExtensionType { - FFD = 0, - AdjustColor = 10, - BevelFilter = 11, - BlurFilter = 12, - DropShadowFilter = 13, - GlowFilter = 14, - GradientBevelFilter = 15, - GradientGlowFilter = 16 -}; - -enum class EventType { - Frame = 0, - Sound = 1 -}; - -enum class ActionType { - Play = 0, - Stop = 1, - GotoAndPlay = 2, - GotoAndStop = 3, - FadeIn = 4, - FadeOut = 5 -}; - -enum class BlendMode -{ - Normal = 0, - Add = 1, - Alpha = 2, - Darken = 3, - Difference = 4, - Erase = 5, - HardLight = 6, - Invert = 7, - Layer = 8, - Lighten = 9, - Multiply = 10, - Overlay = 11, - Screen = 12, - Subtract = 13 -}; - -const float PI = 3.14159265358979323846f; -const float PI_D = PI * 2.0f; -const float PI_H = PI * 0.5f; -const float PI_Q = PI * 0.25f; -const float ANGLE_TO_RADIAN = PI / 180.f; -const float RADIAN_TO_ANGLE = 180.f / PI; -const float SECOND_TO_MILLISECOND = 1000.f; -const float NO_TWEEN = 100.f; -// VERSION 4.7.2 - -template -std::string to_string(const T& value) -{ - std::ostringstream stream; - stream << value; - return stream.str(); -} - -template -inline T* mapFind(const std::map& map, const std::string& key) -{ - const auto iterator = map.find(key); - return (iterator != map.end()) ? iterator->second : nullptr; -} - -template -inline int indexOf(const std::vector& vector, const T& value) -{ - for (std::size_t i = 0, l = vector.size(); i < l; ++i) - { - if (vector[i] == value) - { - return (int) i; - } - } - - return -1; -} - -DRAGONBONES_NAMESPACE_END - -#endif // DRAGONBONES_H diff --git a/native/cocos/editor-support/dragonbones/events/EventObject.cpp b/native/cocos/editor-support/dragonbones/events/EventObject.cpp deleted file mode 100644 index e8af15bc43..0000000000 --- a/native/cocos/editor-support/dragonbones/events/EventObject.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "EventObject.h" - -DRAGONBONES_NAMESPACE_BEGIN - -const char* EventObject::START = "start"; -const char* EventObject::LOOP_COMPLETE = "loopComplete"; -const char* EventObject::COMPLETE = "complete"; - -const char* EventObject::FADE_IN = "fadeIn"; -const char* EventObject::FADE_IN_COMPLETE = "fadeInComplete"; -const char* EventObject::FADE_OUT = "fadeOut"; -const char* EventObject::FADE_OUT_COMPLETE = "fadeOutComplete"; - -const char* EventObject::FRAME_EVENT = "frameEvent"; -const char* EventObject::SOUND_EVENT = "soundEvent"; - -IEventDispatcher* EventObject::_soundEventManager = nullptr; - -EventObject::EventObject() -{ - _onClear(); -} - -EventObject::~EventObject() -{ - _onClear(); -} - -void EventObject::_onClear() -{ - type.clear(); - name.clear(); - //data = null; - userData = nullptr; - armature = nullptr; - bone = nullptr; - slot = nullptr; - animationState = nullptr; - frame = nullptr; -} - -DRAGONBONES_NAMESPACE_END \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/events/EventObject.h b/native/cocos/editor-support/dragonbones/events/EventObject.h deleted file mode 100644 index 0d008eb656..0000000000 --- a/native/cocos/editor-support/dragonbones/events/EventObject.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef DRAGONBONES_EVENT_OBJECT_H -#define DRAGONBONES_EVENT_OBJECT_H - -#include "../core/BaseObject.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class IEventDispatcher; -class Armature; -class Bone; -class Slot; -class AnimationState; -class AnimationFrameData; - -class EventObject final : public BaseObject -{ - BIND_CLASS_TYPE(EventObject); - -public: - static const char* START; - static const char* LOOP_COMPLETE; - static const char* COMPLETE; - - static const char* FADE_IN; - static const char* FADE_IN_COMPLETE; - static const char* FADE_OUT; - static const char* FADE_OUT_COMPLETE; - - static const char* FRAME_EVENT; - static const char* SOUND_EVENT; - -public: - /** @private */ - static IEventDispatcher* _soundEventManager; - -public: - std::string type; - std::string name; - //void* data; // TODO - void* userData; - Armature* armature; - Bone* bone; - Slot* slot; - AnimationState* animationState; - AnimationFrameData* frame; - -public: - EventObject(); - ~EventObject(); - -protected: - void _onClear() override; - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(EventObject); -}; - -class IEventDispatcher -{ -protected: - IEventDispatcher() {}; - virtual ~IEventDispatcher() {}; - -public: - /** @private */ - virtual void _onClear() = 0; - /** @private */ - virtual void _dispatchEvent(EventObject* value) = 0; - - virtual bool hasEvent(const std::string& type) const = 0; -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_EVENT_OBJECT_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/factories/BaseFactory.cpp b/native/cocos/editor-support/dragonbones/factories/BaseFactory.cpp deleted file mode 100644 index f5a36fd970..0000000000 --- a/native/cocos/editor-support/dragonbones/factories/BaseFactory.cpp +++ /dev/null @@ -1,451 +0,0 @@ -#include "BaseFactory.h" - -DRAGONBONES_NAMESPACE_BEGIN - -JSONDataParser BaseFactory::_defaultDataParser; - -BaseFactory::BaseFactory() : - autoSearch(false), - - _dataParser(&_defaultDataParser), - _dragonBonesDataMap(), - _textureAtlasDataMap() -{} -BaseFactory::~BaseFactory() {} - -TextureData* BaseFactory::_getTextureData(const std::string& dragonBonesName, const std::string& textureName) const -{ - const auto iterator = _textureAtlasDataMap.find(dragonBonesName); - if (iterator != _textureAtlasDataMap.end()) - { - for (const auto textureAtlasData : iterator->second) - { - const auto textureData = textureAtlasData->getTexture(textureName); - if (textureData) - { - return textureData; - } - } - } - - if (autoSearch) - { - for (const auto& pair : _textureAtlasDataMap) - { - for (const auto textureAtlasData : pair.second) - { - if (textureAtlasData->autoSearch) - { - const auto textureData = textureAtlasData->getTexture(textureName); - if (textureData) - { - return textureData; - } - } - } - } - } - - return nullptr; -} - -bool BaseFactory::_fillBuildArmaturePackage(const std::string& dragonBonesName, const std::string& armatureName, const std::string& skinName, BuildArmaturePackage& dataPackage) const -{ - if (!dragonBonesName.empty()) - { - const auto iterator = _dragonBonesDataMap.find(dragonBonesName); - if (iterator != _dragonBonesDataMap.end()) - { - const auto armatureData = iterator->second->getArmature(armatureName); - if (armatureData) - { - dataPackage.dataName = dragonBonesName; - dataPackage.data = iterator->second; - dataPackage.armature = armatureData; - dataPackage.skin = armatureData->getSkin(skinName); - if (!dataPackage.skin) - { - dataPackage.skin = armatureData->getDefaultSkin(); - } - - return true; - } - } - } - - if (dragonBonesName.empty() || autoSearch) - { - for (const auto& pair : _dragonBonesDataMap) - { - if (dragonBonesName.empty() || pair.second->autoSearch) - { - const auto armatureData = pair.second->getArmature(armatureName); - if (armatureData) - { - dataPackage.dataName = pair.first; - dataPackage.data = pair.second; - dataPackage.armature = armatureData; - dataPackage.skin = armatureData->getSkin(skinName); - if (!dataPackage.skin) - { - dataPackage.skin = armatureData->getDefaultSkin(); - } - - return true; - } - } - } - } - - return false; -} - -void BaseFactory::_buildBones(const BuildArmaturePackage& dataPackage, Armature& armature) const -{ - for (const auto boneData : dataPackage.armature->getSortedBones()) - { - const auto bone = BaseObject::borrowObject(); - bone->name = boneData->name; - bone->inheritTranslation = boneData->inheritTranslation; - bone->inheritRotation = boneData->inheritRotation; - bone->inheritScale = boneData->inheritScale; - bone->length = boneData->length; - bone->origin = boneData->transform; // copy - - if (boneData->parent) - { - armature.addBone(bone, boneData->parent->name); - } - else - { - armature.addBone(bone); - } - - if (boneData->ik) - { - bone->ikBendPositive = boneData->bendPositive; - bone->ikWeight = boneData->weight; - bone->_setIK(armature.getBone(boneData->ik->name), boneData->chain, boneData->chainIndex); - } - } -} - -void BaseFactory::_buildSlots(const BuildArmaturePackage& dataPackage, Armature& armature) const -{ - const auto currentSkin = dataPackage.skin; - const auto defaultSkin = dataPackage.armature->getDefaultSkin(); - auto slotDisplayDataSetMap = defaultSkin->slots; // copy - - if (currentSkin != defaultSkin) - { - for (const auto& pair : currentSkin->slots) - { - slotDisplayDataSetMap[pair.first] = pair.second; - } - } - - for (const auto slotData : dataPackage.armature->getSortedSlots()) - { - const auto itetator = slotDisplayDataSetMap.find(slotData->name); - if (itetator == slotDisplayDataSetMap.cend()) - { - continue; - } - - const auto slot = _generateSlot(dataPackage, *itetator->second); - slot->_displayDataSet = itetator->second; - slot->_setDisplayIndex(slotData->displayIndex); - slot->_setBlendMode(slotData->blendMode); - slot->_setColor(*slotData->color); - - armature.addSlot(slot, slotData->parent->name); - } -} - -void BaseFactory::_replaceSlotDisplay(const BuildArmaturePackage& dataPackage, DisplayData& displayData, Slot& slot, int displayIndex) const -{ - if (displayIndex < 0) - { - displayIndex = slot.getDisplayIndex(); - } - - if (displayIndex >= 0) - { - auto displayList = slot.getDisplayList(); // copy - if (displayList.size() <= (unsigned)displayIndex) - { - displayList.resize(displayIndex + 1, std::make_pair(nullptr, DisplayType::Image)); - } - - if (slot._replacedDisplayDataSet.size() <= (unsigned)displayIndex) - { - slot._replacedDisplayDataSet.resize(displayIndex + 1, nullptr); - } - - slot._replacedDisplayDataSet[displayIndex] = const_cast(&displayData); - - if (displayData.type == DisplayType::Armature) - { - const auto childArmature = buildArmature(displayData.name, dataPackage.dataName); - displayList[displayIndex] = std::make_pair(childArmature, DisplayType::Armature); - } - else - { - if (!displayData.texture) - { - displayData.texture = _getTextureData(dataPackage.dataName, displayData.name); - } - - if ( - displayData.mesh && - (displayIndex < slot._displayDataSet->displays.size() && slot._displayDataSet->displays[displayIndex]->mesh) - ) - { - displayList[displayIndex] = std::make_pair(slot.getMeshDisplay(), displayData.type); - } - else - { - displayList[displayIndex] = std::make_pair(slot.getRawDisplay(), displayData.type); - } - } - - slot.setDisplayList(displayList); - slot.invalidUpdate(); - } -} - -DragonBonesData* BaseFactory::parseDragonBonesData(const char* rawData, const std::string& dragonBonesName, float scale) -{ - const auto dragonBonesData = _dataParser->parseDragonBonesData(rawData, scale); - addDragonBonesData(dragonBonesData, dragonBonesName); - - return dragonBonesData; -} - -TextureAtlasData* BaseFactory::parseTextureAtlasData(const char* rawData, void* textureAtlas, const std::string& dragonBonesName, float scale) -{ - const auto textureAtlasData = _generateTextureAtlasData(nullptr, nullptr); - _dataParser->parseTextureAtlasData(rawData, *textureAtlasData, scale); - - _generateTextureAtlasData(textureAtlasData, textureAtlas); - addTextureAtlasData(textureAtlasData, dragonBonesName); - - return textureAtlasData; -} - -void BaseFactory::addDragonBonesData(DragonBonesData* data, const std::string& dragonBonesName) -{ - if (data) - { - const auto& mapName = dragonBonesName.empty() ? data->name : dragonBonesName; - if (!mapName.empty()) - { - if (_dragonBonesDataMap.find(mapName) == _dragonBonesDataMap.end()) - { - _dragonBonesDataMap[mapName] = data; - } - else - { - DRAGONBONES_ASSERT(false, "Same name data."); - } - } - else - { - DRAGONBONES_ASSERT(false, "Unnamed data."); - } - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -void BaseFactory::removeDragonBonesData(const std::string& dragonBonesName, bool disposeData) -{ - const auto iterator = _dragonBonesDataMap.find(dragonBonesName); - if (iterator != _dragonBonesDataMap.end()) - { - if (disposeData) - { - iterator->second->returnToPool(); - } - - _dragonBonesDataMap.erase(iterator); - } -} - -void BaseFactory::addTextureAtlasData(TextureAtlasData* data, const std::string& dragonBonesName) -{ - if (data) - { - const auto& mapName = dragonBonesName.empty() ? data->name : dragonBonesName; - if (!mapName.empty()) - { - auto& textureAtlasList = _textureAtlasDataMap[mapName]; - if (std::find(textureAtlasList.begin(), textureAtlasList.end(), data) == textureAtlasList.end()) - { - textureAtlasList.push_back(data); - } - } - else - { - DRAGONBONES_ASSERT(false, "Unnamed data."); - } - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -void BaseFactory::removeTextureAtlasData(const std::string& dragonBonesName, bool disposeData) -{ - const auto iterator = _textureAtlasDataMap.find(dragonBonesName); - if (iterator != _textureAtlasDataMap.end()) - { - if (disposeData) - { - for (const auto textureAtlasData : iterator->second) - { - textureAtlasData->returnToPool(); - } - } - - _textureAtlasDataMap.erase(iterator); - } -} - -void BaseFactory::clear(bool disposeData) -{ - if (disposeData) - { - for (const auto& pair : _dragonBonesDataMap) - { - pair.second->returnToPool(); - } - - for (const auto& pair : _textureAtlasDataMap) - { - for (const auto textureAtlasData : pair.second) - { - textureAtlasData->returnToPool(); - } - } - } - - _dragonBonesDataMap.clear(); - _textureAtlasDataMap.clear(); -} - -Armature * BaseFactory::buildArmature(const std::string & armatureName, const std::string & dragonBonesName, const std::string & skinName) const -{ - BuildArmaturePackage dataPackage; - if (_fillBuildArmaturePackage(dragonBonesName, armatureName, skinName, dataPackage)) - { - const auto armature = _generateArmature(dataPackage); - _buildBones(dataPackage, *armature); - _buildSlots(dataPackage, *armature); - - // Update armature pose - armature->advanceTime(0.f); - return armature; - } - - return nullptr; -} - -bool BaseFactory::copyAnimationsToArmature( - Armature& toArmature, - const std::string& fromArmatreName, const std::string& fromSkinName, const std::string& fromDragonBonesDataName, - bool ifRemoveOriginalAnimationList -) const -{ - BuildArmaturePackage dataPackage; - if (_fillBuildArmaturePackage(fromDragonBonesDataName, fromArmatreName, fromSkinName, dataPackage)) - { - const auto fromArmatureData = dataPackage.armature; - if (ifRemoveOriginalAnimationList) - { - toArmature.getAnimation().setAnimations(fromArmatureData->animations); - } - else - { - auto animations = toArmature.getAnimation().getAnimations(); // copy - - for (const auto& pair : fromArmatureData->animations) - { - animations[pair.first] = pair.second; - } - - toArmature.getAnimation().setAnimations(animations); - } - - if (dataPackage.skin) - { - for (const auto toSlot : toArmature.getSlots()) - { - const auto& toSlotDisplayList = toSlot->getDisplayList(); - std::size_t index = 0; - for (const auto& pair : toSlotDisplayList) - { - if (pair.second == DisplayType::Armature) - { - const auto displays = dataPackage.skin->getSlot(toSlot->name)->displays; - if (index < displays.size()) - { - const auto fromDisplayData = displays[index]; - if (fromDisplayData->type == DisplayType::Armature) - { - copyAnimationsToArmature(*(Armature*)pair.first, fromDisplayData->name, fromSkinName, fromDragonBonesDataName, ifRemoveOriginalAnimationList); - } - } - } - - index++; - } - } - - return true; - } - } - - return false; -} - -void BaseFactory::replaceSlotDisplay(const std::string& dragonBonesName, const std::string& armatureName, const std::string& slotName, const std::string& displayName, Slot& slot, int displayIndex) const -{ - BuildArmaturePackage dataPackage; - if (_fillBuildArmaturePackage(dragonBonesName, armatureName, "", dataPackage)) - { - const auto slotDisplayDataSet = dataPackage.skin->getSlot(slotName); - if (slotDisplayDataSet) - { - for (const auto displayData : slotDisplayDataSet->displays) - { - if (displayData->name == displayName) - { - _replaceSlotDisplay(dataPackage, *displayData, slot, displayIndex); - } - } - } - } -} - -void BaseFactory::replaceSlotDisplayList(const std::string& dragonBonesName, const std::string& armatureName, const std::string& slotName, Slot& slot) const -{ - BuildArmaturePackage dataPackage; - if (_fillBuildArmaturePackage(dragonBonesName, armatureName, "", dataPackage)) - { - const auto slotDisplayDataSet = dataPackage.skin->getSlot(slotName); - if (slotDisplayDataSet) - { - int displayIndex = 0; - for (const auto displayData : slotDisplayDataSet->displays) - { - _replaceSlotDisplay(dataPackage, *displayData, slot, displayIndex++); - } - } - } -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/factories/BaseFactory.h b/native/cocos/editor-support/dragonbones/factories/BaseFactory.h deleted file mode 100644 index c189426c45..0000000000 --- a/native/cocos/editor-support/dragonbones/factories/BaseFactory.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef DRAGONBONES_BASE_FACTORY_H -#define DRAGONBONES_BASE_FACTORY_H - -#include "../parsers/JSONDataParser.h" -#include "../armature/Armature.h" -#include "../animation/Animation.h" -#include "../armature/Bone.h" -#include "../armature/Slot.h" - -DRAGONBONES_NAMESPACE_BEGIN - -/** - * @private - */ -class BuildArmaturePackage final -{ -public: - std::string dataName; - DragonBonesData* data; - ArmatureData* armature; - SkinData* skin; - -public: - BuildArmaturePackage() : - dataName(), - data(nullptr), - armature(nullptr), - skin(nullptr) - { - } - ~BuildArmaturePackage() {} - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(BuildArmaturePackage); -}; - -class BaseFactory -{ -protected: - static JSONDataParser _defaultDataParser; - -public: - bool autoSearch; - -protected: - DataParser* _dataParser; - std::map _dragonBonesDataMap; - std::map> _textureAtlasDataMap; - -public: - /** @private */ - BaseFactory(); - /** @private */ - virtual ~BaseFactory() = 0; - -protected: - virtual TextureData* _getTextureData(const std::string& dragonBonesName, const std::string& textureName) const; - virtual bool _fillBuildArmaturePackage(const std::string& dragonBonesName, const std::string& armatureName, const std::string& skinName, BuildArmaturePackage& dataPackage) const; - virtual void _buildBones(const BuildArmaturePackage& dataPackage, Armature& armature) const; - virtual void _buildSlots(const BuildArmaturePackage& dataPackage, Armature& armature) const; - virtual void _replaceSlotDisplay(const BuildArmaturePackage& dataPackage, DisplayData& displayData, Slot& slot, int displayIndex) const; - - virtual TextureAtlasData* _generateTextureAtlasData(TextureAtlasData* textureAtlasData, void* textureAtlas) const = 0; - virtual Armature* _generateArmature(const BuildArmaturePackage& dataPackage) const = 0; - virtual Slot* _generateSlot(const BuildArmaturePackage& dataPackage, const SlotDisplayDataSet& slotDisplayDataSet) const = 0; - -public: - virtual DragonBonesData* parseDragonBonesData(const char* rawData, const std::string& dragonBonesName = "", float scale = 1.f); - virtual TextureAtlasData* parseTextureAtlasData(const char* rawData, void* textureAtlas, const std::string& dragonBonesName = "", float scale = 0.f); - virtual void addDragonBonesData(DragonBonesData* data, const std::string& dragonBonesName = ""); - virtual void removeDragonBonesData(const std::string& dragonBonesName, bool disposeData = true); - virtual void addTextureAtlasData(TextureAtlasData* data, const std::string& dragonBonesName = ""); - virtual void removeTextureAtlasData(const std::string& dragonBonesName, bool disposeData = true); - virtual void clear(bool disposeData = true); - - virtual Armature* buildArmature(const std::string& armatureName, const std::string& dragonBonesName = "", const std::string& skinName = "") const; - virtual bool copyAnimationsToArmature( - Armature& toArmature, - const std::string& fromArmatreName, const std::string& fromSkinName = "", const std::string& fromDragonBonesDataName = "", - bool ifRemoveOriginalAnimationList = true - ) const; - virtual void replaceSlotDisplay(const std::string& dragonBonesName, const std::string& armatureName, const std::string& slotName, const std::string& displayName, Slot& slot, int displayIndex = -1) const; - virtual void replaceSlotDisplayList(const std::string& dragonBonesName, const std::string& armatureName, const std::string& slotName, Slot& slot) const; - - inline DragonBonesData* getDragonBonesData(const std::string& dragonBonesName) const - { - return mapFind(_dragonBonesDataMap, dragonBonesName); - } - - inline std::vector* getTextureAtlasData(const std::string& dragonBonesName) const - { - const auto iterator = _textureAtlasDataMap.find(dragonBonesName); - return (iterator != _textureAtlasDataMap.end()) ? &const_cast&>(iterator->second) : nullptr; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_BASE_FACTORY_H diff --git a/native/cocos/editor-support/dragonbones/geom/ColorTransform.h b/native/cocos/editor-support/dragonbones/geom/ColorTransform.h deleted file mode 100644 index 1a8e81f8db..0000000000 --- a/native/cocos/editor-support/dragonbones/geom/ColorTransform.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef DRAGONBONES_COLOR_TRANSFORM_H -#define DRAGONBONES_COLOR_TRANSFORM_H - -#include "../core/DragonBones.h" - -DRAGONBONES_NAMESPACE_BEGIN - -/** - * @private - */ -class ColorTransform final -{ -public: - float alphaMultiplier; - float redMultiplier; - float greenMultiplier; - float blueMultiplier; - int alphaOffset; - int redOffset; - int greenOffset; - int blueOffset; - - ColorTransform(): - alphaMultiplier(1.f), - redMultiplier(1.f), - greenMultiplier(1.f), - blueMultiplier(1.f), - alphaOffset(0), - redOffset(0), - greenOffset(0), - blueOffset(0) - { - } - ColorTransform(const ColorTransform &value) - { - operator=(value); - } - ~ColorTransform() {} - - inline void operator=(const ColorTransform &value) - { - alphaMultiplier = value.alphaMultiplier; - redMultiplier = value.redMultiplier; - greenMultiplier = value.greenMultiplier; - blueMultiplier = value.blueMultiplier; - alphaOffset = value.alphaOffset; - redOffset = value.redOffset; - greenOffset = value.greenOffset; - blueOffset = value.blueOffset; - } - - inline void identity() - { - alphaMultiplier = redMultiplier = greenMultiplier = blueMultiplier = 1.f; - alphaOffset = redOffset = greenOffset = blueOffset = 0; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_COLOR_TRANSFORM_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/geom/Matrix.h b/native/cocos/editor-support/dragonbones/geom/Matrix.h deleted file mode 100644 index 018514fe2a..0000000000 --- a/native/cocos/editor-support/dragonbones/geom/Matrix.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef DRAGONBONES_MATRIX_H -#define DRAGONBONES_MATRIX_H - -#include "../core/DragonBones.h" -#include "Point.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class Matrix final -{ -public: - float a; - float b; - float c; - float d; - float tx; - float ty; - - Matrix(): - a(1.f), - b(0.f), - c(0.f), - d(1.f), - tx(0.f), - ty(0.f) - { - } - Matrix(const Matrix& value) - { - operator=(value); - } - ~Matrix() {} - - inline void operator=(const Matrix& value) - { - a = value.a; - b = value.b; - c = value.c; - d = value.d; - tx = value.tx; - ty = value.ty; - } - - inline void identity() - { - a = d = 1.f; - b = c = 0.f; - tx = ty = 0.f; - } - - inline void concat(const Matrix& value) - { - const auto aA = a; - const auto bA = b; - const auto cA = c; - const auto dA = d; - const auto txA = tx; - const auto tyA = ty; - const auto aB = value.a; - const auto bB = value.b; - const auto cB = value.c; - const auto dB = value.d; - const auto txB = value.tx; - const auto tyB = value.ty; - - a = aA * aB + bA * cB; - b = aA * bB + bA * dB; - c = cA * aB + dA * cB; - d = cA * bB + dA * dB; - tx = aB * txA + cB * tyA + txB; - ty = dB * tyA + bB * txA + tyB; - } - - inline void invert() - { - const auto aA = a; - const auto bA = b; - const auto cA = c; - const auto dA = d; - const auto txA = tx; - const auto tyA = ty; - const auto n = aA * dA - bA * cA; - - a = dA / n; - b = -bA / n; - c = -cA / n; - d = aA / n; - tx = (cA * tyA - dA * txA) / n; - ty = -(aA * tyA - bA * txA) / n; - } - - inline void transformPoint(float x, float y, Point& result, bool delta = false) const - { - result.x = a * x + c * y; - result.y = b * x + d * y; - - if (!delta) - { - result.x += tx; - result.y += ty; - } - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_MATRIX_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/geom/Point.h b/native/cocos/editor-support/dragonbones/geom/Point.h deleted file mode 100644 index bd366507d8..0000000000 --- a/native/cocos/editor-support/dragonbones/geom/Point.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef DRAGONBONES_POINT_H -#define DRAGONBONES_POINT_H - -#include "../core/DragonBones.h" - -DRAGONBONES_NAMESPACE_BEGIN - -/** - * @private - */ -class Point final -{ -public: - float x; - float y; - - Point(): - x(0.f), - y(0.f) - { - } - Point(const Point& value) - { - operator=(value); - } - ~Point() {} - - inline void operator=(const Point& value) - { - x = value.x; - y = value.y; - } - - inline void clear() - { - x = y = 0.f; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_POINT_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/geom/Rectangle.h b/native/cocos/editor-support/dragonbones/geom/Rectangle.h deleted file mode 100644 index 5687d134f1..0000000000 --- a/native/cocos/editor-support/dragonbones/geom/Rectangle.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef DRAGONBONES_RECTANGLE_H -#define DRAGONBONES_RECTANGLE_H - -#include "../core/DragonBones.h" - -DRAGONBONES_NAMESPACE_BEGIN - -/** - * @private - */ -class Rectangle final -{ -public: - float x; - float y; - float width; - float height; - - Rectangle(): - x(0.f), - y(0.f), - width(0.f), - height(0.f) - { - } - Rectangle(const Rectangle& value) - { - operator=(value); - } - ~Rectangle() {} - - inline void operator=(const Rectangle& value) - { - x = value.x; - y = value.y; - width = value.width; - height = value.height; - } - - void clear() - { - x = y = 0.f; - width = height = 0.f; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_RECTANGLE_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/geom/Transform.h b/native/cocos/editor-support/dragonbones/geom/Transform.h deleted file mode 100644 index bed1557723..0000000000 --- a/native/cocos/editor-support/dragonbones/geom/Transform.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef DRAGONBONES_TRANSFORM_H -#define DRAGONBONES_TRANSFORM_H - -#include "../core/DragonBones.h" -#include "Matrix.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class Transform final -{ -public: - static float normalizeRadian(float value) - { - value = std::fmod(value + PI, PI * 2.f); - value += value > 0.f ? -PI : PI; - - return value; - } - -public: - float x; - float y; - float skewX; - float skewY; - float scaleX; - float scaleY; - - Transform(): - x(0.f), - y(0.f), - skewX(0.f), - skewY(0.f), - scaleX(1.f), - scaleY(1.f) - { - } - Transform(const Transform& value) - { - operator=(value); - } - ~Transform() {} - - inline void operator=(const Transform& value) - { - x = value.x; - y = value.y; - skewX = value.skewX; - skewY = value.skewY; - scaleX = value.scaleX; - scaleY = value.scaleY; - } - - inline Transform& identity() - { - x = y = skewX = skewY = 0.f; - scaleX = scaleY = 1.f; - - return *this; - } - - inline Transform& add(const Transform& value) - { - x += value.x; - y += value.y; - skewX += value.skewX; - skewY += value.skewY; - scaleX *= value.scaleX; - scaleY *= value.scaleY; - - return *this; - } - - inline Transform& minus(const Transform& value) - { - x -= value.x; - y -= value.y; - skewX = normalizeRadian(skewX - value.skewX); - skewY = normalizeRadian(skewY - value.skewY); - scaleX /= value.scaleX; - scaleY /= value.scaleY; - - return *this; - } - - inline Transform& fromMatrix(const Matrix& matrix) - { - const auto backupScaleX = scaleX, backupScaleY = scaleY; - - x = matrix.tx; - y = matrix.ty; - - skewX = std::atan(-matrix.c / matrix.d); - skewY = std::atan(matrix.b / matrix.a); - if (skewX != skewX) skewX = 0.f; - if (skewY != skewY) skewY = 0.f; - - scaleY = (skewX > -PI_Q && skewX < PI_Q) ? (matrix.d / std::cos(skewX)) : (-matrix.c / std::sin(skewX)); - scaleX = (skewY > -PI_Q && skewY < PI_Q) ? (matrix.a / std::cos(skewY)) : (matrix.b / std::sin(skewY)); - - if (backupScaleX >= 0.f && scaleX < 0.f) - { - scaleX = -scaleX; - skewY = skewY - PI; - } - - if (backupScaleY >= 0.f && scaleY < 0.f) - { - scaleY = -scaleY; - skewX = skewX - PI; - } - - return *this; - } - - inline Transform& toMatrix(Matrix& matrix) - { - matrix.a = scaleX * cos(skewY); - matrix.b = scaleX * sin(skewY); - matrix.c = -scaleY * sin(skewX); - matrix.d = scaleY * cos(skewX); - matrix.tx = x; - matrix.ty = y; - - return *this; - } - - inline float getRotation() const - { - return skewY; - } - - inline void setRotation(float value) - { - const auto dValue = value - skewY; - skewX += dValue; - skewY += dValue; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_TRANSFORM_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/model/AnimationData.cpp b/native/cocos/editor-support/dragonbones/model/AnimationData.cpp deleted file mode 100644 index e7528f3ffc..0000000000 --- a/native/cocos/editor-support/dragonbones/model/AnimationData.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "AnimationData.h" -#include "ArmatureData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -AnimationData::AnimationData() -{ - _onClear(); -} -AnimationData::~AnimationData() -{ - _onClear(); -} - -void AnimationData::_onClear() -{ - TimelineData::_onClear(); - - for (const auto& pair : boneTimelines) - { - pair.second->returnToPool(); - } - - for (const auto& pair : slotTimelines) - { - pair.second->returnToPool(); - } - - for (const auto& skinPair : ffdTimelines) - { - for (const auto& slotPair : skinPair.second) - { - for (const auto& pair : slotPair.second) - { - pair.second->returnToPool(); - } - } - } - - hasAsynchronyTimeline = false; - frameCount = 0; - playTimes = 0; - position = 0.f; - duration = 0.f; - fadeInTime = 0.f; - cacheTimeToFrameScale = 0.f; - name.clear(); - animation = nullptr; - boneTimelines.clear(); - slotTimelines.clear(); - ffdTimelines.clear(); - cachedFrames.clear(); -} - -void AnimationData::cacheFrames(float value) -{ - if (animation) - { - return; - } - - const auto cacheFrameCount = (unsigned)std::max(std::floor((frameCount + 1) * scale * value), 1.f); - - cacheTimeToFrameScale = cacheFrameCount / (duration + 0.0000001f); - cachedFrames.resize(cacheFrameCount, false); - - for (const auto& pair : boneTimelines) - { - pair.second->cacheFrames(cacheFrameCount); - } - - for (const auto& pair : slotTimelines) - { - pair.second->cacheFrames(cacheFrameCount); - } -} - -void AnimationData::addBoneTimeline(BoneTimelineData* value) -{ - if (value && value->bone && boneTimelines.find(value->bone->name) == boneTimelines.end()) - { - boneTimelines[value->bone->name] = value; - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -void AnimationData::addSlotTimeline(SlotTimelineData* value) -{ - if (value && value->slot && slotTimelines.find(value->slot->name) == slotTimelines.end()) - { - slotTimelines[value->slot->name] = value; - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -void AnimationData::addFFDTimeline(FFDTimelineData* value) -{ - if (value && value->skin && value->slot) - { - const auto& skinName = value->skin->name; - const auto& slotName = value->slot->slot->name; - const auto& displayIndex = to_string(value->displayIndex); // std::to_string - - auto& skin = ffdTimelines[skinName]; - auto& slot = skin[slotName]; - if (slot.find(displayIndex) == slot.end()) - { - slot[displayIndex] = value; - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -DRAGONBONES_NAMESPACE_END \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/model/AnimationData.h b/native/cocos/editor-support/dragonbones/model/AnimationData.h deleted file mode 100644 index 177edf1f38..0000000000 --- a/native/cocos/editor-support/dragonbones/model/AnimationData.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef DRAGONBONES_ANIMATION_DATA_H -#define DRAGONBONES_ANIMATION_DATA_H - -#include "TimelineData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class AnimationData final : public TimelineData -{ - BIND_CLASS_TYPE(AnimationData); - -public: - /** @private */ - bool hasAsynchronyTimeline; - unsigned frameCount; - unsigned playTimes; - float position; - float duration; - float fadeInTime; - /** @private */ - float cacheTimeToFrameScale; - std::string name; - /** @private */ - AnimationData* animation; - /** @private */ - std::map boneTimelines; - /** @private */ - std::map slotTimelines; - /** @private */ - std::map>> ffdTimelines; // skin slot displayIndex - /** @private */ - std::vector cachedFrames; - - /** @private */ - AnimationData(); - /** @private */ - ~AnimationData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(AnimationData); - -protected: - void _onClear() override; - -public: - /** @private */ - void cacheFrames(float value); - /** @private */ - void addBoneTimeline(BoneTimelineData* value); - /** @private */ - void addSlotTimeline(SlotTimelineData* value); - /** @private */ - void addFFDTimeline(FFDTimelineData* value); - - /** @private */ - inline BoneTimelineData* getBoneTimeline(const std::string& theName) const - { - return mapFind(boneTimelines, theName); - } - - /** @private */ - inline SlotTimelineData* getSlotTimeline(const std::string& theName) const - { - return mapFind(slotTimelines, theName); - } - - /** @private */ - inline FFDTimelineData* getFFDTimeline(const std::string& skinName, const std::string& slotName, unsigned displayIndex) const - { - const auto iteratorSkin = ffdTimelines.find(skinName); - if (iteratorSkin != ffdTimelines.end()) - { - const auto& skin = iteratorSkin->second; - const auto iteratorSlot = skin.find(slotName); - if (iteratorSlot != skin.end()) - { - const auto& slot = iteratorSlot->second; - return mapFind(slot, to_string(displayIndex)); // std::to_string - } - } - - return nullptr; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_ANIMATION_DATA_H diff --git a/native/cocos/editor-support/dragonbones/model/ArmatureData.cpp b/native/cocos/editor-support/dragonbones/model/ArmatureData.cpp deleted file mode 100644 index 849c512bde..0000000000 --- a/native/cocos/editor-support/dragonbones/model/ArmatureData.cpp +++ /dev/null @@ -1,403 +0,0 @@ -#include "ArmatureData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -BoneData::BoneData() -{ - _onClear(); -} -BoneData::~BoneData() -{ - _onClear(); -} - -void BoneData::_onClear() -{ - inheritTranslation = false; - inheritRotation = false; - inheritScale = false; - bendPositive = false; - chain = 0; - chainIndex = 0; - weight = 0.f; - length = 0.f; - name.clear(); - parent = nullptr; - ik = nullptr; - transform.identity(); -} - -ColorTransform SlotData::DEFAULT_COLOR; -ColorTransform * SlotData::generateColor() -{ - return new ColorTransform(); -} - -SlotData::SlotData() : - color(nullptr) -{ - _onClear(); -} -SlotData::~SlotData() -{ - _onClear(); -} - -void SlotData::_onClear() -{ - for (const auto action : actions) - { - action->returnToPool(); - } - - displayIndex = 0; - zOrder = 0; - blendMode = BlendMode::Normal; - name.clear(); - parent = nullptr; - - if (color) - { - if (color != &DEFAULT_COLOR) - { - delete color; - } - - color = nullptr; - } - - actions.clear(); -} - -MeshData::MeshData() -{ - _onClear(); -} -MeshData::~MeshData() -{ - _onClear(); -} - -void MeshData::_onClear() -{ - skinned = false; - slotPose.identity(); - uvs.clear(); - vertices.clear(); - vertexIndices.clear(); - boneIndices.clear(); - weights.clear(); - boneVertices.clear(); - bones.clear(); - inverseBindPose.clear(); -} - -DisplayData::DisplayData() : - mesh(nullptr) -{ - _onClear(); -} -DisplayData::~DisplayData() -{ - _onClear(); -} - -void DisplayData::_onClear() -{ - isRelativePivot = false; - type = DisplayType::Image; - name.clear(); - texture = nullptr; - armature = nullptr; - - if (mesh) - { - mesh->returnToPool(); - mesh = nullptr; - } - - pivot.clear(); - transform.identity(); -} - -SlotDisplayDataSet::SlotDisplayDataSet() -{ - _onClear(); -} -SlotDisplayDataSet::~SlotDisplayDataSet() -{ - _onClear(); -} - -void SlotDisplayDataSet::_onClear() -{ - slot = nullptr; - - for (const auto displayData : displays) - { - displayData->returnToPool(); - } - - displays.clear(); -} - -SkinData::SkinData() -{ - _onClear(); -} -SkinData::~SkinData() -{ - _onClear(); -} - -void SkinData::_onClear() -{ - name.clear(); - - for (const auto& pair : slots) - { - pair.second->returnToPool(); - } - - slots.clear(); -} - -void SkinData::addSlot(SlotDisplayDataSet* value) -{ - if (value && value->slot && slots.find(value->slot->name) == slots.end()) - { - slots[value->slot->name] = value; - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -bool ArmatureData::_onSortSlots(const SlotData* a, const SlotData* b) -{ - return a->zOrder < b->zOrder; -} - -ArmatureData::ArmatureData() -{ - _onClear(); -} -ArmatureData::~ArmatureData() -{ - _onClear(); -} - -void ArmatureData::_onClear() -{ - for (const auto& pair : bones) - { - pair.second->returnToPool(); - } - - for (const auto& pair : slots) - { - pair.second->returnToPool(); - } - - for (const auto& pair : skins) - { - pair.second->returnToPool(); - } - - for (const auto& pair : animations) - { - pair.second->returnToPool(); - } - - for (const auto action : actions) - { - action->returnToPool(); - } - - frameRate = 0; - type = ArmatureType::Armature; - name.clear(); - parent = nullptr; - aabb.clear(); - actions.clear(); - bones.clear(); - slots.clear(); - skins.clear(); - animations.clear(); - - cacheFrameRate = 0; - scale = 1.f; - - _boneDirty = false; - _slotDirty = false; - _defaultSkin = nullptr; - _defaultAnimation = nullptr; - - _sortedBones.clear(); - _sortedSlots.clear(); - _bonesChildren.clear(); -} - -void ArmatureData::_sortBones() -{ - if (_sortedBones.empty()) - { - return; - } - - const auto total = _sortedBones.size(); - const auto sortHelper = _sortedBones; - std::size_t index = 0; - std::size_t count = 0; - - _sortedBones.clear(); - - while (count < total) - { - const auto bone = sortHelper[index++]; - - if (index >= total) - { - index = 0; - } - - if (std::find(_sortedBones.cbegin(), _sortedBones.cend(), bone) != _sortedBones.cend()) - { - continue; - } - - if (bone->parent && std::find(_sortedBones.cbegin(), _sortedBones.cend(), bone->parent) == _sortedBones.cend()) - { - continue; - } - - if (bone->ik && std::find(_sortedBones.cbegin(), _sortedBones.cend(), bone->ik) == _sortedBones.cend()) - { - continue; - } - - if (bone->ik && bone->chain > 0 && bone->chainIndex == bone->chain) - { - auto parentInerator = std::find(_sortedBones.begin(), _sortedBones.end(), bone->parent); - _sortedBones.insert(parentInerator + 1, bone); - } - else - { - _sortedBones.push_back(bone); - } - - count++; - } -} - -void ArmatureData::_sortSlots() -{ - std::sort(_sortedSlots.begin(), _sortedSlots.end(), _onSortSlots); - - auto copy = _sortedSlots; - copy.swap(_sortedSlots); -} - -void ArmatureData::cacheFrames(unsigned value) -{ - if (cacheFrameRate == value) - { - return; - } - - cacheFrameRate = value; - - const auto frameScale = (float)cacheFrameRate / frameRate; - for (const auto& pair : animations) - { - pair.second->cacheFrames(frameScale); - } -} - -void ArmatureData::addBone(BoneData* value, const std::string& parentName) -{ - if (value && !value->name.empty() && bones.find(value->name) == bones.end()) - { - if (!parentName.empty()) - { - const auto parent = getBone(parentName); - if (parent) - { - value->parent = parent; - } - else - { - auto& children = _bonesChildren[parentName]; - children.push_back(value); - } - } - - const auto iterator = _bonesChildren.find(value->name); - if (iterator != _bonesChildren.cend()) - { - for (const auto child : iterator->second) - { - child->parent = value; - } - - _bonesChildren.erase(iterator); - } - - bones[value->name] = value; - _sortedBones.push_back(value); - _boneDirty = true; - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -void ArmatureData::addSlot(SlotData* value) -{ - if (value && !value->name.empty() && slots.find(value->name) == slots.end()) - { - slots[value->name] = value; - _slotDirty = true; - _sortedSlots.push_back(value); - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -void ArmatureData::addSkin(SkinData* value) -{ - if (value && !value->name.empty() && skins.find(value->name) == skins.end()) - { - skins[value->name] = value; - if (!_defaultSkin) - { - _defaultSkin = value; - } - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -void ArmatureData::addAnimation(AnimationData* value) -{ - if (value && !value->name.empty() && animations.find(value->name) == animations.end()) - { - animations[value->name] = value; - if (!_defaultAnimation) - { - _defaultAnimation = value; - } - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -DRAGONBONES_NAMESPACE_END \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/model/ArmatureData.h b/native/cocos/editor-support/dragonbones/model/ArmatureData.h deleted file mode 100644 index fb07e8a5d5..0000000000 --- a/native/cocos/editor-support/dragonbones/model/ArmatureData.h +++ /dev/null @@ -1,332 +0,0 @@ -#ifndef DRAGONBONES_ARMATURE_DATA_H -#define DRAGONBONES_ARMATURE_DATA_H - -#include "../core/BaseObject.h" -#include "../geom/Transform.h" -#include "../geom/Point.h" -#include "../geom/ColorTransform.h" -#include "../textures/TextureData.h" -#include "AnimationData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class DragonBonesData; -class ArmatureData; - -class BoneData : public BaseObject -{ - BIND_CLASS_TYPE(BoneData); - -public: - /** @private */ - bool inheritTranslation; - /** @private */ - bool inheritRotation; - /** @private */ - bool inheritScale; - /** @private */ - bool bendPositive; - /** @private */ - unsigned chain; - /** @private */ - int chainIndex; - /** @private */ - float weight; - /** @private */ - float length; - - std::string name; - - BoneData* parent; - /** @private */ - BoneData* ik; - /** @private */ - Transform transform; - - /** @private */ - BoneData(); - /** @private */ - ~BoneData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(BoneData); - -protected: - virtual void _onClear() override; -}; - -class SlotData : public BaseObject -{ - BIND_CLASS_TYPE(SlotData); - -public: - /** @private */ - static ColorTransform DEFAULT_COLOR; - /** @private */ - static ColorTransform* generateColor(); - -public: - /** @private */ - int displayIndex; - /** @private */ - int zOrder; - /** @private */ - BlendMode blendMode; - - std::string name; - - BoneData* parent; - /** @private */ - ColorTransform* color; - /** @private */ - std::vector actions; - - /** @private */ - SlotData(); - /** @private */ - ~SlotData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(SlotData); - -protected: - void _onClear() override; -}; - -/** - * @private - */ -class MeshData final : public BaseObject -{ - BIND_CLASS_TYPE(MeshData); - -public: - bool skinned; - Matrix slotPose; - - std::vector uvs; - std::vector vertices; - std::vector vertexIndices; - - std::vector> boneIndices; - std::vector> weights; - std::vector> boneVertices; - - std::vector bones; - std::vector inverseBindPose; - - MeshData(); - ~MeshData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(MeshData); - -protected: - void _onClear() override; -}; - -/** - * @private - */ -class DisplayData final : public BaseObject -{ - BIND_CLASS_TYPE(DisplayData); - -public: - bool isRelativePivot; - DisplayType type; - std::string name; - TextureData* texture; - ArmatureData* armature; - MeshData* mesh; - Point pivot; - Transform transform; - - DisplayData(); - ~DisplayData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(DisplayData); - -protected: - void _onClear() override; -}; - -/** - * @private - */ -class SlotDisplayDataSet final : public BaseObject -{ - BIND_CLASS_TYPE(SlotDisplayDataSet); - -public: - SlotData* slot; - std::vector displays; - - SlotDisplayDataSet(); - ~SlotDisplayDataSet(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(SlotDisplayDataSet); - -protected: - void _onClear() override; -}; - -class SkinData final : public BaseObject -{ - BIND_CLASS_TYPE(SkinData); - -public: - std::string name; - /** @private */ - std::map slots; - - /** @private */ - SkinData(); - /** @private */ - ~SkinData(); - -protected: - void _onClear() override; - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(SkinData); - -public: - /** @private */ - void addSlot(SlotDisplayDataSet* value); - - /** @private */ - inline SlotDisplayDataSet* getSlot(const std::string& theName) const - { - return mapFind(slots, theName); - } -}; - -class ArmatureData : public BaseObject -{ - BIND_CLASS_TYPE(ArmatureData); - -private: - static bool _onSortSlots(const SlotData* a, const SlotData* b); - -public: - unsigned frameRate; - ArmatureType type; - std::string name; - Rectangle aabb; - DragonBonesData* parent; - std::map bones; - std::map slots; - std::map skins; - std::map animations; - /** @private */ - std::vector actions; - - /** @private */ - unsigned cacheFrameRate; - /** @private */ - float scale; - -private: - bool _boneDirty; - bool _slotDirty; - SkinData* _defaultSkin; - AnimationData* _defaultAnimation; - std::vector _sortedBones; - std::vector _sortedSlots; - std::map> _bonesChildren; - -public: - /** @private */ - ArmatureData(); - /** @private */ - ~ArmatureData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(ArmatureData); - - void _sortBones(); - void _sortSlots(); - -protected: - void _onClear() override; - -public: - /** @private */ - void cacheFrames(unsigned value); - /** @private */ - void addBone(BoneData* value, const std::string& parentName = ""); - /** @private */ - void addSlot(SlotData* value); - /** @private */ - void addSkin(SkinData* value); - /** @private */ - void addAnimation(AnimationData* value); - - inline BoneData* getBone(const std::string& theName) const - { - return mapFind(bones, theName); - } - - inline SlotData* getSlot(const std::string& theName) const - { - return mapFind(slots, theName); - } - - inline SkinData* getSkin(const std::string& theName) const - { - if (theName.empty()) - { - return _defaultSkin; - } - - return mapFind(skins, theName); - } - - inline AnimationData* getAnimation(const std::string& theName) const - { - if (theName.empty()) - { - return _defaultAnimation; - } - - return mapFind(animations, theName); - } - - inline const std::vector& getSortedBones() // const - { - if (_boneDirty) - { - _boneDirty = false; - _sortBones(); - } - - return _sortedBones; - } - - inline const std::vector& getSortedSlots() // const - { - if (_slotDirty) - { - _slotDirty = false; - _sortSlots(); - } - - return _sortedSlots; - } - - inline SkinData* getDefaultSkin() const - { - return _defaultSkin; - } - - inline AnimationData* getDefaultAnimation() const - { - return _defaultAnimation; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_ARMATURE_DATA_H diff --git a/native/cocos/editor-support/dragonbones/model/DragonBonesData.cpp b/native/cocos/editor-support/dragonbones/model/DragonBonesData.cpp deleted file mode 100644 index b7fc0c510d..0000000000 --- a/native/cocos/editor-support/dragonbones/model/DragonBonesData.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "DragonBonesData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -DragonBonesData::DragonBonesData() -{ - _onClear(); -} -DragonBonesData::~DragonBonesData() -{ - _onClear(); -} - -void DragonBonesData::_onClear() -{ - autoSearch = false; - frameRate = 0; - name.clear(); - - for (const auto& pair : armatures) - { - pair.second->returnToPool(); - } - - armatures.clear(); - - _armatureNames.clear(); -} - -void DragonBonesData::addArmature(ArmatureData * value) -{ - if (value && !value->name.empty() && armatures.find(value->name) == armatures.end()) - { - armatures[value->name] = value; - _armatureNames.push_back(value->name); - value->parent = this; - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/model/DragonBonesData.h b/native/cocos/editor-support/dragonbones/model/DragonBonesData.h deleted file mode 100644 index 0e3d42302c..0000000000 --- a/native/cocos/editor-support/dragonbones/model/DragonBonesData.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef DRAGONBONES_DRAGONBONES_DATA_H -#define DRAGONBONES_DRAGONBONES_DATA_H - -#include "../core/BaseObject.h" -#include "ArmatureData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class DragonBonesData : public BaseObject -{ - BIND_CLASS_TYPE(DragonBonesData); - -public: - bool autoSearch; - unsigned frameRate; - std::string name; - std::map armatures; - -private: - std::vector _armatureNames; - -public: - /** @private */ - DragonBonesData(); - /** @private */ - ~DragonBonesData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(DragonBonesData); - -protected: - void _onClear() override; - -public: - /** @private */ - void addArmature(ArmatureData* value); - - inline ArmatureData* getArmature(const std::string& theName) const - { - return mapFind(armatures, theName); - } - - inline const std::vector& getArmatureNames() const - { - return _armatureNames; - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_DRAGONBONES_DATA_H diff --git a/native/cocos/editor-support/dragonbones/model/FrameData.cpp b/native/cocos/editor-support/dragonbones/model/FrameData.cpp deleted file mode 100644 index c0f93a9be9..0000000000 --- a/native/cocos/editor-support/dragonbones/model/FrameData.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "FrameData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -ActionData::ActionData() -{ - _onClear(); -} -ActionData::~ActionData() -{ - _onClear(); -} - -void ActionData::_onClear() -{ - type = ActionType::Play; - bone = nullptr; - slot = nullptr; - - std::get<0>(data).clear(); - std::get<1>(data).clear(); - std::get<2>(data).clear(); -} - -EventData::EventData() -{ - _onClear(); -} -EventData::~EventData() -{ - _onClear(); -} - -void EventData::_onClear() -{ - type = EventType::Frame; - name.clear(); - //data = nullptr; - bone = nullptr; - slot = nullptr; -} - -AnimationFrameData::AnimationFrameData() -{ - _onClear(); -} -AnimationFrameData::~AnimationFrameData() -{ - _onClear(); -} - -void AnimationFrameData::_onClear() -{ - FrameData::_onClear(); -} - -BoneFrameData::BoneFrameData() -{ - _onClear(); -} -BoneFrameData::~BoneFrameData() -{ - _onClear(); -} - -void BoneFrameData::_onClear() -{ - TweenFrameData::_onClear(); - - tweenScale = false; - tweenRotate = 0; - parent = nullptr; - transform.identity(); -} - -ColorTransform SlotFrameData::DEFAULT_COLOR; -ColorTransform * SlotFrameData::generateColor() -{ - return new ColorTransform(); -} - -SlotFrameData::SlotFrameData() : - color(nullptr) -{ - _onClear(); -} -SlotFrameData::~SlotFrameData() -{ - _onClear(); -} - -void SlotFrameData::_onClear() -{ - TweenFrameData::_onClear(); - - displayIndex = 0; - zOrder = 0; - - if (color) - { - if (color != &DEFAULT_COLOR) - { - delete color; - } - - color = nullptr; - } -} - -ExtensionFrameData::ExtensionFrameData() -{ - _onClear(); -} -ExtensionFrameData::~ExtensionFrameData() -{ - _onClear(); -} - -void ExtensionFrameData::_onClear() -{ - TweenFrameData::_onClear(); - - type = ExtensionType::FFD; - tweens.clear(); - keys.clear(); -} - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/model/FrameData.h b/native/cocos/editor-support/dragonbones/model/FrameData.h deleted file mode 100644 index a8fccbf5ab..0000000000 --- a/native/cocos/editor-support/dragonbones/model/FrameData.h +++ /dev/null @@ -1,258 +0,0 @@ -#ifndef DRAGONBONES_FRAME_DATA_H -#define DRAGONBONES_FRAME_DATA_H - -#include "../core/BaseObject.h" -#include "../geom/Transform.h" -#include "../geom/ColorTransform.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class BoneData; -class SlotData; - -/** - * @private - */ -class ActionData final : public BaseObject -{ - BIND_CLASS_TYPE(ActionData); - -public: - ActionType type; - BoneData* bone; - SlotData* slot; - std::tuple, std::vector, std::vector> data; - - ActionData(); - ~ActionData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(ActionData); - -protected: - void _onClear() override; -}; - -/** - * @private - */ -class EventData final : public BaseObject -{ - BIND_CLASS_TYPE(EventData); - -public: - EventType type; - std::string name; - //void* data; //TODO - BoneData* bone; - SlotData* slot; - - EventData(); - ~EventData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(EventData); - -protected: - void _onClear() override; -}; - -/** - * @private - */ -template -class FrameData : public BaseObject -{ -public: - float position; - float duration; - T* prev; - T* next; - - std::vector actions; - std::vector events; - - FrameData() {} - virtual ~FrameData() {} - -protected: - virtual void _onClear() override - { - position = 0.f; - duration = 0.f; - prev = nullptr; - next = nullptr; - - for (const auto action : actions) - { - action->returnToPool(); - } - - for (const auto event : events) - { - event->returnToPool(); - } - - actions.clear(); - events.clear(); - } -}; - -/** - * @private - */ -template -class TweenFrameData : public FrameData -{ -public: - static void samplingCurve(std::vector& curve, unsigned frameCount, std::vector& sampling) - { - if (curve.empty() || frameCount == 0) - { - return; - } - - const auto curveCount = curve.size(); - const auto samplingTimes = frameCount + 2; - const auto samplingStep = 1.f / samplingTimes; - sampling.resize((samplingTimes - 1) * 2); - - int stepIndex = -2; - for (std::size_t i = 0; i < samplingTimes - 1; ++i) - { - const auto step = samplingStep * (i + 1); - while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1.f) < step) // stepIndex + 3 * 2 - { - stepIndex += 6; // stepIndex += 3 * 2 - } - - const auto isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; - const auto x1 = isInCurve ? curve[stepIndex] : 0.f; - const auto y1 = isInCurve ? curve[stepIndex + 1] : 0.f; - const auto x4 = isInCurve ? curve[stepIndex + 6] : 1.f; - const auto y4 = isInCurve ? curve[stepIndex + 7] : 1.f; - - const auto t = (step - x1) / (x4 - x1); - const auto l_t = 1.f - t; - - const auto powA = l_t * l_t; - const auto powB = t * t; - - const auto kA = l_t * powA; - const auto kB = 3.f * t * powA; - const auto kC = 3.f * l_t * powB; - const auto kD = t * powB; - - sampling[i * 2] = kA * x1 + kB * curve[stepIndex + 2] + kC * curve[stepIndex + 4] + kD * x4; - sampling[i * 2 + 1] = kA * y1 + kB * curve[stepIndex + 3] + kC * curve[stepIndex + 5] + kD * y4; - } - } - -public: - float tweenEasing; - std::vector curve; - - TweenFrameData() {} - virtual ~TweenFrameData() {} - -protected: - virtual void _onClear() override - { - FrameData::_onClear(); - - tweenEasing = 0.f; - curve.clear(); - } -}; - -/** - * @private - */ -class AnimationFrameData final : public FrameData -{ - BIND_CLASS_TYPE(AnimationFrameData); - -public: - AnimationFrameData(); - ~AnimationFrameData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(AnimationFrameData); - -protected: - void _onClear() override; -}; - -/** - * @private - */ -class BoneFrameData final : public TweenFrameData -{ - BIND_CLASS_TYPE(BoneFrameData); - -public: - bool tweenScale; - int tweenRotate; - BoneData* parent; - Transform transform; - - BoneFrameData(); - ~BoneFrameData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(BoneFrameData); - -protected: - void _onClear() override; -}; - -/** - * @private - */ -class SlotFrameData final : public TweenFrameData -{ - BIND_CLASS_TYPE(SlotFrameData); - -public: - static ColorTransform DEFAULT_COLOR; - static ColorTransform* generateColor(); - -public: - int displayIndex; - int zOrder; - ColorTransform* color; - - SlotFrameData(); - ~SlotFrameData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(SlotFrameData); - -protected: - void _onClear() override; -}; - -/** - * @private - */ -class ExtensionFrameData final : public TweenFrameData -{ - BIND_CLASS_TYPE(ExtensionFrameData); - -public: - ExtensionType type; - std::vector tweens; - std::vector keys; - - ExtensionFrameData(); - ~ExtensionFrameData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(ExtensionFrameData); - -protected: - void _onClear() override; -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_FRAME_DATA_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/model/TimelineData.cpp b/native/cocos/editor-support/dragonbones/model/TimelineData.cpp deleted file mode 100644 index 1cb073ea96..0000000000 --- a/native/cocos/editor-support/dragonbones/model/TimelineData.cpp +++ /dev/null @@ -1,144 +0,0 @@ -#include "TimelineData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -Matrix* BoneTimelineData::cacheFrame(std::vector& cacheFrames, std::size_t cacheFrameIndex, const Matrix& globalTransformMatrix) -{ - const auto cacheMatrix = cacheFrames[cacheFrameIndex] = new Matrix(); - *cacheMatrix = globalTransformMatrix; - - return cacheMatrix; -} - -BoneTimelineData::BoneTimelineData() -{ - _onClear(); -} -BoneTimelineData::~BoneTimelineData() -{ - _onClear(); -} - -void BoneTimelineData::_onClear() -{ - TimelineData::_onClear(); - - bone = nullptr; - originTransform.identity(); - - Matrix* prevMatrix = nullptr; - for (const auto matrix : cachedFrames) - { - if (matrix) - { - if (prevMatrix && prevMatrix != matrix) - { - delete prevMatrix; - } - - prevMatrix = matrix; - } - } - - cachedFrames.clear(); -} - -void BoneTimelineData::cacheFrames(std::size_t cacheFrameCount) -{ - Matrix* prevMatrix = nullptr; - for (const auto matrix : cachedFrames) - { - if (matrix) - { - if (prevMatrix && prevMatrix != matrix) - { - delete prevMatrix; - } - - prevMatrix = matrix; - } - } - - cachedFrames.clear(); - cachedFrames.resize(cacheFrameCount, nullptr); -} - -Matrix* SlotTimelineData::cacheFrame(std::vector& cacheFrames, std::size_t cacheFrameIndex, const Matrix& globalTransformMatrix) -{ - const auto cacheMatrix = cacheFrames[cacheFrameIndex] = new Matrix(); - *cacheMatrix = globalTransformMatrix; - - return cacheMatrix; -} - -SlotTimelineData::SlotTimelineData() -{ - _onClear(); -} -SlotTimelineData::~SlotTimelineData() -{ - _onClear(); -} - -void SlotTimelineData::_onClear() -{ - TimelineData::_onClear(); - - slot = nullptr; - - Matrix* prevMatrix = nullptr; - for (const auto matrix : cachedFrames) - { - if (matrix) - { - if (prevMatrix && prevMatrix != matrix) - { - delete prevMatrix; - } - - prevMatrix = matrix; - } - } - - cachedFrames.clear(); -} - -void SlotTimelineData::cacheFrames(std::size_t cacheFrameCount) -{ - Matrix* prevMatrix = nullptr; - for (const auto matrix : cachedFrames) - { - if (matrix) - { - if (prevMatrix && prevMatrix != matrix) - { - delete prevMatrix; - } - - prevMatrix = matrix; - } - } - - cachedFrames.clear(); - cachedFrames.resize(cacheFrameCount, nullptr); -} - -FFDTimelineData::FFDTimelineData() -{ - _onClear(); -} -FFDTimelineData::~FFDTimelineData() -{ - _onClear(); -} - -void FFDTimelineData::_onClear() -{ - TimelineData::_onClear(); - - displayIndex = 0; - skin = nullptr; - slot = nullptr; -} - -DRAGONBONES_NAMESPACE_END \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/model/TimelineData.h b/native/cocos/editor-support/dragonbones/model/TimelineData.h deleted file mode 100644 index 2c54dc28e2..0000000000 --- a/native/cocos/editor-support/dragonbones/model/TimelineData.h +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef DRAGONBONES_TIMELINE_DATA_H -#define DRAGONBONES_TIMELINE_DATA_H - -#include "../core/BaseObject.h" -#include "FrameData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class SkinData; -class SlotDisplayDataSet; - -/** - * @private - */ -template -class TimelineData : public BaseObject -{ -public: - float scale; - float offset; - - std::vector frames; - - TimelineData() {} - virtual ~TimelineData() {} - -protected: - virtual void _onClear() override - { - scale = 1.f; - offset = 0.f; - - std::vector deleteFrames; - for (const auto frame : frames) { - auto i = std::find(deleteFrames.begin(), deleteFrames.end(), frame); - if (i == deleteFrames.end()) { - deleteFrames.push_back(frame); - } - } - - for (const auto frame : deleteFrames) { - frame->returnToPool(); - } - - frames.clear(); - } -}; - -/** - * @private - */ -class BoneTimelineData final : public TimelineData -{ - BIND_CLASS_TYPE(BoneTimelineData); - -public: - static Matrix* cacheFrame(std::vector& cacheFrames, std::size_t cacheFrameIndex, const Matrix& globalTransformMatrix); - -public: - BoneData* bone; - Transform originTransform; - std::vector cachedFrames; - - BoneTimelineData(); - ~BoneTimelineData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(BoneTimelineData); - -protected: - void _onClear() override; - -public: - /** @private */ - void cacheFrames(std::size_t cacheFrameCount); -}; - -/** - * @private - */ -class SlotTimelineData final : public TimelineData -{ - BIND_CLASS_TYPE(SlotTimelineData); - -public: - static Matrix* cacheFrame(std::vector& cacheFrames, std::size_t cacheFrameIndex, const Matrix& globalTransformMatrix); - -public: - SlotData* slot; - std::vector cachedFrames; - - SlotTimelineData(); - ~SlotTimelineData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(SlotTimelineData); - -protected: - void _onClear() override; - -public: - /** @private */ - void cacheFrames(std::size_t cacheFrameCount); -}; - -/** - * @private - */ -class FFDTimelineData final : public TimelineData -{ - BIND_CLASS_TYPE(FFDTimelineData); - -public: - std::size_t displayIndex; - SkinData* skin; - SlotDisplayDataSet* slot; - - FFDTimelineData(); - ~FFDTimelineData(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(FFDTimelineData); - -protected: - void _onClear() override; -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_TIMELINE_DATA_H diff --git a/native/cocos/editor-support/dragonbones/parsers/DataParser.cpp b/native/cocos/editor-support/dragonbones/parsers/DataParser.cpp deleted file mode 100644 index d5c57ba914..0000000000 --- a/native/cocos/editor-support/dragonbones/parsers/DataParser.cpp +++ /dev/null @@ -1,515 +0,0 @@ -#include "DataParser.h" -#include "../animation/BaseTimelineState.h" - -DRAGONBONES_NAMESPACE_BEGIN - -const char* DataParser::DATA_VERSION_2_3 = "2.3"; -const char* DataParser::DATA_VERSION_3_0 = "3.0"; -const char* DataParser::DATA_VERSION_4_0 = "4.0"; -const char* DataParser::DATA_VERSION = "4.5"; - -const char* DataParser::TEXTURE_ATLAS = "TextureAtlas"; -const char* DataParser::SUB_TEXTURE = "SubTexture"; -const char* DataParser::FORMAT = "format"; -const char* DataParser::IMAGE_PATH = "imagePath"; -const char* DataParser::WIDTH = "width"; -const char* DataParser::HEIGHT = "height"; -const char* DataParser::ROTATED = "rotated"; -const char* DataParser::FRAME_X = "frameX"; -const char* DataParser::FRAME_Y = "frameY"; -const char* DataParser::FRAME_WIDTH = "frameWidth"; -const char* DataParser::FRAME_HEIGHT = "frameHeight"; - -const char* DataParser::DRADON_BONES = "dragonBones"; -const char* DataParser::ARMATURE = "armature"; -const char* DataParser::BONE = "bone"; -const char* DataParser::IK = "ik"; -const char* DataParser::SLOT = "slot"; -const char* DataParser::SKIN = "skin"; -const char* DataParser::DISPLAY = "display"; -const char* DataParser::ANIMATION = "animation"; -const char* DataParser::FFD = "ffd"; -const char* DataParser::FRAME = "frame"; - -const char* DataParser::PIVOT = "pivot"; -const char* DataParser::TRANSFORM = "transform"; -const char* DataParser::AABB = "aabb"; -const char* DataParser::COLOR = "color"; -const char* DataParser::FILTER = "filter"; - -const char* DataParser::VERSION = "version"; -const char* DataParser::IS_GLOBAL = "isGlobal"; -const char* DataParser::FRAME_RATE = "frameRate"; -const char* DataParser::TYPE = "type"; -const char* DataParser::NAME = "name"; -const char* DataParser::PARENT = "parent"; -const char* DataParser::LENGTH = "length"; -const char* DataParser::DATA = "data"; -const char* DataParser::DISPLAY_INDEX = "displayIndex"; -const char* DataParser::Z_ORDER = "z"; -const char* DataParser::BLEND_MODE = "blendMode"; -const char* DataParser::INHERIT_TRANSLATION = "inheritTranslation"; -const char* DataParser::INHERIT_ROTATION = "inheritRotation"; -const char* DataParser::INHERIT_SCALE = "inheritScale"; -const char* DataParser::TARGET = "target"; -const char* DataParser::BEND_POSITIVE = "bendPositive"; -const char* DataParser::CHAIN = "chain"; -const char* DataParser::WEIGHT = "weight"; - -const char* DataParser::FADE_IN_TIME = "fadeInTime"; -const char* DataParser::PLAY_TIMES = "playTimes"; -const char* DataParser::SCALE = "scale"; -const char* DataParser::OFFSET = "offset"; -const char* DataParser::POSITION = "position"; -const char* DataParser::DURATION = "duration"; -const char* DataParser::TWEEN_EASING = "tweenEasing"; -const char* DataParser::TWEEN_ROTATE = "tweenRotate"; -const char* DataParser::TWEEN_SCALE = "tweenScale"; -const char* DataParser::CURVE = "curve"; -const char* DataParser::EVENT = "event"; -const char* DataParser::SOUND = "sound"; -const char* DataParser::ACTION = "action"; -const char* DataParser::ACTIONS = "actions"; -const char* DataParser::DEFAULT_ACTIONS = "defaultActions"; - -const char* DataParser::X = "x"; -const char* DataParser::Y = "y"; -const char* DataParser::SKEW_X = "skX"; -const char* DataParser::SKEW_Y = "skY"; -const char* DataParser::SCALE_X = "scX"; -const char* DataParser::SCALE_Y = "scY"; - -const char* DataParser::ALPHA_OFFSET = "aO"; -const char* DataParser::RED_OFFSET = "rO"; -const char* DataParser::GREEN_OFFSET = "gO"; -const char* DataParser::BLUE_OFFSET = "bO"; -const char* DataParser::ALPHA_MULTIPLIER = "aM"; -const char* DataParser::RED_MULTIPLIER = "rM"; -const char* DataParser::GREEN_MULTIPLIER = "gM"; -const char* DataParser::BLUE_MULTIPLIER = "bM"; - -const char* DataParser::UVS = "uvs"; -const char* DataParser::VERTICES = "vertices"; -const char* DataParser::TRIANGLES = "triangles"; -const char* DataParser::WEIGHTS = "weights"; -const char* DataParser::SLOT_POSE = "slotPose"; -const char* DataParser::BONE_POSE = "bonePose"; - -const char* DataParser::TWEEN = "tween"; -const char* DataParser::KEY = "key"; - -const char* DataParser::COLOR_TRANSFORM = "colorTransform"; -const char* DataParser::TIMELINE = "timeline"; -const char* DataParser::PIVOT_X = "pX"; -const char* DataParser::PIVOT_Y = "pY"; -const char* DataParser::LOOP = "loop"; -const char* DataParser::AUTO_TWEEN = "autoTween"; -const char* DataParser::HIDE = "hide"; - -TextureFormat DataParser::_getTextureFormat(const std::string& value) -{ - auto lower = value; - std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); - - if (lower == "rgba8888") - { - return TextureFormat::RGBA8888; - } - else if (lower == "bgra8888") - { - return TextureFormat::BGRA8888; - } - else if (lower == "rgba4444") - { - return TextureFormat::RGBA4444; - } - else if (lower == "rgb888") - { - return TextureFormat::RGB888; - } - else if (lower == "rgb565") - { - return TextureFormat::RGB565; - } - else if (lower == "rgba5551") - { - return TextureFormat::RGBA5551; - } - - return TextureFormat::DEFAULT; -} - -ArmatureType DataParser::_getArmatureType(const std::string& value) -{ - auto lower = value; - std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); - - if (lower == "armature") - { - return ArmatureType::Armature; - } - else if (lower == "movieClip") - { - return ArmatureType::MovieClip; - } - else if (lower == "stage") - { - return ArmatureType::Stage; - } - - return ArmatureType::Armature; -} - -DisplayType DataParser::_getDisplayType(const std::string& value) -{ - auto lower = value; - std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); - - if (lower == "image") - { - return DisplayType::Image; - } - else if (lower == "armature") - { - return DisplayType::Armature; - } - else if (lower == "mesh") - { - return DisplayType::Mesh; - } - - return DisplayType::Image; -} - -BlendMode DataParser::_getBlendMode(const std::string& value) -{ - auto lower = value; - std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); - - if (lower == "normal") - { - return BlendMode::Normal; - } - else if (lower == "add") - { - return BlendMode::Add; - } - else if (lower == "alpha") - { - return BlendMode::Alpha; - } - else if (lower == "darken") - { - return BlendMode::Darken; - } - else if (lower == "difference") - { - return BlendMode::Difference; - } - else if (lower == "erase") - { - return BlendMode::Erase; - } - else if (lower == "hardlight") - { - return BlendMode::HardLight; - } - else if (lower == "invert") - { - return BlendMode::Invert; - } - else if (lower == "layer") - { - return BlendMode::Layer; - } - else if (lower == "lighten") - { - return BlendMode::Lighten; - } - else if (lower == "multiply") - { - return BlendMode::Multiply; - } - else if (lower == "overlay") - { - return BlendMode::Overlay; - } - else if (lower == "screen") - { - return BlendMode::Screen; - } - else if (lower == "subtract") - { - return BlendMode::Subtract; - } - - return BlendMode::Normal; -} - -ActionType DataParser::_getActionType(const std::string& value) -{ - auto lower = value; - std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); - - if (lower == "fadeIn") - { - return ActionType::FadeIn; - } - else if (lower == "play") - { - return ActionType::Play; - } - else if (lower == "stop") - { - return ActionType::Stop; - } - else if (lower == "gotoandplay") - { - return ActionType::GotoAndPlay; - } - else if (lower == "gotoandstop") - { - return ActionType::GotoAndStop; - } - else if (lower == "fadeout") - { - return ActionType::FadeOut; - } - - return ActionType::FadeIn; -} - -DataParser::DataParser() : - _data(nullptr), - _armature(nullptr), - _skin(nullptr), - _slotDisplayDataSet(nullptr), - _mesh(nullptr), - _animation(nullptr), - _timeline(nullptr), - - _isOldData(false), - _isGlobalTransform(false), - _isAutoTween(false), - _animationTweenEasing(0.f), - _timelinePivot(), - - _helpPoint(), - _helpTransformA(), - _helpTransformB(), - _helpMatrix(), - _rawBones() -{} -DataParser::~DataParser() {} - -void DataParser::_getTimelineFrameMatrix(const AnimationData& animation, BoneTimelineData& timeline, float position, Transform& transform) const -{ - const auto frameIndex = unsigned(position * animation.frameCount / animation.duration); // floor - if (timeline.frames.size() == 1 || frameIndex >= timeline.frames.size()) - { - transform = timeline.frames[0]->transform; // copy - } - else - { - const auto frame = timeline.frames[frameIndex]; - auto tweenProgress = 0.f; - - if (frame->duration > 0.f && frame->tweenEasing != NO_TWEEN) - { - tweenProgress = (position - frame->position) / frame->duration; - if (frame->tweenEasing != 0.f) - { - tweenProgress = TweenTimelineState::_getEasingValue(tweenProgress, frame->tweenEasing); - } - } - else if (!frame->curve.empty()) - { - tweenProgress = (position - frame->position) / frame->duration; - tweenProgress = TweenTimelineState::_getCurveEasingValue(tweenProgress, frame->curve); - } - - const auto nextFrame = frame->next; - - transform.x = nextFrame->transform.x - frame->transform.x; - transform.y = nextFrame->transform.y - frame->transform.y; - transform.skewX = Transform::normalizeRadian(nextFrame->transform.skewX - frame->transform.skewX); - transform.skewY = Transform::normalizeRadian(nextFrame->transform.skewY - frame->transform.skewY); - transform.scaleX = nextFrame->transform.scaleX - frame->transform.scaleX; - transform.scaleY = nextFrame->transform.scaleY - frame->transform.scaleY; - - transform.x = frame->transform.x + transform.x * tweenProgress; - transform.y = frame->transform.y + transform.y * tweenProgress; - transform.skewX = frame->transform.skewX + transform.skewX * tweenProgress; - transform.skewY = frame->transform.skewY + transform.skewY * tweenProgress; - transform.scaleX = frame->transform.scaleX + transform.scaleX * tweenProgress; - transform.scaleY = frame->transform.scaleY + transform.scaleY * tweenProgress; - } - - transform.add(timeline.originTransform); -} - -void DataParser::_globalToLocal(ArmatureData* armature) const -{ - std::vector keyFrames; - auto bones = armature->getSortedBones(); // copy - bones.reserve(bones.size()); - - for (const auto bone : bones) - { - if (bone->parent) - { - bone->parent->transform.toMatrix(_helpMatrix); - _helpMatrix.invert(); - _helpMatrix.transformPoint(bone->transform.x, bone->transform.y, _helpPoint); - bone->transform.x = _helpPoint.x; - bone->transform.y = _helpPoint.y; - bone->transform.setRotation(bone->transform.getRotation() - bone->parent->transform.getRotation()); - } - - for (const auto& animationPair : armature->animations) - { - const auto animation = animationPair.second; - const auto timeline = animation->getBoneTimeline(bone->name); - - if (!timeline) - { - continue; - } - - const auto parentTimeline = bone->parent ? animation->getBoneTimeline(bone->parent->name) : nullptr; - _helpTransformB = timeline->originTransform; // copy - keyFrames.clear(); - - auto isFirstFrame = true; - for (const auto frame : timeline->frames) - { - if (std::find(keyFrames.cbegin(), keyFrames.cend(), frame) != keyFrames.cend()) - { - continue; - } - - keyFrames.push_back(frame); - - if (parentTimeline) - { - _getTimelineFrameMatrix(*animation, *parentTimeline, frame->position, _helpTransformA); - frame->transform.add(_helpTransformB); - _helpTransformA.toMatrix(_helpMatrix); - _helpMatrix.invert(); - _helpMatrix.transformPoint(frame->transform.x, frame->transform.y, _helpPoint); - frame->transform.setRotation(frame->transform.getRotation() - _helpTransformA.getRotation()); - } - else - { - frame->transform.add(_helpTransformB); - } - - frame->transform.minus(bone->transform); - - if (isFirstFrame) - { - isFirstFrame = false; - timeline->originTransform = frame->transform; - frame->transform.identity(); - } - else - { - frame->transform.minus(timeline->originTransform); - } - } - } - } -} - -void DataParser::_mergeFrameToAnimationTimeline(float framePosition, const std::vector& actions, const std::vector& events) const -{ - const auto frameStart = std::floor(framePosition * _armature->frameRate); - auto& frames = _animation->frames; - - if (frames.empty()) - { - const auto startFrame = BaseObject::borrowObject(); - startFrame->position = 0.f; - - if (_animation->frameCount > 1) - { - frames.resize(_animation->frameCount + 1, nullptr); - - const auto endFrame = BaseObject::borrowObject(); - endFrame->position = _animation->frameCount / _armature->frameRate; - - frames[0] = startFrame; - frames[_animation->frameCount] = endFrame; - } - } - - auto insertedFrame = (AnimationFrameData*)nullptr; - const auto replacedFrame = frames[frameStart]; - - if (replacedFrame && (frameStart == 0 || frames[frameStart - 1] == replacedFrame->prev)) - { - insertedFrame = replacedFrame; - } - else - { - insertedFrame = BaseObject::borrowObject(); - insertedFrame->position = frameStart / _armature->frameRate; - frames[frameStart] = insertedFrame; - - for (size_t i = frameStart + 1, l = frames.size(); i < l; ++i) - { - if (replacedFrame && frames[i] == replacedFrame) - { - frames[i] = nullptr; - } - } - } - - if (!actions.empty()) - { - for (const auto action : actions) - { - insertedFrame->actions.push_back(action); - } - } - - if (!events.empty()) - { - for (const auto event : events) - { - insertedFrame->events.push_back(event); - } - } - - auto prevFrame = (AnimationFrameData*)nullptr; - auto nextFrame = (AnimationFrameData*)nullptr; - for (size_t i = 0, l = frames.size(); i < l; ++i) - { - const auto currentFrame = frames[i]; - if (currentFrame && nextFrame != currentFrame) - { - nextFrame = currentFrame; - - if (prevFrame) { - nextFrame->prev = prevFrame; - prevFrame->next = nextFrame; - prevFrame->duration = nextFrame->position - prevFrame->position; - } - - prevFrame = nextFrame; - } - else - { - frames[i] = prevFrame; - } - } - - nextFrame->duration = _animation->duration - nextFrame->position; - - nextFrame = frames[0]; - prevFrame->next = nextFrame; - nextFrame->prev = prevFrame; -} - - -DRAGONBONES_NAMESPACE_END diff --git a/native/cocos/editor-support/dragonbones/parsers/DataParser.h b/native/cocos/editor-support/dragonbones/parsers/DataParser.h deleted file mode 100644 index 3b40bb716d..0000000000 --- a/native/cocos/editor-support/dragonbones/parsers/DataParser.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef DRAGONBONES_DATA_PARSER_H -#define DRAGONBONES_DATA_PARSER_H - -#include "../core/DragonBones.h" -#include "../model/DragonBonesData.h" -#include "../textures/TextureData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -/** - * @private - */ -class DataParser -{ -protected: - static const char* DATA_VERSION_2_3; - static const char* DATA_VERSION_3_0; - static const char* DATA_VERSION_4_0; - static const char* DATA_VERSION; - static const char* TEXTURE_ATLAS; - static const char* SUB_TEXTURE; - static const char* FORMAT; - static const char* IMAGE_PATH; - static const char* WIDTH; - static const char* HEIGHT; - static const char* ROTATED; - static const char* FRAME_X; - static const char* FRAME_Y; - static const char* FRAME_WIDTH; - static const char* FRAME_HEIGHT; - - static const char* DRADON_BONES; - static const char* ARMATURE; - static const char* BONE; - static const char* IK; - static const char* SLOT; - static const char* SKIN; - static const char* DISPLAY; - static const char* ANIMATION; - static const char* FFD; - static const char* FRAME; - - static const char* PIVOT; - static const char* TRANSFORM; - static const char* AABB; - static const char* COLOR; - static const char* FILTER; - - static const char* VERSION; - static const char* IS_GLOBAL; - static const char* FRAME_RATE; - static const char* TYPE; - static const char* NAME; - static const char* PARENT; - static const char* LENGTH; - static const char* DATA; - static const char* DISPLAY_INDEX; - static const char* Z_ORDER; - static const char* BLEND_MODE; - static const char* INHERIT_TRANSLATION; - static const char* INHERIT_ROTATION; - static const char* INHERIT_SCALE; - static const char* TARGET; - static const char* BEND_POSITIVE; - static const char* CHAIN; - static const char* WEIGHT; - - static const char* FADE_IN_TIME; - static const char* PLAY_TIMES; - static const char* SCALE; - static const char* OFFSET; - static const char* POSITION; - static const char* DURATION; - static const char* TWEEN_EASING; - static const char* TWEEN_ROTATE; - static const char* TWEEN_SCALE; - static const char* CURVE; - static const char* EVENT; - static const char* SOUND; - static const char* ACTION; - static const char* ACTIONS; - static const char* DEFAULT_ACTIONS; - - static const char* X; - static const char* Y; - static const char* SKEW_X; - static const char* SKEW_Y; - static const char* SCALE_X; - static const char* SCALE_Y; - - static const char* ALPHA_OFFSET; - static const char* RED_OFFSET; - static const char* GREEN_OFFSET; - static const char* BLUE_OFFSET; - static const char* ALPHA_MULTIPLIER; - static const char* RED_MULTIPLIER; - static const char* GREEN_MULTIPLIER; - static const char* BLUE_MULTIPLIER; - - static const char* UVS; - static const char* VERTICES; - static const char* TRIANGLES; - static const char* WEIGHTS; - static const char* SLOT_POSE; - static const char* BONE_POSE; - - static const char* TWEEN; - static const char* KEY; - - static const char* COLOR_TRANSFORM; - static const char* TIMELINE; - static const char* PIVOT_X; - static const char* PIVOT_Y; - static const char* LOOP; - static const char* AUTO_TWEEN; - static const char* HIDE; - - static TextureFormat _getTextureFormat(const std::string& value); - static ArmatureType _getArmatureType(const std::string& value); - static DisplayType _getDisplayType(const std::string& value); - static BlendMode _getBlendMode(const std::string& value); - static ActionType _getActionType(const std::string& value); - -protected: - DragonBonesData* _data; - ArmatureData* _armature; - SkinData* _skin; - SlotDisplayDataSet* _slotDisplayDataSet; - mutable MeshData* _mesh; - mutable AnimationData* _animation; - mutable void* _timeline; // TimelineData* - - bool _isOldData; - bool _isGlobalTransform; - mutable bool _isAutoTween; - mutable float _animationTweenEasing; - mutable Point _timelinePivot; - - mutable Point _helpPoint; - mutable Transform _helpTransformA; - mutable Transform _helpTransformB; - mutable Matrix _helpMatrix; - std::vector _rawBones; - -public: - DataParser(); - virtual ~DataParser() = 0; - - virtual DragonBonesData* parseDragonBonesData(const char* rawData, float scale = 1.f) = 0; - virtual void parseTextureAtlasData(const char* rawData, TextureAtlasData& textureAtlasData, float scale = 0.f) = 0; - -private: - void _getTimelineFrameMatrix(const AnimationData& animation, BoneTimelineData& timeline, float position, Transform& transform) const; - -protected: - void _globalToLocal(ArmatureData* armature) const; - - void _mergeFrameToAnimationTimeline(float framePosition, const std::vector& actions, const std::vector& events) const; -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_DATA_PARSER_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/parsers/JSONDataParser.cpp b/native/cocos/editor-support/dragonbones/parsers/JSONDataParser.cpp deleted file mode 100644 index f78a9e8240..0000000000 --- a/native/cocos/editor-support/dragonbones/parsers/JSONDataParser.cpp +++ /dev/null @@ -1,1065 +0,0 @@ -#include "JSONDataParser.h" - -DRAGONBONES_NAMESPACE_BEGIN - -JSONDataParser::JSONDataParser() {} -JSONDataParser::~JSONDataParser() {} - -ArmatureData * JSONDataParser::_parseArmature(const rapidjson::Value & rawData, float scale) -{ - const auto armature = BaseObject::borrowObject(); - armature->name = _getString(rawData, NAME, ""); - armature->frameRate = _getNumber(rawData, FRAME_RATE, this->_data->frameRate); - armature->scale = scale; - - if (armature->frameRate == 0) - { - armature->frameRate = this->_data->frameRate; - } - - if (rawData.HasMember(TYPE) && rawData[TYPE].IsString()) - { - armature->type = _getArmatureType(rawData[TYPE].GetString()); - } - else - { - armature->type = (ArmatureType)_getNumber(rawData, TYPE, (int)ArmatureType::Armature); - } - - this->_armature = armature; - this->_rawBones.clear(); - - if (rawData.HasMember(AABB)) - { - const auto& aabbObject = rawData[AABB]; - armature->aabb.x = _getNumber(aabbObject, X, 0.f); - armature->aabb.y = _getNumber(aabbObject, Y, 0.f); - armature->aabb.width = _getNumber(aabbObject, WIDTH, 0.f); - armature->aabb.height = _getNumber(aabbObject, HEIGHT, 0.f); - } - - if (rawData.HasMember(BONE)) - { - const auto& bones = rawData[BONE]; - for (size_t i = 0, l = bones.Size(); i < l; ++i) - { - const auto bone = _parseBone(bones[i]); - armature->addBone(bone, _getString(bones[i], PARENT, "")); - this->_rawBones.push_back(bone); - } - } - - if (rawData.HasMember(IK)) - { - const auto& iks = rawData[IK]; - for (size_t i = 0, l = iks.Size(); i < l; ++i) - { - _parseIK(iks[i]); - } - } - - if (rawData.HasMember(SLOT)) - { - int zOrder = 0; - const auto& slots = rawData[SLOT]; - for (size_t i = 0, l = slots.Size(); i < l; ++i) - { - armature->addSlot(_parseSlot(slots[i], zOrder++)); - } - } - - if (rawData.HasMember(SKIN)) - { - const auto& skins = rawData[SKIN]; - for (size_t i = 0, l = skins.Size(); i < l; ++i) - { - armature->addSkin(_parseSkin(skins[i])); - } - } - - if (rawData.HasMember(ANIMATION)) - { - const auto& animations = rawData[ANIMATION]; - for (size_t i = 0, l = animations.Size(); i < l; ++i) - { - armature->addAnimation(_parseAnimation(animations[i])); - } - } - - if (rawData.HasMember(ACTIONS) || rawData.HasMember(DEFAULT_ACTIONS)) - { - _parseActionData(rawData, armature->actions, nullptr, nullptr); - } - - if (this->_isOldData && _getBoolean(rawData, IS_GLOBAL, true)) - { - this->_globalToLocal(armature); - } - - this->_armature = nullptr; - this->_rawBones.clear(); - - return armature; -} - -BoneData * JSONDataParser::_parseBone(const rapidjson::Value & rawData) -{ - const auto bone = BaseObject::borrowObject(); - bone->name = _getString(rawData, NAME, ""); - bone->inheritTranslation = _getBoolean(rawData, INHERIT_TRANSLATION, true); - bone->inheritRotation = _getBoolean(rawData, INHERIT_ROTATION, true); - bone->inheritScale = _getBoolean(rawData, INHERIT_SCALE, true); - bone->length = _getNumber(rawData, LENGTH, 0.f) * this->_armature->scale; - - if (rawData.HasMember(TRANSFORM)) - { - _parseTransform(rawData[TRANSFORM], bone->transform); - } - - if (this->_isOldData) - { - bone->inheritScale = false; - } - - return bone; -} - -void JSONDataParser::_parseIK(const rapidjson::Value & rawData) -{ - const auto bone = this->_armature->getBone(_getString(rawData, rawData.HasMember(BONE) ? BONE : NAME, "")); - if (bone) - { - bone->ik = this->_armature->getBone(_getString(rawData, TARGET, "")); - bone->bendPositive = _getBoolean(rawData, BEND_POSITIVE, true); - bone->chain = _getNumber(rawData, CHAIN, (unsigned)0); - bone->weight = _getNumber(rawData, WEIGHT, 1.f); - - if (bone->chain > 0 && bone->parent && !bone->parent->ik) - { - bone->parent->ik = bone->ik; - bone->parent->chainIndex = 0; - bone->parent->chain = 0; - bone->chainIndex = 1; - } - else - { - bone->chain = 0; - bone->chainIndex = 0; - } - } -} - -SlotData * JSONDataParser::_parseSlot(const rapidjson::Value& rawData, int zOrder) -{ - const auto slot = BaseObject::borrowObject(); - slot->name = _getString(rawData, NAME, ""); - slot->parent = this->_armature->getBone(_getString(rawData, PARENT, "")); - slot->displayIndex = _getNumber(rawData, DISPLAY_INDEX, (int)0); - slot->zOrder = _getNumber(rawData, Z_ORDER, zOrder); - - if (rawData.HasMember(COLOR)) - { - slot->color = SlotData::generateColor(); - _parseColorTransform(rawData[COLOR], *slot->color); - } - else - { - slot->color = &SlotData::DEFAULT_COLOR; - } - - if (rawData.HasMember(BLEND_MODE) && rawData[BLEND_MODE].IsString()) - { - slot->blendMode = _getBlendMode(rawData[BLEND_MODE].GetString()); - } - else - { - slot->blendMode = (BlendMode)_getNumber(rawData, BLEND_MODE, (int)BlendMode::Normal); - } - - if (rawData.HasMember(ACTIONS) || rawData.HasMember(DEFAULT_ACTIONS)) - { - _parseActionData(rawData, slot->actions, nullptr, nullptr); - } - - if (this->_isOldData) - { - if (rawData.HasMember(COLOR_TRANSFORM)) - { - slot->color = SlotData::generateColor(); - _parseColorTransform(rawData[COLOR_TRANSFORM], *slot->color); - } - else - { - slot->color = &SlotData::DEFAULT_COLOR; - } - } - - return slot; -} - -SkinData * JSONDataParser::_parseSkin(const rapidjson::Value & rawData) -{ - const auto skin = BaseObject::borrowObject(); - skin->name = _getString(rawData, NAME, "__default"); - if (skin->name.empty()) - { - skin->name = "__default"; - } - - if (rawData.HasMember(SLOT)) - { - this->_skin = skin; - - int zOrder = 0; - const auto& slots = rawData[SLOT]; - for (size_t i = 0, l = slots.Size(); i < l; ++i) - { - if (this->_isOldData) - { - this->_armature->addSlot(_parseSlot(slots[i], zOrder++)); - } - - skin->addSlot(_parseSlotDisplaySet(slots[i])); - } - - this->_skin = nullptr; - } - - return skin; -} - -SlotDisplayDataSet * JSONDataParser::_parseSlotDisplaySet(const rapidjson::Value & rawData) -{ - const auto slotDisplayDataSet = BaseObject::borrowObject(); - slotDisplayDataSet->slot = this->_armature->getSlot(_getString(rawData, NAME, "")); - - if (rawData.HasMember(DISPLAY)) - { - this->_slotDisplayDataSet = slotDisplayDataSet; - - const auto& displayObjects = rawData[DISPLAY]; - auto& displayDataSet = slotDisplayDataSet->displays; - displayDataSet.reserve(displayObjects.Size()); - for (size_t i = 0, l = displayObjects.Size(); i < l; ++i) - { - displayDataSet.push_back(_parseDisplay(displayObjects[i])); - } - - this->_slotDisplayDataSet = nullptr; - } - - return slotDisplayDataSet; -} - -DisplayData * JSONDataParser::_parseDisplay(const rapidjson::Value & rawData) -{ - const auto display = BaseObject::borrowObject(); - display->name = _getString(rawData, NAME, ""); - - if (rawData.HasMember(TYPE) && rawData[TYPE].IsString()) - { - display->type = _getDisplayType(rawData[TYPE].GetString()); - } - else - { - display->type = (DisplayType)_getNumber(rawData, TYPE, (int)DisplayType::Image); - } - - display->isRelativePivot = true; - if (rawData.HasMember(PIVOT)) - { - const auto& pivotObject = rawData[PIVOT]; - display->pivot.x = _getNumber(pivotObject, X, 0.f); - display->pivot.y = _getNumber(pivotObject, Y, 0.f); - } - else if (this->_isOldData) - { - const auto& transformObject = rawData[TRANSFORM]; - display->isRelativePivot = false; - display->pivot.x = _getNumber(transformObject, PIVOT_X, 0.f) * this->_armature->scale; - display->pivot.y = _getNumber(transformObject, PIVOT_Y, 0.f) * this->_armature->scale; - } - else - { - display->pivot.x = 0.5f; - display->pivot.y = 0.5f; - } - - if (rawData.HasMember(TRANSFORM)) - { - _parseTransform(rawData[TRANSFORM], display->transform); - } - - switch (display->type) - { - case DisplayType::Image: - break; - - case DisplayType::Armature: - break; - - case DisplayType::Mesh: - display->mesh = _parseMesh(rawData); - break; - } - - return display; -} - -MeshData * JSONDataParser::_parseMesh(const rapidjson::Value & rawData) -{ - const auto mesh = BaseObject::borrowObject(); - - const auto& rawVertices = rawData[VERTICES]; - const auto& rawUVs = rawData[UVS]; - const auto& rawTriangles = rawData[TRIANGLES]; - - const auto numVertices = (unsigned)(rawVertices.Size() / 2); - const auto numTriangles = (unsigned)(rawTriangles.Size() / 3); - - std::vector inverseBindPose(this->_armature->getSortedBones().size(), Matrix()); - - mesh->skinned = rawData.HasMember(WEIGHTS) && !rawData[WEIGHTS].Empty(); - mesh->uvs.resize(numVertices * 2); - mesh->vertices.resize(numVertices * 2); - mesh->vertexIndices.resize(numTriangles * 3); - - if (mesh->skinned) - { - mesh->boneIndices.resize(numVertices); - mesh->weights.resize(numVertices); - mesh->boneVertices.resize(numVertices); - - if (rawData.HasMember(SLOT_POSE)) - { - const auto& rawSlotPose = rawData[SLOT_POSE]; - mesh->slotPose.a = rawSlotPose[0].GetDouble(); - mesh->slotPose.b = rawSlotPose[1].GetDouble(); - mesh->slotPose.c = rawSlotPose[2].GetDouble(); - mesh->slotPose.d = rawSlotPose[3].GetDouble(); - mesh->slotPose.tx = rawSlotPose[4].GetDouble() * this->_armature->scale; - mesh->slotPose.ty = rawSlotPose[5].GetDouble() * this->_armature->scale; - } - - if (rawData.HasMember(BONE_POSE)) - { - const auto& rawBonePose = rawData[BONE_POSE]; - for (std::size_t i = 0, l = rawBonePose.Size(); i < l; i += 7) - { - const auto rawBoneIndex = rawBonePose[i].GetUint(); - auto& boneMatrix = inverseBindPose[rawBoneIndex]; - boneMatrix.a = rawBonePose[i + 1].GetDouble(); - boneMatrix.b = rawBonePose[i + 2].GetDouble(); - boneMatrix.c = rawBonePose[i + 3].GetDouble(); - boneMatrix.d = rawBonePose[i + 4].GetDouble(); - boneMatrix.tx = rawBonePose[i + 5].GetDouble() * this->_armature->scale; - boneMatrix.ty = rawBonePose[i + 6].GetDouble() * this->_armature->scale; - boneMatrix.invert(); - } - } - } - - for (std::size_t i = 0, iW = 0, l = rawVertices.Size(); i < l; i += 2) - { - const auto iN = i + 1; - const auto vertexIndex = i / 2; - - auto x = mesh->vertices[i] = rawVertices[i].GetDouble() * this->_armature->scale; - auto y = mesh->vertices[iN] = rawVertices[iN].GetDouble() * this->_armature->scale; - mesh->uvs[i] = rawUVs[i].GetDouble(); - mesh->uvs[iN] = rawUVs[iN].GetDouble(); - - if (mesh->skinned) - { - const auto& rawWeights = rawData[WEIGHTS]; - const auto numBones = rawWeights[iW].GetUint(); - auto& indices = mesh->boneIndices[vertexIndex]; - auto& weights = mesh->weights[vertexIndex]; - auto& boneVertices = mesh->boneVertices[vertexIndex]; - mesh->slotPose.transformPoint(x, y, _helpPoint); - x = mesh->vertices[i] = _helpPoint.x; - y = mesh->vertices[iN] = _helpPoint.y; - - for (std::size_t iB = 0; iB < numBones; ++iB) - { - const auto iI = iW + 1 + iB * 2; - const auto rawBoneIndex = rawWeights[iI].GetUint(); - const auto boneData = this->_rawBones[rawBoneIndex]; - - const auto iderator = std::find(mesh->bones.cbegin(), mesh->bones.cend(), boneData); - std::size_t boneIndex = 0; - if (iderator == mesh->bones.cend()) - { - boneIndex = mesh->bones.size(); - mesh->bones.push_back(boneData); - mesh->inverseBindPose.push_back(inverseBindPose[rawBoneIndex]); // copy - } - else - { - boneIndex = std::distance(mesh->bones.cbegin(), iderator); - } - - mesh->inverseBindPose[boneIndex].transformPoint(x, y, _helpPoint); - - indices.push_back(boneIndex); - weights.push_back(rawWeights[iI + 1].GetDouble()); - boneVertices.push_back(_helpPoint.x); - boneVertices.push_back(_helpPoint.y); - } - - iW += numBones * 2 + 1; - } - } - - for (std::size_t i = 0, l = rawTriangles.Size(); i < l; ++i) - { - mesh->vertexIndices[i] = rawTriangles[i].GetUint(); - } - - return mesh; -} - -AnimationData * JSONDataParser::_parseAnimation(const rapidjson::Value & rawData) const -{ - const auto animation = BaseObject::borrowObject(); - animation->name = _getString(rawData, NAME, "__default"); - if (animation->name.empty()) - { - animation->name = "__default"; - } - - animation->frameCount = std::max(_getNumber(rawData, DURATION, (unsigned)1), (unsigned)1); - animation->position = _getNumber(rawData, POSITION, 0.f) / this->_armature->frameRate; - animation->duration = (float)animation->frameCount / this->_armature->frameRate; - animation->playTimes = _getNumber(rawData, PLAY_TIMES, (unsigned)1); - animation->fadeInTime = _getNumber(rawData, FADE_IN_TIME, 0.f); - - this->_animation = animation; - - std::string animationName = _getString(rawData, ANIMATION, ""); - if (!animationName.empty()) - { - animation->animation = this->_armature->getAnimation(animationName); - if (!animation->animation) - { - } - - return animation; - } - - _parseTimeline(rawData, *animation, std::bind(&JSONDataParser::_parseAnimationFrame, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - - if (rawData.HasMember(BONE)) - { - const auto& boneTimelineObjects = rawData[BONE]; - for (size_t i = 0, l = boneTimelineObjects.Size(); i < l; ++i) - { - animation->addBoneTimeline(_parseBoneTimeline(boneTimelineObjects[i])); - } - } - - if (rawData.HasMember(SLOT)) - { - const auto& slotTimelineObjects = rawData[SLOT]; - for (size_t i = 0, l = slotTimelineObjects.Size(); i < l; ++i) - { - animation->addSlotTimeline(_parseSlotTimeline(slotTimelineObjects[i])); - } - } - - if (rawData.HasMember(FFD)) - { - const auto& ffdTimelineObjects = rawData[FFD]; - for (size_t i = 0, l = ffdTimelineObjects.Size(); i < l; ++i) - { - animation->addFFDTimeline(_parseFFDTimeline(ffdTimelineObjects[i])); - } - } - - if (this->_isOldData) - { - this->_isAutoTween = _getBoolean(rawData, AUTO_TWEEN, true); - this->_animationTweenEasing = _getNumber(rawData, TWEEN_EASING, 0.f) || 0.f; - animation->playTimes = _getNumber(rawData, LOOP, (unsigned)1); - - if (rawData.HasMember(TIMELINE)) - { - const auto& timelineObjects = rawData[TIMELINE]; - for (size_t i = 0, l = timelineObjects.Size(); i < l; ++i) - { - const auto& timelineObject = timelineObjects[i]; - animation->addBoneTimeline(_parseBoneTimeline(timelineObject)); - animation->addSlotTimeline(_parseSlotTimeline(timelineObject)); - } - } - } - else - { - this->_isAutoTween = false; - this->_animationTweenEasing = 0.f; - } - - for (const auto& pair : this->_armature->bones) - { - if (!animation->getBoneTimeline(pair.second->name)) - { - const auto boneTimeline = BaseObject::borrowObject(); - const auto boneFrame = BaseObject::borrowObject(); - boneTimeline->bone = pair.second; - boneTimeline->frames.reserve(1); - boneTimeline->frames.push_back(boneFrame); - animation->addBoneTimeline(boneTimeline); - } - } - - for (const auto& pair : this->_armature->slots) - { - if (!animation->getSlotTimeline(pair.second->name)) - { - const auto slotTimeline = BaseObject::borrowObject(); - const auto slotFrame = BaseObject::borrowObject(); - slotTimeline->slot = pair.second; - slotFrame->displayIndex = pair.second->displayIndex; - - if (pair.second->color == &SlotData::DEFAULT_COLOR) - { - slotFrame->color = &SlotFrameData::DEFAULT_COLOR; - } - else - { - slotFrame->color = SlotFrameData::generateColor(); - *slotFrame->color = *pair.second->color; // copy - } - - slotTimeline->frames.reserve(1); - slotTimeline->frames.push_back(slotFrame); - animation->addSlotTimeline(slotTimeline); - - if (this->_isOldData) - { - slotFrame->displayIndex = -1; - } - } - } - - this->_animation = nullptr; - - return animation; -} - -BoneTimelineData * JSONDataParser::_parseBoneTimeline(const rapidjson::Value& rawData) const -{ - const auto timeline = BaseObject::borrowObject(); - timeline->bone = this->_armature->getBone(_getString(rawData, NAME, "")); - - _parseTimeline(rawData, *timeline, std::bind(&JSONDataParser::_parseBoneFrame, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - - auto& originTransform = timeline->originTransform; - BoneFrameData* prevFrame = nullptr; - - for (const auto frame : timeline->frames) - { - if (!prevFrame) - { - originTransform = frame->transform; // copy - frame->transform.identity(); - - if (originTransform.scaleX == 0.f) - { - originTransform.scaleX = 0.001f; - //frame->transform.scaleX = 0.f; - } - - if (originTransform.scaleY == 0.f) - { - originTransform.scaleY = 0.001f; - //frame->transform.scaleY = 0.f; - } - } - else if (prevFrame != frame) - { - frame->transform.minus(originTransform); - } - - prevFrame = frame; - } - - if (timeline->scale != 1.f || timeline->offset != 0.f) - { - this->_animation->hasAsynchronyTimeline = true; - } - - if ( - this->_isOldData && - (rawData.HasMember(PIVOT_X) || rawData.HasMember(PIVOT_Y)) - ) - { - this->_timelinePivot.x = _getNumber(rawData, PIVOT_X, 0.f); - this->_timelinePivot.y = _getNumber(rawData, PIVOT_Y, 0.f); - } - else - { - _timelinePivot.clear(); - } - - return timeline; -} - -SlotTimelineData * JSONDataParser::_parseSlotTimeline(const rapidjson::Value& rawData) const -{ - const auto timeline = BaseObject::borrowObject(); - timeline->slot = this->_armature->getSlot(_getString(rawData, NAME, "")); - - _parseTimeline(rawData, *timeline, std::bind(&JSONDataParser::_parseSlotFrame, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - - if (timeline->scale != 1.f || timeline->offset != 0.f) - { - this->_animation->hasAsynchronyTimeline = true; - } - - return timeline; -} - -FFDTimelineData * JSONDataParser::_parseFFDTimeline(const rapidjson::Value& rawData) const -{ - const auto timeline = BaseObject::borrowObject(); - timeline->skin = this->_armature->getSkin(_getString(rawData, SKIN, "")); - timeline->slot = timeline->skin->getSlot(_getString(rawData, SLOT, "")); - - const auto meshName = _getString(rawData, NAME, ""); - for (std::size_t i = 0, l = timeline->slot->displays.size(); i < l; ++i) - { - const auto displayData = timeline->slot->displays[i]; - if (displayData->mesh && displayData->name == meshName) - { - timeline->displayIndex = i; - this->_mesh = displayData->mesh; - break; - } - } - - _parseTimeline(rawData, *timeline, std::bind(&JSONDataParser::_parseFFDFrame, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - - this->_mesh = nullptr; - - return timeline; -} - -AnimationFrameData * JSONDataParser::_parseAnimationFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount) const -{ - const auto frame = BaseObject::borrowObject(); - - _parseFrame(rawData, *frame, frameStart, frameCount); - - if (rawData.HasMember(ACTION) || rawData.HasMember(ACTIONS)) - { - _parseActionData(rawData, frame->actions, nullptr, nullptr); - } - - if (rawData.HasMember(EVENT) || rawData.HasMember(SOUND)) - { - _parseEventData(rawData, frame->events, nullptr, nullptr); - } - - return frame; -} - -BoneFrameData * JSONDataParser::_parseBoneFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount) const -{ - const auto frame = BaseObject::borrowObject(); - frame->parent = this->_armature->getBone(_getString(rawData, PARENT, "")); - frame->tweenRotate = _getNumber(rawData, TWEEN_ROTATE, (int)0); - frame->tweenScale = _getBoolean(rawData, TWEEN_SCALE, true); - - _parseTweenFrame(rawData, *frame, frameStart, frameCount); - - if (rawData.HasMember(TRANSFORM)) - { - const auto& transformObject = rawData[TRANSFORM]; - _parseTransform(transformObject, frame->transform); - - if (this->_isOldData) - { - this->_helpPoint.x = this->_timelinePivot.x + _getNumber(transformObject, PIVOT_X, 0.f); - this->_helpPoint.y = this->_timelinePivot.y + _getNumber(transformObject, PIVOT_Y, 0.f); - frame->transform.toMatrix(this->_helpMatrix); - this->_helpMatrix.transformPoint(this->_helpPoint.x, this->_helpPoint.y, this->_helpPoint, true); - frame->transform.x += this->_helpPoint.x; - frame->transform.y += this->_helpPoint.y; - } - } - - const auto bone = static_cast(this->_timeline)->bone; - std::vector actions; - std::vector events; - - if (rawData.HasMember(ACTION) || rawData.HasMember(ACTIONS)) - { - const auto slot = this->_armature->getSlot(bone->name); - _parseActionData(rawData, actions, bone, slot); - } - - if ((rawData.HasMember(EVENT) || rawData.HasMember(SOUND))) - { - _parseEventData(rawData, events, bone, nullptr); - } - - if (!actions.empty() || !events.empty()) - { - this->_mergeFrameToAnimationTimeline(frame->position, actions, events); - } - - return frame; -} - -SlotFrameData * JSONDataParser::_parseSlotFrame(const rapidjson::Value & rawData, unsigned frameStart, unsigned frameCount) const -{ - const auto frame = BaseObject::borrowObject(); - frame->displayIndex = _getNumber(rawData, DISPLAY_INDEX, (int)0); - - _parseTweenFrame(rawData, *frame, frameStart, frameCount); - - if (rawData.HasMember(COLOR) || rawData.HasMember(COLOR_TRANSFORM)) - { - frame->color = SlotFrameData::generateColor(); - _parseColorTransform(rawData.HasMember(COLOR) ? rawData[COLOR] : rawData[COLOR_TRANSFORM], *frame->color); - } - else - { - frame->color = &SlotFrameData::DEFAULT_COLOR; - } - - if (this->_isOldData) - { - if (_getBoolean(rawData, HIDE, false)) - { - frame->displayIndex = -1; - } - } - else if (rawData.HasMember(ACTION) || rawData.HasMember(ACTIONS)) - { - const auto slot = static_cast(this->_timeline)->slot; - std::vector actions; - std::vector events; - _parseActionData(rawData, actions, slot->parent, slot); - - this->_mergeFrameToAnimationTimeline(frame->position, actions, events); - } - - return frame; -} - -ExtensionFrameData * JSONDataParser::_parseFFDFrame(const rapidjson::Value & rawData, unsigned frameStart, unsigned frameCount) const -{ - const auto frame = BaseObject::borrowObject(); - frame->type = (ExtensionType)_getNumber(rawData, TYPE, (int)ExtensionType::FFD); - - _parseTweenFrame(rawData, *frame, frameStart, frameCount); - - const auto hasVertices = rawData.HasMember(VERTICES); - const auto offset = _getNumber(rawData, OFFSET, (unsigned)0); - auto x = 0.f; - auto y = 0.f; - for (std::size_t i = 0, l = this->_mesh->vertices.size(); i < l; i += 2) - { - if (hasVertices) - { - const auto& rawVertices = rawData[VERTICES]; - if (i < offset || i - offset >= rawVertices.Size()) - { - x = 0.f; - y = 0.f; - } - else - { - x = rawVertices[i - offset].GetDouble() * this->_armature->scale; - y = rawVertices[i + 1 - offset].GetDouble() * this->_armature->scale; - } - } - else - { - x = 0.f; - y = 0.f; - } - - if (this->_mesh->skinned) - { - this->_mesh->slotPose.transformPoint(x, y, _helpPoint, true); - x = _helpPoint.x; - y = _helpPoint.y; - - const auto& boneIndices = this->_mesh->boneIndices[(std::size_t)(i / 2)]; - for (const auto boneIndex : boneIndices) - { - this->_mesh->inverseBindPose[boneIndex].transformPoint(x, y, _helpPoint, true); - frame->tweens.push_back(_helpPoint.x); - frame->tweens.push_back(_helpPoint.y); - } - } - else - { - frame->tweens.push_back(x); - frame->tweens.push_back(y); - } - } - - return frame; -} - -void JSONDataParser::_parseActionData(const rapidjson::Value& rawData, std::vector& actions, BoneData * bone, SlotData * slot) const -{ - const auto& actionsObject = rawData.HasMember(ACTION) ? rawData[ACTION] : (rawData.HasMember(ACTIONS) ? rawData[ACTIONS] : rawData[DEFAULT_ACTIONS]); - - if (actionsObject.IsString()) - { - const auto actionData = BaseObject::borrowObject(); - actionData->type = ActionType::FadeIn; - - auto& ints = std::get<0>(actionData->data); - auto& floats = std::get<1>(actionData->data); - auto& strings = std::get<2>(actionData->data); - - strings.push_back(actionsObject.GetString()); - floats.push_back(-1.f); - ints.push_back(-1); - - actionData->bone = bone; - actionData->slot = slot; - actions.push_back(actionData); - } - else if (actionsObject.IsArray()) - { - const char* GOTO_AND_PLAY = "gotoAndPlay"; - for (size_t i = 0, l = actionsObject.Size(); i < l; ++i) - { - const auto& actionObject = actionsObject[i]; - const auto isArray = actionObject.IsArray(); - const auto actionData = BaseObject::borrowObject(); - const auto animationName = isArray ? _getParameter(actionObject, 1, "") : _getString(actionObject, GOTO_AND_PLAY, ""); - - if (isArray) - { - const auto& actionType = actionObject[0]; - if (actionType.IsString()) - { - actionData->type = _getActionType(actionType.GetString()); - } - else - { - actionData->type = (ActionType)_getParameter(actionObject, 0, (int)ActionType::FadeIn); - } - } - else - { - actionData->type = ActionType::GotoAndPlay; - } - - auto& ints = std::get<0>(actionData->data); - auto& floats = std::get<1>(actionData->data); - auto& strings = std::get<2>(actionData->data); - - switch (actionData->type) - { - case ActionType::Play: - strings.push_back(animationName); - ints.push_back(isArray ? _getParameter(actionObject, 2, (int)-1) : -1); - break; - - case ActionType::Stop: - strings.push_back(animationName); - break; - - case ActionType::GotoAndPlay: - strings.push_back(animationName); - floats.push_back(isArray ? _getParameter(actionObject, 2, 0.f) : 0.f); - ints.push_back(isArray ? _getParameter(actionObject, 3, (int)-1) : -1); - break; - - case ActionType::GotoAndStop: - strings.push_back(animationName); - floats.push_back(isArray ? _getParameter(actionObject, 2, 0.f) : 0.f); - break; - - case ActionType::FadeIn: - strings.push_back(animationName); - floats.push_back(isArray ? _getParameter(actionObject, 2, -1.f) : -1.f); - ints.push_back(isArray ? _getParameter(actionObject, 3, (int)-1) : -1); - break; - - case ActionType::FadeOut: - strings.push_back(animationName); - floats.push_back(isArray ? _getParameter(actionObject, 2, 0.f) : 0.f); - break; - } - - actionData->bone = bone; - actionData->slot = slot; - actions.push_back(actionData); - } - } -} - -void JSONDataParser::_parseEventData(const rapidjson::Value& rawData, std::vector& events, BoneData* bone, SlotData* slot) const -{ - if (rawData.HasMember(SOUND)) - { - const auto eventData = BaseObject::borrowObject(); - eventData->type = EventType::Sound; - eventData->name = rawData[SOUND].GetString(); - eventData->bone = bone; - eventData->slot = slot; - events.push_back(eventData); - } - - if (rawData.HasMember(EVENT)) - { - const auto eventData = BaseObject::borrowObject(); - eventData->type = EventType::Frame; - eventData->name = rawData[EVENT].GetString(); - eventData->bone = bone; - eventData->slot = slot; - - if (rawData.HasMember(DATA)) - { - // eventData->data = rawData[DATA]; // TODO - } - - events.push_back(eventData); - } -} - -void JSONDataParser::_parseTransform(const rapidjson::Value& rawData, Transform& transform) const -{ - transform.x = _getNumber(rawData, X, 0.f) * this->_armature->scale; - transform.y = _getNumber(rawData, Y, 0.f) * this->_armature->scale; - transform.skewX = _getNumber(rawData, SKEW_X, 0.f) * ANGLE_TO_RADIAN; - transform.skewY = _getNumber(rawData, SKEW_Y, 0.f) * ANGLE_TO_RADIAN; - transform.scaleX = _getNumber(rawData, SCALE_X, 1.f); - transform.scaleY = _getNumber(rawData, SCALE_Y, 1.f); -} - -void JSONDataParser::_parseColorTransform(const rapidjson::Value& rawData, ColorTransform& color) const -{ - color.alphaMultiplier = _getNumber(rawData, ALPHA_MULTIPLIER, (int)100) * 0.01f; - color.redMultiplier = _getNumber(rawData, RED_MULTIPLIER, (int)100) * 0.01f; - color.greenMultiplier = _getNumber(rawData, GREEN_MULTIPLIER, (int)100) * 0.01f; - color.blueMultiplier = _getNumber(rawData, BLUE_MULTIPLIER, (int)100) * 0.01f; - color.alphaOffset = _getNumber(rawData, ALPHA_OFFSET, (int)0); - color.redOffset = _getNumber(rawData, RED_OFFSET, (int)0); - color.greenOffset = _getNumber(rawData, GREEN_OFFSET, (int)0); - color.blueOffset = _getNumber(rawData, BLUE_OFFSET, (int)0); -} - -DragonBonesData * JSONDataParser::parseDragonBonesData(const char* rawData, float scale) -{ - if (rawData) - { - rapidjson::Document document; - document.Parse(rawData); - - std::string version = _getString(document, VERSION, ""); - this->_isOldData = version == DATA_VERSION_2_3 || version == DATA_VERSION_3_0; - if (this->_isOldData) - { - this->_isGlobalTransform = _getBoolean(document, IS_GLOBAL, true); - } - else - { - this->_isGlobalTransform = false; - } - - if (version == DATA_VERSION || version == DATA_VERSION_4_0 || this->_isOldData) - { - const auto data = BaseObject::borrowObject(); - data->name = _getString(document, NAME, ""); - data->frameRate = _getNumber(document, FRAME_RATE, (unsigned)24); - if (data->frameRate == 0) - { - data->frameRate = 24; - } - - if (document.HasMember(ARMATURE)) - { - this->_data = data; - const auto& armatureObjects = document[ARMATURE]; - for (size_t i = 0, l = armatureObjects.Size(); i < l; ++i) - { - data->addArmature(_parseArmature(armatureObjects[i], scale)); - } - - this->_data = nullptr; - } - - return data; - } - else - { - DRAGONBONES_ASSERT(false, "Nonsupport data version."); - } - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } - - return nullptr; -} - -void JSONDataParser::parseTextureAtlasData(const char* rawData, TextureAtlasData& textureAtlasData, float scale) -{ - if (rawData) - { - rapidjson::Document document; - document.Parse(rawData); - - textureAtlasData.name = _getString(document, NAME, ""); - textureAtlasData.imagePath = _getString(document, IMAGE_PATH, ""); - textureAtlasData.format = _getTextureFormat(_getString(document, FORMAT, "")); - - if (scale > 0.f) - { - textureAtlasData.scale = scale; - } - else - { - scale = textureAtlasData.scale = _getNumber(document, SCALE, textureAtlasData.scale); - } - - scale = 1.f / scale; - - if (document.HasMember(SUB_TEXTURE)) - { - const auto& textureObjects = document[SUB_TEXTURE]; - for (size_t i = 0, l = textureObjects.Size(); i < l; ++i) - { - const auto& textureObject = textureObjects[i]; - const auto textureData = textureAtlasData.generateTexture(); - textureData->name = _getString(textureObject, NAME, ""); - textureData->rotated = _getBoolean(textureObject, ROTATED, false); - textureData->region.x = _getNumber(textureObject, X, 0.f) * scale; - textureData->region.y = _getNumber(textureObject, Y, 0.f) * scale; - textureData->region.width = _getNumber(textureObject, WIDTH, 0.f) * scale; - textureData->region.height = _getNumber(textureObject, HEIGHT, 0.f) * scale; - - const auto frameWidth = _getNumber(textureObject, FRAME_WIDTH, -1.f); - const auto frameHeight = _getNumber(textureObject, FRAME_HEIGHT, -1.f); - if (frameWidth > 0.f && frameHeight > 0.f) - { - textureData->frame = TextureData::generateRectangle(); - textureData->frame->x = _getNumber(textureObject, FRAME_X, 0.f) * scale; - textureData->frame->y = _getNumber(textureObject, FRAME_Y, 0.f) * scale; - textureData->frame->width = frameWidth * scale; - textureData->frame->height = frameHeight * scale; - } - - textureAtlasData.addTexture(textureData); - } - } - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -DRAGONBONES_NAMESPACE_END \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/parsers/JSONDataParser.h b/native/cocos/editor-support/dragonbones/parsers/JSONDataParser.h deleted file mode 100644 index cb38cc65e2..0000000000 --- a/native/cocos/editor-support/dragonbones/parsers/JSONDataParser.h +++ /dev/null @@ -1,293 +0,0 @@ -#ifndef DRAGONBONES_JSON_DATA_PARSER_H -#define DRAGONBONES_JSON_DATA_PARSER_H - -#include "DataParser.h" -#include "json/document.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class JSONDataParser : public DataParser -{ -protected: - inline static bool _getBoolean(const rapidjson::Value& rawData, const char*& key, bool defaultValue) - { - if (rawData.HasMember(key)) - { - const auto& value = rawData[key]; - if (value.IsBool()) - { - return value.GetBool(); - } - else if (value.IsNumber()) - { - return value.GetInt() != 0; - } - else if (value.IsString()) - { - const std::string stringValue = value.GetString(); - if ( - stringValue == "0" || - stringValue == "NaN" || - stringValue == "" || - stringValue == "false" || - stringValue == "null" || - stringValue == "undefined" - ) - { - return false; - } - - return true; - } - } - - return defaultValue; - } - - inline static unsigned _getNumber(const rapidjson::Value& rawData, const char*& key, unsigned defaultValue) - { - if (rawData.HasMember(key)) - { - return rawData[key].GetUint(); - } - - return defaultValue; - } - - inline static int _getNumber(const rapidjson::Value& rawData, const char*& key, int defaultValue) - { - if (rawData.HasMember(key)) - { - return rawData[key].GetInt(); - } - - return defaultValue; - } - - inline static float _getNumber(const rapidjson::Value& rawData, const char*& key, float defaultValue) - { - if (rawData.HasMember(key) && rawData[key].IsNumber()) - { - return rawData[key].GetDouble(); - } - - return defaultValue; - } - - inline static std::string _getString(const rapidjson::Value& rawData, const char*& key, const std::string& defaultValue) - { - if (rawData.HasMember(key)) - { - if (rawData[key].IsString()) - { - return rawData[key].GetString(); - } - - // - return dragonBones::to_string(rawData[key].GetDouble()); - } - - return defaultValue; - } - - inline static int _getParameter(const rapidjson::Value& rawData, std::size_t index, int defaultValue) - { - if (rawData.Size() > index) - { - return rawData[(int) index].GetInt(); - } - - return defaultValue; - } - - inline static float _getParameter(const rapidjson::Value& rawData, std::size_t index, float defaultValue) - { - if (rawData.Size() > index) - { - return rawData[(int) index].GetFloat(); - } - - return defaultValue; - } - - inline static std::string _getParameter(const rapidjson::Value& rawData, std::size_t index, const std::string& defaultValue) - { - if (rawData.Size() > index) - { - return rawData[(int) index].GetString(); - } - - return defaultValue; - } - -public: - JSONDataParser(); - ~JSONDataParser(); - -private: - DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(JSONDataParser); - -protected: - virtual ArmatureData* _parseArmature(const rapidjson::Value& rawData, float scale); - virtual BoneData* _parseBone(const rapidjson::Value& rawData); - virtual void _parseIK(const rapidjson::Value& rawData); - virtual SlotData* _parseSlot(const rapidjson::Value& rawData, int zOrder); - virtual SkinData* _parseSkin(const rapidjson::Value& rawData); - virtual SlotDisplayDataSet* _parseSlotDisplaySet(const rapidjson::Value& rawData); - virtual DisplayData* _parseDisplay(const rapidjson::Value& rawData); - virtual MeshData* _parseMesh(const rapidjson::Value& rawData); - virtual AnimationData* _parseAnimation(const rapidjson::Value& rawData) const; - virtual BoneTimelineData* _parseBoneTimeline(const rapidjson::Value& rawData) const; - virtual SlotTimelineData* _parseSlotTimeline(const rapidjson::Value& rawData) const; - virtual FFDTimelineData* _parseFFDTimeline(const rapidjson::Value& rawData) const; - virtual AnimationFrameData* _parseAnimationFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount) const; - virtual BoneFrameData* _parseBoneFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount) const; - virtual SlotFrameData* _parseSlotFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount) const; - virtual ExtensionFrameData* _parseFFDFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount) const; - virtual void _parseActionData(const rapidjson::Value& rawData, std::vector& actions, BoneData* bone, SlotData* slot) const; - virtual void _parseEventData(const rapidjson::Value& rawData, std::vector& events, BoneData* bone, SlotData* slot) const; - - template - void _parseTweenFrame(const rapidjson::Value& rawData, TweenFrameData& frame, unsigned frameStart, unsigned frameCount) const - { - _parseFrame(rawData, frame, frameStart, frameCount); - - if (frame.duration > 0) - { - if (rawData.HasMember(TWEEN_EASING)) - { - frame.tweenEasing = _getNumber(rawData, TWEEN_EASING, NO_TWEEN); - } - else if (this->_isOldData) - { - frame.tweenEasing = this->_isAutoTween ? this->_animationTweenEasing : NO_TWEEN; - } - - // TODO - /*if (this->_isOldData && this->_animation.scale == 1.f && (static_cast(this->_timeline))->scale == 1.f && frame.duration * this->_armature->frameRate < 2.f) - { - frame.tweenEasing = NO_TWEEN; - }*/ - - if (rawData.HasMember(CURVE)) - { - auto& rawCurve = rawData[CURVE]; - std::vector curve; - curve.reserve(rawCurve.Size()); - - for (size_t i = 0, l = rawCurve.Size(); i < l; ++i) - { - curve.push_back(rawCurve[i].GetDouble()); - } - - TweenFrameData::samplingCurve(curve, frameCount, frame.curve); - } - } - else - { - frame.tweenEasing = NO_TWEEN; - frame.curve.clear(); - } - } - - template - void _parseFrame(const rapidjson::Value& rawData, FrameData& frame, unsigned frameStart, unsigned frameCount) const - { - frame.position = (float)frameStart / this->_armature->frameRate; - frame.duration = (float)frameCount / this->_armature->frameRate; - } - - template - void _parseTimeline( - const rapidjson::Value& rawData, - TimelineData& timeline, - const std::function& frameParser) const - { - timeline.scale = _getNumber(rawData, SCALE, 1.f); - timeline.offset = _getNumber(rawData, OFFSET, 0.f); - - _timeline = (void*)(&timeline); - - if (rawData.HasMember(FRAME)) - { - const auto& rawFrames = rawData[FRAME]; - if (!rawFrames.Empty()) - { - if (rawFrames.Size() == 1) - { - const auto& frameObject = rawFrames[0]; - const auto frame = frameParser(frameObject, 0, _getNumber(frameObject, DURATION, (unsigned)1)); - timeline.frames.reserve(1); - timeline.frames.push_back(frame); - } - else - { - timeline.frames.reserve(this->_animation->frameCount + 1); - - unsigned frameStart = 0; - unsigned frameCount = 0; - T* frame = nullptr; - T* prevFrame = nullptr; - - for (unsigned i = 0, iW = 0, l = this->_animation->frameCount + 1; i < l; ++i) - { - if (frameStart + frameCount <= i && iW < rawFrames.Size()) - { - const auto& frameObject = rawFrames[iW++]; - frameStart = i; - frameCount = _getNumber(frameObject, DURATION, 1); - frame = frameParser(frameObject, frameStart, frameCount); - - if (prevFrame) - { - prevFrame->next = frame; - frame->prev = prevFrame; - - if (this->_isOldData) - { - const auto tweenFrame = dynamic_cast*>(frame); - if (tweenFrame && frameObject.HasMember(DISPLAY_INDEX) && frameObject[DISPLAY_INDEX].GetInt() == -1) - { - tweenFrame->tweenEasing = NO_TWEEN; - } - } - } - - prevFrame = frame; - } - - timeline.frames.push_back(frame); - } - - frame->duration = this->_animation->duration - frame->position; - - frame = timeline.frames[0]; - prevFrame->next = frame; - frame->prev = prevFrame; - - if (this->_isOldData) - { - const auto& frameObject = rawFrames[0]; - const auto tweenFrame = dynamic_cast*>(prevFrame); - if (tweenFrame && frameObject.HasMember(DISPLAY_INDEX) && frameObject[DISPLAY_INDEX].GetInt() == -1) - { - tweenFrame->tweenEasing = NO_TWEEN; - } - } - } - } - } - - _timeline = nullptr; - } - - virtual void _parseTransform(const rapidjson::Value& rawData, Transform& transform) const; - virtual void _parseColorTransform(const rapidjson::Value& rawData, ColorTransform& color) const; - -public: - virtual DragonBonesData* parseDragonBonesData(const char* rawData, float scale = 1.f) override; - virtual void parseTextureAtlasData(const char* rawData, TextureAtlasData& textureAtlasData, float scale = 0.f) override; -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_JSON_DATA_PARSER_H \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/proj.android/Android.mk b/native/cocos/editor-support/dragonbones/proj.android/Android.mk deleted file mode 100644 index 15be361d8f..0000000000 --- a/native/cocos/editor-support/dragonbones/proj.android/Android.mk +++ /dev/null @@ -1,45 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := dragonbones_static - -LOCAL_MODULE_FILENAME := libdragonbones - - -LOCAL_SRC_FILES := ../animation/Animation.cpp \ - ../animation/AnimationState.cpp \ - ../animation/TimelineState.cpp \ - ../animation/WorldClock.cpp \ - ../armature/Armature.cpp \ - ../armature/Bone.cpp \ - ../armature/Slot.cpp \ - ../core/BaseObject.cpp \ - ../events/EventObject.cpp \ - ../factories/BaseFactory.cpp \ - ../model/AnimationData.cpp \ - ../model/ArmatureData.cpp \ - ../model/DragonBonesData.cpp \ - ../model/FrameData.cpp \ - ../model/TimelineData.cpp \ - ../parsers/DataParser.cpp \ - ../parsers/JSONDataParser.cpp \ - ../textures/TextureData.cpp \ - ../cocos2dx/CCArmatureDisplay.cpp \ - ../cocos2dx/CCFactory.cpp \ - ../cocos2dx/CCSlot.cpp \ - ../cocos2dx/CCTextureData.cpp - - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../.. \ - $(LOCAL_PATH)/../../.. \ - $(LOCAL_PATH)/../../../../external/sources - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. \ - $(LOCAL_PATH)/../../.. \ - $(LOCAL_PATH)/../../../../external/sources - -LOCAL_CFLAGS += -Wno-psabi -LOCAL_EXPORT_CFLAGS += -Wno-psabi - -include $(BUILD_STATIC_LIBRARY) diff --git a/native/cocos/editor-support/dragonbones/proj.win32/libDragonBones.vcxproj b/native/cocos/editor-support/dragonbones/proj.win32/libDragonBones.vcxproj deleted file mode 100644 index 9522010aa7..0000000000 --- a/native/cocos/editor-support/dragonbones/proj.win32/libDragonBones.vcxproj +++ /dev/null @@ -1,160 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {6B494955-1E66-40DA-830D-0D31B8D301EF} - libSpine - 8.1 - - - - StaticLibrary - true - v120 - v120_xp - v140 - v140_xp - v140 - v140_xp - Unicode - - - StaticLibrary - false - v120 - v120_xp - v140 - v140_xp - v140 - v140_xp - true - Unicode - - - - - - - - - - - - - - - $(SolutionDir)$(Configuration).win32\ - $(Configuration).win32\ - - - $(SolutionDir)$(Configuration).win32\ - $(Configuration).win32\ - - - - Level3 - Disabled - - - $(EngineRoot);$(EngineRoot)cocos\editor-support;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - 4267;4251;4244;%(DisableSpecificWarnings) - false - - - true - - - - - Level3 - MinSpace - true - true - - - WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(EngineRoot);$(EngineRoot)cocos\editor-support;%(AdditionalIncludeDirectories) - None - false - - - true - true - true - - - - - - \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/proj.win32/libDragonBones.vcxproj.filters b/native/cocos/editor-support/dragonbones/proj.win32/libDragonBones.vcxproj.filters deleted file mode 100644 index 7b5fa25026..0000000000 --- a/native/cocos/editor-support/dragonbones/proj.win32/libDragonBones.vcxproj.filters +++ /dev/null @@ -1,205 +0,0 @@ - - - - - {73c620ad-e833-43cf-82f8-d7d03882edc2} - - - {5c89ad34-1d08-4fc9-b604-3cf2c65c23f8} - - - {ab2d0b52-d224-423b-aaa5-65f6cc4d3ffa} - - - {5a22ee5b-33ba-4ad6-92b4-856144fffa91} - - - {fe95ed5e-3aa3-430f-87af-e5f6b8d40cd6} - - - {52a7d733-abaf-4c7c-bae8-947644cb4286} - - - {d5d6a8e9-9769-4fc7-91d3-b1c449819ed3} - - - {b166696f-7d17-4a75-8ca7-84b7f2fbe649} - - - {069950cf-2d35-4c38-bc91-61711a587d2f} - - - {80a04357-0b0c-4fea-b29c-aa2f461b4d24} - - - - - animation - - - animation - - - animation - - - animation - - - armature - - - armature - - - armature - - - cocos2dx - - - cocos2dx - - - cocos2dx - - - cocos2dx - - - core - - - events - - - factories - - - model - - - model - - - model - - - model - - - model - - - textures - - - parsers - - - parsers - - - - - animation - - - animation - - - animation - - - animation - - - animation - - - animation - - - armature - - - armature - - - armature - - - armature - - - armature - - - cocos2dx - - - cocos2dx - - - cocos2dx - - - cocos2dx - - - cocos2dx - - - core - - - core - - - events - - - factories - - - geom - - - geom - - - geom - - - geom - - - geom - - - model - - - model - - - model - - - model - - - model - - - textures - - - parsers - - - parsers - - - - \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/textures/TextureData.cpp b/native/cocos/editor-support/dragonbones/textures/TextureData.cpp deleted file mode 100644 index 77fc166089..0000000000 --- a/native/cocos/editor-support/dragonbones/textures/TextureData.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "TextureData.h" - -DRAGONBONES_NAMESPACE_BEGIN - -Rectangle* TextureData::generateRectangle() -{ - return new Rectangle(); -} - -TextureData::TextureData() : - frame(nullptr) -{} -TextureData::~TextureData() {} - -void TextureData::_onClear() -{ - rotated = false; - name.clear(); - - if (frame) - { - delete frame; - frame = nullptr; - } - - parent = nullptr; - region.clear(); -} - -TextureAtlasData::TextureAtlasData() {} -TextureAtlasData::~TextureAtlasData() {} - -void TextureAtlasData::_onClear() -{ - for (const auto& pair : textures) - { - pair.second->returnToPool(); - } - - autoSearch = false; - format = TextureFormat::DEFAULT; - scale = 1.f; - name.clear(); - imagePath.clear(); - textures.clear(); -} - -void TextureAtlasData::addTexture(TextureData * value) -{ - if (value && !value->name.empty() && textures.find(value->name) == textures.end()) - { - textures[value->name] = value; - value->parent = this; - } - else - { - DRAGONBONES_ASSERT(false, "Argument error."); - } -} - -DRAGONBONES_NAMESPACE_END \ No newline at end of file diff --git a/native/cocos/editor-support/dragonbones/textures/TextureData.h b/native/cocos/editor-support/dragonbones/textures/TextureData.h deleted file mode 100644 index 4ebce53fa0..0000000000 --- a/native/cocos/editor-support/dragonbones/textures/TextureData.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef DRAGONBONES_TEXTURE_DATA_H -#define DRAGONBONES_TEXTURE_DATA_H - -#include "../core/BaseObject.h" -#include "../geom/Rectangle.h" - -DRAGONBONES_NAMESPACE_BEGIN - -class TextureAtlasData; - -/** - * @private - */ -class TextureData : public BaseObject -{ -public: - static Rectangle* generateRectangle(); - -public: - bool rotated; - std::string name; - Rectangle* frame; - TextureAtlasData* parent; - Rectangle region; - - TextureData(); - virtual ~TextureData() = 0; - -protected: - virtual void _onClear() override; -}; - -class TextureAtlasData : public BaseObject -{ -public: - bool autoSearch; - float scale; - TextureFormat format; - std::string name; - std::string imagePath; - /** @private */ - std::map textures; - - /** @private */ - TextureAtlasData(); - /** @private */ - virtual ~TextureAtlasData() = 0; - -protected: - virtual void _onClear() override; - -public: - /** @private */ - virtual TextureData* generateTexture() const = 0; - /** @private */ - virtual void addTexture(TextureData* value); - /** @private */ - inline TextureData* getTexture(const std::string& texName) const - { - return mapFind(textures, texName); - } -}; - -DRAGONBONES_NAMESPACE_END -#endif // DRAGONBONES_TEXTURE_DATA_H diff --git a/native/cocos/editor-support/spine/Android.mk b/native/cocos/editor-support/spine/Android.mk deleted file mode 100644 index 06e36d509d..0000000000 --- a/native/cocos/editor-support/spine/Android.mk +++ /dev/null @@ -1,56 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := spine_static - -LOCAL_MODULE_FILENAME := libspine - -LOCAL_ARM_MODE := arm - -LOCAL_SRC_FILES := \ -Animation.c \ -AnimationState.c \ -AnimationStateData.c \ -Atlas.c \ -AtlasAttachmentLoader.c \ -Attachment.c \ -AttachmentLoader.c \ -AttachmentVertices.cpp \ -Bone.c \ -BoneData.c \ -BoundingBoxAttachment.c \ -Cocos2dAttachmentLoader.cpp \ -Event.c \ -EventData.c \ -IkConstraint.c \ -IkConstraintData.c \ -Json.c \ -MeshAttachment.c \ -PathAttachment.c \ -PathConstraint.c \ -PathConstraintData.c \ -RegionAttachment.c \ -Skeleton.c \ -SkeletonAnimation.cpp \ -SkeletonBatch.cpp \ -SkeletonBinary.c \ -SkeletonBounds.c \ -SkeletonData.c \ -SkeletonJson.c \ -SkeletonRenderer.cpp \ -Skin.c \ -Slot.c \ -SlotData.c \ -TransformConstraint.c \ -TransformConstraintData.c \ -VertexAttachment.c \ -extension.c \ -spine-cocos2dx.cpp - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \ - $(LOCAL_PATH)/../.. - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. \ - $(LOCAL_PATH)/../.. - -include $(BUILD_STATIC_LIBRARY) diff --git a/native/cocos/editor-support/spine/Animation.c b/native/cocos/editor-support/spine/Animation.c deleted file mode 100644 index 23bf646a23..0000000000 --- a/native/cocos/editor-support/spine/Animation.c +++ /dev/null @@ -1,1341 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include -#include - -spAnimation* spAnimation_create (const char* name, int timelinesCount) { - spAnimation* self = NEW(spAnimation); - MALLOC_STR(self->name, name); - self->timelinesCount = timelinesCount; - self->timelines = MALLOC(spTimeline*, timelinesCount); - return self; -} - -void spAnimation_dispose (spAnimation* self) { - int i; - for (i = 0; i < self->timelinesCount; ++i) - spTimeline_dispose(self->timelines[i]); - FREE(self->timelines); - FREE(self->name); - FREE(self); -} - -void spAnimation_apply (const spAnimation* self, spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events, - int* eventsCount, float alpha, int setupPose, int mixingOut) { - int i, n = self->timelinesCount; - - if (loop && self->duration) { - time = FMOD(time, self->duration); - if (lastTime > 0) lastTime = FMOD(lastTime, self->duration); - } - - for (i = 0; i < n; ++i) - spTimeline_apply(self->timelines[i], skeleton, lastTime, time, events, eventsCount, alpha, setupPose, mixingOut); -} - -/**/ - -typedef struct _spTimelineVtable { - void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int setupPose, int mixingOut); - int (*getPropertyId) (const spTimeline* self); - void (*dispose) (spTimeline* self); -} _spTimelineVtable; - -void _spTimeline_init (spTimeline* self, spTimelineType type, /**/ - void (*dispose) (spTimeline* self), /**/ - void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut), - int (*getPropertyId) (const spTimeline* self)) { - CONST_CAST(spTimelineType, self->type) = type; - CONST_CAST(_spTimelineVtable*, self->vtable) = NEW(_spTimelineVtable); - VTABLE(spTimeline, self)->dispose = dispose; - VTABLE(spTimeline, self)->apply = apply; - VTABLE(spTimeline, self)->getPropertyId = getPropertyId; -} - -void _spTimeline_deinit (spTimeline* self) { - FREE(self->vtable); -} - -void spTimeline_dispose (spTimeline* self) { - VTABLE(spTimeline, self)->dispose(self); -} - -void spTimeline_apply (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int /*boolean*/ setupPose, int /*boolean*/ mixingOut) { - VTABLE(spTimeline, self)->apply(self, skeleton, lastTime, time, firedEvents, eventsCount, alpha, setupPose, mixingOut); -} - -int spTimeline_getPropertyId (const spTimeline* self) { - return VTABLE(spTimeline, self)->getPropertyId(self); -} - -/**/ - -static const float CURVE_LINEAR = 0, CURVE_STEPPED = 1, CURVE_BEZIER = 2; -static const int BEZIER_SIZE = 10 * 2 - 1; - -void _spCurveTimeline_init (spCurveTimeline* self, spTimelineType type, int framesCount, /**/ - void (*dispose) (spTimeline* self), /**/ - void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut), - int (*getPropertyId)(const spTimeline* self)) { - _spTimeline_init(SUPER(self), type, dispose, apply, getPropertyId); - self->curves = CALLOC(float, (framesCount - 1) * BEZIER_SIZE); -} - -void _spCurveTimeline_deinit (spCurveTimeline* self) { - _spTimeline_deinit(SUPER(self)); - FREE(self->curves); -} - -void spCurveTimeline_setLinear (spCurveTimeline* self, int frameIndex) { - self->curves[frameIndex * BEZIER_SIZE] = CURVE_LINEAR; -} - -void spCurveTimeline_setStepped (spCurveTimeline* self, int frameIndex) { - self->curves[frameIndex * BEZIER_SIZE] = CURVE_STEPPED; -} - -void spCurveTimeline_setCurve (spCurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2) { - float tmpx = (-cx1 * 2 + cx2) * 0.03f, tmpy = (-cy1 * 2 + cy2) * 0.03f; - float dddfx = ((cx1 - cx2) * 3 + 1) * 0.006f, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006f; - float ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy; - float dfx = cx1 * 0.3f + tmpx + dddfx * 0.16666667f, dfy = cy1 * 0.3f + tmpy + dddfy * 0.16666667f; - float x = dfx, y = dfy; - - int i = frameIndex * BEZIER_SIZE, n = i + BEZIER_SIZE - 1; - self->curves[i++] = CURVE_BEZIER; - - for (; i < n; i += 2) { - self->curves[i] = x; - self->curves[i + 1] = y; - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - x += dfx; - y += dfy; - } -} - -float spCurveTimeline_getCurvePercent (const spCurveTimeline* self, int frameIndex, float percent) { - float x, y; - int i = frameIndex * BEZIER_SIZE, start, n; - float type = self->curves[i]; - percent = CLAMP(percent, 0, 1); - if (type == CURVE_LINEAR) return percent; - if (type == CURVE_STEPPED) return 0; - i++; - x = 0; - for (start = i, n = i + BEZIER_SIZE - 1; i < n; i += 2) { - x = self->curves[i]; - if (x >= percent) { - float prevX, prevY; - if (i == start) { - prevX = 0; - prevY = 0; - } else { - prevX = self->curves[i - 2]; - prevY = self->curves[i - 1]; - } - return prevY + (self->curves[i + 1] - prevY) * (percent - prevX) / (x - prevX); - } - } - y = self->curves[i - 1]; - return y + (1 - y) * (percent - x) / (1 - x); /* Last point is 1,1. */ -} - -/* @param target After the first and before the last entry. */ -static int binarySearch (float *values, int valuesLength, float target, int step) { - int low = 0, current; - int high = valuesLength / step - 2; - if (high == 0) return step; - current = high >> 1; - while (1) { - if (values[(current + 1) * step] <= target) - low = current + 1; - else - high = current; - if (low == high) return (low + 1) * step; - current = (low + high) >> 1; - } - return 0; -} - -int _spCurveTimeline_binarySearch (float *values, int valuesLength, float target, int step) { - return binarySearch(values, valuesLength, target, step); -} - -/* @param target After the first and before the last entry. */ -static int binarySearch1 (float *values, int valuesLength, float target) { - int low = 0, current; - int high = valuesLength - 2; - if (high == 0) return 1; - current = high >> 1; - while (1) { - if (values[(current + 1)] <= target) - low = current + 1; - else - high = current; - if (low == high) return low + 1; - current = (low + high) >> 1; - } - return 0; -} - -/**/ - -void _spBaseTimeline_dispose (spTimeline* timeline) { - struct spBaseTimeline* self = SUB_CAST(struct spBaseTimeline, timeline); - _spCurveTimeline_deinit(SUPER(self)); - FREE(self->frames); - FREE(self); -} - -/* Many timelines have structure identical to struct spBaseTimeline and extend spCurveTimeline. **/ -struct spBaseTimeline* _spBaseTimeline_create (int framesCount, spTimelineType type, int frameSize, /**/ - void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int setupPose, int mixingOut), - int (*getPropertyId) (const spTimeline* self)) { - struct spBaseTimeline* self = NEW(struct spBaseTimeline); - _spCurveTimeline_init(SUPER(self), type, framesCount, _spBaseTimeline_dispose, apply, getPropertyId); - - CONST_CAST(int, self->framesCount) = framesCount * frameSize; - CONST_CAST(float*, self->frames) = CALLOC(float, self->framesCount); - - return self; -} - -/**/ - -void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int setupPose, int mixingOut) { - spBone *bone; - int frame; - float prevRotation, frameTime, percent, r; - - spRotateTimeline* self = SUB_CAST(spRotateTimeline, timeline); - - bone = skeleton->bones[self->boneIndex]; - if (time < self->frames[0]) { - if (setupPose) bone->rotation = bone->data->rotation; - return; - } - - if (time >= self->frames[self->framesCount - ROTATE_ENTRIES]) { /* Time is after last frame. */ - if (setupPose) - bone->rotation = bone->data->rotation + self->frames[self->framesCount + ROTATE_PREV_ROTATION] * alpha; - else { - r = bone->data->rotation + self->frames[self->framesCount + ROTATE_PREV_ROTATION] - bone->rotation; - r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360; /* Wrap within -180 and 180. */ - bone->rotation += r * alpha; - } - return; - } - - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(self->frames, self->framesCount, time, ROTATE_ENTRIES); - prevRotation = self->frames[frame + ROTATE_PREV_ROTATION]; - frameTime = self->frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), (frame >> 1) - 1, 1 - (time - frameTime) / (self->frames[frame + ROTATE_PREV_TIME] - frameTime)); - - r = self->frames[frame + ROTATE_ROTATION] - prevRotation; - r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360; - r = prevRotation + r * percent; - if (setupPose) { - r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360; - bone->rotation = bone->data->rotation + r * alpha; - } else { - r = bone->data->rotation + r - bone->rotation; - r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360; - bone->rotation += r * alpha; - } - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spRotateTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_ROTATE << 25) + SUB_CAST(spRotateTimeline, timeline)->boneIndex; -} - -spRotateTimeline* spRotateTimeline_create (int framesCount) { - return _spBaseTimeline_create(framesCount, SP_TIMELINE_ROTATE, ROTATE_ENTRIES, _spRotateTimeline_apply, _spRotateTimeline_getPropertyId); -} - -void spRotateTimeline_setFrame (spRotateTimeline* self, int frameIndex, float time, float degrees) { - frameIndex <<= 1; - self->frames[frameIndex] = time; - self->frames[frameIndex + ROTATE_ROTATION] = degrees; -} - -/**/ - -static const int TRANSLATE_PREV_TIME = -3, TRANSLATE_PREV_X = -2, TRANSLATE_PREV_Y = -1; -static const int TRANSLATE_X = 1, TRANSLATE_Y = 2; - -void _spTranslateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, - spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut) { - spBone *bone; - int frame; - float frameTime, percent; - float x, y; - float *frames; - int framesCount; - - spTranslateTimeline* self = SUB_CAST(spTranslateTimeline, timeline); - - bone = skeleton->bones[self->boneIndex]; - if (time < self->frames[0]) { - if (setupPose) { - bone->x = bone->data->x; - bone->y = bone->data->y; - } - return; - } - - frames = self->frames; - framesCount = self->framesCount; - if (time >= frames[framesCount - TRANSLATE_ENTRIES]) { /* Time is after last frame. */ - x = frames[framesCount + TRANSLATE_PREV_X]; - y = frames[framesCount + TRANSLATE_PREV_Y]; - } else { - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(frames, framesCount, time, TRANSLATE_ENTRIES); - x = frames[frame + TRANSLATE_PREV_X]; - y = frames[frame + TRANSLATE_PREV_Y]; - frameTime = frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TRANSLATE_ENTRIES - 1, - 1 - (time - frameTime) / (frames[frame + TRANSLATE_PREV_TIME] - frameTime)); - - x += (frames[frame + TRANSLATE_X] - x) * percent; - y += (frames[frame + TRANSLATE_Y] - y) * percent; - } - if (setupPose) { - bone->x = bone->data->x + x * alpha; - bone->y = bone->data->y + y * alpha; - } else { - bone->x += (bone->data->x + x - bone->x) * alpha; - bone->y += (bone->data->y + y - bone->y) * alpha; - } - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spTranslateTimeline_getPropertyId (const spTimeline* self) { - return (SP_TIMELINE_TRANSLATE << 24) + SUB_CAST(spTranslateTimeline, self)->boneIndex; -} - -spTranslateTimeline* spTranslateTimeline_create (int framesCount) { - return _spBaseTimeline_create(framesCount, SP_TIMELINE_TRANSLATE, TRANSLATE_ENTRIES, _spTranslateTimeline_apply, _spTranslateTimeline_getPropertyId); -} - -void spTranslateTimeline_setFrame (spTranslateTimeline* self, int frameIndex, float time, float x, float y) { - frameIndex *= TRANSLATE_ENTRIES; - self->frames[frameIndex] = time; - self->frames[frameIndex + TRANSLATE_X] = x; - self->frames[frameIndex + TRANSLATE_Y] = y; -} - -/**/ - -void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int setupPose, int mixingOut) { - spBone *bone; - int frame; - float frameTime, percent, x, y; - float *frames; - int framesCount; - - spScaleTimeline* self = SUB_CAST(spScaleTimeline, timeline); - - bone = skeleton->bones[self->boneIndex]; - if (time < self->frames[0]) { - if (setupPose) { - bone->scaleX = bone->data->scaleX; - bone->scaleY = bone->data->scaleY; - } - return; - } - - frames = self->frames; - framesCount = self->framesCount; - if (time >= frames[framesCount - TRANSLATE_ENTRIES]) { /* Time is after last frame. */ - x = frames[framesCount + TRANSLATE_PREV_X] * bone->data->scaleX; - y = frames[framesCount + TRANSLATE_PREV_Y] * bone->data->scaleY; - } else { - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(frames, framesCount, time, TRANSLATE_ENTRIES); - x = frames[frame + TRANSLATE_PREV_X]; - y = frames[frame + TRANSLATE_PREV_Y]; - frameTime = frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TRANSLATE_ENTRIES - 1, - 1 - (time - frameTime) / (frames[frame + TRANSLATE_PREV_TIME] - frameTime)); - - x = (x + (frames[frame + TRANSLATE_X] - x) * percent) * bone->data->scaleX; - y = (y + (frames[frame + TRANSLATE_Y] - y) * percent) * bone->data->scaleY; - } - if (alpha == 1) { - bone->scaleX = x; - bone->scaleY = y; - } else { - float bx, by; - if (setupPose) { - bx = bone->data->scaleX; - by = bone->data->scaleY; - } else { - bx = bone->scaleX; - by = bone->scaleY; - } - /* Mixing out uses sign of setup or current pose, else use sign of key. */ - if (mixingOut) { - x = ABS(x) * SIGNUM(bx); - y = ABS(y) * SIGNUM(by); - } else { - bx = ABS(bx) * SIGNUM(x); - by = ABS(by) * SIGNUM(y); - } - bone->scaleX = bx + (x - bx) * alpha; - bone->scaleY = by + (y - by) * alpha; - } - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spScaleTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_SCALE << 24) + SUB_CAST(spScaleTimeline, timeline)->boneIndex; -} - -spScaleTimeline* spScaleTimeline_create (int framesCount) { - return _spBaseTimeline_create(framesCount, SP_TIMELINE_SCALE, TRANSLATE_ENTRIES, _spScaleTimeline_apply, _spScaleTimeline_getPropertyId); -} - -void spScaleTimeline_setFrame (spScaleTimeline* self, int frameIndex, float time, float x, float y) { - spTranslateTimeline_setFrame(self, frameIndex, time, x, y); -} - -/**/ - -void _spShearTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int setupPose, int mixingOut) { - spBone *bone; - int frame; - float frameTime, percent, x, y; - float *frames; - int framesCount; - - spShearTimeline* self = SUB_CAST(spShearTimeline, timeline); - - bone = skeleton->bones[self->boneIndex]; - frames = self->frames; - framesCount = self->framesCount; - if (time < self->frames[0]) { - if (setupPose) { - bone->shearX = bone->data->shearX; - bone->shearY = bone->data->shearY; - } - return; - } - - if (time >= frames[framesCount - TRANSLATE_ENTRIES]) { /* Time is after last frame. */ - x = frames[framesCount + TRANSLATE_PREV_X]; - y = frames[framesCount + TRANSLATE_PREV_Y]; - } else { - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(frames, framesCount, time, TRANSLATE_ENTRIES); - x = frames[frame + TRANSLATE_PREV_X]; - y = frames[frame + TRANSLATE_PREV_Y]; - frameTime = frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TRANSLATE_ENTRIES - 1, - 1 - (time - frameTime) / (frames[frame + TRANSLATE_PREV_TIME] - frameTime)); - - x = x + (frames[frame + TRANSLATE_X] - x) * percent; - y = y + (frames[frame + TRANSLATE_Y] - y) * percent; - } - if (setupPose) { - bone->shearX = bone->data->shearX + x * alpha; - bone->shearY = bone->data->shearY + y * alpha; - } else { - bone->shearX += (bone->data->shearX + x - bone->shearX) * alpha; - bone->shearY += (bone->data->shearY + y - bone->shearY) * alpha; - } - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spShearTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_SHEAR << 24) + SUB_CAST(spShearTimeline, timeline)->boneIndex; -} - -spShearTimeline* spShearTimeline_create (int framesCount) { - return (spShearTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_SHEAR, 3, _spShearTimeline_apply, _spShearTimeline_getPropertyId); -} - -void spShearTimeline_setFrame (spShearTimeline* self, int frameIndex, float time, float x, float y) { - spTranslateTimeline_setFrame(self, frameIndex, time, x, y); -} - -/**/ - -static const int COLOR_PREV_TIME = -5, COLOR_PREV_R = -4, COLOR_PREV_G = -3, COLOR_PREV_B = -2, COLOR_PREV_A = -1; -static const int COLOR_R = 1, COLOR_G = 2, COLOR_B = 3, COLOR_A = 4; - -void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int setupPose, int mixingOut) { - spSlot *slot; - int frame; - float percent, frameTime; - float r, g, b, a; - spColorTimeline* self = (spColorTimeline*)timeline; - slot = skeleton->slots[self->slotIndex]; - - if (time < self->frames[0]) { - if (setupPose) { - slot->r = slot->data->r; - slot->g = slot->data->g; - slot->b = slot->data->b; - slot->a = slot->data->a; - } - return; - } - - if (time >= self->frames[self->framesCount - 5]) { /* Time is after last frame */ - int i = self->framesCount; - r = self->frames[i + COLOR_PREV_R]; - g = self->frames[i + COLOR_PREV_G]; - b = self->frames[i + COLOR_PREV_B]; - a = self->frames[i + COLOR_PREV_A]; - } else { - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(self->frames, self->framesCount, time, COLOR_ENTRIES); - - r = self->frames[frame + COLOR_PREV_R]; - g = self->frames[frame + COLOR_PREV_G]; - b = self->frames[frame + COLOR_PREV_B]; - a = self->frames[frame + COLOR_PREV_A]; - - frameTime = self->frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / COLOR_ENTRIES - 1, - 1 - (time - frameTime) / (self->frames[frame + COLOR_PREV_TIME] - frameTime)); - - r += (self->frames[frame + COLOR_R] - r) * percent; - g += (self->frames[frame + COLOR_G] - g) * percent; - b += (self->frames[frame + COLOR_B] - b) * percent; - a += (self->frames[frame + COLOR_A] - a) * percent; - } - if (alpha == 1) { - slot->r = r; - slot->g = g; - slot->b = b; - slot->a = a; - } else { - if (setupPose) { - slot->r = slot->data->r; - slot->g = slot->data->g; - slot->b = slot->data->b; - slot->a = slot->data->a; - } - slot->r += (r - slot->r) * alpha; - slot->g += (g - slot->g) * alpha; - slot->b += (b - slot->b) * alpha; - slot->a += (a - slot->a) * alpha; - } - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spColorTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_COLOR << 24) + SUB_CAST(spColorTimeline, timeline)->slotIndex; -} - -spColorTimeline* spColorTimeline_create (int framesCount) { - return (spColorTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_COLOR, 5, _spColorTimeline_apply, _spColorTimeline_getPropertyId); -} - -void spColorTimeline_setFrame (spColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a) { - frameIndex *= COLOR_ENTRIES; - self->frames[frameIndex] = time; - self->frames[frameIndex + COLOR_R] = r; - self->frames[frameIndex + COLOR_G] = g; - self->frames[frameIndex + COLOR_B] = b; - self->frames[frameIndex + COLOR_A] = a; -} - -/**/ - -void _spAttachmentTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, - spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut) { - const char* attachmentName; - spAttachmentTimeline* self = (spAttachmentTimeline*)timeline; - int frameIndex; - spSlot* slot = skeleton->slots[self->slotIndex]; - - if (mixingOut && setupPose) { - const char* attachmentName = slot->data->attachmentName; - spSlot_setAttachment(slot, attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0); - return; - } - - if (time < self->frames[0]) { - if (setupPose) { - attachmentName = slot->data->attachmentName; - spSlot_setAttachment(skeleton->slots[self->slotIndex], - attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0); - } - return; - } - - if (time >= self->frames[self->framesCount - 1]) - frameIndex = self->framesCount - 1; - else - frameIndex = binarySearch1(self->frames, self->framesCount, time) - 1; - - attachmentName = self->attachmentNames[frameIndex]; - spSlot_setAttachment(skeleton->slots[self->slotIndex], - attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0); - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); - UNUSED(alpha); -} - -int _spAttachmentTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_ATTACHMENT << 24) + SUB_CAST(spAttachmentTimeline, timeline)->slotIndex; -} - -void _spAttachmentTimeline_dispose (spTimeline* timeline) { - spAttachmentTimeline* self = SUB_CAST(spAttachmentTimeline, timeline); - int i; - - _spTimeline_deinit(timeline); - - for (i = 0; i < self->framesCount; ++i) - FREE(self->attachmentNames[i]); - FREE(self->attachmentNames); - FREE(self->frames); - FREE(self); -} - -spAttachmentTimeline* spAttachmentTimeline_create (int framesCount) { - spAttachmentTimeline* self = NEW(spAttachmentTimeline); - _spTimeline_init(SUPER(self), SP_TIMELINE_ATTACHMENT, _spAttachmentTimeline_dispose, _spAttachmentTimeline_apply, _spAttachmentTimeline_getPropertyId); - - CONST_CAST(int, self->framesCount) = framesCount; - CONST_CAST(float*, self->frames) = CALLOC(float, framesCount); - CONST_CAST(char**, self->attachmentNames) = CALLOC(char*, framesCount); - - return self; -} - -void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex, float time, const char* attachmentName) { - self->frames[frameIndex] = time; - - FREE(self->attachmentNames[frameIndex]); - if (attachmentName) - MALLOC_STR(self->attachmentNames[frameIndex], attachmentName); - else - self->attachmentNames[frameIndex] = 0; -} - -/**/ - -void _spDeformTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int setupPose, int mixingOut) { - int frame, i, vertexCount; - float percent, frameTime; - const float* prevVertices; - const float* nextVertices; - float* frames; - int framesCount; - const float** frameVertices; - float* vertices; - spDeformTimeline* self = (spDeformTimeline*)timeline; - - spSlot *slot = skeleton->slots[self->slotIndex]; - - if (slot->attachment != self->attachment) { - if (!slot->attachment) return; - switch (slot->attachment->type) { - case SP_ATTACHMENT_MESH: { - spMeshAttachment* mesh = SUB_CAST(spMeshAttachment, slot->attachment); - if (!mesh->inheritDeform || mesh->parentMesh != (void*)self->attachment) return; - break; - } - default: - return; - } - } - - frames = self->frames; - framesCount = self->framesCount; - if (time < frames[0]) { /* Time is before first frame. */ - if (setupPose) slot->attachmentVerticesCount = 0; - return; - } - - vertexCount = self->frameVerticesCount; - if (slot->attachmentVerticesCount < vertexCount) { - if (slot->attachmentVerticesCapacity < vertexCount) { - FREE(slot->attachmentVertices); - slot->attachmentVertices = MALLOC(float, vertexCount); - slot->attachmentVerticesCapacity = vertexCount; - } - } - if (slot->attachmentVerticesCount != vertexCount) alpha = 1; /* Don't mix from uninitialized slot vertices. */ - slot->attachmentVerticesCount = vertexCount; - - frameVertices = self->frameVertices; - vertices = slot->attachmentVertices; - - if (time >= frames[framesCount - 1]) { /* Time is after last frame. */ - const float* lastVertices = self->frameVertices[framesCount - 1]; - if (alpha == 1) { - /* Vertex positions or deform offsets, no alpha. */ - memcpy(vertices, lastVertices, vertexCount * sizeof(float)); - } else if (setupPose) { - spVertexAttachment* vertexAttachment = SUB_CAST(spVertexAttachment, slot->attachment); - if (!vertexAttachment->bones) { - /* Unweighted vertex positions, with alpha. */ - float* setupVertices = vertexAttachment->vertices; - for (i = 0; i < vertexCount; i++) { - float setup = setupVertices[i]; - vertices[i] = setup + (lastVertices[i] - setup) * alpha; - } - } else { - /* Weighted deform offsets, with alpha. */ - for (i = 0; i < vertexCount; i++) - vertices[i] = lastVertices[i] * alpha; - } - } else { - /* Vertex positions or deform offsets, with alpha. */ - for (i = 0; i < vertexCount; i++) - vertices[i] += (lastVertices[i] - vertices[i]) * alpha; - } - return; - } - - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(frames, framesCount, time, 1); - prevVertices = frameVertices[frame - 1]; - nextVertices = frameVertices[frame]; - frameTime = frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); - - if (alpha == 1) { - /* Vertex positions or deform offsets, no alpha. */ - for (i = 0; i < vertexCount; i++) { - float prev = prevVertices[i]; - vertices[i] = prev + (nextVertices[i] - prev) * percent; - } - } else if (setupPose) { - spVertexAttachment* vertexAttachment = SUB_CAST(spVertexAttachment, slot->attachment); - if (!vertexAttachment->bones) { - /* Unweighted vertex positions, with alpha. */ - float* setupVertices = vertexAttachment->vertices; - for (i = 0; i < vertexCount; i++) { - float prev = prevVertices[i], setup = setupVertices[i]; - vertices[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha; - } - } else { - /* Weighted deform offsets, with alpha. */ - for (i = 0; i < vertexCount; i++) { - float prev = prevVertices[i]; - vertices[i] = (prev + (nextVertices[i] - prev) * percent) * alpha; - } - } - } else { - /* Vertex positions or deform offsets, with alpha. */ - for (i = 0; i < vertexCount; i++) { - float prev = prevVertices[i]; - vertices[i] += (prev + (nextVertices[i] - prev) * percent - vertices[i]) * alpha; - } - } - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spDeformTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_DEFORM << 24) + SUB_CAST(spDeformTimeline, timeline)->slotIndex; -} - -void _spDeformTimeline_dispose (spTimeline* timeline) { - spDeformTimeline* self = SUB_CAST(spDeformTimeline, timeline); - int i; - - _spCurveTimeline_deinit(SUPER(self)); - - for (i = 0; i < self->framesCount; ++i) - FREE(self->frameVertices[i]); - FREE(self->frameVertices); - FREE(self->frames); - FREE(self); -} - -spDeformTimeline* spDeformTimeline_create (int framesCount, int frameVerticesCount) { - spDeformTimeline* self = NEW(spDeformTimeline); - _spCurveTimeline_init(SUPER(self), SP_TIMELINE_DEFORM, framesCount, _spDeformTimeline_dispose, _spDeformTimeline_apply, _spDeformTimeline_getPropertyId); - CONST_CAST(int, self->framesCount) = framesCount; - CONST_CAST(float*, self->frames) = CALLOC(float, self->framesCount); - CONST_CAST(float**, self->frameVertices) = CALLOC(float*, framesCount); - CONST_CAST(int, self->frameVerticesCount) = frameVerticesCount; - return self; -} - -void spDeformTimeline_setFrame (spDeformTimeline* self, int frameIndex, float time, float* vertices) { - self->frames[frameIndex] = time; - - FREE(self->frameVertices[frameIndex]); - if (!vertices) - self->frameVertices[frameIndex] = 0; - else { - self->frameVertices[frameIndex] = MALLOC(float, self->frameVerticesCount); - memcpy(CONST_CAST(float*, self->frameVertices[frameIndex]), vertices, self->frameVerticesCount * sizeof(float)); - } -} - - -/**/ - -/** Fires events for frames > lastTime and <= time. */ -void _spEventTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int setupPose, int mixingOut) { - spEventTimeline* self = (spEventTimeline*)timeline; - int frame; - if (!firedEvents) return; - - if (lastTime > time) { /* Fire events after last time for looped animations. */ - _spEventTimeline_apply(timeline, skeleton, lastTime, (float)INT_MAX, firedEvents, eventsCount, alpha, setupPose, mixingOut); - lastTime = -1; - } else if (lastTime >= self->frames[self->framesCount - 1]) /* Last time is after last frame. */ - return; - if (time < self->frames[0]) return; /* Time is before first frame. */ - - if (lastTime < self->frames[0]) - frame = 0; - else { - float frameTime; - frame = binarySearch1(self->frames, self->framesCount, lastTime); - frameTime = self->frames[frame]; - while (frame > 0) { /* Fire multiple events with the same frame. */ - if (self->frames[frame - 1] != frameTime) break; - frame--; - } - } - for (; frame < self->framesCount && time >= self->frames[frame]; ++frame) { - firedEvents[*eventsCount] = self->events[frame]; - (*eventsCount)++; - } -} - -int _spEventTimeline_getPropertyId (const spTimeline* timeline) { - return SP_TIMELINE_EVENT << 24; -} - -void _spEventTimeline_dispose (spTimeline* timeline) { - spEventTimeline* self = SUB_CAST(spEventTimeline, timeline); - int i; - - _spTimeline_deinit(timeline); - - for (i = 0; i < self->framesCount; ++i) - spEvent_dispose(self->events[i]); - FREE(self->events); - FREE(self->frames); - FREE(self); -} - -spEventTimeline* spEventTimeline_create (int framesCount) { - spEventTimeline* self = NEW(spEventTimeline); - _spTimeline_init(SUPER(self), SP_TIMELINE_EVENT, _spEventTimeline_dispose, _spEventTimeline_apply, _spEventTimeline_getPropertyId); - - CONST_CAST(int, self->framesCount) = framesCount; - CONST_CAST(float*, self->frames) = CALLOC(float, framesCount); - CONST_CAST(spEvent**, self->events) = CALLOC(spEvent*, framesCount); - - return self; -} - -void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, spEvent* event) { - self->frames[frameIndex] = event->time; - - FREE(self->events[frameIndex]); - self->events[frameIndex] = event; -} - -/**/ - -void _spDrawOrderTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, - spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut) { - int i; - int frame; - const int* drawOrderToSetupIndex; - spDrawOrderTimeline* self = (spDrawOrderTimeline*)timeline; - - if (mixingOut && setupPose) { - memcpy(skeleton->drawOrder, skeleton->slots, self->slotsCount * sizeof(spSlot*)); - return; - } - - if (time < self->frames[0]) { - if (setupPose) memcpy(skeleton->drawOrder, skeleton->slots, self->slotsCount * sizeof(spSlot*)); - return; - } - - if (time >= self->frames[self->framesCount - 1]) /* Time is after last frame. */ - frame = self->framesCount - 1; - else - frame = binarySearch1(self->frames, self->framesCount, time) - 1; - - drawOrderToSetupIndex = self->drawOrders[frame]; - if (!drawOrderToSetupIndex) - memcpy(skeleton->drawOrder, skeleton->slots, self->slotsCount * sizeof(spSlot*)); - else { - for (i = 0; i < self->slotsCount; ++i) - skeleton->drawOrder[i] = skeleton->slots[drawOrderToSetupIndex[i]]; - } - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); - UNUSED(alpha); -} - -int _spDrawOrderTimeline_getPropertyId (const spTimeline* timeline) { - return SP_TIMELINE_DRAWORDER << 24; -} - -void _spDrawOrderTimeline_dispose (spTimeline* timeline) { - spDrawOrderTimeline* self = SUB_CAST(spDrawOrderTimeline, timeline); - int i; - - _spTimeline_deinit(timeline); - - for (i = 0; i < self->framesCount; ++i) - FREE(self->drawOrders[i]); - FREE(self->drawOrders); - FREE(self->frames); - FREE(self); -} - -spDrawOrderTimeline* spDrawOrderTimeline_create (int framesCount, int slotsCount) { - spDrawOrderTimeline* self = NEW(spDrawOrderTimeline); - _spTimeline_init(SUPER(self), SP_TIMELINE_DRAWORDER, _spDrawOrderTimeline_dispose, _spDrawOrderTimeline_apply, _spDrawOrderTimeline_getPropertyId); - - CONST_CAST(int, self->framesCount) = framesCount; - CONST_CAST(float*, self->frames) = CALLOC(float, framesCount); - CONST_CAST(int**, self->drawOrders) = CALLOC(int*, framesCount); - CONST_CAST(int, self->slotsCount) = slotsCount; - - return self; -} - -void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder) { - self->frames[frameIndex] = time; - - FREE(self->drawOrders[frameIndex]); - if (!drawOrder) - self->drawOrders[frameIndex] = 0; - else { - self->drawOrders[frameIndex] = MALLOC(int, self->slotsCount); - memcpy(CONST_CAST(int*, self->drawOrders[frameIndex]), drawOrder, self->slotsCount * sizeof(int)); - } -} - -/**/ - -static const int IKCONSTRAINT_PREV_TIME = -3, IKCONSTRAINT_PREV_MIX = -2, IKCONSTRAINT_PREV_BEND_DIRECTION = -1; -static const int IKCONSTRAINT_MIX = 1, IKCONSTRAINT_BEND_DIRECTION = 2; - -void _spIkConstraintTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, - spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut) { - int frame; - float frameTime, percent, mix; - float *frames; - int framesCount; - spIkConstraint* constraint; - spIkConstraintTimeline* self = (spIkConstraintTimeline*)timeline; - - constraint = skeleton->ikConstraints[self->ikConstraintIndex]; - - if (time < self->frames[0]) { - if (setupPose) { - constraint->mix = constraint->data->mix; - constraint->bendDirection = constraint->data->bendDirection; - } - return; - } - - frames = self->frames; - framesCount = self->framesCount; - if (time >= frames[framesCount - IKCONSTRAINT_ENTRIES]) { /* Time is after last frame. */ - if (setupPose) { - constraint->mix = constraint->data->mix + (frames[framesCount + IKCONSTRAINT_PREV_MIX] - constraint->data->mix) * alpha; - constraint->bendDirection = mixingOut ? constraint->data->bendDirection - : (int)frames[framesCount + IKCONSTRAINT_PREV_BEND_DIRECTION]; - } else { - constraint->mix += (frames[framesCount + IKCONSTRAINT_PREV_MIX] - constraint->mix) * alpha; - if (!mixingOut) constraint->bendDirection = (int)frames[framesCount + IKCONSTRAINT_PREV_BEND_DIRECTION]; - } - return; - } - - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(self->frames, self->framesCount, time, IKCONSTRAINT_ENTRIES); - mix = self->frames[frame + IKCONSTRAINT_PREV_MIX]; - frameTime = self->frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / IKCONSTRAINT_ENTRIES - 1, 1 - (time - frameTime) / (self->frames[frame + IKCONSTRAINT_PREV_TIME] - frameTime)); - - if (setupPose) { - constraint->mix = constraint->data->mix + (mix + (frames[frame + IKCONSTRAINT_MIX] - mix) * percent - constraint->data->mix) * alpha; - constraint->bendDirection = mixingOut ? constraint->data->bendDirection : (int)frames[frame + IKCONSTRAINT_PREV_BEND_DIRECTION]; - } else { - constraint->mix += (mix + (frames[frame + IKCONSTRAINT_MIX] - mix) * percent - constraint->mix) * alpha; - if (!mixingOut) constraint->bendDirection = (int)frames[frame + IKCONSTRAINT_PREV_BEND_DIRECTION]; - } - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spIkConstraintTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_IKCONSTRAINT << 24) + SUB_CAST(spIkConstraintTimeline, timeline)->ikConstraintIndex; -} - -spIkConstraintTimeline* spIkConstraintTimeline_create (int framesCount) { - return (spIkConstraintTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_IKCONSTRAINT, IKCONSTRAINT_ENTRIES, _spIkConstraintTimeline_apply, _spIkConstraintTimeline_getPropertyId); -} - -void spIkConstraintTimeline_setFrame (spIkConstraintTimeline* self, int frameIndex, float time, float mix, int bendDirection) { - frameIndex *= IKCONSTRAINT_ENTRIES; - self->frames[frameIndex] = time; - self->frames[frameIndex + IKCONSTRAINT_MIX] = mix; - self->frames[frameIndex + IKCONSTRAINT_BEND_DIRECTION] = (float)bendDirection; -} - -/**/ -static const int TRANSFORMCONSTRAINT_PREV_TIME = -5; -static const int TRANSFORMCONSTRAINT_PREV_ROTATE = -4; -static const int TRANSFORMCONSTRAINT_PREV_TRANSLATE = -3; -static const int TRANSFORMCONSTRAINT_PREV_SCALE = -2; -static const int TRANSFORMCONSTRAINT_PREV_SHEAR = -1; -static const int TRANSFORMCONSTRAINT_ROTATE = 1; -static const int TRANSFORMCONSTRAINT_TRANSLATE = 2; -static const int TRANSFORMCONSTRAINT_SCALE = 3; -static const int TRANSFORMCONSTRAINT_SHEAR = 4; - -void _spTransformConstraintTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, - spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut) { - int frame; - float frameTime, percent, rotate, translate, scale, shear; - spTransformConstraint* constraint; - spTransformConstraintTimeline* self = (spTransformConstraintTimeline*)timeline; - float *frames; - int framesCount; - - constraint = skeleton->transformConstraints[self->transformConstraintIndex]; - if (time < self->frames[0]) { - if (setupPose) { - spTransformConstraintData* data = constraint->data; - constraint->rotateMix = data->rotateMix; - constraint->translateMix = data->translateMix; - constraint->scaleMix = data->scaleMix; - constraint->shearMix = data->shearMix; - } - return; - } - - frames = self->frames; - framesCount = self->framesCount; - if (time >= frames[framesCount - TRANSFORMCONSTRAINT_ENTRIES]) { /* Time is after last frame. */ - int i = framesCount; - rotate = frames[i + TRANSFORMCONSTRAINT_PREV_ROTATE]; - translate = frames[i + TRANSFORMCONSTRAINT_PREV_TRANSLATE]; - scale = frames[i + TRANSFORMCONSTRAINT_PREV_SCALE]; - shear = frames[i + TRANSFORMCONSTRAINT_PREV_SHEAR]; - } else { - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(frames, framesCount, time, TRANSFORMCONSTRAINT_ENTRIES); - rotate = frames[frame + TRANSFORMCONSTRAINT_PREV_ROTATE]; - translate = frames[frame + TRANSFORMCONSTRAINT_PREV_TRANSLATE]; - scale = frames[frame + TRANSFORMCONSTRAINT_PREV_SCALE]; - shear = frames[frame + TRANSFORMCONSTRAINT_PREV_SHEAR]; - frameTime = frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TRANSFORMCONSTRAINT_ENTRIES - 1, - 1 - (time - frameTime) / (frames[frame + TRANSFORMCONSTRAINT_PREV_TIME] - frameTime)); - - rotate += (frames[frame + TRANSFORMCONSTRAINT_ROTATE] - rotate) * percent; - translate += (frames[frame + TRANSFORMCONSTRAINT_TRANSLATE] - translate) * percent; - scale += (frames[frame + TRANSFORMCONSTRAINT_SCALE] - scale) * percent; - shear += (frames[frame + TRANSFORMCONSTRAINT_SHEAR] - shear) * percent; - } - if (setupPose) { - spTransformConstraintData* data = constraint->data; - constraint->rotateMix = data->rotateMix + (rotate - data->rotateMix) * alpha; - constraint->translateMix = data->translateMix + (translate - data->translateMix) * alpha; - constraint->scaleMix = data->scaleMix + (scale - data->scaleMix) * alpha; - constraint->shearMix = data->shearMix + (shear - data->shearMix) * alpha; - } else { - constraint->rotateMix += (rotate - constraint->rotateMix) * alpha; - constraint->translateMix += (translate - constraint->translateMix) * alpha; - constraint->scaleMix += (scale - constraint->scaleMix) * alpha; - constraint->shearMix += (shear - constraint->shearMix) * alpha; - } - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spTransformConstraintTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_TRANSFORMCONSTRAINT << 24) + SUB_CAST(spTransformConstraintTimeline, timeline)->transformConstraintIndex; -} - -spTransformConstraintTimeline* spTransformConstraintTimeline_create (int framesCount) { - return (spTransformConstraintTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_TRANSFORMCONSTRAINT, TRANSFORMCONSTRAINT_ENTRIES, _spTransformConstraintTimeline_apply, _spTransformConstraintTimeline_getPropertyId); -} - -void spTransformConstraintTimeline_setFrame (spTransformConstraintTimeline* self, int frameIndex, float time, float rotateMix, float translateMix, float scaleMix, float shearMix) { - frameIndex *= TRANSFORMCONSTRAINT_ENTRIES; - self->frames[frameIndex] = time; - self->frames[frameIndex + TRANSFORMCONSTRAINT_ROTATE] = rotateMix; - self->frames[frameIndex + TRANSFORMCONSTRAINT_TRANSLATE] = translateMix; - self->frames[frameIndex + TRANSFORMCONSTRAINT_SCALE] = scaleMix; - self->frames[frameIndex + TRANSFORMCONSTRAINT_SHEAR] = shearMix; -} - -/**/ - -static const int PATHCONSTRAINTPOSITION_PREV_TIME = -2; -static const int PATHCONSTRAINTPOSITION_PREV_VALUE = -1; -static const int PATHCONSTRAINTPOSITION_VALUE = 1; - -void _spPathConstraintPositionTimeline_apply(const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, - spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut) { - int frame; - float frameTime, percent, position; - spPathConstraint* constraint; - spPathConstraintPositionTimeline* self = (spPathConstraintPositionTimeline*)timeline; - float* frames; - int framesCount; - - constraint = skeleton->pathConstraints[self->pathConstraintIndex]; - if (time < self->frames[0]) { - if (setupPose) { - constraint->position = constraint->data->position; - } - return; - } - - frames = self->frames; - framesCount = self->framesCount; - if (time >= frames[framesCount - PATHCONSTRAINTPOSITION_ENTRIES]) /* Time is after last frame. */ - position = frames[framesCount + PATHCONSTRAINTPOSITION_PREV_VALUE]; - else { - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(frames, framesCount, time, PATHCONSTRAINTPOSITION_ENTRIES); - position = frames[frame + PATHCONSTRAINTPOSITION_PREV_VALUE]; - frameTime = frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / PATHCONSTRAINTPOSITION_ENTRIES - 1, - 1 - (time - frameTime) / (frames[frame + PATHCONSTRAINTPOSITION_PREV_TIME] - frameTime)); - - position += (frames[frame + PATHCONSTRAINTPOSITION_VALUE] - position) * percent; - } - if (setupPose) - constraint->position = constraint->data->position + (position - constraint->data->position) * alpha; - else - constraint->position += (position - constraint->position) * alpha; - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spPathConstraintPositionTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_PATHCONSTRAINTPOSITION << 24) + SUB_CAST(spPathConstraintPositionTimeline, timeline)->pathConstraintIndex; -} - -spPathConstraintPositionTimeline* spPathConstraintPositionTimeline_create (int framesCount) { - return (spPathConstraintPositionTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_PATHCONSTRAINTPOSITION, PATHCONSTRAINTPOSITION_ENTRIES, _spPathConstraintPositionTimeline_apply, _spPathConstraintPositionTimeline_getPropertyId); -} - -void spPathConstraintPositionTimeline_setFrame (spPathConstraintPositionTimeline* self, int frameIndex, float time, float value) { - frameIndex *= PATHCONSTRAINTPOSITION_ENTRIES; - self->frames[frameIndex] = time; - self->frames[frameIndex + PATHCONSTRAINTPOSITION_VALUE] = value; -} - -/**/ -static const int PATHCONSTRAINTSPACING_PREV_TIME = -2; -static const int PATHCONSTRAINTSPACING_PREV_VALUE = -1; -static const int PATHCONSTRAINTSPACING_VALUE = 1; - -void _spPathConstraintSpacingTimeline_apply(const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, - spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut) { - int frame; - float frameTime, percent, spacing; - spPathConstraint* constraint; - spPathConstraintSpacingTimeline* self = (spPathConstraintSpacingTimeline*)timeline; - float* frames; - int framesCount; - - constraint = skeleton->pathConstraints[self->pathConstraintIndex]; - if (time < self->frames[0]) { - if (setupPose) { - constraint->spacing = constraint->data->spacing; - } - return; - } - - frames = self->frames; - framesCount = self->framesCount; - if (time >= frames[framesCount - PATHCONSTRAINTSPACING_ENTRIES]) /* Time is after last frame. */ - spacing = frames[framesCount + PATHCONSTRAINTSPACING_PREV_VALUE]; - else { - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(frames, framesCount, time, PATHCONSTRAINTSPACING_ENTRIES); - spacing = frames[frame + PATHCONSTRAINTSPACING_PREV_VALUE]; - frameTime = frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / PATHCONSTRAINTSPACING_ENTRIES - 1, - 1 - (time - frameTime) / (frames[frame + PATHCONSTRAINTSPACING_PREV_TIME] - frameTime)); - - spacing += (frames[frame + PATHCONSTRAINTSPACING_VALUE] - spacing) * percent; - } - - if (setupPose) - constraint->spacing = constraint->data->spacing + (spacing - constraint->data->spacing) * alpha; - else - constraint->spacing += (spacing - constraint->spacing) * alpha; - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spPathConstraintSpacingTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_PATHCONSTRAINTSPACING << 24) + SUB_CAST(spPathConstraintSpacingTimeline, timeline)->pathConstraintIndex; -} - -spPathConstraintSpacingTimeline* spPathConstraintSpacingTimeline_create (int framesCount) { - return (spPathConstraintSpacingTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_PATHCONSTRAINTSPACING, PATHCONSTRAINTSPACING_ENTRIES, _spPathConstraintSpacingTimeline_apply, _spPathConstraintSpacingTimeline_getPropertyId); -} - -void spPathConstraintSpacingTimeline_setFrame (spPathConstraintSpacingTimeline* self, int frameIndex, float time, float value) { - frameIndex *= PATHCONSTRAINTSPACING_ENTRIES; - self->frames[frameIndex] = time; - self->frames[frameIndex + PATHCONSTRAINTSPACING_VALUE] = value; -} - -/**/ - -static const int PATHCONSTRAINTMIX_PREV_TIME = -3; -static const int PATHCONSTRAINTMIX_PREV_ROTATE = -2; -static const int PATHCONSTRAINTMIX_PREV_TRANSLATE = -1; -static const int PATHCONSTRAINTMIX_ROTATE = 1; -static const int PATHCONSTRAINTMIX_TRANSLATE = 2; - -void _spPathConstraintMixTimeline_apply(const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, - spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut) { - int frame; - float frameTime, percent, rotate, translate; - spPathConstraint* constraint; - spPathConstraintMixTimeline* self = (spPathConstraintMixTimeline*)timeline; - float* frames; - int framesCount; - - constraint = skeleton->pathConstraints[self->pathConstraintIndex]; - if (time < self->frames[0]) { - if (setupPose) { - constraint->rotateMix = constraint->data->rotateMix; - constraint->translateMix = constraint->data->translateMix; - } - return; - } - - frames = self->frames; - framesCount = self->framesCount; - if (time >= frames[framesCount - PATHCONSTRAINTMIX_ENTRIES]) { /* Time is after last frame. */ - rotate = frames[framesCount + PATHCONSTRAINTMIX_PREV_ROTATE]; - translate = frames[framesCount + PATHCONSTRAINTMIX_PREV_TRANSLATE]; - } else { - /* Interpolate between the previous frame and the current frame. */ - frame = binarySearch(frames, framesCount, time, PATHCONSTRAINTMIX_ENTRIES); - rotate = frames[frame + PATHCONSTRAINTMIX_PREV_ROTATE]; - translate = frames[frame + PATHCONSTRAINTMIX_PREV_TRANSLATE]; - frameTime = frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / PATHCONSTRAINTMIX_ENTRIES - 1, - 1 - (time - frameTime) / (frames[frame + PATHCONSTRAINTMIX_PREV_TIME] - frameTime)); - - rotate += (frames[frame + PATHCONSTRAINTMIX_ROTATE] - rotate) * percent; - translate += (frames[frame + PATHCONSTRAINTMIX_TRANSLATE] - translate) * percent; - } - - if (setupPose) { - constraint->rotateMix = constraint->data->rotateMix + (rotate - constraint->data->rotateMix) * alpha; - constraint->translateMix = constraint->data->translateMix + (translate - constraint->data->translateMix) * alpha; - } else { - constraint->rotateMix += (rotate - constraint->rotateMix) * alpha; - constraint->translateMix += (translate - constraint->translateMix) * alpha; - } - - UNUSED(lastTime); - UNUSED(firedEvents); - UNUSED(eventsCount); -} - -int _spPathConstraintMixTimeline_getPropertyId (const spTimeline* timeline) { - return (SP_TIMELINE_PATHCONSTRAINTMIX << 24) + SUB_CAST(spPathConstraintMixTimeline, timeline)->pathConstraintIndex; -} - -spPathConstraintMixTimeline* spPathConstraintMixTimeline_create (int framesCount) { - return (spPathConstraintMixTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_PATHCONSTRAINTMIX, PATHCONSTRAINTMIX_ENTRIES, _spPathConstraintMixTimeline_apply, _spPathConstraintMixTimeline_getPropertyId); -} - -void spPathConstraintMixTimeline_setFrame (spPathConstraintMixTimeline* self, int frameIndex, float time, float rotateMix, float translateMix) { - frameIndex *= PATHCONSTRAINTMIX_ENTRIES; - self->frames[frameIndex] = time; - self->frames[frameIndex + PATHCONSTRAINTMIX_ROTATE] = rotateMix; - self->frames[frameIndex + PATHCONSTRAINTMIX_TRANSLATE] = translateMix; -} diff --git a/native/cocos/editor-support/spine/Animation.h b/native/cocos/editor-support/spine/Animation.h deleted file mode 100644 index 1a432529a2..0000000000 --- a/native/cocos/editor-support/spine/Animation.h +++ /dev/null @@ -1,545 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_ANIMATION_H_ -#define SPINE_ANIMATION_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spTimeline spTimeline; -struct spSkeleton; - -typedef struct spAnimation { - const char* const name; - float duration; - - int timelinesCount; - spTimeline** timelines; - -#ifdef __cplusplus - spAnimation() : - name(0), - duration(0), - timelinesCount(0), - timelines(0) { - } -#endif -} spAnimation; - -spAnimation* spAnimation_create (const char* name, int timelinesCount); -void spAnimation_dispose (spAnimation* self); - -/** Poses the skeleton at the specified time for this animation. - * @param lastTime The last time the animation was applied. - * @param events Any triggered events are added. May be null.*/ -void spAnimation_apply (const spAnimation* self, struct spSkeleton* skeleton, float lastTime, float time, int loop, - spEvent** events, int* eventsCount, float alpha, int /*boolean*/ setupPose, int /*boolean*/ mixingOut); - -#ifdef SPINE_SHORT_NAMES -typedef spAnimation Animation; -#define Animation_create(...) spAnimation_create(__VA_ARGS__) -#define Animation_dispose(...) spAnimation_dispose(__VA_ARGS__) -#define Animation_apply(...) spAnimation_apply(__VA_ARGS__) -#endif - -/**/ - -typedef enum { - SP_TIMELINE_ROTATE, - SP_TIMELINE_TRANSLATE, - SP_TIMELINE_SCALE, - SP_TIMELINE_SHEAR, - SP_TIMELINE_ATTACHMENT, - SP_TIMELINE_COLOR, - SP_TIMELINE_DEFORM, - SP_TIMELINE_EVENT, - SP_TIMELINE_DRAWORDER, - SP_TIMELINE_IKCONSTRAINT, - SP_TIMELINE_TRANSFORMCONSTRAINT, - SP_TIMELINE_PATHCONSTRAINTPOSITION, - SP_TIMELINE_PATHCONSTRAINTSPACING, - SP_TIMELINE_PATHCONSTRAINTMIX -} spTimelineType; - -struct spTimeline { - const spTimelineType type; - const void* const vtable; - -#ifdef __cplusplus - spTimeline() : - type(SP_TIMELINE_SCALE), - vtable(0) { - } -#endif -}; - -void spTimeline_dispose (spTimeline* self); -void spTimeline_apply (const spTimeline* self, struct spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int /*boolean*/ setupPose, int /*boolean*/ mixingOut); -int spTimeline_getPropertyId (const spTimeline* self); - -#ifdef SPINE_SHORT_NAMES -typedef spTimeline Timeline; -#define TIMELINE_SCALE SP_TIMELINE_SCALE -#define TIMELINE_ROTATE SP_TIMELINE_ROTATE -#define TIMELINE_TRANSLATE SP_TIMELINE_TRANSLATE -#define TIMELINE_COLOR SP_TIMELINE_COLOR -#define TIMELINE_ATTACHMENT SP_TIMELINE_ATTACHMENT -#define TIMELINE_EVENT SP_TIMELINE_EVENT -#define TIMELINE_DRAWORDER SP_TIMELINE_DRAWORDER -#define Timeline_dispose(...) spTimeline_dispose(__VA_ARGS__) -#define Timeline_apply(...) spTimeline_apply(__VA_ARGS__) -#endif - -/**/ - -typedef struct spCurveTimeline { - spTimeline super; - float* curves; /* type, x, y, ... */ - -#ifdef __cplusplus - spCurveTimeline() : - super(), - curves(0) { - } -#endif -} spCurveTimeline; - -void spCurveTimeline_setLinear (spCurveTimeline* self, int frameIndex); -void spCurveTimeline_setStepped (spCurveTimeline* self, int frameIndex); - -/* Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next. - * cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of - * the difference between the keyframe's values. */ -void spCurveTimeline_setCurve (spCurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2); -float spCurveTimeline_getCurvePercent (const spCurveTimeline* self, int frameIndex, float percent); - -#ifdef SPINE_SHORT_NAMES -typedef spCurveTimeline CurveTimeline; -#define CurveTimeline_setLinear(...) spCurveTimeline_setLinear(__VA_ARGS__) -#define CurveTimeline_setStepped(...) spCurveTimeline_setStepped(__VA_ARGS__) -#define CurveTimeline_setCurve(...) spCurveTimeline_setCurve(__VA_ARGS__) -#define CurveTimeline_getCurvePercent(...) spCurveTimeline_getCurvePercent(__VA_ARGS__) -#endif - -/**/ - -typedef struct spBaseTimeline { - spCurveTimeline super; - int const framesCount; - float* const frames; /* time, angle, ... for rotate. time, x, y, ... for translate and scale. */ - int boneIndex; - -#ifdef __cplusplus - spBaseTimeline() : - super(), - framesCount(0), - frames(0), - boneIndex(0) { - } -#endif -} spBaseTimeline; - -/**/ - -static const int ROTATE_PREV_TIME = -2, ROTATE_PREV_ROTATION = -1; -static const int ROTATE_ROTATION = 1; -static const int ROTATE_ENTRIES = 2; - -typedef struct spBaseTimeline spRotateTimeline; - -spRotateTimeline* spRotateTimeline_create (int framesCount); - -void spRotateTimeline_setFrame (spRotateTimeline* self, int frameIndex, float time, float angle); - -#ifdef SPINE_SHORT_NAMES -typedef spRotateTimeline RotateTimeline; -#define RotateTimeline_create(...) spRotateTimeline_create(__VA_ARGS__) -#define RotateTimeline_setFrame(...) spRotateTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -static const int TRANSLATE_ENTRIES = 3; - -typedef struct spBaseTimeline spTranslateTimeline; - -spTranslateTimeline* spTranslateTimeline_create (int framesCount); - -void spTranslateTimeline_setFrame (spTranslateTimeline* self, int frameIndex, float time, float x, float y); - -#ifdef SPINE_SHORT_NAMES -typedef spTranslateTimeline TranslateTimeline; -#define TranslateTimeline_create(...) spTranslateTimeline_create(__VA_ARGS__) -#define TranslateTimeline_setFrame(...) spTranslateTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -typedef struct spBaseTimeline spScaleTimeline; - -spScaleTimeline* spScaleTimeline_create (int framesCount); - -void spScaleTimeline_setFrame (spScaleTimeline* self, int frameIndex, float time, float x, float y); - -#ifdef SPINE_SHORT_NAMES -typedef spScaleTimeline ScaleTimeline; -#define ScaleTimeline_create(...) spScaleTimeline_create(__VA_ARGS__) -#define ScaleTimeline_setFrame(...) spScaleTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -typedef struct spBaseTimeline spShearTimeline; - -spShearTimeline* spShearTimeline_create (int framesCount); - -void spShearTimeline_setFrame (spShearTimeline* self, int frameIndex, float time, float x, float y); - -#ifdef SPINE_SHORT_NAMES -typedef spShearTimeline ShearTimeline; -#define ShearTimeline_create(...) spShearTimeline_create(__VA_ARGS__) -#define ShearTimeline_setFrame(...) spShearTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -static const int COLOR_ENTRIES = 5; - -typedef struct spColorTimeline { - spCurveTimeline super; - int const framesCount; - float* const frames; /* time, r, g, b, a, ... */ - int slotIndex; - -#ifdef __cplusplus - spColorTimeline() : - super(), - framesCount(0), - frames(0), - slotIndex(0) { - } -#endif -} spColorTimeline; - -spColorTimeline* spColorTimeline_create (int framesCount); - -void spColorTimeline_setFrame (spColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a); - -#ifdef SPINE_SHORT_NAMES -typedef spColorTimeline ColorTimeline; -#define ColorTimeline_create(...) spColorTimeline_create(__VA_ARGS__) -#define ColorTimeline_setFrame(...) spColorTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -typedef struct spAttachmentTimeline { - spTimeline super; - int const framesCount; - float* const frames; /* time, ... */ - int slotIndex; - const char** const attachmentNames; - -#ifdef __cplusplus - spAttachmentTimeline() : - super(), - framesCount(0), - frames(0), - slotIndex(0), - attachmentNames(0) { - } -#endif -} spAttachmentTimeline; - -spAttachmentTimeline* spAttachmentTimeline_create (int framesCount); - -/* @param attachmentName May be 0. */ -void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex, float time, const char* attachmentName); - -#ifdef SPINE_SHORT_NAMES -typedef spAttachmentTimeline AttachmentTimeline; -#define AttachmentTimeline_create(...) spAttachmentTimeline_create(__VA_ARGS__) -#define AttachmentTimeline_setFrame(...) spAttachmentTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -typedef struct spEventTimeline { - spTimeline super; - int const framesCount; - float* const frames; /* time, ... */ - spEvent** const events; - -#ifdef __cplusplus - spEventTimeline() : - super(), - framesCount(0), - frames(0), - events(0) { - } -#endif -} spEventTimeline; - -spEventTimeline* spEventTimeline_create (int framesCount); - -void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, spEvent* event); - -#ifdef SPINE_SHORT_NAMES -typedef spEventTimeline EventTimeline; -#define EventTimeline_create(...) spEventTimeline_create(__VA_ARGS__) -#define EventTimeline_setFrame(...) spEventTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -typedef struct spDrawOrderTimeline { - spTimeline super; - int const framesCount; - float* const frames; /* time, ... */ - const int** const drawOrders; - int const slotsCount; - -#ifdef __cplusplus - spDrawOrderTimeline() : - super(), - framesCount(0), - frames(0), - drawOrders(0), - slotsCount(0) { - } -#endif -} spDrawOrderTimeline; - -spDrawOrderTimeline* spDrawOrderTimeline_create (int framesCount, int slotsCount); - -void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder); - -#ifdef SPINE_SHORT_NAMES -typedef spDrawOrderTimeline DrawOrderTimeline; -#define DrawOrderTimeline_create(...) spDrawOrderTimeline_create(__VA_ARGS__) -#define DrawOrderTimeline_setFrame(...) spDrawOrderTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -typedef struct spDeformTimeline { - spCurveTimeline super; - int const framesCount; - float* const frames; /* time, ... */ - int const frameVerticesCount; - const float** const frameVertices; - int slotIndex; - spAttachment* attachment; - -#ifdef __cplusplus - spDeformTimeline() : - super(), - framesCount(0), - frames(0), - frameVerticesCount(0), - frameVertices(0), - slotIndex(0) { - } -#endif -} spDeformTimeline; - -spDeformTimeline* spDeformTimeline_create (int framesCount, int frameVerticesCount); - -void spDeformTimeline_setFrame (spDeformTimeline* self, int frameIndex, float time, float* vertices); - -#ifdef SPINE_SHORT_NAMES -typedef spDeformTimeline DeformTimeline; -#define DeformTimeline_create(...) spDeformTimeline_create(__VA_ARGS__) -#define DeformTimeline_setFrame(...) spDeformTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -static const int IKCONSTRAINT_ENTRIES = 3; - -typedef struct spIkConstraintTimeline { - spCurveTimeline super; - int const framesCount; - float* const frames; /* time, mix, bendDirection, ... */ - int ikConstraintIndex; - -#ifdef __cplusplus - spIkConstraintTimeline() : - super(), - framesCount(0), - frames(0), - ikConstraintIndex(0) { - } -#endif -} spIkConstraintTimeline; - -spIkConstraintTimeline* spIkConstraintTimeline_create (int framesCount); - -void spIkConstraintTimeline_setFrame (spIkConstraintTimeline* self, int frameIndex, float time, float mix, int bendDirection); - -#ifdef SPINE_SHORT_NAMES -typedef spIkConstraintTimeline IkConstraintTimeline; -#define IkConstraintTimeline_create(...) spIkConstraintTimeline_create(__VA_ARGS__) -#define IkConstraintTimeline_setFrame(...) spIkConstraintTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -static const int TRANSFORMCONSTRAINT_ENTRIES = 5; - -typedef struct spTransformConstraintTimeline { - spCurveTimeline super; - int const framesCount; - float* const frames; /* time, rotate mix, translate mix, scale mix, shear mix, ... */ - int transformConstraintIndex; - -#ifdef __cplusplus - spTransformConstraintTimeline() : - super(), - framesCount(0), - frames(0), - transformConstraintIndex(0) { - } -#endif -} spTransformConstraintTimeline; - -spTransformConstraintTimeline* spTransformConstraintTimeline_create (int framesCount); - -void spTransformConstraintTimeline_setFrame (spTransformConstraintTimeline* self, int frameIndex, float time, float rotateMix, float translateMix, float scaleMix, float shearMix); - -#ifdef SPINE_SHORT_NAMES -typedef spTransformConstraintTimeline TransformConstraintTimeline; -#define TransformConstraintTimeline_create(...) spTransformConstraintTimeline_create(__VA_ARGS__) -#define TransformConstraintTimeline_setFrame(...) spTransformConstraintTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -static const int PATHCONSTRAINTPOSITION_ENTRIES = 2; - -typedef struct spPathConstraintPositionTimeline { - spCurveTimeline super; - int const framesCount; - float* const frames; /* time, rotate mix, translate mix, scale mix, shear mix, ... */ - int pathConstraintIndex; - -#ifdef __cplusplus - spPathConstraintPositionTimeline() : - super(), - framesCount(0), - frames(0), - pathConstraintIndex(0) { - } -#endif -} spPathConstraintPositionTimeline; - -spPathConstraintPositionTimeline* spPathConstraintPositionTimeline_create (int framesCount); - -void spPathConstraintPositionTimeline_setFrame (spPathConstraintPositionTimeline* self, int frameIndex, float time, float value); - -#ifdef SPINE_SHORT_NAMES -typedef spPathConstraintPositionTimeline PathConstraintPositionTimeline; -#define PathConstraintPositionTimeline_create(...) spPathConstraintPositionTimeline_create(__VA_ARGS__) -#define PathConstraintPositionTimeline_setFrame(...) spPathConstraintPositionTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -static const int PATHCONSTRAINTSPACING_ENTRIES = 2; - -typedef struct spPathConstraintSpacingTimeline { - spCurveTimeline super; - int const framesCount; - float* const frames; /* time, rotate mix, translate mix, scale mix, shear mix, ... */ - int pathConstraintIndex; - -#ifdef __cplusplus - spPathConstraintSpacingTimeline() : - super(), - framesCount(0), - frames(0), - pathConstraintIndex(0) { - } -#endif -} spPathConstraintSpacingTimeline; - -spPathConstraintSpacingTimeline* spPathConstraintSpacingTimeline_create (int framesCount); - -void spPathConstraintSpacingTimeline_setFrame (spPathConstraintSpacingTimeline* self, int frameIndex, float time, float value); - -#ifdef SPINE_SHORT_NAMES -typedef spPathConstraintSpacingTimeline PathConstraintSpacingTimeline; -#define PathConstraintSpacingTimeline_create(...) spPathConstraintSpacingTimeline_create(__VA_ARGS__) -#define PathConstraintSpacingTimeline_setFrame(...) spPathConstraintSpacingTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -static const int PATHCONSTRAINTMIX_ENTRIES = 3; - -typedef struct spPathConstraintMixTimeline { - spCurveTimeline super; - int const framesCount; - float* const frames; /* time, rotate mix, translate mix, scale mix, shear mix, ... */ - int pathConstraintIndex; - -#ifdef __cplusplus - spPathConstraintMixTimeline() : - super(), - framesCount(0), - frames(0), - pathConstraintIndex(0) { - } -#endif -} spPathConstraintMixTimeline; - -spPathConstraintMixTimeline* spPathConstraintMixTimeline_create (int framesCount); - -void spPathConstraintMixTimeline_setFrame (spPathConstraintMixTimeline* self, int frameIndex, float time, float rotateMix, float translateMix); - -#ifdef SPINE_SHORT_NAMES -typedef spPathConstraintMixTimeline PathConstraintMixTimeline; -#define PathConstraintMixTimeline_create(...) spPathConstraintMixTimeline_create(__VA_ARGS__) -#define PathConstraintMixTimeline_setFrame(...) spPathConstraintMixTimeline_setFrame(__VA_ARGS__) -#endif - -/**/ - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_ANIMATION_H_ */ diff --git a/native/cocos/editor-support/spine/AnimationState.c b/native/cocos/editor-support/spine/AnimationState.c deleted file mode 100644 index f97b205843..0000000000 --- a/native/cocos/editor-support/spine/AnimationState.c +++ /dev/null @@ -1,871 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include - -static spAnimation* SP_EMPTY_ANIMATION = 0; - -static TrackEntryDisposeCallback _trackEntryDisposeCallback = 0; - -void spAnimationState_disposeStatics () { - if (SP_EMPTY_ANIMATION) spAnimation_dispose(SP_EMPTY_ANIMATION); - SP_EMPTY_ANIMATION = 0; -} - -/* Forward declaration of some "private" functions so we can keep - the same function order in C as we have method order in Java */ -void _spAnimationState_disposeTrackEntry (spTrackEntry* entry); -void _spAnimationState_disposeTrackEntries (spAnimationState* state, spTrackEntry* entry); -void _spAnimationState_updateMixingFrom (spAnimationState* self, spTrackEntry* entry, float delta); -float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* entry, spSkeleton* skeleton); -void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline* timeline, spSkeleton* skeleton, float time, float alpha, int /*boolean*/ setupPose, float* timelinesRotation, int i, int /*boolean*/ firstFrame); -void _spAnimationState_queueEvents (spAnimationState* self, spTrackEntry* entry, float animationTime); -void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* current, int /*boolean*/ interrupt); -spTrackEntry* _spAnimationState_expandToIndex (spAnimationState* self, int index); -spTrackEntry* _spAnimationState_trackEntry (spAnimationState* self, int trackIndex, spAnimation* animation, int /*boolean*/ loop, spTrackEntry* last); -void _spAnimationState_disposeNext (spAnimationState* self, spTrackEntry* entry); -void _spAnimationState_animationsChanged (spAnimationState* self); -float* _spAnimationState_resizeTimelinesRotation(spTrackEntry* entry, int newSize); -int* _spAnimationState_resizeTimelinesFirst(spTrackEntry* entry, int newSize); -void _spAnimationState_ensureCapacityPropertyIDs(spAnimationState* self, int capacity); -int _spAnimationState_addPropertyID(spAnimationState* self, int id); -void _spAnimationState_setTimelinesFirst (spAnimationState* self, spTrackEntry* entry); -void _spAnimationState_checkTimelinesFirst (spAnimationState* self, spTrackEntry* entry); -void _spAnimationState_checkTimelinesUsage (spAnimationState* self, spTrackEntry* entry); - -_spEventQueue* _spEventQueue_create (_spAnimationState* state) { - _spEventQueue *self = CALLOC(_spEventQueue, 1); - self->state = state; - self->objectsCount = 0; - self->objectsCapacity = 16; - self->objects = CALLOC(_spEventQueueItem, self->objectsCapacity); - self->drainDisabled = 0; - return self; -} - -void _spEventQueue_free (_spEventQueue* self) { - FREE(self->objects); - FREE(self); -} - -void _spEventQueue_ensureCapacity (_spEventQueue* self, int newElements) { - if (self->objectsCount + newElements > self->objectsCapacity) { - _spEventQueueItem* newObjects; - self->objectsCapacity <<= 1; - newObjects = CALLOC(_spEventQueueItem, self->objectsCapacity); - memcpy(newObjects, self->objects, sizeof(_spEventQueueItem) * self->objectsCount); - FREE(self->objects); - self->objects = newObjects; - } -} - -void _spEventQueue_addType (_spEventQueue* self, spEventType type) { - _spEventQueue_ensureCapacity(self, 1); - self->objects[self->objectsCount++].type = type; -} - -void _spEventQueue_addEntry (_spEventQueue* self, spTrackEntry* entry) { - _spEventQueue_ensureCapacity(self, 1); - self->objects[self->objectsCount++].entry = entry; -} - -void _spEventQueue_addEvent (_spEventQueue* self, spEvent* event) { - _spEventQueue_ensureCapacity(self, 1); - self->objects[self->objectsCount++].event = event; -} - -void _spEventQueue_start (_spEventQueue* self, spTrackEntry* entry) { - _spEventQueue_addType(self, SP_ANIMATION_START); - _spEventQueue_addEntry(self, entry); - self->state->animationsChanged = 1; -} - -void _spEventQueue_interrupt (_spEventQueue* self, spTrackEntry* entry) { - _spEventQueue_addType(self, SP_ANIMATION_INTERRUPT); - _spEventQueue_addEntry(self, entry); -} - -void _spEventQueue_end (_spEventQueue* self, spTrackEntry* entry) { - _spEventQueue_addType(self, SP_ANIMATION_END); - _spEventQueue_addEntry(self, entry); - self->state->animationsChanged = 1; -} - -void _spEventQueue_dispose (_spEventQueue* self, spTrackEntry* entry) { - _spEventQueue_addType(self, SP_ANIMATION_DISPOSE); - _spEventQueue_addEntry(self, entry); -} - -void _spEventQueue_complete (_spEventQueue* self, spTrackEntry* entry) { - _spEventQueue_addType(self, SP_ANIMATION_COMPLETE); - _spEventQueue_addEntry(self, entry); -} - -void _spEventQueue_event (_spEventQueue* self, spTrackEntry* entry, spEvent* event) { - _spEventQueue_addType(self, SP_ANIMATION_EVENT); - _spEventQueue_addEntry(self, entry); - _spEventQueue_addEvent(self, event); -} - -void _spEventQueue_clear (_spEventQueue* self) { - self->objectsCount = 0; -} - -void _spEventQueue_drain (_spEventQueue* self) { - int i; - if (self->drainDisabled) return; - self->drainDisabled = 1; - for (i = 0; i < self->objectsCount; i += 2) { - spEventType type = self->objects[i].type; - spTrackEntry* entry = self->objects[i+1].entry; - spEvent* event; - switch (type) { - case SP_ANIMATION_START: - case SP_ANIMATION_INTERRUPT: - case SP_ANIMATION_COMPLETE: - if (entry->listener) entry->listener(SUPER(self->state), type, entry, 0); - if (self->state->super.listener) self->state->super.listener(SUPER(self->state), type, entry, 0); - break; - case SP_ANIMATION_END: - if (entry->listener) entry->listener(SUPER(self->state), type, entry, 0); - if (self->state->super.listener) self->state->super.listener(SUPER(self->state), type, entry, 0); - /* Fall through. */ - case SP_ANIMATION_DISPOSE: - if (entry->listener) entry->listener(SUPER(self->state), SP_ANIMATION_DISPOSE, entry, 0); - if (self->state->super.listener) self->state->super.listener(SUPER(self->state), SP_ANIMATION_DISPOSE, entry, 0); - _spAnimationState_disposeTrackEntry(entry); - break; - case SP_ANIMATION_EVENT: - event = self->objects[i+2].event; - if (entry->listener) entry->listener(SUPER(self->state), type, entry, event); - if (self->state->super.listener) self->state->super.listener(SUPER(self->state), type, entry, event); - i++; - break; - } - } - _spEventQueue_clear(self); - - self->drainDisabled = 0; -} - -void _spAnimationState_disposeTrackEntry (spTrackEntry* entry) { - if (_trackEntryDisposeCallback) - _trackEntryDisposeCallback(entry); - - FREE(entry->timelinesFirst); - FREE(entry->timelinesRotation); - FREE(entry); -} - -void _spAnimationState_disposeTrackEntries (spAnimationState* state, spTrackEntry* entry) { - while (entry) { - spTrackEntry* next = entry->next; - spTrackEntry* from = entry->mixingFrom; - while (from) { - spTrackEntry* nextFrom = from->mixingFrom; - _spAnimationState_disposeTrackEntry(from); - from = nextFrom; - } - _spAnimationState_disposeTrackEntry(entry); - entry = next; - } -} - -void spTrackEntry_setDisposeCallback(TrackEntryDisposeCallback cb) -{ - _trackEntryDisposeCallback = cb; -} - -spAnimationState* spAnimationState_create (spAnimationStateData* data) { - _spAnimationState* internal; - spAnimationState* self; - - if (!SP_EMPTY_ANIMATION) { - SP_EMPTY_ANIMATION = (spAnimation*)1; /* dirty trick so we can recursively call spAnimation_create */ - SP_EMPTY_ANIMATION = spAnimation_create("", 0); - } - - internal = NEW(_spAnimationState); - self = SUPER(internal); - - CONST_CAST(spAnimationStateData*, self->data) = data; - self->timeScale = 1; - - internal->queue = _spEventQueue_create(internal); - internal->events = CALLOC(spEvent*, 128); - - internal->propertyIDs = CALLOC(int, 128); - internal->propertyIDsCapacity = 128; - - return self; -} - -void spAnimationState_dispose (spAnimationState* self) { - int i; - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - for (i = 0; i < self->tracksCount; i++) - _spAnimationState_disposeTrackEntries(self, self->tracks[i]); - FREE(self->tracks); - _spEventQueue_free(internal->queue); - FREE(internal->events); - FREE(internal->propertyIDs); - FREE(internal); -} - -void spAnimationState_update (spAnimationState* self, float delta) { - int i, n; - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - delta *= self->timeScale; - for (i = 0, n = self->tracksCount; i < n; i++) { - float currentDelta; - spTrackEntry* current = self->tracks[i]; - spTrackEntry* next; - if (!current) continue; - - current->animationLast = current->nextAnimationLast; - current->trackLast = current->nextTrackLast; - - currentDelta = delta * current->timeScale; - - if (current->delay > 0) { - current->delay -= currentDelta; - if (current->delay > 0) continue; - currentDelta = -current->delay; - current->delay = 0; - } - - next = current->next; - if (next) { - /* When the next entry's delay is passed, change to the next entry, preserving leftover time. */ - float nextTime = current->trackLast - next->delay; - if (nextTime >= 0) { - next->delay = 0; - next->trackTime = nextTime + delta * next->timeScale; - current->trackTime += currentDelta; - _spAnimationState_setCurrent(self, i, next, 1); - while (next->mixingFrom) { - next->mixTime += currentDelta; - next = next->mixingFrom; - } - continue; - } - } else { - /* Clear the track when there is no next entry, the track end time is reached, and there is no mixingFrom. */ - if (current->trackLast >= current->trackEnd && current->mixingFrom == 0) { - self->tracks[i] = 0; - _spEventQueue_end(internal->queue, current); - _spAnimationState_disposeNext(self, current); - continue; - } - } - _spAnimationState_updateMixingFrom(self, current, delta); - - current->trackTime += currentDelta; - } - - _spEventQueue_drain(internal->queue); -} - -void _spAnimationState_updateMixingFrom (spAnimationState* self, spTrackEntry* entry, float delta) { - spTrackEntry* from = entry->mixingFrom; - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - if (!from) return; - - _spAnimationState_updateMixingFrom(self, from, delta); - - if (entry->mixTime >= entry->mixDuration && from->mixingFrom == 0 && entry->mixTime > 0) { - entry->mixingFrom = 0; - _spEventQueue_end(internal->queue, from); - return; - } - - from->animationLast = from->nextAnimationLast; - from->trackLast = from->nextTrackLast; - from->trackTime += delta * from->timeScale; - entry->mixTime += delta * entry->timeScale; -} - -void spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) { - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - spTrackEntry* current; - int i, ii, n; - float animationLast, animationTime; - int timelineCount; - spTimeline** timelines; - int /*boolean*/ firstFrame; - float* timelinesRotation; - int* timelinesFirst; - spTimeline* timeline; - - if (internal->animationsChanged) _spAnimationState_animationsChanged(self); - - for (i = 0, n = self->tracksCount; i < n; i++) { - float mix; - current = self->tracks[i]; - if (!current || current->delay > 0) continue; - - /* Apply mixing from entries first. */ - mix = current->alpha; - if (current->mixingFrom) - mix *= _spAnimationState_applyMixingFrom(self, current, skeleton); - else if (current->trackTime >= current->trackEnd) - mix = 0; - - /* Apply current entry. */ - animationLast = current->animationLast; animationTime = spTrackEntry_getAnimationTime(current); - timelineCount = current->animation->timelinesCount; - timelines = current->animation->timelines; - if (mix == 1) { - for (ii = 0; ii < timelineCount; ii++) - spTimeline_apply(timelines[ii], skeleton, animationLast, animationTime, internal->events, &internal->eventsCount, 1, 1, 0); - } else { - firstFrame = current->timelinesRotationCount == 0; - if (firstFrame) _spAnimationState_resizeTimelinesRotation(current, timelineCount << 1); - timelinesRotation = current->timelinesRotation; - - timelinesFirst = current->timelinesFirst; - for (ii = 0; ii < timelineCount; ii++) { - timeline = timelines[ii]; - if (timeline->type == SP_TIMELINE_ROTATE) - _spAnimationState_applyRotateTimeline(self, timeline, skeleton, animationTime, mix, timelinesFirst[ii], timelinesRotation, ii << 1, firstFrame); - else - spTimeline_apply(timeline, skeleton, animationLast, animationTime, internal->events, &internal->eventsCount, mix, timelinesFirst[ii], 0); - } - } - _spAnimationState_queueEvents(self, current, animationTime); - internal->eventsCount = 0; - current->nextAnimationLast = animationTime; - current->nextTrackLast = current->trackTime; - } - - _spEventQueue_drain(internal->queue); -} - -float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* entry, spSkeleton* skeleton) { - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - float mix; - spEvent** events; - int /*boolean*/ attachments; - int /*boolean*/ drawOrder; - float animationLast; - float animationTime; - int timelineCount; - spTimeline** timelines; - int* timelinesFirst; - float alpha; - int /*boolean*/ firstFrame; - float* timelinesRotation; - spTimeline* timeline; - int /*boolean*/ setupPose; - int i; - - spTrackEntry* from = entry->mixingFrom; - if (from->mixingFrom) _spAnimationState_applyMixingFrom(self, from, skeleton); - - if (entry->mixDuration == 0) /* Single frame mix to undo mixingFrom changes. */ - mix = 1; - else { - mix = entry->mixTime / entry->mixDuration; - if (mix > 1) mix = 1; - } - - events = mix < from->eventThreshold ? internal->events : 0; - attachments = mix < from->attachmentThreshold; - drawOrder = mix < from->drawOrderThreshold; - animationLast = from->animationLast; - animationTime = spTrackEntry_getAnimationTime(from); - timelineCount = from->animation->timelinesCount; - timelines = from->animation->timelines; - timelinesFirst = from->timelinesFirst; - alpha = from->alpha * entry->mixAlpha * (1 - mix); - - firstFrame = from->timelinesRotationCount == 0; - if (firstFrame) _spAnimationState_resizeTimelinesRotation(from, timelineCount << 1); - timelinesRotation = from->timelinesRotation; - - for (i = 0; i < timelineCount; i++) { - timeline = timelines[i]; - setupPose = timelinesFirst[i]; - if (timeline->type == SP_TIMELINE_ROTATE) - _spAnimationState_applyRotateTimeline(self, timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame); - else { - if (!setupPose) { - if (!attachments && timeline->type == SP_TIMELINE_ATTACHMENT) continue; - if (!drawOrder && timeline->type == SP_TIMELINE_DRAWORDER) continue; - } - spTimeline_apply(timeline, skeleton, animationLast, animationTime, events, &internal->eventsCount, alpha, setupPose, 1); - } - } - - if (entry->mixDuration > 0) _spAnimationState_queueEvents(self, from, animationTime); - internal->eventsCount = 0; - from->nextAnimationLast = animationTime; - from->nextTrackLast = from->trackTime; - - return mix; -} - -void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline* timeline, spSkeleton* skeleton, float time, float alpha, int /*boolean*/ setupPose, float* timelinesRotation, int i, int /*boolean*/ firstFrame) { - spRotateTimeline *rotateTimeline; - float *frames; - spBone* bone; - float r1, r2; - int frame; - float prevRotation; - float frameTime; - float percent; - float total, diff; - int /*boolean*/ current, dir; - - if (firstFrame) timelinesRotation[i] = 0; - - if (alpha == 1) { - spTimeline_apply(timeline, skeleton, 0, time, 0, 0, 1, setupPose, 0); - return; - } - - rotateTimeline = SUB_CAST(spRotateTimeline, timeline); - frames = rotateTimeline->frames; - bone = skeleton->bones[rotateTimeline->boneIndex]; - if (time < frames[0]) { - if (setupPose) { - bone->rotation = bone->data->rotation; - } - return; /* Time is before first frame. */ - } - - if (time >= frames[rotateTimeline->framesCount - ROTATE_ENTRIES]) /* Time is after last frame. */ - r2 = bone->data->rotation + frames[rotateTimeline->framesCount + ROTATE_PREV_ROTATION]; - else { - /* Interpolate between the previous frame and the current frame. */ - frame = _spCurveTimeline_binarySearch(frames, rotateTimeline->framesCount, time, ROTATE_ENTRIES); - prevRotation = frames[frame + ROTATE_PREV_ROTATION]; - frameTime = frames[frame]; - percent = spCurveTimeline_getCurvePercent(SUPER(rotateTimeline), (frame >> 1) - 1, - 1 - (time - frameTime) / (frames[frame + ROTATE_PREV_TIME] - frameTime)); - - r2 = frames[frame + ROTATE_ROTATION] - prevRotation; - r2 -= (16384 - (int)(16384.499999999996 - r2 / 360)) * 360; - r2 = prevRotation + r2 * percent + bone->data->rotation; - r2 -= (16384 - (int)(16384.499999999996 - r2 / 360)) * 360; - } - - /* Mix between rotations using the direction of the shortest route on the first frame while detecting crosses. */ - r1 = setupPose ? bone->data->rotation : bone->rotation; - diff = r2 - r1; - if (diff == 0) { - total = timelinesRotation[i]; - } else { - float lastTotal, lastDiff; - diff -= (16384 - (int)(16384.499999999996 - diff / 360)) * 360; - if (firstFrame) { - lastTotal = 0; - lastDiff = diff; - } else { - lastTotal = timelinesRotation[i]; /* Angle and direction of mix, including loops. */ - lastDiff = timelinesRotation[i + 1]; /* Difference between bones. */ - } - current = diff > 0; - dir = lastTotal >= 0; - /* Detect cross at 0 (not 180). */ - if (SIGNUM(lastDiff) != SIGNUM(diff) && ABS(lastDiff) <= 90) { - /* A cross after a 360 rotation is a loop. */ - if (ABS(lastTotal) > 180) lastTotal += 360 * SIGNUM(lastTotal); - dir = current; - } - total = diff + lastTotal - FMOD(lastTotal, 360); /* Store loops as part of lastTotal. */ - if (dir != current) total += 360 * SIGNUM(lastTotal); - timelinesRotation[i] = total; - } - timelinesRotation[i + 1] = diff; - r1 += total * alpha; - bone->rotation = r1 - (16384 - (int)(16384.499999999996 - r1 / 360)) * 360; -} - -void _spAnimationState_queueEvents (spAnimationState* self, spTrackEntry* entry, float animationTime) { - spEvent** events; - spEvent* event; - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - int i, n; - float animationStart = entry->animationStart, animationEnd = entry->animationEnd; - float duration = animationEnd - animationStart; - float trackLastWrapped = FMOD(entry->trackLast, duration); - - /* Queue events before complete. */ - events = internal->events; - for (i = 0, n = internal->eventsCount; i < n; i++) { - event = events[i]; - if (event->time < trackLastWrapped) break; - if (event->time > animationEnd) continue; /* Discard events outside animation start/end. */ - _spEventQueue_event(internal->queue, entry, event); - } - - /* Queue complete if completed a loop iteration or the animation. */ - if (entry->loop ? (trackLastWrapped > FMOD(entry->trackTime, duration)) - : (animationTime >= animationEnd && entry->animationLast < animationEnd)) { - _spEventQueue_complete(internal->queue, entry); - } - - /* Queue events after complete. */ - for (; i < n; i++) { - event = events[i]; - if (event->time < animationStart) continue; /* Discard events outside animation start/end. */ - _spEventQueue_event(internal->queue, entry, event); - } -} - -void spAnimationState_clearTracks (spAnimationState* self) { - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - int i, n; - internal->queue->drainDisabled = 1; - for (i = 0, n = self->tracksCount; i < n; i++) - spAnimationState_clearTrack(self, i); - self->tracksCount = 0; - internal->queue->drainDisabled = 0; - _spEventQueue_drain(internal->queue); -} - -void spAnimationState_clearTrack (spAnimationState* self, int trackIndex) { - spTrackEntry* current; - spTrackEntry* entry; - spTrackEntry* from; - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - - if (trackIndex >= self->tracksCount) return; - current = self->tracks[trackIndex]; - if (!current) return; - - _spEventQueue_end(internal->queue, current); - - _spAnimationState_disposeNext(self, current); - - entry = current; - while (1) { - from = entry->mixingFrom; - if (!from) break; - _spEventQueue_end(internal->queue, from); - entry->mixingFrom = 0; - entry = from; - } - - self->tracks[current->trackIndex] = 0; - _spEventQueue_drain(internal->queue); -} - -void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* current, int /*boolean*/ interrupt) { - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - spTrackEntry* from = _spAnimationState_expandToIndex(self, index); - self->tracks[index] = current; - - if (from) { - if (interrupt) _spEventQueue_interrupt(internal->queue, from); - current->mixingFrom = from; - current->mixTime = 0; - - from->timelinesRotationCount = 0; - - /* If not completely mixed in, set mixAlpha so mixing out happens from current mix to zero. */ - if (from->mixingFrom && from->mixDuration > 0) current->mixAlpha *= MIN(from->mixTime / from->mixDuration, 1); - } - - _spEventQueue_start(internal->queue, current); -} - -/** Set the current animation. Any queued animations are cleared. */ -spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, - int/*bool*/loop) { - spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName); - return spAnimationState_setAnimation(self, trackIndex, animation, loop); -} - -spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop) { - spTrackEntry* entry; - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - int interrupt = 1; - spTrackEntry* current = _spAnimationState_expandToIndex(self, trackIndex); - if (current) { - if (current->nextTrackLast == -1) { - /* Don't mix from an entry that was never applied. */ - self->tracks[trackIndex] = current->mixingFrom; - _spEventQueue_interrupt(internal->queue, current); - _spEventQueue_end(internal->queue, current); - _spAnimationState_disposeNext(self, current); - current = current->mixingFrom; - interrupt = 0; - } else - _spAnimationState_disposeNext(self, current); - } - entry = _spAnimationState_trackEntry(self, trackIndex, animation, loop, current); - _spAnimationState_setCurrent(self, trackIndex, entry, interrupt); - _spEventQueue_drain(internal->queue); - return entry; -} - -/** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix - * duration. */ -spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, - int/*bool*/loop, float delay) { - spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName); - return spAnimationState_addAnimation(self, trackIndex, animation, loop, delay); -} - -spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop, - float delay) { - spTrackEntry* entry; - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - spTrackEntry* last = _spAnimationState_expandToIndex(self, trackIndex); - if (last) { - while (last->next) - last = last->next; - } - - entry = _spAnimationState_trackEntry(self, trackIndex, animation, loop, last); - - if (!last) { - _spAnimationState_setCurrent(self, trackIndex, entry, 1); - _spEventQueue_drain(internal->queue); - } else { - last->next = entry; - if (delay <= 0) { - float duration = last->animationEnd - last->animationStart; - if (duration != 0) - delay += duration * (1 + (int)(last->trackTime / duration)) - spAnimationStateData_getMix(self->data, last->animation, animation); - else - delay = 0; - } - } - - entry->delay = delay; - return entry; -} - -spTrackEntry* spAnimationState_setEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration) { - spTrackEntry* entry = spAnimationState_setAnimation(self, trackIndex, SP_EMPTY_ANIMATION, 0); - entry->mixDuration = mixDuration; - entry->trackEnd = mixDuration; - return entry; -} - -spTrackEntry* spAnimationState_addEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration, float delay) { - spTrackEntry* entry; - if (delay <= 0) delay -= mixDuration; - entry = spAnimationState_addAnimation(self, trackIndex, SP_EMPTY_ANIMATION, 0, delay); - entry->mixDuration = mixDuration; - entry->trackEnd = mixDuration; - return entry; -} - -void spAnimationState_setEmptyAnimations(spAnimationState* self, float mixDuration) { - int i, n; - spTrackEntry* current; - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - internal->queue->drainDisabled = 1; - for (i = 0, n = self->tracksCount; i < n; i++) { - current = self->tracks[i]; - if (current) spAnimationState_setEmptyAnimation(self, current->trackIndex, mixDuration); - } - internal->queue->drainDisabled = 0; - _spEventQueue_drain(internal->queue); -} - -spTrackEntry* _spAnimationState_expandToIndex (spAnimationState* self, int index) { - spTrackEntry** newTracks; - if (index < self->tracksCount) return self->tracks[index]; - newTracks = CALLOC(spTrackEntry*, index + 1); - memcpy(newTracks, self->tracks, self->tracksCount * sizeof(spTrackEntry*)); - FREE(self->tracks); - self->tracks = newTracks; - self->tracksCount = index + 1; - return 0; -} - -spTrackEntry* _spAnimationState_trackEntry (spAnimationState* self, int trackIndex, spAnimation* animation, int /*boolean*/ loop, spTrackEntry* last) { - spTrackEntry* entry = NEW(spTrackEntry); - entry->trackIndex = trackIndex; - entry->animation = animation; - entry->loop = loop; - - entry->eventThreshold = 0; - entry->attachmentThreshold = 0; - entry->drawOrderThreshold = 0; - - entry->animationStart = 0; - entry->animationEnd = animation->duration; - entry->animationLast = -1; - entry->nextAnimationLast = -1; - - entry->delay = 0; - entry->trackTime = 0; - entry->trackLast = -1; - entry->nextTrackLast = -1; - entry->trackEnd = (float)INT_MAX; - entry->timeScale = 1; - - entry->alpha = 1; - entry->mixAlpha = 1; - entry->mixTime = 0; - entry->mixDuration = !last ? 0 : spAnimationStateData_getMix(self->data, last->animation, animation); - return entry; -} - -void _spAnimationState_disposeNext (spAnimationState* self, spTrackEntry* entry) { - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - spTrackEntry* next = entry->next; - while (next) { - _spEventQueue_dispose(internal->queue, next); - next = next->next; - } - entry->next = 0; -} - -void _spAnimationState_animationsChanged (spAnimationState* self) { - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - int i, n; - spTrackEntry* entry; - internal->animationsChanged = 0; - - i = 0; n = self->tracksCount; - internal->propertyIDsCount = 0; - - for (; i < n; i++) { - entry = self->tracks[i]; - if (!entry) continue; - _spAnimationState_setTimelinesFirst(self, entry); - i++; - break; - } - for (; i < n; i++) { - entry = self->tracks[i]; - if (entry) _spAnimationState_checkTimelinesFirst(self, entry); - } -} - -float* _spAnimationState_resizeTimelinesRotation(spTrackEntry* entry, int newSize) { - if (entry->timelinesRotationCount != newSize) { - float* newTimelinesRotation = CALLOC(float, newSize); - FREE(entry->timelinesRotation); - entry->timelinesRotation = newTimelinesRotation; - entry->timelinesRotationCount = newSize; - } - return entry->timelinesRotation; -} - -int* _spAnimationState_resizeTimelinesFirst(spTrackEntry* entry, int newSize) { - if (entry->timelinesFirstCount != newSize) { - int* newTimelinesFirst = CALLOC(int, newSize); - FREE(entry->timelinesFirst); - entry->timelinesFirst = newTimelinesFirst; - entry->timelinesFirstCount = newSize; - } - - return entry->timelinesFirst; -} - -void _spAnimationState_ensureCapacityPropertyIDs(spAnimationState* self, int capacity) { - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - if (internal->propertyIDsCapacity < capacity) { - int *newPropertyIDs = CALLOC(int, capacity << 1); - memcpy(newPropertyIDs, internal->propertyIDs, sizeof(int) * internal->propertyIDsCount); - FREE(internal->propertyIDs); - internal->propertyIDs = newPropertyIDs; - internal->propertyIDsCapacity = capacity << 1; - } -} - -int _spAnimationState_addPropertyID(spAnimationState* self, int id) { - int i, n; - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - - for (i = 0, n = internal->propertyIDsCount; i < n; i++) { - if (internal->propertyIDs[i] == id) return 0; - } - - _spAnimationState_ensureCapacityPropertyIDs(self, internal->propertyIDsCount + 1); - internal->propertyIDs[internal->propertyIDsCount] = id; - internal->propertyIDsCount++; - return 1; -} - -void _spAnimationState_setTimelinesFirst (spAnimationState* self, spTrackEntry* entry) { - int i, n; - int* usage; - spTimeline** timelines; - - if (entry->mixingFrom) { - _spAnimationState_setTimelinesFirst(self, entry->mixingFrom); - _spAnimationState_checkTimelinesUsage(self, entry); - return; - } - - n = entry->animation->timelinesCount; - timelines = entry->animation->timelines; - usage = _spAnimationState_resizeTimelinesFirst(entry, n); - for (i = 0; i < n; i++) { - _spAnimationState_addPropertyID(self, spTimeline_getPropertyId(timelines[i])); - usage[i] = 1; - } -} - -void _spAnimationState_checkTimelinesFirst (spAnimationState* self, spTrackEntry* entry) { - if (entry->mixingFrom) _spAnimationState_checkTimelinesFirst(self, entry->mixingFrom); - _spAnimationState_checkTimelinesUsage(self, entry); -} - -void _spAnimationState_checkTimelinesUsage (spAnimationState* self, spTrackEntry* entry) { - int i, n; - int* usage; - spTimeline** timelines; - n = entry->animation->timelinesCount; - timelines = entry->animation->timelines; - usage = _spAnimationState_resizeTimelinesFirst(entry, n); - for (i = 0; i < n; i++) - usage[i] = _spAnimationState_addPropertyID(self, spTimeline_getPropertyId(timelines[i])); -} - -spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex) { - if (trackIndex >= self->tracksCount) return 0; - return self->tracks[trackIndex]; -} - -void spAnimationState_clearListenerNotifications(spAnimationState* self) { - _spAnimationState* internal = SUB_CAST(_spAnimationState, self); - _spEventQueue_clear(internal->queue); -} - -float spTrackEntry_getAnimationTime (spTrackEntry* entry) { - if (entry->loop) { - float duration = entry->animationEnd - entry->animationStart; - if (duration == 0) return entry->animationStart; - return FMOD(entry->trackTime, duration) + entry->animationStart; - } - return MIN(entry->trackTime + entry->animationStart, entry->animationEnd); -} diff --git a/native/cocos/editor-support/spine/AnimationState.h b/native/cocos/editor-support/spine/AnimationState.h deleted file mode 100644 index ae08e02754..0000000000 --- a/native/cocos/editor-support/spine/AnimationState.h +++ /dev/null @@ -1,179 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_ANIMATIONSTATE_H_ -#define SPINE_ANIMATIONSTATE_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - SP_ANIMATION_START, SP_ANIMATION_INTERRUPT, SP_ANIMATION_END, SP_ANIMATION_COMPLETE, SP_ANIMATION_DISPOSE, SP_ANIMATION_EVENT -} spEventType; - -typedef struct spAnimationState spAnimationState; -typedef struct spTrackEntry spTrackEntry; - -typedef void (*spAnimationStateListener) (spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event); - -struct spTrackEntry { - spAnimation* animation; - spTrackEntry* next; - spTrackEntry* mixingFrom; - spAnimationStateListener listener; - int trackIndex; - int /*boolean*/ loop; - float eventThreshold, attachmentThreshold, drawOrderThreshold; - float animationStart, animationEnd, animationLast, nextAnimationLast; - float delay, trackTime, trackLast, nextTrackLast, trackEnd, timeScale; - float alpha, mixTime, mixDuration, mixAlpha; - int* /*boolean*/ timelinesFirst; - int timelinesFirstCount; - float* timelinesRotation; - int timelinesRotationCount; - void* rendererObject; - -#ifdef __cplusplus - spTrackEntry() : - animation(0), - next(0), mixingFrom(0), - listener(0), - trackIndex(0), - loop(0), - eventThreshold(0), attachmentThreshold(0), drawOrderThreshold(0), - animationStart(0), animationEnd(0), animationLast(0), nextAnimationLast(0), - delay(0), trackTime(0), trackLast(0), nextTrackLast(0), trackEnd(0), timeScale(0), - alpha(0), mixTime(0), mixDuration(0), mixAlpha(0), - timelinesFirst(0), - timelinesFirstCount(0), - timelinesRotation(0), - timelinesRotationCount(0) { - } -#endif -}; - -struct spAnimationState { - spAnimationStateData* const data; - - int tracksCount; - spTrackEntry** tracks; - - spAnimationStateListener listener; - - float timeScale; - - void* rendererObject; - -#ifdef __cplusplus - spAnimationState() : - data(0), - tracksCount(0), - tracks(0), - listener(0), - timeScale(0) { - } -#endif -}; - -/* @param data May be 0 for no mixing. */ -spAnimationState* spAnimationState_create (spAnimationStateData* data); -void spAnimationState_dispose (spAnimationState* self); - -void spAnimationState_update (spAnimationState* self, float delta); -void spAnimationState_apply (spAnimationState* self, struct spSkeleton* skeleton); - -void spAnimationState_clearTracks (spAnimationState* self); -void spAnimationState_clearTrack (spAnimationState* self, int trackIndex); - -/** Set the current animation. Any queued animations are cleared. */ -spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, - int/*bool*/loop); -spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop); - -/** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix - * duration. */ -spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, - int/*bool*/loop, float delay); -spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop, - float delay); -spTrackEntry* spAnimationState_setEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration); -spTrackEntry* spAnimationState_addEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration, float delay); -void spAnimationState_setEmptyAnimations(spAnimationState* self, float mixDuration); - -spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex); - -void spAnimationState_clearListenerNotifications(spAnimationState* self); - -float spTrackEntry_getAnimationTime (spTrackEntry* entry); - -/** Use this to dispose static memory before your app exits to appease your memory leak detector*/ -void spAnimationState_disposeStatics (); - -typedef void (*TrackEntryDisposeCallback)(spTrackEntry*); -void spTrackEntry_setDisposeCallback(TrackEntryDisposeCallback cb); - -#ifdef SPINE_SHORT_NAMES -typedef spEventType EventType; -#define ANIMATION_START SP_ANIMATION_START -#define ANIMATION_INTERRUPT SP_ANIMATION_INTERRUPT -#define ANIMATION_END SP_ANIMATION_END -#define ANIMATION_COMPLETE SP_ANIMATION_COMPLETE -#define ANIMATION_DISPOSE SP_ANIMATION_DISPOSE -#define ANIMATION_EVENT SP_ANIMATION_EVENT -typedef spAnimationStateListener AnimationStateListener; -typedef spTrackEntry TrackEntry; -typedef spAnimationState AnimationState; -#define AnimationState_create(...) spAnimationState_create(__VA_ARGS__) -#define AnimationState_dispose(...) spAnimationState_dispose(__VA_ARGS__) -#define AnimationState_update(...) spAnimationState_update(__VA_ARGS__) -#define AnimationState_apply(...) spAnimationState_apply(__VA_ARGS__) -#define AnimationState_clearTracks(...) spAnimationState_clearTracks(__VA_ARGS__) -#define AnimationState_clearTrack(...) spAnimationState_clearTrack(__VA_ARGS__) -#define AnimationState_setAnimationByName(...) spAnimationState_setAnimationByName(__VA_ARGS__) -#define AnimationState_setAnimation(...) spAnimationState_setAnimation(__VA_ARGS__) -#define AnimationState_addAnimationByName(...) spAnimationState_addAnimationByName(__VA_ARGS__) -#define AnimationState_addAnimation(...) spAnimationState_addAnimation(__VA_ARGS__) -#define AnimationState_setEmptyAnimation(...) spAnimatinState_setEmptyAnimation(__VA_ARGS__) -#define AnimationState_addEmptyAnimation(...) spAnimatinState_addEmptyAnimation(__VA_ARGS__) -#define AnimationState_setEmptyAnimations(...) spAnimatinState_setEmptyAnimations(__VA_ARGS__) -#define AnimationState_getCurrent(...) spAnimationState_getCurrent(__VA_ARGS__) -#define AnimationState_clearListenerNotifications(...) spAnimatinState_clearListenerNotifications(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_ANIMATIONSTATE_H_ */ diff --git a/native/cocos/editor-support/spine/AnimationStateData.c b/native/cocos/editor-support/spine/AnimationStateData.c deleted file mode 100644 index 2aeb25adda..0000000000 --- a/native/cocos/editor-support/spine/AnimationStateData.c +++ /dev/null @@ -1,151 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -typedef struct _ToEntry _ToEntry; -struct _ToEntry { - spAnimation* animation; - float duration; - _ToEntry* next; -}; - -_ToEntry* _ToEntry_create (spAnimation* to, float duration) { - _ToEntry* self = NEW(_ToEntry); - self->animation = to; - self->duration = duration; - return self; -} - -void _ToEntry_dispose (_ToEntry* self) { - FREE(self); -} - -/**/ - -typedef struct _FromEntry _FromEntry; -struct _FromEntry { - spAnimation* animation; - _ToEntry* toEntries; - _FromEntry* next; -}; - -_FromEntry* _FromEntry_create (spAnimation* from) { - _FromEntry* self = NEW(_FromEntry); - self->animation = from; - return self; -} - -void _FromEntry_dispose (_FromEntry* self) { - FREE(self); -} - -/**/ - -spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData) { - spAnimationStateData* self = NEW(spAnimationStateData); - CONST_CAST(spSkeletonData*, self->skeletonData) = skeletonData; - return self; -} - -void spAnimationStateData_dispose (spAnimationStateData* self) { - _ToEntry* toEntry; - _ToEntry* nextToEntry; - _FromEntry* nextFromEntry; - - _FromEntry* fromEntry = (_FromEntry*)self->entries; - while (fromEntry) { - toEntry = fromEntry->toEntries; - while (toEntry) { - nextToEntry = toEntry->next; - _ToEntry_dispose(toEntry); - toEntry = nextToEntry; - } - nextFromEntry = fromEntry->next; - _FromEntry_dispose(fromEntry); - fromEntry = nextFromEntry; - } - - FREE(self); -} - -void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration) { - spAnimation* to; - spAnimation* from = spSkeletonData_findAnimation(self->skeletonData, fromName); - if (!from) return; - to = spSkeletonData_findAnimation(self->skeletonData, toName); - if (!to) return; - spAnimationStateData_setMix(self, from, to, duration); -} - -void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration) { - /* Find existing FromEntry. */ - _ToEntry* toEntry; - _FromEntry* fromEntry = (_FromEntry*)self->entries; - while (fromEntry) { - if (fromEntry->animation == from) { - /* Find existing ToEntry. */ - toEntry = fromEntry->toEntries; - while (toEntry) { - if (toEntry->animation == to) { - toEntry->duration = duration; - return; - } - toEntry = toEntry->next; - } - break; /* Add new ToEntry to the existing FromEntry. */ - } - fromEntry = fromEntry->next; - } - if (!fromEntry) { - fromEntry = _FromEntry_create(from); - fromEntry->next = (_FromEntry*)self->entries; - CONST_CAST(_FromEntry*, self->entries) = fromEntry; - } - toEntry = _ToEntry_create(to, duration); - toEntry->next = fromEntry->toEntries; - fromEntry->toEntries = toEntry; -} - -float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to) { - _FromEntry* fromEntry = (_FromEntry*)self->entries; - while (fromEntry) { - if (fromEntry->animation == from) { - _ToEntry* toEntry = fromEntry->toEntries; - while (toEntry) { - if (toEntry->animation == to) return toEntry->duration; - toEntry = toEntry->next; - } - } - fromEntry = fromEntry->next; - } - return self->defaultMix; -} diff --git a/native/cocos/editor-support/spine/AnimationStateData.h b/native/cocos/editor-support/spine/AnimationStateData.h deleted file mode 100644 index 063f7fdeb7..0000000000 --- a/native/cocos/editor-support/spine/AnimationStateData.h +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_ANIMATIONSTATEDATA_H_ -#define SPINE_ANIMATIONSTATEDATA_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spAnimationStateData { - spSkeletonData* const skeletonData; - float defaultMix; - const void* const entries; - -#ifdef __cplusplus - spAnimationStateData() : - skeletonData(0), - defaultMix(0), - entries(0) { - } -#endif -} spAnimationStateData; - -spAnimationStateData* spAnimationStateData_create (spSkeletonData* skeletonData); -void spAnimationStateData_dispose (spAnimationStateData* self); - -void spAnimationStateData_setMixByName (spAnimationStateData* self, const char* fromName, const char* toName, float duration); -void spAnimationStateData_setMix (spAnimationStateData* self, spAnimation* from, spAnimation* to, float duration); -/* Returns 0 if there is no mixing between the animations. */ -float spAnimationStateData_getMix (spAnimationStateData* self, spAnimation* from, spAnimation* to); - -#ifdef SPINE_SHORT_NAMES -typedef spAnimationStateData AnimationStateData; -#define AnimationStateData_create(...) spAnimationStateData_create(__VA_ARGS__) -#define AnimationStateData_dispose(...) spAnimationStateData_dispose(__VA_ARGS__) -#define AnimationStateData_setMixByName(...) spAnimationStateData_setMixByName(__VA_ARGS__) -#define AnimationStateData_setMix(...) spAnimationStateData_setMix(__VA_ARGS__) -#define AnimationStateData_getMix(...) spAnimationStateData_getMix(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_ANIMATIONSTATEDATA_H_ */ diff --git a/native/cocos/editor-support/spine/Atlas.c b/native/cocos/editor-support/spine/Atlas.c deleted file mode 100644 index 99ced93ed3..0000000000 --- a/native/cocos/editor-support/spine/Atlas.c +++ /dev/null @@ -1,353 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include - -spAtlasPage* spAtlasPage_create (spAtlas* atlas, const char* name) { - spAtlasPage* self = NEW(spAtlasPage); - CONST_CAST(spAtlas*, self->atlas) = atlas; - MALLOC_STR(self->name, name); - return self; -} - -void spAtlasPage_dispose (spAtlasPage* self) { - _spAtlasPage_disposeTexture(self); - FREE(self->name); - FREE(self); -} - -/**/ - -spAtlasRegion* spAtlasRegion_create () { - return NEW(spAtlasRegion); -} - -void spAtlasRegion_dispose (spAtlasRegion* self) { - FREE(self->name); - FREE(self->splits); - FREE(self->pads); - FREE(self); -} - -/**/ - -typedef struct { - const char* begin; - const char* end; -} Str; - -static void trim (Str* str) { - while (isspace((unsigned char)*str->begin) && str->begin < str->end) - (str->begin)++; - if (str->begin == str->end) return; - str->end--; - while (isspace((unsigned char)*str->end) && str->end >= str->begin) - str->end--; - str->end++; -} - -/* Tokenize string without modification. Returns 0 on failure. */ -static int readLine (const char** begin, const char* end, Str* str) { - if (*begin == end) return 0; - str->begin = *begin; - - /* Find next delimiter. */ - while (*begin != end && **begin != '\n') - (*begin)++; - - str->end = *begin; - trim(str); - - if (*begin != end) (*begin)++; - return 1; -} - -/* Moves str->begin past the first occurence of c. Returns 0 on failure. */ -static int beginPast (Str* str, char c) { - const char* begin = str->begin; - while (1) { - char lastSkippedChar = *begin; - if (begin == str->end) return 0; - begin++; - if (lastSkippedChar == c) break; - } - str->begin = begin; - return 1; -} - -/* Returns 0 on failure. */ -static int readValue (const char** begin, const char* end, Str* str) { - readLine(begin, end, str); - if (!beginPast(str, ':')) return 0; - trim(str); - return 1; -} - -/* Returns the number of tuple values read (1, 2, 4, or 0 for failure). */ -static int readTuple (const char** begin, const char* end, Str tuple[]) { - int i; - Str str = {NULL, NULL}; - readLine(begin, end, &str); - if (!beginPast(&str, ':')) return 0; - - for (i = 0; i < 3; ++i) { - tuple[i].begin = str.begin; - if (!beginPast(&str, ',')) break; - tuple[i].end = str.begin - 2; - trim(&tuple[i]); - } - tuple[i].begin = str.begin; - tuple[i].end = str.end; - trim(&tuple[i]); - return i + 1; -} - -static char* mallocString (Str* str) { - int length = (int)(str->end - str->begin); - char* string = MALLOC(char, length + 1); - memcpy(string, str->begin, length); - string[length] = '\0'; - return string; -} - -static int indexOf (const char** array, int count, Str* str) { - int length = (int)(str->end - str->begin); - int i; - for (i = count - 1; i >= 0; i--) - if (strncmp(array[i], str->begin, length) == 0) return i; - return 0; -} - -static int equals (Str* str, const char* other) { - return strncmp(other, str->begin, str->end - str->begin) == 0; -} - -static int toInt (Str* str) { - return (int)strtol(str->begin, (char**)&str->end, 10); -} - -static spAtlas* abortAtlas (spAtlas* self) { - spAtlas_dispose(self); - return 0; -} - -static const char* formatNames[] = {"", "Alpha", "Intensity", "LuminanceAlpha", "RGB565", "RGBA4444", "RGB888", "RGBA8888"}; -static const char* textureFilterNames[] = {"", "Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapLinearNearest", - "MipMapNearestLinear", "MipMapLinearLinear"}; - -spAtlas* spAtlas_create (const char* begin, int length, const char* dir, void* rendererObject) { - spAtlas* self; - - int count; - const char* end = begin + length; - int dirLength = (int)strlen(dir); - int needsSlash = dirLength > 0 && dir[dirLength - 1] != '/' && dir[dirLength - 1] != '\\'; - - spAtlasPage *page = 0; - spAtlasPage *lastPage = 0; - spAtlasRegion *lastRegion = 0; - Str str; - Str tuple[4]; - - self = NEW(spAtlas); - self->rendererObject = rendererObject; - - while (readLine(&begin, end, &str)) { - if (str.end - str.begin == 0) { - page = 0; - } else if (!page) { - char* name = mallocString(&str); - char* path = MALLOC(char, dirLength + needsSlash + strlen(name) + 1); - memcpy(path, dir, dirLength); - if (needsSlash) path[dirLength] = '/'; - strcpy(path + dirLength + needsSlash, name); - - page = spAtlasPage_create(self, name); - FREE(name); - if (lastPage) - lastPage->next = page; - else - self->pages = page; - lastPage = page; - - switch (readTuple(&begin, end, tuple)) { - case 0: - return abortAtlas(self); - case 2: /* size is only optional for an atlas packed with an old TexturePacker. */ - page->width = toInt(tuple); - page->height = toInt(tuple + 1); - if (!readTuple(&begin, end, tuple)) return abortAtlas(self); - } - page->format = (spAtlasFormat)indexOf(formatNames, 8, tuple); - - if (!readTuple(&begin, end, tuple)) return abortAtlas(self); - page->minFilter = (spAtlasFilter)indexOf(textureFilterNames, 8, tuple); - page->magFilter = (spAtlasFilter)indexOf(textureFilterNames, 8, tuple + 1); - - if (!readValue(&begin, end, &str)) return abortAtlas(self); - - page->uWrap = SP_ATLAS_CLAMPTOEDGE; - page->vWrap = SP_ATLAS_CLAMPTOEDGE; - if (!equals(&str, "none")) { - if (str.end - str.begin == 1) { - if (*str.begin == 'x') - page->uWrap = SP_ATLAS_REPEAT; - else if (*str.begin == 'y') - page->vWrap = SP_ATLAS_REPEAT; - } else if (equals(&str, "xy")) { - page->uWrap = SP_ATLAS_REPEAT; - page->vWrap = SP_ATLAS_REPEAT; - } - } - - _spAtlasPage_createTexture(page, path); - FREE(path); - } else { - spAtlasRegion *region = spAtlasRegion_create(); - if (lastRegion) - lastRegion->next = region; - else - self->regions = region; - lastRegion = region; - - region->page = page; - region->name = mallocString(&str); - - if (!readValue(&begin, end, &str)) return abortAtlas(self); - region->rotate = equals(&str, "true"); - - if (readTuple(&begin, end, tuple) != 2) return abortAtlas(self); - region->x = toInt(tuple); - region->y = toInt(tuple + 1); - - if (readTuple(&begin, end, tuple) != 2) return abortAtlas(self); - region->width = toInt(tuple); - region->height = toInt(tuple + 1); - - region->u = region->x / (float)page->width; - region->v = region->y / (float)page->height; - if (region->rotate) { - region->u2 = (region->x + region->height) / (float)page->width; - region->v2 = (region->y + region->width) / (float)page->height; - } else { - region->u2 = (region->x + region->width) / (float)page->width; - region->v2 = (region->y + region->height) / (float)page->height; - } - - if (!(count = readTuple(&begin, end, tuple))) return abortAtlas(self); - if (count == 4) { /* split is optional */ - region->splits = MALLOC(int, 4); - region->splits[0] = toInt(tuple); - region->splits[1] = toInt(tuple + 1); - region->splits[2] = toInt(tuple + 2); - region->splits[3] = toInt(tuple + 3); - - if (!(count = readTuple(&begin, end, tuple))) return abortAtlas(self); - if (count == 4) { /* pad is optional, but only present with splits */ - region->pads = MALLOC(int, 4); - region->pads[0] = toInt(tuple); - region->pads[1] = toInt(tuple + 1); - region->pads[2] = toInt(tuple + 2); - region->pads[3] = toInt(tuple + 3); - - if (!readTuple(&begin, end, tuple)) return abortAtlas(self); - } - } - - region->originalWidth = toInt(tuple); - region->originalHeight = toInt(tuple + 1); - - readTuple(&begin, end, tuple); - region->offsetX = toInt(tuple); - region->offsetY = toInt(tuple + 1); - - if (!readValue(&begin, end, &str)) return abortAtlas(self); - region->index = toInt(&str); - } - } - - return self; -} - -spAtlas* spAtlas_createFromFile (const char* path, void* rendererObject) { - int dirLength; - char *dir; - int length; - const char* data; - - spAtlas* atlas = 0; - - /* Get directory from atlas path. */ - const char* lastForwardSlash = strrchr(path, '/'); - const char* lastBackwardSlash = strrchr(path, '\\'); - const char* lastSlash = lastForwardSlash > lastBackwardSlash ? lastForwardSlash : lastBackwardSlash; - if (lastSlash == path) lastSlash++; /* Never drop starting slash. */ - dirLength = (int)(lastSlash ? lastSlash - path : 0); - dir = MALLOC(char, dirLength + 1); - memcpy(dir, path, dirLength); - dir[dirLength] = '\0'; - - data = _spUtil_readFile(path, &length); - if (data) atlas = spAtlas_create(data, length, dir, rendererObject); - - FREE(data); - FREE(dir); - return atlas; -} - -void spAtlas_dispose (spAtlas* self) { - spAtlasRegion* region, *nextRegion; - spAtlasPage* page = self->pages; - while (page) { - spAtlasPage* nextPage = page->next; - spAtlasPage_dispose(page); - page = nextPage; - } - - region = self->regions; - while (region) { - nextRegion = region->next; - spAtlasRegion_dispose(region); - region = nextRegion; - } - - FREE(self); -} - -spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name) { - spAtlasRegion* region = self->regions; - while (region) { - if (strcmp(region->name, name) == 0) return region; - region = region->next; - } - return 0; -} diff --git a/native/cocos/editor-support/spine/Atlas.h b/native/cocos/editor-support/spine/Atlas.h deleted file mode 100644 index 392e498df9..0000000000 --- a/native/cocos/editor-support/spine/Atlas.h +++ /dev/null @@ -1,172 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_ATLAS_H_ -#define SPINE_ATLAS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spAtlas spAtlas; - -typedef enum { - SP_ATLAS_UNKNOWN_FORMAT, - SP_ATLAS_ALPHA, - SP_ATLAS_INTENSITY, - SP_ATLAS_LUMINANCE_ALPHA, - SP_ATLAS_RGB565, - SP_ATLAS_RGBA4444, - SP_ATLAS_RGB888, - SP_ATLAS_RGBA8888 -} spAtlasFormat; - -typedef enum { - SP_ATLAS_UNKNOWN_FILTER, - SP_ATLAS_NEAREST, - SP_ATLAS_LINEAR, - SP_ATLAS_MIPMAP, - SP_ATLAS_MIPMAP_NEAREST_NEAREST, - SP_ATLAS_MIPMAP_LINEAR_NEAREST, - SP_ATLAS_MIPMAP_NEAREST_LINEAR, - SP_ATLAS_MIPMAP_LINEAR_LINEAR -} spAtlasFilter; - -typedef enum { - SP_ATLAS_MIRROREDREPEAT, - SP_ATLAS_CLAMPTOEDGE, - SP_ATLAS_REPEAT -} spAtlasWrap; - -typedef struct spAtlasPage spAtlasPage; -struct spAtlasPage { - const spAtlas* atlas; - const char* name; - spAtlasFormat format; - spAtlasFilter minFilter, magFilter; - spAtlasWrap uWrap, vWrap; - - void* rendererObject; - int width, height; - - spAtlasPage* next; -}; - -spAtlasPage* spAtlasPage_create (spAtlas* atlas, const char* name); -void spAtlasPage_dispose (spAtlasPage* self); - -#ifdef SPINE_SHORT_NAMES -typedef spAtlasFormat AtlasFormat; -#define ATLAS_UNKNOWN_FORMAT SP_ATLAS_UNKNOWN_FORMAT -#define ATLAS_ALPHA SP_ATLAS_ALPHA -#define ATLAS_INTENSITY SP_ATLAS_INTENSITY -#define ATLAS_LUMINANCE_ALPHA SP_ATLAS_LUMINANCE_ALPHA -#define ATLAS_RGB565 SP_ATLAS_RGB565 -#define ATLAS_RGBA4444 SP_ATLAS_RGBA4444 -#define ATLAS_RGB888 SP_ATLAS_RGB888 -#define ATLAS_RGBA8888 SP_ATLAS_RGBA8888 -typedef spAtlasFilter AtlasFilter; -#define ATLAS_UNKNOWN_FILTER SP_ATLAS_UNKNOWN_FILTER -#define ATLAS_NEAREST SP_ATLAS_NEAREST -#define ATLAS_LINEAR SP_ATLAS_LINEAR -#define ATLAS_MIPMAP SP_ATLAS_MIPMAP -#define ATLAS_MIPMAP_NEAREST_NEAREST SP_ATLAS_MIPMAP_NEAREST_NEAREST -#define ATLAS_MIPMAP_LINEAR_NEAREST SP_ATLAS_MIPMAP_LINEAR_NEAREST -#define ATLAS_MIPMAP_NEAREST_LINEAR SP_ATLAS_MIPMAP_NEAREST_LINEAR -#define ATLAS_MIPMAP_LINEAR_LINEAR SP_ATLAS_MIPMAP_LINEAR_LINEAR -typedef spAtlasWrap AtlasWrap; -#define ATLAS_MIRROREDREPEAT SP_ATLAS_MIRROREDREPEAT -#define ATLAS_CLAMPTOEDGE SP_ATLAS_CLAMPTOEDGE -#define ATLAS_REPEAT SP_ATLAS_REPEAT -typedef spAtlasPage AtlasPage; -#define AtlasPage_create(...) spAtlasPage_create(__VA_ARGS__) -#define AtlasPage_dispose(...) spAtlasPage_dispose(__VA_ARGS__) -#endif - -/**/ - -typedef struct spAtlasRegion spAtlasRegion; -struct spAtlasRegion { - const char* name; - int x, y, width, height; - float u, v, u2, v2; - int offsetX, offsetY; - int originalWidth, originalHeight; - int index; - int/*bool*/rotate; - int/*bool*/flip; - int* splits; - int* pads; - - spAtlasPage* page; - - spAtlasRegion* next; -}; - -spAtlasRegion* spAtlasRegion_create (); -void spAtlasRegion_dispose (spAtlasRegion* self); - -#ifdef SPINE_SHORT_NAMES -typedef spAtlasRegion AtlasRegion; -#define AtlasRegion_create(...) spAtlasRegion_create(__VA_ARGS__) -#define AtlasRegion_dispose(...) spAtlasRegion_dispose(__VA_ARGS__) -#endif - -/**/ - -struct spAtlas { - spAtlasPage* pages; - spAtlasRegion* regions; - - void* rendererObject; -}; - -/* Image files referenced in the atlas file will be prefixed with dir. */ -spAtlas* spAtlas_create (const char* data, int length, const char* dir, void* rendererObject); -/* Image files referenced in the atlas file will be prefixed with the directory containing the atlas file. */ -spAtlas* spAtlas_createFromFile (const char* path, void* rendererObject); -void spAtlas_dispose (spAtlas* atlas); - -/* Returns 0 if the region was not found. */ -spAtlasRegion* spAtlas_findRegion (const spAtlas* self, const char* name); - -#ifdef SPINE_SHORT_NAMES -typedef spAtlas Atlas; -#define Atlas_create(...) spAtlas_create(__VA_ARGS__) -#define Atlas_createFromFile(...) spAtlas_createFromFile(__VA_ARGS__) -#define Atlas_dispose(...) spAtlas_dispose(__VA_ARGS__) -#define Atlas_findRegion(...) spAtlas_findRegion(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_ATLAS_H_ */ diff --git a/native/cocos/editor-support/spine/AtlasAttachmentLoader.c b/native/cocos/editor-support/spine/AtlasAttachmentLoader.c deleted file mode 100644 index ec5d2d7339..0000000000 --- a/native/cocos/editor-support/spine/AtlasAttachmentLoader.c +++ /dev/null @@ -1,96 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -spAttachment* _spAtlasAttachmentLoader_createAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type, - const char* name, const char* path) { - spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader); - switch (type) { - case SP_ATTACHMENT_REGION: { - spRegionAttachment* attachment; - spAtlasRegion* region = spAtlas_findRegion(self->atlas, path); - if (!region) { - _spAttachmentLoader_setError(loader, "Region not found: ", path); - return 0; - } - attachment = spRegionAttachment_create(name); - attachment->rendererObject = region; - spRegionAttachment_setUVs(attachment, region->u, region->v, region->u2, region->v2, region->rotate); - attachment->regionOffsetX = region->offsetX; - attachment->regionOffsetY = region->offsetY; - attachment->regionWidth = region->width; - attachment->regionHeight = region->height; - attachment->regionOriginalWidth = region->originalWidth; - attachment->regionOriginalHeight = region->originalHeight; - return SUPER(attachment); - } - case SP_ATTACHMENT_MESH: - case SP_ATTACHMENT_LINKED_MESH: { - spMeshAttachment* attachment; - spAtlasRegion* region = spAtlas_findRegion(self->atlas, path); - if (!region) { - _spAttachmentLoader_setError(loader, "Region not found: ", path); - return 0; - } - attachment = spMeshAttachment_create(name); - attachment->rendererObject = region; - attachment->regionU = region->u; - attachment->regionV = region->v; - attachment->regionU2 = region->u2; - attachment->regionV2 = region->v2; - attachment->regionRotate = region->rotate; - attachment->regionOffsetX = region->offsetX; - attachment->regionOffsetY = region->offsetY; - attachment->regionWidth = region->width; - attachment->regionHeight = region->height; - attachment->regionOriginalWidth = region->originalWidth; - attachment->regionOriginalHeight = region->originalHeight; - return SUPER(SUPER(attachment)); - } - case SP_ATTACHMENT_BOUNDING_BOX: - return SUPER(SUPER(spBoundingBoxAttachment_create(name))); - case SP_ATTACHMENT_PATH: - return SUPER(SUPER(spPathAttachment_create(name))); - default: - _spAttachmentLoader_setUnknownTypeError(loader, type); - return 0; - } - - UNUSED(skin); -} - -spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas) { - spAtlasAttachmentLoader* self = NEW(spAtlasAttachmentLoader); - _spAttachmentLoader_init(SUPER(self), _spAttachmentLoader_deinit, _spAtlasAttachmentLoader_createAttachment, 0, 0); - self->atlas = atlas; - return self; -} diff --git a/native/cocos/editor-support/spine/AtlasAttachmentLoader.h b/native/cocos/editor-support/spine/AtlasAttachmentLoader.h deleted file mode 100644 index 3ea864e13b..0000000000 --- a/native/cocos/editor-support/spine/AtlasAttachmentLoader.h +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_ATLASATTACHMENTLOADER_H_ -#define SPINE_ATLASATTACHMENTLOADER_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spAtlasAttachmentLoader { - spAttachmentLoader super; - spAtlas* atlas; -} spAtlasAttachmentLoader; - -spAtlasAttachmentLoader* spAtlasAttachmentLoader_create (spAtlas* atlas); - -#ifdef SPINE_SHORT_NAMES -typedef spAtlasAttachmentLoader AtlasAttachmentLoader; -#define AtlasAttachmentLoader_create(...) spAtlasAttachmentLoader_create(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_ATLASATTACHMENTLOADER_H_ */ diff --git a/native/cocos/editor-support/spine/Attachment.c b/native/cocos/editor-support/spine/Attachment.c deleted file mode 100644 index 3dad43a69b..0000000000 --- a/native/cocos/editor-support/spine/Attachment.c +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include - -typedef struct _spAttachmentVtable { - void (*dispose) (spAttachment* self); -} _spAttachmentVtable; - -void _spAttachment_init (spAttachment* self, const char* name, spAttachmentType type, /**/ - void (*dispose) (spAttachment* self)) { - - CONST_CAST(_spAttachmentVtable*, self->vtable) = NEW(_spAttachmentVtable); - VTABLE(spAttachment, self) ->dispose = dispose; - - MALLOC_STR(self->name, name); - CONST_CAST(spAttachmentType, self->type) = type; -} - -void _spAttachment_deinit (spAttachment* self) { - if (self->attachmentLoader) spAttachmentLoader_disposeAttachment(self->attachmentLoader, self); - FREE(self->vtable); - FREE(self->name); -} - -void spAttachment_dispose (spAttachment* self) { - VTABLE(spAttachment, self) ->dispose(self); -} diff --git a/native/cocos/editor-support/spine/Attachment.h b/native/cocos/editor-support/spine/Attachment.h deleted file mode 100644 index b78425d921..0000000000 --- a/native/cocos/editor-support/spine/Attachment.h +++ /dev/null @@ -1,79 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_ATTACHMENT_H_ -#define SPINE_ATTACHMENT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -struct spAttachmentLoader; - -typedef enum { - SP_ATTACHMENT_REGION, - SP_ATTACHMENT_BOUNDING_BOX, - SP_ATTACHMENT_MESH, - SP_ATTACHMENT_LINKED_MESH, - SP_ATTACHMENT_PATH -} spAttachmentType; - -typedef struct spAttachment { - const char* const name; - const spAttachmentType type; - const void* const vtable; - struct spAttachmentLoader* attachmentLoader; - -#ifdef __cplusplus - spAttachment() : - name(0), - type(SP_ATTACHMENT_REGION), - vtable(0) { - } -#endif -} spAttachment; - -void spAttachment_dispose (spAttachment* self); - -#ifdef SPINE_SHORT_NAMES -typedef spAttachmentType AttachmentType; -#define ATTACHMENT_REGION SP_ATTACHMENT_REGION -#define ATTACHMENT_BOUNDING_BOX SP_ATTACHMENT_BOUNDING_BOX -#define ATTACHMENT_MESH SP_ATTACHMENT_MESH -#define ATTACHMENT_LINKED_MESH SP_ATTACHMENT_LINKED_MESH -typedef spAttachment Attachment; -#define Attachment_dispose(...) spAttachment_dispose(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_ATTACHMENT_H_ */ diff --git a/native/cocos/editor-support/spine/AttachmentLoader.c b/native/cocos/editor-support/spine/AttachmentLoader.c deleted file mode 100644 index 14cbd92ab6..0000000000 --- a/native/cocos/editor-support/spine/AttachmentLoader.c +++ /dev/null @@ -1,98 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include - -typedef struct _spAttachmentLoaderVtable { - spAttachment* (*createAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, - const char* path); - void (*configureAttachment) (spAttachmentLoader* self, spAttachment*); - void (*disposeAttachment) (spAttachmentLoader* self, spAttachment*); - void (*dispose) (spAttachmentLoader* self); -} _spAttachmentLoaderVtable; - -void _spAttachmentLoader_init (spAttachmentLoader* self, - void (*dispose) (spAttachmentLoader* self), - spAttachment* (*createAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, - const char* path), - void (*configureAttachment) (spAttachmentLoader* self, spAttachment*), - void (*disposeAttachment) (spAttachmentLoader* self, spAttachment*) -) { - CONST_CAST(_spAttachmentLoaderVtable*, self->vtable) = NEW(_spAttachmentLoaderVtable); - VTABLE(spAttachmentLoader, self)->dispose = dispose; - VTABLE(spAttachmentLoader, self)->createAttachment = createAttachment; - VTABLE(spAttachmentLoader, self)->configureAttachment = configureAttachment; - VTABLE(spAttachmentLoader, self)->disposeAttachment = disposeAttachment; -} - -void _spAttachmentLoader_deinit (spAttachmentLoader* self) { - FREE(self->vtable); - FREE(self->error1); - FREE(self->error2); -} - -void spAttachmentLoader_dispose (spAttachmentLoader* self) { - VTABLE(spAttachmentLoader, self)->dispose(self); - FREE(self); -} - -spAttachment* spAttachmentLoader_createAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, - const char* path) { - FREE(self->error1); - FREE(self->error2); - self->error1 = 0; - self->error2 = 0; - return VTABLE(spAttachmentLoader, self)->createAttachment(self, skin, type, name, path); -} - -void spAttachmentLoader_configureAttachment (spAttachmentLoader* self, spAttachment* attachment) { - if (!VTABLE(spAttachmentLoader, self)->configureAttachment) return; - VTABLE(spAttachmentLoader, self)->configureAttachment(self, attachment); -} - -void spAttachmentLoader_disposeAttachment (spAttachmentLoader* self, spAttachment* attachment) { - if (!VTABLE(spAttachmentLoader, self)->disposeAttachment) return; - VTABLE(spAttachmentLoader, self)->disposeAttachment(self, attachment); -} - -void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2) { - FREE(self->error1); - FREE(self->error2); - MALLOC_STR(self->error1, error1); - MALLOC_STR(self->error2, error2); -} - -void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type) { - char buffer[16]; - sprintf(buffer, "%d", type); - _spAttachmentLoader_setError(self, "Unknown attachment type: ", buffer); -} diff --git a/native/cocos/editor-support/spine/AttachmentLoader.h b/native/cocos/editor-support/spine/AttachmentLoader.h deleted file mode 100644 index 7111c45a08..0000000000 --- a/native/cocos/editor-support/spine/AttachmentLoader.h +++ /dev/null @@ -1,78 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_ATTACHMENTLOADER_H_ -#define SPINE_ATTACHMENTLOADER_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spAttachmentLoader { - const char* error1; - const char* error2; - - const void* const vtable; -#ifdef __cplusplus - spAttachmentLoader () : - error1(0), - error2(0), - vtable(0) { - } -#endif -} spAttachmentLoader; - -void spAttachmentLoader_dispose (spAttachmentLoader* self); - -/* Called to create each attachment. Returns 0 to not load an attachment. If 0 is returned and _spAttachmentLoader_setError was - * called, an error occurred. */ -spAttachment* spAttachmentLoader_createAttachment (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, - const char* path); -/* Called after the attachment has been fully configured. */ -void spAttachmentLoader_configureAttachment (spAttachmentLoader* self, spAttachment* attachment); -/* Called just before the attachment is disposed. This can release allocations made in spAttachmentLoader_configureAttachment. */ -void spAttachmentLoader_disposeAttachment (spAttachmentLoader* self, spAttachment* attachment); - -#ifdef SPINE_SHORT_NAMES -typedef spAttachmentLoader AttachmentLoader; -#define AttachmentLoader_dispose(...) spAttachmentLoader_dispose(__VA_ARGS__) -#define AttachmentLoader_createAttachment(...) spAttachmentLoader_createAttachment(__VA_ARGS__) -#define AttachmentLoader_configureAttachment(...) spAttachmentLoader_configureAttachment(__VA_ARGS__) -#define AttachmentLoader_disposeAttachment(...) spAttachmentLoader_disposeAttachment(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_ATTACHMENTLOADER_H_ */ diff --git a/native/cocos/editor-support/spine/AttachmentVertices.cpp b/native/cocos/editor-support/spine/AttachmentVertices.cpp deleted file mode 100644 index 7de8814e3c..0000000000 --- a/native/cocos/editor-support/spine/AttachmentVertices.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include - -USING_NS_CC; - -namespace spine { - -AttachmentVertices::AttachmentVertices (Texture2D* texture, int verticesCount, unsigned short* triangles, int trianglesCount) { - _texture = texture; - - _triangles = new TrianglesCommand::Triangles(); - _triangles->verts = new V3F_C4B_T2F[verticesCount]; - _triangles->vertCount = verticesCount; - _triangles->indices = triangles; - _triangles->indexCount = trianglesCount; -} - -AttachmentVertices::~AttachmentVertices () { - delete [] _triangles->verts; - delete _triangles; -} - -} diff --git a/native/cocos/editor-support/spine/AttachmentVertices.h b/native/cocos/editor-support/spine/AttachmentVertices.h deleted file mode 100644 index 8ae54ef038..0000000000 --- a/native/cocos/editor-support/spine/AttachmentVertices.h +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_ATTACHMENTVERTICES_H_ -#define SPINE_ATTACHMENTVERTICES_H_ - -#include "cocos2d.h" - -namespace spine { - -class AttachmentVertices { -public: - AttachmentVertices (cocos2d::Texture2D* texture, int verticesCount, unsigned short* triangles, int trianglesCount); - virtual ~AttachmentVertices (); - - cocos2d::Texture2D* _texture; - cocos2d::TrianglesCommand::Triangles* _triangles; -}; - -} - -#endif /* SPINE_ATTACHMENTVERTICES_H_ */ diff --git a/native/cocos/editor-support/spine/Bone.c b/native/cocos/editor-support/spine/Bone.c deleted file mode 100644 index aa5841894a..0000000000 --- a/native/cocos/editor-support/spine/Bone.c +++ /dev/null @@ -1,301 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include -static int yDown; - -void spBone_setYDown (int value) { - yDown = value; -} - -int spBone_isYDown () { - return yDown; -} - -spBone* spBone_create (spBoneData* data, spSkeleton* skeleton, spBone* parent) { - spBone* self = NEW(spBone); - CONST_CAST(spBoneData*, self->data) = data; - CONST_CAST(spSkeleton*, self->skeleton) = skeleton; - CONST_CAST(spBone*, self->parent) = parent; - spBone_setToSetupPose(self); - return self; -} - -void spBone_dispose (spBone* self) { - FREE(self->children); - FREE(self); -} - -void spBone_updateWorldTransform (spBone* self) { - spBone_updateWorldTransformWith(self, self->x, self->y, self->rotation, self->scaleX, self->scaleY, self->shearX, self->shearY); -} - -void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY) { - float cosine, sine; - float pa, pb, pc, pd; - spBone* parent = self->parent; - - self->ax = x; - self->ay = y; - self->arotation = rotation; - self->ascaleX = scaleX; - self->ascaleY = scaleY; - self->ashearX = shearX; - self->ashearY = shearY; - self->appliedValid = 1; - - if (!parent) { /* Root bone. */ - float rotationY = rotation + 90 + shearY; - float la = COS_DEG(rotation + shearX) * scaleX; - float lb = COS_DEG(rotationY) * scaleY; - float lc = SIN_DEG(rotation + shearX) * scaleX; - float ld = SIN_DEG(rotationY) * scaleY; - if (self->skeleton->flipX) { - x = -x; - la = -la; - lb = -lb; - } - if (self->skeleton->flipY != yDown) { - y = -y; - lc = -lc; - ld = -ld; - } - CONST_CAST(float, self->a) = la; - CONST_CAST(float, self->b) = lb; - CONST_CAST(float, self->c) = lc; - CONST_CAST(float, self->d) = ld; - CONST_CAST(float, self->worldX) = x + self->skeleton->x; - CONST_CAST(float, self->worldY) = y + self->skeleton->y; - return; - } - - pa = parent->a; - pb = parent->b; - pc = parent->c; - pd = parent->d; - - CONST_CAST(float, self->worldX) = pa * x + pb * y + parent->worldX; - CONST_CAST(float, self->worldY) = pc * x + pd * y + parent->worldY; - - switch (self->data->transformMode) { - case SP_TRANSFORMMODE_NORMAL: { - float rotationY = rotation + 90 + shearY; - float la = COS_DEG(rotation + shearX) * scaleX; - float lb = COS_DEG(rotationY) * scaleY; - float lc = SIN_DEG(rotation + shearX) * scaleX; - float ld = SIN_DEG(rotationY) * scaleY; - CONST_CAST(float, self->a) = pa * la + pb * lc; - CONST_CAST(float, self->b) = pa * lb + pb * ld; - CONST_CAST(float, self->c) = pc * la + pd * lc; - CONST_CAST(float, self->d) = pc * lb + pd * ld; - return; - } - case SP_TRANSFORMMODE_ONLYTRANSLATION: { - float rotationY = rotation + 90 + shearY; - CONST_CAST(float, self->a) = COS_DEG(rotation + shearX) * scaleX; - CONST_CAST(float, self->b) = COS_DEG(rotationY) * scaleY; - CONST_CAST(float, self->c) = SIN_DEG(rotation + shearX) * scaleX; - CONST_CAST(float, self->d) = SIN_DEG(rotationY) * scaleY; - break; - } - case SP_TRANSFORMMODE_NOROTATIONORREFLECTION: { - float s = pa * pa + pc * pc; - float prx, rx, ry, la, lb, lc, ld; - if (s > 0.0001f) { - s = ABS(pa * pd - pb * pc) / s; - pb = pc * s; - pd = pa * s; - prx = ATAN2(pc, pa) * RAD_DEG; - } else { - pa = 0; - pc = 0; - prx = 90 - ATAN2(pd, pb) * RAD_DEG; - } - rx = rotation + shearX - prx; - ry = rotation + shearY - prx + 90; - la = COS_DEG(rx) * scaleX; - lb = COS_DEG(ry) * scaleY; - lc = SIN_DEG(rx) * scaleX; - ld = SIN_DEG(ry) * scaleY; - CONST_CAST(float, self->a) = pa * la - pb * lc; - CONST_CAST(float, self->b) = pa * lb - pb * ld; - CONST_CAST(float, self->c) = pc * la + pd * lc; - CONST_CAST(float, self->d) = pc * lb + pd * ld; - break; - } - case SP_TRANSFORMMODE_NOSCALE: - case SP_TRANSFORMMODE_NOSCALEORREFLECTION: { - float za, zc, s; - float r, zb, zd, la, lb, lc, ld; - cosine = COS_DEG(rotation); sine = SIN_DEG(rotation); - za = pa * cosine + pb * sine; - zc = pc * cosine + pd * sine; - s = SQRT(za * za + zc * zc); - if (s > 0.00001f) s = 1 / s; - za *= s; - zc *= s; - s = SQRT(za * za + zc * zc); - r = PI / 2 + atan2(zc, za); - zb = COS(r) * s; - zd = SIN(r) * s; - la = COS_DEG(shearX) * scaleX; - lb = COS_DEG(90 + shearY) * scaleY; - lc = SIN_DEG(shearX) * scaleX; - ld = SIN_DEG(90 + shearY) * scaleY; - CONST_CAST(float, self->a) = za * la + zb * lc; - CONST_CAST(float, self->b) = za * lb + zb * ld; - CONST_CAST(float, self->c) = zc * la + zd * lc; - CONST_CAST(float, self->d) = zc * lb + zd * ld; - if (self->data->transformMode != SP_TRANSFORMMODE_NOSCALEORREFLECTION ? pa * pd - pb * pc < 0 : self->skeleton->flipX != self->skeleton->flipY) { - CONST_CAST(float, self->b) = -self->b; - CONST_CAST(float, self->d) = -self->d; - } - return; - } - } - if (self->skeleton->flipX) { - CONST_CAST(float, self->a) = -self->a; - CONST_CAST(float, self->b) = -self->b; - } - if (self->skeleton->flipY != yDown) { - CONST_CAST(float, self->c) = -self->c; - CONST_CAST(float, self->d) = -self->d; - } -} - -void spBone_setToSetupPose (spBone* self) { - self->x = self->data->x; - self->y = self->data->y; - self->rotation = self->data->rotation; - self->scaleX = self->data->scaleX; - self->scaleY = self->data->scaleY; - self->shearX = self->data->shearX; - self->shearY = self->data->shearY; -} - -float spBone_getWorldRotationX (spBone* self) { - return ATAN2(self->c, self->a) * RAD_DEG; -} - -float spBone_getWorldRotationY (spBone* self) { - return ATAN2(self->d, self->b) * RAD_DEG; -} - -float spBone_getWorldScaleX (spBone* self) { - return SQRT(self->a * self->a + self->c * self->c); -} - -float spBone_getWorldScaleY (spBone* self) { - return SQRT(self->b * self->b + self->d * self->d); -} - -float spBone_worldToLocalRotationX (spBone* self) { - spBone* parent = self->parent; - if (!parent) return self->arotation; - return ATAN2(parent->a * self->c - parent->c * self->a, parent->d * self->a - parent->b * self->c) * RAD_DEG; -} - -float spBone_worldToLocalRotationY (spBone* self) { - spBone* parent = self->parent; - if (!parent) return self->arotation; - return ATAN2(parent->a * self->d - parent->c * self->b, parent->d * self->b - parent->b * self->d) * RAD_DEG; -} - -void spBone_rotateWorld (spBone* self, float degrees) { - float a = self->a, b = self->b, c = self->c, d = self->d; - float cosine = COS_DEG(degrees), sine = SIN_DEG(degrees); - CONST_CAST(float, self->a) = cosine * a - sine * c; - CONST_CAST(float, self->b) = cosine * b - sine * d; - CONST_CAST(float, self->c) = sine * a + cosine * c; - CONST_CAST(float, self->d) = sine * b + cosine * d; - CONST_CAST(int, self->appliedValid) = 1; -} - - -/** Computes the individual applied transform values from the world transform. This can be useful to perform processing using - * the applied transform after the world transform has been modified directly (eg, by a constraint). - *

- * Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. */ -void spBone_updateAppliedTransform (spBone* self) { - spBone* parent = self->parent; - self->appliedValid = 1; - if (!parent) { - self->ax = self->worldX; - self->ay = self->worldY; - self->arotation = ATAN2(self->c, self->a) * RAD_DEG; - self->ascaleX = SQRT(self->a * self->a + self->c * self->c); - self->ascaleY = SQRT(self->b * self->b + self->d * self->d); - self->ashearX = 0; - self->ashearY = ATAN2(self->a * self->b + self->c * self->d, self->a * self->d - self->b * self->c) * RAD_DEG; - } else { - float pa = parent->a, pb = parent->b, pc = parent->c, pd = parent->d; - float pid = 1 / (pa * pd - pb * pc); - float dx = self->worldX - parent->worldX, dy = self->worldY - parent->worldY; - float ia = pid * pd; - float id = pid * pa; - float ib = pid * pb; - float ic = pid * pc; - float ra = ia * self->a - ib * self->c; - float rb = ia * self->b - ib * self->d; - float rc = id * self->c - ic * self->a; - float rd = id * self->d - ic * self->b; - self->ax = (dx * pd * pid - dy * pb * pid); - self->ay = (dy * pa * pid - dx * pc * pid); - self->ashearX = 0; - self->ascaleX = SQRT(ra * ra + rc * rc); - if (self->ascaleX > 0.0001f) { - float det = ra * rd - rb * rc; - self->ascaleY = det / self->ascaleX; - self->ashearY = ATAN2(ra * rb + rc * rd, det) * RAD_DEG; - self->arotation = ATAN2(rc, ra) * RAD_DEG; - } else { - self->ascaleX = 0; - self->ascaleY = SQRT(rb * rb + rd * rd); - self->ashearY = 0; - self->arotation = 90 - ATAN2(rd, rb) * RAD_DEG; - } - } -} - -void spBone_worldToLocal (spBone* self, float worldX, float worldY, float* localX, float* localY) { - float a = self->a, b = self->b, c = self->c, d = self->d; - float invDet = 1 / (a * d - b * c); - float x = worldX - self->worldX, y = worldY - self->worldY; - *localX = (x * d * invDet - y * b * invDet); - *localY = (y * a * invDet - x * c * invDet); -} - -void spBone_localToWorld (spBone* self, float localX, float localY, float* worldX, float* worldY) { - float x = localX, y = localY; - *worldX = x * self->a + y * self->b + self->worldX; - *worldY = x * self->c + y * self->d + self->worldY; -} diff --git a/native/cocos/editor-support/spine/Bone.h b/native/cocos/editor-support/spine/Bone.h deleted file mode 100644 index 4ecf9d24ca..0000000000 --- a/native/cocos/editor-support/spine/Bone.h +++ /dev/null @@ -1,126 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_BONE_H_ -#define SPINE_BONE_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct spSkeleton; - -typedef struct spBone spBone; -struct spBone { - spBoneData* const data; - struct spSkeleton* const skeleton; - spBone* const parent; - int childrenCount; - spBone** const children; - float x, y, rotation, scaleX, scaleY, shearX, shearY; - float ax, ay, arotation, ascaleX, ascaleY, ashearX, ashearY; - int /*bool*/ appliedValid; - - float const a, b, worldX; - float const c, d, worldY; - - int/*bool*/ sorted; - -#ifdef __cplusplus - spBone() : - data(0), - skeleton(0), - parent(0), - childrenCount(0), children(0), - x(0), y(0), rotation(0), scaleX(0), scaleY(0), - ax(0), ay(0), arotation(0), ascaleX(0), ascaleY(0), ashearX(0), ashearY(0), - appliedValid(0), - - a(0), b(0), worldX(0), - c(0), d(0), worldY(0), - - sorted(0) { - } -#endif -}; - -void spBone_setYDown (int/*bool*/yDown); -int/*bool*/spBone_isYDown (); - -/* @param parent May be 0. */ -spBone* spBone_create (spBoneData* data, struct spSkeleton* skeleton, spBone* parent); -void spBone_dispose (spBone* self); - -void spBone_setToSetupPose (spBone* self); - -void spBone_updateWorldTransform (spBone* self); -void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY); - -float spBone_getWorldRotationX (spBone* self); -float spBone_getWorldRotationY (spBone* self); -float spBone_getWorldScaleX (spBone* self); -float spBone_getWorldScaleY (spBone* self); - -float spBone_worldToLocalRotationX (spBone* self); -float spBone_worldToLocalRotationY (spBone* self); -void spBone_rotateWorld (spBone* self, float degrees); -void spBone_updateAppliedTransform (spBone* self); - -void spBone_worldToLocal (spBone* self, float worldX, float worldY, float* localX, float* localY); -void spBone_localToWorld (spBone* self, float localX, float localY, float* worldX, float* worldY); - -#ifdef SPINE_SHORT_NAMES -typedef spBone Bone; -#define Bone_setYDown(...) spBone_setYDown(__VA_ARGS__) -#define Bone_isYDown() spBone_isYDown() -#define Bone_create(...) spBone_create(__VA_ARGS__) -#define Bone_dispose(...) spBone_dispose(__VA_ARGS__) -#define Bone_setToSetupPose(...) spBone_setToSetupPose(__VA_ARGS__) -#define Bone_updateWorldTransform(...) spBone_updateWorldTransform(__VA_ARGS__) -#define Bone_updateWorldTransformWith(...) spBone_updateWorldTransformWith(__VA_ARGS__) -#define Bone_getWorldRotationX(...) spBone_getWorldRotationX(__VA_ARGS__) -#define Bone_getWorldRotationY(...) spBone_getWorldRotationY(__VA_ARGS__) -#define Bone_getWorldScaleX(...) spBone_getWorldScaleX(__VA_ARGS__) -#define Bone_getWorldScaleY(...) spBone_getWorldScaleY(__VA_ARGS__) -#define Bone_worldToLocalRotationX(...) spBone_worldToLocalRotationX(__VA_ARGS__) -#define Bone_worldToLocalRotationY(...) spBone_worldToLocalRotationY(__VA_ARGS__) -#define Bone_rotateWorld(...) spBone_rotateWorld(__VA_ARGS__) -#define Bone_updateAppliedTransform(...) spBone_updateAppliedTransform(__VA_ARGS__) -#define Bone_worldToLocal(...) spBone_worldToLocal(__VA_ARGS__) -#define Bone_localToWorld(...) spBone_localToWorld(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_BONE_H_ */ diff --git a/native/cocos/editor-support/spine/BoneData.c b/native/cocos/editor-support/spine/BoneData.c deleted file mode 100644 index 5933571ed6..0000000000 --- a/native/cocos/editor-support/spine/BoneData.c +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -spBoneData* spBoneData_create (int index, const char* name, spBoneData* parent) { - spBoneData* self = NEW(spBoneData); - CONST_CAST(int, self->index) = index; - MALLOC_STR(self->name, name); - CONST_CAST(spBoneData*, self->parent) = parent; - self->scaleX = 1; - self->scaleY = 1; - self->transformMode = SP_TRANSFORMMODE_NORMAL; - return self; -} - -void spBoneData_dispose (spBoneData* self) { - FREE(self->name); - FREE(self); -} diff --git a/native/cocos/editor-support/spine/BoneData.h b/native/cocos/editor-support/spine/BoneData.h deleted file mode 100644 index 244a50e0d9..0000000000 --- a/native/cocos/editor-support/spine/BoneData.h +++ /dev/null @@ -1,83 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_BONEDATA_H_ -#define SPINE_BONEDATA_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - SP_TRANSFORMMODE_NORMAL, - SP_TRANSFORMMODE_ONLYTRANSLATION, - SP_TRANSFORMMODE_NOROTATIONORREFLECTION, - SP_TRANSFORMMODE_NOSCALE, - SP_TRANSFORMMODE_NOSCALEORREFLECTION -} spTransformMode; - -typedef struct spBoneData spBoneData; -struct spBoneData { - const int index; - const char* const name; - spBoneData* const parent; - float length; - float x, y, rotation, scaleX, scaleY, shearX, shearY; - spTransformMode transformMode; - -#ifdef __cplusplus - spBoneData() : - index(0), - name(0), - parent(0), - length(0), - x(0), y(0), - rotation(0), - scaleX(0), scaleY(0), - shearX(0), shearY(0), - transformMode(SP_TRANSFORMMODE_NORMAL) { - } -#endif -}; - -spBoneData* spBoneData_create (int index, const char* name, spBoneData* parent); -void spBoneData_dispose (spBoneData* self); - -#ifdef SPINE_SHORT_NAMES -typedef spBoneData BoneData; -#define BoneData_create(...) spBoneData_create(__VA_ARGS__) -#define BoneData_dispose(...) spBoneData_dispose(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_BONEDATA_H_ */ diff --git a/native/cocos/editor-support/spine/BoundingBoxAttachment.c b/native/cocos/editor-support/spine/BoundingBoxAttachment.c deleted file mode 100644 index 9b212288cc..0000000000 --- a/native/cocos/editor-support/spine/BoundingBoxAttachment.c +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -void _spBoundingBoxAttachment_dispose (spAttachment* attachment) { - spBoundingBoxAttachment* self = SUB_CAST(spBoundingBoxAttachment, attachment); - - _spVertexAttachment_deinit(SUPER(self)); - - FREE(self); -} - -spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name) { - spBoundingBoxAttachment* self = NEW(spBoundingBoxAttachment); - _spAttachment_init(SUPER(SUPER(self)), name, SP_ATTACHMENT_BOUNDING_BOX, _spBoundingBoxAttachment_dispose); - return self; -} - -void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, spSlot* slot, float* worldVertices) { - spVertexAttachment_computeWorldVertices(SUPER(self), slot, worldVertices); -} diff --git a/native/cocos/editor-support/spine/BoundingBoxAttachment.h b/native/cocos/editor-support/spine/BoundingBoxAttachment.h deleted file mode 100644 index 44959e9cef..0000000000 --- a/native/cocos/editor-support/spine/BoundingBoxAttachment.h +++ /dev/null @@ -1,60 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_BOUNDINGBOXATTACHMENT_H_ -#define SPINE_BOUNDINGBOXATTACHMENT_H_ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spBoundingBoxAttachment { - spVertexAttachment super; -} spBoundingBoxAttachment; - -spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name); -void spBoundingBoxAttachment_computeWorldVertices (spBoundingBoxAttachment* self, spSlot* slot, float* worldVertices); - -#ifdef SPINE_SHORT_NAMES -typedef spBoundingBoxAttachment BoundingBoxAttachment; -#define BoundingBoxAttachment_create(...) spBoundingBoxAttachment_create(__VA_ARGS__) -#define BoundingBoxAttachment_computeWorldVertices(...) spBoundingBoxAttachment_computeWorldVertices(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_BOUNDINGBOXATTACHMENT_H_ */ diff --git a/native/cocos/editor-support/spine/CMakeLists.txt b/native/cocos/editor-support/spine/CMakeLists.txt deleted file mode 100644 index d3a7030966..0000000000 --- a/native/cocos/editor-support/spine/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ - -set(COCOS_SPINE_SRC - editor-support/spine/Animation.c - editor-support/spine/AnimationState.c - editor-support/spine/AnimationStateData.c - editor-support/spine/Atlas.c - editor-support/spine/AtlasAttachmentLoader.c - editor-support/spine/Attachment.c - editor-support/spine/AttachmentLoader.c - editor-support/spine/AttachmentVertices.cpp - editor-support/spine/Bone.c - editor-support/spine/BoneData.c - editor-support/spine/BoundingBoxAttachment.c - editor-support/spine/Cocos2dAttachmentLoader.cpp - editor-support/spine/Event.c - editor-support/spine/EventData.c - editor-support/spine/IkConstraint.c - editor-support/spine/IkConstraintData.c - editor-support/spine/Json.c - editor-support/spine/MeshAttachment.c - editor-support/spine/PathAttachment.c - editor-support/spine/PathConstraint.c - editor-support/spine/PathConstraintData.c - editor-support/spine/RegionAttachment.c - editor-support/spine/Skeleton.c - editor-support/spine/SkeletonAnimation.cpp - editor-support/spine/SkeletonBatch.cpp - editor-support/spine/SkeletonBounds.c - editor-support/spine/SkeletonData.c - editor-support/spine/SkeletonJson.c - editor-support/spine/SkeletonRenderer.cpp - editor-support/spine/Skin.c - editor-support/spine/Slot.c - editor-support/spine/SlotData.c - editor-support/spine/TransformConstraint.c - editor-support/spine/TransformConstraintData.c - editor-support/spine/VertexAttachment.c - editor-support/spine/extension.c - editor-support/spine/spine-cocos2dx.cpp -) - -include_directories( editor-support ) diff --git a/native/cocos/editor-support/spine/Cocos2dAttachmentLoader.cpp b/native/cocos/editor-support/spine/Cocos2dAttachmentLoader.cpp deleted file mode 100644 index 48df257eed..0000000000 --- a/native/cocos/editor-support/spine/Cocos2dAttachmentLoader.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include - -USING_NS_CC; -using namespace spine; - -static unsigned short quadTriangles[6] = {0, 1, 2, 2, 3, 0}; - -spAttachment* _Cocos2dAttachmentLoader_createAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type, - const char* name, const char* path) { - Cocos2dAttachmentLoader* self = SUB_CAST(Cocos2dAttachmentLoader, loader); - return spAttachmentLoader_createAttachment(SUPER(self->atlasAttachmentLoader), skin, type, name, path); -} - -void _Cocos2dAttachmentLoader_configureAttachment (spAttachmentLoader* loader, spAttachment* attachment) { - attachment->attachmentLoader = loader; - - switch (attachment->type) { - case SP_ATTACHMENT_REGION: { - spRegionAttachment* regionAttachment = SUB_CAST(spRegionAttachment, attachment); - spAtlasRegion* region = (spAtlasRegion*)regionAttachment->rendererObject; - AttachmentVertices* attachmentVertices = new AttachmentVertices((Texture2D*)region->page->rendererObject, 4, quadTriangles, 6); - V3F_C4B_T2F* vertices = attachmentVertices->_triangles->verts; - for (int i = 0, ii = 0; i < 4; ++i, ii += 2) { - vertices[i].texCoords.u = regionAttachment->uvs[ii]; - vertices[i].texCoords.v = regionAttachment->uvs[ii + 1]; - } - regionAttachment->rendererObject = attachmentVertices; - break; - } - case SP_ATTACHMENT_MESH: { - spMeshAttachment* meshAttachment = SUB_CAST(spMeshAttachment, attachment); - spAtlasRegion* region = (spAtlasRegion*)meshAttachment->rendererObject; - AttachmentVertices* attachmentVertices = new AttachmentVertices((Texture2D*)region->page->rendererObject, - meshAttachment->super.worldVerticesLength >> 1, meshAttachment->triangles, meshAttachment->trianglesCount); - V3F_C4B_T2F* vertices = attachmentVertices->_triangles->verts; - for (int i = 0, ii = 0, nn = meshAttachment->super.worldVerticesLength; ii < nn; ++i, ii += 2) { - vertices[i].texCoords.u = meshAttachment->uvs[ii]; - vertices[i].texCoords.v = meshAttachment->uvs[ii + 1]; - } - meshAttachment->rendererObject = attachmentVertices; - break; - } - default: ; - } -} - -void _Cocos2dAttachmentLoader_disposeAttachment (spAttachmentLoader* loader, spAttachment* attachment) { - switch (attachment->type) { - case SP_ATTACHMENT_REGION: { - spRegionAttachment* regionAttachment = SUB_CAST(spRegionAttachment, attachment); - delete (AttachmentVertices*)regionAttachment->rendererObject; - break; - } - case SP_ATTACHMENT_MESH: { - spMeshAttachment* meshAttachment = SUB_CAST(spMeshAttachment, attachment); - delete (AttachmentVertices*)meshAttachment->rendererObject; - break; - } - default: ; - } -} - -void _Cocos2dAttachmentLoader_dispose (spAttachmentLoader* loader) { - Cocos2dAttachmentLoader* self = SUB_CAST(Cocos2dAttachmentLoader, loader); - spAttachmentLoader_dispose(SUPER_CAST(spAttachmentLoader, self->atlasAttachmentLoader)); - _spAttachmentLoader_deinit(loader); -} - -Cocos2dAttachmentLoader* Cocos2dAttachmentLoader_create (spAtlas* atlas) { - Cocos2dAttachmentLoader* self = NEW(Cocos2dAttachmentLoader); - _spAttachmentLoader_init(SUPER(self), _Cocos2dAttachmentLoader_dispose, _Cocos2dAttachmentLoader_createAttachment, - _Cocos2dAttachmentLoader_configureAttachment, _Cocos2dAttachmentLoader_disposeAttachment); - self->atlasAttachmentLoader = spAtlasAttachmentLoader_create(atlas); - return self; -} diff --git a/native/cocos/editor-support/spine/Cocos2dAttachmentLoader.h b/native/cocos/editor-support/spine/Cocos2dAttachmentLoader.h deleted file mode 100644 index 92454a6a85..0000000000 --- a/native/cocos/editor-support/spine/Cocos2dAttachmentLoader.h +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_COCOS2DATTACHMENTLOADER_H_ -#define SPINE_COCOS2DATTACHMENTLOADER_H_ - -#include - -extern "C" { - -typedef struct Cocos2dAttachmentLoader { - spAttachmentLoader super; - spAtlasAttachmentLoader* atlasAttachmentLoader; -} Cocos2dAttachmentLoader; - -/* The Cocos2dAttachmentLoader must not be disposed until after the skeleton data has been disposed. */ -Cocos2dAttachmentLoader* Cocos2dAttachmentLoader_create (spAtlas* atlas); - -} - -#endif /* SPINE_COCOS2DATTACHMENTLOADER_H_ */ diff --git a/native/cocos/editor-support/spine/Event.c b/native/cocos/editor-support/spine/Event.c deleted file mode 100644 index 7c1435cef2..0000000000 --- a/native/cocos/editor-support/spine/Event.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -spEvent* spEvent_create (float time, spEventData* data) { - spEvent* self = NEW(spEvent); - CONST_CAST(spEventData*, self->data) = data; - CONST_CAST(float, self->time) = time; - return self; -} - -void spEvent_dispose (spEvent* self) { - FREE(self->stringValue); - FREE(self); -} diff --git a/native/cocos/editor-support/spine/Event.h b/native/cocos/editor-support/spine/Event.h deleted file mode 100644 index a943c454f6..0000000000 --- a/native/cocos/editor-support/spine/Event.h +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_EVENT_H_ -#define SPINE_EVENT_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spEvent { - spEventData* const data; - float const time; - int intValue; - float floatValue; - const char* stringValue; - -#ifdef __cplusplus - spEvent() : - data(0), - time(0), - intValue(0), - floatValue(0), - stringValue(0) { - } -#endif -} spEvent; - -spEvent* spEvent_create (float time, spEventData* data); -void spEvent_dispose (spEvent* self); - -#ifdef SPINE_SHORT_NAMES -typedef spEvent Event; -#define Event_create(...) spEvent_create(__VA_ARGS__) -#define Event_dispose(...) spEvent_dispose(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_EVENT_H_ */ diff --git a/native/cocos/editor-support/spine/EventData.c b/native/cocos/editor-support/spine/EventData.c deleted file mode 100644 index 8b0014f785..0000000000 --- a/native/cocos/editor-support/spine/EventData.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -spEventData* spEventData_create (const char* name) { - spEventData* self = NEW(spEventData); - MALLOC_STR(self->name, name); - return self; -} - -void spEventData_dispose (spEventData* self) { - FREE(self->stringValue); - FREE(self->name); - FREE(self); -} diff --git a/native/cocos/editor-support/spine/EventData.h b/native/cocos/editor-support/spine/EventData.h deleted file mode 100644 index 050bee1583..0000000000 --- a/native/cocos/editor-support/spine/EventData.h +++ /dev/null @@ -1,67 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_EVENTDATA_H_ -#define SPINE_EVENTDATA_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spEventData { - const char* const name; - int intValue; - float floatValue; - const char* stringValue; - -#ifdef __cplusplus - spEventData() : - name(0), - intValue(0), - floatValue(0), - stringValue(0) { - } -#endif -} spEventData; - -spEventData* spEventData_create (const char* name); -void spEventData_dispose (spEventData* self); - -#ifdef SPINE_SHORT_NAMES -typedef spEventData EventData; -#define EventData_create(...) spEventData_create(__VA_ARGS__) -#define EventData_dispose(...) spEventData_dispose(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_EVENTDATA_H_ */ diff --git a/native/cocos/editor-support/spine/IkConstraint.c b/native/cocos/editor-support/spine/IkConstraint.c deleted file mode 100644 index 0370709670..0000000000 --- a/native/cocos/editor-support/spine/IkConstraint.c +++ /dev/null @@ -1,216 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include -#include - -spIkConstraint *spIkConstraint_create(spIkConstraintData *data, const spSkeleton *skeleton) { - int i; - - spIkConstraint *self = NEW(spIkConstraint); - CONST_CAST(spIkConstraintData*, self->data) = data; - self->bendDirection = data->bendDirection; - self->mix = data->mix; - - self->bonesCount = self->data->bonesCount; - self->bones = MALLOC(spBone*, self->bonesCount); - for (i = 0; i < self->bonesCount; ++i) - self->bones[i] = spSkeleton_findBone(skeleton, self->data->bones[i]->name); - self->target = spSkeleton_findBone(skeleton, self->data->target->name); - - return self; -} - -void spIkConstraint_dispose(spIkConstraint *self) { - FREE(self->bones); - FREE(self); -} - -void spIkConstraint_apply(spIkConstraint *self) { - switch (self->bonesCount) { - case 1: - spIkConstraint_apply1(self->bones[0], self->target->worldX, self->target->worldY, self->mix); - break; - case 2: - spIkConstraint_apply2(self->bones[0], self->bones[1], self->target->worldX, self->target->worldY, self->bendDirection, self->mix); - break; - } -} - -void spIkConstraint_apply1 (spBone* bone, float targetX, float targetY, float alpha) { - spBone* p = bone->parent; - float id, x, y, tx, ty, rotationIK; - if (!bone->appliedValid) spBone_updateAppliedTransform(bone); - id = 1 / (p->a * p->d - p->b * p->c); - x = targetX - p->worldX, y = targetY - p->worldY; - tx = (x * p->d - y * p->b) * id - bone->ax; ty = (y * p->a - x * p->c) * id - bone->ay; - rotationIK = ATAN2(ty, tx) * RAD_DEG - bone->ashearX - bone->arotation; - if (bone->ascaleX < 0) rotationIK += 180; - if (rotationIK > 180) rotationIK -= 360; - else if (rotationIK < -180) rotationIK += 360; - spBone_updateWorldTransformWith(bone, bone->ax, bone->ay, bone->arotation + rotationIK * alpha, bone->ascaleX, - bone->ascaleY, bone->ashearX, bone->ashearY); -} - -void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float targetY, int bendDir, float alpha) { - float px, py, psx, psy; - float cx, cy, csx, cwx, cwy; - int o1, o2, s2, u; - spBone* pp = parent->parent; - float tx, ty, dx, dy, l1, l2, a1, a2, r; - float id, x, y; - if (alpha == 0) { - spBone_updateWorldTransform(child); - return; - } - if (!parent->appliedValid) spBone_updateAppliedTransform(parent); - if (!child->appliedValid) spBone_updateAppliedTransform(child); - px = parent->ax; py = parent->ay; psx = parent->ascaleX; psy = parent->ascaleY; csx = child->ascaleX; - if (psx < 0) { - psx = -psx; - o1 = 180; - s2 = -1; - } else { - o1 = 0; - s2 = 1; - } - if (psy < 0) { - psy = -psy; - s2 = -s2; - } - if (csx < 0) { - csx = -csx; - o2 = 180; - } else - o2 = 0; - r = psx - psy; - cx = child->ax; - u = (r < 0 ? -r : r) <= 0.0001f; - if (!u) { - cy = 0; - cwx = parent->a * cx + parent->worldX; - cwy = parent->c * cx + parent->worldY; - } else { - cy = child->ay; - cwx = parent->a * cx + parent->b * cy + parent->worldX; - cwy = parent->c * cx + parent->d * cy + parent->worldY; - } - id = 1 / (pp->a * pp->d - pp->b * pp->c); - x = targetX - pp->worldX; - y = targetY - pp->worldY; - tx = (x * pp->d - y * pp->b) * id - px; - ty = (y * pp->a - x * pp->c) * id - py; - x = cwx - pp->worldX; - y = cwy - pp->worldY; - dx = (x * pp->d - y * pp->b) * id - px; - dy = (y * pp->a - x * pp->c) * id - py; - l1 = SQRT(dx * dx + dy * dy); - l2 = child->data->length * csx; - if (u) { - float cosine, a, b; - l2 *= psx; - cosine = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2); - if (cosine < -1) cosine = -1; - else if (cosine > 1) cosine = 1; - a2 = ACOS(cosine) * bendDir; - a = l1 + l2 * cosine; - b = l2 * SIN(a2); - a1 = ATAN2(ty * a - tx * b, tx * a + ty * b); - } else { - float a = psx * l2, b = psy * l2; - float aa = a * a, bb = b * b, ll = l1 * l1, dd = tx * tx + ty * ty, ta = ATAN2(ty, tx); - float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa; - float d = c1 * c1 - 4 * c2 * c0; - float minAngle = 0, minDist = FLT_MAX, minX = 0, minY = 0; - float maxAngle = 0, maxDist = 0, maxX = 0, maxY = 0; - float x = l1 + a, dist = x * x, angle, y; - if (d >= 0) { - float q = SQRT(d), r0, r1; - if (c1 < 0) q = -q; - q = -(c1 + q) / 2; - r0 = q / c2; r1 = c0 / q; - r = ABS(r0) < ABS(r1) ? r0 : r1; - if (r * r <= dd) { - y = SQRT(dd - r * r) * bendDir; - a1 = ta - ATAN2(y, r); - a2 = ATAN2(y / psy, (r - l1) / psx); - goto outer; - } - } - if (dist > maxDist) { - maxAngle = 0; - maxDist = dist; - maxX = x; - } - x = l1 - a; - dist = x * x; - if (dist < minDist) { - minAngle = PI; - minDist = dist; - minX = x; - } - angle = ACOS(-a * l1 / (aa - bb)); - x = a * COS(angle) + l1; - y = b * SIN(angle); - dist = x * x + y * y; - if (dist < minDist) { - minAngle = angle; - minDist = dist; - minX = x; - minY = y; - } - if (dist > maxDist) { - maxAngle = angle; - maxDist = dist; - maxX = x; - maxY = y; - } - if (dd <= (minDist + maxDist) / 2) { - a1 = ta - ATAN2(minY * bendDir, minX); - a2 = minAngle * bendDir; - } else { - a1 = ta - ATAN2(maxY * bendDir, maxX); - a2 = maxAngle * bendDir; - } - } - outer: { - float os = ATAN2(cy, cx) * s2; - a1 = (a1 - os) * RAD_DEG + o1 - parent->arotation; - if (a1 > 180) a1 -= 360; - else if (a1 < -180) a1 += 360; - spBone_updateWorldTransformWith(parent, px, py, parent->rotation + a1 * alpha, parent->ascaleX, parent->ascaleY, 0, 0); - a2 = ((a2 + os) * RAD_DEG - child->ashearX) * s2 + o2 - child->arotation; - if (a2 > 180) a2 -= 360; - else if (a2 < -180) a2 += 360; - spBone_updateWorldTransformWith(child, cx, cy, child->arotation + a2 * alpha, child->ascaleX, child->ascaleY, child->ashearX, child->ashearY); - } -} diff --git a/native/cocos/editor-support/spine/IkConstraint.h b/native/cocos/editor-support/spine/IkConstraint.h deleted file mode 100644 index aef3c26a8d..0000000000 --- a/native/cocos/editor-support/spine/IkConstraint.h +++ /dev/null @@ -1,86 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_IKCONSTRAINT_H_ -#define SPINE_IKCONSTRAINT_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct spSkeleton; - -typedef struct spIkConstraint { - spIkConstraintData* const data; - - int bonesCount; - spBone** bones; - - spBone* target; - int bendDirection; - float mix; - -#ifdef __cplusplus - spIkConstraint() : - data(0), - bonesCount(0), - bones(0), - target(0), - bendDirection(0), - mix(0) { - } -#endif -} spIkConstraint; - -spIkConstraint* spIkConstraint_create (spIkConstraintData* data, const struct spSkeleton* skeleton); -void spIkConstraint_dispose (spIkConstraint* self); - -void spIkConstraint_apply (spIkConstraint* self); - -void spIkConstraint_apply1 (spBone* bone, float targetX, float targetY, float alpha); -void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float targetY, int bendDirection, float alpha); - -#ifdef SPINE_SHORT_NAMES -typedef spIkConstraint IkConstraint; -#define IkConstraint_create(...) spIkConstraint_create(__VA_ARGS__) -#define IkConstraint_dispose(...) spIkConstraint_dispose(__VA_ARGS__) -#define IkConstraint_apply(...) spIkConstraint_apply(__VA_ARGS__) -#define IkConstraint_apply1(...) spIkConstraint_apply1(__VA_ARGS__) -#define IkConstraint_apply2(...) spIkConstraint_apply2(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_IKCONSTRAINT_H_ */ diff --git a/native/cocos/editor-support/spine/IkConstraintData.c b/native/cocos/editor-support/spine/IkConstraintData.c deleted file mode 100644 index b557cc58f8..0000000000 --- a/native/cocos/editor-support/spine/IkConstraintData.c +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -spIkConstraintData* spIkConstraintData_create (const char* name) { - spIkConstraintData* self = NEW(spIkConstraintData); - MALLOC_STR(self->name, name); - self->bendDirection = 1; - self->mix = 1; - return self; -} - -void spIkConstraintData_dispose (spIkConstraintData* self) { - FREE(self->name); - FREE(self->bones); - FREE(self); -} diff --git a/native/cocos/editor-support/spine/IkConstraintData.h b/native/cocos/editor-support/spine/IkConstraintData.h deleted file mode 100644 index 65c2f08b78..0000000000 --- a/native/cocos/editor-support/spine/IkConstraintData.h +++ /dev/null @@ -1,75 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_IKCONSTRAINTDATA_H_ -#define SPINE_IKCONSTRAINTDATA_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spIkConstraintData { - const char* const name; - int order; - int bonesCount; - spBoneData** bones; - - spBoneData* target; - int bendDirection; - float mix; - -#ifdef __cplusplus - spIkConstraintData() : - name(0), - bonesCount(0), - bones(0), - target(0), - bendDirection(0), - mix(0) { - } -#endif -} spIkConstraintData; - -spIkConstraintData* spIkConstraintData_create (const char* name); -void spIkConstraintData_dispose (spIkConstraintData* self); - -#ifdef SPINE_SHORT_NAMES -typedef spIkConstraintData IkConstraintData; -#define IkConstraintData_create(...) spIkConstraintData_create(__VA_ARGS__) -#define IkConstraintData_dispose(...) spIkConstraintData_dispose(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_IKCONSTRAINTDATA_H_ */ diff --git a/native/cocos/editor-support/spine/Json.c b/native/cocos/editor-support/spine/Json.c deleted file mode 100644 index 6225ff00cc..0000000000 --- a/native/cocos/editor-support/spine/Json.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - Copyright (c) 2009, Dave Gamble - Copyright (c) 2013, Esoteric Software - - Permission is hereby granted, dispose of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ - -/* Json */ -/* JSON parser in C. */ - -#ifndef _DEFAULT_SOURCE -/* Bring strings.h definitions into string.h, where appropriate */ -#define _DEFAULT_SOURCE -#endif - -#ifndef _BSD_SOURCE -/* Bring strings.h definitions into string.h, where appropriate */ -#define _BSD_SOURCE -#endif - -#include "Json.h" -#include -#include -#include /* strtod (C89), strtof (C99) */ -#include /* strcasecmp (4.4BSD - compatibility), _stricmp (_WIN32) */ -#include - -#ifndef SPINE_JSON_DEBUG -/* Define this to do extra NULL and expected-character checking */ -#define SPINE_JSON_DEBUG 0 -#endif - -static const char* ep; - -const char* Json_getError (void) { - return ep; -} - -static int Json_strcasecmp (const char* s1, const char* s2) { - /* TODO we may be able to elide these NULL checks if we can prove - * the graph and input (only callsite is Json_getItem) should not have NULLs - */ - if (s1 && s2) { -#if defined(_WIN32) - return _stricmp(s1, s2); -#else - return strcasecmp( s1, s2 ); -#endif - } else { - if (s1 < s2) - return -1; /* s1 is null, s2 is not */ - else if (s1 == s2) - return 0; /* both are null */ - else - return 1; /* s2 is nul s1 is not */ - } -} - -/* Internal constructor. */ -static Json *Json_new (void) { - return (Json*)CALLOC(Json, 1); -} - -/* Delete a Json structure. */ -void Json_dispose (Json *c) { - Json *next; - while (c) { - next = c->next; - if (c->child) Json_dispose(c->child); - if (c->valueString) FREE(c->valueString); - if (c->name) FREE(c->name); - FREE(c); - c = next; - } -} - -/* Parse the input text to generate a number, and populate the result into item. */ -static const char* parse_number (Json *item, const char* num) { - char * endptr; - float n; - - /* Using strtod and strtof is slightly more permissive than RFC4627, - * accepting for example hex-encoded floating point, but either - * is often leagues faster than any manual implementation. - * - * We also already know that this starts with [-0-9] from parse_value. - */ -#if __STDC_VERSION__ >= 199901L - n = strtof(num, &endptr); -#else - n = (float)strtod( num, &endptr ); -#endif - /* ignore errno's ERANGE, which returns +/-HUGE_VAL */ - /* n is 0 on any other error */ - - if (endptr != num) { - /* Parse success, number found. */ - item->valueFloat = n; - item->valueInt = (int)n; - item->type = Json_Number; - return endptr; - } else { - /* Parse failure, ep is set. */ - ep = num; - return 0; - } -} - -/* Parse the input text into an unescaped cstring, and populate item. */ -static const unsigned char firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; -static const char* parse_string (Json *item, const char* str) { - const char* ptr = str + 1; - char* ptr2; - char* out; - int len = 0; - unsigned uc, uc2; - if (*str != '\"') { /* TODO: don't need this check when called from parse_value, but do need from parse_object */ - ep = str; - return 0; - } /* not a string! */ - - while (*ptr != '\"' && *ptr && ++len) - if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */ - - out = MALLOC(char, len + 1); /* The length needed for the string, roughly. */ - if (!out) return 0; - - ptr = str + 1; - ptr2 = out; - while (*ptr != '\"' && *ptr) { - if (*ptr != '\\') - *ptr2++ = *ptr++; - else { - ptr++; - switch (*ptr) { - case 'b': - *ptr2++ = '\b'; - break; - case 'f': - *ptr2++ = '\f'; - break; - case 'n': - *ptr2++ = '\n'; - break; - case 'r': - *ptr2++ = '\r'; - break; - case 't': - *ptr2++ = '\t'; - break; - case 'u': /* transcode utf16 to utf8. */ - sscanf(ptr + 1, "%4x", &uc); - ptr += 4; /* get the unicode char. */ - - if ((uc >= 0xDC00 && uc <= 0xDFFF) || uc == 0) break; /* check for invalid. */ - - /* TODO provide an option to ignore surrogates, use unicode replacement character? */ - if (uc >= 0xD800 && uc <= 0xDBFF) /* UTF16 surrogate pairs. */ - { - if (ptr[1] != '\\' || ptr[2] != 'u') break; /* missing second-half of surrogate. */ - sscanf(ptr + 3, "%4x", &uc2); - ptr += 6; - if (uc2 < 0xDC00 || uc2 > 0xDFFF) break; /* invalid second-half of surrogate. */ - uc = 0x10000 + (((uc & 0x3FF) << 10) | (uc2 & 0x3FF)); - } - - len = 4; - if (uc < 0x80) - len = 1; - else if (uc < 0x800) - len = 2; - else if (uc < 0x10000) len = 3; - ptr2 += len; - - switch (len) { - case 4: - *--ptr2 = ((uc | 0x80) & 0xBF); - uc >>= 6; - /* fallthrough */ - case 3: - *--ptr2 = ((uc | 0x80) & 0xBF); - uc >>= 6; - /* fallthrough */ - case 2: - *--ptr2 = ((uc | 0x80) & 0xBF); - uc >>= 6; - /* fallthrough */ - case 1: - *--ptr2 = (uc | firstByteMark[len]); - } - ptr2 += len; - break; - default: - *ptr2++ = *ptr; - break; - } - ptr++; - } - } - *ptr2 = 0; - if (*ptr == '\"') ptr++; /* TODO error handling if not \" or \0 ? */ - item->valueString = out; - item->type = Json_String; - return ptr; -} - -/* Predeclare these prototypes. */ -static const char* parse_value (Json *item, const char* value); -static const char* parse_array (Json *item, const char* value); -static const char* parse_object (Json *item, const char* value); - -/* Utility to jump whitespace and cr/lf */ -static const char* skip (const char* in) { - if (!in) return 0; /* must propagate NULL since it's often called in skip(f(...)) form */ - while (*in && (unsigned char)*in <= 32) - in++; - return in; -} - -/* Parse an object - create a new root, and populate. */ -Json *Json_create (const char* value) { - Json *c; - ep = 0; - if (!value) return 0; /* only place we check for NULL other than skip() */ - c = Json_new(); - if (!c) return 0; /* memory fail */ - - value = parse_value(c, skip(value)); - if (!value) { - Json_dispose(c); - return 0; - } /* parse failure. ep is set. */ - - return c; -} - -/* Parser core - when encountering text, process appropriately. */ -static const char* parse_value (Json *item, const char* value) { - /* Referenced by Json_create(), parse_array(), and parse_object(). */ - /* Always called with the result of skip(). */ -#if SPINE_JSON_DEBUG /* Checked at entry to graph, Json_create, and after every parse_ call. */ - if (!value) return 0; /* Fail on null. */ -#endif - - switch (*value) { - case 'n': { - if (!strncmp(value + 1, "ull", 3)) { - item->type = Json_NULL; - return value + 4; - } - break; - } - case 'f': { - if (!strncmp(value + 1, "alse", 4)) { - item->type = Json_False; - /* calloc prevents us needing item->type = Json_False or valueInt = 0 here */ - return value + 5; - } - break; - } - case 't': { - if (!strncmp(value + 1, "rue", 3)) { - item->type = Json_True; - item->valueInt = 1; - return value + 4; - } - break; - } - case '\"': - return parse_string(item, value); - case '[': - return parse_array(item, value); - case '{': - return parse_object(item, value); - case '-': /* fallthrough */ - case '0': /* fallthrough */ - case '1': /* fallthrough */ - case '2': /* fallthrough */ - case '3': /* fallthrough */ - case '4': /* fallthrough */ - case '5': /* fallthrough */ - case '6': /* fallthrough */ - case '7': /* fallthrough */ - case '8': /* fallthrough */ - case '9': - return parse_number(item, value); - default: - break; - } - - ep = value; - return 0; /* failure. */ -} - -/* Build an array from input text. */ -static const char* parse_array (Json *item, const char* value) { - Json *child; - -#if SPINE_JSON_DEBUG /* unnecessary, only callsite (parse_value) verifies this */ - if (*value != '[') { - ep = value; - return 0; - } /* not an array! */ -#endif - - item->type = Json_Array; - value = skip(value + 1); - if (*value == ']') return value + 1; /* empty array. */ - - item->child = child = Json_new(); - if (!item->child) return 0; /* memory fail */ - value = skip(parse_value(child, skip(value))); /* skip any spacing, get the value. */ - if (!value) return 0; - item->size = 1; - - while (*value == ',') { - Json *new_item = Json_new(); - if (!new_item) return 0; /* memory fail */ - child->next = new_item; -#if SPINE_JSON_HAVE_PREV - new_item->prev = child; -#endif - child = new_item; - value = skip(parse_value(child, skip(value + 1))); - if (!value) return 0; /* parse fail */ - item->size++; - } - - if (*value == ']') return value + 1; /* end of array */ - ep = value; - return 0; /* malformed. */ -} - -/* Build an object from the text. */ -static const char* parse_object (Json *item, const char* value) { - Json *child; - -#if SPINE_JSON_DEBUG /* unnecessary, only callsite (parse_value) verifies this */ - if (*value != '{') { - ep = value; - return 0; - } /* not an object! */ -#endif - - item->type = Json_Object; - value = skip(value + 1); - if (*value == '}') return value + 1; /* empty array. */ - - item->child = child = Json_new(); - if (!item->child) return 0; - value = skip(parse_string(child, skip(value))); - if (!value) return 0; - child->name = child->valueString; - child->valueString = 0; - if (*value != ':') { - ep = value; - return 0; - } /* fail! */ - value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */ - if (!value) return 0; - item->size = 1; - - while (*value == ',') { - Json *new_item = Json_new(); - if (!new_item) return 0; /* memory fail */ - child->next = new_item; -#if SPINE_JSON_HAVE_PREV - new_item->prev = child; -#endif - child = new_item; - value = skip(parse_string(child, skip(value + 1))); - if (!value) return 0; - child->name = child->valueString; - child->valueString = 0; - if (*value != ':') { - ep = value; - return 0; - } /* fail! */ - value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */ - if (!value) return 0; - item->size++; - } - - if (*value == '}') return value + 1; /* end of array */ - ep = value; - return 0; /* malformed. */ -} - -Json *Json_getItem (Json *object, const char* string) { - Json *c = object->child; - while (c && Json_strcasecmp(c->name, string)) - c = c->next; - return c; -} - -const char* Json_getString (Json* object, const char* name, const char* defaultValue) { - object = Json_getItem(object, name); - if (object) return object->valueString; - return defaultValue; -} - -float Json_getFloat (Json* value, const char* name, float defaultValue) { - value = Json_getItem(value, name); - return value ? value->valueFloat : defaultValue; -} - -int Json_getInt (Json* value, const char* name, int defaultValue) { - value = Json_getItem(value, name); - return value ? value->valueInt : defaultValue; -} diff --git a/native/cocos/editor-support/spine/Json.h b/native/cocos/editor-support/spine/Json.h deleted file mode 100644 index 078a5a7158..0000000000 --- a/native/cocos/editor-support/spine/Json.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright (c) 2009 Dave Gamble - - Permission is hereby granted, dispose of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - */ - -/* Esoteric Software: Removed everything except parsing, shorter method names, more get methods, double to float, formatted. */ - -#ifndef SPINE_JSON_H_ -#define SPINE_JSON_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Json Types: */ -#define Json_False 0 -#define Json_True 1 -#define Json_NULL 2 -#define Json_Number 3 -#define Json_String 4 -#define Json_Array 5 -#define Json_Object 6 - -#ifndef SPINE_JSON_HAVE_PREV -/* Spine doesn't use the "prev" link in the Json sibling lists. */ -#define SPINE_JSON_HAVE_PREV 0 -#endif - -/* The Json structure: */ -typedef struct Json { - struct Json* next; -#if SPINE_JSON_HAVE_PREV - struct Json* prev; /* next/prev allow you to walk array/object chains. Alternatively, use getSize/getItem */ -#endif - struct Json* child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ - - int type; /* The type of the item, as above. */ - int size; /* The number of children. */ - - const char* valueString; /* The item's string, if type==Json_String */ - int valueInt; /* The item's number, if type==Json_Number */ - float valueFloat; /* The item's number, if type==Json_Number */ - - const char* name; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ -} Json; - -/* Supply a block of JSON, and this returns a Json object you can interrogate. Call Json_dispose when finished. */ -Json* Json_create (const char* value); - -/* Delete a Json entity and all subentities. */ -void Json_dispose (Json* json); - -/* Get item "string" from object. Case insensitive. */ -Json* Json_getItem (Json* json, const char* string); -const char* Json_getString (Json* json, const char* name, const char* defaultValue); -float Json_getFloat (Json* json, const char* name, float defaultValue); -int Json_getInt (Json* json, const char* name, int defaultValue); - -/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when Json_create() returns 0. 0 when Json_create() succeeds. */ -const char* Json_getError (void); - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_JSON_H_ */ diff --git a/native/cocos/editor-support/spine/MeshAttachment.c b/native/cocos/editor-support/spine/MeshAttachment.c deleted file mode 100644 index d853527896..0000000000 --- a/native/cocos/editor-support/spine/MeshAttachment.c +++ /dev/null @@ -1,105 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -void _spMeshAttachment_dispose (spAttachment* attachment) { - spMeshAttachment* self = SUB_CAST(spMeshAttachment, attachment); - FREE(self->path); - FREE(self->uvs); - if (!self->parentMesh) { - _spVertexAttachment_deinit(SUPER(self)); - FREE(self->regionUVs); - FREE(self->triangles); - FREE(self->edges); - } else - _spAttachment_deinit(attachment); - FREE(self); -} - -spMeshAttachment* spMeshAttachment_create (const char* name) { - spMeshAttachment* self = NEW(spMeshAttachment); - self->r = 1; - self->g = 1; - self->b = 1; - self->a = 1; - _spAttachment_init(SUPER(SUPER(self)), name, SP_ATTACHMENT_MESH, _spMeshAttachment_dispose); - return self; -} - -void spMeshAttachment_updateUVs (spMeshAttachment* self) { - int i; - float width = self->regionU2 - self->regionU, height = self->regionV2 - self->regionV; - int verticesLength = SUPER(self)->worldVerticesLength; - FREE(self->uvs); - self->uvs = MALLOC(float, verticesLength); - if (self->regionRotate) { - for (i = 0; i < verticesLength; i += 2) { - self->uvs[i] = self->regionU + self->regionUVs[i + 1] * width; - self->uvs[i + 1] = self->regionV + height - self->regionUVs[i] * height; - } - } else { - for (i = 0; i < verticesLength; i += 2) { - self->uvs[i] = self->regionU + self->regionUVs[i] * width; - self->uvs[i + 1] = self->regionV + self->regionUVs[i + 1] * height; - } - } -} - -void spMeshAttachment_computeWorldVertices (spMeshAttachment* self, spSlot* slot, float* worldVertices) { - spVertexAttachment_computeWorldVertices(SUPER(self), slot, worldVertices); -} - -void spMeshAttachment_setParentMesh (spMeshAttachment* self, spMeshAttachment* parentMesh) { - CONST_CAST(spMeshAttachment*, self->parentMesh) = parentMesh; - if (parentMesh) { - self->super.worldVerticesLength = parentMesh->super.worldVerticesLength; - - self->super.bones = parentMesh->super.bones; - self->super.bonesCount = parentMesh->super.bonesCount; - - self->super.vertices = parentMesh->super.vertices; - self->super.verticesCount = parentMesh->super.verticesCount; - - self->regionUVs = parentMesh->regionUVs; - - self->triangles = parentMesh->triangles; - self->trianglesCount = parentMesh->trianglesCount; - - self->hullLength = parentMesh->hullLength; - - self->edges = parentMesh->edges; - self->edgesCount = parentMesh->edgesCount; - - self->width = parentMesh->width; - self->height = parentMesh->height; - } -} diff --git a/native/cocos/editor-support/spine/MeshAttachment.h b/native/cocos/editor-support/spine/MeshAttachment.h deleted file mode 100644 index 08e82e3026..0000000000 --- a/native/cocos/editor-support/spine/MeshAttachment.h +++ /dev/null @@ -1,92 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_MESHATTACHMENT_H_ -#define SPINE_MESHATTACHMENT_H_ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spMeshAttachment spMeshAttachment; -struct spMeshAttachment { - spVertexAttachment super; - - void* rendererObject; - int regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */ - int regionWidth, regionHeight; /* Unrotated, stripped pixel size. */ - int regionOriginalWidth, regionOriginalHeight; /* Unrotated, unstripped pixel size. */ - float regionU, regionV, regionU2, regionV2; - int/*bool*/regionRotate; - - const char* path; - - float* regionUVs; - float* uvs; - - int trianglesCount; - unsigned short* triangles; - - float r, g, b, a; - - int hullLength; - - spMeshAttachment* const parentMesh; - int/*bool*/inheritDeform; - - /* Nonessential. */ - int edgesCount; - int* edges; - float width, height; -}; - -spMeshAttachment* spMeshAttachment_create (const char* name); -void spMeshAttachment_updateUVs (spMeshAttachment* self); -void spMeshAttachment_computeWorldVertices (spMeshAttachment* self, spSlot* slot, float* worldVertices); -void spMeshAttachment_setParentMesh (spMeshAttachment* self, spMeshAttachment* parentMesh); - -#ifdef SPINE_SHORT_NAMES -typedef spMeshAttachment MeshAttachment; -#define MeshAttachment_create(...) spMeshAttachment_create(__VA_ARGS__) -#define MeshAttachment_updateUVs(...) spMeshAttachment_updateUVs(__VA_ARGS__) -#define MeshAttachment_computeWorldVertices(...) spMeshAttachment_computeWorldVertices(__VA_ARGS__) -#define MeshAttachment_setParentMesh(...) spMeshAttachment_setParentMesh(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_MESHATTACHMENT_H_ */ diff --git a/native/cocos/editor-support/spine/PathAttachment.c b/native/cocos/editor-support/spine/PathAttachment.c deleted file mode 100644 index 6281fa864e..0000000000 --- a/native/cocos/editor-support/spine/PathAttachment.c +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -void _spPathAttachment_dispose (spAttachment* attachment) { - spPathAttachment* self = SUB_CAST(spPathAttachment, attachment); - - _spVertexAttachment_deinit(SUPER(self)); - - FREE(self->lengths); - FREE(self); -} - -spPathAttachment* spPathAttachment_create (const char* name) { - spPathAttachment* self = NEW(spPathAttachment); - _spAttachment_init(SUPER(SUPER(self)), name, SP_ATTACHMENT_PATH, _spPathAttachment_dispose); - return self; -} - -void spPathAttachment_computeWorldVertices (spPathAttachment* self, spSlot* slot, float* worldVertices) { - spVertexAttachment_computeWorldVertices(SUPER(self), slot, worldVertices); -} - -void spPathAttachment_computeWorldVertices1 (spPathAttachment* self, spSlot* slot, int start, int count, float* worldVertices, int offset) { - spVertexAttachment_computeWorldVertices1(SUPER(self), start, count, slot, worldVertices, offset); -} diff --git a/native/cocos/editor-support/spine/PathAttachment.h b/native/cocos/editor-support/spine/PathAttachment.h deleted file mode 100644 index f9cf5234aa..0000000000 --- a/native/cocos/editor-support/spine/PathAttachment.h +++ /dev/null @@ -1,64 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_PATHATTACHMENT_H_ -#define SPINE_PATHATTACHMENT_H_ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spPathAttachment { - spVertexAttachment super; - int lengthsLength; - float* lengths; - int/*bool*/ closed, constantSpeed; -} spPathAttachment; - -spPathAttachment* spPathAttachment_create (const char* name); -void spPathAttachment_computeWorldVertices (spPathAttachment* self, spSlot* slot, float* worldVertices); -void spPathAttachment_computeWorldVertices1 (spPathAttachment* self, spSlot* slot, int start, int count, float* worldVertices, int offset); - -#ifdef SPINE_SHORT_NAMES -typedef spPathAttachment PathAttachment; -#define PathAttachment_create(...) spPathAttachment_create(__VA_ARGS__) -#define PathAttachment_computeWorldVertices(...) spPathAttachment_computeWorldVertices(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_PATHATTACHMENT_H_ */ diff --git a/native/cocos/editor-support/spine/PathConstraint.c b/native/cocos/editor-support/spine/PathConstraint.c deleted file mode 100644 index 825f8c713a..0000000000 --- a/native/cocos/editor-support/spine/PathConstraint.c +++ /dev/null @@ -1,459 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include - -#define PATHCONSTRAINT_NONE -1 -#define PATHCONSTRAINT_BEFORE -2 -#define PATHCONSTRAINT_AFTER -3 - -spPathConstraint* spPathConstraint_create (spPathConstraintData* data, const spSkeleton* skeleton) { - int i; - spPathConstraint *self = NEW(spPathConstraint); - CONST_CAST(spPathConstraintData*, self->data) = data; - self->bonesCount = data->bonesCount; - CONST_CAST(spBone**, self->bones) = MALLOC(spBone*, self->bonesCount); - for (i = 0; i < self->bonesCount; ++i) - self->bones[i] = spSkeleton_findBone(skeleton, self->data->bones[i]->name); - self->target = spSkeleton_findSlot(skeleton, self->data->target->name); - self->position = data->position; - self->spacing = data->spacing; - self->rotateMix = data->rotateMix; - self->translateMix = data->translateMix; - self->spacesCount = 0; - self->spaces = 0; - self->positionsCount = 0; - self->positions = 0; - self->worldCount = 0; - self->world = 0; - self->curvesCount = 0; - self->curves = 0; - self->lengthsCount = 0; - self->lengths = 0; - return self; -} - -void spPathConstraint_dispose (spPathConstraint* self) { - FREE(self->bones); - FREE(self->spaces); - if (self->positions) FREE(self->positions); - if (self->world) FREE(self->world); - if (self->curves) FREE(self->curves); - if (self->lengths) FREE(self->lengths); - FREE(self); -} - -void spPathConstraint_apply (spPathConstraint* self) { - int i, p, n; - float length, x, y, dx, dy, s; - float* spaces, *lengths, *positions; - float spacing; - float boneX, boneY, offsetRotation; - int/*bool*/tip; - float rotateMix = self->rotateMix, translateMix = self->translateMix; - int/*bool*/ translate = translateMix > 0, rotate = rotateMix > 0; - spPathAttachment* attachment = (spPathAttachment*)self->target->attachment; - spPathConstraintData* data = self->data; - spSpacingMode spacingMode = data->spacingMode; - int lengthSpacing = spacingMode == SP_SPACING_MODE_LENGTH; - spRotateMode rotateMode = data->rotateMode; - int tangents = rotateMode == SP_ROTATE_MODE_TANGENT, scale = rotateMode == SP_ROTATE_MODE_CHAIN_SCALE; - int boneCount = self->bonesCount, spacesCount = tangents ? boneCount : boneCount + 1; - spBone** bones = self->bones; - spBone* pa; - - if (!translate && !rotate) return; - if ((attachment == 0) || (attachment->super.super.type != SP_ATTACHMENT_PATH)) return; - - if (self->spacesCount != spacesCount) { - if (self->spaces) FREE(self->spaces); - self->spaces = MALLOC(float, spacesCount); - self->spacesCount = spacesCount; - } - spaces = self->spaces; - spaces[0] = 0; - lengths = 0; - spacing = self->spacing; - if (scale || lengthSpacing) { - if (scale) { - if (self->lengthsCount != boneCount) { - if (self->lengths) FREE(self->lengths); - self->lengths = MALLOC(float, boneCount); - self->lengthsCount = boneCount; - } - lengths = self->lengths; - } - for (i = 0, n = spacesCount - 1; i < n;) { - spBone* bone = bones[i]; - length = bone->data->length, x = length * bone->a, y = length * bone->c; - length = SQRT(x * x + y * y); - if (scale) lengths[i] = length; - spaces[++i] = lengthSpacing ? MAX(0, length + spacing) : spacing; - } - } else { - for (i = 1; i < spacesCount; i++) { - spaces[i] = spacing; - } - } - - positions = spPathConstraint_computeWorldPositions(self, attachment, spacesCount, tangents, - data->positionMode == SP_POSITION_MODE_PERCENT, spacingMode == SP_SPACING_MODE_PERCENT); - boneX = positions[0], boneY = positions[1], offsetRotation = self->data->offsetRotation; - tip = 0; - if (offsetRotation == 0) - tip = rotateMode == SP_ROTATE_MODE_CHAIN; - else { - tip = 0; - pa = self->target->bone; - offsetRotation *= pa->a * pa->d - pa->b * pa->c > 0 ? DEG_RAD : -DEG_RAD; - } - for (i = 0, p = 3; i < boneCount; i++, p += 3) { - spBone* bone = bones[i]; - CONST_CAST(float, bone->worldX) += (boneX - bone->worldX) * translateMix; - CONST_CAST(float, bone->worldY) += (boneY - bone->worldY) * translateMix; - x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY; - if (scale) { - length = lengths[i]; - if (length != 0) { - s = (SQRT(dx * dx + dy * dy) / length - 1) * rotateMix + 1; - CONST_CAST(float, bone->a) *= s; - CONST_CAST(float, bone->c) *= s; - } - } - boneX = x; - boneY = y; - if (rotate) { - float a = bone->a, b = bone->b, c = bone->c, d = bone->d, r, cosine, sine; - if (tangents) - r = positions[p - 1]; - else if (spaces[i + 1] == 0) - r = positions[p + 2]; - else - r = ATAN2(dy, dx); - r -= ATAN2(c, a) - offsetRotation * DEG_RAD; - if (tip) { - cosine = COS(r); - sine = SIN(r); - length = bone->data->length; - boneX += (length * (cosine * a - sine * c) - dx) * rotateMix; - boneY += (length * (sine * a + cosine * c) - dy) * rotateMix; - } else - r += offsetRotation; - if (r > PI) - r -= PI2; - else if (r < -PI) - r += PI2; - r *= rotateMix; - cosine = COS(r); - sine = SIN(r); - CONST_CAST(float, bone->a) = cosine * a - sine * c; - CONST_CAST(float, bone->b) = cosine * b - sine * d; - CONST_CAST(float, bone->c) = sine * a + cosine * c; - CONST_CAST(float, bone->d) = sine * b + cosine * d; - } - CONST_CAST(int, bone->appliedValid) = -1; - } -} - -static void _addBeforePosition(float p, float* temp, int i, float* out, int o) { - float x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = ATAN2(dy, dx); - out[o] = x1 + p * COS(r); - out[o + 1] = y1 + p * SIN(r); - out[o + 2] = r; -} - -static void _addAfterPosition (float p, float* temp, int i, float* out, int o) { - float x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = ATAN2(dy, dx); - out[o] = x1 + p * COS(r); - out[o + 1] = y1 + p * SIN(r); - out[o + 2] = r; -} - -static void _addCurvePosition (float p, float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2, float y2, - float* out, int o, int/*bool*/tangents) { - float tt, ttt, u, uu, uuu; - float ut, ut3, uut3, utt3; - float x, y; - if (p == 0) p = 0.0001f; - tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u; - ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p; - x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt; - out[o] = x; - out[o + 1] = y; - if (tangents) out[o + 2] = ATAN2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt)); -} - -float* spPathConstraint_computeWorldPositions(spPathConstraint* self, spPathAttachment* path, int spacesCount, int/*bool*/ tangents, int/*bool*/percentPosition, int/**/percentSpacing) { - int i, o, w, curve, segment, /*bool*/closed, verticesLength, curveCount, prevCurve; - float* out, *curves, *segments; - float tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy, pathLength, curveLength, p; - float x1, y1, cx1, cy1, cx2, cy2, x2, y2; - spSlot* target = self->target; - float position = self->position; - float* spaces = self->spaces, *world = 0; - if (self->positionsCount != spacesCount * 3 + 2) { - if (self->positions) FREE(self->positions); - self->positions = MALLOC(float, spacesCount * 3 + 2); - self->positionsCount = spacesCount * 3 + 2; - } - out = self->positions; - closed = path->closed; - verticesLength = path->super.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = PATHCONSTRAINT_NONE; - - if (!path->constantSpeed) { - float* lengths = path->lengths; - curveCount -= closed ? 1 : 2; - pathLength = lengths[curveCount]; - if (percentPosition) position *= pathLength; - if (percentSpacing) { - for (i = 0; i < spacesCount; i++) - spaces[i] *= pathLength; - } - if (self->worldCount != 8) { - if (self->world) FREE(self->world); - self->world = MALLOC(float, 8); - self->worldCount = 8; - } - world = self->world; - for (i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) { - float space = spaces[i]; - position += space; - p = position; - - if (closed) { - p = FMOD(p, pathLength); - if (p < 0) p += pathLength; - curve = 0; - } else if (p < 0) { - if (prevCurve != PATHCONSTRAINT_BEFORE) { - prevCurve = PATHCONSTRAINT_BEFORE; - spPathAttachment_computeWorldVertices1(path, target, 2, 4, world, 0); - } - _addBeforePosition(p, world, 0, out, o); - continue; - } else if (p > pathLength) { - if (prevCurve != PATHCONSTRAINT_AFTER) { - prevCurve = PATHCONSTRAINT_AFTER; - spPathAttachment_computeWorldVertices1(path, target, verticesLength - 6, 4, world, 0); - } - _addAfterPosition(p - pathLength, world, 0, out, o); - continue; - } - - /* Determine curve containing position. */ - for (;; curve++) { - float length = lengths[curve]; - if (p > length) continue; - if (curve == 0) - p /= length; - else { - float prev = lengths[curve - 1]; - p = (p - prev) / (length - prev); - } - break; - } - if (curve != prevCurve) { - prevCurve = curve; - if (closed && curve == curveCount) { - spPathAttachment_computeWorldVertices1(path, target, verticesLength - 4, 4, world, 0); - spPathAttachment_computeWorldVertices1(path, target, 0, 4, world, 4); - } else - spPathAttachment_computeWorldVertices1(path, target, curve * 6 + 2, 8, world, 0); - } - _addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], out, o, - tangents || (i > 0 && space == 0)); - } - return out; - } - - /* World vertices. */ - if (closed) { - verticesLength += 2; - if (self->worldCount != verticesLength) { - if (self->world) FREE(self->world); - self->world = MALLOC(float, verticesLength); - self->worldCount = verticesLength; - } - world = self->world; - spPathAttachment_computeWorldVertices1(path, target, 2, verticesLength - 4, world, 0); - spPathAttachment_computeWorldVertices1(path, target, 0, 2, world, verticesLength - 4); - world[verticesLength - 2] = world[0]; - world[verticesLength - 1] = world[1]; - } else { - curveCount--; - verticesLength -= 4; - if (self->worldCount != verticesLength) { - if (self->world) FREE(self->world); - self->world = MALLOC(float, verticesLength); - self->worldCount = verticesLength; - } - world = self->world; - spPathAttachment_computeWorldVertices1(path, target, 2, verticesLength, world, 0); - } - - /* Curve lengths. */ - if (self->curvesCount != curveCount) { - if (self->curves) FREE(self->curves); - self->curves = MALLOC(float, curveCount); - self->curvesCount = curveCount; - } - curves = self->curves; - pathLength = 0; - x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; - for (i = 0, w = 2; i < curveCount; i++, w += 6) { - cx1 = world[w]; - cy1 = world[w + 1]; - cx2 = world[w + 2]; - cy2 = world[w + 3]; - x2 = world[w + 4]; - y2 = world[w + 5]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.1875f; - tmpy = (y1 - cy1 * 2 + cy2) * 0.1875f; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375f; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375f; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.75f + tmpx + dddfx * 0.16666667f; - dfy = (cy1 - y1) * 0.75f + tmpy + dddfy * 0.16666667f; - pathLength += SQRT(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - pathLength += SQRT(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - pathLength += SQRT(dfx * dfx + dfy * dfy); - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - pathLength += SQRT(dfx * dfx + dfy * dfy); - curves[i] = pathLength; - x1 = x2; - y1 = y2; - } - if (percentPosition) position *= pathLength; - if (percentSpacing) { - for (i = 0; i < spacesCount; i++) - spaces[i] *= pathLength; - } - - segments = self->segments; - curveLength = 0; - for (i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) { - float space = spaces[i]; - position += space; - p = position; - - if (closed) { - p = FMOD(p, pathLength); - if (p < 0) p += pathLength; - curve = 0; - } else if (p < 0) { - _addBeforePosition(p, world, 0, out, o); - continue; - } else if (p > pathLength) { - _addAfterPosition(p - pathLength, world, verticesLength - 4, out, o); - continue; - } - - /* Determine curve containing position. */ - for (;; curve++) { - float length = curves[curve]; - if (p > length) continue; - if (curve == 0) - p /= length; - else { - float prev = curves[curve - 1]; - p = (p - prev) / (length - prev); - } - break; - } - - /* Curve segment lengths. */ - if (curve != prevCurve) { - int ii; - prevCurve = curve; - ii = curve * 6; - x1 = world[ii]; - y1 = world[ii + 1]; - cx1 = world[ii + 2]; - cy1 = world[ii + 3]; - cx2 = world[ii + 4]; - cy2 = world[ii + 5]; - x2 = world[ii + 6]; - y2 = world[ii + 7]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.03f; - tmpy = (y1 - cy1 * 2 + cy2) * 0.03f; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006f; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006f; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.3f + tmpx + dddfx * 0.16666667f; - dfy = (cy1 - y1) * 0.3f + tmpy + dddfy * 0.16666667f; - curveLength = SQRT(dfx * dfx + dfy * dfy); - segments[0] = curveLength; - for (ii = 1; ii < 8; ii++) { - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - curveLength += SQRT(dfx * dfx + dfy * dfy); - segments[ii] = curveLength; - } - dfx += ddfx; - dfy += ddfy; - curveLength += SQRT(dfx * dfx + dfy * dfy); - segments[8] = curveLength; - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - curveLength += SQRT(dfx * dfx + dfy * dfy); - segments[9] = curveLength; - segment = 0; - } - - /* Weight by segment length. */ - p *= curveLength; - for (;; segment++) { - float length = segments[segment]; - if (p > length) continue; - if (segment == 0) - p /= length; - else { - float prev = segments[segment - 1]; - p = segment + (p - prev) / (length - prev); - } - break; - } - _addCurvePosition(p * 0.1f, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0)); - } - return out; -} diff --git a/native/cocos/editor-support/spine/PathConstraint.h b/native/cocos/editor-support/spine/PathConstraint.h deleted file mode 100644 index 836708ae2a..0000000000 --- a/native/cocos/editor-support/spine/PathConstraint.h +++ /dev/null @@ -1,112 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_PATHCONSTRAINT_H_ -#define SPINE_PATHCONSTRAINT_H_ - -#include -#include -#include -#include "PathAttachment.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct spSkeleton; - -typedef struct spPathConstraint { - spPathConstraintData* const data; - int bonesCount; - spBone** const bones; - spSlot* target; - float position, spacing, rotateMix, translateMix; - - int spacesCount; - float* spaces; - - int positionsCount; - float* positions; - - int worldCount; - float* world; - - int curvesCount; - float* curves; - - int lengthsCount; - float* lengths; - - float segments[10]; - -#ifdef __cplusplus - spPathConstraint() : - data(0), - bonesCount(0), - bones(0), - target(0), - position(0), - spacing(0), - rotateMix(0), - translateMix(0), - spacesCount(0), - spaces(0), - positionsCount(0), - positions(0), - worldCount(0), - world(0), - curvesCount(0), - curves(0), - lengthsCount(0), - lengths(0) { - } -#endif -} spPathConstraint; - -#define SP_PATHCONSTRAINT_ - -spPathConstraint* spPathConstraint_create (spPathConstraintData* data, const struct spSkeleton* skeleton); -void spPathConstraint_dispose (spPathConstraint* self); - -void spPathConstraint_apply (spPathConstraint* self); -float* spPathConstraint_computeWorldPositions(spPathConstraint* self, spPathAttachment* path, int spacesCount, int/*bool*/ tangents, int/*bool*/percentPosition, int/**/percentSpacing); - -#ifdef SPINE_SHORT_NAMES -typedef spPathConstraint PathConstraint; -#define PathConstraint_create(...) spPathConstraint_create(__VA_ARGS__) -#define PathConstraint_dispose(...) spPathConstraint_dispose(__VA_ARGS__) -#define PathConstraint_apply(...) spPathConstraint_apply(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_PATHCONSTRAINT_H_ */ diff --git a/native/cocos/editor-support/spine/PathConstraintData.c b/native/cocos/editor-support/spine/PathConstraintData.c deleted file mode 100644 index e0556cbe5b..0000000000 --- a/native/cocos/editor-support/spine/PathConstraintData.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -spPathConstraintData* spPathConstraintData_create (const char* name) { - spPathConstraintData* self = NEW(spPathConstraintData); - MALLOC_STR(self->name, name); - return self; -} - -void spPathConstraintData_dispose (spPathConstraintData* self) { - FREE(self->name); - FREE(self->bones); - FREE(self); -} diff --git a/native/cocos/editor-support/spine/PathConstraintData.h b/native/cocos/editor-support/spine/PathConstraintData.h deleted file mode 100644 index 31c9fad20f..0000000000 --- a/native/cocos/editor-support/spine/PathConstraintData.h +++ /dev/null @@ -1,96 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_PATHCONSTRAINTDATA_H_ -#define SPINE_PATHCONSTRAINTDATA_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - SP_POSITION_MODE_FIXED, SP_POSITION_MODE_PERCENT -} spPositionMode; - -typedef enum { - SP_SPACING_MODE_LENGTH, SP_SPACING_MODE_FIXED, SP_SPACING_MODE_PERCENT -} spSpacingMode; - -typedef enum { - SP_ROTATE_MODE_TANGENT, SP_ROTATE_MODE_CHAIN, SP_ROTATE_MODE_CHAIN_SCALE -} spRotateMode; - -typedef struct spPathConstraintData { - const char* const name; - int order; - int bonesCount; - spBoneData** const bones; - spSlotData* target; - spPositionMode positionMode; - spSpacingMode spacingMode; - spRotateMode rotateMode; - float offsetRotation; - float position, spacing, rotateMix, translateMix; - -#ifdef __cplusplus - spPathConstraintData() : - name(0), - bonesCount(0), - bones(0), - target(0), - positionMode(SP_POSITION_MODE_FIXED), - spacingMode(SP_SPACING_MODE_LENGTH), - rotateMode(SP_ROTATE_MODE_TANGENT), - offsetRotation(0), - position(0), - spacing(0), - rotateMix(0), - translateMix(0) { - } -#endif -} spPathConstraintData; - -spPathConstraintData* spPathConstraintData_create (const char* name); -void spPathConstraintData_dispose (spPathConstraintData* self); - -#ifdef SPINE_SHORT_NAMES -typedef spPathConstraintData PathConstraintData; -#define PathConstraintData_create(...) spPathConstraintData_create(__VA_ARGS__) -#define PathConstraintData_dispose(...) spPathConstraintData_dispose(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_PATHCONSTRAINTDATA_H_ */ diff --git a/native/cocos/editor-support/spine/RegionAttachment.c b/native/cocos/editor-support/spine/RegionAttachment.c deleted file mode 100644 index 50b1fc833e..0000000000 --- a/native/cocos/editor-support/spine/RegionAttachment.c +++ /dev/null @@ -1,113 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -void _spRegionAttachment_dispose (spAttachment* attachment) { - spRegionAttachment* self = SUB_CAST(spRegionAttachment, attachment); - _spAttachment_deinit(attachment); - FREE(self->path); - FREE(self); -} - -spRegionAttachment* spRegionAttachment_create (const char* name) { - spRegionAttachment* self = NEW(spRegionAttachment); - self->scaleX = 1; - self->scaleY = 1; - self->r = 1; - self->g = 1; - self->b = 1; - self->a = 1; - _spAttachment_init(SUPER(self), name, SP_ATTACHMENT_REGION, _spRegionAttachment_dispose); - return self; -} - -void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate) { - if (rotate) { - self->uvs[SP_VERTEX_X2] = u; - self->uvs[SP_VERTEX_Y2] = v2; - self->uvs[SP_VERTEX_X3] = u; - self->uvs[SP_VERTEX_Y3] = v; - self->uvs[SP_VERTEX_X4] = u2; - self->uvs[SP_VERTEX_Y4] = v; - self->uvs[SP_VERTEX_X1] = u2; - self->uvs[SP_VERTEX_Y1] = v2; - } else { - self->uvs[SP_VERTEX_X1] = u; - self->uvs[SP_VERTEX_Y1] = v2; - self->uvs[SP_VERTEX_X2] = u; - self->uvs[SP_VERTEX_Y2] = v; - self->uvs[SP_VERTEX_X3] = u2; - self->uvs[SP_VERTEX_Y3] = v; - self->uvs[SP_VERTEX_X4] = u2; - self->uvs[SP_VERTEX_Y4] = v2; - } -} - -void spRegionAttachment_updateOffset (spRegionAttachment* self) { - float regionScaleX = self->width / self->regionOriginalWidth * self->scaleX; - float regionScaleY = self->height / self->regionOriginalHeight * self->scaleY; - float localX = -self->width / 2 * self->scaleX + self->regionOffsetX * regionScaleX; - float localY = -self->height / 2 * self->scaleY + self->regionOffsetY * regionScaleY; - float localX2 = localX + self->regionWidth * regionScaleX; - float localY2 = localY + self->regionHeight * regionScaleY; - float radians = self->rotation * DEG_RAD; - float cosine = COS(radians), sine = SIN(radians); - float localXCos = localX * cosine + self->x; - float localXSin = localX * sine; - float localYCos = localY * cosine + self->y; - float localYSin = localY * sine; - float localX2Cos = localX2 * cosine + self->x; - float localX2Sin = localX2 * sine; - float localY2Cos = localY2 * cosine + self->y; - float localY2Sin = localY2 * sine; - self->offset[SP_VERTEX_X1] = localXCos - localYSin; - self->offset[SP_VERTEX_Y1] = localYCos + localXSin; - self->offset[SP_VERTEX_X2] = localXCos - localY2Sin; - self->offset[SP_VERTEX_Y2] = localY2Cos + localXSin; - self->offset[SP_VERTEX_X3] = localX2Cos - localY2Sin; - self->offset[SP_VERTEX_Y3] = localY2Cos + localX2Sin; - self->offset[SP_VERTEX_X4] = localX2Cos - localYSin; - self->offset[SP_VERTEX_Y4] = localYCos + localX2Sin; -} - -void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, spBone* bone, float* vertices) { - const float* offset = self->offset; - float x = bone->worldX, y = bone->worldY; - vertices[SP_VERTEX_X1] = offset[SP_VERTEX_X1] * bone->a + offset[SP_VERTEX_Y1] * bone->b + x; - vertices[SP_VERTEX_Y1] = offset[SP_VERTEX_X1] * bone->c + offset[SP_VERTEX_Y1] * bone->d + y; - vertices[SP_VERTEX_X2] = offset[SP_VERTEX_X2] * bone->a + offset[SP_VERTEX_Y2] * bone->b + x; - vertices[SP_VERTEX_Y2] = offset[SP_VERTEX_X2] * bone->c + offset[SP_VERTEX_Y2] * bone->d + y; - vertices[SP_VERTEX_X3] = offset[SP_VERTEX_X3] * bone->a + offset[SP_VERTEX_Y3] * bone->b + x; - vertices[SP_VERTEX_Y3] = offset[SP_VERTEX_X3] * bone->c + offset[SP_VERTEX_Y3] * bone->d + y; - vertices[SP_VERTEX_X4] = offset[SP_VERTEX_X4] * bone->a + offset[SP_VERTEX_Y4] * bone->b + x; - vertices[SP_VERTEX_Y4] = offset[SP_VERTEX_X4] * bone->c + offset[SP_VERTEX_Y4] * bone->d + y; -} diff --git a/native/cocos/editor-support/spine/RegionAttachment.h b/native/cocos/editor-support/spine/RegionAttachment.h deleted file mode 100644 index e71eabb62f..0000000000 --- a/native/cocos/editor-support/spine/RegionAttachment.h +++ /dev/null @@ -1,87 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_REGIONATTACHMENT_H_ -#define SPINE_REGIONATTACHMENT_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - SP_VERTEX_X1 = 0, SP_VERTEX_Y1, SP_VERTEX_X2, SP_VERTEX_Y2, SP_VERTEX_X3, SP_VERTEX_Y3, SP_VERTEX_X4, SP_VERTEX_Y4 -} spVertexIndex; - -typedef struct spRegionAttachment { - spAttachment super; - const char* path; - float x, y, scaleX, scaleY, rotation, width, height; - float r, g, b, a; - - void* rendererObject; - int regionOffsetX, regionOffsetY; /* Pixels stripped from the bottom left, unrotated. */ - int regionWidth, regionHeight; /* Unrotated, stripped pixel size. */ - int regionOriginalWidth, regionOriginalHeight; /* Unrotated, unstripped pixel size. */ - - float offset[8]; - float uvs[8]; -} spRegionAttachment; - -spRegionAttachment* spRegionAttachment_create (const char* name); -void spRegionAttachment_setUVs (spRegionAttachment* self, float u, float v, float u2, float v2, int/*bool*/rotate); -void spRegionAttachment_updateOffset (spRegionAttachment* self); -void spRegionAttachment_computeWorldVertices (spRegionAttachment* self, spBone* bone, float* vertices); - -#ifdef SPINE_SHORT_NAMES -typedef spVertexIndex VertexIndex; -#define VERTEX_X1 SP_VERTEX_X1 -#define VERTEX_Y1 SP_VERTEX_Y1 -#define VERTEX_X2 SP_VERTEX_X2 -#define VERTEX_Y2 SP_VERTEX_Y2 -#define VERTEX_X3 SP_VERTEX_X3 -#define VERTEX_Y3 SP_VERTEX_Y3 -#define VERTEX_X4 SP_VERTEX_X4 -#define VERTEX_Y4 SP_VERTEX_Y4 -typedef spRegionAttachment RegionAttachment; -#define RegionAttachment_create(...) spRegionAttachment_create(__VA_ARGS__) -#define RegionAttachment_setUVs(...) spRegionAttachment_setUVs(__VA_ARGS__) -#define RegionAttachment_updateOffset(...) spRegionAttachment_updateOffset(__VA_ARGS__) -#define RegionAttachment_computeWorldVertices(...) spRegionAttachment_computeWorldVertices(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_REGIONATTACHMENT_H_ */ diff --git a/native/cocos/editor-support/spine/Skeleton.c b/native/cocos/editor-support/spine/Skeleton.c deleted file mode 100644 index cc994bcc42..0000000000 --- a/native/cocos/editor-support/spine/Skeleton.c +++ /dev/null @@ -1,565 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include -#include - -typedef enum { - SP_UPDATE_BONE, SP_UPDATE_IK_CONSTRAINT, SP_UPDATE_PATH_CONSTRAINT, SP_UPDATE_TRANSFORM_CONSTRAINT -} _spUpdateType; - -typedef struct { - _spUpdateType type; - void* object; -} _spUpdate; - -typedef struct { - spSkeleton super; - - int updateCacheCount; - int updateCacheCapacity; - _spUpdate* updateCache; - - int updateCacheResetCount; - int updateCacheResetCapacity; - spBone** updateCacheReset; -} _spSkeleton; - -spSkeleton* spSkeleton_create (spSkeletonData* data) { - int i; - int* childrenCounts; - - _spSkeleton* internal = NEW(_spSkeleton); - spSkeleton* self = SUPER(internal); - CONST_CAST(spSkeletonData*, self->data) = data; - - self->bonesCount = self->data->bonesCount; - self->bones = MALLOC(spBone*, self->bonesCount); - childrenCounts = CALLOC(int, self->bonesCount); - - for (i = 0; i < self->bonesCount; ++i) { - spBoneData* boneData = self->data->bones[i]; - spBone* newBone; - if (!boneData->parent) - newBone = spBone_create(boneData, self, 0); - else { - spBone* parent = self->bones[boneData->parent->index]; - newBone = spBone_create(boneData, self, parent); - ++childrenCounts[boneData->parent->index]; - } - self->bones[i] = newBone; - } - for (i = 0; i < self->bonesCount; ++i) { - spBoneData* boneData = self->data->bones[i]; - spBone* bone = self->bones[i]; - CONST_CAST(spBone**, bone->children) = MALLOC(spBone*, childrenCounts[boneData->index]); - } - for (i = 0; i < self->bonesCount; ++i) { - spBone* bone = self->bones[i]; - spBone* parent = bone->parent; - if (parent) - parent->children[parent->childrenCount++] = bone; - } - CONST_CAST(spBone*, self->root) = (self->bonesCount > 0 ? self->bones[0] : NULL); - - self->slotsCount = data->slotsCount; - self->slots = MALLOC(spSlot*, self->slotsCount); - for (i = 0; i < self->slotsCount; ++i) { - spSlotData *slotData = data->slots[i]; - spBone* bone = self->bones[slotData->boneData->index]; - self->slots[i] = spSlot_create(slotData, bone); - } - - self->drawOrder = MALLOC(spSlot*, self->slotsCount); - memcpy(self->drawOrder, self->slots, sizeof(spSlot*) * self->slotsCount); - - self->ikConstraintsCount = data->ikConstraintsCount; - self->ikConstraints = MALLOC(spIkConstraint*, self->ikConstraintsCount); - for (i = 0; i < self->data->ikConstraintsCount; ++i) - self->ikConstraints[i] = spIkConstraint_create(self->data->ikConstraints[i], self); - - self->transformConstraintsCount = data->transformConstraintsCount; - self->transformConstraints = MALLOC(spTransformConstraint*, self->transformConstraintsCount); - for (i = 0; i < self->data->transformConstraintsCount; ++i) - self->transformConstraints[i] = spTransformConstraint_create(self->data->transformConstraints[i], self); - - self->pathConstraintsCount = data->pathConstraintsCount; - self->pathConstraints = MALLOC(spPathConstraint*, self->pathConstraintsCount); - for (i = 0; i < self->data->pathConstraintsCount; i++) - self->pathConstraints[i] = spPathConstraint_create(self->data->pathConstraints[i], self); - - self->r = 1; self->g = 1; self->b = 1; self->a = 1; - - spSkeleton_updateCache(self); - - FREE(childrenCounts); - - return self; -} - -void spSkeleton_dispose (spSkeleton* self) { - int i; - _spSkeleton* internal = SUB_CAST(_spSkeleton, self); - - FREE(internal->updateCache); - FREE(internal->updateCacheReset); - - for (i = 0; i < self->bonesCount; ++i) - spBone_dispose(self->bones[i]); - FREE(self->bones); - - for (i = 0; i < self->slotsCount; ++i) - spSlot_dispose(self->slots[i]); - FREE(self->slots); - - for (i = 0; i < self->ikConstraintsCount; ++i) - spIkConstraint_dispose(self->ikConstraints[i]); - FREE(self->ikConstraints); - - for (i = 0; i < self->transformConstraintsCount; ++i) - spTransformConstraint_dispose(self->transformConstraints[i]); - FREE(self->transformConstraints); - - for (i = 0; i < self->pathConstraintsCount; i++) - spPathConstraint_dispose(self->pathConstraints[i]); - FREE(self->pathConstraints); - - FREE(self->drawOrder); - FREE(self); -} - -static void _addToUpdateCache(_spSkeleton* const internal, _spUpdateType type, void *object) { - _spUpdate* update; - if (internal->updateCacheCount == internal->updateCacheCapacity) { - internal->updateCacheCapacity *= 2; - internal->updateCache = realloc(internal->updateCache, sizeof(_spUpdate) * internal->updateCacheCapacity); - } - update = internal->updateCache + internal->updateCacheCount; - update->type = type; - update->object = object; - ++internal->updateCacheCount; -} - -static void _addToUpdateCacheReset(_spSkeleton* const internal, spBone* bone) { - if (internal->updateCacheResetCount == internal->updateCacheResetCapacity) { - internal->updateCacheResetCapacity *= 2; - internal->updateCacheReset = realloc(internal->updateCacheReset, sizeof(spBone*) * internal->updateCacheResetCapacity); - } - internal->updateCacheReset[internal->updateCacheResetCount] = bone; - ++internal->updateCacheResetCount; -} - -static void _sortBone(_spSkeleton* const internal, spBone* bone) { - if (bone->sorted) return; - if (bone->parent) _sortBone(internal, bone->parent); - bone->sorted = 1; - _addToUpdateCache(internal, SP_UPDATE_BONE, bone); -} - -static void _sortPathConstraintAttachmentBones(_spSkeleton* const internal, spAttachment* attachment, spBone* slotBone) { - spPathAttachment* pathAttachment = (spPathAttachment*)attachment; - int* pathBones; - int pathBonesCount; - if (pathAttachment->super.super.type != SP_ATTACHMENT_PATH) return; - pathBones = pathAttachment->super.bones; - pathBonesCount = pathAttachment->super.bonesCount; - if (pathBones == 0) - _sortBone(internal, slotBone); - else { - spBone** bones = internal->super.bones; - int i = 0, n; - while (i < pathBonesCount) { - int boneCount = pathBones[i++]; - for (n = i + boneCount; i < n; i++) - _sortBone(internal, bones[pathBones[i]]); - } - } -} - -static void _sortPathConstraintAttachment(_spSkeleton* const internal, spSkin* skin, int slotIndex, spBone* slotBone) { - _Entry* entry = SUB_CAST(_spSkin, skin)->entries; - while (entry) { - if (entry->slotIndex == slotIndex) _sortPathConstraintAttachmentBones(internal, entry->attachment, slotBone); - entry = entry->next; - } -} - -static void _sortReset(spBone** bones, int bonesCount) { - int i; - for (i = 0; i < bonesCount; ++i) { - spBone* bone = bones[i]; - if (bone->sorted) _sortReset(bone->children, bone->childrenCount); - bone->sorted = 0; - } -} - -static void _sortIkConstraint (_spSkeleton* const internal, spIkConstraint* constraint) { - int /*bool*/ contains = 0; - int i; - spBone* target = constraint->target; - spBone** constrained; - spBone* parent; - _sortBone(internal, target); - - constrained = constraint->bones; - parent = constrained[0]; - _sortBone(internal, parent); - - if (constraint->bonesCount > 1) { - spBone* child = constrained[constraint->bonesCount - 1]; - contains = 0; - for (i = 0; i < internal->updateCacheCount; i++) { - _spUpdate update = internal->updateCache[i]; - if (update.object == child) { - contains = -1; - break; - } - } - if (!contains) - _addToUpdateCacheReset(internal, child); - } - - _addToUpdateCache(internal, SP_UPDATE_IK_CONSTRAINT, constraint); - - _sortReset(parent->children, parent->childrenCount); - constrained[constraint->bonesCount-1]->sorted = 1; -} - -static void _sortPathConstraint(_spSkeleton* const internal, spPathConstraint* constraint) { - spSlot* slot = constraint->target; - int slotIndex = slot->data->index; - spBone* slotBone = slot->bone; - int ii, nn, boneCount; - spAttachment* attachment; - spBone** constrained; - spSkeleton* skeleton = SUPER_CAST(spSkeleton, internal); - if (skeleton->skin) _sortPathConstraintAttachment(internal, skeleton->skin, slotIndex, slotBone); - if (skeleton->data->defaultSkin && skeleton->data->defaultSkin != skeleton->skin) - _sortPathConstraintAttachment(internal, skeleton->data->defaultSkin, slotIndex, slotBone); - for (ii = 0, nn = skeleton->data->skinsCount; ii < nn; ii++) - _sortPathConstraintAttachment(internal, skeleton->data->skins[ii], slotIndex, slotBone); - - attachment = slot->attachment; - if (attachment->type == SP_ATTACHMENT_PATH) _sortPathConstraintAttachmentBones(internal, attachment, slotBone); - - constrained = constraint->bones; - boneCount = constraint->bonesCount; - for (ii = 0; ii < boneCount; ii++) - _sortBone(internal, constrained[ii]); - - _addToUpdateCache(internal, SP_UPDATE_PATH_CONSTRAINT, constraint); - - for (ii = 0; ii < boneCount; ii++) - _sortReset(constrained[ii]->children, constrained[ii]->childrenCount); - for (ii = 0; ii < boneCount; ii++) - constrained[ii]->sorted = 1; -} - -static void _sortTransformConstraint(_spSkeleton* const internal, spTransformConstraint* constraint) { - int ii, boneCount; - spBone** constrained; - _sortBone(internal, constraint->target); - - constrained = constraint->bones; - boneCount = constraint->bonesCount; - for (ii = 0; ii < boneCount; ii++) - _sortBone(internal, constrained[ii]); - - _addToUpdateCache(internal, SP_UPDATE_TRANSFORM_CONSTRAINT, constraint); - - for (ii = 0; ii < boneCount; ii++) - _sortReset(constrained[ii]->children, constrained[ii]->childrenCount); - for (ii = 0; ii < boneCount; ii++) - constrained[ii]->sorted = 1; -} - -void spSkeleton_updateCache (spSkeleton* self) { - int i, ii; - spBone** bones; - spIkConstraint** ikConstraints; - spPathConstraint** pathConstraints; - spTransformConstraint** transformConstraints; - int ikCount, transformCount, pathCount, constraintCount; - _spSkeleton* internal = SUB_CAST(_spSkeleton, self); - - internal->updateCacheCapacity = self->bonesCount + self->ikConstraintsCount + self->transformConstraintsCount + self->pathConstraintsCount; - FREE(internal->updateCache); - internal->updateCache = MALLOC(_spUpdate, internal->updateCacheCapacity); - internal->updateCacheCount = 0; - - internal->updateCacheResetCapacity = self->bonesCount; - FREE(internal->updateCacheReset); - internal->updateCacheReset = MALLOC(spBone*, internal->updateCacheResetCapacity); - internal->updateCacheResetCount = 0; - - bones = self->bones; - for (i = 0; i < self->bonesCount; ++i) - bones[i]->sorted = 0; - - /* IK first, lowest hierarchy depth first. */ - ikConstraints = self->ikConstraints; - transformConstraints = self->transformConstraints; - pathConstraints = self->pathConstraints; - ikCount = self->ikConstraintsCount; transformCount = self->transformConstraintsCount; pathCount = self->pathConstraintsCount; - constraintCount = ikCount + transformCount + pathCount; - - i = 0; - outer: - for (; i < constraintCount; i++) { - for (ii = 0; ii < ikCount; ii++) { - spIkConstraint* ikConstraint = ikConstraints[ii]; - if (ikConstraint->data->order == i) { - _sortIkConstraint(internal, ikConstraint); - i++; - goto outer; - } - } - - for (ii = 0; ii < transformCount; ii++) { - spTransformConstraint* transformConstraint = transformConstraints[ii]; - if (transformConstraint->data->order == i) { - _sortTransformConstraint(internal, transformConstraint); - i++; - goto outer; - } - } - - for (ii = 0; ii < pathCount; ii++) { - spPathConstraint* pathConstraint = pathConstraints[ii]; - if (pathConstraint->data->order == i) { - _sortPathConstraint(internal, pathConstraint); - i++; - goto outer; - } - } - } - - for (i = 0; i < self->bonesCount; ++i) - _sortBone(internal, self->bones[i]); -} - -void spSkeleton_updateWorldTransform (const spSkeleton* self) { - int i; - _spSkeleton* internal = SUB_CAST(_spSkeleton, self); - spBone** updateCacheReset = internal->updateCacheReset; - for (i = 0; i < internal->updateCacheResetCount; i++) { - spBone* bone = updateCacheReset[i]; - CONST_CAST(float, bone->ax) = bone->x; - CONST_CAST(float, bone->ay) = bone->y; - CONST_CAST(float, bone->arotation) = bone->rotation; - CONST_CAST(float, bone->ascaleX) = bone->scaleX; - CONST_CAST(float, bone->ascaleY) = bone->scaleY; - CONST_CAST(float, bone->ashearX) = bone->shearX; - CONST_CAST(float, bone->ashearY) = bone->shearY; - CONST_CAST(int, bone->appliedValid) = 1; - } - - for (i = 0; i < internal->updateCacheCount; ++i) { - _spUpdate* update = internal->updateCache + i; - switch (update->type) { - case SP_UPDATE_BONE: - spBone_updateWorldTransform((spBone*)update->object); - break; - case SP_UPDATE_IK_CONSTRAINT: - spIkConstraint_apply((spIkConstraint*)update->object); - break; - case SP_UPDATE_TRANSFORM_CONSTRAINT: - spTransformConstraint_apply((spTransformConstraint*)update->object); - break; - case SP_UPDATE_PATH_CONSTRAINT: - spPathConstraint_apply((spPathConstraint*)update->object); - break; - } - } -} - -void spSkeleton_setToSetupPose (const spSkeleton* self) { - spSkeleton_setBonesToSetupPose(self); - spSkeleton_setSlotsToSetupPose(self); -} - -void spSkeleton_setBonesToSetupPose (const spSkeleton* self) { - int i; - for (i = 0; i < self->bonesCount; ++i) - spBone_setToSetupPose(self->bones[i]); - - for (i = 0; i < self->ikConstraintsCount; ++i) { - spIkConstraint* ikConstraint = self->ikConstraints[i]; - ikConstraint->bendDirection = ikConstraint->data->bendDirection; - ikConstraint->mix = ikConstraint->data->mix; - } - - for (i = 0; i < self->transformConstraintsCount; ++i) { - spTransformConstraint* constraint = self->transformConstraints[i]; - spTransformConstraintData* data = constraint->data; - constraint->rotateMix = data->rotateMix; - constraint->translateMix = data->translateMix; - constraint->scaleMix = data->scaleMix; - constraint->shearMix = data->shearMix; - } - - for (i = 0; i < self->pathConstraintsCount; ++i) { - spPathConstraint* constraint = self->pathConstraints[i]; - spPathConstraintData* data = constraint->data; - constraint->position = data->position; - constraint->spacing = data->spacing; - constraint->rotateMix = data->rotateMix; - constraint->translateMix = data->translateMix; - } -} - -void spSkeleton_setSlotsToSetupPose (const spSkeleton* self) { - int i; - memcpy(self->drawOrder, self->slots, self->slotsCount * sizeof(spSlot*)); - for (i = 0; i < self->slotsCount; ++i) - spSlot_setToSetupPose(self->slots[i]); -} - -spBone* spSkeleton_findBone (const spSkeleton* self, const char* boneName) { - int i; - for (i = 0; i < self->bonesCount; ++i) - if (strcmp(self->data->bones[i]->name, boneName) == 0) return self->bones[i]; - return 0; -} - -int spSkeleton_findBoneIndex (const spSkeleton* self, const char* boneName) { - int i; - for (i = 0; i < self->bonesCount; ++i) - if (strcmp(self->data->bones[i]->name, boneName) == 0) return i; - return -1; -} - -spSlot* spSkeleton_findSlot (const spSkeleton* self, const char* slotName) { - int i; - for (i = 0; i < self->slotsCount; ++i) - if (strcmp(self->data->slots[i]->name, slotName) == 0) return self->slots[i]; - return 0; -} - -int spSkeleton_findSlotIndex (const spSkeleton* self, const char* slotName) { - int i; - for (i = 0; i < self->slotsCount; ++i) - if (strcmp(self->data->slots[i]->name, slotName) == 0) return i; - return -1; -} - -int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName) { - spSkin *skin; - if (!skinName) { - spSkeleton_setSkin(self, 0); - return 1; - } - skin = spSkeletonData_findSkin(self->data, skinName); - if (!skin) return 0; - spSkeleton_setSkin(self, skin); - return 1; -} - -void spSkeleton_setSkin (spSkeleton* self, spSkin* newSkin) { - if (newSkin) { - if (self->skin) - spSkin_attachAll(newSkin, self, self->skin); - else { - /* No previous skin, attach setup pose attachments. */ - int i; - for (i = 0; i < self->slotsCount; ++i) { - spSlot* slot = self->slots[i]; - if (slot->data->attachmentName) { - spAttachment* attachment = spSkin_getAttachment(newSkin, i, slot->data->attachmentName); - if (attachment) spSlot_setAttachment(slot, attachment); - } - } - } - } - CONST_CAST(spSkin*, self->skin) = newSkin; -} - -spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName) { - int slotIndex = spSkeletonData_findSlotIndex(self->data, slotName); - return spSkeleton_getAttachmentForSlotIndex(self, slotIndex, attachmentName); -} - -spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName) { - if (slotIndex == -1) return 0; - if (self->skin) { - spAttachment *attachment = spSkin_getAttachment(self->skin, slotIndex, attachmentName); - if (attachment) return attachment; - } - if (self->data->defaultSkin) { - spAttachment *attachment = spSkin_getAttachment(self->data->defaultSkin, slotIndex, attachmentName); - if (attachment) return attachment; - } - return 0; -} - -int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName) { - int i; - for (i = 0; i < self->slotsCount; ++i) { - spSlot *slot = self->slots[i]; - if (strcmp(slot->data->name, slotName) == 0) { - if (!attachmentName) - spSlot_setAttachment(slot, 0); - else { - spAttachment* attachment = spSkeleton_getAttachmentForSlotIndex(self, i, attachmentName); - if (!attachment) return 0; - spSlot_setAttachment(slot, attachment); - } - return 1; - } - } - return 0; -} - -spIkConstraint* spSkeleton_findIkConstraint (const spSkeleton* self, const char* constraintName) { - int i; - for (i = 0; i < self->ikConstraintsCount; ++i) - if (strcmp(self->ikConstraints[i]->data->name, constraintName) == 0) return self->ikConstraints[i]; - return 0; -} - -spTransformConstraint* spSkeleton_findTransformConstraint (const spSkeleton* self, const char* constraintName) { - int i; - for (i = 0; i < self->transformConstraintsCount; ++i) - if (strcmp(self->transformConstraints[i]->data->name, constraintName) == 0) return self->transformConstraints[i]; - return 0; -} - -spPathConstraint* spSkeleton_findPathConstraint (const spSkeleton* self, const char* constraintName) { - int i; - for (i = 0; i < self->pathConstraintsCount; ++i) - if (strcmp(self->pathConstraints[i]->data->name, constraintName) == 0) return self->pathConstraints[i]; - return 0; -} - -void spSkeleton_update (spSkeleton* self, float deltaTime) { - self->time += deltaTime; -} diff --git a/native/cocos/editor-support/spine/Skeleton.h b/native/cocos/editor-support/spine/Skeleton.h deleted file mode 100644 index c8c1c005c5..0000000000 --- a/native/cocos/editor-support/spine/Skeleton.h +++ /dev/null @@ -1,173 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SKELETON_H_ -#define SPINE_SKELETON_H_ - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spSkeleton { - spSkeletonData* const data; - - int bonesCount; - spBone** bones; - spBone* const root; - - int slotsCount; - spSlot** slots; - spSlot** drawOrder; - - int ikConstraintsCount; - spIkConstraint** ikConstraints; - - int transformConstraintsCount; - spTransformConstraint** transformConstraints; - - int pathConstraintsCount; - spPathConstraint** pathConstraints; - - spSkin* const skin; - float r, g, b, a; - float time; - int/*bool*/flipX, flipY; - float x, y; - -#ifdef __cplusplus - spSkeleton() : - data(0), - bonesCount(0), - bones(0), - root(0), - slotsCount(0), - slots(0), - drawOrder(0), - - ikConstraintsCount(0), - ikConstraints(0), - - transformConstraintsCount(0), - transformConstraints(0), - - skin(0), - r(0), g(0), b(0), a(0), - time(0), - flipX(0), - flipY(0), - x(0), y(0) { - } -#endif -} spSkeleton; - -spSkeleton* spSkeleton_create (spSkeletonData* data); -void spSkeleton_dispose (spSkeleton* self); - -/* Caches information about bones and constraints. Must be called if bones or constraints, or weighted path attachments - * are added or removed. */ -void spSkeleton_updateCache (spSkeleton* self); -void spSkeleton_updateWorldTransform (const spSkeleton* self); - -/* Sets the bones, constraints, and slots to their setup pose values. */ -void spSkeleton_setToSetupPose (const spSkeleton* self); -/* Sets the bones and constraints to their setup pose values. */ -void spSkeleton_setBonesToSetupPose (const spSkeleton* self); -void spSkeleton_setSlotsToSetupPose (const spSkeleton* self); - -/* Returns 0 if the bone was not found. */ -spBone* spSkeleton_findBone (const spSkeleton* self, const char* boneName); -/* Returns -1 if the bone was not found. */ -int spSkeleton_findBoneIndex (const spSkeleton* self, const char* boneName); - -/* Returns 0 if the slot was not found. */ -spSlot* spSkeleton_findSlot (const spSkeleton* self, const char* slotName); -/* Returns -1 if the slot was not found. */ -int spSkeleton_findSlotIndex (const spSkeleton* self, const char* slotName); - -/* Sets the skin used to look up attachments before looking in the SkeletonData defaultSkin. Attachments from the new skin are - * attached if the corresponding attachment from the old skin was attached. If there was no old skin, each slot's setup mode - * attachment is attached from the new skin. - * @param skin May be 0.*/ -void spSkeleton_setSkin (spSkeleton* self, spSkin* skin); -/* Returns 0 if the skin was not found. See spSkeleton_setSkin. - * @param skinName May be 0. */ -int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName); - -/* Returns 0 if the slot or attachment was not found. */ -spAttachment* spSkeleton_getAttachmentForSlotName (const spSkeleton* self, const char* slotName, const char* attachmentName); -/* Returns 0 if the slot or attachment was not found. */ -spAttachment* spSkeleton_getAttachmentForSlotIndex (const spSkeleton* self, int slotIndex, const char* attachmentName); -/* Returns 0 if the slot or attachment was not found. - * @param attachmentName May be 0. */ -int spSkeleton_setAttachment (spSkeleton* self, const char* slotName, const char* attachmentName); - -/* Returns 0 if the IK constraint was not found. */ -spIkConstraint* spSkeleton_findIkConstraint (const spSkeleton* self, const char* constraintName); - -/* Returns 0 if the transform constraint was not found. */ -spTransformConstraint* spSkeleton_findTransformConstraint (const spSkeleton* self, const char* constraintName); - -/* Returns 0 if the path constraint was not found. */ -spPathConstraint* spSkeleton_findPathConstraint (const spSkeleton* self, const char* constraintName); - -void spSkeleton_update (spSkeleton* self, float deltaTime); - -#ifdef SPINE_SHORT_NAMES -typedef spSkeleton Skeleton; -#define Skeleton_create(...) spSkeleton_create(__VA_ARGS__) -#define Skeleton_dispose(...) spSkeleton_dispose(__VA_ARGS__) -#define Skeleton_updateWorldTransform(...) spSkeleton_updateWorldTransform(__VA_ARGS__) -#define Skeleton_setToSetupPose(...) spSkeleton_setToSetupPose(__VA_ARGS__) -#define Skeleton_setBonesToSetupPose(...) spSkeleton_setBonesToSetupPose(__VA_ARGS__) -#define Skeleton_setSlotsToSetupPose(...) spSkeleton_setSlotsToSetupPose(__VA_ARGS__) -#define Skeleton_findBone(...) spSkeleton_findBone(__VA_ARGS__) -#define Skeleton_findBoneIndex(...) spSkeleton_findBoneIndex(__VA_ARGS__) -#define Skeleton_findSlot(...) spSkeleton_findSlot(__VA_ARGS__) -#define Skeleton_findSlotIndex(...) spSkeleton_findSlotIndex(__VA_ARGS__) -#define Skeleton_setSkin(...) spSkeleton_setSkin(__VA_ARGS__) -#define Skeleton_setSkinByName(...) spSkeleton_setSkinByName(__VA_ARGS__) -#define Skeleton_getAttachmentForSlotName(...) spSkeleton_getAttachmentForSlotName(__VA_ARGS__) -#define Skeleton_getAttachmentForSlotIndex(...) spSkeleton_getAttachmentForSlotIndex(__VA_ARGS__) -#define Skeleton_setAttachment(...) spSkeleton_setAttachment(__VA_ARGS__) -#define Skeleton_update(...) spSkeleton_update(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_SKELETON_H_*/ diff --git a/native/cocos/editor-support/spine/SkeletonAnimation.cpp b/native/cocos/editor-support/spine/SkeletonAnimation.cpp deleted file mode 100644 index aacbea8ce5..0000000000 --- a/native/cocos/editor-support/spine/SkeletonAnimation.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include -#include - -USING_NS_CC; -using std::min; -using std::max; -using std::vector; - -namespace spine { - -typedef struct _TrackEntryListeners { - StartListener startListener; - InterruptListener interruptListener; - EndListener endListener; - DisposeListener disposeListener; - CompleteListener completeListener; - EventListener eventListener; -} _TrackEntryListeners; - -void animationCallback (spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event) { - ((SkeletonAnimation*)state->rendererObject)->onAnimationStateEvent(entry, type, event); -} - -void trackEntryCallback (spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event) { - ((SkeletonAnimation*)state->rendererObject)->onTrackEntryEvent(entry, type, event); - if (type == SP_ANIMATION_DISPOSE) - if (entry->rendererObject) delete (spine::_TrackEntryListeners*)entry->rendererObject; -} - -static _TrackEntryListeners* getListeners (spTrackEntry* entry) { - if (!entry->rendererObject) { - entry->rendererObject = new spine::_TrackEntryListeners(); - entry->listener = trackEntryCallback; - } - return (_TrackEntryListeners*)entry->rendererObject; -} - -// - -SkeletonAnimation* SkeletonAnimation::createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData) { - SkeletonAnimation* node = new SkeletonAnimation(); - node->initWithData(skeletonData, ownsSkeletonData); - node->autorelease(); - return node; -} - -SkeletonAnimation* SkeletonAnimation::createWithJsonFile (const std::string& skeletonJsonFile, spAtlas* atlas, float scale) { - SkeletonAnimation* node = new SkeletonAnimation(); - node->initWithJsonFile(skeletonJsonFile, atlas, scale); - node->autorelease(); - return node; -} - -SkeletonAnimation* SkeletonAnimation::createWithJsonFile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale) { - SkeletonAnimation* node = new SkeletonAnimation(); - spAtlas* atlas = spAtlas_createFromFile(atlasFile.c_str(), 0); - node->initWithJsonFile(skeletonJsonFile, atlas, scale); - node->autorelease(); - return node; -} - -SkeletonAnimation* SkeletonAnimation::createWithBinaryFile (const std::string& skeletonBinaryFile, spAtlas* atlas, float scale) { - SkeletonAnimation* node = new SkeletonAnimation(); - node->initWithBinaryFile(skeletonBinaryFile, atlas, scale); - node->autorelease(); - return node; -} - -SkeletonAnimation* SkeletonAnimation::createWithBinaryFile (const std::string& skeletonBinaryFile, const std::string& atlasFile, float scale) { - SkeletonAnimation* node = new SkeletonAnimation(); - spAtlas* atlas = spAtlas_createFromFile(atlasFile.c_str(), 0); - node->initWithBinaryFile(skeletonBinaryFile, atlas, scale); - node->autorelease(); - return node; -} - - -void SkeletonAnimation::initialize () { - super::initialize(); - - _ownsAnimationStateData = true; - _state = spAnimationState_create(spAnimationStateData_create(_skeleton->data)); - _state->rendererObject = this; - _state->listener = animationCallback; - - _spAnimationState* stateInternal = (_spAnimationState*)_state; -} - -SkeletonAnimation::SkeletonAnimation () - : SkeletonRenderer() { -} - -SkeletonAnimation::SkeletonAnimation (spSkeletonData *skeletonData, bool ownsSkeletonData) - : SkeletonRenderer(skeletonData, ownsSkeletonData) { - initialize(); -} - -SkeletonAnimation::SkeletonAnimation (const std::string& skeletonDataFile, spAtlas* atlas, float scale) - : SkeletonRenderer(skeletonDataFile, atlas, scale) { - initialize(); -} - -SkeletonAnimation::SkeletonAnimation (const std::string& skeletonDataFile, const std::string& atlasFile, float scale) - : SkeletonRenderer(skeletonDataFile, atlasFile, scale) { - initialize(); -} - -SkeletonAnimation::~SkeletonAnimation () { - if (_ownsAnimationStateData) spAnimationStateData_dispose(_state->data); - spAnimationState_dispose(_state); -} - -void SkeletonAnimation::update (float deltaTime) { - super::update(deltaTime); - - deltaTime *= _timeScale; - spAnimationState_update(_state, deltaTime); - spAnimationState_apply(_state, _skeleton); - spSkeleton_updateWorldTransform(_skeleton); -} - -void SkeletonAnimation::setAnimationStateData (spAnimationStateData* stateData) { - CCASSERT(stateData, "stateData cannot be null."); - - if (_ownsAnimationStateData) spAnimationStateData_dispose(_state->data); - spAnimationState_dispose(_state); - - _ownsAnimationStateData = false; - _state = spAnimationState_create(stateData); - _state->rendererObject = this; - _state->listener = animationCallback; -} - -void SkeletonAnimation::setMix (const std::string& fromAnimation, const std::string& toAnimation, float duration) { - spAnimationStateData_setMixByName(_state->data, fromAnimation.c_str(), toAnimation.c_str(), duration); -} - -spTrackEntry* SkeletonAnimation::setAnimation (int trackIndex, const std::string& name, bool loop) { - spAnimation* animation = spSkeletonData_findAnimation(_skeleton->data, name.c_str()); - if (!animation) { - log("Spine: Animation not found: %s", name.c_str()); - return 0; - } - return spAnimationState_setAnimation(_state, trackIndex, animation, loop); -} - -spTrackEntry* SkeletonAnimation::addAnimation (int trackIndex, const std::string& name, bool loop, float delay) { - spAnimation* animation = spSkeletonData_findAnimation(_skeleton->data, name.c_str()); - if (!animation) { - log("Spine: Animation not found: %s", name.c_str()); - return 0; - } - return spAnimationState_addAnimation(_state, trackIndex, animation, loop, delay); -} - -spAnimation* SkeletonAnimation::findAnimation(const std::string& name) const { - return spSkeletonData_findAnimation(_skeleton->data, name.c_str()); -} - -spTrackEntry* SkeletonAnimation::getCurrent (int trackIndex) { - return spAnimationState_getCurrent(_state, trackIndex); -} - -void SkeletonAnimation::clearTracks () { - spAnimationState_clearTracks(_state); -} - -void SkeletonAnimation::clearTrack (int trackIndex) { - spAnimationState_clearTrack(_state, trackIndex); -} - -void SkeletonAnimation::onAnimationStateEvent (spTrackEntry* entry, spEventType type, spEvent* event) { - switch (type) { - case SP_ANIMATION_START: - if (_startListener) _startListener(entry); - break; - case SP_ANIMATION_INTERRUPT: - if (_interruptListener) _interruptListener(entry); - break; - case SP_ANIMATION_END: - if (_endListener) _endListener(entry); - break; - case SP_ANIMATION_DISPOSE: - if (_disposeListener) _disposeListener(entry); - break; - case SP_ANIMATION_COMPLETE: - if (_completeListener) _completeListener(entry); - break; - case SP_ANIMATION_EVENT: - if (_eventListener) _eventListener(entry, event); - break; - } -} - -void SkeletonAnimation::onTrackEntryEvent (spTrackEntry* entry, spEventType type, spEvent* event) { - if (!entry->rendererObject) return; - _TrackEntryListeners* listeners = (_TrackEntryListeners*)entry->rendererObject; - switch (type) { - case SP_ANIMATION_START: - if (listeners->startListener) listeners->startListener(entry); - break; - case SP_ANIMATION_INTERRUPT: - if (listeners->interruptListener) listeners->interruptListener(entry); - break; - case SP_ANIMATION_END: - if (listeners->endListener) listeners->endListener(entry); - break; - case SP_ANIMATION_DISPOSE: - if (listeners->disposeListener) listeners->disposeListener(entry); - break; - case SP_ANIMATION_COMPLETE: - if (listeners->completeListener) listeners->completeListener(entry); - break; - case SP_ANIMATION_EVENT: - if (listeners->eventListener) listeners->eventListener(entry, event); - break; - } -} - -void SkeletonAnimation::setStartListener (const StartListener& listener) { - _startListener = listener; -} - -void SkeletonAnimation::setInterruptListener (const InterruptListener& listener) { - _interruptListener = listener; -} - -void SkeletonAnimation::setEndListener (const EndListener& listener) { - _endListener = listener; -} - -void SkeletonAnimation::setDisposeListener (const DisposeListener& listener) { - _disposeListener = listener; -} - -void SkeletonAnimation::setCompleteListener (const CompleteListener& listener) { - _completeListener = listener; -} - -void SkeletonAnimation::setEventListener (const EventListener& listener) { - _eventListener = listener; -} - -void SkeletonAnimation::setTrackStartListener (spTrackEntry* entry, const StartListener& listener) { - getListeners(entry)->startListener = listener; -} - -void SkeletonAnimation::setTrackInterruptListener (spTrackEntry* entry, const InterruptListener& listener) { - getListeners(entry)->interruptListener = listener; -} - -void SkeletonAnimation::setTrackEndListener (spTrackEntry* entry, const EndListener& listener) { - getListeners(entry)->endListener = listener; -} - -void SkeletonAnimation::setTrackDisposeListener (spTrackEntry* entry, const DisposeListener& listener) { - getListeners(entry)->disposeListener = listener; -} - -void SkeletonAnimation::setTrackCompleteListener (spTrackEntry* entry, const CompleteListener& listener) { - getListeners(entry)->completeListener = listener; -} - -void SkeletonAnimation::setTrackEventListener (spTrackEntry* entry, const EventListener& listener) { - getListeners(entry)->eventListener = listener; -} - -spAnimationState* SkeletonAnimation::getState() const { - return _state; -} - -} diff --git a/native/cocos/editor-support/spine/SkeletonAnimation.h b/native/cocos/editor-support/spine/SkeletonAnimation.h deleted file mode 100644 index 4861cac878..0000000000 --- a/native/cocos/editor-support/spine/SkeletonAnimation.h +++ /dev/null @@ -1,126 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SKELETONANIMATION_H_ -#define SPINE_SKELETONANIMATION_H_ - -#include -#include -#include "cocos2d.h" - -namespace spine { - -typedef std::function StartListener; -typedef std::function InterruptListener; -typedef std::function EndListener; -typedef std::function DisposeListener; -typedef std::function CompleteListener; -typedef std::function EventListener; - -/** Draws an animated skeleton, providing an AnimationState for applying one or more animations and queuing animations to be - * played later. */ -class SkeletonAnimation: public SkeletonRenderer { -public: - CREATE_FUNC(SkeletonAnimation); - static SkeletonAnimation* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false); - static SkeletonAnimation* createWithJsonFile (const std::string& skeletonJsonFile, spAtlas* atlas, float scale = 1); - static SkeletonAnimation* createWithJsonFile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale = 1); - static SkeletonAnimation* createWithBinaryFile (const std::string& skeletonBinaryFile, spAtlas* atlas, float scale = 1); - static SkeletonAnimation* createWithBinaryFile (const std::string& skeletonBinaryFile, const std::string& atlasFile, float scale = 1); - - // Use createWithJsonFile instead - CC_DEPRECATED_ATTRIBUTE static SkeletonAnimation* createWithFile (const std::string& skeletonJsonFile, spAtlas* atlas, float scale = 1) - { - return SkeletonAnimation::createWithJsonFile(skeletonJsonFile, atlas, scale); - } - // Use createWithJsonFile instead - CC_DEPRECATED_ATTRIBUTE static SkeletonAnimation* createWithile (const std::string& skeletonJsonFile, const std::string& atlasFile, float scale = 1) - { - return SkeletonAnimation::createWithJsonFile(skeletonJsonFile, atlasFile, scale); - } - - virtual void update (float deltaTime) override; - - void setAnimationStateData (spAnimationStateData* stateData); - void setMix (const std::string& fromAnimation, const std::string& toAnimation, float duration); - - spTrackEntry* setAnimation (int trackIndex, const std::string& name, bool loop); - spTrackEntry* addAnimation (int trackIndex, const std::string& name, bool loop, float delay = 0); - spAnimation* findAnimation(const std::string& name) const; - spTrackEntry* getCurrent (int trackIndex = 0); - void clearTracks (); - void clearTrack (int trackIndex = 0); - - void setStartListener (const StartListener& listener); - void setInterruptListener (const InterruptListener& listener); - void setEndListener (const EndListener& listener); - void setDisposeListener (const DisposeListener& listener); - void setCompleteListener (const CompleteListener& listener); - void setEventListener (const EventListener& listener); - - void setTrackStartListener (spTrackEntry* entry, const StartListener& listener); - void setTrackInterruptListener (spTrackEntry* entry, const InterruptListener& listener); - void setTrackEndListener (spTrackEntry* entry, const EndListener& listener); - void setTrackDisposeListener (spTrackEntry* entry, const DisposeListener& listener); - void setTrackCompleteListener (spTrackEntry* entry, const CompleteListener& listener); - void setTrackEventListener (spTrackEntry* entry, const EventListener& listener); - - virtual void onAnimationStateEvent (spTrackEntry* entry, spEventType type, spEvent* event); - virtual void onTrackEntryEvent (spTrackEntry* entry, spEventType type, spEvent* event); - - spAnimationState* getState() const; - -CC_CONSTRUCTOR_ACCESS: - SkeletonAnimation (); - SkeletonAnimation (spSkeletonData* skeletonData, bool ownsSkeletonData = false); - SkeletonAnimation (const std::string&skeletonDataFile, spAtlas* atlas, float scale = 1); - SkeletonAnimation (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1); - virtual ~SkeletonAnimation (); - virtual void initialize () override; - -protected: - spAnimationState* _state; - - bool _ownsAnimationStateData; - - StartListener _startListener; - InterruptListener _interruptListener; - EndListener _endListener; - DisposeListener _disposeListener; - CompleteListener _completeListener; - EventListener _eventListener; - -private: - typedef SkeletonRenderer super; -}; - -} - -#endif /* SPINE_SKELETONANIMATION_H_ */ diff --git a/native/cocos/editor-support/spine/SkeletonBatch.cpp b/native/cocos/editor-support/spine/SkeletonBatch.cpp deleted file mode 100644 index 094b963b00..0000000000 --- a/native/cocos/editor-support/spine/SkeletonBatch.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include - -USING_NS_CC; -#define EVENT_AFTER_DRAW_RESET_POSITION "director_after_draw" -using std::max; - -namespace spine { - - static SkeletonBatch* instance = nullptr; - - SkeletonBatch* SkeletonBatch::getInstance () { - if (!instance) instance = new SkeletonBatch(); - return instance; - } - - void SkeletonBatch::destroyInstance () { - if (instance) { - delete instance; - instance = nullptr; - } - } - - SkeletonBatch::SkeletonBatch () - { - _firstCommand = new Command(); - _command = _firstCommand; - - Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_AFTER_DRAW_RESET_POSITION, [this](EventCustom* eventCustom){ - this->update(0); - });; - } - - SkeletonBatch::~SkeletonBatch () { - Director::getInstance()->getEventDispatcher()->removeCustomEventListeners(EVENT_AFTER_DRAW_RESET_POSITION); - - Command* command = _firstCommand; - while (command) { - Command* next = command->next; - delete command; - command = next; - } - } - - void SkeletonBatch::update (float delta) { - _command = _firstCommand; - } - - void SkeletonBatch::addCommand (cocos2d::Renderer* renderer, float globalZOrder, GLuint textureID, GLProgramState* glProgramState, - BlendFunc blendFunc, const TrianglesCommand::Triangles& triangles, const Mat4& transform, uint32_t transformFlags - ) { - if (_command->triangles->verts) { - free(_command->triangles->verts); - _command->triangles->verts = NULL; - } - - _command->triangles->verts = (V3F_C4B_T2F *)malloc(sizeof(V3F_C4B_T2F) * triangles.vertCount); - memcpy(_command->triangles->verts, triangles.verts, sizeof(V3F_C4B_T2F) * triangles.vertCount); - - _command->triangles->vertCount = triangles.vertCount; - _command->triangles->indexCount = triangles.indexCount; - _command->triangles->indices = triangles.indices; - - _command->trianglesCommand->init(globalZOrder, textureID, glProgramState, blendFunc, *_command->triangles, transform, transformFlags); - renderer->addCommand(_command->trianglesCommand); - - if (!_command->next) _command->next = new Command(); - _command = _command->next; - } - - SkeletonBatch::Command::Command () : - next(nullptr) - { - trianglesCommand = new TrianglesCommand(); - triangles = new TrianglesCommand::Triangles(); - } - - SkeletonBatch::Command::~Command () { - if (triangles->verts) { - free(triangles->verts); - } - delete triangles; - delete trianglesCommand; - } - -} diff --git a/native/cocos/editor-support/spine/SkeletonBatch.h b/native/cocos/editor-support/spine/SkeletonBatch.h deleted file mode 100644 index a475606354..0000000000 --- a/native/cocos/editor-support/spine/SkeletonBatch.h +++ /dev/null @@ -1,70 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SKELETONBATCH_H_ -#define SPINE_SKELETONBATCH_H_ - -#include -#include "cocos2d.h" - -namespace spine { - - class SkeletonBatch { - public: - static SkeletonBatch* getInstance (); - - static void destroyInstance (); - - void update (float delta); - - void addCommand (cocos2d::Renderer* renderer, float globalOrder, GLuint textureID, cocos2d::GLProgramState* glProgramState, - cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand:: Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags); - - protected: - SkeletonBatch (); - virtual ~SkeletonBatch (); - - class Command { - public: - Command (); - virtual ~Command (); - - cocos2d::TrianglesCommand* trianglesCommand; - cocos2d::TrianglesCommand::Triangles* triangles; - Command* next; - }; - - Command* _firstCommand; - Command* _command; - }; - -} - -#endif // SPINE_SKELETONBATCH_H_ diff --git a/native/cocos/editor-support/spine/SkeletonBinary.c b/native/cocos/editor-support/spine/SkeletonBinary.c deleted file mode 100644 index 4371bdd113..0000000000 --- a/native/cocos/editor-support/spine/SkeletonBinary.c +++ /dev/null @@ -1,1046 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include "kvec.h" - -typedef struct { - const unsigned char* cursor; - const unsigned char* end; -} _dataInput; - -typedef struct { - const char* parent; - const char* skin; - int slotIndex; - spMeshAttachment* mesh; -} _spLinkedMesh; - -typedef struct { - spSkeletonBinary super; - int ownsLoader; - - int linkedMeshCount; - int linkedMeshCapacity; - _spLinkedMesh* linkedMeshes; -} _spSkeletonBinary; - -spSkeletonBinary* spSkeletonBinary_createWithLoader (spAttachmentLoader* attachmentLoader) { - spSkeletonBinary* self = SUPER(NEW(_spSkeletonBinary)); - self->scale = 1; - self->attachmentLoader = attachmentLoader; - return self; -} - -spSkeletonBinary* spSkeletonBinary_create (spAtlas* atlas) { - spAtlasAttachmentLoader* attachmentLoader = spAtlasAttachmentLoader_create(atlas); - spSkeletonBinary* self = spSkeletonBinary_createWithLoader(SUPER(attachmentLoader)); - SUB_CAST(_spSkeletonBinary, self)->ownsLoader = 1; - return self; -} - -void spSkeletonBinary_dispose (spSkeletonBinary* self) { - int i; - _spSkeletonBinary* internal = SUB_CAST(_spSkeletonBinary, self); - if (internal->ownsLoader) spAttachmentLoader_dispose(self->attachmentLoader); - for (i = 0; i < internal->linkedMeshCount; ++i) { - FREE(internal->linkedMeshes[i].parent); - FREE(internal->linkedMeshes[i].skin); - } - FREE(internal->linkedMeshes); - FREE(self->error); - FREE(self); -} - -void _spSkeletonBinary_setError (spSkeletonBinary* self, const char* value1, const char* value2) { - char message[256]; - int length; - FREE(self->error); - strcpy(message, value1); - length = (int)strlen(value1); - if (value2) strncat(message + length, value2, 255 - length); - MALLOC_STR(self->error, message); -} - -static unsigned char readByte (_dataInput* input) { - return *input->cursor++; -} - -static signed char readSByte (_dataInput* input) { - return (signed char)readByte(input); -} - -static int readBoolean (_dataInput* input) { - return readByte(input) != 0; -} - -static int readInt (_dataInput* input) { - int result = readByte(input); - result <<= 8; - result |= readByte(input); - result <<= 8; - result |= readByte(input); - result <<= 8; - result |= readByte(input); - return result; -} - -static int readVarint (_dataInput* input, int/*bool*/optimizePositive) { - unsigned char b = readByte(input); - int value = b & 0x7F; - if (b & 0x80) { - b = readByte(input); - value |= (b & 0x7F) << 7; - if (b & 0x80) { - b = readByte(input); - value |= (b & 0x7F) << 14; - if (b & 0x80) { - b = readByte(input); - value |= (b & 0x7F) << 21; - if (b & 0x80) value |= (readByte(input) & 0x7F) << 28; - } - } - } - if (!optimizePositive) value = (((unsigned int)value >> 1) ^ -(value & 1)); - return value; -} - -float readFloat (_dataInput* input) { - union { - int intValue; - float floatValue; - } intToFloat; - intToFloat.intValue = readInt(input); - return intToFloat.floatValue; -} - -char* readString (_dataInput* input) { - int length = readVarint(input, 1); - char* string; - if (length == 0) { - return 0; - } - string = MALLOC(char, length); - memcpy(string, input->cursor, length - 1); - input->cursor += length - 1; - string[length - 1] = '\0'; - return string; -} - -static void readColor (_dataInput* input, float *r, float *g, float *b, float *a) { - *r = readByte(input) / 255.0f; - *g = readByte(input) / 255.0f; - *b = readByte(input) / 255.0f; - *a = readByte(input) / 255.0f; -} - -#define ATTACHMENT_REGION 0 -#define ATTACHMENT_BOUNDING_BOX 1 -#define ATTACHMENT_MESH 2 -#define ATTACHMENT_LINKED_MESH 3 -#define ATTACHMENT_PATH 4 - -#define BLEND_MODE_NORMAL 0 -#define BLEND_MODE_ADDITIVE 1 -#define BLEND_MODE_MULTIPLY 2 -#define BLEND_MODE_SCREEN 3 - -#define CURVE_LINEAR 0 -#define CURVE_STEPPED 1 -#define CURVE_BEZIER 2 - -#define BONE_ROTATE 0 -#define BONE_TRANSLATE 1 -#define BONE_SCALE 2 -#define BONE_SHEAR 3 - -#define SLOT_ATTACHMENT 0 -#define SLOT_COLOR 1 - -#define PATH_POSITION 0 -#define PATH_SPACING 1 -#define PATH_MIX 2 - -#define PATH_POSITION_FIXED 0 -#define PATH_POSITION_PERCENT 1 - -#define PATH_SPACING_LENGTH 0 -#define PATH_SPACING_FIXED 1 -#define PATH_SPACING_PERCENT 2 - -#define PATH_ROTATE_TANGENT 0 -#define PATH_ROTATE_CHAIN 1 -#define PATH_ROTATE_CHAIN_SCALE 2 - -static void readCurve (_dataInput* input, spCurveTimeline* timeline, int frameIndex) { - switch (readByte(input)) { - case CURVE_STEPPED: { - spCurveTimeline_setStepped(timeline, frameIndex); - break; - } - case CURVE_BEZIER: { - float cx1 = readFloat(input); - float cy1 = readFloat(input); - float cx2 = readFloat(input); - float cy2 = readFloat(input); - spCurveTimeline_setCurve(timeline, frameIndex, cx1, cy1, cx2, cy2); - break; - } - } -} - -static void _spSkeletonBinary_addLinkedMesh (spSkeletonBinary* self, spMeshAttachment* mesh, - const char* skin, int slotIndex, const char* parent) { - _spLinkedMesh* linkedMesh; - _spSkeletonBinary* internal = SUB_CAST(_spSkeletonBinary, self); - - if (internal->linkedMeshCount == internal->linkedMeshCapacity) { - _spLinkedMesh* linkedMeshes; - internal->linkedMeshCapacity *= 2; - if (internal->linkedMeshCapacity < 8) internal->linkedMeshCapacity = 8; - /* TODO Why not realloc? */ - linkedMeshes = MALLOC(_spLinkedMesh, internal->linkedMeshCapacity); - memcpy(linkedMeshes, internal->linkedMeshes, sizeof(_spLinkedMesh) * internal->linkedMeshCount); - FREE(internal->linkedMeshes); - internal->linkedMeshes = linkedMeshes; - } - - linkedMesh = internal->linkedMeshes + internal->linkedMeshCount++; - linkedMesh->mesh = mesh; - linkedMesh->skin = skin; - linkedMesh->slotIndex = slotIndex; - linkedMesh->parent = parent; -} - -static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, const char* name, - _dataInput* input, spSkeletonData *skeletonData) { - kvec_t(spTimeline*) timelines; - float duration = 0; - int i, n, ii, nn, iii, nnn; - int frameIndex; - int drawOrderCount, eventCount; - spAnimation* animation; - - kv_init(timelines); - - /* Slot timelines. */ - for (i = 0, n = readVarint(input, 1); i < n; ++i) { - int slotIndex = readVarint(input, 1); - for (ii = 0, nn = readVarint(input, 1); ii < nn; ++ii) { - unsigned char timelineType = readByte(input); - int frameCount = readVarint(input, 1); - switch (timelineType) { - case SLOT_COLOR: { - spColorTimeline* timeline = spColorTimeline_create(frameCount); - timeline->slotIndex = slotIndex; - for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) { - float time = readFloat(input); - float r, g, b, a; - readColor(input, &r, &g, &b, &a); - spColorTimeline_setFrame(timeline, frameIndex, time, r, g, b, a); - if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex); - } - kv_push(spTimeline*, timelines, SUPER(SUPER(timeline))); - duration = MAX(duration, timeline->frames[(frameCount - 1) * COLOR_ENTRIES]); - break; - } - case SLOT_ATTACHMENT: { - spAttachmentTimeline* timeline = spAttachmentTimeline_create(frameCount); - timeline->slotIndex = slotIndex; - for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) { - float time = readFloat(input); - const char* attachmentName = readString(input); - /* TODO Avoid copying of attachmentName inside */ - spAttachmentTimeline_setFrame(timeline, frameIndex, time, attachmentName); - FREE(attachmentName); - } - kv_push(spTimeline*, timelines, SUPER(timeline)); - duration = MAX(duration, timeline->frames[frameCount - 1]); - break; - } - default: { - int i; - for (i = 0; i < kv_size(timelines); ++i) - spTimeline_dispose(kv_A(timelines, i)); - kv_destroy(timelines); - _spSkeletonBinary_setError(self, "Invalid timeline type for a slot: ", skeletonData->slots[slotIndex]->name); - return 0; - } - } - } - } - - /* Bone timelines. */ - for (i = 0, n = readVarint(input, 1); i < n; ++i) { - int boneIndex = readVarint(input, 1); - for (ii = 0, nn = readVarint(input, 1); ii < nn; ++ii) { - unsigned char timelineType = readByte(input); - int frameCount = readVarint(input, 1); - switch (timelineType) { - case BONE_ROTATE: { - spRotateTimeline *timeline = spRotateTimeline_create(frameCount); - timeline->boneIndex = boneIndex; - for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) { - float time = readFloat(input); - float degrees = readFloat(input); - spRotateTimeline_setFrame(timeline, frameIndex, time, degrees); - if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex); - } - kv_push(spTimeline*, timelines, SUPER(SUPER(timeline))); - duration = MAX(duration, timeline->frames[(frameCount - 1) * ROTATE_ENTRIES]); - break; - } - case BONE_TRANSLATE: - case BONE_SCALE: - case BONE_SHEAR: { - float timelineScale = 1; - spTranslateTimeline *timeline = 0; - switch (timelineType) { - case BONE_SCALE: - timeline = spScaleTimeline_create(frameCount); - break; - case BONE_SHEAR: - timeline = spShearTimeline_create(frameCount); - break; - case BONE_TRANSLATE: - timeline = spTranslateTimeline_create(frameCount); - timelineScale = self->scale; - break; - default: - break; - } - timeline->boneIndex = boneIndex; - for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) { - float time = readFloat(input); - float x = readFloat(input) * timelineScale; - float y = readFloat(input) * timelineScale; - spTranslateTimeline_setFrame(timeline, frameIndex, time, x, y); - if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex); - } - kv_push(spTimeline*, timelines, SUPER_CAST(spTimeline, timeline)); - duration = MAX(duration, timeline->frames[(frameCount - 1) * TRANSLATE_ENTRIES]); - break; - } - default: { - int i; - for (i = 0; i < kv_size(timelines); ++i) - spTimeline_dispose(kv_A(timelines, i)); - kv_destroy(timelines); - _spSkeletonBinary_setError(self, "Invalid timeline type for a bone: ", skeletonData->bones[boneIndex]->name); - return 0; - } - } - } - } - - /* IK constraint timelines. */ - for (i = 0, n = readVarint(input, 1); i < n; ++i) { - int index = readVarint(input, 1); - int frameCount = readVarint(input, 1); - spIkConstraintTimeline* timeline = spIkConstraintTimeline_create(frameCount); - timeline->ikConstraintIndex = index; - for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) { - float time = readFloat(input); - float mix = readFloat(input); - signed char bendDirection = readSByte(input); - spIkConstraintTimeline_setFrame(timeline, frameIndex, time, mix, bendDirection); - if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex); - } - kv_push(spTimeline*, timelines, SUPER(SUPER(timeline))); - duration = MAX(duration, timeline->frames[(frameCount - 1) * IKCONSTRAINT_ENTRIES]); - } - - /* Transform constraint timelines. */ - for (i = 0, n = readVarint(input, 1); i < n; ++i) { - int index = readVarint(input, 1); - int frameCount = readVarint(input, 1); - spTransformConstraintTimeline* timeline = spTransformConstraintTimeline_create(frameCount); - timeline->transformConstraintIndex = index; - for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) { - float time = readFloat(input); - float rotateMix = readFloat(input); - float translateMix = readFloat(input); - float scaleMix = readFloat(input); - float shearMix = readFloat(input); - spTransformConstraintTimeline_setFrame(timeline, frameIndex, time, rotateMix, translateMix, - scaleMix, shearMix); - if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex); - } - kv_push(spTimeline*, timelines, SUPER(SUPER(timeline))); - duration = MAX(duration, timeline->frames[(frameCount - 1) * TRANSFORMCONSTRAINT_ENTRIES]); - } - - /* Path constraint timelines. */ - for (i = 0, n = readVarint(input, 1); i < n; ++i) { - int index = readVarint(input, 1); - spPathConstraintData* data = skeletonData->pathConstraints[index]; - for (ii = 0, nn = readVarint(input, 1); ii < nn; ++ii) { - unsigned char timelineType = readByte(input); - int frameCount = readVarint(input, 1); - switch (timelineType) { - case PATH_POSITION: - case PATH_SPACING: { - spPathConstraintPositionTimeline* timeline = 0; - float timelineScale = 1; - if (timelineType == PATH_SPACING) { - timeline = (spPathConstraintPositionTimeline*)spPathConstraintSpacingTimeline_create(frameCount); - if (data->spacingMode == SP_SPACING_MODE_LENGTH || data->spacingMode == SP_SPACING_MODE_FIXED) - timelineScale = self->scale; - } else { - timeline = spPathConstraintPositionTimeline_create(frameCount); - if (data->positionMode == SP_POSITION_MODE_FIXED) - timelineScale = self->scale; - } - timeline->pathConstraintIndex = index; - for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) { - float time = readFloat(input); - float value = readFloat(input) * timelineScale; - spPathConstraintPositionTimeline_setFrame(timeline, frameIndex, time, value); - if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex); - } - kv_push(spTimeline*, timelines, SUPER(SUPER(timeline))); - duration = MAX(duration, timeline->frames[(frameCount - 1) * PATHCONSTRAINTPOSITION_ENTRIES]); - break; - } - case PATH_MIX: { - spPathConstraintMixTimeline* timeline = spPathConstraintMixTimeline_create(frameCount); - timeline->pathConstraintIndex = index; - for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) { - float time = readFloat(input); - float rotateMix = readFloat(input); - float translateMix = readFloat(input); - spPathConstraintMixTimeline_setFrame(timeline, frameIndex, time, rotateMix, translateMix); - if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex); - } - kv_push(spTimeline*, timelines, SUPER(SUPER(timeline))); - duration = MAX(duration, timeline->frames[(frameCount - 1) * PATHCONSTRAINTMIX_ENTRIES]); - } - } - } - } - - /* Deform timelines. */ - for (i = 0, n = readVarint(input, 1); i < n; ++i) { - spSkin* skin = skeletonData->skins[readVarint(input, 1)]; - for (ii = 0, nn = readVarint(input, 1); ii < nn; ++ii) { - int slotIndex = readVarint(input, 1); - for (iii = 0, nnn = readVarint(input, 1); iii < nnn; ++iii) { - float* tempDeform; - spDeformTimeline *timeline; - int weighted, deformLength; - const char* attachmentName = readString(input); - int frameCount; - - spVertexAttachment* attachment = SUB_CAST(spVertexAttachment, - spSkin_getAttachment(skin, slotIndex, attachmentName)); - if (!attachment) { - int i; - for (i = 0; i < kv_size(timelines); ++i) - spTimeline_dispose(kv_A(timelines, i)); - kv_destroy(timelines); - _spSkeletonBinary_setError(self, "Attachment not found: ", attachmentName); - FREE(attachmentName); - return 0; - } - FREE(attachmentName); - - weighted = attachment->bones != 0; - deformLength = weighted ? attachment->verticesCount / 3 * 2 : attachment->verticesCount; - tempDeform = MALLOC(float, deformLength); - - frameCount = readVarint(input, 1); - timeline = spDeformTimeline_create(frameCount, deformLength); - timeline->slotIndex = slotIndex; - timeline->attachment = SUPER(attachment); - - for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) { - float time = readFloat(input); - float* deform; - int end = readVarint(input, 1); - if (!end) { - if (weighted) { - deform = tempDeform; - memset(deform, 0, sizeof(float) * deformLength); - } else - deform = attachment->vertices; - } else { - int v, start = readVarint(input, 1); - deform = tempDeform; - memset(deform, 0, sizeof(float) * start); - end += start; - if (self->scale == 1) { - for (v = start; v < end; ++v) - deform[v] = readFloat(input); - } else { - for (v = start; v < end; ++v) - deform[v] = readFloat(input) * self->scale; - } - memset(deform + v, 0, sizeof(float) * (deformLength - v)); - if (!weighted) { - float* vertices = attachment->vertices; - for (v = 0; v < deformLength; ++v) - deform[v] += vertices[v]; - } - } - spDeformTimeline_setFrame(timeline, frameIndex, time, deform); - if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex); - } - FREE(tempDeform); - - kv_push(spTimeline*, timelines, SUPER(SUPER(timeline))); - duration = MAX(duration, timeline->frames[frameCount - 1]); - } - } - } - - /* Draw order timeline. */ - drawOrderCount = readVarint(input, 1); - if (drawOrderCount) { - spDrawOrderTimeline* timeline = spDrawOrderTimeline_create(drawOrderCount, skeletonData->slotsCount); - for (i = 0; i < drawOrderCount; ++i) { - float time = readFloat(input); - int offsetCount = readVarint(input, 1); - int* drawOrder = MALLOC(int, skeletonData->slotsCount); - int* unchanged = MALLOC(int, skeletonData->slotsCount - offsetCount); - int originalIndex = 0, unchangedIndex = 0; - memset(drawOrder, -1, sizeof(int) * skeletonData->slotsCount); - for (ii = 0; ii < offsetCount; ++ii) { - int slotIndex = readVarint(input, 1); - /* Collect unchanged items. */ - while (originalIndex != slotIndex) - unchanged[unchangedIndex++] = originalIndex++; - /* Set changed items. */ - drawOrder[originalIndex + readVarint(input, 1)] = originalIndex; - ++originalIndex; - } - /* Collect remaining unchanged items. */ - while (originalIndex < skeletonData->slotsCount) - unchanged[unchangedIndex++] = originalIndex++; - /* Fill in unchanged items. */ - for (ii = skeletonData->slotsCount - 1; ii >= 0; ii--) - if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex]; - FREE(unchanged); - /* TODO Avoid copying of drawOrder inside */ - spDrawOrderTimeline_setFrame(timeline, i, time, drawOrder); - FREE(drawOrder); - } - kv_push(spTimeline*, timelines, SUPER(timeline)); - duration = MAX(duration, timeline->frames[drawOrderCount - 1]); - } - - /* Event timeline. */ - eventCount = readVarint(input, 1); - if (eventCount) { - spEventTimeline* timeline = spEventTimeline_create(eventCount); - for (i = 0; i < eventCount; ++i) { - float time = readFloat(input); - spEventData* eventData = skeletonData->events[readVarint(input, 1)]; - spEvent* event = spEvent_create(time, eventData); - event->intValue = readVarint(input, 0); - event->floatValue = readFloat(input); - if (readBoolean(input)) - event->stringValue = readString(input); - else - MALLOC_STR(event->stringValue, eventData->stringValue); - spEventTimeline_setFrame(timeline, i, event); - } - kv_push(spTimeline*, timelines, SUPER(timeline)); - duration = MAX(duration, timeline->frames[eventCount - 1]); - } - - kv_trim(spTimeline*, timelines); - - animation = spAnimation_create(name, 0); - FREE(animation->timelines); - animation->duration = duration; - animation->timelinesCount = kv_size(timelines); - animation->timelines = kv_array(timelines); - return animation; -} - -static float* _readFloatArray(_dataInput *input, int n, float scale) { - float* array = MALLOC(float, n); - int i; - if (scale == 1) - for (i = 0; i < n; ++i) - array[i] = readFloat(input); - else - for (i = 0; i < n; ++i) - array[i] = readFloat(input) * scale; - return array; -} - -static short* _readShortArray(_dataInput *input, int *length) { - int n = readVarint(input, 1); - short* array = MALLOC(short, n); - int i; - *length = n; - for (i = 0; i < n; ++i) { - array[i] = readByte(input) << 8; - array[i] |= readByte(input); - } - return array; -} - -static void _readVertices(spSkeletonBinary* self, _dataInput* input, spVertexAttachment* attachment, - int vertexCount) { - int i, ii; - int verticesLength = vertexCount << 1; - kvec_t(float) weights; - kvec_t(int) bones; - - attachment->worldVerticesLength = verticesLength; - - if (!readBoolean(input)) { - attachment->verticesCount = verticesLength; - attachment->vertices = _readFloatArray(input, verticesLength, self->scale); - attachment->bonesCount = 0; - attachment->bones = 0; - return; - } - - kv_init(weights); - kv_resize(float, weights, verticesLength * 3 * 3); - - kv_init(bones); - kv_resize(int, bones, verticesLength * 3); - - for (i = 0; i < vertexCount; ++i) { - int boneCount = readVarint(input, 1); - kv_push(int, bones, boneCount); - for (ii = 0; ii < boneCount; ++ii) { - kv_push(int, bones, readVarint(input, 1)); - kv_push(float, weights, readFloat(input) * self->scale); - kv_push(float, weights, readFloat(input) * self->scale); - kv_push(float, weights, readFloat(input)); - } - } - - kv_trim(float, weights); - attachment->verticesCount = kv_size(weights); - attachment->vertices = kv_array(weights); - - kv_trim(int, bones); - attachment->bonesCount = kv_size(bones); - attachment->bones = kv_array(bones); -} - -spAttachment* spSkeletonBinary_readAttachment(spSkeletonBinary* self, _dataInput* input, - spSkin* skin, int slotIndex, const char* attachmentName, int/*bool*/ nonessential) { - int i; - spAttachmentType type; - const char* name = readString(input); - int freeName = name != 0; - if (!name) { - freeName = 0; - name = attachmentName; - } - - type = (spAttachmentType)readByte(input); - - switch (type) { - case SP_ATTACHMENT_REGION: { - const char* path = readString(input); - spAttachment* attachment; - spRegionAttachment* region; - if (!path) MALLOC_STR(path, name); - attachment = spAttachmentLoader_createAttachment( - self->attachmentLoader, skin, type, name, path); - region = SUB_CAST(spRegionAttachment, attachment); - region->path = path; - region->rotation = readFloat(input); - region->x = readFloat(input) * self->scale; - region->y = readFloat(input) * self->scale; - region->scaleX = readFloat(input); - region->scaleY = readFloat(input); - region->width = readFloat(input) * self->scale; - region->height = readFloat(input) * self->scale; - readColor(input, ®ion->r, ®ion->g, ®ion->b, ®ion->a); - spRegionAttachment_updateOffset(region); - spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment); - if (freeName) FREE(name); - return attachment; - } - case SP_ATTACHMENT_BOUNDING_BOX: { - int vertexCount = readVarint(input, 1); - spAttachment* attachment = spAttachmentLoader_createAttachment( - self->attachmentLoader, skin, type, name, 0); - _readVertices(self, input, SUB_CAST(spVertexAttachment, attachment), vertexCount); - if (nonessential) readInt(input); /* Skip color. */ - spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment); - if (freeName) FREE(name); - return attachment; - } - case SP_ATTACHMENT_MESH: { - int vertexCount; - spAttachment* attachment; - spMeshAttachment* mesh; - const char* path = readString(input); - if (!path) MALLOC_STR(path, name); - attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path); - mesh = SUB_CAST(spMeshAttachment, attachment); - mesh->path = path; - readColor(input, &mesh->r, &mesh->g, &mesh->b, &mesh->a); - vertexCount = readVarint(input, 1); - mesh->regionUVs = _readFloatArray(input, vertexCount << 1, 1); - mesh->triangles = (unsigned short*)_readShortArray(input, &mesh->trianglesCount); - _readVertices(self, input, SUPER(mesh), vertexCount); - spMeshAttachment_updateUVs(mesh); - mesh->hullLength = readVarint(input, 1) << 1; - if (nonessential) { - mesh->edges = (int*)_readShortArray(input, &mesh->edgesCount); - mesh->width = readFloat(input) * self->scale; - mesh->height = readFloat(input) * self->scale; - } else { - mesh->edges = 0; - mesh->width = 0; - mesh->height = 0; - } - spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment); - if (freeName) FREE(name); - return attachment; - } - case SP_ATTACHMENT_LINKED_MESH: { - const char* skinName; - const char* parent; - spAttachment* attachment; - spMeshAttachment* mesh; - const char* path = readString(input); - if (!path) MALLOC_STR(path, name); - attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path); - mesh = SUB_CAST(spMeshAttachment, attachment); - mesh->path = path; - readColor(input, &mesh->r, &mesh->g, &mesh->b, &mesh->a); - skinName = readString(input); - parent = readString(input); - mesh->inheritDeform = readBoolean(input); - if (nonessential) { - mesh->width = readFloat(input) * self->scale; - mesh->height = readFloat(input) * self->scale; - } - _spSkeletonBinary_addLinkedMesh(self, mesh, skinName, slotIndex, parent); - if (freeName) FREE(name); - return attachment; - } - case SP_ATTACHMENT_PATH: { - spAttachment* attachment = spAttachmentLoader_createAttachment( - self->attachmentLoader, skin, type, name, 0); - spPathAttachment* path = SUB_CAST(spPathAttachment, attachment); - int vertexCount = 0; - path->closed = readBoolean(input); - path->constantSpeed = readBoolean(input); - vertexCount = readVarint(input, 1); - _readVertices(self, input, SUPER(path), vertexCount); - path->lengthsLength = vertexCount / 3; - path->lengths = MALLOC(float, path->lengthsLength); - for (i = 0; i < path->lengthsLength; ++i) { - path->lengths[i] = readFloat(input) * self->scale; - } - if (nonessential) readInt(input); /* Skip color. */ - if (freeName) FREE(name); - return attachment; - } - } - - if (freeName) FREE(name); - return 0; -} - -spSkin* spSkeletonBinary_readSkin(spSkeletonBinary* self, _dataInput* input, - const char* skinName, int/*bool*/ nonessential) { - spSkin* skin; - int slotCount = readVarint(input, 1); - int i, ii, nn; - if (slotCount == 0) - return 0; - skin = spSkin_create(skinName); - for (i = 0; i < slotCount; ++i) { - int slotIndex = readVarint(input, 1); - for (ii = 0, nn = readVarint(input, 1); ii < nn; ++ii) { - const char* name = readString(input); - spAttachment* attachment = spSkeletonBinary_readAttachment(self, input, skin, slotIndex, name, nonessential); - if (attachment) spSkin_addAttachment(skin, slotIndex, name, attachment); - FREE(name); - } - } - return skin; -} - -spSkeletonData* spSkeletonBinary_readSkeletonDataFile (spSkeletonBinary* self, const char* path) { - int length; - spSkeletonData* skeletonData; - const char* binary = _spUtil_readFile(path, &length); - if (length == 0 || !binary) { - _spSkeletonBinary_setError(self, "Unable to read skeleton file: ", path); - return 0; - } - skeletonData = spSkeletonBinary_readSkeletonData(self, (unsigned char*)binary, length); - FREE(binary); - return skeletonData; -} - -spSkeletonData* spSkeletonBinary_readSkeletonData (spSkeletonBinary* self, const unsigned char* binary, - const int length) { - int i, ii, nonessential; - spSkeletonData* skeletonData; - _spSkeletonBinary* internal = SUB_CAST(_spSkeletonBinary, self); - - _dataInput* input = NEW(_dataInput); - input->cursor = binary; - input->end = binary + length; - - FREE(self->error); - CONST_CAST(char*, self->error) = 0; - internal->linkedMeshCount = 0; - - skeletonData = spSkeletonData_create(); - - skeletonData->hash = readString(input); - if (!strlen(skeletonData->hash)) { - FREE(skeletonData->hash); - skeletonData->hash = 0; - } - - skeletonData->version = readString(input); - if (!strlen(skeletonData->version)) { - FREE(skeletonData->version); - skeletonData->version = 0; - } - - skeletonData->width = readFloat(input); - skeletonData->height = readFloat(input); - - nonessential = readBoolean(input); - - if (nonessential) { - /* Skip images path & fps */ - readFloat(input); - FREE(readString(input)); - } - - /* Bones. */ - skeletonData->bonesCount = readVarint(input, 1); - skeletonData->bones = MALLOC(spBoneData*, skeletonData->bonesCount); - for (i = 0; i < skeletonData->bonesCount; ++i) { - spBoneData* data; - int mode; - const char* name = readString(input); - spBoneData* parent = i == 0 ? 0 : skeletonData->bones[readVarint(input, 1)]; - /* TODO Avoid copying of name */ - data = spBoneData_create(i, name, parent); - FREE(name); - data->rotation = readFloat(input); - data->x = readFloat(input) * self->scale; - data->y = readFloat(input) * self->scale; - data->scaleX = readFloat(input); - data->scaleY = readFloat(input); - data->shearX = readFloat(input); - data->shearY = readFloat(input); - data->length = readFloat(input) * self->scale; - mode = readVarint(input, 1); - switch (mode) { - case 0: data->transformMode = SP_TRANSFORMMODE_NORMAL; break; - case 1: data->transformMode = SP_TRANSFORMMODE_ONLYTRANSLATION; break; - case 2: data->transformMode = SP_TRANSFORMMODE_NOROTATIONORREFLECTION; break; - case 3: data->transformMode = SP_TRANSFORMMODE_NOSCALE; break; - case 4: data->transformMode = SP_TRANSFORMMODE_NOSCALEORREFLECTION; break; - } - if (nonessential) readInt(input); /* Skip bone color. */ - skeletonData->bones[i] = data; - } - - /* Slots. */ - skeletonData->slotsCount = readVarint(input, 1); - skeletonData->slots = MALLOC(spSlotData*, skeletonData->slotsCount); - for (i = 0; i < skeletonData->slotsCount; ++i) { - const char* slotName = readString(input); - spBoneData* boneData = skeletonData->bones[readVarint(input, 1)]; - /* TODO Avoid copying of slotName */ - spSlotData* slotData = spSlotData_create(i, slotName, boneData); - FREE(slotName); - readColor(input, &slotData->r, &slotData->g, &slotData->b, &slotData->a); - slotData->attachmentName = readString(input); - slotData->blendMode = (spBlendMode)readVarint(input, 1); - skeletonData->slots[i] = slotData; - } - - /* IK constraints. */ - skeletonData->ikConstraintsCount = readVarint(input, 1); - skeletonData->ikConstraints = MALLOC(spIkConstraintData*, skeletonData->ikConstraintsCount); - for (i = 0; i < skeletonData->ikConstraintsCount; ++i) { - const char* name = readString(input); - /* TODO Avoid copying of name */ - spIkConstraintData* data = spIkConstraintData_create(name); - data->order = readVarint(input, 1); - FREE(name); - data->bonesCount = readVarint(input, 1); - data->bones = MALLOC(spBoneData*, data->bonesCount); - for (ii = 0; ii < data->bonesCount; ++ii) - data->bones[ii] = skeletonData->bones[readVarint(input, 1)]; - data->target = skeletonData->bones[readVarint(input, 1)]; - data->mix = readFloat(input); - data->bendDirection = readSByte(input); - skeletonData->ikConstraints[i] = data; - } - - /* Transform constraints. */ - skeletonData->transformConstraintsCount = readVarint(input, 1); - skeletonData->transformConstraints = MALLOC( - spTransformConstraintData*, skeletonData->transformConstraintsCount); - for (i = 0; i < skeletonData->transformConstraintsCount; ++i) { - const char* name = readString(input); - /* TODO Avoid copying of name */ - spTransformConstraintData* data = spTransformConstraintData_create(name); - data->order = readVarint(input, 1); - FREE(name); - data->bonesCount = readVarint(input, 1); - CONST_CAST(spBoneData**, data->bones) = MALLOC(spBoneData*, data->bonesCount); - for (ii = 0; ii < data->bonesCount; ++ii) - data->bones[ii] = skeletonData->bones[readVarint(input, 1)]; - data->target = skeletonData->bones[readVarint(input, 1)]; - data->offsetRotation = readFloat(input); - data->offsetX = readFloat(input) * self->scale; - data->offsetY = readFloat(input) * self->scale; - data->offsetScaleX = readFloat(input); - data->offsetScaleY = readFloat(input); - data->offsetShearY = readFloat(input); - data->rotateMix = readFloat(input); - data->translateMix = readFloat(input); - data->scaleMix = readFloat(input); - data->shearMix = readFloat(input); - skeletonData->transformConstraints[i] = data; - } - - /* Path constraints */ - skeletonData->pathConstraintsCount = readVarint(input, 1); - skeletonData->pathConstraints = MALLOC(spPathConstraintData*, skeletonData->pathConstraintsCount); - for (i = 0; i < skeletonData->pathConstraintsCount; ++i) { - const char* name = readString(input); - /* TODO Avoid copying of name */ - spPathConstraintData* data = spPathConstraintData_create(name); - data->order = readVarint(input, 1); - FREE(name); - data->bonesCount = readVarint(input, 1); - CONST_CAST(spBoneData**, data->bones) = MALLOC(spBoneData*, data->bonesCount); - for (ii = 0; ii < data->bonesCount; ++ii) - data->bones[ii] = skeletonData->bones[readVarint(input, 1)]; - data->target = skeletonData->slots[readVarint(input, 1)]; - data->positionMode = (spPositionMode)readVarint(input, 1); - data->spacingMode = (spSpacingMode)readVarint(input, 1); - data->rotateMode = (spRotateMode)readVarint(input, 1); - data->offsetRotation = readFloat(input); - data->position = readFloat(input); - if (data->positionMode == SP_POSITION_MODE_FIXED) data->position *= self->scale; - data->spacing = readFloat(input); - if (data->spacingMode == SP_SPACING_MODE_LENGTH || data->spacingMode == SP_SPACING_MODE_FIXED) data->spacing *= self->scale; - data->rotateMix = readFloat(input); - data->translateMix = readFloat(input); - skeletonData->pathConstraints[i] = data; - } - - /* Default skin. */ - skeletonData->defaultSkin = spSkeletonBinary_readSkin(self, input, "default", nonessential); - skeletonData->skinsCount = readVarint(input, 1); - - if (skeletonData->defaultSkin) - ++skeletonData->skinsCount; - - skeletonData->skins = MALLOC(spSkin*, skeletonData->skinsCount); - - if (skeletonData->defaultSkin) - skeletonData->skins[0] = skeletonData->defaultSkin; - - /* Skins. */ - for (i = skeletonData->defaultSkin ? 1 : 0; i < skeletonData->skinsCount; ++i) { - const char* skinName = readString(input); - /* TODO Avoid copying of skinName */ - skeletonData->skins[i] = spSkeletonBinary_readSkin(self, input, skinName, nonessential); - FREE(skinName); - } - - /* Linked meshes. */ - for (i = 0; i < internal->linkedMeshCount; ++i) { - _spLinkedMesh* linkedMesh = internal->linkedMeshes + i; - spSkin* skin = !linkedMesh->skin ? skeletonData->defaultSkin : spSkeletonData_findSkin(skeletonData, linkedMesh->skin); - spAttachment* parent; - if (!skin) { - FREE(input); - spSkeletonData_dispose(skeletonData); - _spSkeletonBinary_setError(self, "Skin not found: ", linkedMesh->skin); - return 0; - } - parent = spSkin_getAttachment(skin, linkedMesh->slotIndex, linkedMesh->parent); - if (!parent) { - FREE(input); - spSkeletonData_dispose(skeletonData); - _spSkeletonBinary_setError(self, "Parent mesh not found: ", linkedMesh->parent); - return 0; - } - spMeshAttachment_setParentMesh(linkedMesh->mesh, SUB_CAST(spMeshAttachment, parent)); - spMeshAttachment_updateUVs(linkedMesh->mesh); - spAttachmentLoader_configureAttachment(self->attachmentLoader, SUPER(SUPER(linkedMesh->mesh))); - } - - /* Events. */ - skeletonData->eventsCount = readVarint(input, 1); - skeletonData->events = MALLOC(spEventData*, skeletonData->eventsCount); - for (i = 0; i < skeletonData->eventsCount; ++i) { - const char* name = readString(input); - /* TODO Avoid copying of skinName */ - spEventData* eventData = spEventData_create(name); - FREE(name); - eventData->intValue = readVarint(input, 0); - eventData->floatValue = readFloat(input); - eventData->stringValue = readString(input); - skeletonData->events[i] = eventData; - } - - /* Animations. */ - skeletonData->animationsCount = readVarint(input, 1); - skeletonData->animations = MALLOC(spAnimation*, skeletonData->animationsCount); - for (i = 0; i < skeletonData->animationsCount; ++i) { - const char* name = readString(input); - spAnimation* animation = _spSkeletonBinary_readAnimation(self, name, input, skeletonData); - FREE(name); - if (!animation) { - FREE(input); - spSkeletonData_dispose(skeletonData); - return 0; - } - skeletonData->animations[i] = animation; - } - - FREE(input); - return skeletonData; -} diff --git a/native/cocos/editor-support/spine/SkeletonBinary.h b/native/cocos/editor-support/spine/SkeletonBinary.h deleted file mode 100644 index 7a84382e1d..0000000000 --- a/native/cocos/editor-support/spine/SkeletonBinary.h +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SKELETONBINARY_H_ -#define SPINE_SKELETONBINARY_H_ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct spAtlasAttachmentLoader; - -typedef struct spSkeletonBinary { - float scale; - spAttachmentLoader* attachmentLoader; - const char* const error; -} spSkeletonBinary; - -spSkeletonBinary* spSkeletonBinary_createWithLoader (spAttachmentLoader* attachmentLoader); -spSkeletonBinary* spSkeletonBinary_create (spAtlas* atlas); -void spSkeletonBinary_dispose (spSkeletonBinary* self); - -spSkeletonData* spSkeletonBinary_readSkeletonData (spSkeletonBinary* self, const unsigned char* binary, const int length); -spSkeletonData* spSkeletonBinary_readSkeletonDataFile (spSkeletonBinary* self, const char* path); - -#ifdef SPINE_SHORT_NAMES -typedef spSkeletonBinary SkeletonBinary; -#define SkeletonBinary_createWithLoader(...) spSkeletonBinary_createWithLoader(__VA_ARGS__) -#define SkeletonBinary_create(...) spSkeletonBinary_create(__VA_ARGS__) -#define SkeletonBinary_dispose(...) spSkeletonBinary_dispose(__VA_ARGS__) -#define SkeletonBinary_readSkeletonData(...) spSkeletonBinary_readSkeletonData(__VA_ARGS__) -#define SkeletonBinary_readSkeletonDataFile(...) spSkeletonBinary_readSkeletonDataFile(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_SKELETONBINARY_H_ */ diff --git a/native/cocos/editor-support/spine/SkeletonBounds.c b/native/cocos/editor-support/spine/SkeletonBounds.c deleted file mode 100644 index 5b6ac964a0..0000000000 --- a/native/cocos/editor-support/spine/SkeletonBounds.c +++ /dev/null @@ -1,205 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include - -spPolygon* spPolygon_create (int capacity) { - spPolygon* self = NEW(spPolygon); - self->capacity = capacity; - CONST_CAST(float*, self->vertices) = MALLOC(float, capacity); - return self; -} - -void spPolygon_dispose (spPolygon* self) { - FREE(self->vertices); - FREE(self); -} - -int/*bool*/spPolygon_containsPoint (spPolygon* self, float x, float y) { - int prevIndex = self->count - 2; - int inside = 0; - int i; - for (i = 0; i < self->count; i += 2) { - float vertexY = self->vertices[i + 1]; - float prevY = self->vertices[prevIndex + 1]; - if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { - float vertexX = self->vertices[i]; - if (vertexX + (y - vertexY) / (prevY - vertexY) * (self->vertices[prevIndex] - vertexX) < x) inside = !inside; - } - prevIndex = i; - } - return inside; -} - -int/*bool*/spPolygon_intersectsSegment (spPolygon* self, float x1, float y1, float x2, float y2) { - float width12 = x1 - x2, height12 = y1 - y2; - float det1 = x1 * y2 - y1 * x2; - float x3 = self->vertices[self->count - 2], y3 = self->vertices[self->count - 1]; - int i; - for (i = 0; i < self->count; i += 2) { - float x4 = self->vertices[i], y4 = self->vertices[i + 1]; - float det2 = x3 * y4 - y3 * x4; - float width34 = x3 - x4, height34 = y3 - y4; - float det3 = width12 * height34 - height12 * width34; - float x = (det1 * width34 - width12 * det2) / det3; - if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { - float y = (det1 * height34 - height12 * det2) / det3; - if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) return 1; - } - x3 = x4; - y3 = y4; - } - return 0; -} - -/**/ - -typedef struct { - spSkeletonBounds super; - int capacity; -} _spSkeletonBounds; - -spSkeletonBounds* spSkeletonBounds_create () { - return SUPER(NEW(_spSkeletonBounds)); -} - -void spSkeletonBounds_dispose (spSkeletonBounds* self) { - int i; - for (i = 0; i < SUB_CAST(_spSkeletonBounds, self)->capacity; ++i) - if (self->polygons[i]) spPolygon_dispose(self->polygons[i]); - FREE(self->polygons); - FREE(self->boundingBoxes); - FREE(self); -} - -void spSkeletonBounds_update (spSkeletonBounds* self, spSkeleton* skeleton, int/*bool*/updateAabb) { - int i; - - _spSkeletonBounds* internal = SUB_CAST(_spSkeletonBounds, self); - if (internal->capacity < skeleton->slotsCount) { - spPolygon** newPolygons; - - FREE(self->boundingBoxes); - self->boundingBoxes = MALLOC(spBoundingBoxAttachment*, skeleton->slotsCount); - - newPolygons = CALLOC(spPolygon*, skeleton->slotsCount); - memcpy(newPolygons, self->polygons, sizeof(spPolygon*) * internal->capacity); - FREE(self->polygons); - self->polygons = newPolygons; - - internal->capacity = skeleton->slotsCount; - } - - self->minX = (float)INT_MAX; - self->minY = (float)INT_MAX; - self->maxX = (float)INT_MIN; - self->maxY = (float)INT_MIN; - - self->count = 0; - for (i = 0; i < skeleton->slotsCount; ++i) { - spPolygon* polygon; - spBoundingBoxAttachment* boundingBox; - - spSlot* slot = skeleton->slots[i]; - spAttachment* attachment = slot->attachment; - if (!attachment || attachment->type != SP_ATTACHMENT_BOUNDING_BOX) continue; - boundingBox = (spBoundingBoxAttachment*)attachment; - self->boundingBoxes[self->count] = boundingBox; - - polygon = self->polygons[self->count]; - if (!polygon || polygon->capacity < boundingBox->super.worldVerticesLength) { - if (polygon) spPolygon_dispose(polygon); - self->polygons[self->count] = polygon = spPolygon_create(boundingBox->super.worldVerticesLength); - } - polygon->count = boundingBox->super.worldVerticesLength; - spBoundingBoxAttachment_computeWorldVertices(boundingBox, slot, polygon->vertices); - - if (updateAabb) { - int ii = 0; - for (; ii < polygon->count; ii += 2) { - float x = polygon->vertices[ii]; - float y = polygon->vertices[ii + 1]; - if (x < self->minX) self->minX = x; - if (y < self->minY) self->minY = y; - if (x > self->maxX) self->maxX = x; - if (y > self->maxY) self->maxY = y; - } - } - - self->count++; - } -} - -int/*bool*/spSkeletonBounds_aabbContainsPoint (spSkeletonBounds* self, float x, float y) { - return x >= self->minX && x <= self->maxX && y >= self->minY && y <= self->maxY; -} - -int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2) { - float m, x, y; - if ((x1 <= self->minX && x2 <= self->minX) || (y1 <= self->minY && y2 <= self->minY) || (x1 >= self->maxX && x2 >= self->maxX) - || (y1 >= self->maxY && y2 >= self->maxY)) return 0; - m = (y2 - y1) / (x2 - x1); - y = m * (self->minX - x1) + y1; - if (y > self->minY && y < self->maxY) return 1; - y = m * (self->maxX - x1) + y1; - if (y > self->minY && y < self->maxY) return 1; - x = (self->minY - y1) / m + x1; - if (x > self->minX && x < self->maxX) return 1; - x = (self->maxY - y1) / m + x1; - if (x > self->minX && x < self->maxX) return 1; - return 0; -} - -int/*bool*/spSkeletonBounds_aabbIntersectsSkeleton (spSkeletonBounds* self, spSkeletonBounds* bounds) { - return self->minX < bounds->maxX && self->maxX > bounds->minX && self->minY < bounds->maxY && self->maxY > bounds->minY; -} - -spBoundingBoxAttachment* spSkeletonBounds_containsPoint (spSkeletonBounds* self, float x, float y) { - int i; - for (i = 0; i < self->count; ++i) - if (spPolygon_containsPoint(self->polygons[i], x, y)) return self->boundingBoxes[i]; - return 0; -} - -spBoundingBoxAttachment* spSkeletonBounds_intersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2) { - int i; - for (i = 0; i < self->count; ++i) - if (spPolygon_intersectsSegment(self->polygons[i], x1, y1, x2, y2)) return self->boundingBoxes[i]; - return 0; -} - -spPolygon* spSkeletonBounds_getPolygon (spSkeletonBounds* self, spBoundingBoxAttachment* boundingBox) { - int i; - for (i = 0; i < self->count; ++i) - if (self->boundingBoxes[i] == boundingBox) return self->polygons[i]; - return 0; -} diff --git a/native/cocos/editor-support/spine/SkeletonBounds.h b/native/cocos/editor-support/spine/SkeletonBounds.h deleted file mode 100644 index 83add8fcc9..0000000000 --- a/native/cocos/editor-support/spine/SkeletonBounds.h +++ /dev/null @@ -1,112 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SKELETONBOUNDS_H_ -#define SPINE_SKELETONBOUNDS_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spPolygon { - float* const vertices; - int count; - int capacity; -} spPolygon; - -spPolygon* spPolygon_create (int capacity); -void spPolygon_dispose (spPolygon* self); - -int/*bool*/spPolygon_containsPoint (spPolygon* polygon, float x, float y); -int/*bool*/spPolygon_intersectsSegment (spPolygon* polygon, float x1, float y1, float x2, float y2); - -#ifdef SPINE_SHORT_NAMES -typedef spPolygon Polygon; -#define Polygon_create(...) spPolygon_create(__VA_ARGS__) -#define Polygon_dispose(...) spPolygon_dispose(__VA_ARGS__) -#define Polygon_containsPoint(...) spPolygon_containsPoint(__VA_ARGS__) -#define Polygon_intersectsSegment(...) spPolygon_intersectsSegment(__VA_ARGS__) -#endif - -/**/ - -typedef struct spSkeletonBounds { - int count; - spBoundingBoxAttachment** boundingBoxes; - spPolygon** polygons; - - float minX, minY, maxX, maxY; -} spSkeletonBounds; - -spSkeletonBounds* spSkeletonBounds_create (); -void spSkeletonBounds_dispose (spSkeletonBounds* self); -void spSkeletonBounds_update (spSkeletonBounds* self, spSkeleton* skeleton, int/*bool*/updateAabb); - -/** Returns true if the axis aligned bounding box contains the point. */ -int/*bool*/spSkeletonBounds_aabbContainsPoint (spSkeletonBounds* self, float x, float y); - -/** Returns true if the axis aligned bounding box intersects the line segment. */ -int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2); - -/** Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds. */ -int/*bool*/spSkeletonBounds_aabbIntersectsSkeleton (spSkeletonBounds* self, spSkeletonBounds* bounds); - -/** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more - * efficient to only call this method if spSkeletonBounds_aabbContainsPoint returns true. */ -spBoundingBoxAttachment* spSkeletonBounds_containsPoint (spSkeletonBounds* self, float x, float y); - -/** Returns the first bounding box attachment that contains the line segment, or null. When doing many checks, it is usually - * more efficient to only call this method if spSkeletonBounds_aabbIntersectsSegment returns true. */ -spBoundingBoxAttachment* spSkeletonBounds_intersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2); - -/** Returns the polygon for the specified bounding box, or null. */ -spPolygon* spSkeletonBounds_getPolygon (spSkeletonBounds* self, spBoundingBoxAttachment* boundingBox); - -#ifdef SPINE_SHORT_NAMES -typedef spSkeletonBounds SkeletonBounds; -#define SkeletonBounds_create(...) spSkeletonBounds_create(__VA_ARGS__) -#define SkeletonBounds_dispose(...) spSkeletonBounds_dispose(__VA_ARGS__) -#define SkeletonBounds_update(...) spSkeletonBounds_update(__VA_ARGS__) -#define SkeletonBounds_aabbContainsPoint(...) spSkeletonBounds_aabbContainsPoint(__VA_ARGS__) -#define SkeletonBounds_aabbIntersectsSegment(...) spSkeletonBounds_aabbIntersectsSegment(__VA_ARGS__) -#define SkeletonBounds_aabbIntersectsSkeleton(...) spSkeletonBounds_aabbIntersectsSkeleton(__VA_ARGS__) -#define SkeletonBounds_containsPoint(...) spSkeletonBounds_containsPoint(__VA_ARGS__) -#define SkeletonBounds_intersectsSegment(...) spSkeletonBounds_intersectsSegment(__VA_ARGS__) -#define SkeletonBounds_getPolygon(...) spSkeletonBounds_getPolygon(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_SKELETONBOUNDS_H_ */ diff --git a/native/cocos/editor-support/spine/SkeletonData.c b/native/cocos/editor-support/spine/SkeletonData.c deleted file mode 100644 index 9db2c03067..0000000000 --- a/native/cocos/editor-support/spine/SkeletonData.c +++ /dev/null @@ -1,147 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include - -spSkeletonData* spSkeletonData_create () { - return NEW(spSkeletonData); -} - -void spSkeletonData_dispose (spSkeletonData* self) { - int i; - for (i = 0; i < self->bonesCount; ++i) - spBoneData_dispose(self->bones[i]); - FREE(self->bones); - - for (i = 0; i < self->slotsCount; ++i) - spSlotData_dispose(self->slots[i]); - FREE(self->slots); - - for (i = 0; i < self->skinsCount; ++i) - spSkin_dispose(self->skins[i]); - FREE(self->skins); - - for (i = 0; i < self->eventsCount; ++i) - spEventData_dispose(self->events[i]); - FREE(self->events); - - for (i = 0; i < self->animationsCount; ++i) - spAnimation_dispose(self->animations[i]); - FREE(self->animations); - - for (i = 0; i < self->ikConstraintsCount; ++i) - spIkConstraintData_dispose(self->ikConstraints[i]); - FREE(self->ikConstraints); - - for (i = 0; i < self->transformConstraintsCount; ++i) - spTransformConstraintData_dispose(self->transformConstraints[i]); - FREE(self->transformConstraints); - - for (i = 0; i < self->pathConstraintsCount; i++) - spPathConstraintData_dispose(self->pathConstraints[i]); - FREE(self->pathConstraints); - - FREE(self->hash); - FREE(self->version); - - FREE(self); -} - -spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName) { - int i; - for (i = 0; i < self->bonesCount; ++i) - if (strcmp(self->bones[i]->name, boneName) == 0) return self->bones[i]; - return 0; -} - -int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName) { - int i; - for (i = 0; i < self->bonesCount; ++i) - if (strcmp(self->bones[i]->name, boneName) == 0) return i; - return -1; -} - -spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName) { - int i; - for (i = 0; i < self->slotsCount; ++i) - if (strcmp(self->slots[i]->name, slotName) == 0) return self->slots[i]; - return 0; -} - -int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName) { - int i; - for (i = 0; i < self->slotsCount; ++i) - if (strcmp(self->slots[i]->name, slotName) == 0) return i; - return -1; -} - -spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName) { - int i; - for (i = 0; i < self->skinsCount; ++i) - if (strcmp(self->skins[i]->name, skinName) == 0) return self->skins[i]; - return 0; -} - -spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName) { - int i; - for (i = 0; i < self->eventsCount; ++i) - if (strcmp(self->events[i]->name, eventName) == 0) return self->events[i]; - return 0; -} - -spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName) { - int i; - for (i = 0; i < self->animationsCount; ++i) - if (strcmp(self->animations[i]->name, animationName) == 0) return self->animations[i]; - return 0; -} - -spIkConstraintData* spSkeletonData_findIkConstraint (const spSkeletonData* self, const char* constraintName) { - int i; - for (i = 0; i < self->ikConstraintsCount; ++i) - if (strcmp(self->ikConstraints[i]->name, constraintName) == 0) return self->ikConstraints[i]; - return 0; -} - -spTransformConstraintData* spSkeletonData_findTransformConstraint (const spSkeletonData* self, const char* constraintName) { - int i; - for (i = 0; i < self->transformConstraintsCount; ++i) - if (strcmp(self->transformConstraints[i]->name, constraintName) == 0) return self->transformConstraints[i]; - return 0; -} - -spPathConstraintData* spSkeletonData_findPathConstraint (const spSkeletonData* self, const char* constraintName) { - int i; - for (i = 0; i < self->pathConstraintsCount; ++i) - if (strcmp(self->pathConstraints[i]->name, constraintName) == 0) return self->pathConstraints[i]; - return 0; -} diff --git a/native/cocos/editor-support/spine/SkeletonData.h b/native/cocos/editor-support/spine/SkeletonData.h deleted file mode 100644 index 4245100ca2..0000000000 --- a/native/cocos/editor-support/spine/SkeletonData.h +++ /dev/null @@ -1,116 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SKELETONDATA_H_ -#define SPINE_SKELETONDATA_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spSkeletonData { - const char* version; - const char* hash; - float width, height; - - int bonesCount; - spBoneData** bones; - - int slotsCount; - spSlotData** slots; - - int skinsCount; - spSkin** skins; - spSkin* defaultSkin; - - int eventsCount; - spEventData** events; - - int animationsCount; - spAnimation** animations; - - int ikConstraintsCount; - spIkConstraintData** ikConstraints; - - int transformConstraintsCount; - spTransformConstraintData** transformConstraints; - - int pathConstraintsCount; - spPathConstraintData** pathConstraints; -} spSkeletonData; - -spSkeletonData* spSkeletonData_create (); -void spSkeletonData_dispose (spSkeletonData* self); - -spBoneData* spSkeletonData_findBone (const spSkeletonData* self, const char* boneName); -int spSkeletonData_findBoneIndex (const spSkeletonData* self, const char* boneName); - -spSlotData* spSkeletonData_findSlot (const spSkeletonData* self, const char* slotName); -int spSkeletonData_findSlotIndex (const spSkeletonData* self, const char* slotName); - -spSkin* spSkeletonData_findSkin (const spSkeletonData* self, const char* skinName); - -spEventData* spSkeletonData_findEvent (const spSkeletonData* self, const char* eventName); - -spAnimation* spSkeletonData_findAnimation (const spSkeletonData* self, const char* animationName); - -spIkConstraintData* spSkeletonData_findIkConstraint (const spSkeletonData* self, const char* constraintName); - -spTransformConstraintData* spSkeletonData_findTransformConstraint (const spSkeletonData* self, const char* constraintName); - -spPathConstraintData* spSkeletonData_findPathConstraint (const spSkeletonData* self, const char* constraintName); - -#ifdef SPINE_SHORT_NAMES -typedef spSkeletonData SkeletonData; -#define SkeletonData_create(...) spSkeletonData_create(__VA_ARGS__) -#define SkeletonData_dispose(...) spSkeletonData_dispose(__VA_ARGS__) -#define SkeletonData_findBone(...) spSkeletonData_findBone(__VA_ARGS__) -#define SkeletonData_findBoneIndex(...) spSkeletonData_findBoneIndex(__VA_ARGS__) -#define SkeletonData_findSlot(...) spSkeletonData_findSlot(__VA_ARGS__) -#define SkeletonData_findSlotIndex(...) spSkeletonData_findSlotIndex(__VA_ARGS__) -#define SkeletonData_findSkin(...) spSkeletonData_findSkin(__VA_ARGS__) -#define SkeletonData_findEvent(...) spSkeletonData_findEvent(__VA_ARGS__) -#define SkeletonData_findAnimation(...) spSkeletonData_findAnimation(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_SKELETONDATA_H_ */ diff --git a/native/cocos/editor-support/spine/SkeletonJson.c b/native/cocos/editor-support/spine/SkeletonJson.c deleted file mode 100644 index 488b29052f..0000000000 --- a/native/cocos/editor-support/spine/SkeletonJson.c +++ /dev/null @@ -1,1058 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include -#include "Json.h" -#include -#include -#include - -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) -#define strdup _strdup -#endif - -typedef struct { - const char* parent; - const char* skin; - int slotIndex; - spMeshAttachment* mesh; -} _spLinkedMesh; - -typedef struct { - spSkeletonJson super; - int ownsLoader; - - int linkedMeshCount; - int linkedMeshCapacity; - _spLinkedMesh* linkedMeshes; -} _spSkeletonJson; - -spSkeletonJson* spSkeletonJson_createWithLoader (spAttachmentLoader* attachmentLoader) { - spSkeletonJson* self = SUPER(NEW(_spSkeletonJson)); - self->scale = 1; - self->attachmentLoader = attachmentLoader; - return self; -} - -spSkeletonJson* spSkeletonJson_create (spAtlas* atlas) { - spAtlasAttachmentLoader* attachmentLoader = spAtlasAttachmentLoader_create(atlas); - spSkeletonJson* self = spSkeletonJson_createWithLoader(SUPER(attachmentLoader)); - SUB_CAST(_spSkeletonJson, self)->ownsLoader = 1; - return self; -} - -void spSkeletonJson_dispose (spSkeletonJson* self) { - _spSkeletonJson* internal = SUB_CAST(_spSkeletonJson, self); - if (internal->ownsLoader) spAttachmentLoader_dispose(self->attachmentLoader); - FREE(internal->linkedMeshes); - FREE(self->error); - FREE(self); -} - -void _spSkeletonJson_setError (spSkeletonJson* self, Json* root, const char* value1, const char* value2) { - char message[256]; - int length; - FREE(self->error); - strcpy(message, value1); - length = (int)strlen(value1); - if (value2) strncat(message + length, value2, 255 - length); - MALLOC_STR(self->error, message); - if (root) Json_dispose(root); -} - -static float toColor (const char* value, int index) { - char digits[3]; - char *error; - int color; - - if (strlen(value) != 8) return -1; - value += index * 2; - - digits[0] = *value; - digits[1] = *(value + 1); - digits[2] = '\0'; - color = (int)strtoul(digits, &error, 16); - if (*error != 0) return -1; - return color / (float)255; -} - -static void readCurve (Json* frame, spCurveTimeline* timeline, int frameIndex) { - Json* curve = Json_getItem(frame, "curve"); - if (!curve) return; - if (curve->type == Json_String && strcmp(curve->valueString, "stepped") == 0) - spCurveTimeline_setStepped(timeline, frameIndex); - else if (curve->type == Json_Array) { - Json* child0 = curve->child; - Json* child1 = child0->next; - Json* child2 = child1->next; - Json* child3 = child2->next; - spCurveTimeline_setCurve(timeline, frameIndex, child0->valueFloat, child1->valueFloat, child2->valueFloat, - child3->valueFloat); - } -} - -static void _spSkeletonJson_addLinkedMesh (spSkeletonJson* self, spMeshAttachment* mesh, const char* skin, int slotIndex, - const char* parent) { - _spLinkedMesh* linkedMesh; - _spSkeletonJson* internal = SUB_CAST(_spSkeletonJson, self); - - if (internal->linkedMeshCount == internal->linkedMeshCapacity) { - _spLinkedMesh* linkedMeshes; - internal->linkedMeshCapacity *= 2; - if (internal->linkedMeshCapacity < 8) internal->linkedMeshCapacity = 8; - linkedMeshes = MALLOC(_spLinkedMesh, internal->linkedMeshCapacity); - memcpy(linkedMeshes, internal->linkedMeshes, sizeof(_spLinkedMesh) * internal->linkedMeshCount); - FREE(internal->linkedMeshes); - internal->linkedMeshes = linkedMeshes; - } - - linkedMesh = internal->linkedMeshes + internal->linkedMeshCount++; - linkedMesh->mesh = mesh; - linkedMesh->skin = skin; - linkedMesh->slotIndex = slotIndex; - linkedMesh->parent = parent; -} - -static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* root, spSkeletonData *skeletonData) { - int frameIndex; - spAnimation* animation; - Json* valueMap; - int timelinesCount = 0; - - Json* bones = Json_getItem(root, "bones"); - Json* slots = Json_getItem(root, "slots"); - Json* ik = Json_getItem(root, "ik"); - Json* transform = Json_getItem(root, "transform"); - Json* paths = Json_getItem(root, "paths"); - Json* deform = Json_getItem(root, "deform"); - Json* drawOrder = Json_getItem(root, "drawOrder"); - Json* events = Json_getItem(root, "events"); - Json *boneMap, *slotMap, *constraintMap; - if (!drawOrder) drawOrder = Json_getItem(root, "draworder"); - - for (boneMap = bones ? bones->child : 0; boneMap; boneMap = boneMap->next) - timelinesCount += boneMap->size; - for (slotMap = slots ? slots->child : 0; slotMap; slotMap = slotMap->next) - timelinesCount += slotMap->size; - timelinesCount += ik ? ik->size : 0; - timelinesCount += transform ? transform->size : 0; - for (constraintMap = paths ? paths->child : 0; constraintMap; constraintMap = constraintMap->next) - timelinesCount += constraintMap->size; - for (constraintMap = deform ? deform->child : 0; constraintMap; constraintMap = constraintMap->next) - for (slotMap = constraintMap->child; slotMap; slotMap = slotMap->next) - timelinesCount += slotMap->size; - if (drawOrder) ++timelinesCount; - if (events) ++timelinesCount; - - animation = spAnimation_create(root->name, timelinesCount); - animation->timelinesCount = 0; - - /* Slot timelines. */ - for (slotMap = slots ? slots->child : 0; slotMap; slotMap = slotMap->next) { - Json *timelineMap; - - int slotIndex = spSkeletonData_findSlotIndex(skeletonData, slotMap->name); - if (slotIndex == -1) { - spAnimation_dispose(animation); - _spSkeletonJson_setError(self, root, "Slot not found: ", slotMap->name); - return 0; - } - - for (timelineMap = slotMap->child; timelineMap; timelineMap = timelineMap->next) { - if (strcmp(timelineMap->name, "color") == 0) { - spColorTimeline *timeline = spColorTimeline_create(timelineMap->size); - timeline->slotIndex = slotIndex; - - for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - const char* s = Json_getString(valueMap, "color", 0); - spColorTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2), - toColor(s, 3)); - readCurve(valueMap, SUPER(timeline), frameIndex); - } - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[(timelineMap->size - 1) * COLOR_ENTRIES]); - - } else if (strcmp(timelineMap->name, "attachment") == 0) { - spAttachmentTimeline *timeline = spAttachmentTimeline_create(timelineMap->size); - timeline->slotIndex = slotIndex; - - for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - Json* name = Json_getItem(valueMap, "name"); - spAttachmentTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), - name->type == Json_NULL ? 0 : name->valueString); - } - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[timelineMap->size - 1]); - - } else { - spAnimation_dispose(animation); - _spSkeletonJson_setError(self, 0, "Invalid timeline type for a slot: ", timelineMap->name); - return 0; - } - } - } - - /* Bone timelines. */ - for (boneMap = bones ? bones->child : 0; boneMap; boneMap = boneMap->next) { - Json *timelineMap; - - int boneIndex = spSkeletonData_findBoneIndex(skeletonData, boneMap->name); - if (boneIndex == -1) { - spAnimation_dispose(animation); - _spSkeletonJson_setError(self, root, "Bone not found: ", boneMap->name); - return 0; - } - - for (timelineMap = boneMap->child; timelineMap; timelineMap = timelineMap->next) { - if (strcmp(timelineMap->name, "rotate") == 0) { - spRotateTimeline *timeline = spRotateTimeline_create(timelineMap->size); - timeline->boneIndex = boneIndex; - - for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - spRotateTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), Json_getFloat(valueMap, "angle", 0)); - readCurve(valueMap, SUPER(timeline), frameIndex); - } - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[(timelineMap->size - 1) * ROTATE_ENTRIES]); - - } else { - int isScale = strcmp(timelineMap->name, "scale") == 0; - int isTranslate = strcmp(timelineMap->name, "translate") == 0; - int isShear = strcmp(timelineMap->name, "shear") == 0; - if (isScale || isTranslate || isShear) { - float timelineScale = isTranslate ? self->scale: 1; - spTranslateTimeline *timeline = 0; - if (isScale) timeline = spScaleTimeline_create(timelineMap->size); - else if (isTranslate) timeline = spTranslateTimeline_create(timelineMap->size); - else if (isShear) timeline = spShearTimeline_create(timelineMap->size); - timeline->boneIndex = boneIndex; - - for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - spTranslateTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), Json_getFloat(valueMap, "x", 0) * timelineScale, - Json_getFloat(valueMap, "y", 0) * timelineScale); - readCurve(valueMap, SUPER(timeline), frameIndex); - } - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[(timelineMap->size - 1) * TRANSLATE_ENTRIES]); - - } else { - spAnimation_dispose(animation); - _spSkeletonJson_setError(self, 0, "Invalid timeline type for a bone: ", timelineMap->name); - return 0; - } - } - } - } - - /* IK constraint timelines. */ - for (constraintMap = ik ? ik->child : 0; constraintMap; constraintMap = constraintMap->next) { - spIkConstraintData* constraint = spSkeletonData_findIkConstraint(skeletonData, constraintMap->name); - spIkConstraintTimeline* timeline = spIkConstraintTimeline_create(constraintMap->size); - for (frameIndex = 0; frameIndex < skeletonData->ikConstraintsCount; ++frameIndex) { - if (constraint == skeletonData->ikConstraints[frameIndex]) { - timeline->ikConstraintIndex = frameIndex; - break; - } - } - for (valueMap = constraintMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - spIkConstraintTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), Json_getFloat(valueMap, "mix", 1), - Json_getInt(valueMap, "bendPositive", 1) ? 1 : -1); - readCurve(valueMap, SUPER(timeline), frameIndex); - } - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[(constraintMap->size - 1) * IKCONSTRAINT_ENTRIES]); - } - - /* Transform constraint timelines. */ - for (constraintMap = transform ? transform->child : 0; constraintMap; constraintMap = constraintMap->next) { - spTransformConstraintData* constraint = spSkeletonData_findTransformConstraint(skeletonData, constraintMap->name); - spTransformConstraintTimeline* timeline = spTransformConstraintTimeline_create(constraintMap->size); - for (frameIndex = 0; frameIndex < skeletonData->transformConstraintsCount; ++frameIndex) { - if (constraint == skeletonData->transformConstraints[frameIndex]) { - timeline->transformConstraintIndex = frameIndex; - break; - } - } - for (valueMap = constraintMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - spTransformConstraintTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), Json_getFloat(valueMap, "rotateMix", 1), - Json_getFloat(valueMap, "translateMix", 1), Json_getFloat(valueMap, "scaleMix", 1), Json_getFloat(valueMap, "shearMix", 1)); - readCurve(valueMap, SUPER(timeline), frameIndex); - } - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[(constraintMap->size - 1) * TRANSFORMCONSTRAINT_ENTRIES]); - } - - /** Path constraint timelines. */ - for(constraintMap = paths ? paths->child : 0; constraintMap; constraintMap = constraintMap->next ) { - int constraintIndex, i; - Json* timelineMap; - - spPathConstraintData* data = spSkeletonData_findPathConstraint(skeletonData, constraintMap->name); - if (!data) { - spAnimation_dispose(animation); - _spSkeletonJson_setError(self, root, "Path constraint not found: ", constraintMap->name); - return 0; - } - for (i = 0; i < skeletonData->pathConstraintsCount; i++) { - if (skeletonData->pathConstraints[i] == data) { - constraintIndex = i; - break; - } - } - - for (timelineMap = constraintMap->child; timelineMap; timelineMap = timelineMap->next) { - const char* timelineName = timelineMap->name; - if (strcmp(timelineName, "position") == 0 || strcmp(timelineName, "spacing") == 0) { - spPathConstraintPositionTimeline* timeline; - float timelineScale = 1; - if (strcmp(timelineName, "spacing") == 0) { - timeline = (spPathConstraintPositionTimeline*)spPathConstraintSpacingTimeline_create(timelineMap->size); - if (data->spacingMode == SP_SPACING_MODE_LENGTH || data->spacingMode == SP_SPACING_MODE_FIXED) timelineScale = self->scale; - } else { - timeline = spPathConstraintPositionTimeline_create(timelineMap->size); - if (data->positionMode == SP_POSITION_MODE_FIXED) timelineScale = self->scale; - } - timeline->pathConstraintIndex = constraintIndex; - for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - spPathConstraintPositionTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), Json_getFloat(valueMap, timelineName, 0) * timelineScale); - readCurve(valueMap, SUPER(timeline), frameIndex); - } - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[(timelineMap->size - 1) * PATHCONSTRAINTPOSITION_ENTRIES]); - } else if (strcmp(timelineName, "mix")) { - spPathConstraintMixTimeline* timeline = spPathConstraintMixTimeline_create(timelineMap->size); - timeline->pathConstraintIndex = constraintIndex; - for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - spPathConstraintMixTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), - Json_getFloat(valueMap, "rotateMix", 1), Json_getFloat(valueMap, "translateMix", 1)); - readCurve(valueMap, SUPER(timeline), frameIndex); - } - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[(timelineMap->size - 1) * PATHCONSTRAINTMIX_ENTRIES]); - } - } - } - - /* Deform timelines. */ - for (constraintMap = deform ? deform->child : 0; constraintMap; constraintMap = constraintMap->next) { - spSkin* skin = spSkeletonData_findSkin(skeletonData, constraintMap->name); - for (slotMap = constraintMap->child; slotMap; slotMap = slotMap->next) { - int slotIndex = spSkeletonData_findSlotIndex(skeletonData, slotMap->name); - Json* timelineMap; - for (timelineMap = slotMap->child; timelineMap; timelineMap = timelineMap->next) { - float* tempDeform; - spDeformTimeline *timeline; - int weighted, deformLength; - - spVertexAttachment* attachment = SUB_CAST(spVertexAttachment, spSkin_getAttachment(skin, slotIndex, timelineMap->name)); - if (!attachment) { - spAnimation_dispose(animation); - _spSkeletonJson_setError(self, 0, "Attachment not found: ", timelineMap->name); - return 0; - } - weighted = attachment->bones != 0; - deformLength = weighted ? attachment->verticesCount / 3 * 2 : attachment->verticesCount; - tempDeform = MALLOC(float, deformLength); - - timeline = spDeformTimeline_create(timelineMap->size, deformLength); - timeline->slotIndex = slotIndex; - timeline->attachment = SUPER(attachment); - - for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - Json* vertices = Json_getItem(valueMap, "vertices"); - float* deform; - if (!vertices) { - if (weighted) { - deform = tempDeform; - memset(deform, 0, sizeof(float) * deformLength); - } else - deform = attachment->vertices; - } else { - int v, start = Json_getInt(valueMap, "offset", 0); - Json* vertex; - deform = tempDeform; - memset(deform, 0, sizeof(float) * start); - if (self->scale == 1) { - for (vertex = vertices->child, v = start; vertex; vertex = vertex->next, ++v) - deform[v] = vertex->valueFloat; - } else { - for (vertex = vertices->child, v = start; vertex; vertex = vertex->next, ++v) - deform[v] = vertex->valueFloat * self->scale; - } - memset(deform + v, 0, sizeof(float) * (deformLength - v)); - if (!weighted) { - float* vertices = attachment->vertices; - for (v = 0; v < deformLength; ++v) - deform[v] += vertices[v]; - } - } - spDeformTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), deform); - readCurve(valueMap, SUPER(timeline), frameIndex); - } - FREE(tempDeform); - - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[timelineMap->size - 1]); - } - } - } - - /* Draw order timeline. */ - if (drawOrder) { - spDrawOrderTimeline* timeline = spDrawOrderTimeline_create(drawOrder->size, skeletonData->slotsCount); - for (valueMap = drawOrder->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - int ii; - int* drawOrder = 0; - Json* offsets = Json_getItem(valueMap, "offsets"); - if (offsets) { - Json* offsetMap; - int* unchanged = MALLOC(int, skeletonData->slotsCount - offsets->size); - int originalIndex = 0, unchangedIndex = 0; - - drawOrder = MALLOC(int, skeletonData->slotsCount); - for (ii = skeletonData->slotsCount - 1; ii >= 0; --ii) - drawOrder[ii] = -1; - - for (offsetMap = offsets->child; offsetMap; offsetMap = offsetMap->next) { - int slotIndex = spSkeletonData_findSlotIndex(skeletonData, Json_getString(offsetMap, "slot", 0)); - if (slotIndex == -1) { - spAnimation_dispose(animation); - _spSkeletonJson_setError(self, 0, "Slot not found: ", Json_getString(offsetMap, "slot", 0)); - return 0; - } - /* Collect unchanged items. */ - while (originalIndex != slotIndex) - unchanged[unchangedIndex++] = originalIndex++; - /* Set changed items. */ - drawOrder[originalIndex + Json_getInt(offsetMap, "offset", 0)] = originalIndex; - originalIndex++; - } - /* Collect remaining unchanged items. */ - while (originalIndex < skeletonData->slotsCount) - unchanged[unchangedIndex++] = originalIndex++; - /* Fill in unchanged items. */ - for (ii = skeletonData->slotsCount - 1; ii >= 0; ii--) - if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex]; - FREE(unchanged); - } - spDrawOrderTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), drawOrder); - FREE(drawOrder); - } - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[drawOrder->size - 1]); - } - - /* Event timeline. */ - if (events) { - spEventTimeline* timeline = spEventTimeline_create(events->size); - for (valueMap = events->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) { - spEvent* event; - const char* stringValue; - spEventData* eventData = spSkeletonData_findEvent(skeletonData, Json_getString(valueMap, "name", 0)); - if (!eventData) { - spAnimation_dispose(animation); - _spSkeletonJson_setError(self, 0, "Event not found: ", Json_getString(valueMap, "name", 0)); - return 0; - } - event = spEvent_create(Json_getFloat(valueMap, "time", 0), eventData); - event->intValue = Json_getInt(valueMap, "int", eventData->intValue); - event->floatValue = Json_getFloat(valueMap, "float", eventData->floatValue); - stringValue = Json_getString(valueMap, "string", eventData->stringValue); - if (stringValue) MALLOC_STR(event->stringValue, stringValue); - spEventTimeline_setFrame(timeline, frameIndex, event); - } - animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline); - animation->duration = MAX(animation->duration, timeline->frames[events->size - 1]); - } - - return animation; -} - -static void _readVertices (spSkeletonJson* self, Json* attachmentMap, spVertexAttachment* attachment, int verticesLength) { - Json* entry; - float* vertices; - int i, b, w, nn, entrySize; - - attachment->worldVerticesLength = verticesLength; - - entry = Json_getItem(attachmentMap, "vertices"); - entrySize = entry->size; - vertices = MALLOC(float, entrySize); - for (entry = entry->child, i = 0; entry; entry = entry->next, ++i) - vertices[i] = entry->valueFloat; - - if (verticesLength == entrySize) { - if (self->scale != 1) - for (i = 0; i < entrySize; ++i) - vertices[i] *= self->scale; - attachment->verticesCount = verticesLength; - attachment->vertices = vertices; - - attachment->bonesCount = 0; - attachment->bones = 0; - } else { - attachment->verticesCount = 0; - attachment->bonesCount = 0; - - for (i = 0; i < entrySize;) { - int bonesCount = (int)vertices[i]; - attachment->bonesCount += 1 + bonesCount; - attachment->verticesCount += 3 * bonesCount; - i += 1 + bonesCount * 4; - } - - attachment->vertices = MALLOC(float, attachment->verticesCount); - attachment->bones = MALLOC(int, attachment->bonesCount); - - for (i = 0, b = 0, w = 0; i < entrySize;) { - int bonesCount = (int)vertices[i++]; - attachment->bones[b++] = bonesCount; - for (nn = i + bonesCount * 4; i < nn;) { - attachment->bones[b++] = (int)vertices[i++]; - attachment->vertices[w++] = vertices[i++] * self->scale; - attachment->vertices[w++] = vertices[i++] * self->scale; - attachment->vertices[w++] = vertices[i++]; - } - } - - FREE(vertices); - } -} - -spSkeletonData* spSkeletonJson_readSkeletonDataFile (spSkeletonJson* self, const char* path) { - int length; - spSkeletonData* skeletonData; - const char* json = _spUtil_readFile(path, &length); - if (length == 0 || !json) { - _spSkeletonJson_setError(self, 0, "Unable to read skeleton file: ", path); - return 0; - } - skeletonData = spSkeletonJson_readSkeletonData(self, json); - FREE(json); - return skeletonData; -} - -spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const char* json) { - int i, ii; - spSkeletonData* skeletonData; - Json *root, *skeleton, *bones, *boneMap, *ik, *transform, *path, *slots, *skins, *animations, *events; - char* oldLocale; - _spSkeletonJson* internal = SUB_CAST(_spSkeletonJson, self); - - FREE(self->error); - CONST_CAST(char*, self->error) = 0; - internal->linkedMeshCount = 0; - -#ifndef __ANDROID__ - oldLocale = strdup(setlocale(LC_NUMERIC, NULL)); - setlocale(LC_NUMERIC, "C"); -#endif - - root = Json_create(json); - -#ifndef __ANDROID__ - setlocale(LC_NUMERIC, oldLocale); - free(oldLocale); -#endif - - if (!root) { - _spSkeletonJson_setError(self, 0, "Invalid skeleton JSON: ", Json_getError()); - return 0; - } - - skeletonData = spSkeletonData_create(); - - skeleton = Json_getItem(root, "skeleton"); - if (skeleton) { - MALLOC_STR(skeletonData->hash, Json_getString(skeleton, "hash", 0)); - MALLOC_STR(skeletonData->version, Json_getString(skeleton, "spine", 0)); - skeletonData->width = Json_getFloat(skeleton, "width", 0); - skeletonData->height = Json_getFloat(skeleton, "height", 0); - } - - /* Bones. */ - bones = Json_getItem(root, "bones"); - skeletonData->bones = MALLOC(spBoneData*, bones->size); - for (boneMap = bones->child, i = 0; boneMap; boneMap = boneMap->next, ++i) { - spBoneData* data; - const char* transformMode; - - spBoneData* parent = 0; - const char* parentName = Json_getString(boneMap, "parent", 0); - if (parentName) { - parent = spSkeletonData_findBone(skeletonData, parentName); - if (!parent) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, root, "Parent bone not found: ", parentName); - return 0; - } - } - - data = spBoneData_create(skeletonData->bonesCount, Json_getString(boneMap, "name", 0), parent); - data->length = Json_getFloat(boneMap, "length", 0) * self->scale; - data->x = Json_getFloat(boneMap, "x", 0) * self->scale; - data->y = Json_getFloat(boneMap, "y", 0) * self->scale; - data->rotation = Json_getFloat(boneMap, "rotation", 0); - data->scaleX = Json_getFloat(boneMap, "scaleX", 1); - data->scaleY = Json_getFloat(boneMap, "scaleY", 1); - data->shearX = Json_getFloat(boneMap, "shearX", 0); - data->shearY = Json_getFloat(boneMap, "shearY", 0); - transformMode = Json_getString(boneMap, "transform", "normal"); - data->transformMode = SP_TRANSFORMMODE_NORMAL; - if (strcmp(transformMode, "normal") == 0) - data->transformMode = SP_TRANSFORMMODE_NORMAL; - if (strcmp(transformMode, "onlyTranslation") == 0) - data->transformMode = SP_TRANSFORMMODE_ONLYTRANSLATION; - if (strcmp(transformMode, "noRotationOrReflection") == 0) - data->transformMode = SP_TRANSFORMMODE_NOROTATIONORREFLECTION; - if (strcmp(transformMode, "noScale") == 0) - data->transformMode = SP_TRANSFORMMODE_NOSCALE; - if (strcmp(transformMode, "noScaleOrReflection") == 0) - data->transformMode = SP_TRANSFORMMODE_NOSCALEORREFLECTION; - - skeletonData->bones[i] = data; - skeletonData->bonesCount++; - } - - /* Slots. */ - slots = Json_getItem(root, "slots"); - if (slots) { - Json *slotMap; - skeletonData->slotsCount = slots->size; - skeletonData->slots = MALLOC(spSlotData*, slots->size); - for (slotMap = slots->child, i = 0; slotMap; slotMap = slotMap->next, ++i) { - spSlotData* data; - const char* color; - Json *item; - - const char* boneName = Json_getString(slotMap, "bone", 0); - spBoneData* boneData = spSkeletonData_findBone(skeletonData, boneName); - if (!boneData) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, root, "Slot bone not found: ", boneName); - return 0; - } - - data = spSlotData_create(i, Json_getString(slotMap, "name", 0), boneData); - - color = Json_getString(slotMap, "color", 0); - if (color) { - data->r = toColor(color, 0); - data->g = toColor(color, 1); - data->b = toColor(color, 2); - data->a = toColor(color, 3); - } - - item = Json_getItem(slotMap, "attachment"); - if (item) spSlotData_setAttachmentName(data, item->valueString); - - item = Json_getItem(slotMap, "blend"); - if (item) { - if (strcmp(item->valueString, "additive") == 0) - data->blendMode = SP_BLEND_MODE_ADDITIVE; - else if (strcmp(item->valueString, "multiply") == 0) - data->blendMode = SP_BLEND_MODE_MULTIPLY; - else if (strcmp(item->valueString, "screen") == 0) - data->blendMode = SP_BLEND_MODE_SCREEN; - } - - skeletonData->slots[i] = data; - } - } - - /* IK constraints. */ - ik = Json_getItem(root, "ik"); - if (ik) { - Json *constraintMap; - skeletonData->ikConstraintsCount = ik->size; - skeletonData->ikConstraints = MALLOC(spIkConstraintData*, ik->size); - for (constraintMap = ik->child, i = 0; constraintMap; constraintMap = constraintMap->next, ++i) { - const char* targetName; - - spIkConstraintData* data = spIkConstraintData_create(Json_getString(constraintMap, "name", 0)); - data->order = Json_getInt(constraintMap, "order", 0); - - boneMap = Json_getItem(constraintMap, "bones"); - data->bonesCount = boneMap->size; - data->bones = MALLOC(spBoneData*, boneMap->size); - for (boneMap = boneMap->child, ii = 0; boneMap; boneMap = boneMap->next, ++ii) { - data->bones[ii] = spSkeletonData_findBone(skeletonData, boneMap->valueString); - if (!data->bones[ii]) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, root, "IK bone not found: ", boneMap->valueString); - return 0; - } - } - - targetName = Json_getString(constraintMap, "target", 0); - data->target = spSkeletonData_findBone(skeletonData, targetName); - if (!data->target) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, root, "Target bone not found: ", boneMap->name); - return 0; - } - - data->bendDirection = Json_getInt(constraintMap, "bendPositive", 1) ? 1 : -1; - data->mix = Json_getFloat(constraintMap, "mix", 1); - - skeletonData->ikConstraints[i] = data; - } - } - - /* Transform constraints. */ - transform = Json_getItem(root, "transform"); - if (transform) { - Json *constraintMap; - skeletonData->transformConstraintsCount = transform->size; - skeletonData->transformConstraints = MALLOC(spTransformConstraintData*, transform->size); - for (constraintMap = transform->child, i = 0; constraintMap; constraintMap = constraintMap->next, ++i) { - const char* name; - - spTransformConstraintData* data = spTransformConstraintData_create(Json_getString(constraintMap, "name", 0)); - data->order = Json_getInt(constraintMap, "order", 0); - - boneMap = Json_getItem(constraintMap, "bones"); - data->bonesCount = boneMap->size; - CONST_CAST(spBoneData**, data->bones) = MALLOC(spBoneData*, boneMap->size); - for (boneMap = boneMap->child, ii = 0; boneMap; boneMap = boneMap->next, ++ii) { - data->bones[ii] = spSkeletonData_findBone(skeletonData, boneMap->valueString); - if (!data->bones[ii]) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, root, "Transform bone not found: ", boneMap->valueString); - return 0; - } - } - - name = Json_getString(constraintMap, "target", 0); - data->target = spSkeletonData_findBone(skeletonData, name); - if (!data->target) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, root, "Target bone not found: ", boneMap->name); - return 0; - } - - data->offsetRotation = Json_getFloat(constraintMap, "rotation", 0); - data->offsetX = Json_getFloat(constraintMap, "x", 0) * self->scale; - data->offsetY = Json_getFloat(constraintMap, "y", 0) * self->scale; - data->offsetScaleX = Json_getFloat(constraintMap, "scaleX", 0); - data->offsetScaleY = Json_getFloat(constraintMap, "scaleY", 0); - data->offsetShearY = Json_getFloat(constraintMap, "shearY", 0); - - data->rotateMix = Json_getFloat(constraintMap, "rotateMix", 1); - data->translateMix = Json_getFloat(constraintMap, "translateMix", 1); - data->scaleMix = Json_getFloat(constraintMap, "scaleMix", 1); - data->shearMix = Json_getFloat(constraintMap, "shearMix", 1); - - skeletonData->transformConstraints[i] = data; - } - } - - /* Path constraints */ - path = Json_getItem(root, "path"); - if (path) { - Json *constraintMap; - skeletonData->pathConstraintsCount = path->size; - skeletonData->pathConstraints = MALLOC(spPathConstraintData*, path->size); - for (constraintMap = path->child, i = 0; constraintMap; constraintMap = constraintMap->next, ++i) { - const char* name; - const char* item; - - spPathConstraintData* data = spPathConstraintData_create(Json_getString(constraintMap, "name", 0)); - data->order = Json_getInt(constraintMap, "order", 0); - - boneMap = Json_getItem(constraintMap, "bones"); - data->bonesCount = boneMap->size; - CONST_CAST(spBoneData**, data->bones) = MALLOC(spBoneData*, boneMap->size); - for (boneMap = boneMap->child, ii = 0; boneMap; boneMap = boneMap->next, ++ii) { - data->bones[ii] = spSkeletonData_findBone(skeletonData, boneMap->valueString); - if (!data->bones[ii]) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, root, "Path bone not found: ", boneMap->valueString); - return 0; - } - } - - name = Json_getString(constraintMap, "target", 0); - data->target = spSkeletonData_findSlot(skeletonData, name); - if (!data->target) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, root, "Target slot not found: ", boneMap->name); - return 0; - } - - item = Json_getString(constraintMap, "positionMode", "percent"); - if (strcmp(item, "fixed") == 0) data->positionMode = SP_POSITION_MODE_FIXED; - else if (strcmp(item, "percent") == 0) data->positionMode = SP_POSITION_MODE_PERCENT; - - item = Json_getString(constraintMap, "spacingMode", "length"); - if (strcmp(item, "length") == 0) data->spacingMode = SP_SPACING_MODE_LENGTH; - else if (strcmp(item, "fixed") == 0) data->spacingMode = SP_SPACING_MODE_FIXED; - else if (strcmp(item, "percent") == 0) data->spacingMode = SP_SPACING_MODE_PERCENT; - - item = Json_getString(constraintMap, "rotateMode", "tangent"); - if (strcmp(item, "tangent") == 0) data->rotateMode = SP_ROTATE_MODE_TANGENT; - else if (strcmp(item, "chain") == 0) data->rotateMode = SP_ROTATE_MODE_CHAIN; - else if (strcmp(item, "chainScale") == 0) data->rotateMode = SP_ROTATE_MODE_CHAIN_SCALE; - - data->offsetRotation = Json_getFloat(constraintMap, "rotation", 0); - data->position = Json_getFloat(constraintMap, "position", 0); - if (data->positionMode == SP_POSITION_MODE_FIXED) data->position *= self->scale; - data->spacing = Json_getFloat(constraintMap, "spacing", 0); - if (data->spacingMode == SP_SPACING_MODE_LENGTH || data->spacingMode == SP_SPACING_MODE_FIXED) data->spacing *= self->scale; - data->rotateMix = Json_getFloat(constraintMap, "rotateMix", 1); - data->translateMix = Json_getFloat(constraintMap, "translateMix", 1); - - skeletonData->pathConstraints[i] = data; - } - } - - /* Skins. */ - skins = Json_getItem(root, "skins"); - if (skins) { - Json *skinMap; - skeletonData->skins = MALLOC(spSkin*, skins->size); - for (skinMap = skins->child, i = 0; skinMap; skinMap = skinMap->next, ++i) { - Json *attachmentsMap; - Json *curves; - spSkin *skin = spSkin_create(skinMap->name); - - skeletonData->skins[skeletonData->skinsCount++] = skin; - if (strcmp(skinMap->name, "default") == 0) skeletonData->defaultSkin = skin; - - for (attachmentsMap = skinMap->child; attachmentsMap; attachmentsMap = attachmentsMap->next) { - int slotIndex = spSkeletonData_findSlotIndex(skeletonData, attachmentsMap->name); - Json *attachmentMap; - - for (attachmentMap = attachmentsMap->child; attachmentMap; attachmentMap = attachmentMap->next) { - spAttachment* attachment; - const char* skinAttachmentName = attachmentMap->name; - const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName); - const char* path = Json_getString(attachmentMap, "path", attachmentName); - const char* color; - Json* entry; - - const char* typeString = Json_getString(attachmentMap, "type", "region"); - spAttachmentType type; - if (strcmp(typeString, "region") == 0) - type = SP_ATTACHMENT_REGION; - else if (strcmp(typeString, "mesh") == 0) - type = SP_ATTACHMENT_MESH; - else if (strcmp(typeString, "linkedmesh") == 0) - type = SP_ATTACHMENT_LINKED_MESH; - else if (strcmp(typeString, "boundingbox") == 0) - type = SP_ATTACHMENT_BOUNDING_BOX; - else if (strcmp(typeString, "path") == 0) - type = SP_ATTACHMENT_PATH; - else { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, root, "Unknown attachment type: ", typeString); - return 0; - } - - attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, attachmentName, path); - if (!attachment) { - if (self->attachmentLoader->error1) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, root, self->attachmentLoader->error1, self->attachmentLoader->error2); - return 0; - } - continue; - } - - switch (attachment->type) { - case SP_ATTACHMENT_REGION: { - spRegionAttachment* region = SUB_CAST(spRegionAttachment, attachment); - if (path) MALLOC_STR(region->path, path); - region->x = Json_getFloat(attachmentMap, "x", 0) * self->scale; - region->y = Json_getFloat(attachmentMap, "y", 0) * self->scale; - region->scaleX = Json_getFloat(attachmentMap, "scaleX", 1); - region->scaleY = Json_getFloat(attachmentMap, "scaleY", 1); - region->rotation = Json_getFloat(attachmentMap, "rotation", 0); - region->width = Json_getFloat(attachmentMap, "width", 32) * self->scale; - region->height = Json_getFloat(attachmentMap, "height", 32) * self->scale; - - color = Json_getString(attachmentMap, "color", 0); - if (color) { - region->r = toColor(color, 0); - region->g = toColor(color, 1); - region->b = toColor(color, 2); - region->a = toColor(color, 3); - } - - spRegionAttachment_updateOffset(region); - - spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment); - break; - } - case SP_ATTACHMENT_MESH: - case SP_ATTACHMENT_LINKED_MESH: { - spMeshAttachment* mesh = SUB_CAST(spMeshAttachment, attachment); - - MALLOC_STR(mesh->path, path); - - color = Json_getString(attachmentMap, "color", 0); - if (color) { - mesh->r = toColor(color, 0); - mesh->g = toColor(color, 1); - mesh->b = toColor(color, 2); - mesh->a = toColor(color, 3); - } - - mesh->width = Json_getFloat(attachmentMap, "width", 32) * self->scale; - mesh->height = Json_getFloat(attachmentMap, "height", 32) * self->scale; - - entry = Json_getItem(attachmentMap, "parent"); - if (!entry) { - int verticesLength; - entry = Json_getItem(attachmentMap, "triangles"); - mesh->trianglesCount = entry->size; - mesh->triangles = MALLOC(unsigned short, entry->size); - for (entry = entry->child, ii = 0; entry; entry = entry->next, ++ii) - mesh->triangles[ii] = (unsigned short)entry->valueInt; - - entry = Json_getItem(attachmentMap, "uvs"); - verticesLength = entry->size; - mesh->regionUVs = MALLOC(float, verticesLength); - for (entry = entry->child, ii = 0; entry; entry = entry->next, ++ii) - mesh->regionUVs[ii] = entry->valueFloat; - - _readVertices(self, attachmentMap, SUPER(mesh), verticesLength); - - spMeshAttachment_updateUVs(mesh); - - mesh->hullLength = Json_getInt(attachmentMap, "hull", 0); - - entry = Json_getItem(attachmentMap, "edges"); - if (entry) { - mesh->edgesCount = entry->size; - mesh->edges = MALLOC(int, entry->size); - for (entry = entry->child, ii = 0; entry; entry = entry->next, ++ii) - mesh->edges[ii] = entry->valueInt; - } - - spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment); - } else { - mesh->inheritDeform = Json_getInt(attachmentMap, "deform", 1); - _spSkeletonJson_addLinkedMesh(self, SUB_CAST(spMeshAttachment, attachment), Json_getString(attachmentMap, "skin", 0), slotIndex, - entry->valueString); - } - break; - } - case SP_ATTACHMENT_BOUNDING_BOX: { - spBoundingBoxAttachment* box = SUB_CAST(spBoundingBoxAttachment, attachment); - int vertexCount = Json_getInt(attachmentMap, "vertexCount", 0) << 1; - _readVertices(self, attachmentMap, SUPER(box), vertexCount); - box->super.verticesCount = vertexCount; - spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment); - break; - } - case SP_ATTACHMENT_PATH: { - spPathAttachment* path = SUB_CAST(spPathAttachment, attachment); - int vertexCount = 0; - path->closed = Json_getInt(attachmentMap, "closed", 0); - path->constantSpeed = Json_getInt(attachmentMap, "constantSpeed", 1); - vertexCount = Json_getInt(attachmentMap, "vertexCount", 0); - _readVertices(self, attachmentMap, SUPER(path), vertexCount << 1); - - path->lengthsLength = vertexCount / 3; - path->lengths = MALLOC(float, path->lengthsLength); - - curves = Json_getItem(attachmentMap, "lengths"); - for (curves = curves->child, ii = 0; curves; curves = curves->next, ++ii) { - path->lengths[ii] = curves->valueFloat * self->scale; - } - break; - } - } - - spSkin_addAttachment(skin, slotIndex, skinAttachmentName, attachment); - } - } - } - } - - /* Linked meshes. */ - for (i = 0; i < internal->linkedMeshCount; i++) { - spAttachment* parent; - _spLinkedMesh* linkedMesh = internal->linkedMeshes + i; - spSkin* skin = !linkedMesh->skin ? skeletonData->defaultSkin : spSkeletonData_findSkin(skeletonData, linkedMesh->skin); - if (!skin) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, 0, "Skin not found: ", linkedMesh->skin); - return 0; - } - parent = spSkin_getAttachment(skin, linkedMesh->slotIndex, linkedMesh->parent); - if (!parent) { - spSkeletonData_dispose(skeletonData); - _spSkeletonJson_setError(self, 0, "Parent mesh not found: ", linkedMesh->parent); - return 0; - } - spMeshAttachment_setParentMesh(linkedMesh->mesh, SUB_CAST(spMeshAttachment, parent)); - spMeshAttachment_updateUVs(linkedMesh->mesh); - spAttachmentLoader_configureAttachment(self->attachmentLoader, SUPER(SUPER(linkedMesh->mesh))); - } - - /* Events. */ - events = Json_getItem(root, "events"); - if (events) { - Json *eventMap; - const char* stringValue; - skeletonData->eventsCount = events->size; - skeletonData->events = MALLOC(spEventData*, events->size); - for (eventMap = events->child, i = 0; eventMap; eventMap = eventMap->next, ++i) { - spEventData* eventData = spEventData_create(eventMap->name); - eventData->intValue = Json_getInt(eventMap, "int", 0); - eventData->floatValue = Json_getFloat(eventMap, "float", 0); - stringValue = Json_getString(eventMap, "string", 0); - if (stringValue) MALLOC_STR(eventData->stringValue, stringValue); - skeletonData->events[i] = eventData; - } - } - - /* Animations. */ - animations = Json_getItem(root, "animations"); - if (animations) { - Json *animationMap; - skeletonData->animations = MALLOC(spAnimation*, animations->size); - for (animationMap = animations->child; animationMap; animationMap = animationMap->next) { - spAnimation* animation = _spSkeletonJson_readAnimation(self, animationMap, skeletonData); - if (!animation) { - spSkeletonData_dispose(skeletonData); - return 0; - } - skeletonData->animations[skeletonData->animationsCount++] = animation; - } - } - - Json_dispose(root); - return skeletonData; -} diff --git a/native/cocos/editor-support/spine/SkeletonJson.h b/native/cocos/editor-support/spine/SkeletonJson.h deleted file mode 100644 index b7159fdd6c..0000000000 --- a/native/cocos/editor-support/spine/SkeletonJson.h +++ /dev/null @@ -1,72 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SKELETONJSON_H_ -#define SPINE_SKELETONJSON_H_ - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct spAtlasAttachmentLoader; - -typedef struct spSkeletonJson { - float scale; - spAttachmentLoader* attachmentLoader; - const char* const error; -} spSkeletonJson; - -spSkeletonJson* spSkeletonJson_createWithLoader (spAttachmentLoader* attachmentLoader); -spSkeletonJson* spSkeletonJson_create (spAtlas* atlas); -void spSkeletonJson_dispose (spSkeletonJson* self); - -spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const char* json); -spSkeletonData* spSkeletonJson_readSkeletonDataFile (spSkeletonJson* self, const char* path); - -#ifdef SPINE_SHORT_NAMES -typedef spSkeletonJson SkeletonJson; -#define SkeletonJson_createWithLoader(...) spSkeletonJson_createWithLoader(__VA_ARGS__) -#define SkeletonJson_create(...) spSkeletonJson_create(__VA_ARGS__) -#define SkeletonJson_dispose(...) spSkeletonJson_dispose(__VA_ARGS__) -#define SkeletonJson_readSkeletonData(...) spSkeletonJson_readSkeletonData(__VA_ARGS__) -#define SkeletonJson_readSkeletonDataFile(...) spSkeletonJson_readSkeletonDataFile(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_SKELETONJSON_H_ */ diff --git a/native/cocos/editor-support/spine/SkeletonRenderer.cpp b/native/cocos/editor-support/spine/SkeletonRenderer.cpp deleted file mode 100644 index ea92a595ec..0000000000 --- a/native/cocos/editor-support/spine/SkeletonRenderer.cpp +++ /dev/null @@ -1,450 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -USING_NS_CC; -using std::min; -using std::max; - -namespace spine { - -SkeletonRenderer* SkeletonRenderer::createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData) { - SkeletonRenderer* node = new SkeletonRenderer(skeletonData, ownsSkeletonData); - node->autorelease(); - return node; -} - -SkeletonRenderer* SkeletonRenderer::createWithFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale) { - SkeletonRenderer* node = new SkeletonRenderer(skeletonDataFile, atlas, scale); - node->autorelease(); - return node; -} - -SkeletonRenderer* SkeletonRenderer::createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale) { - SkeletonRenderer* node = new SkeletonRenderer(skeletonDataFile, atlasFile, scale); - node->autorelease(); - return node; -} - -void SkeletonRenderer::initialize () { - _worldVertices = new float[1000]; // Max number of vertices per mesh. - - _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - setOpacityModifyRGB(true); - - setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); -} - -void SkeletonRenderer::setSkeletonData (spSkeletonData *skeletonData, bool ownsSkeletonData) { - _skeleton = spSkeleton_create(skeletonData); - _ownsSkeletonData = ownsSkeletonData; -} - -SkeletonRenderer::SkeletonRenderer () - : _atlas(nullptr), _attachmentLoader(nullptr), _debugSlots(false), _debugBones(false), _timeScale(1) { -} - -SkeletonRenderer::SkeletonRenderer (spSkeletonData *skeletonData, bool ownsSkeletonData) - : _atlas(nullptr), _attachmentLoader(nullptr), _debugSlots(false), _debugBones(false), _timeScale(1) { - initWithData(skeletonData, ownsSkeletonData); -} - -SkeletonRenderer::SkeletonRenderer (const std::string& skeletonDataFile, spAtlas* atlas, float scale) - : _atlas(nullptr), _attachmentLoader(nullptr), _debugSlots(false), _debugBones(false), _timeScale(1) { - initWithJsonFile(skeletonDataFile, atlas, scale); -} - -SkeletonRenderer::SkeletonRenderer (const std::string& skeletonDataFile, const std::string& atlasFile, float scale) - : _atlas(nullptr), _attachmentLoader(nullptr), _debugSlots(false), _debugBones(false), _timeScale(1) { - initWithJsonFile(skeletonDataFile, atlasFile, scale); -} - -SkeletonRenderer::~SkeletonRenderer () { - if (_ownsSkeletonData) spSkeletonData_dispose(_skeleton->data); - spSkeleton_dispose(_skeleton); - if (_atlas) spAtlas_dispose(_atlas); - if (_attachmentLoader) spAttachmentLoader_dispose(_attachmentLoader); - delete [] _worldVertices; -} - -void SkeletonRenderer::initWithData (spSkeletonData* skeletonData, bool ownsSkeletonData) { - setSkeletonData(skeletonData, ownsSkeletonData); - - initialize(); -} - -void SkeletonRenderer::initWithJsonFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale) { - _atlas = atlas; - _attachmentLoader = SUPER(Cocos2dAttachmentLoader_create(_atlas)); - - spSkeletonJson* json = spSkeletonJson_createWithLoader(_attachmentLoader); - json->scale = scale; - spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile.c_str()); - CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data."); - spSkeletonJson_dispose(json); - - setSkeletonData(skeletonData, true); - - initialize(); -} - -void SkeletonRenderer::initWithJsonFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale) { - _atlas = spAtlas_createFromFile(atlasFile.c_str(), 0); - CCASSERT(_atlas, "Error reading atlas file."); - - _attachmentLoader = SUPER(Cocos2dAttachmentLoader_create(_atlas)); - - spSkeletonJson* json = spSkeletonJson_createWithLoader(_attachmentLoader); - json->scale = scale; - spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile.c_str()); - CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data file."); - spSkeletonJson_dispose(json); - - setSkeletonData(skeletonData, true); - - initialize(); -} - -void SkeletonRenderer::initWithBinaryFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale) { - _atlas = atlas; - _attachmentLoader = SUPER(Cocos2dAttachmentLoader_create(_atlas)); - - spSkeletonBinary* binary = spSkeletonBinary_createWithLoader(_attachmentLoader); - binary->scale = scale; - spSkeletonData* skeletonData = spSkeletonBinary_readSkeletonDataFile(binary, skeletonDataFile.c_str()); - CCASSERT(skeletonData, binary->error ? binary->error : "Error reading skeleton data file."); - spSkeletonBinary_dispose(binary); - - setSkeletonData(skeletonData, true); - - initialize(); -} - -void SkeletonRenderer::initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale) { - _atlas = spAtlas_createFromFile(atlasFile.c_str(), 0); - CCASSERT(_atlas, "Error reading atlas file."); - - _attachmentLoader = SUPER(Cocos2dAttachmentLoader_create(_atlas)); - - spSkeletonBinary* binary = spSkeletonBinary_createWithLoader(_attachmentLoader); - binary->scale = scale; - spSkeletonData* skeletonData = spSkeletonBinary_readSkeletonDataFile(binary, skeletonDataFile.c_str()); - CCASSERT(skeletonData, binary->error ? binary->error : "Error reading skeleton data file."); - spSkeletonBinary_dispose(binary); - - setSkeletonData(skeletonData, true); - - initialize(); -} - - -void SkeletonRenderer::update (float deltaTime) { - spSkeleton_update(_skeleton, deltaTime * _timeScale); -} - -void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t transformFlags) { - SkeletonBatch* batch = SkeletonBatch::getInstance(); - - Color3B nodeColor = getColor(); - _skeleton->r = nodeColor.r / (float)255; - _skeleton->g = nodeColor.g / (float)255; - _skeleton->b = nodeColor.b / (float)255; - _skeleton->a = getDisplayedOpacity() / (float)255; - - Color4F color; - AttachmentVertices* attachmentVertices = nullptr; - for (int i = 0, n = _skeleton->slotsCount; i < n; ++i) { - spSlot* slot = _skeleton->drawOrder[i]; - if (!slot->attachment) continue; - - switch (slot->attachment->type) { - case SP_ATTACHMENT_REGION: { - spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices); - attachmentVertices = getAttachmentVertices(attachment); - color.r = attachment->r; - color.g = attachment->g; - color.b = attachment->b; - color.a = attachment->a; - break; - } - case SP_ATTACHMENT_MESH: { - spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment; - spMeshAttachment_computeWorldVertices(attachment, slot, _worldVertices); - attachmentVertices = getAttachmentVertices(attachment); - color.r = attachment->r; - color.g = attachment->g; - color.b = attachment->b; - color.a = attachment->a; - break; - } - default: - continue; - } - - color.a *= _skeleton->a * slot->a * 255; - float multiplier = _premultipliedAlpha ? color.a : 255; - color.r *= _skeleton->r * slot->r * multiplier; - color.g *= _skeleton->g * slot->g * multiplier; - color.b *= _skeleton->b * slot->b * multiplier; - - - - for (int v = 0, w = 0, vn = attachmentVertices->_triangles->vertCount; v < vn; ++v, w += 2) { - V3F_C4B_T2F* vertex = attachmentVertices->_triangles->verts + v; - vertex->vertices.x = _worldVertices[w]; - vertex->vertices.y = _worldVertices[w + 1]; - vertex->colors.r = (GLubyte)color.r; - vertex->colors.g = (GLubyte)color.g; - vertex->colors.b = (GLubyte)color.b; - vertex->colors.a = (GLubyte)color.a; - } - - BlendFunc blendFunc; - switch (slot->data->blendMode) { - case SP_BLEND_MODE_ADDITIVE: - blendFunc.src = _premultipliedAlpha ? GL_ONE : GL_SRC_ALPHA; - blendFunc.dst = GL_ONE; - break; - case SP_BLEND_MODE_MULTIPLY: - blendFunc.src = GL_DST_COLOR; - blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; - break; - case SP_BLEND_MODE_SCREEN: - blendFunc.src = GL_ONE; - blendFunc.dst = GL_ONE_MINUS_SRC_COLOR; - break; - default: - blendFunc.src = _premultipliedAlpha ? GL_ONE : GL_SRC_ALPHA; - blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; - } - - batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture->getName(), _glProgramState, blendFunc, - *attachmentVertices->_triangles, transform, transformFlags); - } - - if (_debugSlots || _debugBones) { - drawDebug(renderer, transform, transformFlags); - } -} - -void SkeletonRenderer::drawDebug (Renderer* renderer, const Mat4 &transform, uint32_t transformFlags) { - - Director* director = Director::getInstance(); - director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform); - - DrawNode* drawNode = DrawNode::create(); - - if (_debugSlots) { - // Slots. - // DrawPrimitives::setDrawColor4B(0, 0, 255, 255); - glLineWidth(1); - Vec2 points[4]; - V3F_C4B_T2F_Quad quad; - for (int i = 0, n = _skeleton->slotsCount; i < n; i++) { - spSlot* slot = _skeleton->drawOrder[i]; - if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue; - spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices); - points[0] = Vec2(_worldVertices[0], _worldVertices[1]); - points[1] = Vec2(_worldVertices[2], _worldVertices[3]); - points[2] = Vec2(_worldVertices[4], _worldVertices[5]); - points[3] = Vec2(_worldVertices[6], _worldVertices[7]); - drawNode->drawPoly(points, 4, true, Color4F::BLUE); - } - } - if (_debugBones) { - // Bone lengths. - glLineWidth(2); - for (int i = 0, n = _skeleton->bonesCount; i < n; i++) { - spBone *bone = _skeleton->bones[i]; - float x = bone->data->length * bone->a + bone->worldX; - float y = bone->data->length * bone->c + bone->worldY; - drawNode->drawLine(Vec2(bone->worldX, bone->worldY), Vec2(x, y), Color4F::RED); - } - // Bone origins. - auto color = Color4F::BLUE; // Root bone is blue. - for (int i = 0, n = _skeleton->bonesCount; i < n; i++) { - spBone *bone = _skeleton->bones[i]; - drawNode->drawPoint(Vec2(bone->worldX, bone->worldY), 4, color); - if (i == 0) color = Color4F::GREEN; - } - } - - drawNode->draw(renderer, transform, transformFlags); - director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); -} - -AttachmentVertices* SkeletonRenderer::getAttachmentVertices (spRegionAttachment* attachment) const { - return (AttachmentVertices*)attachment->rendererObject; -} - -AttachmentVertices* SkeletonRenderer::getAttachmentVertices (spMeshAttachment* attachment) const { - return (AttachmentVertices*)attachment->rendererObject; -} - -Rect SkeletonRenderer::getBoundingBox () const { - float minX = FLT_MAX, minY = FLT_MAX, maxX = -FLT_MAX, maxY = -FLT_MAX; - float scaleX = getScaleX(), scaleY = getScaleY(); - for (int i = 0; i < _skeleton->slotsCount; ++i) { - spSlot* slot = _skeleton->slots[i]; - if (!slot->attachment) continue; - int verticesCount; - if (slot->attachment->type == SP_ATTACHMENT_REGION) { - spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices); - verticesCount = 8; - } else if (slot->attachment->type == SP_ATTACHMENT_MESH) { - spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment; - spMeshAttachment_computeWorldVertices(mesh, slot, _worldVertices); - verticesCount = mesh->super.worldVerticesLength; - } else - continue; - for (int ii = 0; ii < verticesCount; ii += 2) { - float x = _worldVertices[ii] * scaleX, y = _worldVertices[ii + 1] * scaleY; - minX = min(minX, x); - minY = min(minY, y); - maxX = max(maxX, x); - maxY = max(maxY, y); - } - } - Vec2 position = getPosition(); - if (minX == FLT_MAX) minX = minY = maxX = maxY = 0; - return Rect(position.x + minX, position.y + minY, maxX - minX, maxY - minY); -} - -// --- Convenience methods for Skeleton_* functions. - -void SkeletonRenderer::updateWorldTransform () { - spSkeleton_updateWorldTransform(_skeleton); -} - -void SkeletonRenderer::setToSetupPose () { - spSkeleton_setToSetupPose(_skeleton); -} -void SkeletonRenderer::setBonesToSetupPose () { - spSkeleton_setBonesToSetupPose(_skeleton); -} -void SkeletonRenderer::setSlotsToSetupPose () { - spSkeleton_setSlotsToSetupPose(_skeleton); -} - -spBone* SkeletonRenderer::findBone (const std::string& boneName) const { - return spSkeleton_findBone(_skeleton, boneName.c_str()); -} - -spSlot* SkeletonRenderer::findSlot (const std::string& slotName) const { - return spSkeleton_findSlot(_skeleton, slotName.c_str()); -} - -bool SkeletonRenderer::setSkin (const std::string& skinName) { - return spSkeleton_setSkinByName(_skeleton, skinName.empty() ? 0 : skinName.c_str()) ? true : false; -} -bool SkeletonRenderer::setSkin (const char* skinName) { - return spSkeleton_setSkinByName(_skeleton, skinName) ? true : false; -} - -spAttachment* SkeletonRenderer::getAttachment (const std::string& slotName, const std::string& attachmentName) const { - return spSkeleton_getAttachmentForSlotName(_skeleton, slotName.c_str(), attachmentName.c_str()); -} -bool SkeletonRenderer::setAttachment (const std::string& slotName, const std::string& attachmentName) { - return spSkeleton_setAttachment(_skeleton, slotName.c_str(), attachmentName.empty() ? 0 : attachmentName.c_str()) ? true : false; -} -bool SkeletonRenderer::setAttachment (const std::string& slotName, const char* attachmentName) { - return spSkeleton_setAttachment(_skeleton, slotName.c_str(), attachmentName) ? true : false; -} - -spSkeleton* SkeletonRenderer::getSkeleton () { - return _skeleton; -} - -void SkeletonRenderer::setTimeScale (float scale) { - _timeScale = scale; -} -float SkeletonRenderer::getTimeScale () const { - return _timeScale; -} - -void SkeletonRenderer::setDebugSlotsEnabled (bool enabled) { - _debugSlots = enabled; -} -bool SkeletonRenderer::getDebugSlotsEnabled () const { - return _debugSlots; -} - -void SkeletonRenderer::setDebugBonesEnabled (bool enabled) { - _debugBones = enabled; -} -bool SkeletonRenderer::getDebugBonesEnabled () const { - return _debugBones; -} - -void SkeletonRenderer::onEnter () { -#if CC_ENABLE_SCRIPT_BINDING - if (_scriptType == kScriptTypeJavascript && ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnEnter)) return; -#endif - Node::onEnter(); - scheduleUpdate(); -} - -void SkeletonRenderer::onExit () { -#if CC_ENABLE_SCRIPT_BINDING - if (_scriptType == kScriptTypeJavascript && ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnExit)) return; -#endif - Node::onExit(); - unscheduleUpdate(); -} - -// --- CCBlendProtocol - -const BlendFunc& SkeletonRenderer::getBlendFunc () const { - return _blendFunc; -} - -void SkeletonRenderer::setBlendFunc (const BlendFunc &blendFunc) { - _blendFunc = blendFunc; -} - -void SkeletonRenderer::setOpacityModifyRGB (bool value) { - _premultipliedAlpha = value; -} - -bool SkeletonRenderer::isOpacityModifyRGB () const { - return _premultipliedAlpha; -} - -} diff --git a/native/cocos/editor-support/spine/SkeletonRenderer.h b/native/cocos/editor-support/spine/SkeletonRenderer.h deleted file mode 100644 index 56cb2a679e..0000000000 --- a/native/cocos/editor-support/spine/SkeletonRenderer.h +++ /dev/null @@ -1,137 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SKELETONRENDERER_H_ -#define SPINE_SKELETONRENDERER_H_ - -#include -#include "cocos2d.h" - -namespace spine { - -class AttachmentVertices; - -/* Draws a skeleton. */ -class SkeletonRenderer: public cocos2d::Node, public cocos2d::BlendProtocol { -public: - CREATE_FUNC(SkeletonRenderer); - static SkeletonRenderer* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false); - static SkeletonRenderer* createWithFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale = 1); - static SkeletonRenderer* createWithFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1); - - virtual void update (float deltaTime) override; - virtual void draw (cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t transformFlags) override; - virtual void drawDebug (cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t transformFlags); - virtual cocos2d::Rect getBoundingBox () const override; - virtual void onEnter () override; - virtual void onExit () override; - - spSkeleton* getSkeleton(); - - void setTimeScale(float scale); - float getTimeScale() const; - - /* */ - void setDebugSlotsEnabled(bool enabled); - bool getDebugSlotsEnabled() const; - - void setDebugBonesEnabled(bool enabled); - bool getDebugBonesEnabled() const; - - // --- Convenience methods for common Skeleton_* functions. - void updateWorldTransform (); - - void setToSetupPose (); - void setBonesToSetupPose (); - void setSlotsToSetupPose (); - - /* Returns 0 if the bone was not found. */ - spBone* findBone (const std::string& boneName) const; - /* Returns 0 if the slot was not found. */ - spSlot* findSlot (const std::string& slotName) const; - - /* Sets the skin used to look up attachments not found in the SkeletonData defaultSkin. Attachments from the new skin are - * attached if the corresponding attachment from the old skin was attached. Returns false if the skin was not found. - * @param skin May be empty string ("") for no skin.*/ - bool setSkin (const std::string& skinName); - /** @param skin May be 0 for no skin.*/ - bool setSkin (const char* skinName); - - /* Returns 0 if the slot or attachment was not found. */ - spAttachment* getAttachment (const std::string& slotName, const std::string& attachmentName) const; - /* Returns false if the slot or attachment was not found. - * @param attachmentName May be empty string ("") for no attachment. */ - bool setAttachment (const std::string& slotName, const std::string& attachmentName); - /* @param attachmentName May be 0 for no attachment. */ - bool setAttachment (const std::string& slotName, const char* attachmentName); - - // --- BlendProtocol - virtual void setBlendFunc (const cocos2d::BlendFunc& blendFunc)override; - virtual const cocos2d::BlendFunc& getBlendFunc () const override; - virtual void setOpacityModifyRGB (bool value) override; - virtual bool isOpacityModifyRGB () const override; - -CC_CONSTRUCTOR_ACCESS: - SkeletonRenderer (); - SkeletonRenderer (spSkeletonData* skeletonData, bool ownsSkeletonData = false); - SkeletonRenderer (const std::string& skeletonDataFile, spAtlas* atlas, float scale = 1); - SkeletonRenderer (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1); - - virtual ~SkeletonRenderer (); - - void initWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false); - void initWithJsonFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale = 1); - void initWithJsonFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1); - void initWithBinaryFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale = 1); - void initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1); - - virtual void initialize (); - -protected: - void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData); - virtual AttachmentVertices* getAttachmentVertices (spRegionAttachment* attachment) const; - virtual AttachmentVertices* getAttachmentVertices (spMeshAttachment* attachment) const; - - bool _ownsSkeletonData; - spAtlas* _atlas; - spAttachmentLoader* _attachmentLoader; - cocos2d::CustomCommand _debugCommand; - cocos2d::BlendFunc _blendFunc; - float* _worldVertices; - bool _premultipliedAlpha; - spSkeleton* _skeleton; - float _timeScale; - bool _debugSlots; - bool _debugBones; -}; - -} - -#endif /* SPINE_SKELETONRENDERER_H_ */ diff --git a/native/cocos/editor-support/spine/Skin.c b/native/cocos/editor-support/spine/Skin.c deleted file mode 100644 index 91f2d21fe7..0000000000 --- a/native/cocos/editor-support/spine/Skin.c +++ /dev/null @@ -1,106 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -_Entry* _Entry_create (int slotIndex, const char* name, spAttachment* attachment) { - _Entry* self = NEW(_Entry); - self->slotIndex = slotIndex; - MALLOC_STR(self->name, name); - self->attachment = attachment; - return self; -} - -void _Entry_dispose (_Entry* self) { - spAttachment_dispose(self->attachment); - FREE(self->name); - FREE(self); -} - -/**/ - -spSkin* spSkin_create (const char* name) { - spSkin* self = SUPER(NEW(_spSkin)); - MALLOC_STR(self->name, name); - return self; -} - -void spSkin_dispose (spSkin* self) { - _Entry* entry = SUB_CAST(_spSkin, self)->entries; - while (entry) { - _Entry* nextEntry = entry->next; - _Entry_dispose(entry); - entry = nextEntry; - } - - FREE(self->name); - FREE(self); -} - -void spSkin_addAttachment (spSkin* self, int slotIndex, const char* name, spAttachment* attachment) { - _Entry* newEntry = _Entry_create(slotIndex, name, attachment); - newEntry->next = SUB_CAST(_spSkin, self)->entries; - SUB_CAST(_spSkin, self)->entries = newEntry; -} - -spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name) { - const _Entry* entry = SUB_CAST(_spSkin, self)->entries; - while (entry) { - if (entry->slotIndex == slotIndex && strcmp(entry->name, name) == 0) return entry->attachment; - entry = entry->next; - } - return 0; -} - -const char* spSkin_getAttachmentName (const spSkin* self, int slotIndex, int attachmentIndex) { - const _Entry* entry = SUB_CAST(_spSkin, self)->entries; - int i = 0; - while (entry) { - if (entry->slotIndex == slotIndex) { - if (i == attachmentIndex) return entry->name; - i++; - } - entry = entry->next; - } - return 0; -} - -void spSkin_attachAll (const spSkin* self, spSkeleton* skeleton, const spSkin* oldSkin) { - const _Entry *entry = SUB_CAST(_spSkin, oldSkin)->entries; - while (entry) { - spSlot *slot = skeleton->slots[entry->slotIndex]; - if (slot->attachment == entry->attachment) { - spAttachment *attachment = spSkin_getAttachment(self, entry->slotIndex, entry->name); - if (attachment) spSlot_setAttachment(slot, attachment); - } - entry = entry->next; - } -} diff --git a/native/cocos/editor-support/spine/Skin.h b/native/cocos/editor-support/spine/Skin.h deleted file mode 100644 index 90ec026fa1..0000000000 --- a/native/cocos/editor-support/spine/Skin.h +++ /dev/null @@ -1,94 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SKIN_H_ -#define SPINE_SKIN_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct spSkeleton; - -typedef struct spSkin { - const char* const name; - -#ifdef __cplusplus - spSkin() : - name(0) { - } -#endif -} spSkin; - -/* Private structs, needed by Skeleton */ -typedef struct _Entry _Entry; -struct _Entry { - int slotIndex; - const char* name; - spAttachment* attachment; - _Entry* next; -}; - -typedef struct { - spSkin super; - _Entry* entries; -} _spSkin; - -spSkin* spSkin_create (const char* name); -void spSkin_dispose (spSkin* self); - -/* The Skin owns the attachment. */ -void spSkin_addAttachment (spSkin* self, int slotIndex, const char* name, spAttachment* attachment); -/* Returns 0 if the attachment was not found. */ -spAttachment* spSkin_getAttachment (const spSkin* self, int slotIndex, const char* name); - -/* Returns 0 if the slot or attachment was not found. */ -const char* spSkin_getAttachmentName (const spSkin* self, int slotIndex, int attachmentIndex); - -/** Attach each attachment in this skin if the corresponding attachment in oldSkin is currently attached. */ -void spSkin_attachAll (const spSkin* self, struct spSkeleton* skeleton, const spSkin* oldspSkin); - -#ifdef SPINE_SHORT_NAMES -typedef spSkin Skin; -#define Skin_create(...) spSkin_create(__VA_ARGS__) -#define Skin_dispose(...) spSkin_dispose(__VA_ARGS__) -#define Skin_addAttachment(...) spSkin_addAttachment(__VA_ARGS__) -#define Skin_getAttachment(...) spSkin_getAttachment(__VA_ARGS__) -#define Skin_getAttachmentName(...) spSkin_getAttachmentName(__VA_ARGS__) -#define Skin_attachAll(...) spSkin_attachAll(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_SKIN_H_ */ diff --git a/native/cocos/editor-support/spine/Slot.c b/native/cocos/editor-support/spine/Slot.c deleted file mode 100644 index 0f07aba1a8..0000000000 --- a/native/cocos/editor-support/spine/Slot.c +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -typedef struct { - spSlot super; - float attachmentTime; -} _spSlot; - -spSlot* spSlot_create (spSlotData* data, spBone* bone) { - spSlot* self = SUPER(NEW(_spSlot)); - CONST_CAST(spSlotData*, self->data) = data; - CONST_CAST(spBone*, self->bone) = bone; - spSlot_setToSetupPose(self); - return self; -} - -void spSlot_dispose (spSlot* self) { - FREE(self->attachmentVertices); - FREE(self); -} - -void spSlot_setAttachment (spSlot* self, spAttachment* attachment) { - if (attachment == self->attachment) return; - CONST_CAST(spAttachment*, self->attachment) = attachment; - SUB_CAST(_spSlot, self)->attachmentTime = self->bone->skeleton->time; - self->attachmentVerticesCount = 0; -} - -void spSlot_setAttachmentTime (spSlot* self, float time) { - SUB_CAST(_spSlot, self)->attachmentTime = self->bone->skeleton->time - time; -} - -float spSlot_getAttachmentTime (const spSlot* self) { - return self->bone->skeleton->time - SUB_CAST(_spSlot, self) ->attachmentTime; -} - -void spSlot_setToSetupPose (spSlot* self) { - self->r = self->data->r; - self->g = self->data->g; - self->b = self->data->b; - self->a = self->data->a; - - if (!self->data->attachmentName) - spSlot_setAttachment(self, 0); - else { - spAttachment* attachment = spSkeleton_getAttachmentForSlotIndex( - self->bone->skeleton, self->data->index, self->data->attachmentName); - CONST_CAST(spAttachment*, self->attachment) = 0; - spSlot_setAttachment(self, attachment); - } -} diff --git a/native/cocos/editor-support/spine/Slot.h b/native/cocos/editor-support/spine/Slot.h deleted file mode 100644 index 91b29fbfb1..0000000000 --- a/native/cocos/editor-support/spine/Slot.h +++ /dev/null @@ -1,90 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SLOT_H_ -#define SPINE_SLOT_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spSlot { - spSlotData* const data; - spBone* const bone; - float r, g, b, a; - spAttachment* const attachment; - - int attachmentVerticesCapacity; - int attachmentVerticesCount; - float* attachmentVertices; - -#ifdef __cplusplus - spSlot() : - data(0), - bone(0), - r(0), g(0), b(0), a(0), - attachment(0), - attachmentVerticesCapacity(0), - attachmentVerticesCount(0), - attachmentVertices(0) { - } -#endif -} spSlot; - -spSlot* spSlot_create (spSlotData* data, spBone* bone); -void spSlot_dispose (spSlot* self); - -/* @param attachment May be 0 to clear the attachment for the slot. */ -void spSlot_setAttachment (spSlot* self, spAttachment* attachment); - -void spSlot_setAttachmentTime (spSlot* self, float time); -float spSlot_getAttachmentTime (const spSlot* self); - -void spSlot_setToSetupPose (spSlot* self); - -#ifdef SPINE_SHORT_NAMES -typedef spSlot Slot; -#define Slot_create(...) spSlot_create(__VA_ARGS__) -#define Slot_dispose(...) spSlot_dispose(__VA_ARGS__) -#define Slot_setAttachment(...) spSlot_setAttachment(__VA_ARGS__) -#define Slot_setAttachmentTime(...) spSlot_setAttachmentTime(__VA_ARGS__) -#define Slot_getAttachmentTime(...) spSlot_getAttachmentTime(__VA_ARGS__) -#define Slot_setToSetupPose(...) spSlot_setToSetupPose(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_SLOT_H_ */ diff --git a/native/cocos/editor-support/spine/SlotData.c b/native/cocos/editor-support/spine/SlotData.c deleted file mode 100644 index 46f9734dfc..0000000000 --- a/native/cocos/editor-support/spine/SlotData.c +++ /dev/null @@ -1,58 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -spSlotData* spSlotData_create (const int index, const char* name, spBoneData* boneData) { - spSlotData* self = NEW(spSlotData); - CONST_CAST(int, self->index) = index; - MALLOC_STR(self->name, name); - CONST_CAST(spBoneData*, self->boneData) = boneData; - self->r = 1; - self->g = 1; - self->b = 1; - self->a = 1; - return self; -} - -void spSlotData_dispose (spSlotData* self) { - FREE(self->name); - FREE(self->attachmentName); - FREE(self); -} - -void spSlotData_setAttachmentName (spSlotData* self, const char* attachmentName) { - FREE(self->attachmentName); - if (attachmentName) - MALLOC_STR(self->attachmentName, attachmentName); - else - CONST_CAST(char*, self->attachmentName) = 0; -} diff --git a/native/cocos/editor-support/spine/SlotData.h b/native/cocos/editor-support/spine/SlotData.h deleted file mode 100644 index 6a016895c3..0000000000 --- a/native/cocos/editor-support/spine/SlotData.h +++ /dev/null @@ -1,86 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SLOTDATA_H_ -#define SPINE_SLOTDATA_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - SP_BLEND_MODE_NORMAL, SP_BLEND_MODE_ADDITIVE, SP_BLEND_MODE_MULTIPLY, SP_BLEND_MODE_SCREEN -} spBlendMode; - -typedef struct spSlotData { - const int index; - const char* const name; - const spBoneData* const boneData; - const char* attachmentName; - float r, g, b, a; - spBlendMode blendMode; - -#ifdef __cplusplus - spSlotData() : - index(0), - name(0), - boneData(0), - attachmentName(0), - r(0), g(0), b(0), a(0), - blendMode(SP_BLEND_MODE_NORMAL) { - } -#endif -} spSlotData; - -spSlotData* spSlotData_create (const int index, const char* name, spBoneData* boneData); -void spSlotData_dispose (spSlotData* self); - -/* @param attachmentName May be 0 for no setup pose attachment. */ -void spSlotData_setAttachmentName (spSlotData* self, const char* attachmentName); - -#ifdef SPINE_SHORT_NAMES -typedef spBlendMode BlendMode; -#define BLEND_MODE_NORMAL SP_BLEND_MODE_NORMAL -#define BLEND_MODE_ADDITIVE SP_BLEND_MODE_ADDITIVE -#define BLEND_MODE_MULTIPLY SP_BLEND_MODE_MULTIPLY -#define BLEND_MODE_SCREEN SP_BLEND_MODE_SCREEN -typedef spSlotData SlotData; -#define SlotData_create(...) spSlotData_create(__VA_ARGS__) -#define SlotData_dispose(...) spSlotData_dispose(__VA_ARGS__) -#define SlotData_setAttachmentName(...) spSlotData_setAttachmentName(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_SLOTDATA_H_ */ diff --git a/native/cocos/editor-support/spine/TransformConstraint.c b/native/cocos/editor-support/spine/TransformConstraint.c deleted file mode 100644 index 528cc6a8a8..0000000000 --- a/native/cocos/editor-support/spine/TransformConstraint.c +++ /dev/null @@ -1,121 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include -#include - -spTransformConstraint* spTransformConstraint_create (spTransformConstraintData* data, const spSkeleton* skeleton) { - int i; - spTransformConstraint* self = NEW(spTransformConstraint); - CONST_CAST(spTransformConstraintData*, self->data) = data; - self->rotateMix = data->rotateMix; - self->translateMix = data->translateMix; - self->scaleMix = data->scaleMix; - self->shearMix = data->shearMix; - self->bonesCount = data->bonesCount; - CONST_CAST(spBone**, self->bones) = MALLOC(spBone*, self->bonesCount); - for (i = 0; i < self->bonesCount; ++i) - self->bones[i] = spSkeleton_findBone(skeleton, self->data->bones[i]->name); - self->target = spSkeleton_findBone(skeleton, self->data->target->name); - return self; -} - -void spTransformConstraint_dispose (spTransformConstraint* self) { - FREE(self->bones); - FREE(self); -} - -void spTransformConstraint_apply (spTransformConstraint* self) { - float rotateMix = self->rotateMix, translateMix = self->translateMix, scaleMix = self->scaleMix, shearMix = self->shearMix; - spBone* target = self->target; - float ta = target->a, tb = target->b, tc = target->c, td = target->d; - float degRadReflect = ta * td - tb * tc > 0 ? DEG_RAD : -DEG_RAD; - float offsetRotation = self->data->offsetRotation * degRadReflect, offsetShearY = self->data->offsetShearY * degRadReflect; - int /*bool*/ modified; - int i; - for (i = 0; i < self->bonesCount; ++i) { - spBone* bone = self->bones[i]; - modified = 0; - - if (rotateMix != 0) { - float a = bone->a, b = bone->b, c = bone->c, d = bone->d; - float r = ATAN2(tc, ta) - ATAN2(c, a) + offsetRotation; - float cosine, sine; - if (r > PI) r -= PI2; - else if (r < -PI) r += PI2; - r *= rotateMix; - cosine = COS(r); - sine = SIN(r); - CONST_CAST(float, bone->a) = cosine * a - sine * c; - CONST_CAST(float, bone->b) = cosine * b - sine * d; - CONST_CAST(float, bone->c) = sine * a + cosine * c; - CONST_CAST(float, bone->d) = sine * b + cosine * d; - modified = 1; - } - - if (translateMix != 0) { - float x, y; - spBone_localToWorld(target, self->data->offsetX, self->data->offsetY, &x, &y); - CONST_CAST(float, bone->worldX) += (x - bone->worldX) * translateMix; - CONST_CAST(float, bone->worldY) += (y - bone->worldY) * translateMix; - modified = 1; - } - - if (scaleMix > 0) { - float s = SQRT(bone->a * bone->a + bone->c * bone->c); - float ts = SQRT(ta * ta + tc * tc); - if (s > 0.00001f) s = (s + (ts - s + self->data->offsetScaleX) * scaleMix) / s; - CONST_CAST(float, bone->a) *= s; - CONST_CAST(float, bone->c) *= s; - s = SQRT(bone->b * bone->b + bone->d * bone->d); - ts = SQRT(tb * tb + td * td); - if (s > 0.00001f) s = (s + (ts - s + self->data->offsetScaleY) * scaleMix) / s; - CONST_CAST(float, bone->b) *= s; - CONST_CAST(float, bone->d) *= s; - modified = 1; - } - - if (shearMix > 0) { - float b = bone->b, d = bone->d; - float by = ATAN2(d, b); - float r = ATAN2(td, tb) - ATAN2(tc, ta) - (by - ATAN2(bone->c, bone->a)); - float s = SQRT(b * b + d * d); - if (r > PI) r -= PI2; - else if (r < -PI) r += PI2; - r = by + (r + offsetShearY) * shearMix; - CONST_CAST(float, bone->b) = COS(r) * s; - CONST_CAST(float, bone->d) = SIN(r) * s; - modified = 1; - } - - if (modified) CONST_CAST(int, bone->appliedValid) = 0; - } -} diff --git a/native/cocos/editor-support/spine/TransformConstraint.h b/native/cocos/editor-support/spine/TransformConstraint.h deleted file mode 100644 index 254297834c..0000000000 --- a/native/cocos/editor-support/spine/TransformConstraint.h +++ /dev/null @@ -1,80 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_TRANSFORMCONSTRAINT_H_ -#define SPINE_TRANSFORMCONSTRAINT_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct spSkeleton; - -typedef struct spTransformConstraint { - spTransformConstraintData* const data; - int bonesCount; - spBone** const bones; - spBone* target; - float rotateMix, translateMix, scaleMix, shearMix; - -#ifdef __cplusplus - spTransformConstraint() : - data(0), - bonesCount(0), - bones(0), - target(0), - rotateMix(0), - translateMix(0), - scaleMix(0), - shearMix(0) { - } -#endif -} spTransformConstraint; - -spTransformConstraint* spTransformConstraint_create (spTransformConstraintData* data, const struct spSkeleton* skeleton); -void spTransformConstraint_dispose (spTransformConstraint* self); - -void spTransformConstraint_apply (spTransformConstraint* self); - -#ifdef SPINE_SHORT_NAMES -typedef spTransformConstraint TransformConstraint; -#define TransformConstraint_create(...) spTransformConstraint_create(__VA_ARGS__) -#define TransformConstraint_dispose(...) spTransformConstraint_dispose(__VA_ARGS__) -#define TransformConstraint_apply(...) spTransformConstraint_apply(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_TRANSFORMCONSTRAINT_H_ */ diff --git a/native/cocos/editor-support/spine/TransformConstraintData.c b/native/cocos/editor-support/spine/TransformConstraintData.c deleted file mode 100644 index 34064e0f85..0000000000 --- a/native/cocos/editor-support/spine/TransformConstraintData.c +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -spTransformConstraintData* spTransformConstraintData_create (const char* name) { - spTransformConstraintData* self = NEW(spTransformConstraintData); - MALLOC_STR(self->name, name); - return self; -} - -void spTransformConstraintData_dispose (spTransformConstraintData* self) { - FREE(self->name); - FREE(self->bones); - FREE(self); -} diff --git a/native/cocos/editor-support/spine/TransformConstraintData.h b/native/cocos/editor-support/spine/TransformConstraintData.h deleted file mode 100644 index f7b8f211fa..0000000000 --- a/native/cocos/editor-support/spine/TransformConstraintData.h +++ /dev/null @@ -1,82 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_TRANSFORMCONSTRAINTDATA_H_ -#define SPINE_TRANSFORMCONSTRAINTDATA_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spTransformConstraintData { - const char* const name; - int order; - int bonesCount; - spBoneData** const bones; - spBoneData* target; - float rotateMix, translateMix, scaleMix, shearMix; - float offsetRotation, offsetX, offsetY, offsetScaleX, offsetScaleY, offsetShearY; - -#ifdef __cplusplus - spTransformConstraintData() : - name(0), - bonesCount(0), - bones(0), - target(0), - rotateMix(0), - translateMix(0), - scaleMix(0), - shearMix(0), - offsetRotation(0), - offsetX(0), - offsetY(0), - offsetScaleX(0), - offsetScaleY(0), - offsetShearY(0) { - } -#endif -} spTransformConstraintData; - -spTransformConstraintData* spTransformConstraintData_create (const char* name); -void spTransformConstraintData_dispose (spTransformConstraintData* self); - -#ifdef SPINE_SHORT_NAMES -typedef spTransformConstraintData TransformConstraintData; -#define TransformConstraintData_create(...) spTransformConstraintData_create(__VA_ARGS__) -#define TransformConstraintData_dispose(...) spTransformConstraintData_dispose(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_TRANSFORMCONSTRAINTDATA_H_ */ diff --git a/native/cocos/editor-support/spine/VertexAttachment.c b/native/cocos/editor-support/spine/VertexAttachment.c deleted file mode 100644 index 32357d3caa..0000000000 --- a/native/cocos/editor-support/spine/VertexAttachment.c +++ /dev/null @@ -1,111 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -void _spVertexAttachment_deinit (spVertexAttachment* attachment) { - _spAttachment_deinit(SUPER(attachment)); - FREE(attachment->bones); - FREE(attachment->vertices); -} - -void spVertexAttachment_computeWorldVertices (spVertexAttachment* self, spSlot* slot, float* worldVertices) { - spVertexAttachment_computeWorldVertices1(self, 0, self->worldVerticesLength, slot, worldVertices, 0); -} - -void spVertexAttachment_computeWorldVertices1 (spVertexAttachment* self, int start, int count, spSlot* slot, float* worldVertices, int offset) { - spSkeleton* skeleton; - int deformLength; - float* deform; - float* vertices; - int* bones; - - count += offset; - skeleton = slot->bone->skeleton; - deformLength = slot->attachmentVerticesCount; - deform = slot->attachmentVertices; - vertices = self->vertices; - bones = self->bones; - if (!bones) { - spBone* bone; - int v, w; - float x, y; - if (deformLength > 0) vertices = deform; - bone = slot->bone; - x = bone->worldX; - y = bone->worldY; - for (v = start, w = offset; w < count; v += 2, w += 2) { - float vx = vertices[v], vy = vertices[v + 1]; - worldVertices[w] = vx * bone->a + vy * bone->b + x; - worldVertices[w + 1] = vx * bone->c + vy * bone->d + y; - } - } else { - int v = 0, skip = 0, i; - spBone** skeletonBones; - for (i = 0; i < start; i += 2) { - int n = bones[v]; - v += n + 1; - skip += n; - } - skeletonBones = skeleton->bones; - if (deformLength == 0) { - int w, b; - for (w = offset, b = skip * 3; w < count; w += 2) { - float wx = 0, wy = 0; - int n = bones[v++]; - n += v; - for (; v < n; v++, b += 3) { - spBone* bone = skeletonBones[bones[v]]; - float vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2]; - wx += (vx * bone->a + vy * bone->b + bone->worldX) * weight; - wy += (vx * bone->c + vy * bone->d + bone->worldY) * weight; - } - worldVertices[w] = wx; - worldVertices[w + 1] = wy; - } - } else { - int w, b, f; - for (w = offset, b = skip * 3, f = skip << 1; w < count; w += 2) { - float wx = 0, wy = 0; - int n = bones[v++]; - n += v; - for (; v < n; v++, b += 3, f += 2) { - spBone* bone = skeletonBones[bones[v]]; - float vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2]; - wx += (vx * bone->a + vy * bone->b + bone->worldX) * weight; - wy += (vx * bone->c + vy * bone->d + bone->worldY) * weight; - } - worldVertices[w] = wx; - worldVertices[w + 1] = wy; - } - } - } -} diff --git a/native/cocos/editor-support/spine/VertexAttachment.h b/native/cocos/editor-support/spine/VertexAttachment.h deleted file mode 100644 index 530aa38dcf..0000000000 --- a/native/cocos/editor-support/spine/VertexAttachment.h +++ /dev/null @@ -1,67 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_VERTEXATTACHMENT_H_ -#define SPINE_VERTEXATTACHMENT_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct spVertexAttachment spVertexAttachment; -struct spVertexAttachment { - spAttachment super; - - int bonesCount; - int* bones; - - int verticesCount; - float* vertices; - - int worldVerticesLength; -}; - -void spVertexAttachment_computeWorldVertices (spVertexAttachment* self, spSlot* slot, float* worldVertices); -void spVertexAttachment_computeWorldVertices1 (spVertexAttachment* self, int start, int count, spSlot* slot, float* worldVertices, int offset); - -#ifdef SPINE_SHORT_NAMES -typedef spVertexAttachment VertexAttachment; -#define VertexAttachment_computeWorldVertices(...) spVertexAttachment_computeWorldVertices(__VA_ARGS__) -#define VertexAttachment_computeWorldVertices1(...) spVertexAttachment_computeWorldVertices1(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_VERTEXATTACHMENT_H_ */ diff --git a/native/cocos/editor-support/spine/extension.c b/native/cocos/editor-support/spine/extension.c deleted file mode 100644 index cc43ad3dcb..0000000000 --- a/native/cocos/editor-support/spine/extension.c +++ /dev/null @@ -1,78 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -static void* (*mallocFunc) (size_t size) = malloc; -static void* (*debugMallocFunc) (size_t size, const char* file, int line) = NULL; -static void (*freeFunc) (void* ptr) = free; - -void* _malloc (size_t size, const char* file, int line) { - if(debugMallocFunc) - return debugMallocFunc(size, file, line); - - return mallocFunc(size); -} -void* _calloc (size_t num, size_t size, const char* file, int line) { - void* ptr = _malloc(num * size, file, line); - if (ptr) memset(ptr, 0, num * size); - return ptr; -} -void _free (void* ptr) { - freeFunc(ptr); -} - -void _setDebugMalloc(void* (*malloc) (size_t size, const char* file, int line)) { - debugMallocFunc = malloc; -} - -void _setMalloc (void* (*malloc) (size_t size)) { - mallocFunc = malloc; -} -void _setFree (void (*free) (void* ptr)) { - freeFunc = free; -} - -char* _readFile (const char* path, int* length) { - char *data; - FILE *file = fopen(path, "rb"); - if (!file) return 0; - - fseek(file, 0, SEEK_END); - *length = (int)ftell(file); - fseek(file, 0, SEEK_SET); - - data = MALLOC(char, *length); - fread(data, 1, *length, file); - fclose(file); - - return data; -} diff --git a/native/cocos/editor-support/spine/extension.h b/native/cocos/editor-support/spine/extension.h deleted file mode 100644 index e51bec4b63..0000000000 --- a/native/cocos/editor-support/spine/extension.h +++ /dev/null @@ -1,297 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -/* - Implementation notes: - - - An OOP style is used where each "class" is made up of a struct and a number of functions prefixed with the struct name. - - - struct fields that are const are readonly. Either they are set in a create function and can never be changed, or they can only - be changed by calling a function. - - - Inheritance is done using a struct field named "super" as the first field, allowing the struct to be cast to its "super class". - This works because a pointer to a struct is guaranteed to be a pointer to the first struct field. - - - Classes intended for inheritance provide init/deinit functions which subclasses must call in their create/dispose functions. - - - Polymorphism is done by a base class providing function pointers in its init function. The public API delegates to these - function pointers. - - - Subclasses do not provide a dispose function, instead the base class' dispose function should be used, which will delegate to - a dispose function pointer. - - - Classes not designed for inheritance cannot be extended because they may use an internal subclass to hide private data and don't - expose function pointers. - - - The public API hides implementation details, such as init/deinit functions. An internal API is exposed by extension.h to allow - classes to be extended. Internal functions begin with underscore (_). - - - OOP in C tends to lose type safety. Macros for casting are provided in extension.h to give context for why a cast is being done. - - - If SPINE_SHORT_NAMES is defined, the "sp" prefix for all class names is optional. - */ - -#ifndef SPINE_EXTENSION_H_ -#define SPINE_EXTENSION_H_ - -/* All allocation uses these. */ -#define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * (COUNT), __FILE__, __LINE__)) -#define CALLOC(TYPE,COUNT) ((TYPE*)_calloc(COUNT, sizeof(TYPE), __FILE__, __LINE__)) -#define NEW(TYPE) CALLOC(TYPE,1) - -/* Gets the direct super class. Type safe. */ -#define SUPER(VALUE) (&VALUE->super) - -/* Cast to a super class. Not type safe, use with care. Prefer SUPER() where possible. */ -#define SUPER_CAST(TYPE,VALUE) ((TYPE*)VALUE) - -/* Cast to a sub class. Not type safe, use with care. */ -#define SUB_CAST(TYPE,VALUE) ((TYPE*)VALUE) - -/* Casts away const. Can be used as an lvalue. Not type safe, use with care. */ -#define CONST_CAST(TYPE,VALUE) (*(TYPE*)&VALUE) - -/* Gets the vtable for the specified type. Not type safe, use with care. */ -#define VTABLE(TYPE,VALUE) ((_##TYPE##Vtable*)((TYPE*)VALUE)->vtable) - -/* Frees memory. Can be used on const types. */ -#define FREE(VALUE) _free((void*)VALUE) - -/* Allocates a new char[], assigns it to TO, and copies FROM to it. Can be used on const types. */ -#define MALLOC_STR(TO,FROM) strcpy(CONST_CAST(char*, TO) = (char*)MALLOC(char, strlen(FROM) + 1), FROM) - -#define PI 3.1415926535897932385f -#define PI2 (PI * 2) -#define DEG_RAD (PI / 180) -#define RAD_DEG (180 / PI) - -#define ABS(A) ((A) < 0? -(A): (A)) -#define SIGNUM(A) ((A) < 0? -1: (A) > 0 ? 1 : 0) - -#ifdef __STDC_VERSION__ -#define FMOD(A,B) fmodf(A, B) -#define ATAN2(A,B) atan2f(A, B) -#define SIN(A) sinf(A) -#define COS(A) cosf(A) -#define SQRT(A) sqrtf(A) -#define ACOS(A) acosf(A) -#else -#define FMOD(A,B) (float)fmod(A, B) -#define ATAN2(A,B) (float)atan2(A, B) -#define COS(A) (float)cos(A) -#define SIN(A) (float)sin(A) -#define SQRT(A) (float)sqrt(A) -#define ACOS(A) (float)acos(A) -#endif - -#define SIN_DEG(A) SIN((A) * DEG_RAD) -#define COS_DEG(A) COS((A) * DEG_RAD) -#define CLAMP(x, min, max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x))) -#ifndef MIN -#define MIN(x, y) ((x) < (y) ? (x) : (y)) -#endif -#ifndef MAX -#define MAX(x, y) ((x) > (y) ? (x) : (y)) -#endif - -#define UNUSED(x) (void)(x) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Functions that must be implemented: - */ - -void _spAtlasPage_createTexture (spAtlasPage* self, const char* path); -void _spAtlasPage_disposeTexture (spAtlasPage* self); -char* _spUtil_readFile (const char* path, int* length); - -#ifdef SPINE_SHORT_NAMES -#define _AtlasPage_createTexture(...) _spAtlasPage_createTexture(__VA_ARGS__) -#define _AtlasPage_disposeTexture(...) _spAtlasPage_disposeTexture(__VA_ARGS__) -#define _Util_readFile(...) _spUtil_readFile(__VA_ARGS__) -#endif - -/* - * Internal API available for extension: - */ - -void* _malloc (size_t size, const char* file, int line); -void* _calloc (size_t num, size_t size, const char* file, int line); -void _free (void* ptr); - -void _setMalloc (void* (*_malloc) (size_t size)); -void _setDebugMalloc (void* (*_malloc) (size_t size, const char* file, int line)); -void _setFree (void (*_free) (void* ptr)); - -char* _readFile (const char* path, int* length); - -/**/ - -typedef union _spEventQueueItem { - int type; - spTrackEntry* entry; - spEvent* event; -} _spEventQueueItem; - -typedef struct _spAnimationState _spAnimationState; - -typedef struct _spEventQueue { - _spAnimationState* state; - _spEventQueueItem* objects; - int objectsCount; - int objectsCapacity; - int /*boolean*/ drainDisabled; - -#ifdef __cplusplus - _spEventQueue() : - state(0), - objects(0), - objectsCount(0), - objectsCapacity(0), - drainDisabled(0) { - } -#endif -} _spEventQueue; - -struct _spAnimationState { - spAnimationState super; - - int eventsCount; - spEvent** events; - - _spEventQueue* queue; - - int* propertyIDs; - int propertyIDsCount; - int propertyIDsCapacity; - - int /*boolean*/ animationsChanged; - -#ifdef __cplusplus - _spAnimationState() : - super(), - eventsCount(0), - events(0), - queue(0), - propertyIDs(0), - propertyIDsCount(0), - propertyIDsCapacity(0), - animationsChanged(0) { - } -#endif -}; - - -/**/ - -/* configureAttachment and disposeAttachment may be 0. */ -void _spAttachmentLoader_init (spAttachmentLoader* self, - void (*dispose) (spAttachmentLoader* self), - spAttachment* (*createAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, - const char* path), - void (*configureAttachment) (spAttachmentLoader* self, spAttachment*), - void (*disposeAttachment) (spAttachmentLoader* self, spAttachment*) -); -void _spAttachmentLoader_deinit (spAttachmentLoader* self); -/* Can only be called from createAttachment. */ -void _spAttachmentLoader_setError (spAttachmentLoader* self, const char* error1, const char* error2); -void _spAttachmentLoader_setUnknownTypeError (spAttachmentLoader* self, spAttachmentType type); - -#ifdef SPINE_SHORT_NAMES -#define _AttachmentLoader_init(...) _spAttachmentLoader_init(__VA_ARGS__) -#define _AttachmentLoader_deinit(...) _spAttachmentLoader_deinit(__VA_ARGS__) -#define _AttachmentLoader_setError(...) _spAttachmentLoader_setError(__VA_ARGS__) -#define _AttachmentLoader_setUnknownTypeError(...) _spAttachmentLoader_setUnknownTypeError(__VA_ARGS__) -#endif - -/**/ - -void _spAttachment_init (spAttachment* self, const char* name, spAttachmentType type, -void (*dispose) (spAttachment* self)); -void _spAttachment_deinit (spAttachment* self); -void _spVertexAttachment_deinit (spVertexAttachment* self); - -#ifdef SPINE_SHORT_NAMES -#define _Attachment_init(...) _spAttachment_init(__VA_ARGS__) -#define _Attachment_deinit(...) _spAttachment_deinit(__VA_ARGS__) -#define _VertexAttachment_deinit(...) _spVertexAttachment_deinit(__VA_ARGS__) -#endif - -/**/ - -void _spTimeline_init (spTimeline* self, spTimelineType type, - void (*dispose) (spTimeline* self), - void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, - int* eventsCount, float alpha, int setupPose, int mixingOut), - int (*getPropertyId) (const spTimeline* self)); -void _spTimeline_deinit (spTimeline* self); - -#ifdef SPINE_SHORT_NAMES -#define _Timeline_init(...) _spTimeline_init(__VA_ARGS__) -#define _Timeline_deinit(...) _spTimeline_deinit(__VA_ARGS__) -#endif - -/**/ - -void _spCurveTimeline_init (spCurveTimeline* self, spTimelineType type, int framesCount, - void (*dispose) (spTimeline* self), - void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut), - int (*getPropertyId) (const spTimeline* self)); -void _spCurveTimeline_deinit (spCurveTimeline* self); -int _spCurveTimeline_binarySearch (float *values, int valuesLength, float target, int step); - -#ifdef SPINE_SHORT_NAMES -#define _CurveTimeline_init(...) _spCurveTimeline_init(__VA_ARGS__) -#define _CurveTimeline_deinit(...) _spCurveTimeline_deinit(__VA_ARGS__) -#define _CurveTimeline_binarySearch(...) _spCurveTimeline_binarySearch(__VA_ARGS__) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SPINE_EXTENSION_H_ */ diff --git a/native/cocos/editor-support/spine/kvec.h b/native/cocos/editor-support/spine/kvec.h deleted file mode 100644 index 99f49ccb18..0000000000 --- a/native/cocos/editor-support/spine/kvec.h +++ /dev/null @@ -1,92 +0,0 @@ -/* The MIT License - - Copyright (c) 2008, by Attractive Chaos - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -/* - An example: - -#include "kvec.h" -int main() { - kvec_t(int) array; - kv_init(array); - kv_push(int, array, 10); // append - kv_a(int, array, 20) = 5; // dynamic - kv_A(array, 20) = 4; // static - kv_destroy(array); - return 0; -} -*/ - -/* - 2008-09-22 (0.1.0): - - * The initial version. - -*/ - -#ifndef AC_KVEC_H -#define AC_KVEC_H - -#include - -#define kv_roundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x)) - -#define kvec_t(type) struct { size_t n, m; type *a; } -#define kv_init(v) ((v).n = (v).m = 0, (v).a = 0) -#define kv_destroy(v) free((v).a) -#define kv_A(v, i) ((v).a[(i)]) -#define kv_array(v) ((v).a) -#define kv_pop(v) ((v).a[--(v).n]) -#define kv_size(v) ((v).n) -#define kv_max(v) ((v).m) - -#define kv_resize(type, v, s) ((v).m = (s), (v).a = (type*)realloc((v).a, sizeof(type) * (v).m)) -#define kv_trim(type, v) (kv_resize(type, (v), kv_size(v))) - -#define kv_copy(type, v1, v0) do { \ - if ((v1).m < (v0).n) kv_resize(type, v1, (v0).n); \ - (v1).n = (v0).n; \ - memcpy((v1).a, (v0).a, sizeof(type) * (v0).n); \ - } while (0) \ - -#define kv_push(type, v, x) do { \ - if ((v).n == (v).m) { \ - (v).m = (v).m? (v).m<<1 : 2; \ - (v).a = (type*)realloc((v).a, sizeof(type) * (v).m); \ - } \ - (v).a[(v).n++] = (x); \ - } while (0) - -#define kv_pushp(type, v) (((v).n == (v).m)? \ - ((v).m = ((v).m? (v).m<<1 : 2), \ - (v).a = (type*)realloc((v).a, sizeof(type) * (v).m), 0) \ - : 0), ((v).a + ((v).n++)) - -#define kv_a(type, v, i) (((v).m <= (size_t)(i)? \ - ((v).m = (v).n = (i) + 1, kv_roundup32((v).m), \ - (v).a = (type*)realloc((v).a, sizeof(type) * (v).m), 0) \ - : (v).n <= (size_t)(i)? (v).n = (i) + 1 \ - : 0), (v).a[(i)]) - -#endif diff --git a/native/cocos/editor-support/spine/proj.win32/libSpine.vcxproj b/native/cocos/editor-support/spine/proj.win32/libSpine.vcxproj deleted file mode 100644 index 1741dd9d94..0000000000 --- a/native/cocos/editor-support/spine/proj.win32/libSpine.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {B7C2A162-DEC9-4418-972E-240AB3CBFCAE} - libSpine - 8.1 - - - - StaticLibrary - true - v120 - v120_xp - v140 - v140_xp - v140 - v140_xp - Unicode - - - StaticLibrary - false - v120 - v120_xp - v140 - v140_xp - v140 - v140_xp - true - Unicode - - - - - - - - - - - - - - - $(SolutionDir)$(Configuration).win32\ - $(Configuration).win32\ - - - $(SolutionDir)$(Configuration).win32\ - $(Configuration).win32\ - - - - Level3 - Disabled - - - $(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - 4267;4251;4244;%(DisableSpecificWarnings) - false - - - true - - - - - Level3 - MinSpace - true - true - - - WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) - None - false - - - true - true - true - - - - - - \ No newline at end of file diff --git a/native/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters b/native/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters deleted file mode 100755 index 10e617c877..0000000000 --- a/native/cocos/editor-support/spine/proj.win32/libSpine.vcxproj.filters +++ /dev/null @@ -1,248 +0,0 @@ - - - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - diff --git a/native/cocos/editor-support/spine/spine-cocos2dx.cpp b/native/cocos/editor-support/spine/spine-cocos2dx.cpp deleted file mode 100644 index 1507002610..0000000000 --- a/native/cocos/editor-support/spine/spine-cocos2dx.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -namespace spine { - static CustomTextureLoader _customTextureLoader = nullptr; - void spAtlasPage_setCustomTextureLoader (CustomTextureLoader texLoader) { - _customTextureLoader = texLoader; - } -} - -USING_NS_CC; - -GLuint wrap (spAtlasWrap wrap) { - return wrap == SP_ATLAS_CLAMPTOEDGE ? GL_CLAMP_TO_EDGE : GL_REPEAT; -} - -GLuint filter (spAtlasFilter filter) { - switch (filter) { - case SP_ATLAS_UNKNOWN_FILTER: - break; - case SP_ATLAS_NEAREST: - return GL_NEAREST; - case SP_ATLAS_LINEAR: - return GL_LINEAR; - case SP_ATLAS_MIPMAP: - return GL_LINEAR_MIPMAP_LINEAR; - case SP_ATLAS_MIPMAP_NEAREST_NEAREST: - return GL_NEAREST_MIPMAP_NEAREST; - case SP_ATLAS_MIPMAP_LINEAR_NEAREST: - return GL_LINEAR_MIPMAP_NEAREST; - case SP_ATLAS_MIPMAP_NEAREST_LINEAR: - return GL_NEAREST_MIPMAP_LINEAR; - case SP_ATLAS_MIPMAP_LINEAR_LINEAR: - return GL_LINEAR_MIPMAP_LINEAR; - } - return GL_LINEAR; -} - -void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) { - Texture2D* texture = nullptr; - if (spine::_customTextureLoader) { - texture = spine::_customTextureLoader(path); - } - if (!texture) { - texture = Director::getInstance()->getTextureCache()->addImage(path); - } - CCASSERT(texture != nullptr, "Invalid image"); - texture->retain(); - - Texture2D::TexParams textureParams = {filter(self->minFilter), filter(self->magFilter), wrap(self->uWrap), wrap(self->vWrap)}; - texture->setTexParameters(textureParams); - - self->rendererObject = texture; - self->width = texture->getPixelsWide(); - self->height = texture->getPixelsHigh(); -} - -void _spAtlasPage_disposeTexture (spAtlasPage* self) { - ((Texture2D*)self->rendererObject)->release(); -} - -char* _spUtil_readFile (const char* path, int* length) { - Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path)); - if (data.isNull()) return 0; - - // avoid buffer overflow (int is shorter than ssize_t in certain platforms) -#if COCOS2D_VERSION >= 0x00031200 - ssize_t tmpLen; - char *ret = (char*)data.takeBuffer(&tmpLen); - *length = static_cast(tmpLen); - return ret; -#else - *length = static_cast(data.getSize()); - char* bytes = MALLOC(char, *length); - memcpy(bytes, data.getBytes(), *length); - return bytes; -#endif -} diff --git a/native/cocos/editor-support/spine/spine-cocos2dx.h b/native/cocos/editor-support/spine/spine-cocos2dx.h deleted file mode 100644 index 497d127964..0000000000 --- a/native/cocos/editor-support/spine/spine-cocos2dx.h +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_COCOS2DX_H_ -#define SPINE_COCOS2DX_H_ - -#include -#include "cocos2d.h" -#include -#include -#include -#include - -namespace spine { - typedef cocos2d::Texture2D* (*CustomTextureLoader)(const char* path); - // set custom texture loader for _spAtlasPage_createTexture - void spAtlasPage_setCustomTextureLoader(CustomTextureLoader texLoader); -} - -#endif /* SPINE_COCOS2DX_H_ */ diff --git a/native/cocos/editor-support/spine/spine.h b/native/cocos/editor-support/spine/spine.h deleted file mode 100644 index 7847eb0c4c..0000000000 --- a/native/cocos/editor-support/spine/spine.h +++ /dev/null @@ -1,58 +0,0 @@ -/****************************************************************************** - * Spine Runtimes Software License v2.5 - * - * Copyright (c) 2013-2016, Esoteric Software - * All rights reserved. - * - * You are granted a perpetual, non-exclusive, non-sublicensable, and - * non-transferable license to use, install, execute, and perform the Spine - * Runtimes software and derivative works solely for personal or internal - * use. Without the written permission of Esoteric Software (see Section 2 of - * the Spine Software License Agreement), you may not (a) modify, translate, - * adapt, or develop new applications using the Spine Runtimes or otherwise - * create derivative works or improvements of the Spine Runtimes or (b) remove, - * delete, alter, or obscure any trademarks or any copyright, trademark, patent, - * or other intellectual property or proprietary rights notices on or in the - * Software, including any copy thereof. Redistributions in binary or source - * form must include this license and terms. - * - * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "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 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 THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef SPINE_SPINE_H_ -#define SPINE_SPINE_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif /* SPINE_SPINE_H_ */ diff --git a/native/cocos/math/CCAffineTransform.cpp b/native/cocos/math/CCAffineTransform.cpp deleted file mode 100644 index 6dd4221c10..0000000000 --- a/native/cocos/math/CCAffineTransform.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "math/CCAffineTransform.h" - -#include -#include - -using namespace std; - - -NS_CC_BEGIN - -AffineTransform __CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty) -{ - AffineTransform t; - t.a = a; t.b = b; t.c = c; t.d = d; t.tx = tx; t.ty = ty; - return t; -} - -Vec2 __CCPointApplyAffineTransform(const Vec2& point, const AffineTransform& t) -{ - Vec2 p; - p.x = (float)((double)t.a * point.x + (double)t.c * point.y + t.tx); - p.y = (float)((double)t.b * point.x + (double)t.d * point.y + t.ty); - return p; -} - -Vec2 PointApplyTransform(const Vec2& point, const Mat4& transform) -{ - Vec3 vec(point.x, point.y, 0); - transform.transformPoint(&vec); - return Vec2(vec.x, vec.y); -} - - -Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t) -{ - Size s; - s.width = (float)((double)t.a * size.width + (double)t.c * size.height); - s.height = (float)((double)t.b * size.width + (double)t.d * size.height); - return s; -} - - -AffineTransform AffineTransformMakeIdentity() -{ - return __CCAffineTransformMake(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); -} - -extern const AffineTransform AffineTransformIdentity = AffineTransformMakeIdentity(); -const AffineTransform AffineTransform::IDENTITY = AffineTransformMakeIdentity(); - -Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform) -{ - float top = rect.getMinY(); - float left = rect.getMinX(); - float right = rect.getMaxX(); - float bottom = rect.getMaxY(); - - Vec2 topLeft = PointApplyAffineTransform(Vec2(left, top), anAffineTransform); - Vec2 topRight = PointApplyAffineTransform(Vec2(right, top), anAffineTransform); - Vec2 bottomLeft = PointApplyAffineTransform(Vec2(left, bottom), anAffineTransform); - Vec2 bottomRight = PointApplyAffineTransform(Vec2(right, bottom), anAffineTransform); - - float minX = min(min(topLeft.x, topRight.x), min(bottomLeft.x, bottomRight.x)); - float maxX = max(max(topLeft.x, topRight.x), max(bottomLeft.x, bottomRight.x)); - float minY = min(min(topLeft.y, topRight.y), min(bottomLeft.y, bottomRight.y)); - float maxY = max(max(topLeft.y, topRight.y), max(bottomLeft.y, bottomRight.y)); - - return Rect(minX, minY, (maxX - minX), (maxY - minY)); -} - -Rect RectApplyTransform(const Rect& rect, const Mat4& transform) -{ - float top = rect.getMinY(); - float left = rect.getMinX(); - float right = rect.getMaxX(); - float bottom = rect.getMaxY(); - - Vec3 topLeft(left, top, 0); - Vec3 topRight(right, top, 0); - Vec3 bottomLeft(left, bottom, 0); - Vec3 bottomRight(right, bottom, 0); - transform.transformPoint(&topLeft); - transform.transformPoint(&topRight); - transform.transformPoint(&bottomLeft); - transform.transformPoint(&bottomRight); - - float minX = min(min(topLeft.x, topRight.x), min(bottomLeft.x, bottomRight.x)); - float maxX = max(max(topLeft.x, topRight.x), max(bottomLeft.x, bottomRight.x)); - float minY = min(min(topLeft.y, topRight.y), min(bottomLeft.y, bottomRight.y)); - float maxY = max(max(topLeft.y, topRight.y), max(bottomLeft.y, bottomRight.y)); - - return Rect(minX, minY, (maxX - minX), (maxY - minY)); -} - - -AffineTransform AffineTransformTranslate(const AffineTransform& t, float tx, float ty) -{ - return __CCAffineTransformMake(t.a, t.b, t.c, t.d, t.tx + t.a * tx + t.c * ty, t.ty + t.b * tx + t.d * ty); -} - -AffineTransform AffineTransformScale(const AffineTransform& t, float sx, float sy) -{ - return __CCAffineTransformMake(t.a * sx, t.b * sx, t.c * sy, t.d * sy, t.tx, t.ty); -} - -AffineTransform AffineTransformRotate(const AffineTransform& t, float anAngle) -{ - float sine = sinf(anAngle); - float cosine = cosf(anAngle); - - return __CCAffineTransformMake( t.a * cosine + t.c * sine, - t.b * cosine + t.d * sine, - t.c * cosine - t.a * sine, - t.d * cosine - t.b * sine, - t.tx, - t.ty); -} - -/* Concatenate `t2' to `t1' and return the result: - t' = t1 * t2 */ -AffineTransform AffineTransformConcat(const AffineTransform& t1, const AffineTransform& t2) -{ - return __CCAffineTransformMake( t1.a * t2.a + t1.b * t2.c, t1.a * t2.b + t1.b * t2.d, //a,b - t1.c * t2.a + t1.d * t2.c, t1.c * t2.b + t1.d * t2.d, //c,d - t1.tx * t2.a + t1.ty * t2.c + t2.tx, //tx - t1.tx * t2.b + t1.ty * t2.d + t2.ty); //ty -} - -Mat4 TransformConcat(const Mat4& t1, const Mat4& t2) -{ - return t1 * t2; -} - - -/* Return true if `t1' and `t2' are equal, false otherwise. */ -bool AffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2) -{ - return (t1.a == t2.a && t1.b == t2.b && t1.c == t2.c && t1.d == t2.d && t1.tx == t2.tx && t1.ty == t2.ty); -} - -AffineTransform AffineTransformInvert(const AffineTransform& t) -{ - float determinant = 1 / (t.a * t.d - t.b * t.c); - - return __CCAffineTransformMake(determinant * t.d, -determinant * t.b, -determinant * t.c, determinant * t.a, - determinant * (t.c * t.ty - t.d * t.tx), determinant * (t.b * t.tx - t.a * t.ty) ); -} - -NS_CC_END - diff --git a/native/cocos/math/CCAffineTransform.h b/native/cocos/math/CCAffineTransform.h deleted file mode 100644 index e57c28b57e..0000000000 --- a/native/cocos/math/CCAffineTransform.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __MATH_CCAFFINETRANSFORM_H__ -#define __MATH_CCAFFINETRANSFORM_H__ - -#include "base/ccMacros.h" - -#include "math/CCGeometry.h" -#include "math/CCMath.h" - -/** - * @addtogroup base - * @{ - */ - -NS_CC_BEGIN - -/**@{ - Affine transform - a b 0 - c d 0 - tx ty 1 - - Identity - 1 0 0 - 0 1 0 - 0 0 1 - */ -struct CC_DLL AffineTransform { - float a, b, c, d; - float tx, ty; - - static const AffineTransform IDENTITY; -}; - -/**@}*/ - -/**Make affine transform.*/ -CC_DLL AffineTransform __CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty); -#define AffineTransformMake __CCAffineTransformMake - -/**Multiply point (x,y,1) by a affine transform.*/ -CC_DLL Vec2 __CCPointApplyAffineTransform(const Vec2& point, const AffineTransform& t); -#define PointApplyAffineTransform __CCPointApplyAffineTransform - -/**Multiply size (width,height,0) by a affine transform.*/ -CC_DLL Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t); -#define SizeApplyAffineTransform __CCSizeApplyAffineTransform -/**Make identity affine transform.*/ -CC_DLL AffineTransform AffineTransformMakeIdentity(); -/**Transform Rect, which will transform the four vertices of the point.*/ -CC_DLL Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform); -/**@{ - Transform vec2 and Rect by Mat4. - */ -CC_DLL Rect RectApplyTransform(const Rect& rect, const Mat4& transform); -CC_DLL Vec2 PointApplyTransform(const Vec2& point, const Mat4& transform); -/**@}*/ -/** - Translation, equals - 1 0 1 - 0 1 0 * affine transform - tx ty 1 - */ -CC_DLL AffineTransform AffineTransformTranslate(const AffineTransform& t, float tx, float ty); -/** - Rotation, equals - cos(angle) sin(angle) 0 - -sin(angle) cos(angle) 0 * AffineTransform - 0 0 1 - */ -CC_DLL AffineTransform AffineTransformRotate(const AffineTransform& aTransform, float anAngle); -/** - Scale, equals - sx 0 0 - 0 sy 0 * affineTransform - 0 0 1 - */ -CC_DLL AffineTransform AffineTransformScale(const AffineTransform& t, float sx, float sy); -/**Concat two affine transform, t1 * t2*/ -CC_DLL AffineTransform AffineTransformConcat(const AffineTransform& t1, const AffineTransform& t2); -/**Compare affine transform.*/ -CC_DLL bool AffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2); -/**Get the inverse of affine transform.*/ -CC_DLL AffineTransform AffineTransformInvert(const AffineTransform& t); -/**Concat Mat4, return t1 * t2.*/ -CC_DLL Mat4 TransformConcat(const Mat4& t1, const Mat4& t2); - -extern CC_DLL const AffineTransform AffineTransformIdentity; - -NS_CC_END - -// end of base transform -/// @} - -#endif // __MATH_CCAFFINETRANSFORM_H__ - diff --git a/native/cocos/math/TransformUtils.cpp b/native/cocos/math/TransformUtils.cpp deleted file mode 100644 index 7e22a65d11..0000000000 --- a/native/cocos/math/TransformUtils.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -Copyright (c) 2009 Valentin Milea -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "math/TransformUtils.h" -#include "math/CCAffineTransform.h" - -namespace cocos2d { - -void CGAffineToGL(const AffineTransform& t, GLfloat *m) -{ - // | m[0] m[4] m[8] m[12] | | m11 m21 m31 m41 | | a c 0 tx | - // | m[1] m[5] m[9] m[13] | | m12 m22 m32 m42 | | b d 0 ty | - // | m[2] m[6] m[10] m[14] | <=> | m13 m23 m33 m43 | <=> | 0 0 1 0 | - // | m[3] m[7] m[11] m[15] | | m14 m24 m34 m44 | | 0 0 0 1 | - - m[2] = m[3] = m[6] = m[7] = m[8] = m[9] = m[11] = m[14] = 0.0f; - m[10] = m[15] = 1.0f; - m[0] = t.a; m[4] = t.c; m[12] = t.tx; - m[1] = t.b; m[5] = t.d; m[13] = t.ty; -} - -void GLToCGAffine(const GLfloat *m, AffineTransform *t) -{ - t->a = m[0]; t->c = m[4]; t->tx = m[12]; - t->b = m[1]; t->d = m[5]; t->ty = m[13]; -} - -}//namespace cocos2d - diff --git a/native/cocos/math/TransformUtils.h b/native/cocos/math/TransformUtils.h deleted file mode 100644 index 16816f9b07..0000000000 --- a/native/cocos/math/TransformUtils.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -Copyright (c) 2009 Valentin Milea -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __SUPPORT_TRANSFORM_UTILS_H__ -#define __SUPPORT_TRANSFORM_UTILS_H__ - -// TODO: when in MAC or windows, it includes -#include "platform/CCGL.h" -#include "base/ccMacros.h" - -/** - * @addtogroup base - * @{ - */ - -namespace cocos2d { - -struct AffineTransform; -/**@{ - Conversion between mat4*4 and AffineTransform. - @param m The Mat4*4 pointer. - @param t Affine transform. - */ -CC_DLL void CGAffineToGL(const AffineTransform &t, GLfloat *m); -CC_DLL void GLToCGAffine(const GLfloat *m, AffineTransform *t); -/**@}*/ -}//namespace cocos2d -/** - end of base group - @} - */ -#endif // __SUPPORT_TRANSFORM_UTILS_H__ - diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAudioFocusManager.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAudioFocusManager.java index 6286566a9e..ff3b77e4dd 100644 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAudioFocusManager.java +++ b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAudioFocusManager.java @@ -52,7 +52,6 @@ class Cocos2dxAudioFocusManager { @Override public void run() { nativeOnAudioFocusChange(AUDIOFOCUS_LOST); - Cocos2dxHelper.setAudioFocus(false); } }); @@ -63,7 +62,6 @@ class Cocos2dxAudioFocusManager { @Override public void run() { nativeOnAudioFocusChange(AUDIOFOCUS_LOST_TRANSIENT); - Cocos2dxHelper.setAudioFocus(false); } }); } else if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) { @@ -73,7 +71,6 @@ class Cocos2dxAudioFocusManager { @Override public void run() { nativeOnAudioFocusChange(AUDIOFOCUS_LOST_TRANSIENT_CAN_DUCK); - Cocos2dxHelper.setAudioFocus(false); } }); } else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) { @@ -84,7 +81,6 @@ class Cocos2dxAudioFocusManager { @Override public void run() { nativeOnAudioFocusChange(AUDIOFOCUS_GAIN); - Cocos2dxHelper.setAudioFocus(true); } }); } @@ -122,7 +118,6 @@ class Cocos2dxAudioFocusManager { Cocos2dxHelper.runOnGLThread(new Runnable() { @Override public void run() { - Cocos2dxHelper.setAudioFocus(true); nativeOnAudioFocusChange(AUDIOFOCUS_GAIN); } }); diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index 2bc009b4ae..8fc2877c9b 100644 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -78,8 +78,6 @@ public class Cocos2dxHelper { // Fields // =========================================================== - private static Cocos2dxMusic sCocos2dMusic; - private static Cocos2dxSound sCocos2dSound; private static AssetManager sAssetManager; private static Cocos2dxAccelerometer sCocos2dxAccelerometer; private static boolean sAccelerometerEnabled; @@ -212,8 +210,6 @@ public class Cocos2dxHelper { Cocos2dxHelper.nativeSetApkPath(Cocos2dxHelper.getAssetsPath()); Cocos2dxHelper.sCocos2dxAccelerometer = new Cocos2dxAccelerometer(activity); - Cocos2dxHelper.sCocos2dMusic = new Cocos2dxMusic(activity); - Cocos2dxHelper.sCocos2dSound = new Cocos2dxSound(activity); Cocos2dxHelper.sAssetManager = activity.getAssets(); Cocos2dxHelper.nativeSetContext((Context)activity, Cocos2dxHelper.sAssetManager); Cocos2dxHelper.sVibrateService = (Vibrator)activity.getSystemService(Context.VIBRATOR_SERVICE); @@ -382,98 +378,8 @@ public class Cocos2dxHelper { return array; } - public static void preloadBackgroundMusic(final String pPath) { - Cocos2dxHelper.sCocos2dMusic.preloadBackgroundMusic(pPath); - } - - public static void playBackgroundMusic(final String pPath, final boolean isLoop) { - Cocos2dxHelper.sCocos2dMusic.playBackgroundMusic(pPath, isLoop); - } - - public static void resumeBackgroundMusic() { - Cocos2dxHelper.sCocos2dMusic.resumeBackgroundMusic(); - } - - public static void pauseBackgroundMusic() { - Cocos2dxHelper.sCocos2dMusic.pauseBackgroundMusic(); - } - - public static void stopBackgroundMusic() { - Cocos2dxHelper.sCocos2dMusic.stopBackgroundMusic(); - } - - public static void rewindBackgroundMusic() { - Cocos2dxHelper.sCocos2dMusic.rewindBackgroundMusic(); - } - - public static boolean willPlayBackgroundMusic() { - return Cocos2dxHelper.sCocos2dMusic.willPlayBackgroundMusic(); - } - - public static boolean isBackgroundMusicPlaying() { - return Cocos2dxHelper.sCocos2dMusic.isBackgroundMusicPlaying(); - } - - public static float getBackgroundMusicVolume() { - return Cocos2dxHelper.sCocos2dMusic.getBackgroundVolume(); - } - - public static void setBackgroundMusicVolume(final float volume) { - Cocos2dxHelper.sCocos2dMusic.setBackgroundVolume(volume); - } - - public static void preloadEffect(final String path) { - Cocos2dxHelper.sCocos2dSound.preloadEffect(path); - } - - public static int playEffect(final String path, final boolean isLoop, final float pitch, final float pan, final float gain) { - return Cocos2dxHelper.sCocos2dSound.playEffect(path, isLoop, pitch, pan, gain); - } - - public static void resumeEffect(final int soundId) { - Cocos2dxHelper.sCocos2dSound.resumeEffect(soundId); - } - - public static void pauseEffect(final int soundId) { - Cocos2dxHelper.sCocos2dSound.pauseEffect(soundId); - } - - public static void stopEffect(final int soundId) { - Cocos2dxHelper.sCocos2dSound.stopEffect(soundId); - } - - public static float getEffectsVolume() { - return Cocos2dxHelper.sCocos2dSound.getEffectsVolume(); - } - - public static void setEffectsVolume(final float volume) { - Cocos2dxHelper.sCocos2dSound.setEffectsVolume(volume); - } - - public static void unloadEffect(final String path) { - Cocos2dxHelper.sCocos2dSound.unloadEffect(path); - } - - public static void pauseAllEffects() { - Cocos2dxHelper.sCocos2dSound.pauseAllEffects(); - } - - public static void resumeAllEffects() { - Cocos2dxHelper.sCocos2dSound.resumeAllEffects(); - } - - public static void stopAllEffects() { - Cocos2dxHelper.sCocos2dSound.stopAllEffects(); - } - - static void setAudioFocus(boolean isAudioFocus) { - sCocos2dMusic.setAudioFocus(isAudioFocus); - sCocos2dSound.setAudioFocus(isAudioFocus); - } - public static void end() { - Cocos2dxHelper.sCocos2dMusic.end(); - Cocos2dxHelper.sCocos2dSound.end(); + } public static void onResume() { @@ -491,13 +397,11 @@ public class Cocos2dxHelper { } public static void onEnterBackground() { - sCocos2dSound.onEnterBackground(); - sCocos2dMusic.onEnterBackground(); + } public static void onEnterForeground() { - sCocos2dSound.onEnterForeground(); - sCocos2dMusic.onEnterForeground(); + } public static void terminateProcess() { @@ -508,7 +412,6 @@ public class Cocos2dxHelper { Cocos2dxHelper.sCocos2dxHelperListener.showDialog(pTitle, pMessage); } - public static void setEditTextDialogResult(final String pResult) { try { final byte[] bytesUTF8 = pResult.getBytes("UTF8"); @@ -543,155 +446,6 @@ public class Cocos2dxHelper { return -1; } - // =========================================================== - // Functions for CCUserDefault - // =========================================================== - - public static boolean getBoolForKey(String key, boolean defaultValue) { - SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); - try { - return settings.getBoolean(key, defaultValue); - } - catch (Exception ex) { - ex.printStackTrace(); - - Map allValues = settings.getAll(); - Object value = allValues.get(key); - if ( value instanceof String) - { - return Boolean.parseBoolean(value.toString()); - } - else if (value instanceof Integer) - { - int intValue = ((Integer) value).intValue(); - return (intValue != 0) ; - } - else if (value instanceof Float) - { - float floatValue = ((Float) value).floatValue(); - return (floatValue != 0.0f); - } - } - - return defaultValue; - } - - public static int getIntegerForKey(String key, int defaultValue) { - SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); - try { - return settings.getInt(key, defaultValue); - } - catch (Exception ex) { - ex.printStackTrace(); - - Map allValues = settings.getAll(); - Object value = allValues.get(key); - if ( value instanceof String) { - return Integer.parseInt(value.toString()); - } - else if (value instanceof Float) - { - return ((Float) value).intValue(); - } - else if (value instanceof Boolean) - { - boolean booleanValue = ((Boolean) value).booleanValue(); - if (booleanValue) - return 1; - } - } - - return defaultValue; - } - - public static float getFloatForKey(String key, float defaultValue) { - SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); - try { - return settings.getFloat(key, defaultValue); - } - catch (Exception ex) { - ex.printStackTrace(); - - Map allValues = settings.getAll(); - Object value = allValues.get(key); - if ( value instanceof String) { - return Float.parseFloat(value.toString()); - } - else if (value instanceof Integer) - { - return ((Integer) value).floatValue(); - } - else if (value instanceof Boolean) - { - boolean booleanValue = ((Boolean) value).booleanValue(); - if (booleanValue) - return 1.0f; - } - } - - return defaultValue; - } - - public static double getDoubleForKey(String key, double defaultValue) { - // SharedPreferences doesn't support saving double value - return getFloatForKey(key, (float) defaultValue); - } - - public static String getStringForKey(String key, String defaultValue) { - SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); - try { - return settings.getString(key, defaultValue); - } - catch (Exception ex) { - ex.printStackTrace(); - - return settings.getAll().get(key).toString(); - } - } - - public static void setBoolForKey(String key, boolean value) { - SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); - SharedPreferences.Editor editor = settings.edit(); - editor.putBoolean(key, value); - editor.apply(); - } - - public static void setIntegerForKey(String key, int value) { - SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); - SharedPreferences.Editor editor = settings.edit(); - editor.putInt(key, value); - editor.apply(); - } - - public static void setFloatForKey(String key, float value) { - SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); - SharedPreferences.Editor editor = settings.edit(); - editor.putFloat(key, value); - editor.apply(); - } - - public static void setDoubleForKey(String key, double value) { - // SharedPreferences doesn't support recording double value - SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); - SharedPreferences.Editor editor = settings.edit(); - editor.putFloat(key, (float)value); - editor.apply(); - } - - public static void setStringForKey(String key, String value) { - SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); - SharedPreferences.Editor editor = settings.edit(); - editor.putString(key, value); - editor.apply(); - } - - public static void deleteValueForKey(String key) { - SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0); - SharedPreferences.Editor editor = settings.edit(); - editor.remove(key); - editor.apply(); - } - public static byte[] conversionEncoding(byte[] text, String fromCharset,String newCharset) { try { diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java deleted file mode 100644 index eb5cec5e5d..0000000000 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java +++ /dev/null @@ -1,316 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - ****************************************************************************/ - -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.AssetFileDescriptor; -import android.media.AudioManager; -import android.media.MediaPlayer; -import android.util.Log; - -import java.io.FileInputStream; - -public class Cocos2dxMusic { - // =========================================================== - // Constants - // =========================================================== - - private static final String TAG = Cocos2dxMusic.class.getSimpleName(); - - // =========================================================== - // Fields - // =========================================================== - - private final Context mContext; - private MediaPlayer mBackgroundMediaPlayer; - private float mLeftVolume; - private float mRightVolume; - private boolean mPaused; // whether music is paused state. - private boolean mIsLoop = false; - private boolean mManualPaused = false; // whether music is paused manually before the program is switched to the background. - private boolean mIsAudioFocus = true; - private String mCurrentPath; - - // =========================================================== - // Constructors - // =========================================================== - - public Cocos2dxMusic(final Context context) { - this.mContext = context; - - this.initData(); - } - - // =========================================================== - // Getter & Setter - // =========================================================== - - // =========================================================== - // Methods for/from SuperClass/Interfaces - // =========================================================== - - // =========================================================== - // Methods - // =========================================================== - - public void preloadBackgroundMusic(final String path) { - if ((this.mCurrentPath == null) || (!this.mCurrentPath.equals(path))) { - // preload new background music - - // release old resource and create a new one - if (this.mBackgroundMediaPlayer != null) { - this.mBackgroundMediaPlayer.release(); - } - - this.mBackgroundMediaPlayer = this.createMediaPlayer(path); - - // record the path - this.mCurrentPath = path; - } - } - - public void playBackgroundMusic(final String path, final boolean isLoop) { - if (mCurrentPath == null) { - // it is the first time to play background music or end() was called - mBackgroundMediaPlayer = createMediaPlayer(path); - mCurrentPath = path; - } else { - if (!mCurrentPath.equals(path)) { - // play new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null) { - mBackgroundMediaPlayer.release(); - } - mBackgroundMediaPlayer = createMediaPlayer(path); - - // record the path - mCurrentPath = path; - } - } - - if (mBackgroundMediaPlayer == null) { - Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: background media player is null"); - } else { - try { - // if the music is playing or paused, stop it - if (mPaused) { - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - } else if (mBackgroundMediaPlayer.isPlaying()) { - mBackgroundMediaPlayer.seekTo(0); - } else { - mBackgroundMediaPlayer.start(); - } - mBackgroundMediaPlayer.setLooping(isLoop); - mPaused = false; - mIsLoop = isLoop; - } catch (final Exception e) { - Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: error state"); - } - } - } - - public void stopBackgroundMusic() { - if (this.mBackgroundMediaPlayer != null) { - mBackgroundMediaPlayer.release(); - mBackgroundMediaPlayer = createMediaPlayer(mCurrentPath); - - /** - * should set the state, if not, the following sequence will be error - * play -> pause -> stop -> resume - */ - this.mPaused = false; - } - } - - public void pauseBackgroundMusic() { - try { - if (this.mBackgroundMediaPlayer != null && this.mBackgroundMediaPlayer.isPlaying()) { - this.mBackgroundMediaPlayer.pause(); - this.mPaused = true; - this.mManualPaused = true; - } - } catch (IllegalStateException e) { - Log.e(TAG, "pauseBackgroundMusic, IllegalStateException was triggered!"); - } - } - - public void resumeBackgroundMusic() { - try { - if (this.mBackgroundMediaPlayer != null && this.mPaused) { - this.mBackgroundMediaPlayer.start(); - this.mPaused = false; - this.mManualPaused = false; - } - } catch (IllegalStateException e) { - Log.e(TAG, "resumeBackgroundMusic, IllegalStateException was triggered!"); - } - } - - public void rewindBackgroundMusic() { - if (this.mBackgroundMediaPlayer != null) { - playBackgroundMusic(mCurrentPath, mIsLoop); - } - } - - public boolean willPlayBackgroundMusic() { - // We will play our own background music, if there isn't already some - // music active from some other app (eg the user playing their own - // music). - AudioManager manager = - (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); - return !manager.isMusicActive(); - } - - public boolean isBackgroundMusicPlaying() { - boolean ret = false; - try { - if (this.mBackgroundMediaPlayer == null) { - ret = false; - } else { - ret = this.mBackgroundMediaPlayer.isPlaying(); - } - } catch (IllegalStateException e) { - Log.e(TAG, "isBackgroundMusicPlaying, IllegalStateException was triggered!"); - } - - return ret; - } - - public void end() { - if (this.mBackgroundMediaPlayer != null) { - this.mBackgroundMediaPlayer.release(); - } - - this.initData(); - } - - public float getBackgroundVolume() { - if (this.mBackgroundMediaPlayer != null) { - return (this.mLeftVolume + this.mRightVolume) / 2; - } else { - return 0.0f; - } - } - - public void setBackgroundVolume(float volume) { - if (volume < 0.0f) { - volume = 0.0f; - } - - if (volume > 1.0f) { - volume = 1.0f; - } - - this.mLeftVolume = this.mRightVolume = volume; - if (this.mBackgroundMediaPlayer != null && mIsAudioFocus) { - this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); - } - } - - public void onEnterBackground(){ - try { - if (this.mBackgroundMediaPlayer != null && this.mBackgroundMediaPlayer.isPlaying()) { - this.mBackgroundMediaPlayer.pause(); - this.mPaused = true; - } - } catch (IllegalStateException e) { - Log.e(TAG, "onEnterBackground, IllegalStateException was triggered!"); - } - } - - public void onEnterForeground(){ - try { - if (!this.mManualPaused) { - if (this.mBackgroundMediaPlayer != null && this.mPaused) { - this.mBackgroundMediaPlayer.start(); - this.mPaused = false; - } - } - } catch (IllegalStateException e) { - Log.e(TAG, "onEnterForeground, IllegalStateException was triggered!"); - } - } - - private void initData() { - this.mLeftVolume = 0.5f; - this.mRightVolume = 0.5f; - this.mBackgroundMediaPlayer = null; - this.mPaused = false; - this.mCurrentPath = null; - } - - /** - * create MediaPlayer for music - * - * @param path The path relative to assets - * @return - */ - private MediaPlayer createMediaPlayer(final String path) { - MediaPlayer mediaPlayer = new MediaPlayer(); - - try { - if (path.startsWith("/")) { - final FileInputStream fis = new FileInputStream(path); - mediaPlayer.setDataSource(fis.getFD()); - fis.close(); - } else { - if (Cocos2dxHelper.getObbFile() != null) { - final AssetFileDescriptor assetFileDescriptor = Cocos2dxHelper.getObbFile().getAssetFileDescriptor(path); - mediaPlayer.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength()); - } else { - final AssetFileDescriptor assetFileDescriptor = this.mContext.getAssets().openFd(path); - mediaPlayer.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength()); - } - } - - mediaPlayer.prepare(); - - mediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); - } catch (final Exception e) { - mediaPlayer = null; - Log.e(Cocos2dxMusic.TAG, "error: " + e.getMessage(), e); - } - - return mediaPlayer; - } - - void setAudioFocus(boolean isFocus) { - mIsAudioFocus = isFocus; - - if (mBackgroundMediaPlayer != null) { - float lVolume = mIsAudioFocus ? mLeftVolume : 0.0f; - float rVolume = mIsAudioFocus ? mRightVolume : 0.0f; - mBackgroundMediaPlayer.setVolume(lVolume, rVolume); - } - } - - // =========================================================== - // Inner and Anonymous Classes - // =========================================================== -} diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java deleted file mode 100644 index fd7b8a7e4c..0000000000 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java +++ /dev/null @@ -1,406 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - ****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.media.AudioManager; -import android.media.SoundPool; -import android.util.Log; -import android.content.res.AssetFileDescriptor; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -public class Cocos2dxSound { - // =========================================================== - // Constants - // =========================================================== - - private static final String TAG = "Cocos2dxSound"; - - // =========================================================== - // Fields - // =========================================================== - - private final Context mContext; - private SoundPool mSoundPool; - private float mLeftVolume; - private float mRightVolume; - private boolean mIsAudioFocus = true; - - // sound path and stream ids map - // a file may be played many times at the same time - // so there is an array map to a file path - private final HashMap> mPathStreamIDsMap = new HashMap>(); - // A lock for mPathStreamIDsMap operation to keep mPathStreamIDsMap being visited in only one thread at a time. - private final Object mLockPathStreamIDsMap = new Object(); - - private final HashMap mPathSoundIDMap = new HashMap(); - - // Key: SoundID, Value: SoundInfoForLoadedCompleted - private ConcurrentHashMap mPlayWhenLoadedEffects = - new ConcurrentHashMap(); - - private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; - private static final int MAX_SIMULTANEOUS_STREAMS_I9100 = 3; - private static final float SOUND_RATE = 1.0f; - private static final int SOUND_PRIORITY = 1; - private static final int SOUND_QUALITY = 5; - - private final static int INVALID_SOUND_ID = -1; - private final static int INVALID_STREAM_ID = -1; - - // =========================================================== - // Constructors - // =========================================================== - - public Cocos2dxSound(final Context context) { - this.mContext = context; - - this.initData(); - } - - private void initData() { - if (Cocos2dxHelper.getDeviceModel().contains("GT-I9100")) { - this.mSoundPool = new SoundPool(Cocos2dxSound.MAX_SIMULTANEOUS_STREAMS_I9100, AudioManager.STREAM_MUSIC, Cocos2dxSound.SOUND_QUALITY); - } - else { - this.mSoundPool = new SoundPool(Cocos2dxSound.MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, Cocos2dxSound.SOUND_QUALITY); - } - - this.mSoundPool.setOnLoadCompleteListener(new OnLoadCompletedListener()); - - this.mLeftVolume = 0.5f; - this.mRightVolume = 0.5f; - } - - public int preloadEffect(final String path) { - Integer soundID = this.mPathSoundIDMap.get(path); - - if (soundID == null) { - soundID = this.createSoundIDFromAsset(path); - // save value just in case if file is really loaded - if (soundID != Cocos2dxSound.INVALID_SOUND_ID) { - this.mPathSoundIDMap.put(path, soundID); - } - } - - return soundID; - } - - public void unloadEffect(final String path) { - synchronized (mLockPathStreamIDsMap) { - // stop effects - final ArrayList streamIDs = this.mPathStreamIDsMap.get(path); - if (streamIDs != null) { - for (final Integer steamID : streamIDs) { - this.mSoundPool.stop(steamID); - } - } - this.mPathStreamIDsMap.remove(path); - } - - // unload effect - final Integer soundID = this.mPathSoundIDMap.get(path); - if (soundID != null) { - this.mSoundPool.unload(soundID); - this.mPathSoundIDMap.remove(path); - } - } - - private static final int LOAD_TIME_OUT = 500; - - public int playEffect(final String path, final boolean loop, float pitch, float pan, float gain){ - Integer soundID = this.mPathSoundIDMap.get(path); - int streamID = Cocos2dxSound.INVALID_STREAM_ID; - - if (soundID != null) { - // parameters; pan = -1 for left channel, 1 for right channel, 0 for both channels - - // play sound - streamID = this.doPlayEffect(path, soundID, loop, pitch, pan, gain); - } else { - // the effect is not prepared - soundID = this.preloadEffect(path); - if (soundID == Cocos2dxSound.INVALID_SOUND_ID) { - // can not preload effect - return Cocos2dxSound.INVALID_SOUND_ID; - } - - SoundInfoForLoadedCompleted info = new SoundInfoForLoadedCompleted(path, loop, pitch, pan, gain); - mPlayWhenLoadedEffects.putIfAbsent(soundID, info); - - synchronized(info) { - try { - info.wait(LOAD_TIME_OUT); - } catch (Exception e) { - e.printStackTrace(); - } - } - - streamID = info.effectID; - mPlayWhenLoadedEffects.remove(soundID); - } - - return streamID; - } - - public void stopEffect(final int steamID) { - this.mSoundPool.stop(steamID); - - synchronized (mLockPathStreamIDsMap) { - // remove record - for (final String pPath : this.mPathStreamIDsMap.keySet()) { - if (this.mPathStreamIDsMap.get(pPath).contains(steamID)) { - this.mPathStreamIDsMap.get(pPath).remove(this.mPathStreamIDsMap.get(pPath).indexOf(steamID)); - break; - } - } - } - } - - public void pauseEffect(final int steamID) { - this.mSoundPool.pause(steamID); - } - - public void resumeEffect(final int steamID) { - this.mSoundPool.resume(steamID); - } - - public void pauseAllEffects() { - synchronized (mLockPathStreamIDsMap) { - if (!this.mPathStreamIDsMap.isEmpty()) { - final Iterator>> iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()) { - final Entry> entry = iter.next(); - for (final int steamID : entry.getValue()) { - this.mSoundPool.pause(steamID); - } - } - } - } - } - - public void resumeAllEffects() { - synchronized (mLockPathStreamIDsMap) { - // can not only invoke SoundPool.autoResume() here, because - // it only resumes all effects paused by pauseAllEffects() - if (!this.mPathStreamIDsMap.isEmpty()) { - final Iterator>> iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()) { - final Entry> entry = iter.next(); - for (final int steamID : entry.getValue()) { - this.mSoundPool.resume(steamID); - } - } - } - } - } - - public void stopAllEffects() { - synchronized (mLockPathStreamIDsMap) { - // stop effects - if (!this.mPathStreamIDsMap.isEmpty()) { - final Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()) { - final Map.Entry> entry = (Map.Entry>) iter.next(); - for (final int steamID : entry.getValue()) { - this.mSoundPool.stop(steamID); - } - } - } - - // remove records - this.mPathStreamIDsMap.clear(); - } - } - - public float getEffectsVolume() { - return (this.mLeftVolume + this.mRightVolume) / 2; - } - - public void setEffectsVolume(float volume) { - // volume should be in [0, 1.0] - if (volume < 0) { - volume = 0; - } - if (volume > 1) { - volume = 1; - } - - this.mLeftVolume = this.mRightVolume = volume; - - if (!mIsAudioFocus) - return; - - setEffectsVolumeInternal(mLeftVolume, mRightVolume); - } - - private void setEffectsVolumeInternal(float left, float right) { - synchronized (mLockPathStreamIDsMap) { - // change the volume of playing sounds - if (!this.mPathStreamIDsMap.isEmpty()) { - final Iterator>> iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()) { - final Entry> entry = iter.next(); - for (final int steamID : entry.getValue()) { - this.mSoundPool.setVolume(steamID, left, right); - } - } - } - } - } - - public void end() { - this.mSoundPool.release(); - synchronized (mLockPathStreamIDsMap) { - this.mPathStreamIDsMap.clear(); - } - this.mPathSoundIDMap.clear(); - this.mPlayWhenLoadedEffects.clear(); - - this.mLeftVolume = 0.5f; - this.mRightVolume = 0.5f; - - this.initData(); - } - - private int createSoundIDFromAsset(final String path) { - int soundID = Cocos2dxSound.INVALID_SOUND_ID; - - try { - if (path.startsWith("/")) { - soundID = this.mSoundPool.load(path, 0); - } else { - if (Cocos2dxHelper.getObbFile() != null) { - final AssetFileDescriptor assetFileDescriptor = Cocos2dxHelper.getObbFile().getAssetFileDescriptor(path); - soundID = mSoundPool.load(assetFileDescriptor, 0); - } else { - soundID = this.mSoundPool.load(this.mContext.getAssets().openFd(path), 0); - } - } - } catch (final Exception e) { - soundID = Cocos2dxSound.INVALID_SOUND_ID; - Log.e(Cocos2dxSound.TAG, "error: " + e.getMessage(), e); - } - - // mSoundPool.load returns 0 if something goes wrong, for example a file does not exist - if (soundID == 0) { - soundID = Cocos2dxSound.INVALID_SOUND_ID; - } - - return soundID; - } - - private float clamp(float value, float min, float max) { - return Math.max(min, (Math.min(value, max))); - } - - // Adds 'synchronized' keyword for doPlayeEffect since it's possible to be invoked in GL thread and main thread. - // In Cocos2dxSound.playEffect, it's in GL thread. - // In onLoadComplete callback, it's in main thread. - private synchronized int doPlayEffect(final String path, final int soundId, final boolean loop, float pitch, float pan, float gain) { - float leftVolume = this.mLeftVolume * gain * (1.0f - this.clamp(pan, 0.0f, 1.0f)); - float rightVolume = this.mRightVolume * gain * (1.0f - this.clamp(-pan, 0.0f, 1.0f)); - float soundRate = this.clamp(SOUND_RATE * pitch, 0.5f, 2.0f); - - // play sound - int streamID = this.mSoundPool.play(soundId, this.clamp(leftVolume, 0.0f, 1.0f), this.clamp(rightVolume, 0.0f, 1.0f), Cocos2dxSound.SOUND_PRIORITY, loop ? -1 : 0, soundRate); - - synchronized (mLockPathStreamIDsMap) { - // record stream id - ArrayList streamIDs = this.mPathStreamIDsMap.get(path); - if (streamIDs == null) { - streamIDs = new ArrayList(); - this.mPathStreamIDsMap.put(path, streamIDs); - } - streamIDs.add(streamID); - } - - return streamID; - } - - public void onEnterBackground(){ - this.mSoundPool.autoPause(); - } - - public void onEnterForeground(){ - this.mSoundPool.autoResume(); - } - - void setAudioFocus(boolean isFocus) { - mIsAudioFocus = isFocus; - float leftVolume = mIsAudioFocus ? mLeftVolume : 0.0f; - float rightVolume = mIsAudioFocus ? mRightVolume : 0.0f; - - setEffectsVolumeInternal(leftVolume, rightVolume); - } - - // =========================================================== - // Inner and Anonymous Classes - // =========================================================== - - private class SoundInfoForLoadedCompleted { - boolean isLoop; - float pitch; - float pan; - float gain; - String path; - int effectID; - - SoundInfoForLoadedCompleted(String path, boolean isLoop, float pitch, float pan, float gain) { - this.path = path; - this.isLoop = isLoop; - this.pitch = pitch; - this.pan = pan; - this.gain = gain; - effectID = Cocos2dxSound.INVALID_SOUND_ID; - } - } - - public class OnLoadCompletedListener implements SoundPool.OnLoadCompleteListener { - - @Override - public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { - // This callback is in main thread. - if (status == 0) - { - SoundInfoForLoadedCompleted info = mPlayWhenLoadedEffects.get(sampleId); - - if (info != null) { - info.effectID = doPlayEffect(info.path, sampleId, info.isLoop, info.pitch, info.pan, info.gain); - synchronized (info) { - info.notifyAll(); - } - } - } - } - } -} diff --git a/native/cocos/platform/apple/CCLock-apple.cpp b/native/cocos/platform/apple/CCLock-apple.cpp deleted file mode 100644 index a48fe13450..0000000000 --- a/native/cocos/platform/apple/CCLock-apple.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "platform/apple/CCLock-apple.h" - -NS_CC_BEGIN - -Lock::Lock(void) -{ -} - -Lock::~Lock(void) -{ - -} - -void Lock::lock(void) -{ - -} - -void Lock::unlock(void) -{ - -} - -NS_CC_END diff --git a/native/cocos/platform/apple/CCLock-apple.h b/native/cocos/platform/apple/CCLock-apple.h deleted file mode 100644 index 979eadb562..0000000000 --- a/native/cocos/platform/apple/CCLock-apple.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __PLATFORM_IPHONE_PLATFORM_CCLOCK_H__ -#define __PLATFORM_IPHONE_PLATFORM_CCLOCK_H__ - -#include "base/ccMacros.h" - -NS_CC_BEGIN - -class Lock -{ -public: - /** - * @js ctor - */ - Lock(void); - /** - * @js NA - * @lua NA - */ - ~Lock(void); - - void lock(void); - void unlock(void); -}; - -NS_CC_END - -#endif // __PLATFORM_IPHONE_PLATFORM_CCLOCK_H__ diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp deleted file mode 100644 index c75cbbc176..0000000000 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp +++ /dev/null @@ -1,441 +0,0 @@ -#include "scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) -#include "scripting/js-bindings/manual/jsb_conversions.hpp" -#include "scripting/js-bindings/manual/jsb_global.h" -#include "ui/UIVideoPlayer.h" - -se::Object* __jsb_cocos2d_experimental_ui_VideoPlayer_proto = nullptr; -se::Class* __jsb_cocos2d_experimental_ui_VideoPlayer_class = nullptr; - -static bool js_cocos2dx_experimental_video_VideoPlayer_getFileName(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_getFileName : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - const std::string& result = cobj->getFileName(); - ok &= std_string_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_getFileName : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_getFileName) - -static bool js_cocos2dx_experimental_video_VideoPlayer_getURL(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_getURL : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - const std::string& result = cobj->getURL(); - ok &= std_string_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_getURL : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_getURL) - -static bool js_cocos2dx_experimental_video_VideoPlayer_play(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_play : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cobj->play(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_play) - -static bool js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - bool arg0; - ok &= seval_to_boolean(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled : Error processing arguments"); - cobj->setKeepAspectRatioEnabled(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled) - -static bool js_cocos2dx_experimental_video_VideoPlayer_currentTime(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_currentTime : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - float result = cobj->currentTime(); - ok &= float_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_currentTime : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_currentTime) - -static bool js_cocos2dx_experimental_video_VideoPlayer_stop(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_stop : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cobj->stop(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_stop) - -static bool js_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - bool arg0; - ok &= seval_to_boolean(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled : Error processing arguments"); - cobj->setFullScreenEnabled(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled) - -static bool js_cocos2dx_experimental_video_VideoPlayer_setFileName(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_setFileName : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= seval_to_std_string(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_setFileName : Error processing arguments"); - cobj->setFileName(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_setFileName) - -static bool js_cocos2dx_experimental_video_VideoPlayer_setURL(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_setURL : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= seval_to_std_string(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_setURL : Error processing arguments"); - cobj->setURL(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_setURL) - -static bool js_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = cobj->isKeepAspectRatioEnabled(); - ok &= boolean_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled) - -static bool js_cocos2dx_experimental_video_VideoPlayer_onPlayEvent(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_onPlayEvent : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_onPlayEvent : Error processing arguments"); - cobj->onPlayEvent(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_onPlayEvent) - -static bool js_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = cobj->isFullScreenEnabled(); - ok &= boolean_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled) - -static bool js_cocos2dx_experimental_video_VideoPlayer_addEventListener(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_addEventListener : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::function arg0; - do { - if (args[0].isObject() && args[0].toObject()->isFunction()) - { - se::Value jsThis(s.thisObject()); - se::Value jsFunc(args[0]); - jsThis.toObject()->attachObject(jsFunc.toObject()); - auto lambda = [=](cocos2d::Ref* larg0, cocos2d::experimental::ui::VideoPlayer::EventType larg1) -> void { - se::ScriptEngine::getInstance()->clearException(); - se::AutoHandleScope hs; - - CC_UNUSED bool ok = true; - se::ValueArray args; - args.resize(2); - ok &= native_ptr_to_seval((cocos2d::Ref*)larg0, &args[0]); - ok &= int32_to_seval((int32_t)larg1, &args[1]); - se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; - se::Object* funcObj = jsFunc.toObject(); - bool succeed = funcObj->call(args, thisObj, &rval); - if (!succeed) { - se::ScriptEngine::getInstance()->clearException(); - } - }; - arg0 = lambda; - } - else - { - arg0 = nullptr; - } - } while(false) - ; - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_addEventListener : Error processing arguments"); - cobj->addEventListener(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_addEventListener) - -static bool js_cocos2dx_experimental_video_VideoPlayer_duration(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_duration : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - float result = cobj->duration(); - ok &= float_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_duration : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_duration) - -static bool js_cocos2dx_experimental_video_VideoPlayer_isPlaying(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_isPlaying : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = cobj->isPlaying(); - ok &= boolean_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_isPlaying : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_isPlaying) - -static bool js_cocos2dx_experimental_video_VideoPlayer_seekTo(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_seekTo : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - float arg0 = 0; - ok &= seval_to_float(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_seekTo : Error processing arguments"); - cobj->seekTo(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_seekTo) - -static bool js_cocos2dx_experimental_video_VideoPlayer_setVolume(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_video_VideoPlayer_setVolume : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - float arg0 = 0; - ok &= seval_to_float(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_video_VideoPlayer_setVolume : Error processing arguments"); - cobj->setVolume(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_setVolume) - -static bool js_cocos2dx_experimental_video_VideoPlayer_create(se::State& s) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - auto result = cocos2d::experimental::ui::VideoPlayer::create(); - result->retain(); - auto obj = se::Object::createObjectWithClass(__jsb_cocos2d_experimental_ui_VideoPlayer_class); - obj->setPrivateData(result); - s.rval().setObject(obj); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_video_VideoPlayer_create) - -SE_DECLARE_FINALIZE_FUNC(js_cocos2d_experimental_ui_VideoPlayer_finalize) - -static bool js_cocos2dx_experimental_video_VideoPlayer_constructor(se::State& s) -{ - cocos2d::experimental::ui::VideoPlayer* cobj = new (std::nothrow) cocos2d::experimental::ui::VideoPlayer(); - s.thisObject()->setPrivateData(cobj); - return true; -} -SE_BIND_CTOR(js_cocos2dx_experimental_video_VideoPlayer_constructor, __jsb_cocos2d_experimental_ui_VideoPlayer_class, js_cocos2d_experimental_ui_VideoPlayer_finalize) - - - -extern se::Object* __jsb_cocos2d_ui_Widget_proto; - -static bool js_cocos2d_experimental_ui_VideoPlayer_finalize(se::State& s) -{ - CCLOGINFO("jsbindings: finalizing JS object %p (cocos2d::experimental::ui::VideoPlayer)", s.nativeThisObject()); - cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer*)s.nativeThisObject(); - if (cobj->getReferenceCount() == 1) - cobj->autorelease(); - else - cobj->release(); - return true; -} -SE_BIND_FINALIZE_FUNC(js_cocos2d_experimental_ui_VideoPlayer_finalize) - -bool js_register_cocos2dx_experimental_video_VideoPlayer(se::Object* obj) -{ - auto cls = se::Class::create("VideoPlayer", obj, __jsb_cocos2d_ui_Widget_proto, _SE(js_cocos2dx_experimental_video_VideoPlayer_constructor)); - - cls->defineFunction("getFileName", _SE(js_cocos2dx_experimental_video_VideoPlayer_getFileName)); - cls->defineFunction("getURL", _SE(js_cocos2dx_experimental_video_VideoPlayer_getURL)); - cls->defineFunction("play", _SE(js_cocos2dx_experimental_video_VideoPlayer_play)); - cls->defineFunction("setKeepAspectRatioEnabled", _SE(js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled)); - cls->defineFunction("currentTime", _SE(js_cocos2dx_experimental_video_VideoPlayer_currentTime)); - cls->defineFunction("stop", _SE(js_cocos2dx_experimental_video_VideoPlayer_stop)); - cls->defineFunction("setFullScreenEnabled", _SE(js_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled)); - cls->defineFunction("setFileName", _SE(js_cocos2dx_experimental_video_VideoPlayer_setFileName)); - cls->defineFunction("setURL", _SE(js_cocos2dx_experimental_video_VideoPlayer_setURL)); - cls->defineFunction("isKeepAspectRatioEnabled", _SE(js_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled)); - cls->defineFunction("onPlayEvent", _SE(js_cocos2dx_experimental_video_VideoPlayer_onPlayEvent)); - cls->defineFunction("isFullScreenEnabled", _SE(js_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled)); - cls->defineFunction("addEventListener", _SE(js_cocos2dx_experimental_video_VideoPlayer_addEventListener)); - cls->defineFunction("duration", _SE(js_cocos2dx_experimental_video_VideoPlayer_duration)); - cls->defineFunction("isPlaying", _SE(js_cocos2dx_experimental_video_VideoPlayer_isPlaying)); - cls->defineFunction("seekTo", _SE(js_cocos2dx_experimental_video_VideoPlayer_seekTo)); - cls->defineFunction("setVolume", _SE(js_cocos2dx_experimental_video_VideoPlayer_setVolume)); - cls->defineStaticFunction("create", _SE(js_cocos2dx_experimental_video_VideoPlayer_create)); - cls->defineFinalizeFunction(_SE(js_cocos2d_experimental_ui_VideoPlayer_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cocos2d_experimental_ui_VideoPlayer_proto = cls->getProto(); - __jsb_cocos2d_experimental_ui_VideoPlayer_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} - -bool register_all_cocos2dx_experimental_video(se::Object* obj) -{ - // Get the ns - se::Value nsVal; - if (!obj->getProperty("ccui", &nsVal)) - { - se::HandleObject jsobj(se::Object::createPlainObject()); - nsVal.setObject(jsobj); - obj->setProperty("ccui", nsVal); - } - se::Object* ns = nsVal.toObject(); - - js_register_cocos2dx_experimental_video_VideoPlayer(ns); - return true; -} - -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp deleted file mode 100644 index 137bd72fb8..0000000000 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "base/ccConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) - -#include "cocos/scripting/js-bindings/jswrapper/SeApi.h" - -extern se::Object* __jsb_cocos2d_experimental_ui_VideoPlayer_proto; -extern se::Class* __jsb_cocos2d_experimental_ui_VideoPlayer_class; - -bool js_register_cocos2d_experimental_ui_VideoPlayer(se::Object* obj); -bool register_all_cocos2dx_experimental_video(se::Object* obj); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_getFileName); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_getURL); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_play); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_currentTime); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_stop); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_setFileName); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_setURL); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_onPlayEvent); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_addEventListener); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_duration); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_isPlaying); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_seekTo); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_setVolume); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_create); -SE_DECLARE_FUNC(js_cocos2dx_experimental_video_VideoPlayer_VideoPlayer); - -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp deleted file mode 100644 index 0e2e218154..0000000000 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp +++ /dev/null @@ -1,643 +0,0 @@ -#include "scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.hpp" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) -#include "scripting/js-bindings/manual/jsb_conversions.hpp" -#include "scripting/js-bindings/manual/jsb_global.h" -#include "ui/UIWebView.h" - -se::Object* __jsb_cocos2d_experimental_ui_WebView_proto = nullptr; -se::Class* __jsb_cocos2d_experimental_ui_WebView_class = nullptr; - -static bool js_cocos2dx_experimental_webView_WebView_setOnShouldStartLoading(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_setOnShouldStartLoading : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::function &)> arg0; - do { - if (args[0].isObject() && args[0].toObject()->isFunction()) - { - se::Value jsThis(s.thisObject()); - se::Value jsFunc(args[0]); - jsThis.toObject()->attachObject(jsFunc.toObject()); - auto lambda = [=](cocos2d::experimental::ui::WebView* larg0, const std::basic_string & larg1) -> bool { - se::ScriptEngine::getInstance()->clearException(); - se::AutoHandleScope hs; - - CC_UNUSED bool ok = true; - se::ValueArray args; - args.resize(2); - ok &= native_ptr_to_seval((cocos2d::experimental::ui::WebView*)larg0, &args[0]); - ok &= std_string_to_seval(larg1, &args[1]); - se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; - se::Object* funcObj = jsFunc.toObject(); - bool succeed = funcObj->call(args, thisObj, &rval); - if (!succeed) { - se::ScriptEngine::getInstance()->clearException(); - } - bool result; - ok &= seval_to_boolean(rval, &result); - SE_PRECONDITION2(ok, result, "lambda function : Error processing return value with type bool"); - return result; - }; - arg0 = lambda; - } - else - { - arg0 = nullptr; - } - } while(false) - ; - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_setOnShouldStartLoading : Error processing arguments"); - cobj->setOnShouldStartLoading(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_setOnShouldStartLoading) - -static bool js_cocos2dx_experimental_webView_WebView_setOnDidFailLoading(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_setOnDidFailLoading : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::function &)> arg0; - do { - if (args[0].isObject() && args[0].toObject()->isFunction()) - { - se::Value jsThis(s.thisObject()); - se::Value jsFunc(args[0]); - jsThis.toObject()->attachObject(jsFunc.toObject()); - auto lambda = [=](cocos2d::experimental::ui::WebView* larg0, const std::basic_string & larg1) -> void { - se::ScriptEngine::getInstance()->clearException(); - se::AutoHandleScope hs; - - CC_UNUSED bool ok = true; - se::ValueArray args; - args.resize(2); - ok &= native_ptr_to_seval((cocos2d::experimental::ui::WebView*)larg0, &args[0]); - ok &= std_string_to_seval(larg1, &args[1]); - se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; - se::Object* funcObj = jsFunc.toObject(); - bool succeed = funcObj->call(args, thisObj, &rval); - if (!succeed) { - se::ScriptEngine::getInstance()->clearException(); - } - }; - arg0 = lambda; - } - else - { - arg0 = nullptr; - } - } while(false) - ; - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_setOnDidFailLoading : Error processing arguments"); - cobj->setOnDidFailLoading(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_setOnDidFailLoading) - -static bool js_cocos2dx_experimental_webView_WebView_canGoBack(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_canGoBack : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = cobj->canGoBack(); - ok &= boolean_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_canGoBack : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_canGoBack) - -static bool js_cocos2dx_experimental_webView_WebView_loadHTMLString(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_loadHTMLString : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= seval_to_std_string(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_loadHTMLString : Error processing arguments"); - cobj->loadHTMLString(arg0); - return true; - } - if (argc == 2) { - std::string arg0; - std::string arg1; - ok &= seval_to_std_string(args[0], &arg0); - ok &= seval_to_std_string(args[1], &arg1); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_loadHTMLString : Error processing arguments"); - cobj->loadHTMLString(arg0, arg1); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_loadHTMLString) - -static bool js_cocos2dx_experimental_webView_WebView_goForward(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_goForward : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cobj->goForward(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_goForward) - -static bool js_cocos2dx_experimental_webView_WebView_goBack(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_goBack : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cobj->goBack(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_goBack) - -static bool js_cocos2dx_experimental_webView_WebView_setScalesPageToFit(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_setScalesPageToFit : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - bool arg0; - ok &= seval_to_boolean(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_setScalesPageToFit : Error processing arguments"); - cobj->setScalesPageToFit(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_setScalesPageToFit) - -static bool js_cocos2dx_experimental_webView_WebView_getOnDidFailLoading(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_getOnDidFailLoading : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cocos2d::experimental::ui::WebView::ccWebViewCallback result = cobj->getOnDidFailLoading(); - #pragma warning NO CONVERSION FROM NATIVE FOR std::function; - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_getOnDidFailLoading : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_getOnDidFailLoading) - -static bool js_cocos2dx_experimental_webView_WebView_loadFile(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_loadFile : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= seval_to_std_string(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_loadFile : Error processing arguments"); - cobj->loadFile(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_loadFile) - -static bool js_cocos2dx_experimental_webView_WebView_loadURL(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_loadURL : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= seval_to_std_string(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_loadURL : Error processing arguments"); - cobj->loadURL(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_loadURL) - -static bool js_cocos2dx_experimental_webView_WebView_setBounces(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_setBounces : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - bool arg0; - ok &= seval_to_boolean(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_setBounces : Error processing arguments"); - cobj->setBounces(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_setBounces) - -static bool js_cocos2dx_experimental_webView_WebView_evaluateJS(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_evaluateJS : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= seval_to_std_string(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_evaluateJS : Error processing arguments"); - cobj->evaluateJS(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_evaluateJS) - -static bool js_cocos2dx_experimental_webView_WebView_setOnJSCallback(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_setOnJSCallback : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::function &)> arg0; - do { - if (args[0].isObject() && args[0].toObject()->isFunction()) - { - se::Value jsThis(s.thisObject()); - se::Value jsFunc(args[0]); - jsThis.toObject()->attachObject(jsFunc.toObject()); - auto lambda = [=](cocos2d::experimental::ui::WebView* larg0, const std::basic_string & larg1) -> void { - se::ScriptEngine::getInstance()->clearException(); - se::AutoHandleScope hs; - - CC_UNUSED bool ok = true; - se::ValueArray args; - args.resize(2); - ok &= native_ptr_to_seval((cocos2d::experimental::ui::WebView*)larg0, &args[0]); - ok &= std_string_to_seval(larg1, &args[1]); - se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; - se::Object* funcObj = jsFunc.toObject(); - bool succeed = funcObj->call(args, thisObj, &rval); - if (!succeed) { - se::ScriptEngine::getInstance()->clearException(); - } - }; - arg0 = lambda; - } - else - { - arg0 = nullptr; - } - } while(false) - ; - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_setOnJSCallback : Error processing arguments"); - cobj->setOnJSCallback(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_setOnJSCallback) - -static bool js_cocos2dx_experimental_webView_WebView_getOnJSCallback(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_getOnJSCallback : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cocos2d::experimental::ui::WebView::ccWebViewCallback result = cobj->getOnJSCallback(); - #pragma warning NO CONVERSION FROM NATIVE FOR std::function; - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_getOnJSCallback : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_getOnJSCallback) - -static bool js_cocos2dx_experimental_webView_WebView_canGoForward(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_canGoForward : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - bool result = cobj->canGoForward(); - ok &= boolean_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_canGoForward : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_canGoForward) - -static bool js_cocos2dx_experimental_webView_WebView_getOnShouldStartLoading(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_getOnShouldStartLoading : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - std::function &)> result = cobj->getOnShouldStartLoading(); - #pragma warning NO CONVERSION FROM NATIVE FOR std::function; - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_getOnShouldStartLoading : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_getOnShouldStartLoading) - -static bool js_cocos2dx_experimental_webView_WebView_stopLoading(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_stopLoading : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cobj->stopLoading(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_stopLoading) - -static bool js_cocos2dx_experimental_webView_WebView_reload(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_reload : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - if (argc == 0) { - cobj->reload(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_reload) - -static bool js_cocos2dx_experimental_webView_WebView_loadData(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_loadData : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 4) { - cocos2d::Data arg0; - std::string arg1; - std::string arg2; - std::string arg3; - ok &= seval_to_Data(args[0], &arg0); - ok &= seval_to_std_string(args[1], &arg1); - ok &= seval_to_std_string(args[2], &arg2); - ok &= seval_to_std_string(args[3], &arg3); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_loadData : Error processing arguments"); - cobj->loadData(arg0, arg1, arg2, arg3); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_loadData) - -static bool js_cocos2dx_experimental_webView_WebView_setJavascriptInterfaceScheme(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_setJavascriptInterfaceScheme : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= seval_to_std_string(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_setJavascriptInterfaceScheme : Error processing arguments"); - cobj->setJavascriptInterfaceScheme(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_setJavascriptInterfaceScheme) - -static bool js_cocos2dx_experimental_webView_WebView_setOnDidFinishLoading(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_setOnDidFinishLoading : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::function &)> arg0; - do { - if (args[0].isObject() && args[0].toObject()->isFunction()) - { - se::Value jsThis(s.thisObject()); - se::Value jsFunc(args[0]); - jsThis.toObject()->attachObject(jsFunc.toObject()); - auto lambda = [=](cocos2d::experimental::ui::WebView* larg0, const std::basic_string & larg1) -> void { - se::ScriptEngine::getInstance()->clearException(); - se::AutoHandleScope hs; - - CC_UNUSED bool ok = true; - se::ValueArray args; - args.resize(2); - ok &= native_ptr_to_seval((cocos2d::experimental::ui::WebView*)larg0, &args[0]); - ok &= std_string_to_seval(larg1, &args[1]); - se::Value rval; - se::Object* thisObj = jsThis.isObject() ? jsThis.toObject() : nullptr; - se::Object* funcObj = jsFunc.toObject(); - bool succeed = funcObj->call(args, thisObj, &rval); - if (!succeed) { - se::ScriptEngine::getInstance()->clearException(); - } - }; - arg0 = lambda; - } - else - { - arg0 = nullptr; - } - } while(false) - ; - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_setOnDidFinishLoading : Error processing arguments"); - cobj->setOnDidFinishLoading(arg0); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_setOnDidFinishLoading) - -static bool js_cocos2dx_experimental_webView_WebView_getOnDidFinishLoading(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_cocos2dx_experimental_webView_WebView_getOnDidFinishLoading : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - cocos2d::experimental::ui::WebView::ccWebViewCallback result = cobj->getOnDidFinishLoading(); - #pragma warning NO CONVERSION FROM NATIVE FOR std::function; - SE_PRECONDITION2(ok, false, "js_cocos2dx_experimental_webView_WebView_getOnDidFinishLoading : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_getOnDidFinishLoading) - -static bool js_cocos2dx_experimental_webView_WebView_create(se::State& s) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - auto result = cocos2d::experimental::ui::WebView::create(); - result->retain(); - auto obj = se::Object::createObjectWithClass(__jsb_cocos2d_experimental_ui_WebView_class); - obj->setPrivateData(result); - s.rval().setObject(obj); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_cocos2dx_experimental_webView_WebView_create) - -SE_DECLARE_FINALIZE_FUNC(js_cocos2d_experimental_ui_WebView_finalize) - -static bool js_cocos2dx_experimental_webView_WebView_constructor(se::State& s) -{ - cocos2d::experimental::ui::WebView* cobj = new (std::nothrow) cocos2d::experimental::ui::WebView(); - s.thisObject()->setPrivateData(cobj); - return true; -} -SE_BIND_CTOR(js_cocos2dx_experimental_webView_WebView_constructor, __jsb_cocos2d_experimental_ui_WebView_class, js_cocos2d_experimental_ui_WebView_finalize) - - - -extern se::Object* __jsb_cocos2d_ui_Widget_proto; - -static bool js_cocos2d_experimental_ui_WebView_finalize(se::State& s) -{ - CCLOGINFO("jsbindings: finalizing JS object %p (cocos2d::experimental::ui::WebView)", s.nativeThisObject()); - cocos2d::experimental::ui::WebView* cobj = (cocos2d::experimental::ui::WebView*)s.nativeThisObject(); - if (cobj->getReferenceCount() == 1) - cobj->autorelease(); - else - cobj->release(); - return true; -} -SE_BIND_FINALIZE_FUNC(js_cocos2d_experimental_ui_WebView_finalize) - -bool js_register_cocos2dx_experimental_webView_WebView(se::Object* obj) -{ - auto cls = se::Class::create("WebView", obj, __jsb_cocos2d_ui_Widget_proto, _SE(js_cocos2dx_experimental_webView_WebView_constructor)); - - cls->defineFunction("setOnShouldStartLoading", _SE(js_cocos2dx_experimental_webView_WebView_setOnShouldStartLoading)); - cls->defineFunction("setOnDidFailLoading", _SE(js_cocos2dx_experimental_webView_WebView_setOnDidFailLoading)); - cls->defineFunction("canGoBack", _SE(js_cocos2dx_experimental_webView_WebView_canGoBack)); - cls->defineFunction("loadHTMLString", _SE(js_cocos2dx_experimental_webView_WebView_loadHTMLString)); - cls->defineFunction("goForward", _SE(js_cocos2dx_experimental_webView_WebView_goForward)); - cls->defineFunction("goBack", _SE(js_cocos2dx_experimental_webView_WebView_goBack)); - cls->defineFunction("setScalesPageToFit", _SE(js_cocos2dx_experimental_webView_WebView_setScalesPageToFit)); - cls->defineFunction("getOnDidFailLoading", _SE(js_cocos2dx_experimental_webView_WebView_getOnDidFailLoading)); - cls->defineFunction("loadFile", _SE(js_cocos2dx_experimental_webView_WebView_loadFile)); - cls->defineFunction("loadURL", _SE(js_cocos2dx_experimental_webView_WebView_loadURL)); - cls->defineFunction("setBounces", _SE(js_cocos2dx_experimental_webView_WebView_setBounces)); - cls->defineFunction("evaluateJS", _SE(js_cocos2dx_experimental_webView_WebView_evaluateJS)); - cls->defineFunction("setOnJSCallback", _SE(js_cocos2dx_experimental_webView_WebView_setOnJSCallback)); - cls->defineFunction("getOnJSCallback", _SE(js_cocos2dx_experimental_webView_WebView_getOnJSCallback)); - cls->defineFunction("canGoForward", _SE(js_cocos2dx_experimental_webView_WebView_canGoForward)); - cls->defineFunction("getOnShouldStartLoading", _SE(js_cocos2dx_experimental_webView_WebView_getOnShouldStartLoading)); - cls->defineFunction("stopLoading", _SE(js_cocos2dx_experimental_webView_WebView_stopLoading)); - cls->defineFunction("reload", _SE(js_cocos2dx_experimental_webView_WebView_reload)); - cls->defineFunction("loadData", _SE(js_cocos2dx_experimental_webView_WebView_loadData)); - cls->defineFunction("setJavascriptInterfaceScheme", _SE(js_cocos2dx_experimental_webView_WebView_setJavascriptInterfaceScheme)); - cls->defineFunction("setOnDidFinishLoading", _SE(js_cocos2dx_experimental_webView_WebView_setOnDidFinishLoading)); - cls->defineFunction("getOnDidFinishLoading", _SE(js_cocos2dx_experimental_webView_WebView_getOnDidFinishLoading)); - cls->defineStaticFunction("create", _SE(js_cocos2dx_experimental_webView_WebView_create)); - cls->defineFinalizeFunction(_SE(js_cocos2d_experimental_ui_WebView_finalize)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cocos2d_experimental_ui_WebView_proto = cls->getProto(); - __jsb_cocos2d_experimental_ui_WebView_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} - -bool register_all_cocos2dx_experimental_webView(se::Object* obj) -{ - // Get the ns - se::Value nsVal; - if (!obj->getProperty("ccui", &nsVal)) - { - se::HandleObject jsobj(se::Object::createPlainObject()); - nsVal.setObject(jsobj); - obj->setProperty("ccui", nsVal); - } - se::Object* ns = nsVal.toObject(); - - js_register_cocos2dx_experimental_webView_WebView(ns); - return true; -} - -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.hpp deleted file mode 100644 index 927b38e0ff..0000000000 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "base/ccConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) - -#include "cocos/scripting/js-bindings/jswrapper/SeApi.h" - -extern se::Object* __jsb_cocos2d_experimental_ui_WebView_proto; -extern se::Class* __jsb_cocos2d_experimental_ui_WebView_class; - -bool js_register_cocos2d_experimental_ui_WebView(se::Object* obj); -bool register_all_cocos2dx_experimental_webView(se::Object* obj); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_setOnShouldStartLoading); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_setOnDidFailLoading); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_canGoBack); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_loadHTMLString); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_goForward); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_goBack); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_setScalesPageToFit); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_getOnDidFailLoading); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_loadFile); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_loadURL); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_setBounces); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_evaluateJS); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_setOnJSCallback); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_getOnJSCallback); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_canGoForward); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_getOnShouldStartLoading); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_stopLoading); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_reload); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_loadData); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_setJavascriptInterfaceScheme); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_setOnDidFinishLoading); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_getOnDidFinishLoading); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_create); -SE_DECLARE_FUNC(js_cocos2dx_experimental_webView_WebView_WebView); - -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) diff --git a/native/cocos/scripting/js-bindings/manual/jsb_box2d_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_box2d_manual.cpp deleted file mode 100644 index 3bc2ca3a09..0000000000 --- a/native/cocos/scripting/js-bindings/manual/jsb_box2d_manual.cpp +++ /dev/null @@ -1,1154 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "jsb_box2d_manual.hpp" -#include "cocos/scripting/js-bindings/jswrapper/SeApi.h" -#include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" -#include "cocos/scripting/js-bindings/manual/jsb_global.h" -#include "cocos/scripting/js-bindings/manual/jsb_helper.hpp" -#include "cocos/scripting/js-bindings/auto/jsb_box2d_auto.hpp" - -#include "cocos/editor-support/creator/physics/CCPhysicsContactListener.h" - -bool seval_to_b2BodyDef(const se::Value& v, b2BodyDef* ret) -{ - static b2BodyDef ZERO; - assert(v.isObject()); - assert(ret != nullptr); - - se::Object* obj = v.toObject(); - - bool ok = false; - se::Value tmp, tmp2; - ok = obj->getProperty("angle", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - ret->angle = tmp.toFloat(); - - ok = obj->getProperty("angularVelocity", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - ret->angularVelocity = tmp.toFloat(); - - ok = obj->getProperty("linearDamping", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - ret->linearDamping = tmp.toFloat(); - - ok = obj->getProperty("angularDamping", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - ret->angularDamping = tmp.toFloat(); - - ok = obj->getProperty("gravityScale", &tmp); - if (ok && tmp.isNumber()) - ret->gravityScale = tmp.toFloat(); - else - ret->gravityScale = 1.0f; - - ok = obj->getProperty("allowSleep", &tmp); - if (ok && tmp.isBoolean()) - ret->allowSleep = tmp.toBoolean(); - else - ret->allowSleep = true; - - ok = obj->getProperty("awake", &tmp); - if (ok && tmp.isBoolean()) - ret->awake = tmp.toBoolean(); - else - ret->awake = true; - - ok = obj->getProperty("fixedRotation", &tmp); - if (ok && tmp.isBoolean()) - ret->fixedRotation = tmp.toBoolean(); - else - ret->fixedRotation = true; - - ok = obj->getProperty("bullet", &tmp); - SE_PRECONDITION3(ok && tmp.isBoolean(), false, *ret = ZERO); - ret->bullet = tmp.toBoolean(); - - ok = obj->getProperty("active", &tmp); - if (ok && tmp.isBoolean()) - ret->active = tmp.toBoolean(); - else - ret->active = true; - - ok = obj->getProperty("type", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - ret->type = (b2BodyType)tmp.toInt32(); - - // position - ok = obj->getProperty("position", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - - ok = tmp.toObject()->getProperty("x", &tmp2); - SE_PRECONDITION3(ok && tmp2.isNumber(), false, *ret = ZERO); - ret->position.x = tmp2.toFloat(); - - ok = tmp.toObject()->getProperty("y", &tmp2); - SE_PRECONDITION3(ok && tmp2.isNumber(), false, *ret = ZERO); - ret->position.y = tmp2.toFloat(); - - // linearVelocity - ok = obj->getProperty("linearVelocity", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - - ok = tmp.toObject()->getProperty("x", &tmp2); - SE_PRECONDITION3(ok && tmp2.isNumber(), false, *ret = ZERO); - ret->linearVelocity.x = tmp2.toFloat(); - - ok = tmp.toObject()->getProperty("y", &tmp2); - SE_PRECONDITION3(ok && tmp2.isNumber(), false, *ret = ZERO); - ret->linearVelocity.y = tmp2.toFloat(); - - return true; -} - -bool seval_to_b2JointDef(const se::Value& v, b2JointType type, b2JointDef* ret) -{ - static b2JointDef ZERO; - assert(v.isObject()); - assert(ret != nullptr); - - se::Object* obj = v.toObject(); - - bool ok = false; - se::Value tmp; - ok = obj->getProperty("bodyA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_native_ptr(tmp, &ret->bodyA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("bodyB", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_native_ptr(tmp, &ret->bodyB); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("collideConnected", &tmp); - SE_PRECONDITION3(ok && tmp.isBoolean(), false, *ret = ZERO); - ret->collideConnected = tmp.toBoolean(); - - switch (type) { - case e_distanceJoint: - { - b2DistanceJointDef* def = (b2DistanceJointDef*)ret; - - ok = obj->getProperty("length", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->length = tmp.toFloat(); - - ok = obj->getProperty("frequencyHz", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->frequencyHz = tmp.toFloat(); - - ok = obj->getProperty("dampingRatio", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->dampingRatio = tmp.toFloat(); - break; - } - case e_frictionJoint: - { - b2FrictionJointDef* def = (b2FrictionJointDef*)ret; - - ok = obj->getProperty("localAnchorA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("localAnchorB", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorB); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("maxForce", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->maxForce = tmp.toFloat(); - - ok = obj->getProperty("maxTorque", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->maxTorque = tmp.toFloat(); - break; - } - case e_gearJoint: - { - b2GearJointDef* def = (b2GearJointDef*)ret; - - ok = obj->getProperty("valjoint1", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_native_ptr(tmp, &def->joint1); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("valjoint2", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_native_ptr(tmp, &def->joint2); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("ratio", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->ratio = tmp.toFloat(); - break; - } - case e_motorJoint: - { - b2MotorJointDef* def = (b2MotorJointDef*)ret; - - ok = obj->getProperty("linearOffset", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->linearOffset); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("angularOffset", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->angularOffset = tmp.toFloat(); - - ok = obj->getProperty("maxForce", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->maxForce = tmp.toFloat(); - - ok = obj->getProperty("maxTorque", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->maxTorque = tmp.toFloat(); - - ok = obj->getProperty("correctionFactor", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->correctionFactor = tmp.toFloat(); - break; - } - case e_mouseJoint: - { - b2MouseJointDef* def = (b2MouseJointDef*)ret; - - ok = obj->getProperty("target", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->target); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("frequencyHz", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->frequencyHz = tmp.toFloat(); - - ok = obj->getProperty("maxForce", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->maxForce = tmp.toFloat(); - - ok = obj->getProperty("dampingRatio", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->dampingRatio = tmp.toFloat(); - break; - } - case e_prismaticJoint: - { - b2PrismaticJointDef* def = (b2PrismaticJointDef*)ret; - - ok = obj->getProperty("localAnchorA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("localAnchorB", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorB); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("localAxisA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAxisA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("lowerTranslation", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->lowerTranslation = tmp.toFloat(); - - ok = obj->getProperty("referenceAngle", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->referenceAngle = tmp.toFloat(); - - ok = obj->getProperty("upperTranslation", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->upperTranslation = tmp.toFloat(); - - ok = obj->getProperty("maxMotorForce", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->maxMotorForce = tmp.toFloat(); - - ok = obj->getProperty("motorSpeed", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->motorSpeed = tmp.toFloat(); - - ok = obj->getProperty("enableLimit", &tmp); - SE_PRECONDITION3(ok && tmp.isBoolean(), false, *ret = ZERO); - def->enableLimit = tmp.toBoolean(); - - ok = obj->getProperty("enableMotor", &tmp); - SE_PRECONDITION3(ok && tmp.isBoolean(), false, *ret = ZERO); - def->enableMotor = tmp.toBoolean(); - break; - } - case e_pulleyJoint: - { - b2PulleyJointDef* def = (b2PulleyJointDef*)ret; - - ok = obj->getProperty("localAnchorA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("localAnchorB", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorB); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("groundAnchorA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->groundAnchorA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("groundAnchorB", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->groundAnchorB); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("lengthB", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->lengthB = tmp.toFloat(); - - ok = obj->getProperty("lengthA", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->lengthA = tmp.toFloat(); - - ok = obj->getProperty("ratio", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->ratio = tmp.toFloat(); - - ok = obj->getProperty("collideConnected", &tmp); - SE_PRECONDITION3(ok && tmp.isBoolean(), false, *ret = ZERO); - def->collideConnected = tmp.toBoolean(); - break; - } - case e_revoluteJoint: - { - b2RevoluteJointDef* def = (b2RevoluteJointDef*)ret; - - ok = obj->getProperty("localAnchorA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("localAnchorB", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorB); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("lowerAngle", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->lowerAngle = tmp.toFloat(); - - ok = obj->getProperty("referenceAngle", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->referenceAngle = tmp.toFloat(); - - ok = obj->getProperty("upperAngle", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->upperAngle = tmp.toFloat(); - - ok = obj->getProperty("maxMotorTorque", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->maxMotorTorque = tmp.toFloat(); - - ok = obj->getProperty("motorSpeed", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->motorSpeed = tmp.toFloat(); - - ok = obj->getProperty("enableLimit", &tmp); - SE_PRECONDITION3(ok && tmp.isBoolean(), false, *ret = ZERO); - def->enableLimit = tmp.toBoolean(); - - ok = obj->getProperty("enableMotor", &tmp); - SE_PRECONDITION3(ok && tmp.isBoolean(), false, *ret = ZERO); - def->enableMotor = tmp.toBoolean(); - break; - } - case e_ropeJoint: - { - b2RopeJointDef* def = (b2RopeJointDef*)ret; - - ok = obj->getProperty("localAnchorA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("localAnchorB", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorB); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("maxLength", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->maxLength = tmp.toFloat(); - break; - } - case e_weldJoint: - { - b2WeldJointDef* def = (b2WeldJointDef*)ret; - - ok = obj->getProperty("localAnchorA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("localAnchorB", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorB); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("referenceAngle", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->referenceAngle = tmp.toFloat(); - - ok = obj->getProperty("frequencyHz", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->frequencyHz = tmp.toFloat(); - - ok = obj->getProperty("dampingRatio", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->dampingRatio = tmp.toFloat(); - break; - } - case e_wheelJoint: - { - b2WheelJointDef* def = (b2WheelJointDef*)ret; - - ok = obj->getProperty("localAnchorA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("localAnchorB", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAnchorB); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("localAxisA", &tmp); - SE_PRECONDITION3(ok && tmp.isObject(), false, *ret = ZERO); - ok = seval_to_b2Vec2(tmp, &def->localAxisA); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - ok = obj->getProperty("frequencyHz", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->frequencyHz = tmp.toFloat(); - - ok = obj->getProperty("maxMotorTorque", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->maxMotorTorque = tmp.toFloat(); - - ok = obj->getProperty("dampingRatio", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->dampingRatio = tmp.toFloat(); - - ok = obj->getProperty("motorSpeed", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - def->motorSpeed = tmp.toFloat(); - - ok = obj->getProperty("enableMotor", &tmp); - SE_PRECONDITION3(ok && tmp.isBoolean(), false, *ret = ZERO); - def->enableMotor = tmp.toBoolean(); - - break; - } - default: - assert(false); - break; - } - - return true; -} - -bool seval_to_b2FixtureDef(const se::Value& v, b2FixtureDef* ret) -{ - static b2FixtureDef ZERO; - assert(v.isObject()); - assert(ret != nullptr); - - bool ok = false; - se::Object* obj = v.toObject(); - se::Value tmp; - ok = obj->getProperty("friction", &tmp); - if (ok && tmp.isNumber()) - ret->friction = tmp.toFloat(); - else - ret->friction = 0.2f; - - ok = obj->getProperty("restitution", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - ret->restitution = tmp.toFloat(); - - ok = obj->getProperty("density", &tmp); - SE_PRECONDITION3(ok && tmp.isNumber(), false, *ret = ZERO); - ret->density = tmp.toFloat(); - - ok = obj->getProperty("isSensor", &tmp); - SE_PRECONDITION3(ok && tmp.isBoolean(), false, *ret = ZERO); - ret->isSensor = tmp.toBoolean(); - - ok = obj->getProperty("shape", &tmp); - SE_PRECONDITION3(ok, false, *ret = ZERO); - ok = seval_to_native_ptr(tmp, &ret->shape); - SE_PRECONDITION3(ok, false, *ret = ZERO); - - se::Value filterVal; - ok = obj->getProperty("filter", &filterVal); - SE_PRECONDITION3(ok && filterVal.isObject(), false, *ret = ZERO); - - se::Object* filterObj = filterVal.toObject(); - - ok = filterObj->getProperty("categoryBits", &tmp); - if (ok && tmp.isNumber()) - ret->filter.categoryBits = tmp.toUint16(); - else - ret->filter.categoryBits = 0x0001; - - ok = filterObj->getProperty("groupIndex", &tmp); - if (ok && tmp.isNumber()) - ret->filter.groupIndex = tmp.toInt16(); - else - ret->filter.groupIndex = 0; - - ok = filterObj->getProperty("maskBits", &tmp); - if (ok && tmp.isNumber()) - ret->filter.maskBits = tmp.toInt16(); - else - ret->filter.maskBits = 0xFFFF; - - return true; -} - -bool seval_to_array_of_b2Vec2(const se::Value& v, b2Vec2* outPoints, uint32_t numPoints) -{ - assert(v.isObject() && v.toObject()->isArray()); - assert(outPoints != nullptr); - se::Object* arr = v.toObject(); - uint32_t arrLen = 0; - assert(arr->getArrayLength(&arrLen) && arrLen == numPoints); - bool ok = false; - for (uint32_t i = 0; i < numPoints; ++i) - { - se::Value tmp; - ok = arr->getArrayElement(i, &tmp); - if (!ok) break; - ok = seval_to_b2Vec2(tmp, &outPoints[i]); - if (!ok) break; - } - - return ok; -} - -bool array_of_b2Fixture_to_seval(const std::vector& fixtures, se::Value* ret) -{ - se::HandleObject obj(se::Object::createArrayObject(fixtures.size())); - - se::Value tmp; - int i = 0; - bool ok = true; - for (const auto& e : fixtures) - { - ok = native_ptr_to_rooted_seval(e, &tmp); - if (!ok) - break; - ok = obj->setArrayElement(i, tmp); - if (!ok) - break; - ++i; - } - - if (ok) - ret->setObject(obj, true); - else - ret->setUndefined(); - - return ok; -} - -bool array_of_b2Vec2_to_seval(const std::vector& vs, se::Value* ret) -{ - se::HandleObject obj(se::Object::createArrayObject(vs.size())); - - se::Value tmp; - int i = 0; - bool ok = true; - for (const auto& e : vs) - { - ok = b2Vec2_to_seval(e, &tmp); - if (!ok) - break; - ok = obj->setArrayElement(i, tmp); - if (!ok) - break; - ++i; - } - - if (ok) - ret->setObject(obj, true); - else - ret->setUndefined(); - - return ok; -} - -static bool js_box2dclasses_b2Shape_SetRadius(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - if (argc == 1) - { - b2Shape* cobj = (b2Shape *)s.nativeThisObject(); - SE_PRECONDITION2(args[0].isNumber(), false, "The radius isn't a number!"); - cobj->m_radius = args[0].toFloat(); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2Shape_SetRadius) - -static bool js_box2dclasses_b2Shape_GetRadius(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - if (argc == 0) - { - b2Shape* cobj = (b2Shape *)s.nativeThisObject(); - s.rval().setFloat(cobj->m_radius); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2Shape_GetRadius) - -static bool js_box2dclasses_b2World_CreateBody(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - if (argc == 1) - { - bool ok = false; - b2World* cobj = (b2World *)s.nativeThisObject(); - - b2BodyDef def; - ok = seval_to_b2BodyDef(args[0], &def); - SE_PRECONDITION2(ok, false, "seval_to_b2BodyDef failed!"); - - b2Body* ret = cobj->CreateBody(&def); - - native_ptr_to_rooted_seval(ret, __jsb_b2Body_class, &s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2World_CreateBody) - -static bool js_box2dclasses_b2CircleShape_SetPosition(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - if (argc == 1) - { - bool ok = false; - b2CircleShape* cobj = (b2CircleShape *)s.nativeThisObject(); - b2Vec2 arg0; - ok = seval_to_b2Vec2(args[0], &arg0); - SE_PRECONDITION2(ok, false, "seval_to_b2Vec2 failed!"); - cobj->m_p = arg0; - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2CircleShape_SetPosition) - -static bool js_box2dclasses_b2CircleShape_GetPosition(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - if (argc == 0) - { - b2CircleShape* cobj = (b2CircleShape *)s.nativeThisObject(); - bool ok = false; - ok = b2Vec2_to_seval(cobj->m_p, &s.rval()); - SE_PRECONDITION2(ok, false, "b2Vec2_to_seval failed!"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2CircleShape_GetPosition) - -static bool js_box2dclasses_b2World_CreateJoint(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - if (argc == 1) - { - bool ok = false; - b2World* cobj = (b2World *)s.nativeThisObject(); - b2JointDef* tmpDef = nullptr; - b2JointType type = e_unknownJoint; - - se::Object* seObj = args[0].toObject(); - se::Value tmp; - ok = seObj->getProperty("type", &tmp); - SE_PRECONDITION2(ok, false, "Get type failed!"); - if (tmp.isNumber()) - type = (b2JointType)tmp.toInt32(); - - switch (type) { - case e_distanceJoint: - { - tmpDef = new b2DistanceJointDef(); - break; - } - case e_frictionJoint: - { - tmpDef = new b2FrictionJointDef(); - break; - } - case e_gearJoint: - { - tmpDef = new b2GearJointDef(); - break; - } - case e_motorJoint: - { - tmpDef = new b2MotorJointDef(); - break; - } - case e_mouseJoint: - { - tmpDef = new b2MouseJointDef(); - break; - } - case e_prismaticJoint: - { - tmpDef = new b2PrismaticJointDef(); - break; - } - case e_pulleyJoint: - { - tmpDef = new b2PulleyJointDef(); - break; - } - case e_revoluteJoint: - { - tmpDef = new b2RevoluteJointDef(); - break; - } - case e_ropeJoint: - { - tmpDef = new b2RopeJointDef(); - break; - } - case e_weldJoint: - { - tmpDef = new b2WeldJointDef(); - break; - } - case e_wheelJoint: - { - tmpDef = new b2WheelJointDef(); - break; - } - default: - { - assert(false); - break; - } - } - - ok = seval_to_b2JointDef(args[0], type, tmpDef); - SE_PRECONDITION2(ok, false, "seval_to_b2JointDef failed!"); - - b2Joint* ret = cobj->CreateJoint(tmpDef); - - se::Class* cls = JSBClassType::findClass(ret); - assert(cls != nullptr); - ok = native_ptr_to_rooted_seval(ret, cls, &s.rval()); - - delete tmpDef; - - SE_PRECONDITION2(ok, false, "native_ptr_to_rooted_seval failed!"); - - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2World_CreateJoint) - -static bool js_box2dclasses_b2Body_CreateFixture(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - bool ok = false; - b2Body* cobj = (b2Body *)s.nativeThisObject(); - - if (argc == 2) - { - b2Shape* arg0; - ok = seval_to_native_ptr(args[0], &arg0); - SE_PRECONDITION2(ok, false, "seval_to_native_ptr failed!"); - - float arg1 = args[1].toFloat(); - b2Fixture* ret = cobj->CreateFixture(arg0, arg1); - ok = native_ptr_to_rooted_seval(ret, __jsb_b2Fixture_class, &s.rval()); - SE_PRECONDITION2(ok, false, "native_ptr_to_rooted_seval failed!"); - return true; - } - else if (argc == 1) - { - b2FixtureDef def; - ok = seval_to_b2FixtureDef(args[0], &def); - SE_PRECONDITION2(ok, false, "seval_to_b2FixtureDef failed!"); - b2Fixture* ret = cobj->CreateFixture(&def); - ok = native_ptr_to_rooted_seval(ret, __jsb_b2Fixture_class, &s.rval()); - SE_PRECONDITION2(ok, false, "native_ptr_to_rooted_seval failed!"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2Body_CreateFixture) - -static bool js_box2dclasses_b2Body_SetUserData(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - if (argc == 1) - { - bool ok = false; - b2Body* cobj = (b2Body *)s.nativeThisObject(); - void* arg0 = nullptr; - ok = seval_to_native_ptr(args[0], &arg0); - if (ok) - cobj->SetUserData(arg0); - else - cobj->SetUserData(nullptr); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2Body_SetUserData) - -static bool js_box2dclasses_b2Body_GetUserData(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - if (argc == 0) - { - b2Body* cobj = (b2Body *)s.nativeThisObject(); - void* data = cobj->GetUserData(); - - auto iter = se::NativePtrToObjectMap::find(data); - if (iter != se::NativePtrToObjectMap::end()) - { - s.rval().setObject(iter->second); - } - else - { - s.rval().setNull(); - } - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2Body_GetUserData) - -static bool js_box2dclasses_b2Body_GetJointList(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - bool ok = false; - - if (argc == 0) - { - b2Body* cobj = (b2Body *)s.nativeThisObject(); - - b2JointEdge* list = cobj->GetJointList(); - se::HandleObject arr(se::Object::createArrayObject(0)); - - do - { - if (!list) { - break; - } - - int i = 0; - - se::Value tmp; - ok = native_ptr_to_rooted_seval(list->joint, &tmp); - if (!ok) break; - - ok = arr->setArrayElement(i++, tmp); - if (!ok) break; - - //FIXME: whether to iterate both prev and next? - b2JointEdge* prev = list->prev; - while (prev) { - - ok = native_ptr_to_rooted_seval(prev->joint, &tmp); - if (!ok) break; - - ok = arr->setArrayElement(i++, tmp); - if (!ok) break; - - prev = prev->prev; - } - if (!ok) break; - - b2JointEdge* next = list->next; - while (next) { - ok = native_ptr_to_rooted_seval(next->joint, &tmp); - if (!ok) break; - - ok = arr->setArrayElement(i++, tmp); - if (!ok) break; - - next = next->next; - } - if (!ok) break; - - - } - while(0); - - if (ok) - s.rval().setObject(arr); - else - s.rval().setNull(); - - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2Body_GetJointList) - -static bool js_box2dclasses_b2PolygonShape_Set(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - bool ok = false; - - if (argc == 2) - { - b2PolygonShape* cobj = (b2PolygonShape *)s.nativeThisObject(); - int arg1 = 0; - ok = seval_to_int32(args[1], &arg1); - SE_PRECONDITION2(ok, false, "seval_to_int32 failed!"); - - b2Vec2* arg0 = new (std::nothrow) b2Vec2[arg1]; - ok = seval_to_array_of_b2Vec2(args[0], arg0, arg1); - SE_PRECONDITION2(ok, false, "seval_to_array_of_b2Vec2 failed!"); - - cobj->Set(arg0, arg1); - - delete [] arg0; - - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 2); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2PolygonShape_Set) - -static bool js_box2dclasses_b2PolygonShape_SetAsBox(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - bool ok = false; - - if (argc == 2) - { - b2PolygonShape* cobj = (b2PolygonShape *)s.nativeThisObject(); - float arg0 = 0.0f, arg1 = 0.0f; - ok = seval_to_float(args[0], &arg0); - SE_PRECONDITION2(ok, false, "seval_to_float failed!"); - ok = seval_to_float(args[1], &arg1); - SE_PRECONDITION2(ok, false, "seval_to_float failed!"); - - cobj->SetAsBox(arg0, arg1); - - return true; - } - - if (argc == 4) - { - b2PolygonShape* cobj = (b2PolygonShape *)s.nativeThisObject(); - float arg0 = 0.0f, arg1 = 0.0f; - ok = seval_to_float(args[0], &arg0); - SE_PRECONDITION2(ok, false, "seval_to_float failed!"); - ok = seval_to_float(args[1], &arg1); - SE_PRECONDITION2(ok, false, "seval_to_float failed!"); - - b2Vec2 arg2; - float arg3 = 0.0f; - ok = seval_to_b2Vec2(args[2], &arg2); - SE_PRECONDITION2(ok, false, "seval_to_b2Vec2 failed!"); - ok = seval_to_float(args[3], &arg3); - SE_PRECONDITION2(ok, false, "seval_to_float failed!"); - - cobj->SetAsBox(arg0, arg1, arg2, arg3); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 2); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2PolygonShape_SetAsBox) - -static bool js_box2dclasses_b2ChainShape_CreateLoop(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - bool ok = false; - - if (argc == 2) - { - b2ChainShape* cobj = (b2ChainShape *)s.nativeThisObject(); - int arg1 = 0; - ok = seval_to_int32(args[1], &arg1); - SE_PRECONDITION2(ok, false, "seval_to_int32 failed!"); - - b2Vec2* arg0 = new (std::nothrow) b2Vec2[arg1]; - ok = seval_to_array_of_b2Vec2(args[0], arg0, arg1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - cobj->CreateLoop(arg0, arg1); - - delete[] arg0; - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 2); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2ChainShape_CreateLoop) - -static bool js_box2dclasses_b2ChainShape_CreateChain(se::State& s) -{ - const auto& args = s.args(); - int argc = (int)args.size(); - bool ok = false; - - if (argc == 2) - { - b2ChainShape* cobj = (b2ChainShape *)s.nativeThisObject(); - int arg1 = 0; - ok = seval_to_int32(args[1], &arg1); - SE_PRECONDITION2(ok, false, "seval_to_int32 failed!"); - - b2Vec2* arg0 = new (std::nothrow) b2Vec2[arg1]; - ok = seval_to_array_of_b2Vec2(args[0], arg0, arg1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - cobj->CreateChain(arg0, arg1); - - delete[] arg0; - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", argc, 2); - return false; -} -SE_BIND_FUNC(js_box2dclasses_b2ChainShape_CreateChain) - -bool register_all_box2d_manual(se::Object* obj) -{ - __jsb_b2Shape_proto->defineFunction("SetRadius", _SE(js_box2dclasses_b2Shape_SetRadius)); - __jsb_b2Shape_proto->defineFunction("GetRadius", _SE(js_box2dclasses_b2Shape_GetRadius)); - - __jsb_b2CircleShape_proto->defineFunction("SetPosition", _SE(js_box2dclasses_b2CircleShape_SetPosition)); - __jsb_b2CircleShape_proto->defineFunction("GetPosition", _SE(js_box2dclasses_b2CircleShape_GetPosition)); - - __jsb_b2World_proto->defineFunction("CreateBody", _SE(js_box2dclasses_b2World_CreateBody)); - __jsb_b2World_proto->defineFunction("CreateJoint", _SE(js_box2dclasses_b2World_CreateJoint)); - - __jsb_b2Body_proto->defineFunction("CreateFixture", _SE(js_box2dclasses_b2Body_CreateFixture)); - __jsb_b2Body_proto->defineFunction("SetUserData", _SE(js_box2dclasses_b2Body_SetUserData)); - __jsb_b2Body_proto->defineFunction("GetUserData", _SE(js_box2dclasses_b2Body_GetUserData)); - __jsb_b2Body_proto->defineFunction("GetJointList", _SE(js_box2dclasses_b2Body_GetJointList)); - - __jsb_b2PolygonShape_proto->defineFunction("Set", _SE(js_box2dclasses_b2PolygonShape_Set)); - __jsb_b2PolygonShape_proto->defineFunction("SetAsBox", _SE(js_box2dclasses_b2PolygonShape_SetAsBox)); - - __jsb_b2ChainShape_proto->defineFunction("CreateLoop", _SE(js_box2dclasses_b2ChainShape_CreateLoop)); - __jsb_b2ChainShape_proto->defineFunction("CreateChain", _SE(js_box2dclasses_b2ChainShape_CreateChain)); - - se::ScriptEngine::getInstance()->clearException(); - - b2SetObjectDestroyNotifier([](void* obj, b2ObjectType type, const char* typeName){ - - std::string typeNameStr = typeName; - auto cleanup = [obj, typeNameStr](){ - - if (!se::ScriptEngine::getInstance()->isValid()) - return; - - se::AutoHandleScope hs; - se::ScriptEngine::getInstance()->clearException(); - - auto iter = se::NativePtrToObjectMap::find(obj); - if (iter != se::NativePtrToObjectMap::end()) - { -// CCLOG("%s, %p was recycled!", typeNameStr.c_str(), obj); - se::Object* seObj = iter->second; - seObj->clearPrivateData(); - seObj->unroot(); - seObj->decRef(); - } - else - { -// CCLOG("Didn't find %s, %p in map", typeNameStr.c_str(), obj); -// assert(false); - } - }; - - if (!se::ScriptEngine::getInstance()->isGarbageCollecting()) - { - cleanup(); - } - else - { - CleanupTask::pushTaskToAutoReleasePool(cleanup); - } - - if (type == b2ObjectType::FIXTURE) - { - const auto& instances = creator::PhysicsContactListener::getAllInstances(); - for (auto listener : instances) - { - listener->unregisterContactFixture(reinterpret_cast(obj)); - } - } - }); - - return true; -} diff --git a/native/cocos/scripting/js-bindings/manual/jsb_box2d_manual.hpp b/native/cocos/scripting/js-bindings/manual/jsb_box2d_manual.hpp deleted file mode 100644 index 1a20c2d6c7..0000000000 --- a/native/cocos/scripting/js-bindings/manual/jsb_box2d_manual.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#pragma once - -#include "Box2D/Box2D.h" - -#include - -namespace se { - class Object; - class Value; -} - -bool register_all_box2d_manual(se::Object* obj); - -bool array_of_b2Fixture_to_seval(const std::vector& fixtures, se::Value* ret); -bool array_of_b2Vec2_to_seval(const std::vector& vs, se::Value* ret); diff --git a/native/cocos/scripting/js-bindings/manual/jsb_classtype.cpp b/native/cocos/scripting/js-bindings/manual/jsb_classtype.cpp index c4c63cb2df..b0e4d40ed4 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_classtype.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_classtype.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include "jsb_classtype.hpp" JSBClassType::Map* JSBClassType::__jsbClassTypeMap = nullptr; diff --git a/native/cocos/scripting/js-bindings/manual/jsb_classtype.hpp b/native/cocos/scripting/js-bindings/manual/jsb_classtype.hpp index e81bea2cf0..54366dc9aa 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_classtype.hpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_classtype.hpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #pragma once #include "scripting/js-bindings/jswrapper/SeApi.h" diff --git a/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_extension_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_extension_manual.cpp index 6137daab89..e26a767ee3 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_extension_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_extension_manual.cpp @@ -23,14 +23,6 @@ THE SOFTWARE. ****************************************************************************/ -// -// jsb_cocos2dx_extension_manual.cpp -// cocos2d_js_bindings -// -// Created by James Chen on 6/7/17. -// -// - #include "jsb_cocos2dx_extension_manual.hpp" #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" #include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" diff --git a/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.cpp index 1a525b973f..bade33aa50 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.cpp @@ -1,10 +1,27 @@ -// -// jsb_cocos2dx_manual.cpp -// cocos2d_js_bindings -// -// Created by James Chen on 5/26/17. -// -// +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "jsb_cocos2dx_manual.hpp" diff --git a/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.hpp b/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.hpp index 166e47954e..6f8d7619d3 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.hpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.hpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #pragma once namespace se { diff --git a/native/cocos/scripting/js-bindings/manual/jsb_conversions.cpp b/native/cocos/scripting/js-bindings/manual/jsb_conversions.cpp index ffa17882e3..9b010ce6f9 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_conversions.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_conversions.cpp @@ -1,10 +1,27 @@ -// -// jsb_conversions.cpp -// cocos2d_js_bindings -// -// Created by James Chen on 5/17/17. -// -// +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "jsb_conversions.hpp" #include diff --git a/native/cocos/scripting/js-bindings/manual/jsb_conversions.hpp b/native/cocos/scripting/js-bindings/manual/jsb_conversions.hpp index 0e7271de5e..6cb1b52e46 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_conversions.hpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_conversions.hpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #pragma once #include "scripting/js-bindings/jswrapper/SeApi.h" diff --git a/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp index 18afee2e8b..2e1e1416b0 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp @@ -1,10 +1,27 @@ -// -// jsb_gfx_manual.cpp -// Test -// -// Created by James Chen on 1/8/18. -// Copyright © 2018 cocos. All rights reserved. -// +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "jsb_gfx_manual.hpp" #include "cocos/scripting/js-bindings/auto/jsb_gfx_auto.hpp" diff --git a/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.hpp b/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.hpp index b5e4ca9aa0..3287c0c596 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.hpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.hpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #pragma once namespace se { diff --git a/native/cocos/scripting/js-bindings/manual/jsb_global.cpp b/native/cocos/scripting/js-bindings/manual/jsb_global.cpp index 85b9b56857..0b0f810094 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_global.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_global.cpp @@ -1,6 +1,27 @@ -// -// Created by James Chen on 4/28/17. -// +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "jsb_global.h" #include "jsb_conversions.hpp" diff --git a/native/cocos/scripting/js-bindings/manual/jsb_global.h b/native/cocos/scripting/js-bindings/manual/jsb_global.h index 0d022cc1fa..79eed9be84 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_global.h +++ b/native/cocos/scripting/js-bindings/manual/jsb_global.h @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #pragma once #include diff --git a/native/cocos/scripting/js-bindings/manual/jsb_platform_android.cpp b/native/cocos/scripting/js-bindings/manual/jsb_platform_android.cpp index fcb0ebd9fa..ac632e3c9a 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_platform_android.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_platform_android.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include "jsb_platform.h" #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" diff --git a/native/cocos/scripting/js-bindings/manual/jsb_platfrom_apple.mm b/native/cocos/scripting/js-bindings/manual/jsb_platfrom_apple.mm index 7f8b48cd59..6856a83a4e 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_platfrom_apple.mm +++ b/native/cocos/scripting/js-bindings/manual/jsb_platfrom_apple.mm @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #import "jsb_platform.h" #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" diff --git a/native/cocos/scripting/js-bindings/manual/jsb_platfrom_ios.mm b/native/cocos/scripting/js-bindings/manual/jsb_platfrom_ios.mm index f1280890d3..dcd6a795aa 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_platfrom_ios.mm +++ b/native/cocos/scripting/js-bindings/manual/jsb_platfrom_ios.mm @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #import "jsb_platform_ios.h" @implementation JSB_PlatformIOS diff --git a/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.cpp index d355cf06b5..3df0012332 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.cpp @@ -1,7 +1,31 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include "jsb_renderer_manual.hpp" #include "cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp" #include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" -// #include "Renderer.h" #include "renderer/INode.h" #include "jsb_conversions.hpp" diff --git a/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.hpp b/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.hpp index 02d034d3d0..6451de7a8d 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.hpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.hpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #pragma once namespace se { diff --git a/native/tools/tojs/box2d.ini b/native/tools/tojs/box2d.ini deleted file mode 100644 index 925fef1de8..0000000000 --- a/native/tools/tojs/box2d.ini +++ /dev/null @@ -1,65 +0,0 @@ -[box2d] -target_namespace = b2 - -name = box2d -prefix = box2dclasses - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/%(clang_include)s -clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -DNO_JS_ASSERT -DUINT32_MAX=0xffffffff - -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/android/include -I%(cocosdir)s/external/sources -I%(cocosdir)s/external/android/armeabi-v7a/include -I%(cocosdir)s/external/android/armeabi-v7a/include/spidermonkey - -cocos_flags = -DANDROID - -cxxgenerator_headers = - -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s - -headers = %(cocosdir)s/external/sources/Box2D/Box2D.h - -replace_headers = Box2D.h::Box2D/Box2D.h - -# cpp_headers = scripting/js-bindings/manual/box2d/js_bindings_box2d_manual.h - -classes = b2World b2Shape b2PolygonShape b2ChainShape b2CircleShape b2EdgeShape b2Fixture b2Body b2Draw b2Joint b2ContactListener b2Contact b2QueryCallback b2RayCastCallback b2DistanceJoint b2FrictionJoint b2GearJoint b2MotorJoint b2MouseJoint b2PrismaticJoint b2PulleyJoint b2RevoluteJoint b2RopeJoint b2WeldJoint b2WheelJoint - -classes_need_extend = - -remove_prefix = - -skip = b2World::[GetContactManager CreateJoint CreateBody GetContactList], - b2Body::[CreateFixture SetUserData GetUserData GetJointList], - b2Fixture::[SetUserData GetUserData], - b2Joint::[SetUserData GetUserData], - b2ChainShape::[CreateLoop CreateChain], - b2PolygonShape::[Set SetAsBox] - -base_objects = -abstract_classes = b2Shape b2Draw b2ContactListener b2QueryCallback b2RayCastCallback -classes_have_type_info = no -rename = -rename_functions = - -rename_classes = b2World::World, - b2Shape::Shape, - b2PolygonShape::PolygonShape, - b2ChainShape::ChainShape, - b2CircleShape::CircleShape, - b2EdgeShape::EdgeShape, - b2Fixture::Fixture, - b2Body::Body, - b2Draw::Draw, - b2Joint::Joint, - b2Contact::Contact - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -classes_owned_by_cpp = b2Shape b2Fixture b2Body b2Joint b2ContactListener b2Contact b2QueryCallback b2RayCastCallback b2DistanceJoint b2FrictionJoint b2GearJoint b2MotorJoint b2MouseJoint b2PrismaticJoint b2PulleyJoint b2RevoluteJoint b2RopeJoint b2WeldJoint b2WheelJoint - diff --git a/native/tools/tojs/cocos2dx_dragonbones.ini b/native/tools/tojs/cocos2dx_dragonbones.ini deleted file mode 100644 index b32c38e458..0000000000 --- a/native/tools/tojs/cocos2dx_dragonbones.ini +++ /dev/null @@ -1,72 +0,0 @@ -[cocos2dx_dragonbones] -prefix = cocos2dx_dragonbones - -target_namespace = dragonBones - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/%(clang_include)s -clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -DNO_JS_ASSERT -DUINT32_MAX=0xffffffff - -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/android/include -I%(cocosdir)s/external/sources -I%(cocosdir)s/external/android/armeabi-v7a/include -I%(cocosdir)s/external/android/armeabi-v7a/include/spidermonkey - -cocos_flags = -DANDROID - -cxxgenerator_headers = - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s - -headers = %(cocosdir)s/cocos/editor-support/dragonbones/cocos2dx/CCDragonBonesHeaders.h - -classes = BoneTimelineData DragonBonesData CCFactory CCArmatureDisplay Armature CCSlot WorldClock Animation Slot BaseFactory BaseObject TextureData CCTextureData TextureAtlasData CCTextureAtlasData AnimationState EventObject Bone Transform Matrix TransformObject ArmatureData BoneData SlotData SkinData AnimationData DBCCSprite - -abstract_classes = DragonBonesData Armature CCSlot WorldClock Animation Slot BaseFactory BaseObject TextureData CCTextureData TextureAtlasData CCTextureAtlasData AnimationState EventObject Bone Transform Matrix TransformObject ArmatureData BoneData SlotData SkinData AnimationData - -skip = CCFactory::[loadDragonBonesData loadTextureAtlasData], - BaseFactory::[parseTextureAtlasData replaceSlotDisplayList getTextureAtlasData copyAnimationsToArmature replaceSlotDisplay], - Armature::[_addSlotToSlotList _removeBoneFromBoneList _bufferEvent _addBoneToBoneList _removeSlotFromSlotList getArmatureData getAnimation getBones getSlots getDisplay], - Bone::[_setIK _update getBones getSlots], - Animation::[_advanceTime _updateFFDTimelineStates _setArmature _setParent setAnimations getAnimations], - Slot::[getDisplay$ getRawDisplay getMeshDisplay setDisplay$ _setArmature _update _updateBlendMode _updateMeshData _setBlendMode _updateVisible _setDisplayIndex setDisplayList getDisplayList _setColor _setDisplayList], - CCArmatureDisplay::[_onClear _dispatchEvent getAnimation], - AnimationState::[getAnimationData _isDisabled _fadeIn _updateTimelineStates _updateFFDTimelineStates _advanceTime], - CCSlot::[_onClear], - Transform::[operator= fromMatrix add identity minus toMatrix], - Matrix::[operator= identity concat invert transformPoint], - WorldClock::[add remove], - ArmatureData::[cacheFrames addBone addSlot addSkin addAnimation getSortedBones getSortedSlots], - AnimationData::[cacheFrames addBoneTimeline addSlotTimeline addFFDTimeline getBontTimeline getSlotTimeline getFFDTimeline getBoneTimeline], - SkinData::[addSlot getSlot], - DBCCSprite::[getPolygonInfoModify draw], - BaseObject::[setObjectRecycleOrDestroyCallback], - BoneTimelineData::[*], - SlotData::[generateColor], - TextureData::[generateRectangle] - -field = TransformObject::[name globalTransformMatrix], - Transform::[x y skewX skewY scaleX scaleY], - Slot::[displayController inheritAnimation], - Matrix::[a b c d tx ty], - EventObject::[animationState armature name type bone slot], - AnimationState::[timeScale displayControl additiveBlending playTimes weight autoFadeOutTime fadeTotalTime], - Animation::[timeScale], - ArmatureData::[frameRate name], - AnimationData::[name frameCount playTimes position duration fadeInTime], - BoneData::[name parent], - SlotData::[name parent], - SkinData::[name], - DragonBonesData::[name] - -remove_prefix = - -classes_have_no_parents = WorldClock Slot AnimationData - -base_classes_to_skip = IAnimateble IArmatureDisplay - -rename_functions = CCArmatureDisplay::[getArmature=armature addEvent=addEventListener removeEvent=removeEventListener] - -rename_classes = - -classes_owned_by_cpp = DragonBonesData Armature CCSlot WorldClock Animation Slot BaseFactory BaseObject TextureData CCTextureData TextureAtlasData CCTextureAtlasData AnimationState EventObject Bone Transform Matrix TransformObject ArmatureData BoneData SlotData SkinData AnimationData diff --git a/native/tools/tojs/cocos2dx_experimental_video.ini b/native/tools/tojs/cocos2dx_experimental_video.ini deleted file mode 100644 index 8369a553f3..0000000000 --- a/native/tools/tojs/cocos2dx_experimental_video.ini +++ /dev/null @@ -1,58 +0,0 @@ -[cocos2dx_experimental_video] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = cocos2dx_experimental_video - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = ccui - -macro_judgement = #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/%(clang_include)s -clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ - -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android - -cocos_flags = -DANDROID - -cxxgenerator_headers = - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s - -# what headers to parse -headers = %(cocosdir)s/cocos/ui/UIVideoPlayer.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = VideoPlayer - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# Set is special and we will use a hand-written constructor -abstract_classes = diff --git a/native/tools/tojs/cocos2dx_experimental_webView.ini b/native/tools/tojs/cocos2dx_experimental_webView.ini deleted file mode 100644 index d143ab5820..0000000000 --- a/native/tools/tojs/cocos2dx_experimental_webView.ini +++ /dev/null @@ -1,59 +0,0 @@ -[cocos2dx_experimental_webView] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = cocos2dx_experimental_webView - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = ccui - -macro_judgement = #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/%(clang_include)s -clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ - -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android - -cocos_flags = -DANDROID - -cxxgenerator_headers = - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s - -# what headers to parse -headers = %(cocosdir)s/cocos/ui/UIWebView.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = WebView - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# Set is special and we will use a hand-written constructor -abstract_classes = - diff --git a/native/tools/tojs/creator.ini b/native/tools/tojs/creator.ini deleted file mode 100644 index 93a4a05b4a..0000000000 --- a/native/tools/tojs/creator.ini +++ /dev/null @@ -1,68 +0,0 @@ -[creator] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = creator - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = cc - -# the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::ui::Label". -cpp_namespace = creator - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/%(clang_include)s -clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ - -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external -I%(cocosdir)s/external/sources - -cocos_flags = -DANDROID - -cxxgenerator_headers = - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s - -# what headers to parse -headers = %(creatordir)s/CCScale9Sprite.h - -# cpp_headers = scripting/js-bindings/manual/box2d/js_bindings_box2d_manual.h - -replace_headers = CCScale9Sprite.h::creator/CCScale9Sprite.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Scale9SpriteV2 - -classes_need_extend = Scale9SpriteV2 - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# Set is special and we will use a hand-written constructor -abstract_classes = - - -classes_owned_by_cpp = diff --git a/native/tools/tojs/creator_camera.ini b/native/tools/tojs/creator_camera.ini deleted file mode 100644 index 85112a74e9..0000000000 --- a/native/tools/tojs/creator_camera.ini +++ /dev/null @@ -1,68 +0,0 @@ -[creator] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = creator_camera - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = cc - -# the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::ui::Label". -cpp_namespace = creator - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/%(clang_include)s -clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ - -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external -I%(cocosdir)s/external/sources - -cocos_flags = -DANDROID - -cxxgenerator_headers = - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s - -# what headers to parse -headers = %(creatordir)s/CCCameraNode.h - -# cpp_headers = scripting/js-bindings/manual/box2d/js_bindings_box2d_manual.h - -replace_headers = - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = CameraNode - -classes_need_extend = - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = CameraNode::[(.*)Visit] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# Set is special and we will use a hand-written constructor -abstract_classes = - - -classes_owned_by_cpp = diff --git a/native/tools/tojs/creator_graphics.ini b/native/tools/tojs/creator_graphics.ini deleted file mode 100644 index f49332dcad..0000000000 --- a/native/tools/tojs/creator_graphics.ini +++ /dev/null @@ -1,68 +0,0 @@ -[creator] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = creator_graphics - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = cc - -# the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::ui::Label". -cpp_namespace = creator - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/%(clang_include)s -clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ - -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external -I%(cocosdir)s/external/sources - -cocos_flags = -DANDROID - -cxxgenerator_headers = - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s - -# what headers to parse -headers = %(creatordir)s/CCGraphicsNode.h - -# cpp_headers = scripting/js-bindings/manual/box2d/js_bindings_box2d_manual.h - -replace_headers = CCGraphicsNode.h::creator/CCGraphicsNode.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = GraphicsNode - -classes_need_extend = GraphicsNode - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# Set is special and we will use a hand-written constructor -abstract_classes = - - -classes_owned_by_cpp = diff --git a/native/tools/tojs/creator_physics.ini b/native/tools/tojs/creator_physics.ini deleted file mode 100644 index b64a9ceb0b..0000000000 --- a/native/tools/tojs/creator_physics.ini +++ /dev/null @@ -1,74 +0,0 @@ -[creator] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = creator_physics - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = cc - -# the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::ui::Label". -cpp_namespace = creator - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/%(clang_include)s -clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ - -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external -I%(cocosdir)s/external/sources - -cocos_flags = -DANDROID - -cxxgenerator_headers = - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s - -# what headers to parse -headers = %(creatordir)s/physics/CCPhysicsDebugDraw.h %(creatordir)s/physics/CCPhysicsUtils.h %(creatordir)s/physics/CCPhysicsContactListener.h %(creatordir)s/physics/CCPhysicsAABBQueryCallback.h %(creatordir)s/physics/CCPhysicsRayCastCallback.h %(creatordir)s/physics/CCPhysicsWorldManifoldWrapper.h %(creatordir)s/physics/CCPhysicsContactImpulse.h - -# cpp_headers = scripting/js-bindings/manual/box2d/js_bindings_box2d_manual.h - -replace_headers = - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = PhysicsDebugDraw PhysicsUtils PhysicsContactListener PhysicsAABBQueryCallback PhysicsRayCastCallback PhysicsWorldManifoldWrapper PhysicsManifoldWrapper PhysicsContactImpulse - -classes_need_extend = - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = PhysicsDebugDraw::[DrawPolygon DrawSolidPolygon DrawCircle DrawSolidCircle DrawSegment DrawTransform], - PhysicsContactListener::[getAllInstances BeginContact EndContact PreSolve PostSolve setBeginContact setEndContact setPreSolve setPostSolve], - PhysicsAABBQueryCallback::[ReportFixture getFixtures], - PhysicsRayCastCallback::[ReportFixture getFixtures getNormals getPoints], - PhysicsWorldManifoldWrapper::[init getb2WorldManifold], - PhysicsManifoldWrapper::[init], - PhysicsContactImpulse::[init] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# Set is special and we will use a hand-written constructor -abstract_classes = - - -classes_owned_by_cpp = PhysicsContactImpulse PhysicsWorldManifoldWrapper PhysicsManifoldWrapper