SkeletonData.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /******************************************************************************
  2. * Spine Runtimes License Agreement
  3. * Last updated January 1, 2020. Replaces all prior versions.
  4. *
  5. * Copyright (c) 2013-2020, Esoteric Software LLC
  6. *
  7. * Integration of the Spine Runtimes into software or otherwise creating
  8. * derivative works of the Spine Runtimes is permitted under the terms and
  9. * conditions of Section 2 of the Spine Editor License Agreement:
  10. * http://esotericsoftware.com/spine-editor-license
  11. *
  12. * Otherwise, it is permitted to integrate the Spine Runtimes into software
  13. * or otherwise create derivative works of the Spine Runtimes (collectively,
  14. * "Products"), provided that each user of the Products must obtain their own
  15. * Spine Editor license and redistribution of the Products in any form must
  16. * include this license and copyright notice.
  17. *
  18. * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
  19. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
  24. * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  27. * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *****************************************************************************/
  29. #ifdef SPINE_UE4
  30. #include "SpinePluginPrivatePCH.h"
  31. #endif
  32. #include <spine/SkeletonData.h>
  33. #include <spine/BoneData.h>
  34. #include <spine/SlotData.h>
  35. #include <spine/Skin.h>
  36. #include <spine/EventData.h>
  37. #include <spine/Animation.h>
  38. #include <spine/IkConstraintData.h>
  39. #include <spine/TransformConstraintData.h>
  40. #include <spine/PathConstraintData.h>
  41. #include <spine/ContainerUtil.h>
  42. using namespace spine;
  43. SkeletonData::SkeletonData() :
  44. _name(),
  45. _defaultSkin(NULL),
  46. _x(0),
  47. _y(0),
  48. _width(0),
  49. _height(0),
  50. _version(),
  51. _hash(),
  52. _fps(0),
  53. _imagesPath() {
  54. }
  55. SkeletonData::~SkeletonData() {
  56. ContainerUtil::cleanUpVectorOfPointers(_bones);
  57. ContainerUtil::cleanUpVectorOfPointers(_slots);
  58. ContainerUtil::cleanUpVectorOfPointers(_skins);
  59. _defaultSkin = NULL;
  60. ContainerUtil::cleanUpVectorOfPointers(_events);
  61. ContainerUtil::cleanUpVectorOfPointers(_animations);
  62. ContainerUtil::cleanUpVectorOfPointers(_ikConstraints);
  63. ContainerUtil::cleanUpVectorOfPointers(_transformConstraints);
  64. ContainerUtil::cleanUpVectorOfPointers(_pathConstraints);
  65. for (size_t i = 0; i < _strings.size(); i++) {
  66. SpineExtension::free(_strings[i], __FILE__, __LINE__);
  67. }
  68. }
  69. BoneData *SkeletonData::findBone(const String &boneName) {
  70. return ContainerUtil::findWithName(_bones, boneName);
  71. }
  72. int SkeletonData::findBoneIndex(const String &boneName) {
  73. return ContainerUtil::findIndexWithName(_bones, boneName);
  74. }
  75. SlotData *SkeletonData::findSlot(const String &slotName) {
  76. return ContainerUtil::findWithName(_slots, slotName);
  77. }
  78. int SkeletonData::findSlotIndex(const String &slotName) {
  79. return ContainerUtil::findIndexWithName(_slots, slotName);
  80. }
  81. Skin *SkeletonData::findSkin(const String &skinName) {
  82. return ContainerUtil::findWithName(_skins, skinName);
  83. }
  84. spine::EventData *SkeletonData::findEvent(const String &eventDataName) {
  85. return ContainerUtil::findWithName(_events, eventDataName);
  86. }
  87. Animation *SkeletonData::findAnimation(const String &animationName) {
  88. return ContainerUtil::findWithName(_animations, animationName);
  89. }
  90. IkConstraintData *SkeletonData::findIkConstraint(const String &constraintName) {
  91. return ContainerUtil::findWithName(_ikConstraints, constraintName);
  92. }
  93. TransformConstraintData *SkeletonData::findTransformConstraint(const String &constraintName) {
  94. return ContainerUtil::findWithName(_transformConstraints, constraintName);
  95. }
  96. PathConstraintData *SkeletonData::findPathConstraint(const String &constraintName) {
  97. return ContainerUtil::findWithName(_pathConstraints, constraintName);
  98. }
  99. int SkeletonData::findPathConstraintIndex(const String &pathConstraintName) {
  100. return ContainerUtil::findIndexWithName(_pathConstraints, pathConstraintName);
  101. }
  102. const String &SkeletonData::getName() {
  103. return _name;
  104. }
  105. void SkeletonData::setName(const String &inValue) {
  106. _name = inValue;
  107. }
  108. Vector<BoneData *> &SkeletonData::getBones() {
  109. return _bones;
  110. }
  111. Vector<SlotData *> &SkeletonData::getSlots() {
  112. return _slots;
  113. }
  114. Vector<Skin *> &SkeletonData::getSkins() {
  115. return _skins;
  116. }
  117. Skin *SkeletonData::getDefaultSkin() {
  118. return _defaultSkin;
  119. }
  120. void SkeletonData::setDefaultSkin(Skin *inValue) {
  121. _defaultSkin = inValue;
  122. }
  123. Vector<spine::EventData *> &SkeletonData::getEvents() {
  124. return _events;
  125. }
  126. Vector<Animation *> &SkeletonData::getAnimations() {
  127. return _animations;
  128. }
  129. Vector<IkConstraintData *> &SkeletonData::getIkConstraints() {
  130. return _ikConstraints;
  131. }
  132. Vector<TransformConstraintData *> &SkeletonData::getTransformConstraints() {
  133. return _transformConstraints;
  134. }
  135. Vector<PathConstraintData *> &SkeletonData::getPathConstraints() {
  136. return _pathConstraints;
  137. }
  138. float SkeletonData::getX() {
  139. return _x;
  140. }
  141. void SkeletonData::setX(float inValue) {
  142. _x = inValue;
  143. }
  144. float SkeletonData::getY() {
  145. return _y;
  146. }
  147. void SkeletonData::setY(float inValue) {
  148. _y = inValue;
  149. }
  150. float SkeletonData::getWidth() {
  151. return _width;
  152. }
  153. void SkeletonData::setWidth(float inValue) {
  154. _width = inValue;
  155. }
  156. float SkeletonData::getHeight() {
  157. return _height;
  158. }
  159. void SkeletonData::setHeight(float inValue) {
  160. _height = inValue;
  161. }
  162. const String &SkeletonData::getVersion() {
  163. return _version;
  164. }
  165. void SkeletonData::setVersion(const String &inValue) {
  166. _version = inValue;
  167. }
  168. const String &SkeletonData::getHash() {
  169. return _hash;
  170. }
  171. void SkeletonData::setHash(const String &inValue) {
  172. _hash = inValue;
  173. }
  174. const String &SkeletonData::getImagesPath() {
  175. return _imagesPath;
  176. }
  177. void SkeletonData::setImagesPath(const String &inValue) {
  178. _imagesPath = inValue;
  179. }
  180. const String &SkeletonData::getAudioPath() {
  181. return _audioPath;
  182. }
  183. void SkeletonData::setAudioPath(const String &inValue) {
  184. _audioPath = inValue;
  185. }
  186. float SkeletonData::getFps() {
  187. return _fps;
  188. }
  189. void SkeletonData::setFps(float inValue) {
  190. _fps = inValue;
  191. }