spine-cpp-lite.cpp 168 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840
  1. /******************************************************************************
  2. * Spine Runtimes License Agreement
  3. * Last updated July 28, 2023. Replaces all prior versions.
  4. *
  5. * Copyright (c) 2013-2023, 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 or
  13. * 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 THE
  27. * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *****************************************************************************/
  29. #include "spine-cpp-lite.h"
  30. #include <spine/spine.h>
  31. #include <spine/Version.h>
  32. #include <spine/Debug.h>
  33. using namespace spine;
  34. struct AnimationStateEvent {
  35. EventType type;
  36. TrackEntry *entry;
  37. Event *event;
  38. AnimationStateEvent(EventType type, TrackEntry *entry, Event *event) : type(type), entry(entry), event(event){};
  39. };
  40. struct EventListener : public AnimationStateListenerObject {
  41. Vector<AnimationStateEvent> events;
  42. void callback(AnimationState *state, EventType type, TrackEntry *entry, Event *event) {
  43. events.add(AnimationStateEvent(type, entry, event));
  44. SP_UNUSED(state);
  45. }
  46. };
  47. typedef struct _spine_atlas {
  48. void *atlas;
  49. utf8 **imagePaths;
  50. int32_t numImagePaths;
  51. utf8 *error;
  52. } _spine_atlas;
  53. typedef struct _spine_skeleton_data_result {
  54. spine_skeleton_data skeletonData;
  55. utf8 *error;
  56. } _spine_skeleton_data_result;
  57. typedef struct _spine_bounds {
  58. float x, y, width, height;
  59. } _spine_bounds;
  60. typedef struct _spine_vector {
  61. float x, y;
  62. } _spine_vector;
  63. typedef struct _spine_skeleton_drawable : public SpineObject {
  64. spine_skeleton skeleton;
  65. spine_animation_state animationState;
  66. spine_animation_state_data animationStateData;
  67. spine_animation_state_events animationStateEvents;
  68. SkeletonRenderer *renderer;
  69. } _spine_skeleton_drawable;
  70. typedef struct _spine_skin_entry {
  71. int32_t slotIndex;
  72. utf8 *name;
  73. spine_attachment attachment;
  74. } _spine_skin_entry;
  75. typedef struct _spine_skin_entries {
  76. int32_t numEntries;
  77. _spine_skin_entry *entries;
  78. } _spine_skin_entries;
  79. static Color NULL_COLOR(0, 0, 0, 0);
  80. static SpineExtension *defaultExtension = nullptr;
  81. static DebugExtension *debugExtension = nullptr;
  82. static void initExtensions() {
  83. if (defaultExtension == nullptr) {
  84. defaultExtension = new DefaultSpineExtension();
  85. debugExtension = new DebugExtension(defaultExtension);
  86. }
  87. }
  88. spine::SpineExtension *spine::getDefaultExtension() {
  89. initExtensions();
  90. return defaultExtension;
  91. }
  92. void spine_enable_debug_extension(spine_bool enable) {
  93. initExtensions();
  94. SpineExtension::setInstance(enable ? debugExtension : defaultExtension);
  95. }
  96. int32_t spine_major_version() {
  97. return SPINE_MAJOR_VERSION;
  98. }
  99. int32_t spine_minor_version() {
  100. return SPINE_MINOR_VERSION;
  101. }
  102. void spine_report_leaks() {
  103. initExtensions();
  104. debugExtension->reportLeaks();
  105. fflush(stdout);
  106. }
  107. // Color
  108. float spine_color_get_r(spine_color color) {
  109. if (!color) return 0;
  110. return ((Color *) color)->r;
  111. }
  112. float spine_color_get_g(spine_color color) {
  113. if (!color) return 0;
  114. return ((Color *) color)->g;
  115. }
  116. float spine_color_get_b(spine_color color) {
  117. if (!color) return 0;
  118. return ((Color *) color)->b;
  119. }
  120. float spine_color_get_a(spine_color color) {
  121. if (!color) return 0;
  122. return ((Color *) color)->a;
  123. }
  124. // Bounds
  125. float spine_bounds_get_x(spine_bounds bounds) {
  126. if (!bounds) return 0;
  127. return ((_spine_bounds *) bounds)->x;
  128. }
  129. float spine_bounds_get_y(spine_bounds bounds) {
  130. if (!bounds) return 0;
  131. return ((_spine_bounds *) bounds)->y;
  132. }
  133. float spine_bounds_get_width(spine_bounds bounds) {
  134. if (!bounds) return 0;
  135. return ((_spine_bounds *) bounds)->width;
  136. }
  137. float spine_bounds_get_height(spine_bounds bounds) {
  138. if (!bounds) return 0;
  139. return ((_spine_bounds *) bounds)->height;
  140. }
  141. // Vector
  142. float spine_vector_get_x(spine_vector vector) {
  143. if (!vector) return 0;
  144. return ((_spine_vector *) vector)->x;
  145. }
  146. float spine_vector_get_y(spine_vector vector) {
  147. if (!vector) return 0;
  148. return ((_spine_vector *) vector)->y;
  149. }
  150. // Atlas
  151. class LiteTextureLoad : public TextureLoader {
  152. void load(AtlasPage &page, const String &path) {
  153. page.texture = (void *) (intptr_t) page.index;
  154. }
  155. void unload(void *texture) {
  156. }
  157. };
  158. LiteTextureLoad liteLoader;
  159. spine_atlas spine_atlas_load(const utf8 *atlasData) {
  160. if (!atlasData) return nullptr;
  161. int32_t length = (int32_t) strlen(atlasData);
  162. auto atlas = new (__FILE__, __LINE__) Atlas(atlasData, length, "", &liteLoader, true);
  163. _spine_atlas *result = SpineExtension::calloc<_spine_atlas>(1, __FILE__, __LINE__);
  164. result->atlas = atlas;
  165. result->numImagePaths = (int32_t) atlas->getPages().size();
  166. result->imagePaths = SpineExtension::calloc<utf8 *>(result->numImagePaths, __FILE__, __LINE__);
  167. for (int i = 0; i < result->numImagePaths; i++) {
  168. result->imagePaths[i] = (utf8 *) strdup(atlas->getPages()[i]->texturePath.buffer());
  169. }
  170. return (spine_atlas) result;
  171. }
  172. class CallbackTextureLoad : public TextureLoader {
  173. spine_texture_loader_load_func loadCb;
  174. spine_texture_loader_unload_func unloadCb;
  175. public:
  176. CallbackTextureLoad() : loadCb(nullptr), unloadCb(nullptr) {}
  177. void setCallbacks(spine_texture_loader_load_func load, spine_texture_loader_unload_func unload) {
  178. loadCb = load;
  179. unloadCb = unload;
  180. }
  181. void load(AtlasPage &page, const String &path) {
  182. page.texture = this->loadCb(path.buffer());
  183. }
  184. void unload(void *texture) {
  185. this->unloadCb(texture);
  186. }
  187. };
  188. CallbackTextureLoad callbackLoader;
  189. spine_atlas spine_atlas_load_callback(const utf8 *atlasData, const utf8 *atlasDir, spine_texture_loader_load_func load, spine_texture_loader_unload_func unload) {
  190. if (!atlasData) return nullptr;
  191. int32_t length = (int32_t) strlen(atlasData);
  192. callbackLoader.setCallbacks(load, unload);
  193. auto atlas = new (__FILE__, __LINE__) Atlas(atlasData, length, (const char *) atlasDir, &callbackLoader, true);
  194. _spine_atlas *result = SpineExtension::calloc<_spine_atlas>(1, __FILE__, __LINE__);
  195. result->atlas = atlas;
  196. result->numImagePaths = (int32_t) atlas->getPages().size();
  197. result->imagePaths = SpineExtension::calloc<utf8 *>(result->numImagePaths, __FILE__, __LINE__);
  198. for (int i = 0; i < result->numImagePaths; i++) {
  199. result->imagePaths[i] = (utf8 *) strdup(atlas->getPages()[i]->texturePath.buffer());
  200. }
  201. return (spine_atlas) result;
  202. }
  203. int32_t spine_atlas_get_num_image_paths(spine_atlas atlas) {
  204. if (!atlas) return 0;
  205. return ((_spine_atlas *) atlas)->numImagePaths;
  206. }
  207. spine_bool spine_atlas_is_pma(spine_atlas atlas) {
  208. if (!atlas) return 0;
  209. Atlas *_atlas = static_cast<Atlas *>(((_spine_atlas *) atlas)->atlas);
  210. if (_atlas->getPages().size() > 0) {
  211. return _atlas->getPages()[0]->pma;
  212. } else {
  213. return 0;
  214. }
  215. }
  216. utf8 *spine_atlas_get_image_path(spine_atlas atlas, int32_t index) {
  217. if (!atlas) return nullptr;
  218. return ((_spine_atlas *) atlas)->imagePaths[index];
  219. }
  220. utf8 *spine_atlas_get_error(spine_atlas atlas) {
  221. if (!atlas) return nullptr;
  222. return ((_spine_atlas *) atlas)->error;
  223. }
  224. void spine_atlas_dispose(spine_atlas atlas) {
  225. if (!atlas) return;
  226. _spine_atlas *_atlas = (_spine_atlas *) atlas;
  227. if (_atlas->atlas) delete (Atlas *) _atlas->atlas;
  228. if (_atlas->error) free(_atlas->error);
  229. for (int i = 0; i < _atlas->numImagePaths; i++) {
  230. free(_atlas->imagePaths[i]);
  231. }
  232. SpineExtension::free(_atlas->imagePaths, __FILE__, __LINE__);
  233. SpineExtension::free(_atlas, __FILE__, __LINE__);
  234. }
  235. // SkeletonData
  236. spine_skeleton_data_result spine_skeleton_data_load_json(spine_atlas atlas, const utf8 *skeletonData) {
  237. _spine_skeleton_data_result *result = SpineExtension::calloc<_spine_skeleton_data_result>(1, __FILE__, __LINE__);
  238. _spine_atlas *_atlas = (_spine_atlas *) atlas;
  239. Bone::setYDown(true);
  240. if (!_atlas) return (spine_skeleton_data_result) result;
  241. if (!_atlas->atlas) return (spine_skeleton_data_result) result;
  242. if (!skeletonData) return (spine_skeleton_data_result) result;
  243. SkeletonJson json((Atlas *) _atlas->atlas);
  244. SkeletonData *data = json.readSkeletonData(skeletonData);
  245. result->skeletonData = (spine_skeleton_data) data;
  246. if (!json.getError().isEmpty()) {
  247. result->error = (utf8 *) strdup(json.getError().buffer());
  248. }
  249. return (spine_skeleton_data_result) result;
  250. }
  251. spine_skeleton_data_result spine_skeleton_data_load_binary(spine_atlas atlas, const uint8_t *skeletonData, int32_t length) {
  252. _spine_skeleton_data_result *result = SpineExtension::calloc<_spine_skeleton_data_result>(1, __FILE__, __LINE__);
  253. _spine_atlas *_atlas = (_spine_atlas *) atlas;
  254. Bone::setYDown(true);
  255. if (!_atlas) return (spine_skeleton_data_result) result;
  256. if (!_atlas->atlas) return (spine_skeleton_data_result) result;
  257. if (!skeletonData) return (spine_skeleton_data_result) result;
  258. if (length <= 0) return (spine_skeleton_data_result) result;
  259. SkeletonBinary binary((Atlas *) _atlas->atlas);
  260. SkeletonData *data = binary.readSkeletonData(skeletonData, length);
  261. result->skeletonData = (spine_skeleton_data) data;
  262. if (!binary.getError().isEmpty()) {
  263. result->error = (utf8 *) strdup(binary.getError().buffer());
  264. }
  265. return (spine_skeleton_data_result) result;
  266. }
  267. utf8 *spine_skeleton_data_result_get_error(spine_skeleton_data_result result) {
  268. if (!result) return nullptr;
  269. return ((_spine_skeleton_data_result *) result)->error;
  270. }
  271. spine_skeleton_data spine_skeleton_data_result_get_data(spine_skeleton_data_result result) {
  272. if (!result) return nullptr;
  273. return ((_spine_skeleton_data_result *) result)->skeletonData;
  274. }
  275. void spine_skeleton_data_result_dispose(spine_skeleton_data_result result) {
  276. if (!result) return;
  277. _spine_skeleton_data_result *_result = (_spine_skeleton_data_result *) result;
  278. if (_result->error) SpineExtension::free(_result->error, __FILE__, __LINE__);
  279. SpineExtension::free(_result, __FILE__, __LINE__);
  280. }
  281. spine_bone_data spine_skeleton_data_find_bone(spine_skeleton_data data, const utf8 *name) {
  282. if (data == nullptr) return nullptr;
  283. SkeletonData *_data = (SkeletonData *) data;
  284. return (spine_bone_data) _data->findBone(name);
  285. }
  286. spine_slot_data spine_skeleton_data_find_slot(spine_skeleton_data data, const utf8 *name) {
  287. if (data == nullptr) return nullptr;
  288. SkeletonData *_data = (SkeletonData *) data;
  289. return (spine_slot_data) _data->findSlot(name);
  290. }
  291. spine_skin spine_skeleton_data_find_skin(spine_skeleton_data data, const utf8 *name) {
  292. if (data == nullptr) return nullptr;
  293. SkeletonData *_data = (SkeletonData *) data;
  294. return (spine_skin) _data->findSkin(name);
  295. }
  296. spine_event_data spine_skeleton_data_find_event(spine_skeleton_data data, const utf8 *name) {
  297. if (data == nullptr) return nullptr;
  298. SkeletonData *_data = (SkeletonData *) data;
  299. return (spine_event_data) _data->findEvent(name);
  300. }
  301. spine_animation spine_skeleton_data_find_animation(spine_skeleton_data data, const utf8 *name) {
  302. if (data == nullptr) return nullptr;
  303. SkeletonData *_data = (SkeletonData *) data;
  304. return (spine_animation) _data->findAnimation(name);
  305. }
  306. spine_ik_constraint_data spine_skeleton_data_find_ik_constraint(spine_skeleton_data data, const utf8 *name) {
  307. if (data == nullptr) return nullptr;
  308. SkeletonData *_data = (SkeletonData *) data;
  309. return (spine_ik_constraint_data) _data->findIkConstraint(name);
  310. }
  311. spine_transform_constraint_data spine_skeleton_data_find_transform_constraint(spine_skeleton_data data, const utf8 *name) {
  312. if (data == nullptr) return nullptr;
  313. SkeletonData *_data = (SkeletonData *) data;
  314. return (spine_transform_constraint_data) _data->findTransformConstraint(name);
  315. }
  316. spine_path_constraint_data spine_skeleton_data_find_path_constraint(spine_skeleton_data data, const utf8 *name) {
  317. if (data == nullptr) return nullptr;
  318. SkeletonData *_data = (SkeletonData *) data;
  319. return (spine_path_constraint_data) _data->findPathConstraint(name);
  320. }
  321. spine_physics_constraint_data spine_skeleton_data_find_physics_constraint(spine_skeleton_data data, const utf8 *name) {
  322. if (data == nullptr) return nullptr;
  323. SkeletonData *_data = (SkeletonData *) data;
  324. return (spine_physics_constraint_data) _data->findPhysicsConstraint(name);
  325. }
  326. const utf8 *spine_skeleton_data_get_name(spine_skeleton_data data) {
  327. if (data == nullptr) return nullptr;
  328. SkeletonData *_data = (SkeletonData *) data;
  329. return (utf8 *) _data->getName().buffer();
  330. }
  331. int32_t spine_skeleton_data_get_num_bones(spine_skeleton_data data) {
  332. if (data == nullptr) return 0;
  333. SkeletonData *_data = (SkeletonData *) data;
  334. return (int32_t) _data->getBones().size();
  335. }
  336. spine_bone_data *spine_skeleton_data_get_bones(spine_skeleton_data data) {
  337. if (data == nullptr) return nullptr;
  338. SkeletonData *_data = (SkeletonData *) data;
  339. return (spine_bone_data *) _data->getBones().buffer();
  340. }
  341. int32_t spine_skeleton_data_get_num_slots(spine_skeleton_data data) {
  342. if (data == nullptr) return 0;
  343. SkeletonData *_data = (SkeletonData *) data;
  344. return (int32_t) _data->getSlots().size();
  345. }
  346. spine_slot_data *spine_skeleton_data_get_slots(spine_skeleton_data data) {
  347. if (data == nullptr) return nullptr;
  348. SkeletonData *_data = (SkeletonData *) data;
  349. return (spine_slot_data *) _data->getSlots().buffer();
  350. }
  351. int32_t spine_skeleton_data_get_num_skins(spine_skeleton_data data) {
  352. if (data == nullptr) return 0;
  353. SkeletonData *_data = (SkeletonData *) data;
  354. return (int32_t) _data->getSkins().size();
  355. }
  356. spine_skin *spine_skeleton_data_get_skins(spine_skeleton_data data) {
  357. if (data == nullptr) return nullptr;
  358. SkeletonData *_data = (SkeletonData *) data;
  359. return (spine_skin *) _data->getSkins().buffer();
  360. }
  361. spine_skin spine_skeleton_data_get_default_skin(spine_skeleton_data data) {
  362. if (data == nullptr) return nullptr;
  363. SkeletonData *_data = (SkeletonData *) data;
  364. return (spine_skin) _data->getDefaultSkin();
  365. }
  366. void spine_skeleton_data_set_default_skin(spine_skeleton_data data, spine_skin skin) {
  367. if (data == nullptr) return;
  368. SkeletonData *_data = (SkeletonData *) data;
  369. _data->setDefaultSkin((Skin *) skin);
  370. }
  371. int32_t spine_skeleton_data_get_num_events(spine_skeleton_data data) {
  372. if (data == nullptr) return 0;
  373. SkeletonData *_data = (SkeletonData *) data;
  374. return (int32_t) _data->getEvents().size();
  375. }
  376. spine_event_data *spine_skeleton_data_get_events(spine_skeleton_data data) {
  377. if (data == nullptr) return nullptr;
  378. SkeletonData *_data = (SkeletonData *) data;
  379. return (spine_event_data *) _data->getEvents().buffer();
  380. }
  381. int32_t spine_skeleton_data_get_num_animations(spine_skeleton_data data) {
  382. if (data == nullptr) return 0;
  383. SkeletonData *_data = (SkeletonData *) data;
  384. return (int32_t) _data->getAnimations().size();
  385. }
  386. spine_animation *spine_skeleton_data_get_animations(spine_skeleton_data data) {
  387. if (data == nullptr) return nullptr;
  388. SkeletonData *_data = (SkeletonData *) data;
  389. return (spine_animation *) _data->getAnimations().buffer();
  390. }
  391. int32_t spine_skeleton_data_get_num_ik_constraints(spine_skeleton_data data) {
  392. if (data == nullptr) return 0;
  393. SkeletonData *_data = (SkeletonData *) data;
  394. return (int32_t) _data->getIkConstraints().size();
  395. }
  396. spine_ik_constraint_data *spine_skeleton_data_get_ik_constraints(spine_skeleton_data data) {
  397. if (data == nullptr) return nullptr;
  398. SkeletonData *_data = (SkeletonData *) data;
  399. return (spine_ik_constraint_data *) _data->getIkConstraints().buffer();
  400. }
  401. int32_t spine_skeleton_data_get_num_transform_constraints(spine_skeleton_data data) {
  402. if (data == nullptr) return 0;
  403. SkeletonData *_data = (SkeletonData *) data;
  404. return (int32_t) _data->getTransformConstraints().size();
  405. }
  406. spine_transform_constraint_data *spine_skeleton_data_get_transform_constraints(spine_skeleton_data data) {
  407. if (data == nullptr) return nullptr;
  408. SkeletonData *_data = (SkeletonData *) data;
  409. return (spine_transform_constraint_data *) _data->getTransformConstraints().buffer();
  410. }
  411. int32_t spine_skeleton_data_get_num_path_constraints(spine_skeleton_data data) {
  412. if (data == nullptr) return 0;
  413. SkeletonData *_data = (SkeletonData *) data;
  414. return (int32_t) _data->getPathConstraints().size();
  415. }
  416. spine_path_constraint_data *spine_skeleton_data_get_path_constraints(spine_skeleton_data data) {
  417. if (data == nullptr) return nullptr;
  418. SkeletonData *_data = (SkeletonData *) data;
  419. return (spine_path_constraint_data *) _data->getPathConstraints().buffer();
  420. }
  421. int32_t spine_skeleton_data_get_num_physics_constraints(spine_skeleton_data data) {
  422. if (data == nullptr) return 0;
  423. SkeletonData *_data = (SkeletonData *) data;
  424. return (int32_t) _data->getPhysicsConstraints().size();
  425. }
  426. spine_physics_constraint_data *spine_skeleton_data_get_physics_constraints(spine_skeleton_data data) {
  427. if (data == nullptr) return nullptr;
  428. SkeletonData *_data = (SkeletonData *) data;
  429. return (spine_physics_constraint_data *) _data->getPhysicsConstraints().buffer();
  430. }
  431. float spine_skeleton_data_get_x(spine_skeleton_data data) {
  432. if (data == nullptr) return 0;
  433. SkeletonData *_data = (SkeletonData *) data;
  434. return _data->getX();
  435. }
  436. void spine_skeleton_data_set_x(spine_skeleton_data data, float x) {
  437. if (data == nullptr) return;
  438. SkeletonData *_data = (SkeletonData *) data;
  439. _data->setX(x);
  440. }
  441. float spine_skeleton_data_get_y(spine_skeleton_data data) {
  442. if (data == nullptr) return 0;
  443. SkeletonData *_data = (SkeletonData *) data;
  444. return _data->getY();
  445. }
  446. void spine_skeleton_data_set_y(spine_skeleton_data data, float y) {
  447. if (data == nullptr) return;
  448. SkeletonData *_data = (SkeletonData *) data;
  449. _data->setY(y);
  450. }
  451. float spine_skeleton_data_get_width(spine_skeleton_data data) {
  452. if (data == nullptr) return 0;
  453. SkeletonData *_data = (SkeletonData *) data;
  454. return _data->getWidth();
  455. }
  456. void spine_skeleton_data_set_width(spine_skeleton_data data, float width) {
  457. if (data == nullptr) return;
  458. SkeletonData *_data = (SkeletonData *) data;
  459. _data->setWidth(width);
  460. }
  461. float spine_skeleton_data_get_height(spine_skeleton_data data) {
  462. if (data == nullptr) return 0;
  463. SkeletonData *_data = (SkeletonData *) data;
  464. return _data->getHeight();
  465. }
  466. void spine_skeleton_data_set_height(spine_skeleton_data data, float height) {
  467. if (data == nullptr) return;
  468. SkeletonData *_data = (SkeletonData *) data;
  469. _data->setHeight(height);
  470. }
  471. const utf8 *spine_skeleton_data_get_version(spine_skeleton_data data) {
  472. if (data == nullptr) return nullptr;
  473. SkeletonData *_data = (SkeletonData *) data;
  474. return (utf8 *) _data->getVersion().buffer();
  475. }
  476. const utf8 *spine_skeleton_data_get_hash(spine_skeleton_data data) {
  477. if (data == nullptr) return nullptr;
  478. SkeletonData *_data = (SkeletonData *) data;
  479. return (utf8 *) _data->getHash().buffer();
  480. }
  481. const utf8 *spine_skeleton_data_get_images_path(spine_skeleton_data data) {
  482. if (data == nullptr) return nullptr;
  483. SkeletonData *_data = (SkeletonData *) data;
  484. return (utf8 *) _data->getImagesPath().buffer();
  485. }
  486. const utf8 *spine_skeleton_data_get_audio_path(spine_skeleton_data data) {
  487. if (data == nullptr) return nullptr;
  488. SkeletonData *_data = (SkeletonData *) data;
  489. return (utf8 *) _data->getAudioPath().buffer();
  490. }
  491. float spine_skeleton_data_get_fps(spine_skeleton_data data) {
  492. if (data == nullptr) return 0;
  493. SkeletonData *_data = (SkeletonData *) data;
  494. return _data->getFps();
  495. }
  496. float spine_skeleton_data_get_reference_scale(spine_skeleton_data data) {
  497. if (data == nullptr) return 0;
  498. SkeletonData *_data = (SkeletonData *) data;
  499. return _data->getReferenceScale();
  500. }
  501. void spine_skeleton_data_dispose(spine_skeleton_data data) {
  502. if (!data) return;
  503. delete (SkeletonData *) data;
  504. }
  505. // SkeletonDrawable
  506. spine_skeleton_drawable spine_skeleton_drawable_create(spine_skeleton_data skeletonData) {
  507. _spine_skeleton_drawable *drawable = new (__FILE__, __LINE__) _spine_skeleton_drawable();
  508. drawable->skeleton = (spine_skeleton) new (__FILE__, __LINE__) Skeleton((SkeletonData *) skeletonData);
  509. AnimationStateData *stateData = new (__FILE__, __LINE__) AnimationStateData((SkeletonData *) skeletonData);
  510. drawable->animationStateData = (spine_animation_state_data) stateData;
  511. AnimationState *state = new (__FILE__, __LINE__) AnimationState(stateData);
  512. drawable->animationState = (spine_animation_state) state;
  513. state->setManualTrackEntryDisposal(true);
  514. EventListener *listener = new EventListener();
  515. drawable->animationStateEvents = (spine_animation_state_events) listener;
  516. state->setListener(listener);
  517. drawable->renderer = new (__FILE__, __LINE__) SkeletonRenderer();
  518. return (spine_skeleton_drawable) drawable;
  519. }
  520. void spine_skeleton_drawable_dispose(spine_skeleton_drawable drawable) {
  521. _spine_skeleton_drawable *_drawable = (_spine_skeleton_drawable *) drawable;
  522. if (!_drawable) return;
  523. if (_drawable->skeleton) delete (Skeleton *) _drawable->skeleton;
  524. if (_drawable->animationState) delete (AnimationState *) _drawable->animationState;
  525. if (_drawable->animationStateData) delete (AnimationStateData *) _drawable->animationStateData;
  526. if (_drawable->animationStateEvents) delete (Vector<AnimationStateEvent> *) (_drawable->animationStateEvents);
  527. if (_drawable->renderer) delete (SkeletonRenderer *) _drawable->renderer;
  528. SpineExtension::free(drawable, __FILE__, __LINE__);
  529. }
  530. spine_render_command spine_skeleton_drawable_render(spine_skeleton_drawable drawable) {
  531. _spine_skeleton_drawable *_drawable = (_spine_skeleton_drawable *) drawable;
  532. if (!_drawable) return nullptr;
  533. if (!_drawable->skeleton) return nullptr;
  534. if (!_drawable->renderer) return nullptr;
  535. return (spine_render_command) _drawable->renderer->render(*(Skeleton *) _drawable->skeleton);
  536. }
  537. spine_skeleton spine_skeleton_drawable_get_skeleton(spine_skeleton_drawable drawable) {
  538. if (!drawable) return nullptr;
  539. return ((_spine_skeleton_drawable *) drawable)->skeleton;
  540. }
  541. spine_animation_state spine_skeleton_drawable_get_animation_state(spine_skeleton_drawable drawable) {
  542. if (!drawable) return nullptr;
  543. return ((_spine_skeleton_drawable *) drawable)->animationState;
  544. }
  545. spine_animation_state_data spine_skeleton_drawable_get_animation_state_data(spine_skeleton_drawable drawable) {
  546. if (!drawable) return nullptr;
  547. return ((_spine_skeleton_drawable *) drawable)->animationStateData;
  548. }
  549. spine_animation_state_events spine_skeleton_drawable_get_animation_state_events(spine_skeleton_drawable drawable) {
  550. if (!drawable) return nullptr;
  551. return ((_spine_skeleton_drawable *) drawable)->animationStateEvents;
  552. }
  553. // Render command
  554. float *spine_render_command_get_positions(spine_render_command command) {
  555. if (!command) return nullptr;
  556. return ((RenderCommand *) command)->positions;
  557. }
  558. float *spine_render_command_get_uvs(spine_render_command command) {
  559. if (!command) return nullptr;
  560. return ((RenderCommand *) command)->uvs;
  561. }
  562. int32_t *spine_render_command_get_colors(spine_render_command command) {
  563. if (!command) return nullptr;
  564. return (int32_t *) ((RenderCommand *) command)->colors;
  565. }
  566. int32_t *spine_render_command_get_dark_colors(spine_render_command command) {
  567. if (!command) return nullptr;
  568. return (int32_t *) ((RenderCommand *) command)->darkColors;
  569. }
  570. int32_t spine_render_command_get_num_vertices(spine_render_command command) {
  571. if (!command) return 0;
  572. return ((RenderCommand *) command)->numVertices;
  573. }
  574. uint16_t *spine_render_command_get_indices(spine_render_command command) {
  575. if (!command) return nullptr;
  576. return ((RenderCommand *) command)->indices;
  577. }
  578. int32_t spine_render_command_get_num_indices(spine_render_command command) {
  579. if (!command) return 0;
  580. return ((RenderCommand *) command)->numIndices;
  581. }
  582. int32_t spine_render_command_get_atlas_page(spine_render_command command) {
  583. if (!command) return 0;
  584. return (int32_t) (intptr_t) ((RenderCommand *) command)->texture;
  585. }
  586. spine_blend_mode spine_render_command_get_blend_mode(spine_render_command command) {
  587. if (!command) return SPINE_BLEND_MODE_NORMAL;
  588. return (spine_blend_mode) ((RenderCommand *) command)->blendMode;
  589. }
  590. spine_render_command spine_render_command_get_next(spine_render_command command) {
  591. if (!command) return nullptr;
  592. return (spine_render_command) ((RenderCommand *) command)->next;
  593. }
  594. // Animation
  595. const utf8 *spine_animation_get_name(spine_animation animation) {
  596. if (animation == nullptr) return nullptr;
  597. Animation *_animation = (Animation *) animation;
  598. return (utf8 *) _animation->getName().buffer();
  599. }
  600. float spine_animation_get_duration(spine_animation animation) {
  601. if (animation == nullptr) return 0;
  602. Animation *_animation = (Animation *) animation;
  603. return _animation->getDuration();
  604. }
  605. // AnimationStateData
  606. spine_skeleton_data spine_animation_state_data_get_skeleton_data(spine_animation_state_data stateData) {
  607. if (stateData == nullptr) return nullptr;
  608. AnimationStateData *_stateData = (AnimationStateData *) stateData;
  609. return (spine_skeleton_data) _stateData->getSkeletonData();
  610. }
  611. float spine_animation_state_data_get_default_mix(spine_animation_state_data stateData) {
  612. if (stateData == nullptr) return 0;
  613. AnimationStateData *_stateData = (AnimationStateData *) stateData;
  614. return _stateData->getDefaultMix();
  615. }
  616. void spine_animation_state_data_set_default_mix(spine_animation_state_data stateData, float defaultMix) {
  617. if (stateData == nullptr) return;
  618. AnimationStateData *_stateData = (AnimationStateData *) stateData;
  619. _stateData->setDefaultMix(defaultMix);
  620. }
  621. void spine_animation_state_data_set_mix(spine_animation_state_data stateData, spine_animation from, spine_animation to, float duration) {
  622. if (stateData == nullptr) return;
  623. if (from == nullptr || to == nullptr) return;
  624. AnimationStateData *_stateData = (AnimationStateData *) stateData;
  625. _stateData->setMix((Animation *) from, (Animation *) to, duration);
  626. }
  627. float spine_animation_state_data_get_mix(spine_animation_state_data stateData, spine_animation from, spine_animation to) {
  628. if (stateData == nullptr) return 0;
  629. if (from == nullptr || to == nullptr) return 0;
  630. AnimationStateData *_stateData = (AnimationStateData *) stateData;
  631. return _stateData->getMix((Animation *) from, (Animation *) to);
  632. }
  633. void spine_animation_state_data_set_mix_by_name(spine_animation_state_data stateData, const utf8 *fromName, const utf8 *toName, float duration) {
  634. if (stateData == nullptr) return;
  635. if (fromName == nullptr || toName == nullptr) return;
  636. AnimationStateData *_stateData = (AnimationStateData *) stateData;
  637. _stateData->setMix(fromName, toName, duration);
  638. }
  639. float spine_animation_state_data_get_mix_by_name(spine_animation_state_data stateData, const utf8 *fromName, const utf8 *toName) {
  640. if (stateData == nullptr) return 0;
  641. AnimationStateData *_stateData = (AnimationStateData *) stateData;
  642. Animation *from = _stateData->getSkeletonData()->findAnimation(fromName);
  643. Animation *to = _stateData->getSkeletonData()->findAnimation(toName);
  644. if (from == nullptr || to == nullptr) return 0;
  645. return _stateData->getMix(from, to);
  646. }
  647. void spine_animation_state_data_clear(spine_animation_state_data stateData) {
  648. if (stateData == nullptr) return;
  649. AnimationStateData *_stateData = (AnimationStateData *) stateData;
  650. _stateData->clear();
  651. }
  652. // AnimationState
  653. void spine_animation_state_update(spine_animation_state state, float delta) {
  654. if (state == nullptr) return;
  655. AnimationState *_state = (AnimationState *) state;
  656. _state->update(delta);
  657. }
  658. void spine_animation_state_dispose_track_entry(spine_animation_state state, spine_track_entry entry) {
  659. if (state == nullptr) return;
  660. if (entry == nullptr) return;
  661. AnimationState *_state = (AnimationState *) state;
  662. _state->disposeTrackEntry((TrackEntry *) entry);
  663. }
  664. void spine_animation_state_apply(spine_animation_state state, spine_skeleton skeleton) {
  665. if (state == nullptr) return;
  666. AnimationState *_state = (AnimationState *) state;
  667. _state->apply(*(Skeleton *) skeleton);
  668. }
  669. void spine_animation_state_clear_tracks(spine_animation_state state) {
  670. if (state == nullptr) return;
  671. AnimationState *_state = (AnimationState *) state;
  672. _state->clearTracks();
  673. }
  674. int32_t spine_animation_state_get_num_tracks(spine_animation_state state) {
  675. if (state == nullptr) return 0;
  676. AnimationState *_state = (AnimationState *) state;
  677. return (int32_t) _state->getTracks().size();
  678. }
  679. void spine_animation_state_clear_track(spine_animation_state state, int32_t trackIndex) {
  680. if (state == nullptr) return;
  681. AnimationState *_state = (AnimationState *) state;
  682. _state->clearTrack(trackIndex);
  683. }
  684. spine_track_entry spine_animation_state_set_animation_by_name(spine_animation_state state, int32_t trackIndex, const utf8 *animationName, spine_bool loop) {
  685. if (state == nullptr) return nullptr;
  686. AnimationState *_state = (AnimationState *) state;
  687. return (spine_track_entry) _state->setAnimation(trackIndex, animationName, loop);
  688. }
  689. spine_track_entry spine_animation_state_set_animation(spine_animation_state state, int32_t trackIndex, spine_animation animation, spine_bool loop) {
  690. if (state == nullptr) return nullptr;
  691. AnimationState *_state = (AnimationState *) state;
  692. return (spine_track_entry) _state->setAnimation(trackIndex, (Animation *) animation, loop);
  693. }
  694. spine_track_entry spine_animation_state_add_animation_by_name(spine_animation_state state, int32_t trackIndex, const utf8 *animationName, spine_bool loop, float delay) {
  695. if (state == nullptr) return nullptr;
  696. AnimationState *_state = (AnimationState *) state;
  697. return (spine_track_entry) _state->addAnimation(trackIndex, animationName, loop, delay);
  698. }
  699. spine_track_entry spine_animation_state_add_animation(spine_animation_state state, int32_t trackIndex, spine_animation animation, spine_bool loop, float delay) {
  700. if (state == nullptr) return nullptr;
  701. AnimationState *_state = (AnimationState *) state;
  702. return (spine_track_entry) _state->addAnimation(trackIndex, (Animation *) animation, loop, delay);
  703. }
  704. spine_track_entry spine_animation_state_set_empty_animation(spine_animation_state state, int32_t trackIndex, float mixDuration) {
  705. if (state == nullptr) return nullptr;
  706. AnimationState *_state = (AnimationState *) state;
  707. return (spine_track_entry) _state->setEmptyAnimation(trackIndex, mixDuration);
  708. }
  709. spine_track_entry spine_animation_state_add_empty_animation(spine_animation_state state, int32_t trackIndex, float mixDuration, float delay) {
  710. if (state == nullptr) return nullptr;
  711. AnimationState *_state = (AnimationState *) state;
  712. return (spine_track_entry) _state->addEmptyAnimation(trackIndex, mixDuration, delay);
  713. }
  714. void spine_animation_state_set_empty_animations(spine_animation_state state, float mixDuration) {
  715. if (state == nullptr) return;
  716. AnimationState *_state = (AnimationState *) state;
  717. _state->setEmptyAnimations(mixDuration);
  718. }
  719. spine_track_entry spine_animation_state_get_current(spine_animation_state state, int32_t trackIndex) {
  720. if (state == nullptr) return nullptr;
  721. AnimationState *_state = (AnimationState *) state;
  722. return (spine_track_entry) _state->getCurrent(trackIndex);
  723. }
  724. spine_animation_state_data spine_animation_state_get_data(spine_animation_state state) {
  725. if (state == nullptr) return nullptr;
  726. AnimationState *_state = (AnimationState *) state;
  727. return (spine_animation_state_data) _state->getData();
  728. }
  729. float spine_animation_state_get_time_scale(spine_animation_state state) {
  730. if (state == nullptr) return 0;
  731. AnimationState *_state = (AnimationState *) state;
  732. return _state->getTimeScale();
  733. }
  734. void spine_animation_state_set_time_scale(spine_animation_state state, float timeScale) {
  735. if (state == nullptr) return;
  736. AnimationState *_state = (AnimationState *) state;
  737. _state->setTimeScale(timeScale);
  738. }
  739. int32_t spine_animation_state_events_get_num_events(spine_animation_state_events events) {
  740. if (events == nullptr) return 0;
  741. EventListener *_events = (EventListener *) events;
  742. return (int32_t) _events->events.size();
  743. }
  744. spine_event_type spine_animation_state_events_get_event_type(spine_animation_state_events events, int32_t index) {
  745. if (events == nullptr) return SPINE_EVENT_TYPE_DISPOSE;
  746. if (index < 0) return SPINE_EVENT_TYPE_DISPOSE;
  747. EventListener *_events = (EventListener *) events;
  748. if (index >= (int) _events->events.size()) return SPINE_EVENT_TYPE_DISPOSE;
  749. return (spine_event_type) _events->events[index].type;
  750. }
  751. spine_track_entry spine_animation_state_events_get_track_entry(spine_animation_state_events events, int32_t index) {
  752. if (events == nullptr) return nullptr;
  753. EventListener *_events = (EventListener *) events;
  754. if (index >= (int) _events->events.size()) return nullptr;
  755. return (spine_track_entry) _events->events[index].entry;
  756. }
  757. spine_event spine_animation_state_events_get_event(spine_animation_state_events events, int32_t index) {
  758. if (events == nullptr) return nullptr;
  759. EventListener *_events = (EventListener *) events;
  760. if (index >= (int) _events->events.size()) return nullptr;
  761. return (spine_event) _events->events[index].event;
  762. }
  763. void spine_animation_state_events_reset(spine_animation_state_events events) {
  764. if (events == nullptr) return;
  765. EventListener *_events = (EventListener *) events;
  766. _events->events.clear();
  767. }
  768. // TrackEntry
  769. int32_t spine_track_entry_get_track_index(spine_track_entry entry) {
  770. if (entry == nullptr) return 0;
  771. TrackEntry *_entry = (TrackEntry *) entry;
  772. return _entry->getTrackIndex();
  773. }
  774. spine_animation spine_track_entry_get_animation(spine_track_entry entry) {
  775. if (entry == nullptr) return nullptr;
  776. TrackEntry *_entry = (TrackEntry *) entry;
  777. return (spine_animation) _entry->getAnimation();
  778. }
  779. spine_track_entry spine_track_entry_get_previous(spine_track_entry entry) {
  780. if (entry == nullptr) return nullptr;
  781. TrackEntry *_entry = (TrackEntry *) entry;
  782. return (spine_track_entry) _entry->getPrevious();
  783. }
  784. spine_bool spine_track_entry_get_loop(spine_track_entry entry) {
  785. if (entry == nullptr) return 0;
  786. TrackEntry *_entry = (TrackEntry *) entry;
  787. return _entry->getLoop() ? -1 : 0;
  788. }
  789. void spine_track_entry_set_loop(spine_track_entry entry, spine_bool loop) {
  790. if (entry == nullptr) return;
  791. TrackEntry *_entry = (TrackEntry *) entry;
  792. _entry->setLoop(loop);
  793. }
  794. spine_bool spine_track_entry_get_hold_previous(spine_track_entry entry) {
  795. if (entry == nullptr) return 0;
  796. TrackEntry *_entry = (TrackEntry *) entry;
  797. return _entry->getHoldPrevious() ? -1 : 0;
  798. }
  799. void spine_track_entry_set_hold_previous(spine_track_entry entry, spine_bool holdPrevious) {
  800. if (entry == nullptr) return;
  801. TrackEntry *_entry = (TrackEntry *) entry;
  802. _entry->setHoldPrevious(holdPrevious);
  803. }
  804. spine_bool spine_track_entry_get_reverse(spine_track_entry entry) {
  805. if (entry == nullptr) return 0;
  806. TrackEntry *_entry = (TrackEntry *) entry;
  807. return _entry->getReverse() ? -1 : 0;
  808. }
  809. void spine_track_entry_set_reverse(spine_track_entry entry, spine_bool reverse) {
  810. if (entry == nullptr) return;
  811. TrackEntry *_entry = (TrackEntry *) entry;
  812. _entry->setReverse(reverse);
  813. }
  814. spine_bool spine_track_entry_get_shortest_rotation(spine_track_entry entry) {
  815. if (entry == nullptr) return 0;
  816. TrackEntry *_entry = (TrackEntry *) entry;
  817. return _entry->getShortestRotation() ? -1 : 0;
  818. }
  819. void spine_track_entry_set_shortest_rotation(spine_track_entry entry, spine_bool shortestRotation) {
  820. if (entry == nullptr) return;
  821. TrackEntry *_entry = (TrackEntry *) entry;
  822. _entry->setShortestRotation(shortestRotation);
  823. }
  824. float spine_track_entry_get_delay(spine_track_entry entry) {
  825. if (entry == nullptr) return 0;
  826. TrackEntry *_entry = (TrackEntry *) entry;
  827. return _entry->getDelay();
  828. }
  829. void spine_track_entry_set_delay(spine_track_entry entry, float delay) {
  830. if (entry == nullptr) return;
  831. TrackEntry *_entry = (TrackEntry *) entry;
  832. _entry->setDelay(delay);
  833. }
  834. float spine_track_entry_get_track_time(spine_track_entry entry) {
  835. if (entry == nullptr) return 0;
  836. TrackEntry *_entry = (TrackEntry *) entry;
  837. return _entry->getTrackTime();
  838. }
  839. void spine_track_entry_set_track_time(spine_track_entry entry, float trackTime) {
  840. if (entry == nullptr) return;
  841. TrackEntry *_entry = (TrackEntry *) entry;
  842. _entry->setTrackTime(trackTime);
  843. }
  844. float spine_track_entry_get_track_end(spine_track_entry entry) {
  845. if (entry == nullptr) return 0;
  846. TrackEntry *_entry = (TrackEntry *) entry;
  847. return _entry->getTrackEnd();
  848. }
  849. void spine_track_entry_set_track_end(spine_track_entry entry, float trackEnd) {
  850. if (entry == nullptr) return;
  851. TrackEntry *_entry = (TrackEntry *) entry;
  852. _entry->setTrackEnd(trackEnd);
  853. }
  854. float spine_track_entry_get_animation_start(spine_track_entry entry) {
  855. if (entry == nullptr) return 0;
  856. TrackEntry *_entry = (TrackEntry *) entry;
  857. return _entry->getAnimationStart();
  858. }
  859. void spine_track_entry_set_animation_start(spine_track_entry entry, float animationStart) {
  860. if (entry == nullptr) return;
  861. TrackEntry *_entry = (TrackEntry *) entry;
  862. _entry->setAnimationStart(animationStart);
  863. }
  864. float spine_track_entry_get_animation_end(spine_track_entry entry) {
  865. if (entry == nullptr) return 0;
  866. TrackEntry *_entry = (TrackEntry *) entry;
  867. return _entry->getAnimationEnd();
  868. }
  869. void spine_track_entry_set_animation_end(spine_track_entry entry, float animationEnd) {
  870. if (entry == nullptr) return;
  871. TrackEntry *_entry = (TrackEntry *) entry;
  872. _entry->setAnimationEnd(animationEnd);
  873. }
  874. float spine_track_entry_get_animation_last(spine_track_entry entry) {
  875. if (entry == nullptr) return 0;
  876. TrackEntry *_entry = (TrackEntry *) entry;
  877. return _entry->getAnimationLast();
  878. }
  879. void spine_track_entry_set_animation_last(spine_track_entry entry, float animationLast) {
  880. if (entry == nullptr) return;
  881. TrackEntry *_entry = (TrackEntry *) entry;
  882. _entry->setAnimationLast(animationLast);
  883. }
  884. float spine_track_entry_get_animation_time(spine_track_entry entry) {
  885. if (entry == nullptr) return 0;
  886. TrackEntry *_entry = (TrackEntry *) entry;
  887. return _entry->getAnimationTime();
  888. }
  889. float spine_track_entry_get_time_scale(spine_track_entry entry) {
  890. if (entry == nullptr) return 0;
  891. TrackEntry *_entry = (TrackEntry *) entry;
  892. return _entry->getTimeScale();
  893. }
  894. void spine_track_entry_set_time_scale(spine_track_entry entry, float timeScale) {
  895. if (entry == nullptr) return;
  896. TrackEntry *_entry = (TrackEntry *) entry;
  897. _entry->setTimeScale(timeScale);
  898. }
  899. float spine_track_entry_get_alpha(spine_track_entry entry) {
  900. if (entry == nullptr) return 0;
  901. TrackEntry *_entry = (TrackEntry *) entry;
  902. return _entry->getAlpha();
  903. }
  904. void spine_track_entry_set_alpha(spine_track_entry entry, float alpha) {
  905. if (entry == nullptr) return;
  906. TrackEntry *_entry = (TrackEntry *) entry;
  907. _entry->setAlpha(alpha);
  908. }
  909. float spine_track_entry_get_event_threshold(spine_track_entry entry) {
  910. if (entry == nullptr) return 0;
  911. TrackEntry *_entry = (TrackEntry *) entry;
  912. return _entry->getEventThreshold();
  913. }
  914. void spine_track_entry_set_event_threshold(spine_track_entry entry, float eventThreshold) {
  915. if (entry == nullptr) return;
  916. TrackEntry *_entry = (TrackEntry *) entry;
  917. _entry->setEventThreshold(eventThreshold);
  918. }
  919. float spine_track_entry_get_alpha_attachment_threshold(spine_track_entry entry) {
  920. if (entry == nullptr) return 0;
  921. TrackEntry *_entry = (TrackEntry *) entry;
  922. return _entry->getAlphaAttachmentThreshold();
  923. }
  924. void spine_track_entry_set_alpha_attachment_threshold(spine_track_entry entry, float attachmentThreshold) {
  925. if (entry == nullptr) return;
  926. TrackEntry *_entry = (TrackEntry *) entry;
  927. _entry->setAlphaAttachmentThreshold(attachmentThreshold);
  928. }
  929. float spine_track_entry_get_mix_attachment_threshold(spine_track_entry entry) {
  930. if (entry == nullptr) return 0;
  931. TrackEntry *_entry = (TrackEntry *) entry;
  932. return _entry->getMixAttachmentThreshold();
  933. }
  934. void spine_track_entry_set_mix_attachment_threshold(spine_track_entry entry, float attachmentThreshold) {
  935. if (entry == nullptr) return;
  936. TrackEntry *_entry = (TrackEntry *) entry;
  937. _entry->setMixAttachmentThreshold(attachmentThreshold);
  938. }
  939. float spine_track_entry_get_mix_draw_order_threshold(spine_track_entry entry) {
  940. if (entry == nullptr) return 0;
  941. TrackEntry *_entry = (TrackEntry *) entry;
  942. return _entry->getMixDrawOrderThreshold();
  943. }
  944. void spine_track_entry_set_mix_draw_order_threshold(spine_track_entry entry, float drawOrderThreshold) {
  945. if (entry == nullptr) return;
  946. TrackEntry *_entry = (TrackEntry *) entry;
  947. _entry->setMixDrawOrderThreshold(drawOrderThreshold);
  948. }
  949. spine_track_entry spine_track_entry_get_next(spine_track_entry entry) {
  950. if (entry == nullptr) return nullptr;
  951. TrackEntry *_entry = (TrackEntry *) entry;
  952. return (spine_track_entry) _entry->getNext();
  953. }
  954. spine_bool spine_track_entry_is_complete(spine_track_entry entry) {
  955. if (entry == nullptr) return 0;
  956. TrackEntry *_entry = (TrackEntry *) entry;
  957. return _entry->isComplete() ? -1 : 0;
  958. }
  959. float spine_track_entry_get_mix_time(spine_track_entry entry) {
  960. if (entry == nullptr) return 0;
  961. TrackEntry *_entry = (TrackEntry *) entry;
  962. return _entry->getMixTime();
  963. }
  964. void spine_track_entry_set_mix_time(spine_track_entry entry, float mixTime) {
  965. if (entry == nullptr) return;
  966. TrackEntry *_entry = (TrackEntry *) entry;
  967. _entry->setMixTime(mixTime);
  968. }
  969. float spine_track_entry_get_mix_duration(spine_track_entry entry) {
  970. if (entry == nullptr) return 0;
  971. TrackEntry *_entry = (TrackEntry *) entry;
  972. return _entry->getMixDuration();
  973. }
  974. void spine_track_entry_set_mix_duration(spine_track_entry entry, float mixDuration) {
  975. if (entry == nullptr) return;
  976. TrackEntry *_entry = (TrackEntry *) entry;
  977. _entry->setMixDuration(mixDuration);
  978. }
  979. spine_mix_blend spine_track_entry_get_mix_blend(spine_track_entry entry) {
  980. if (entry == nullptr) return SPINE_MIX_BLEND_SETUP;
  981. TrackEntry *_entry = (TrackEntry *) entry;
  982. return (spine_mix_blend) _entry->getMixBlend();
  983. }
  984. void spine_track_entry_set_mix_blend(spine_track_entry entry, spine_mix_blend mixBlend) {
  985. if (entry == nullptr) return;
  986. TrackEntry *_entry = (TrackEntry *) entry;
  987. _entry->setMixBlend((MixBlend) mixBlend);
  988. }
  989. spine_track_entry spine_track_entry_get_mixing_from(spine_track_entry entry) {
  990. if (entry == nullptr) return nullptr;
  991. TrackEntry *_entry = (TrackEntry *) entry;
  992. return (spine_track_entry) _entry->getMixingFrom();
  993. }
  994. spine_track_entry spine_track_entry_get_mixing_to(spine_track_entry entry) {
  995. if (entry == nullptr) return nullptr;
  996. TrackEntry *_entry = (TrackEntry *) entry;
  997. return (spine_track_entry) _entry->getMixingTo();
  998. }
  999. void spine_track_entry_reset_rotation_directions(spine_track_entry entry) {
  1000. if (entry == nullptr) return;
  1001. TrackEntry *_entry = (TrackEntry *) entry;
  1002. _entry->resetRotationDirections();
  1003. }
  1004. float spine_track_entry_get_track_complete(spine_track_entry entry) {
  1005. if (entry == nullptr) return 0;
  1006. TrackEntry *_entry = (TrackEntry *) entry;
  1007. return _entry->getTrackComplete();
  1008. }
  1009. spine_bool spine_track_entry_was_applied(spine_track_entry entry) {
  1010. if (entry == nullptr) return false;
  1011. TrackEntry *_entry = (TrackEntry *) entry;
  1012. return _entry->wasApplied();
  1013. }
  1014. spine_bool spine_track_entry_is_next_ready(spine_track_entry entry) {
  1015. if (entry == nullptr) return false;
  1016. TrackEntry *_entry = (TrackEntry *) entry;
  1017. return _entry->isNextReady();
  1018. }
  1019. // Skeleton
  1020. void spine_skeleton_update_cache(spine_skeleton skeleton) {
  1021. if (skeleton == nullptr) return;
  1022. Skeleton *_skeleton = (Skeleton *) skeleton;
  1023. _skeleton->updateCache();
  1024. }
  1025. void spine_skeleton_update_world_transform(spine_skeleton skeleton, spine_physics physics) {
  1026. if (skeleton == nullptr) return;
  1027. Skeleton *_skeleton = (Skeleton *) skeleton;
  1028. _skeleton->updateWorldTransform((spine::Physics) physics);
  1029. }
  1030. void spine_skeleton_update_world_transform_bone(spine_skeleton skeleton, spine_physics physics, spine_bone parent) {
  1031. if (skeleton == nullptr) return;
  1032. if (parent == nullptr) return;
  1033. Skeleton *_skeleton = (Skeleton *) skeleton;
  1034. Bone *_bone = (Bone *) parent;
  1035. _skeleton->updateWorldTransform((spine::Physics) physics, _bone);
  1036. }
  1037. void spine_skeleton_set_to_setup_pose(spine_skeleton skeleton) {
  1038. if (skeleton == nullptr) return;
  1039. Skeleton *_skeleton = (Skeleton *) skeleton;
  1040. _skeleton->setToSetupPose();
  1041. }
  1042. void spine_skeleton_set_bones_to_setup_pose(spine_skeleton skeleton) {
  1043. if (skeleton == nullptr) return;
  1044. Skeleton *_skeleton = (Skeleton *) skeleton;
  1045. _skeleton->setBonesToSetupPose();
  1046. }
  1047. void spine_skeleton_set_slots_to_setup_pose(spine_skeleton skeleton) {
  1048. if (skeleton == nullptr) return;
  1049. Skeleton *_skeleton = (Skeleton *) skeleton;
  1050. _skeleton->setSlotsToSetupPose();
  1051. }
  1052. spine_bone spine_skeleton_find_bone(spine_skeleton skeleton, const utf8 *boneName) {
  1053. if (skeleton == nullptr) return nullptr;
  1054. Skeleton *_skeleton = (Skeleton *) skeleton;
  1055. return (spine_bone) _skeleton->findBone(boneName);
  1056. }
  1057. spine_slot spine_skeleton_find_slot(spine_skeleton skeleton, const utf8 *slotName) {
  1058. if (skeleton == nullptr) return nullptr;
  1059. Skeleton *_skeleton = (Skeleton *) skeleton;
  1060. return (spine_slot) _skeleton->findSlot(slotName);
  1061. }
  1062. void spine_skeleton_set_skin_by_name(spine_skeleton skeleton, const utf8 *skinName) {
  1063. if (skeleton == nullptr) return;
  1064. Skeleton *_skeleton = (Skeleton *) skeleton;
  1065. _skeleton->setSkin(skinName);
  1066. }
  1067. void spine_skeleton_set_skin(spine_skeleton skeleton, spine_skin skin) {
  1068. if (skeleton == nullptr) return;
  1069. if (skin == nullptr) return;
  1070. Skeleton *_skeleton = (Skeleton *) skeleton;
  1071. _skeleton->setSkin((Skin *) skin);
  1072. }
  1073. spine_attachment spine_skeleton_get_attachment_by_name(spine_skeleton skeleton, const utf8 *slotName, const utf8 *attachmentName) {
  1074. if (skeleton == nullptr) return nullptr;
  1075. Skeleton *_skeleton = (Skeleton *) skeleton;
  1076. return (spine_attachment) _skeleton->getAttachment(slotName, attachmentName);
  1077. }
  1078. spine_attachment spine_skeleton_get_attachment(spine_skeleton skeleton, int32_t slotIndex, const utf8 *attachmentName) {
  1079. if (skeleton == nullptr) return nullptr;
  1080. Skeleton *_skeleton = (Skeleton *) skeleton;
  1081. return (spine_attachment) _skeleton->getAttachment(slotIndex, attachmentName);
  1082. }
  1083. void spine_skeleton_set_attachment(spine_skeleton skeleton, const utf8 *slotName, const utf8 *attachmentName) {
  1084. if (skeleton == nullptr) return;
  1085. Skeleton *_skeleton = (Skeleton *) skeleton;
  1086. return _skeleton->setAttachment(slotName, attachmentName);
  1087. }
  1088. spine_ik_constraint spine_skeleton_find_ik_constraint(spine_skeleton skeleton, const utf8 *constraintName) {
  1089. if (skeleton == nullptr) return nullptr;
  1090. Skeleton *_skeleton = (Skeleton *) skeleton;
  1091. return (spine_ik_constraint) _skeleton->findIkConstraint(constraintName);
  1092. }
  1093. spine_transform_constraint spine_skeleton_find_transform_constraint(spine_skeleton skeleton, const utf8 *constraintName) {
  1094. if (skeleton == nullptr) return nullptr;
  1095. Skeleton *_skeleton = (Skeleton *) skeleton;
  1096. return (spine_transform_constraint) _skeleton->findTransformConstraint(constraintName);
  1097. }
  1098. spine_path_constraint spine_skeleton_find_path_constraint(spine_skeleton skeleton, const utf8 *constraintName) {
  1099. if (skeleton == nullptr) return nullptr;
  1100. Skeleton *_skeleton = (Skeleton *) skeleton;
  1101. return (spine_path_constraint) _skeleton->findPathConstraint(constraintName);
  1102. }
  1103. spine_physics_constraint spine_skeleton_find_physics_constraint(spine_skeleton skeleton, const utf8 *constraintName) {
  1104. if (skeleton == nullptr) return nullptr;
  1105. Skeleton *_skeleton = (Skeleton *) skeleton;
  1106. return (spine_physics_constraint) _skeleton->findPhysicsConstraint(constraintName);
  1107. }
  1108. _spine_bounds tmp_bounds;
  1109. spine_bounds spine_skeleton_get_bounds(spine_skeleton skeleton) {
  1110. _spine_bounds *bounds = &tmp_bounds;
  1111. if (skeleton == nullptr) return (spine_bounds) bounds;
  1112. Skeleton *_skeleton = (Skeleton *) skeleton;
  1113. Vector<float> vertices;
  1114. SkeletonClipping clipper;
  1115. _skeleton->getBounds(bounds->x, bounds->y, bounds->width, bounds->height, vertices, &clipper);
  1116. return (spine_bounds) bounds;
  1117. }
  1118. spine_bone spine_skeleton_get_root_bone(spine_skeleton skeleton) {
  1119. if (skeleton == nullptr) return nullptr;
  1120. Skeleton *_skeleton = (Skeleton *) skeleton;
  1121. return (spine_bone) _skeleton->getRootBone();
  1122. }
  1123. spine_skeleton_data spine_skeleton_get_data(spine_skeleton skeleton) {
  1124. if (skeleton == nullptr) return nullptr;
  1125. Skeleton *_skeleton = (Skeleton *) skeleton;
  1126. return (spine_skeleton_data) _skeleton->getData();
  1127. }
  1128. int32_t spine_skeleton_get_num_bones(spine_skeleton skeleton) {
  1129. if (skeleton == nullptr) return 0;
  1130. Skeleton *_skeleton = (Skeleton *) skeleton;
  1131. return (int32_t) _skeleton->getBones().size();
  1132. }
  1133. spine_bone *spine_skeleton_get_bones(spine_skeleton skeleton) {
  1134. if (skeleton == nullptr) return nullptr;
  1135. Skeleton *_skeleton = (Skeleton *) skeleton;
  1136. return (spine_bone *) _skeleton->getBones().buffer();
  1137. }
  1138. int32_t spine_skeleton_get_num_slots(spine_skeleton skeleton) {
  1139. if (skeleton == nullptr) return 0;
  1140. Skeleton *_skeleton = (Skeleton *) skeleton;
  1141. return (int32_t) _skeleton->getSlots().size();
  1142. }
  1143. spine_slot *spine_skeleton_get_slots(spine_skeleton skeleton) {
  1144. if (skeleton == nullptr) return nullptr;
  1145. Skeleton *_skeleton = (Skeleton *) skeleton;
  1146. return (spine_slot *) _skeleton->getSlots().buffer();
  1147. }
  1148. int32_t spine_skeleton_get_num_draw_order(spine_skeleton skeleton) {
  1149. if (skeleton == nullptr) return 0;
  1150. Skeleton *_skeleton = (Skeleton *) skeleton;
  1151. return (int32_t) _skeleton->getDrawOrder().size();
  1152. }
  1153. spine_slot *spine_skeleton_get_draw_order(spine_skeleton skeleton) {
  1154. if (skeleton == nullptr) return nullptr;
  1155. Skeleton *_skeleton = (Skeleton *) skeleton;
  1156. return (spine_slot *) _skeleton->getDrawOrder().buffer();
  1157. }
  1158. int32_t spine_skeleton_get_num_ik_constraints(spine_skeleton skeleton) {
  1159. if (skeleton == nullptr) return 0;
  1160. Skeleton *_skeleton = (Skeleton *) skeleton;
  1161. return (int32_t) _skeleton->getIkConstraints().size();
  1162. }
  1163. spine_ik_constraint *spine_skeleton_get_ik_constraints(spine_skeleton skeleton) {
  1164. if (skeleton == nullptr) return nullptr;
  1165. Skeleton *_skeleton = (Skeleton *) skeleton;
  1166. return (spine_ik_constraint *) _skeleton->getIkConstraints().buffer();
  1167. }
  1168. int32_t spine_skeleton_get_num_transform_constraints(spine_skeleton skeleton) {
  1169. if (skeleton == nullptr) return 0;
  1170. Skeleton *_skeleton = (Skeleton *) skeleton;
  1171. return (int32_t) _skeleton->getTransformConstraints().size();
  1172. }
  1173. spine_transform_constraint *spine_skeleton_get_transform_constraints(spine_skeleton skeleton) {
  1174. if (skeleton == nullptr) return nullptr;
  1175. Skeleton *_skeleton = (Skeleton *) skeleton;
  1176. return (spine_transform_constraint *) _skeleton->getTransformConstraints().buffer();
  1177. }
  1178. int32_t spine_skeleton_get_num_path_constraints(spine_skeleton skeleton) {
  1179. if (skeleton == nullptr) return 0;
  1180. Skeleton *_skeleton = (Skeleton *) skeleton;
  1181. return (int32_t) _skeleton->getPathConstraints().size();
  1182. }
  1183. spine_path_constraint *spine_skeleton_get_path_constraints(spine_skeleton skeleton) {
  1184. if (skeleton == nullptr) return nullptr;
  1185. Skeleton *_skeleton = (Skeleton *) skeleton;
  1186. return (spine_path_constraint *) _skeleton->getPathConstraints().buffer();
  1187. }
  1188. int32_t spine_skeleton_get_num_physics_constraints(spine_skeleton skeleton) {
  1189. if (skeleton == nullptr) return 0;
  1190. Skeleton *_skeleton = (Skeleton *) skeleton;
  1191. return (int32_t) _skeleton->getPhysicsConstraints().size();
  1192. }
  1193. spine_physics_constraint *spine_skeleton_get_physics_constraints(spine_skeleton skeleton) {
  1194. if (skeleton == nullptr) return nullptr;
  1195. Skeleton *_skeleton = (Skeleton *) skeleton;
  1196. return (spine_physics_constraint *) _skeleton->getPhysicsConstraints().buffer();
  1197. }
  1198. spine_skin spine_skeleton_get_skin(spine_skeleton skeleton) {
  1199. if (skeleton == nullptr) return nullptr;
  1200. Skeleton *_skeleton = (Skeleton *) skeleton;
  1201. return (spine_skin) _skeleton->getSkin();
  1202. }
  1203. spine_color spine_skeleton_get_color(spine_skeleton skeleton) {
  1204. if (skeleton == nullptr) return (spine_color) &NULL_COLOR;
  1205. Skeleton *_skeleton = (Skeleton *) skeleton;
  1206. return (spine_color) &_skeleton->getColor();
  1207. }
  1208. void spine_skeleton_set_color(spine_skeleton skeleton, float r, float g, float b, float a) {
  1209. if (skeleton == nullptr) return;
  1210. Skeleton *_skeleton = (Skeleton *) skeleton;
  1211. _skeleton->getColor().set(r, g, b, a);
  1212. }
  1213. void spine_skeleton_set_position(spine_skeleton skeleton, float x, float y) {
  1214. if (skeleton == nullptr) return;
  1215. Skeleton *_skeleton = (Skeleton *) skeleton;
  1216. _skeleton->setPosition(x, y);
  1217. }
  1218. float spine_skeleton_get_x(spine_skeleton skeleton) {
  1219. if (skeleton == nullptr) return 0;
  1220. Skeleton *_skeleton = (Skeleton *) skeleton;
  1221. return _skeleton->getX();
  1222. }
  1223. void spine_skeleton_set_x(spine_skeleton skeleton, float x) {
  1224. if (skeleton == nullptr) return;
  1225. Skeleton *_skeleton = (Skeleton *) skeleton;
  1226. _skeleton->setX(x);
  1227. }
  1228. float spine_skeleton_get_y(spine_skeleton skeleton) {
  1229. if (skeleton == nullptr) return 0;
  1230. Skeleton *_skeleton = (Skeleton *) skeleton;
  1231. return _skeleton->getY();
  1232. }
  1233. void spine_skeleton_set_y(spine_skeleton skeleton, float y) {
  1234. if (skeleton == nullptr) return;
  1235. Skeleton *_skeleton = (Skeleton *) skeleton;
  1236. _skeleton->setY(y);
  1237. }
  1238. void spine_skeleton_set_scale(spine_skeleton skeleton, float scaleX, float scaleY) {
  1239. if (skeleton == nullptr) return;
  1240. Skeleton *_skeleton = (Skeleton *) skeleton;
  1241. _skeleton->setScaleX(scaleX);
  1242. _skeleton->setScaleY(scaleY);
  1243. }
  1244. float spine_skeleton_get_scale_x(spine_skeleton skeleton) {
  1245. if (skeleton == nullptr) return 0;
  1246. Skeleton *_skeleton = (Skeleton *) skeleton;
  1247. return _skeleton->getScaleX();
  1248. }
  1249. void spine_skeleton_set_scale_x(spine_skeleton skeleton, float scaleX) {
  1250. if (skeleton == nullptr) return;
  1251. Skeleton *_skeleton = (Skeleton *) skeleton;
  1252. _skeleton->setScaleX(scaleX);
  1253. }
  1254. float spine_skeleton_get_scale_y(spine_skeleton skeleton) {
  1255. if (skeleton == nullptr) return 0;
  1256. Skeleton *_skeleton = (Skeleton *) skeleton;
  1257. return _skeleton->getScaleY();
  1258. }
  1259. void spine_skeleton_set_scale_y(spine_skeleton skeleton, float scaleY) {
  1260. if (skeleton == nullptr) return;
  1261. Skeleton *_skeleton = (Skeleton *) skeleton;
  1262. _skeleton->setScaleY(scaleY);
  1263. }
  1264. float spine_skeleton_get_time(spine_skeleton skeleton) {
  1265. if (skeleton == nullptr) return 0;
  1266. Skeleton *_skeleton = (Skeleton *) skeleton;
  1267. return _skeleton->getTime();
  1268. }
  1269. void spine_skeleton_set_time(spine_skeleton skeleton, float time) {
  1270. if (skeleton == nullptr) return;
  1271. Skeleton *_skeleton = (Skeleton *) skeleton;
  1272. _skeleton->setTime(time);
  1273. }
  1274. void spine_skeleton_update(spine_skeleton skeleton, float delta) {
  1275. if (skeleton == nullptr) return;
  1276. Skeleton *_skeleton = (Skeleton *) skeleton;
  1277. _skeleton->update(delta);
  1278. }
  1279. // EventData
  1280. const utf8 *spine_event_data_get_name(spine_event_data event) {
  1281. if (event == nullptr) return nullptr;
  1282. EventData *_event = (EventData *) event;
  1283. return (utf8 *) _event->getName().buffer();
  1284. }
  1285. int32_t spine_event_data_get_int_value(spine_event_data event) {
  1286. if (event == nullptr) return 0;
  1287. EventData *_event = (EventData *) event;
  1288. return _event->getIntValue();
  1289. }
  1290. void spine_event_data_set_int_value(spine_event_data event, int32_t value) {
  1291. if (event == nullptr) return;
  1292. EventData *_event = (EventData *) event;
  1293. _event->setIntValue(value);
  1294. }
  1295. float spine_event_data_get_float_value(spine_event_data event) {
  1296. if (event == nullptr) return 0;
  1297. EventData *_event = (EventData *) event;
  1298. return _event->getFloatValue();
  1299. }
  1300. void spine_event_data_set_float_value(spine_event_data event, float value) {
  1301. if (event == nullptr) return;
  1302. EventData *_event = (EventData *) event;
  1303. _event->setFloatValue(value);
  1304. }
  1305. const utf8 *spine_event_data_get_string_value(spine_event_data event) {
  1306. if (event == nullptr) return nullptr;
  1307. EventData *_event = (EventData *) event;
  1308. return (utf8 *) _event->getStringValue().buffer();
  1309. }
  1310. void spine_event_data_set_string_value(spine_event_data event, const utf8 *value) {
  1311. if (event == nullptr) return;
  1312. EventData *_event = (EventData *) event;
  1313. _event->setStringValue(value);
  1314. }
  1315. const utf8 *spine_event_data_get_audio_path(spine_event_data event) {
  1316. if (event == nullptr) return nullptr;
  1317. EventData *_event = (EventData *) event;
  1318. return (utf8 *) _event->getAudioPath().buffer();
  1319. }
  1320. float spine_event_data_get_volume(spine_event_data event) {
  1321. if (event == nullptr) return 0;
  1322. EventData *_event = (EventData *) event;
  1323. return _event->getVolume();
  1324. }
  1325. void spine_event_data_set_volume(spine_event_data event, float volume) {
  1326. if (event == nullptr) return;
  1327. EventData *_event = (EventData *) event;
  1328. _event->setVolume(volume);
  1329. }
  1330. float spine_event_data_get_balance(spine_event_data event) {
  1331. if (event == nullptr) return 0;
  1332. EventData *_event = (EventData *) event;
  1333. return _event->getBalance();
  1334. }
  1335. void spine_event_data_set_balance(spine_event_data event, float balance) {
  1336. if (event == nullptr) return;
  1337. EventData *_event = (EventData *) event;
  1338. _event->setBalance(balance);
  1339. }
  1340. // Event
  1341. spine_event_data spine_event_get_data(spine_event event) {
  1342. if (event == nullptr) return nullptr;
  1343. Event *_event = (Event *) event;
  1344. return (spine_event_data) &_event->getData();
  1345. }
  1346. float spine_event_get_time(spine_event event) {
  1347. if (event == nullptr) return 0;
  1348. Event *_event = (Event *) event;
  1349. return _event->getTime();
  1350. }
  1351. int32_t spine_event_get_int_value(spine_event event) {
  1352. if (event == nullptr) return 0;
  1353. Event *_event = (Event *) event;
  1354. return _event->getIntValue();
  1355. }
  1356. void spine_event_set_int_value(spine_event event, int32_t value) {
  1357. if (event == nullptr) return;
  1358. Event *_event = (Event *) event;
  1359. _event->setIntValue(value);
  1360. }
  1361. float spine_event_get_float_value(spine_event event) {
  1362. if (event == nullptr) return 0;
  1363. Event *_event = (Event *) event;
  1364. return _event->getFloatValue();
  1365. }
  1366. void spine_event_set_float_value(spine_event event, float value) {
  1367. if (event == nullptr) return;
  1368. Event *_event = (Event *) event;
  1369. _event->setFloatValue(value);
  1370. }
  1371. const utf8 *spine_event_get_string_value(spine_event event) {
  1372. if (event == nullptr) return nullptr;
  1373. Event *_event = (Event *) event;
  1374. return (utf8 *) _event->getStringValue().buffer();
  1375. }
  1376. void spine_event_set_string_value(spine_event event, const utf8 *value) {
  1377. if (event == nullptr) return;
  1378. Event *_event = (Event *) event;
  1379. _event->setStringValue(value);
  1380. }
  1381. float spine_event_get_volume(spine_event event) {
  1382. if (event == nullptr) return 0;
  1383. Event *_event = (Event *) event;
  1384. return _event->getVolume();
  1385. }
  1386. void spine_event_set_volume(spine_event event, float volume) {
  1387. if (event == nullptr) return;
  1388. Event *_event = (Event *) event;
  1389. _event->setVolume(volume);
  1390. }
  1391. float spine_event_get_balance(spine_event event) {
  1392. if (event == nullptr) return 0;
  1393. Event *_event = (Event *) event;
  1394. return _event->getBalance();
  1395. }
  1396. void spine_event_set_balance(spine_event event, float balance) {
  1397. if (event == nullptr) return;
  1398. Event *_event = (Event *) event;
  1399. _event->setBalance(balance);
  1400. }
  1401. // SlotData
  1402. int32_t spine_slot_data_get_index(spine_slot_data slot) {
  1403. if (slot == nullptr) return 0;
  1404. SlotData *_slot = (SlotData *) slot;
  1405. return _slot->getIndex();
  1406. }
  1407. const utf8 *spine_slot_data_get_name(spine_slot_data slot) {
  1408. if (slot == nullptr) return nullptr;
  1409. SlotData *_slot = (SlotData *) slot;
  1410. return (utf8 *) _slot->getName().buffer();
  1411. }
  1412. spine_bone_data spine_slot_data_get_bone_data(spine_slot_data slot) {
  1413. if (slot == nullptr) return nullptr;
  1414. SlotData *_slot = (SlotData *) slot;
  1415. return (spine_bone_data) &_slot->getBoneData();
  1416. }
  1417. spine_color spine_slot_data_get_color(spine_slot_data slot) {
  1418. if (slot == nullptr) return (spine_color) &NULL_COLOR;
  1419. SlotData *_slot = (SlotData *) slot;
  1420. return (spine_color) &_slot->getColor();
  1421. }
  1422. void spine_slot_data_set_color(spine_slot_data slot, float r, float g, float b, float a) {
  1423. if (slot == nullptr) return;
  1424. SlotData *_slot = (SlotData *) slot;
  1425. _slot->getColor().set(r, g, b, a);
  1426. }
  1427. spine_color spine_slot_data_get_dark_color(spine_slot_data slot) {
  1428. if (slot == nullptr) return (spine_color) &NULL_COLOR;
  1429. SlotData *_slot = (SlotData *) slot;
  1430. return (spine_color) &_slot->getDarkColor();
  1431. }
  1432. void spine_slot_data_set_dark_color(spine_slot_data slot, float r, float g, float b, float a) {
  1433. if (slot == nullptr) return;
  1434. SlotData *_slot = (SlotData *) slot;
  1435. _slot->getDarkColor().set(r, g, b, a);
  1436. }
  1437. spine_bool spine_slot_data_get_has_dark_color(spine_slot_data slot) {
  1438. if (slot == nullptr) return 0;
  1439. SlotData *_slot = (SlotData *) slot;
  1440. return _slot->hasDarkColor() ? -1 : 0;
  1441. }
  1442. void spine_slot_data_set_has_dark_color(spine_slot_data slot, spine_bool hasDarkColor) {
  1443. if (slot == nullptr) return;
  1444. SlotData *_slot = (SlotData *) slot;
  1445. _slot->setHasDarkColor(hasDarkColor);
  1446. }
  1447. const utf8 *spine_slot_data_get_attachment_name(spine_slot_data slot) {
  1448. if (slot == nullptr) return nullptr;
  1449. SlotData *_slot = (SlotData *) slot;
  1450. return (utf8 *) _slot->getAttachmentName().buffer();
  1451. }
  1452. void spine_slot_data_set_attachment_name(spine_slot_data slot, const utf8 *attachmentName) {
  1453. if (slot == nullptr) return;
  1454. SlotData *_slot = (SlotData *) slot;
  1455. _slot->setAttachmentName(attachmentName);
  1456. }
  1457. spine_blend_mode spine_slot_data_get_blend_mode(spine_slot_data slot) {
  1458. if (slot == nullptr) return SPINE_BLEND_MODE_NORMAL;
  1459. SlotData *_slot = (SlotData *) slot;
  1460. return (spine_blend_mode) _slot->getBlendMode();
  1461. }
  1462. void spine_slot_data_set_blend_mode(spine_slot_data slot, spine_blend_mode blendMode) {
  1463. if (slot == nullptr) return;
  1464. SlotData *_slot = (SlotData *) slot;
  1465. _slot->setBlendMode((BlendMode) blendMode);
  1466. }
  1467. spine_bool spine_slot_data_is_visible(spine_slot_data slot) {
  1468. if (slot == nullptr) return false;
  1469. SlotData *_slot = (SlotData *) slot;
  1470. return _slot->isVisible();
  1471. }
  1472. void spine_slot_data_set_visible(spine_slot_data slot, spine_bool visible) {
  1473. if (slot == nullptr) return;
  1474. SlotData *_slot = (SlotData *) slot;
  1475. _slot->setVisible(visible);
  1476. }
  1477. // Slot
  1478. void spine_slot_set_to_setup_pose(spine_slot slot) {
  1479. if (slot == nullptr) return;
  1480. Slot *_slot = (Slot *) slot;
  1481. _slot->setToSetupPose();
  1482. }
  1483. spine_slot_data spine_slot_get_data(spine_slot slot) {
  1484. if (slot == nullptr) return nullptr;
  1485. Slot *_slot = (Slot *) slot;
  1486. return (spine_slot_data) &_slot->getData();
  1487. }
  1488. spine_bone spine_slot_get_bone(spine_slot slot) {
  1489. if (slot == nullptr) return nullptr;
  1490. Slot *_slot = (Slot *) slot;
  1491. return (spine_bone) &_slot->getBone();
  1492. }
  1493. spine_skeleton spine_slot_get_skeleton(spine_slot slot) {
  1494. if (slot == nullptr) return nullptr;
  1495. Slot *_slot = (Slot *) slot;
  1496. return (spine_skeleton) &_slot->getSkeleton();
  1497. }
  1498. spine_color spine_slot_get_color(spine_slot slot) {
  1499. if (slot == nullptr) return (spine_color) &NULL_COLOR;
  1500. Slot *_slot = (Slot *) slot;
  1501. return (spine_color) &_slot->getColor();
  1502. }
  1503. void spine_slot_set_color(spine_slot slot, float r, float g, float b, float a) {
  1504. if (slot == nullptr) return;
  1505. Slot *_slot = (Slot *) slot;
  1506. _slot->getColor().set(r, g, b, a);
  1507. }
  1508. spine_color spine_slot_get_dark_color(spine_slot slot) {
  1509. if (slot == nullptr) return (spine_color) &NULL_COLOR;
  1510. Slot *_slot = (Slot *) slot;
  1511. return (spine_color) &_slot->getDarkColor();
  1512. }
  1513. void spine_slot_set_dark_color(spine_slot slot, float r, float g, float b, float a) {
  1514. if (slot == nullptr) return;
  1515. Slot *_slot = (Slot *) slot;
  1516. _slot->getDarkColor().set(r, g, b, a);
  1517. }
  1518. spine_bool spine_slot_has_dark_color(spine_slot slot) {
  1519. if (slot == nullptr) return 0;
  1520. Slot *_slot = (Slot *) slot;
  1521. return _slot->hasDarkColor() ? -1 : 0;
  1522. }
  1523. spine_attachment spine_slot_get_attachment(spine_slot slot) {
  1524. if (slot == nullptr) return nullptr;
  1525. Slot *_slot = (Slot *) slot;
  1526. return (spine_attachment) _slot->getAttachment();
  1527. }
  1528. void spine_slot_set_attachment(spine_slot slot, spine_attachment attachment) {
  1529. if (slot == nullptr) return;
  1530. Slot *_slot = (Slot *) slot;
  1531. _slot->setAttachment((Attachment *) attachment);
  1532. }
  1533. int32_t spine_slot_get_sequence_index(spine_slot slot) {
  1534. if (slot == nullptr) return 0;
  1535. Slot *_slot = (Slot *) slot;
  1536. return _slot->getSequenceIndex();
  1537. }
  1538. void spine_slot_set_sequence_index(spine_slot slot, int32_t sequenceIndex) {
  1539. if (slot == nullptr) return;
  1540. Slot *_slot = (Slot *) slot;
  1541. _slot->setSequenceIndex(sequenceIndex);
  1542. }
  1543. // BoneData
  1544. int32_t spine_bone_data_get_index(spine_bone_data data) {
  1545. if (data == nullptr) return 0;
  1546. BoneData *_data = (BoneData *) data;
  1547. return _data->getIndex();
  1548. }
  1549. const utf8 *spine_bone_data_get_name(spine_bone_data data) {
  1550. if (data == nullptr) return nullptr;
  1551. BoneData *_data = (BoneData *) data;
  1552. return (utf8 *) _data->getName().buffer();
  1553. }
  1554. spine_bone_data spine_bone_data_get_parent(spine_bone_data data) {
  1555. if (data == nullptr) return nullptr;
  1556. BoneData *_data = (BoneData *) data;
  1557. return (spine_bone_data) _data->getParent();
  1558. }
  1559. float spine_bone_data_get_length(spine_bone_data data) {
  1560. if (data == nullptr) return 0;
  1561. BoneData *_data = (BoneData *) data;
  1562. return _data->getLength();
  1563. }
  1564. void spine_bone_data_set_length(spine_bone_data data, float length) {
  1565. if (data == nullptr) return;
  1566. BoneData *_data = (BoneData *) data;
  1567. _data->setLength(length);
  1568. }
  1569. float spine_bone_data_get_x(spine_bone_data data) {
  1570. if (data == nullptr) return 0;
  1571. BoneData *_data = (BoneData *) data;
  1572. return _data->getX();
  1573. }
  1574. void spine_bone_data_set_x(spine_bone_data data, float x) {
  1575. if (data == nullptr) return;
  1576. BoneData *_data = (BoneData *) data;
  1577. _data->setX(x);
  1578. }
  1579. float spine_bone_data_get_y(spine_bone_data data) {
  1580. if (data == nullptr) return 0;
  1581. BoneData *_data = (BoneData *) data;
  1582. return _data->getY();
  1583. }
  1584. void spine_bone_data_set_y(spine_bone_data data, float y) {
  1585. if (data == nullptr) return;
  1586. BoneData *_data = (BoneData *) data;
  1587. _data->setY(y);
  1588. }
  1589. float spine_bone_data_get_rotation(spine_bone_data data) {
  1590. if (data == nullptr) return 0;
  1591. BoneData *_data = (BoneData *) data;
  1592. return _data->getRotation();
  1593. }
  1594. void spine_bone_data_set_rotation(spine_bone_data data, float rotation) {
  1595. if (data == nullptr) return;
  1596. BoneData *_data = (BoneData *) data;
  1597. _data->setRotation(rotation);
  1598. }
  1599. float spine_bone_data_get_scale_x(spine_bone_data data) {
  1600. if (data == nullptr) return 0;
  1601. BoneData *_data = (BoneData *) data;
  1602. return _data->getScaleX();
  1603. }
  1604. void spine_bone_data_set_scale_x(spine_bone_data data, float scaleX) {
  1605. if (data == nullptr) return;
  1606. BoneData *_data = (BoneData *) data;
  1607. _data->setScaleX(scaleX);
  1608. }
  1609. float spine_bone_data_get_scale_y(spine_bone_data data) {
  1610. if (data == nullptr) return 0;
  1611. BoneData *_data = (BoneData *) data;
  1612. return _data->getScaleY();
  1613. }
  1614. void spine_bone_data_set_scale_y(spine_bone_data data, float scaleY) {
  1615. if (data == nullptr) return;
  1616. BoneData *_data = (BoneData *) data;
  1617. _data->setScaleY(scaleY);
  1618. }
  1619. float spine_bone_data_get_shear_x(spine_bone_data data) {
  1620. if (data == nullptr) return 0;
  1621. BoneData *_data = (BoneData *) data;
  1622. return _data->getShearX();
  1623. }
  1624. void spine_bone_data_set_shear_x(spine_bone_data data, float shearX) {
  1625. if (data == nullptr) return;
  1626. BoneData *_data = (BoneData *) data;
  1627. _data->setShearX(shearX);
  1628. }
  1629. float spine_bone_data_get_shear_y(spine_bone_data data) {
  1630. if (data == nullptr) return 0;
  1631. BoneData *_data = (BoneData *) data;
  1632. return _data->getShearY();
  1633. }
  1634. void spine_bone_data_set_shear_y(spine_bone_data data, float y) {
  1635. if (data == nullptr) return;
  1636. BoneData *_data = (BoneData *) data;
  1637. _data->setShearY(y);
  1638. }
  1639. spine_inherit spine_bone_data_get_inherit(spine_bone_data data) {
  1640. if (data == nullptr) return SPINE_INHERIT_NORMAL;
  1641. BoneData *_data = (BoneData *) data;
  1642. return (spine_inherit) _data->getInherit();
  1643. }
  1644. void spine_bone_data_set_inherit(spine_bone_data data, spine_inherit inherit) {
  1645. if (data == nullptr) return;
  1646. BoneData *_data = (BoneData *) data;
  1647. _data->setInherit((Inherit) inherit);
  1648. }
  1649. spine_bool spine_bone_data_get_is_skin_required(spine_bone_data data) {
  1650. if (data == nullptr) return 0;
  1651. BoneData *_data = (BoneData *) data;
  1652. return _data->isSkinRequired() ? -1 : 0;
  1653. }
  1654. void spine_bone_data_set_is_skin_required(spine_bone_data data, spine_bool isSkinRequired) {
  1655. if (data == nullptr) return;
  1656. BoneData *_data = (BoneData *) data;
  1657. _data->setSkinRequired(isSkinRequired);
  1658. }
  1659. spine_color spine_bone_data_get_color(spine_bone_data data) {
  1660. if (data == nullptr) return (spine_color) &NULL_COLOR;
  1661. BoneData *_data = (BoneData *) data;
  1662. return (spine_color) &_data->getColor();
  1663. }
  1664. void spine_bone_data_set_color(spine_bone_data data, float r, float g, float b, float a) {
  1665. if (data == nullptr) return;
  1666. BoneData *_data = (BoneData *) data;
  1667. _data->getColor().set(r, g, b, a);
  1668. }
  1669. spine_bool spine_bone_data_is_visible(spine_bone_data data) {
  1670. if (data == nullptr) return false;
  1671. BoneData *_data = (BoneData *) data;
  1672. return _data->isVisible();
  1673. }
  1674. void spine_bone_data_set_visible(spine_bone_data data, spine_bool isVisible) {
  1675. if (data == nullptr) return;
  1676. BoneData *_data = (BoneData *) data;
  1677. _data->setVisible(isVisible);
  1678. }
  1679. // Bone
  1680. void spine_bone_set_is_y_down(spine_bool yDown) {
  1681. Bone::setYDown(yDown);
  1682. }
  1683. spine_bool spine_bone_get_is_y_down() {
  1684. return Bone::isYDown() ? -1 : 0;
  1685. }
  1686. void spine_bone_update(spine_bone bone) {
  1687. if (bone == nullptr) return;
  1688. Bone *_bone = (Bone *) bone;
  1689. _bone->update(spine::Physics_Update);
  1690. }
  1691. void spine_bone_update_world_transform(spine_bone bone) {
  1692. if (bone == nullptr) return;
  1693. Bone *_bone = (Bone *) bone;
  1694. _bone->updateWorldTransform();
  1695. }
  1696. void spine_bone_update_world_transform_with(spine_bone bone, float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY) {
  1697. if (bone == nullptr) return;
  1698. Bone *_bone = (Bone *) bone;
  1699. _bone->updateWorldTransform(x, y, rotation, scaleX, scaleY, shearX, shearY);
  1700. }
  1701. void spine_bone_update_applied_transform(spine_bone bone) {
  1702. if (bone == nullptr) return;
  1703. Bone *_bone = (Bone *) bone;
  1704. _bone->updateAppliedTransform();
  1705. }
  1706. void spine_bone_set_to_setup_pose(spine_bone bone) {
  1707. if (bone == nullptr) return;
  1708. Bone *_bone = (Bone *) bone;
  1709. _bone->setToSetupPose();
  1710. }
  1711. _spine_vector tmp_vector;
  1712. spine_vector spine_bone_world_to_local(spine_bone bone, float worldX, float worldY) {
  1713. _spine_vector *coords = &tmp_vector;
  1714. if (bone == nullptr) return (spine_vector) coords;
  1715. Bone *_bone = (Bone *) bone;
  1716. _bone->worldToLocal(worldX, worldY, coords->x, coords->y);
  1717. return (spine_vector) coords;
  1718. }
  1719. spine_vector spine_bone_world_to_parent(spine_bone bone, float worldX, float worldY) {
  1720. _spine_vector *coords = &tmp_vector;
  1721. if (bone == nullptr) return (spine_vector) coords;
  1722. Bone *_bone = (Bone *) bone;
  1723. _bone->worldToParent(worldX, worldY, coords->x, coords->y);
  1724. return (spine_vector) coords;
  1725. }
  1726. spine_vector spine_bone_local_to_world(spine_bone bone, float localX, float localY) {
  1727. _spine_vector *coords = &tmp_vector;
  1728. if (bone == nullptr) return (spine_vector) coords;
  1729. Bone *_bone = (Bone *) bone;
  1730. _bone->localToWorld(localX, localY, coords->x, coords->y);
  1731. return (spine_vector) coords;
  1732. }
  1733. spine_vector spine_bone_parent_to_world(spine_bone bone, float localX, float localY) {
  1734. _spine_vector *coords = &tmp_vector;
  1735. if (bone == nullptr) return (spine_vector) coords;
  1736. Bone *_bone = (Bone *) bone;
  1737. _bone->parentToWorld(localX, localY, coords->x, coords->y);
  1738. return (spine_vector) coords;
  1739. }
  1740. float spine_bone_world_to_local_rotation(spine_bone bone, float worldRotation) {
  1741. if (bone == nullptr) return 0;
  1742. Bone *_bone = (Bone *) bone;
  1743. return _bone->worldToLocalRotation(worldRotation);
  1744. }
  1745. float spine_bone_local_to_world_rotation(spine_bone bone, float localRotation) {
  1746. if (bone == nullptr) return 0;
  1747. Bone *_bone = (Bone *) bone;
  1748. return _bone->localToWorldRotation(localRotation);
  1749. }
  1750. void spine_bone_rotate_world(spine_bone bone, float degrees) {
  1751. if (bone == nullptr) return;
  1752. Bone *_bone = (Bone *) bone;
  1753. _bone->rotateWorld(degrees);
  1754. }
  1755. float spine_bone_get_world_to_local_rotation_x(spine_bone bone) {
  1756. if (bone == nullptr) return 0;
  1757. Bone *_bone = (Bone *) bone;
  1758. return _bone->getWorldToLocalRotationX();
  1759. }
  1760. float spine_bone_get_world_to_local_rotation_y(spine_bone bone) {
  1761. if (bone == nullptr) return 0;
  1762. Bone *_bone = (Bone *) bone;
  1763. return _bone->getWorldToLocalRotationY();
  1764. }
  1765. spine_bone_data spine_bone_get_data(spine_bone bone) {
  1766. if (bone == nullptr) return nullptr;
  1767. Bone *_bone = (Bone *) bone;
  1768. return (spine_bone_data) &_bone->getData();
  1769. }
  1770. spine_skeleton spine_bone_get_skeleton(spine_bone bone) {
  1771. if (bone == nullptr) return nullptr;
  1772. Bone *_bone = (Bone *) bone;
  1773. return (spine_skeleton) &_bone->getSkeleton();
  1774. }
  1775. spine_bone spine_bone_get_parent(spine_bone bone) {
  1776. if (bone == nullptr) return nullptr;
  1777. Bone *_bone = (Bone *) bone;
  1778. return (spine_bone) _bone->getParent();
  1779. }
  1780. int32_t spine_bone_get_num_children(spine_bone bone) {
  1781. if (bone == nullptr) return 0;
  1782. Bone *_bone = (Bone *) bone;
  1783. return (int32_t) _bone->getChildren().size();
  1784. }
  1785. spine_bone *spine_bone_get_children(spine_bone bone) {
  1786. if (bone == nullptr) return nullptr;
  1787. Bone *_bone = (Bone *) bone;
  1788. return (spine_bone *) _bone->getChildren().buffer();
  1789. }
  1790. float spine_bone_get_x(spine_bone bone) {
  1791. if (bone == nullptr) return 0;
  1792. Bone *_bone = (Bone *) bone;
  1793. return _bone->getX();
  1794. }
  1795. void spine_bone_set_x(spine_bone bone, float x) {
  1796. if (bone == nullptr) return;
  1797. Bone *_bone = (Bone *) bone;
  1798. _bone->setX(x);
  1799. }
  1800. float spine_bone_get_y(spine_bone bone) {
  1801. if (bone == nullptr) return 0;
  1802. Bone *_bone = (Bone *) bone;
  1803. return _bone->getY();
  1804. }
  1805. void spine_bone_set_y(spine_bone bone, float y) {
  1806. if (bone == nullptr) return;
  1807. Bone *_bone = (Bone *) bone;
  1808. _bone->setY(y);
  1809. }
  1810. float spine_bone_get_rotation(spine_bone bone) {
  1811. if (bone == nullptr) return 0;
  1812. Bone *_bone = (Bone *) bone;
  1813. return _bone->getRotation();
  1814. }
  1815. void spine_bone_set_rotation(spine_bone bone, float rotation) {
  1816. if (bone == nullptr) return;
  1817. Bone *_bone = (Bone *) bone;
  1818. _bone->setRotation(rotation);
  1819. }
  1820. float spine_bone_get_scale_x(spine_bone bone) {
  1821. if (bone == nullptr) return 0;
  1822. Bone *_bone = (Bone *) bone;
  1823. return _bone->getScaleX();
  1824. }
  1825. void spine_bone_set_scale_x(spine_bone bone, float scaleX) {
  1826. if (bone == nullptr) return;
  1827. Bone *_bone = (Bone *) bone;
  1828. _bone->setScaleX(scaleX);
  1829. }
  1830. float spine_bone_get_scale_y(spine_bone bone) {
  1831. if (bone == nullptr) return 0;
  1832. Bone *_bone = (Bone *) bone;
  1833. return _bone->getScaleY();
  1834. }
  1835. void spine_bone_set_scale_y(spine_bone bone, float scaleY) {
  1836. if (bone == nullptr) return;
  1837. Bone *_bone = (Bone *) bone;
  1838. _bone->setScaleY(scaleY);
  1839. }
  1840. float spine_bone_get_shear_x(spine_bone bone) {
  1841. if (bone == nullptr) return 0;
  1842. Bone *_bone = (Bone *) bone;
  1843. return _bone->getShearX();
  1844. }
  1845. void spine_bone_set_shear_x(spine_bone bone, float shearX) {
  1846. if (bone == nullptr) return;
  1847. Bone *_bone = (Bone *) bone;
  1848. _bone->setShearX(shearX);
  1849. }
  1850. float spine_bone_get_shear_y(spine_bone bone) {
  1851. if (bone == nullptr) return 0;
  1852. Bone *_bone = (Bone *) bone;
  1853. return _bone->getShearY();
  1854. }
  1855. void spine_bone_set_shear_y(spine_bone bone, float shearY) {
  1856. if (bone == nullptr) return;
  1857. Bone *_bone = (Bone *) bone;
  1858. _bone->setShearY(shearY);
  1859. }
  1860. float spine_bone_get_applied_rotation(spine_bone bone) {
  1861. if (bone == nullptr) return 0;
  1862. Bone *_bone = (Bone *) bone;
  1863. return _bone->getAppliedRotation();
  1864. }
  1865. void spine_bone_set_applied_rotation(spine_bone bone, float rotation) {
  1866. if (bone == nullptr) return;
  1867. Bone *_bone = (Bone *) bone;
  1868. _bone->setAppliedRotation(rotation);
  1869. }
  1870. float spine_bone_get_a_x(spine_bone bone) {
  1871. if (bone == nullptr) return 0;
  1872. Bone *_bone = (Bone *) bone;
  1873. return _bone->getAX();
  1874. }
  1875. void spine_bone_set_a_x(spine_bone bone, float x) {
  1876. if (bone == nullptr) return;
  1877. Bone *_bone = (Bone *) bone;
  1878. _bone->setAX(x);
  1879. }
  1880. float spine_bone_get_a_y(spine_bone bone) {
  1881. if (bone == nullptr) return 0;
  1882. Bone *_bone = (Bone *) bone;
  1883. return _bone->getAY();
  1884. }
  1885. void spine_bone_set_a_y(spine_bone bone, float y) {
  1886. if (bone == nullptr) return;
  1887. Bone *_bone = (Bone *) bone;
  1888. _bone->setAY(y);
  1889. }
  1890. float spine_bone_get_a_scale_x(spine_bone bone) {
  1891. if (bone == nullptr) return 0;
  1892. Bone *_bone = (Bone *) bone;
  1893. return _bone->getAScaleX();
  1894. }
  1895. void spine_bone_set_a_scale_x(spine_bone bone, float scaleX) {
  1896. if (bone == nullptr) return;
  1897. Bone *_bone = (Bone *) bone;
  1898. _bone->setAScaleX(scaleX);
  1899. }
  1900. float spine_bone_get_a_scale_y(spine_bone bone) {
  1901. if (bone == nullptr) return 0;
  1902. Bone *_bone = (Bone *) bone;
  1903. return _bone->getAScaleY();
  1904. }
  1905. void spine_bone_set_a_scale_y(spine_bone bone, float scaleY) {
  1906. if (bone == nullptr) return;
  1907. Bone *_bone = (Bone *) bone;
  1908. _bone->setAScaleY(scaleY);
  1909. }
  1910. float spine_bone_get_a_shear_x(spine_bone bone) {
  1911. if (bone == nullptr) return 0;
  1912. Bone *_bone = (Bone *) bone;
  1913. return _bone->getAShearX();
  1914. }
  1915. void spine_bone_set_a_shear_x(spine_bone bone, float shearX) {
  1916. if (bone == nullptr) return;
  1917. Bone *_bone = (Bone *) bone;
  1918. _bone->setAShearX(shearX);
  1919. }
  1920. float spine_bone_get_a_shear_y(spine_bone bone) {
  1921. if (bone == nullptr) return 0;
  1922. Bone *_bone = (Bone *) bone;
  1923. return _bone->getAShearY();
  1924. }
  1925. void spine_bone_set_a_shear_y(spine_bone bone, float shearY) {
  1926. if (bone == nullptr) return;
  1927. Bone *_bone = (Bone *) bone;
  1928. _bone->setAShearY(shearY);
  1929. }
  1930. float spine_bone_get_a(spine_bone bone) {
  1931. if (bone == nullptr) return 0;
  1932. Bone *_bone = (Bone *) bone;
  1933. return _bone->getA();
  1934. }
  1935. void spine_bone_set_a(spine_bone bone, float a) {
  1936. if (bone == nullptr) return;
  1937. Bone *_bone = (Bone *) bone;
  1938. _bone->setA(a);
  1939. }
  1940. float spine_bone_get_b(spine_bone bone) {
  1941. if (bone == nullptr) return 0;
  1942. Bone *_bone = (Bone *) bone;
  1943. return _bone->getB();
  1944. }
  1945. void spine_bone_set_b(spine_bone bone, float b) {
  1946. if (bone == nullptr) return;
  1947. Bone *_bone = (Bone *) bone;
  1948. _bone->setB(b);
  1949. }
  1950. float spine_bone_get_c(spine_bone bone) {
  1951. if (bone == nullptr) return 0;
  1952. Bone *_bone = (Bone *) bone;
  1953. return _bone->getC();
  1954. }
  1955. void spine_bone_set_c(spine_bone bone, float c) {
  1956. if (bone == nullptr) return;
  1957. Bone *_bone = (Bone *) bone;
  1958. _bone->setC(c);
  1959. }
  1960. float spine_bone_get_d(spine_bone bone) {
  1961. if (bone == nullptr) return 0;
  1962. Bone *_bone = (Bone *) bone;
  1963. return _bone->getD();
  1964. }
  1965. void spine_bone_set_d(spine_bone bone, float d) {
  1966. if (bone == nullptr) return;
  1967. Bone *_bone = (Bone *) bone;
  1968. _bone->setD(d);
  1969. }
  1970. float spine_bone_get_world_x(spine_bone bone) {
  1971. if (bone == nullptr) return 0;
  1972. Bone *_bone = (Bone *) bone;
  1973. return _bone->getWorldX();
  1974. }
  1975. void spine_bone_set_world_x(spine_bone bone, float worldX) {
  1976. if (bone == nullptr) return;
  1977. Bone *_bone = (Bone *) bone;
  1978. _bone->setWorldX(worldX);
  1979. }
  1980. float spine_bone_get_world_y(spine_bone bone) {
  1981. if (bone == nullptr) return 0;
  1982. Bone *_bone = (Bone *) bone;
  1983. return _bone->getWorldY();
  1984. }
  1985. void spine_bone_set_world_y(spine_bone bone, float worldY) {
  1986. if (bone == nullptr) return;
  1987. Bone *_bone = (Bone *) bone;
  1988. _bone->setWorldY(worldY);
  1989. }
  1990. float spine_bone_get_world_rotation_x(spine_bone bone) {
  1991. if (bone == nullptr) return 0;
  1992. Bone *_bone = (Bone *) bone;
  1993. return _bone->getWorldRotationX();
  1994. }
  1995. float spine_bone_get_world_rotation_y(spine_bone bone) {
  1996. if (bone == nullptr) return 0;
  1997. Bone *_bone = (Bone *) bone;
  1998. return _bone->getWorldToLocalRotationY();
  1999. }
  2000. float spine_bone_get_world_scale_x(spine_bone bone) {
  2001. if (bone == nullptr) return 0;
  2002. Bone *_bone = (Bone *) bone;
  2003. return _bone->getWorldScaleX();
  2004. }
  2005. float spine_bone_get_world_scale_y(spine_bone bone) {
  2006. if (bone == nullptr) return 0;
  2007. Bone *_bone = (Bone *) bone;
  2008. return _bone->getWorldScaleY();
  2009. }
  2010. spine_bool spine_bone_get_is_active(spine_bone bone) {
  2011. if (bone == nullptr) return 0;
  2012. Bone *_bone = (Bone *) bone;
  2013. return _bone->isActive() ? -1 : 0;
  2014. }
  2015. void spine_bone_set_is_active(spine_bone bone, spine_bool isActive) {
  2016. if (bone == nullptr) return;
  2017. Bone *_bone = (Bone *) bone;
  2018. _bone->setActive(isActive);
  2019. }
  2020. spine_inherit spine_bone_get_inherit(spine_bone bone) {
  2021. if (bone == nullptr) return SPINE_INHERIT_NORMAL;
  2022. Bone *_bone = (Bone *) bone;
  2023. return (spine_inherit) _bone->getInherit();
  2024. }
  2025. void spine_bone_set_inherit(spine_bone bone, spine_inherit inherit) {
  2026. if (bone == nullptr) return;
  2027. Bone *_bone = (Bone *) bone;
  2028. _bone->setInherit((spine::Inherit) inherit);
  2029. }
  2030. // Attachment
  2031. const utf8 *spine_attachment_get_name(spine_attachment attachment) {
  2032. if (attachment == nullptr) return nullptr;
  2033. Attachment *_attachment = (Attachment *) attachment;
  2034. return (utf8 *) _attachment->getName().buffer();
  2035. }
  2036. spine_attachment_type spine_attachment_get_type(spine_attachment attachment) {
  2037. if (attachment == nullptr) return SPINE_ATTACHMENT_REGION;
  2038. Attachment *_attachment = (Attachment *) attachment;
  2039. if (_attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
  2040. return SPINE_ATTACHMENT_REGION;
  2041. } else if (_attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
  2042. return SPINE_ATTACHMENT_MESH;
  2043. } else if (_attachment->getRTTI().isExactly(ClippingAttachment::rtti)) {
  2044. return SPINE_ATTACHMENT_CLIPPING;
  2045. } else if (_attachment->getRTTI().isExactly(BoundingBoxAttachment::rtti)) {
  2046. return SPINE_ATTACHMENT_BOUNDING_BOX;
  2047. } else if (_attachment->getRTTI().isExactly(PathAttachment::rtti)) {
  2048. return SPINE_ATTACHMENT_PATH;
  2049. } else if (_attachment->getRTTI().isExactly(PointAttachment::rtti)) {
  2050. return SPINE_ATTACHMENT_POINT;
  2051. } else {
  2052. return SPINE_ATTACHMENT_REGION;
  2053. }
  2054. }
  2055. spine_attachment spine_attachment_copy(spine_attachment attachment) {
  2056. if (attachment == nullptr) return nullptr;
  2057. Attachment *_attachment = (Attachment *) attachment;
  2058. return (spine_attachment) _attachment->copy();
  2059. }
  2060. spine_bounding_box_attachment spine_attachment_cast_to_bounding_box_attachment(spine_attachment attachment) {
  2061. if (attachment == nullptr) return nullptr;
  2062. Attachment *_attachment = (Attachment *) attachment;
  2063. if (_attachment->getRTTI().isExactly(BoundingBoxAttachment::rtti)) {
  2064. BoundingBoxAttachment *boundingBox = static_cast<BoundingBoxAttachment *>(_attachment);
  2065. return (spine_bounding_box_attachment) boundingBox;
  2066. }
  2067. return nullptr;
  2068. }
  2069. void spine_attachment_dispose(spine_attachment attachment) {
  2070. if (attachment == nullptr) return;
  2071. Attachment *_attachment = (Attachment *) attachment;
  2072. delete _attachment;
  2073. }
  2074. // PointAttachment
  2075. spine_vector spine_point_attachment_compute_world_position(spine_point_attachment attachment, spine_bone bone) {
  2076. _spine_vector *result = &tmp_vector;
  2077. if (attachment == nullptr) return (spine_vector) result;
  2078. PointAttachment *_attachment = (PointAttachment *) attachment;
  2079. _attachment->computeWorldPosition(*(Bone *) bone, result->x, result->y);
  2080. return (spine_vector) result;
  2081. }
  2082. float spine_point_attachment_compute_world_rotation(spine_point_attachment attachment, spine_bone bone) {
  2083. if (attachment == nullptr) return 0;
  2084. PointAttachment *_attachment = (PointAttachment *) attachment;
  2085. return _attachment->computeWorldRotation(*(Bone *) bone);
  2086. }
  2087. float spine_point_attachment_get_x(spine_point_attachment attachment) {
  2088. if (attachment == nullptr) return 0;
  2089. PointAttachment *_attachment = (PointAttachment *) attachment;
  2090. return _attachment->getX();
  2091. }
  2092. void spine_point_attachment_set_x(spine_point_attachment attachment, float x) {
  2093. if (attachment == nullptr) return;
  2094. PointAttachment *_attachment = (PointAttachment *) attachment;
  2095. _attachment->setX(x);
  2096. }
  2097. float spine_point_attachment_get_y(spine_point_attachment attachment) {
  2098. if (attachment == nullptr) return 0;
  2099. PointAttachment *_attachment = (PointAttachment *) attachment;
  2100. return _attachment->getY();
  2101. }
  2102. void spine_point_attachment_set_y(spine_point_attachment attachment, float y) {
  2103. if (attachment == nullptr) return;
  2104. PointAttachment *_attachment = (PointAttachment *) attachment;
  2105. _attachment->setY(y);
  2106. }
  2107. float spine_point_attachment_get_rotation(spine_point_attachment attachment) {
  2108. if (attachment == nullptr) return 0;
  2109. PointAttachment *_attachment = (PointAttachment *) attachment;
  2110. return _attachment->getRotation();
  2111. }
  2112. void spine_point_attachment_set_rotation(spine_point_attachment attachment, float rotation) {
  2113. if (attachment == nullptr) return;
  2114. PointAttachment *_attachment = (PointAttachment *) attachment;
  2115. _attachment->setRotation(rotation);
  2116. }
  2117. spine_color spine_point_attachment_get_color(spine_point_attachment attachment) {
  2118. if (attachment == nullptr) return (spine_color) &NULL_COLOR;
  2119. PointAttachment *_attachment = (PointAttachment *) attachment;
  2120. return (spine_color) &_attachment->getColor();
  2121. }
  2122. void spine_point_attachment_set_color(spine_point_attachment attachment, float r, float g, float b, float a) {
  2123. if (attachment == nullptr) return;
  2124. PointAttachment *_attachment = (PointAttachment *) attachment;
  2125. _attachment->getColor().set(r, g, b, a);
  2126. }
  2127. // RegionAttachment
  2128. void spine_region_attachment_update_region(spine_region_attachment attachment) {
  2129. if (attachment == nullptr) return;
  2130. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2131. _attachment->updateRegion();
  2132. }
  2133. void spine_region_attachment_compute_world_vertices(spine_region_attachment attachment, spine_slot slot, float *worldVertices) {
  2134. if (attachment == nullptr) return;
  2135. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2136. _attachment->computeWorldVertices(*(Slot *) slot, worldVertices, 0);
  2137. }
  2138. float spine_region_attachment_get_x(spine_region_attachment attachment) {
  2139. if (attachment == nullptr) return 0;
  2140. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2141. return _attachment->getX();
  2142. }
  2143. void spine_region_attachment_set_x(spine_region_attachment attachment, float x) {
  2144. if (attachment == nullptr) return;
  2145. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2146. _attachment->setX(x);
  2147. }
  2148. float spine_region_attachment_get_y(spine_region_attachment attachment) {
  2149. if (attachment == nullptr) return 0;
  2150. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2151. return _attachment->getY();
  2152. }
  2153. void spine_region_attachment_set_y(spine_region_attachment attachment, float y) {
  2154. if (attachment == nullptr) return;
  2155. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2156. _attachment->setY(y);
  2157. }
  2158. float spine_region_attachment_get_rotation(spine_region_attachment attachment) {
  2159. if (attachment == nullptr) return 0;
  2160. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2161. return _attachment->getRotation();
  2162. }
  2163. void spine_region_attachment_set_rotation(spine_region_attachment attachment, float rotation) {
  2164. if (attachment == nullptr) return;
  2165. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2166. _attachment->setRotation(rotation);
  2167. }
  2168. float spine_region_attachment_get_scale_x(spine_region_attachment attachment) {
  2169. if (attachment == nullptr) return 0;
  2170. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2171. return _attachment->getScaleX();
  2172. }
  2173. void spine_region_attachment_set_scale_x(spine_region_attachment attachment, float scaleX) {
  2174. if (attachment == nullptr) return;
  2175. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2176. _attachment->setScaleX(scaleX);
  2177. }
  2178. float spine_region_attachment_get_scale_y(spine_region_attachment attachment) {
  2179. if (attachment == nullptr) return 0;
  2180. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2181. return _attachment->getScaleY();
  2182. }
  2183. void spine_region_attachment_set_scale_y(spine_region_attachment attachment, float scaleY) {
  2184. if (attachment == nullptr) return;
  2185. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2186. _attachment->setScaleY(scaleY);
  2187. }
  2188. float spine_region_attachment_get_width(spine_region_attachment attachment) {
  2189. if (attachment == nullptr) return 0;
  2190. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2191. return _attachment->getWidth();
  2192. }
  2193. void spine_region_attachment_set_width(spine_region_attachment attachment, float width) {
  2194. if (attachment == nullptr) return;
  2195. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2196. _attachment->setWidth(width);
  2197. }
  2198. float spine_region_attachment_get_height(spine_region_attachment attachment) {
  2199. if (attachment == nullptr) return 0;
  2200. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2201. return _attachment->getHeight();
  2202. }
  2203. void spine_region_attachment_set_height(spine_region_attachment attachment, float height) {
  2204. if (attachment == nullptr) return;
  2205. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2206. _attachment->setHeight(height);
  2207. }
  2208. spine_color spine_region_attachment_get_color(spine_region_attachment attachment) {
  2209. if (attachment == nullptr) return (spine_color) &NULL_COLOR;
  2210. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2211. return (spine_color) &_attachment->getColor();
  2212. }
  2213. void spine_region_attachment_set_color(spine_region_attachment attachment, float r, float g, float b, float a) {
  2214. if (attachment == nullptr) return;
  2215. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2216. _attachment->getColor().set(r, g, b, a);
  2217. }
  2218. const utf8 *spine_region_attachment_get_path(spine_region_attachment attachment) {
  2219. if (attachment == nullptr) return nullptr;
  2220. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2221. return (utf8 *) _attachment->getPath().buffer();
  2222. }
  2223. spine_texture_region spine_region_attachment_get_region(spine_region_attachment attachment) {
  2224. if (attachment == nullptr) return nullptr;
  2225. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2226. return (spine_texture_region) _attachment->getRegion();
  2227. }
  2228. spine_sequence spine_region_attachment_get_sequence(spine_region_attachment attachment) {
  2229. if (attachment == nullptr) return nullptr;
  2230. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2231. return (spine_sequence) _attachment->getSequence();
  2232. }
  2233. int32_t spine_region_attachment_get_num_offset(spine_region_attachment attachment) {
  2234. if (attachment == nullptr) return 0;
  2235. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2236. return (int32_t) _attachment->getOffset().size();
  2237. }
  2238. float *spine_region_attachment_get_offset(spine_region_attachment attachment) {
  2239. if (attachment == nullptr) return nullptr;
  2240. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2241. return _attachment->getOffset().buffer();
  2242. }
  2243. int32_t spine_region_attachment_get_num_uvs(spine_region_attachment attachment) {
  2244. if (attachment == nullptr) return 0;
  2245. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2246. return (int32_t) _attachment->getUVs().size();
  2247. }
  2248. float *spine_region_attachment_get_uvs(spine_region_attachment attachment) {
  2249. if (attachment == nullptr) return nullptr;
  2250. RegionAttachment *_attachment = (RegionAttachment *) attachment;
  2251. return _attachment->getUVs().buffer();
  2252. }
  2253. // VertexAttachment
  2254. int32_t spine_vertex_attachment_get_world_vertices_length(spine_vertex_attachment attachment) {
  2255. if (attachment == nullptr) return 0;
  2256. VertexAttachment *_attachment = (VertexAttachment *) attachment;
  2257. return (int32_t) _attachment->getWorldVerticesLength();
  2258. }
  2259. void spine_vertex_attachment_compute_world_vertices(spine_vertex_attachment attachment, spine_slot slot, float *worldVertices) {
  2260. if (attachment == nullptr) return;
  2261. VertexAttachment *_attachment = (VertexAttachment *) attachment;
  2262. _attachment->computeWorldVertices(*(Slot *) slot, worldVertices);
  2263. }
  2264. int32_t spine_vertex_attachment_get_num_bones(spine_vertex_attachment attachment) {
  2265. if (attachment == nullptr) return 0;
  2266. VertexAttachment *_attachment = (VertexAttachment *) attachment;
  2267. return (int32_t) _attachment->getBones().size();
  2268. }
  2269. int32_t *spine_vertex_attachment_get_bones(spine_vertex_attachment attachment) {
  2270. if (attachment == nullptr) return nullptr;
  2271. VertexAttachment *_attachment = (VertexAttachment *) attachment;
  2272. return _attachment->getBones().buffer();
  2273. }
  2274. // VertexAttachment
  2275. int32_t spine_vertex_attachment_get_num_vertices(spine_vertex_attachment attachment) {
  2276. if (attachment == nullptr) return 0;
  2277. VertexAttachment *_attachment = (VertexAttachment *) attachment;
  2278. return (int32_t) _attachment->getVertices().size();
  2279. }
  2280. float *spine_vertex_attachment_get_vertices(spine_vertex_attachment attachment) {
  2281. if (attachment == nullptr) return nullptr;
  2282. VertexAttachment *_attachment = (VertexAttachment *) attachment;
  2283. return _attachment->getVertices().buffer();
  2284. }
  2285. spine_attachment spine_vertex_attachment_get_timeline_attachment(spine_vertex_attachment attachment) {
  2286. if (attachment == nullptr) return nullptr;
  2287. VertexAttachment *_attachment = (VertexAttachment *) attachment;
  2288. return (spine_attachment) _attachment->getTimelineAttachment();
  2289. }
  2290. void spine_vertex_attachment_set_timeline_attachment(spine_vertex_attachment attachment, spine_attachment timelineAttachment) {
  2291. if (attachment == nullptr) return;
  2292. VertexAttachment *_attachment = (VertexAttachment *) attachment;
  2293. _attachment->setTimelineAttachment((Attachment *) timelineAttachment);
  2294. }
  2295. // MeshAttachment
  2296. void spine_mesh_attachment_update_region(spine_mesh_attachment attachment) {
  2297. if (attachment == nullptr) return;
  2298. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2299. _attachment->updateRegion();
  2300. }
  2301. int32_t spine_mesh_attachment_get_hull_length(spine_mesh_attachment attachment) {
  2302. if (attachment == nullptr) return 0;
  2303. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2304. return _attachment->getHullLength();
  2305. }
  2306. void spine_mesh_attachment_set_hull_length(spine_mesh_attachment attachment, int32_t hullLength) {
  2307. if (attachment == nullptr) return;
  2308. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2309. _attachment->setHullLength(hullLength);
  2310. }
  2311. int32_t spine_mesh_attachment_get_num_region_uvs(spine_mesh_attachment attachment) {
  2312. if (attachment == nullptr) return 0;
  2313. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2314. return (int32_t) _attachment->getRegionUVs().size();
  2315. }
  2316. float *spine_mesh_attachment_get_region_uvs(spine_mesh_attachment attachment) {
  2317. if (attachment == nullptr) return nullptr;
  2318. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2319. return _attachment->getRegionUVs().buffer();
  2320. }
  2321. int32_t spine_mesh_attachment_get_num_uvs(spine_mesh_attachment attachment) {
  2322. if (attachment == nullptr) return 0;
  2323. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2324. return (int32_t) _attachment->getUVs().size();
  2325. }
  2326. float *spine_mesh_attachment_get_uvs(spine_mesh_attachment attachment) {
  2327. if (attachment == nullptr) return 0;
  2328. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2329. return _attachment->getUVs().buffer();
  2330. }
  2331. int32_t spine_mesh_attachment_get_num_triangles(spine_mesh_attachment attachment) {
  2332. if (attachment == nullptr) return 0;
  2333. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2334. return (int32_t) _attachment->getTriangles().size();
  2335. }
  2336. uint16_t *spine_mesh_attachment_get_triangles(spine_mesh_attachment attachment) {
  2337. if (attachment == nullptr) return nullptr;
  2338. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2339. return _attachment->getTriangles().buffer();
  2340. }
  2341. spine_color spine_mesh_attachment_get_color(spine_mesh_attachment attachment) {
  2342. if (attachment == nullptr) return (spine_color) &NULL_COLOR;
  2343. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2344. return (spine_color) &_attachment->getColor();
  2345. }
  2346. void spine_mesh_attachment_set_color(spine_mesh_attachment attachment, float r, float g, float b, float a) {
  2347. if (attachment == nullptr) return;
  2348. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2349. _attachment->getColor().set(r, g, b, a);
  2350. }
  2351. const utf8 *spine_mesh_attachment_get_path(spine_mesh_attachment attachment) {
  2352. if (attachment == nullptr) return nullptr;
  2353. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2354. return (utf8 *) _attachment->getPath().buffer();
  2355. }
  2356. spine_texture_region spine_mesh_attachment_get_region(spine_mesh_attachment attachment) {
  2357. if (attachment == nullptr) return nullptr;
  2358. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2359. return (spine_texture_region) _attachment->getRegion();
  2360. }
  2361. spine_sequence spine_mesh_attachment_get_sequence(spine_mesh_attachment attachment) {
  2362. if (attachment == nullptr) return nullptr;
  2363. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2364. return (spine_sequence) _attachment->getSequence();
  2365. }
  2366. spine_mesh_attachment spine_mesh_attachment_get_parent_mesh(spine_mesh_attachment attachment) {
  2367. if (attachment == nullptr) return nullptr;
  2368. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2369. return (spine_mesh_attachment) _attachment->getParentMesh();
  2370. }
  2371. void spine_mesh_attachment_set_parent_mesh(spine_mesh_attachment attachment, spine_mesh_attachment parentMesh) {
  2372. if (attachment == nullptr) return;
  2373. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2374. _attachment->setParentMesh((MeshAttachment *) parentMesh);
  2375. }
  2376. int32_t spine_mesh_attachment_get_num_edges(spine_mesh_attachment attachment) {
  2377. if (attachment == nullptr) return 0;
  2378. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2379. return (int32_t) _attachment->getEdges().size();
  2380. }
  2381. unsigned short *spine_mesh_attachment_get_edges(spine_mesh_attachment attachment) {
  2382. if (attachment == nullptr) return nullptr;
  2383. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2384. return _attachment->getEdges().buffer();
  2385. }
  2386. float spine_mesh_attachment_get_width(spine_mesh_attachment attachment) {
  2387. if (attachment == nullptr) return 0;
  2388. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2389. return _attachment->getWidth();
  2390. }
  2391. void spine_mesh_attachment_set_width(spine_mesh_attachment attachment, float width) {
  2392. if (attachment == nullptr) return;
  2393. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2394. _attachment->setWidth(width);
  2395. }
  2396. float spine_mesh_attachment_get_height(spine_mesh_attachment attachment) {
  2397. if (attachment == nullptr) return 0;
  2398. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2399. return _attachment->getHeight();
  2400. }
  2401. void spine_mesh_attachment_set_height(spine_mesh_attachment attachment, float height) {
  2402. if (attachment == nullptr) return;
  2403. MeshAttachment *_attachment = (MeshAttachment *) attachment;
  2404. _attachment->setHeight(height);
  2405. }
  2406. // ClippingAttachment
  2407. spine_slot_data spine_clipping_attachment_get_end_slot(spine_clipping_attachment attachment) {
  2408. if (attachment == nullptr) return nullptr;
  2409. ClippingAttachment *_attachment = (ClippingAttachment *) attachment;
  2410. return (spine_slot_data) _attachment->getEndSlot();
  2411. }
  2412. void spine_clipping_attachment_set_end_slot(spine_clipping_attachment attachment, spine_slot_data endSlot) {
  2413. if (attachment == nullptr) return;
  2414. ClippingAttachment *_attachment = (ClippingAttachment *) attachment;
  2415. _attachment->setEndSlot((SlotData *) endSlot);
  2416. }
  2417. spine_color spine_clipping_attachment_get_color(spine_clipping_attachment attachment) {
  2418. if (attachment == nullptr) return (spine_color) &NULL_COLOR;
  2419. ClippingAttachment *_attachment = (ClippingAttachment *) attachment;
  2420. return (spine_color) &_attachment->getColor();
  2421. }
  2422. void spine_clipping_attachment_set_color(spine_clipping_attachment attachment, float r, float g, float b, float a) {
  2423. if (attachment == nullptr) return;
  2424. ClippingAttachment *_attachment = (ClippingAttachment *) attachment;
  2425. _attachment->getColor().set(r, g, b, a);
  2426. }
  2427. // BoundingBoxAttachment
  2428. spine_color spine_bounding_box_attachment_get_color(spine_bounding_box_attachment attachment) {
  2429. if (attachment == nullptr) return (spine_color) &NULL_COLOR;
  2430. BoundingBoxAttachment *_attachment = (BoundingBoxAttachment *) attachment;
  2431. return (spine_color) &_attachment->getColor();
  2432. }
  2433. void spine_bounding_box_attachment_set_color(spine_bounding_box_attachment attachment, float r, float g, float b, float a) {
  2434. if (attachment == nullptr) return;
  2435. BoundingBoxAttachment *_attachment = (BoundingBoxAttachment *) attachment;
  2436. _attachment->getColor().set(r, g, b, a);
  2437. }
  2438. // PathAttachment
  2439. int32_t spine_path_attachment_get_num_lengths(spine_path_attachment attachment) {
  2440. if (attachment == nullptr) return 0;
  2441. PathAttachment *_attachment = (PathAttachment *) attachment;
  2442. return (int32_t) _attachment->getLengths().size();
  2443. }
  2444. float *spine_path_attachment_get_lengths(spine_path_attachment attachment) {
  2445. if (attachment == nullptr) return nullptr;
  2446. PathAttachment *_attachment = (PathAttachment *) attachment;
  2447. return _attachment->getLengths().buffer();
  2448. }
  2449. spine_bool spine_path_attachment_get_is_closed(spine_path_attachment attachment) {
  2450. if (attachment == nullptr) return 0;
  2451. PathAttachment *_attachment = (PathAttachment *) attachment;
  2452. return _attachment->isClosed() ? -1 : 0;
  2453. }
  2454. void spine_path_attachment_set_is_closed(spine_path_attachment attachment, spine_bool isClosed) {
  2455. if (attachment == nullptr) return;
  2456. PathAttachment *_attachment = (PathAttachment *) attachment;
  2457. _attachment->setClosed(isClosed);
  2458. }
  2459. spine_bool spine_path_attachment_get_is_constant_speed(spine_path_attachment attachment) {
  2460. if (attachment == nullptr) return 0;
  2461. PathAttachment *_attachment = (PathAttachment *) attachment;
  2462. return _attachment->isConstantSpeed() ? -1 : 0;
  2463. }
  2464. void spine_path_attachment_set_is_constant_speed(spine_path_attachment attachment, spine_bool isConstantSpeed) {
  2465. if (attachment == nullptr) return;
  2466. PathAttachment *_attachment = (PathAttachment *) attachment;
  2467. _attachment->setConstantSpeed(isConstantSpeed);
  2468. }
  2469. spine_color spine_path_attachment_get_color(spine_path_attachment attachment) {
  2470. if (attachment == nullptr) return (spine_color) &NULL_COLOR;
  2471. PathAttachment *_attachment = (PathAttachment *) attachment;
  2472. return (spine_color) &_attachment->getColor();
  2473. }
  2474. void spine_path_attachment_set_color(spine_path_attachment attachment, float r, float g, float b, float a) {
  2475. if (attachment == nullptr) return;
  2476. PathAttachment *_attachment = (PathAttachment *) attachment;
  2477. _attachment->getColor().set(r, g, b, a);
  2478. }
  2479. // Skin
  2480. void spine_skin_set_attachment(spine_skin skin, int32_t slotIndex, const utf8 *name, spine_attachment attachment) {
  2481. if (skin == nullptr) return;
  2482. Skin *_skin = (Skin *) skin;
  2483. _skin->setAttachment(slotIndex, name, (Attachment *) attachment);
  2484. }
  2485. spine_attachment spine_skin_get_attachment(spine_skin skin, int32_t slotIndex, const utf8 *name) {
  2486. if (skin == nullptr) return nullptr;
  2487. Skin *_skin = (Skin *) skin;
  2488. return (spine_attachment) _skin->getAttachment(slotIndex, name);
  2489. }
  2490. void spine_skin_remove_attachment(spine_skin skin, int32_t slotIndex, const utf8 *name) {
  2491. if (skin == nullptr) return;
  2492. Skin *_skin = (Skin *) skin;
  2493. _skin->removeAttachment(slotIndex, name);
  2494. }
  2495. const utf8 *spine_skin_get_name(spine_skin skin) {
  2496. if (skin == nullptr) return nullptr;
  2497. Skin *_skin = (Skin *) skin;
  2498. return (utf8 *) _skin->getName().buffer();
  2499. }
  2500. void spine_skin_add_skin(spine_skin skin, spine_skin other) {
  2501. if (skin == nullptr) return;
  2502. if (other == nullptr) return;
  2503. Skin *_skin = (Skin *) skin;
  2504. _skin->addSkin((Skin *) other);
  2505. }
  2506. void spine_skin_copy_skin(spine_skin skin, spine_skin other) {
  2507. if (skin == nullptr) return;
  2508. if (other == nullptr) return;
  2509. Skin *_skin = (Skin *) skin;
  2510. _skin->copySkin((Skin *) other);
  2511. }
  2512. spine_skin_entries spine_skin_get_entries(spine_skin skin) {
  2513. if (skin == nullptr) return nullptr;
  2514. Skin *_skin = (Skin *) skin;
  2515. _spine_skin_entries *entries = SpineExtension::getInstance()->calloc<_spine_skin_entries>(1, __FILE__, __LINE__);
  2516. {
  2517. Skin::AttachmentMap::Entries mapEntries = _skin->getAttachments();
  2518. while (mapEntries.hasNext()) entries->numEntries++;
  2519. }
  2520. {
  2521. entries->entries = SpineExtension::getInstance()->calloc<_spine_skin_entry>(entries->numEntries, __FILE__, __LINE__);
  2522. Skin::AttachmentMap::Entries mapEntries = _skin->getAttachments();
  2523. int32_t i = 0;
  2524. while (mapEntries.hasNext()) {
  2525. Skin::AttachmentMap::Entry entry = mapEntries.next();
  2526. entries->entries[i++] = {(int32_t) entry._slotIndex, (utf8 *) entry._name.buffer(), (spine_attachment) entry._attachment};
  2527. }
  2528. }
  2529. return (spine_skin_entries) entries;
  2530. }
  2531. int32_t spine_skin_entries_get_num_entries(spine_skin_entries entries) {
  2532. if (!entries) return 0;
  2533. return ((_spine_skin_entries *) entries)->numEntries;
  2534. }
  2535. spine_skin_entry spine_skin_entries_get_entry(spine_skin_entries entries, int32_t index) {
  2536. if (!entries) return 0;
  2537. return (spine_skin_entry) & ((_spine_skin_entries *) entries)->entries[index];
  2538. }
  2539. void spine_skin_entries_dispose(spine_skin_entries entries) {
  2540. if (entries == nullptr) return;
  2541. SpineExtension::getInstance()->free(((_spine_skin_entries *) entries)->entries, __FILE__, __LINE__);
  2542. SpineExtension::getInstance()->free(entries, __FILE__, __LINE__);
  2543. }
  2544. int32_t spine_skin_entry_get_slot_index(spine_skin_entry entry) {
  2545. if (!entry) return 0;
  2546. return ((_spine_skin_entry *) entry)->slotIndex;
  2547. }
  2548. utf8 *spine_skin_entry_get_name(spine_skin_entry entry) {
  2549. if (!entry) return nullptr;
  2550. return ((_spine_skin_entry *) entry)->name;
  2551. }
  2552. spine_attachment spine_skin_entry_get_attachment(spine_skin_entry entry) {
  2553. if (!entry) return nullptr;
  2554. return ((_spine_skin_entry *) entry)->attachment;
  2555. }
  2556. int32_t spine_skin_get_num_bones(spine_skin skin) {
  2557. if (skin == nullptr) return 0;
  2558. Skin *_skin = (Skin *) skin;
  2559. return (int32_t) _skin->getBones().size();
  2560. }
  2561. spine_bone_data *spine_skin_get_bones(spine_skin skin) {
  2562. if (skin == nullptr) return nullptr;
  2563. Skin *_skin = (Skin *) skin;
  2564. return (spine_bone_data *) _skin->getBones().buffer();
  2565. }
  2566. int32_t spine_skin_get_num_constraints(spine_skin skin) {
  2567. if (skin == nullptr) return 0;
  2568. Skin *_skin = (Skin *) skin;
  2569. return (int32_t) _skin->getConstraints().size();
  2570. }
  2571. spine_constraint_data *spine_skin_get_constraints(spine_skin skin) {
  2572. if (skin == nullptr) return nullptr;
  2573. Skin *_skin = (Skin *) skin;
  2574. return (spine_constraint_data *) _skin->getConstraints().buffer();
  2575. }
  2576. spine_skin spine_skin_create(const utf8 *name) {
  2577. if (name == nullptr) return nullptr;
  2578. return (spine_skin) new (__FILE__, __LINE__) Skin(name);
  2579. }
  2580. void spine_skin_dispose(spine_skin skin) {
  2581. if (skin == nullptr) return;
  2582. Skin *_skin = (Skin *) skin;
  2583. delete _skin;
  2584. }
  2585. // ConstraintData
  2586. spine_constraint_type spine_constraint_data_get_type(spine_constraint_data data) {
  2587. if (data == nullptr) return SPINE_CONSTRAINT_IK;
  2588. ConstraintData *_data = (ConstraintData *) data;
  2589. if (_data->getRTTI().isExactly(IkConstraintData::rtti)) {
  2590. return SPINE_CONSTRAINT_IK;
  2591. } else if (_data->getRTTI().isExactly(TransformConstraintData::rtti)) {
  2592. return SPINE_CONSTRAINT_TRANSFORM;
  2593. } else if (_data->getRTTI().isExactly(PathConstraintData::rtti)) {
  2594. return SPINE_CONSTRAINT_PATH;
  2595. } else {
  2596. return SPINE_CONSTRAINT_IK;
  2597. }
  2598. }
  2599. const utf8 *spine_constraint_data_get_name(spine_constraint_data data) {
  2600. if (data == nullptr) return nullptr;
  2601. ConstraintData *_data = (ConstraintData *) data;
  2602. return (utf8 *) _data->getName().buffer();
  2603. }
  2604. uint64_t spine_constraint_data_get_order(spine_constraint_data data) {
  2605. if (data == nullptr) return 0;
  2606. ConstraintData *_data = (ConstraintData *) data;
  2607. return (uint64_t) _data->getOrder();
  2608. }
  2609. void spine_constraint_data_set_order(spine_constraint_data data, uint64_t order) {
  2610. if (data == nullptr) return;
  2611. ConstraintData *_data = (ConstraintData *) data;
  2612. _data->setOrder((size_t) order);
  2613. }
  2614. spine_bool spine_constraint_data_get_is_skin_required(spine_constraint_data data) {
  2615. if (data == nullptr) return 0;
  2616. ConstraintData *_data = (ConstraintData *) data;
  2617. return _data->isSkinRequired() ? -1 : 0;
  2618. }
  2619. void spine_constraint_data_set_is_skin_required(spine_constraint_data data, spine_bool isSkinRequired) {
  2620. if (data == nullptr) return;
  2621. ConstraintData *_data = (ConstraintData *) data;
  2622. _data->setSkinRequired(isSkinRequired);
  2623. }
  2624. // IkConstraintData
  2625. int32_t spine_ik_constraint_data_get_num_bones(spine_ik_constraint_data data) {
  2626. if (data == nullptr) return 0;
  2627. IkConstraintData *_data = (IkConstraintData *) data;
  2628. return (int32_t) _data->getBones().size();
  2629. }
  2630. spine_bone_data *spine_ik_constraint_data_get_bones(spine_ik_constraint_data data) {
  2631. if (data == nullptr) return nullptr;
  2632. IkConstraintData *_data = (IkConstraintData *) data;
  2633. return (spine_bone_data *) _data->getBones().buffer();
  2634. }
  2635. spine_bone_data spine_ik_constraint_data_get_target(spine_ik_constraint_data data) {
  2636. if (data == nullptr) return nullptr;
  2637. IkConstraintData *_data = (IkConstraintData *) data;
  2638. return (spine_bone_data) _data->getTarget();
  2639. }
  2640. void spine_ik_constraint_data_set_target(spine_ik_constraint_data data, spine_bone_data target) {
  2641. if (data == nullptr) return;
  2642. IkConstraintData *_data = (IkConstraintData *) data;
  2643. _data->setTarget((BoneData *) target);
  2644. }
  2645. int32_t spine_ik_constraint_data_get_bend_direction(spine_ik_constraint_data data) {
  2646. if (data == nullptr) return 1;
  2647. IkConstraintData *_data = (IkConstraintData *) data;
  2648. return _data->getBendDirection();
  2649. }
  2650. void spine_ik_constraint_data_set_bend_direction(spine_ik_constraint_data data, int32_t bendDirection) {
  2651. if (data == nullptr) return;
  2652. IkConstraintData *_data = (IkConstraintData *) data;
  2653. _data->setBendDirection(bendDirection);
  2654. }
  2655. spine_bool spine_ik_constraint_data_get_compress(spine_ik_constraint_data data) {
  2656. if (data == nullptr) return 0;
  2657. IkConstraintData *_data = (IkConstraintData *) data;
  2658. return _data->getCompress() ? -1 : 0;
  2659. }
  2660. void spine_ik_constraint_data_set_compress(spine_ik_constraint_data data, spine_bool compress) {
  2661. if (data == nullptr) return;
  2662. IkConstraintData *_data = (IkConstraintData *) data;
  2663. _data->setCompress(compress);
  2664. }
  2665. spine_bool spine_ik_constraint_data_get_stretch(spine_ik_constraint_data data) {
  2666. if (data == nullptr) return 0;
  2667. IkConstraintData *_data = (IkConstraintData *) data;
  2668. return _data->getStretch() ? -1 : 0;
  2669. }
  2670. void spine_ik_constraint_data_set_stretch(spine_ik_constraint_data data, spine_bool stretch) {
  2671. if (data == nullptr) return;
  2672. IkConstraintData *_data = (IkConstraintData *) data;
  2673. _data->setStretch(stretch);
  2674. }
  2675. spine_bool spine_ik_constraint_data_get_uniform(spine_ik_constraint_data data) {
  2676. if (data == nullptr) return 0;
  2677. IkConstraintData *_data = (IkConstraintData *) data;
  2678. return _data->getUniform() ? -1 : 0;
  2679. }
  2680. void spine_ik_constraint_data_set_uniform(spine_ik_constraint_data data, spine_bool uniform) {
  2681. if (data == nullptr) return;
  2682. IkConstraintData *_data = (IkConstraintData *) data;
  2683. _data->setUniform(uniform);
  2684. }
  2685. float spine_ik_constraint_data_get_mix(spine_ik_constraint_data data) {
  2686. if (data == nullptr) return 0;
  2687. IkConstraintData *_data = (IkConstraintData *) data;
  2688. return _data->getMix();
  2689. }
  2690. void spine_ik_constraint_data_set_mix(spine_ik_constraint_data data, float mix) {
  2691. if (data == nullptr) return;
  2692. IkConstraintData *_data = (IkConstraintData *) data;
  2693. _data->setMix(mix);
  2694. }
  2695. float spine_ik_constraint_data_get_softness(spine_ik_constraint_data data) {
  2696. if (data == nullptr) return 0;
  2697. IkConstraintData *_data = (IkConstraintData *) data;
  2698. return _data->getSoftness();
  2699. }
  2700. void spine_ik_constraint_data_set_softness(spine_ik_constraint_data data, float softness) {
  2701. if (data == nullptr) return;
  2702. IkConstraintData *_data = (IkConstraintData *) data;
  2703. _data->setSoftness(softness);
  2704. }
  2705. // IKConstraint
  2706. void spine_ik_constraint_update(spine_ik_constraint constraint) {
  2707. if (constraint == nullptr) return;
  2708. IkConstraint *_constraint = (IkConstraint *) constraint;
  2709. _constraint->update(spine::Physics_Update);
  2710. }
  2711. int32_t spine_ik_constraint_get_order(spine_ik_constraint constraint) {
  2712. if (constraint == nullptr) return 0;
  2713. IkConstraint *_constraint = (IkConstraint *) constraint;
  2714. return _constraint->getOrder();
  2715. }
  2716. spine_ik_constraint_data spine_ik_constraint_get_data(spine_ik_constraint constraint) {
  2717. if (constraint == nullptr) return nullptr;
  2718. IkConstraint *_constraint = (IkConstraint *) constraint;
  2719. return (spine_ik_constraint_data) &_constraint->getData();
  2720. }
  2721. int32_t spine_ik_constraint_get_num_bones(spine_ik_constraint constraint) {
  2722. if (constraint == nullptr) return 0;
  2723. IkConstraint *_constraint = (IkConstraint *) constraint;
  2724. return (int32_t) _constraint->getBones().size();
  2725. }
  2726. spine_bone *spine_ik_constraint_get_bones(spine_ik_constraint constraint) {
  2727. if (constraint == nullptr) return nullptr;
  2728. IkConstraint *_constraint = (IkConstraint *) constraint;
  2729. return (spine_bone *) _constraint->getBones().buffer();
  2730. }
  2731. spine_bone spine_ik_constraint_get_target(spine_ik_constraint constraint) {
  2732. if (constraint == nullptr) return nullptr;
  2733. IkConstraint *_constraint = (IkConstraint *) constraint;
  2734. return (spine_bone) _constraint->getTarget();
  2735. }
  2736. void spine_ik_constraint_set_target(spine_ik_constraint constraint, spine_bone target) {
  2737. if (constraint == nullptr) return;
  2738. IkConstraint *_constraint = (IkConstraint *) constraint;
  2739. _constraint->setTarget((Bone *) target);
  2740. }
  2741. int32_t spine_ik_constraint_get_bend_direction(spine_ik_constraint constraint) {
  2742. if (constraint == nullptr) return 1;
  2743. IkConstraint *_constraint = (IkConstraint *) constraint;
  2744. return _constraint->getBendDirection();
  2745. }
  2746. void spine_ik_constraint_set_bend_direction(spine_ik_constraint constraint, int32_t bendDirection) {
  2747. if (constraint == nullptr) return;
  2748. IkConstraint *_constraint = (IkConstraint *) constraint;
  2749. _constraint->setBendDirection(bendDirection);
  2750. }
  2751. spine_bool spine_ik_constraint_get_compress(spine_ik_constraint constraint) {
  2752. if (constraint == nullptr) return 0;
  2753. IkConstraint *_constraint = (IkConstraint *) constraint;
  2754. return _constraint->getCompress() ? -1 : 0;
  2755. }
  2756. void spine_ik_constraint_set_compress(spine_ik_constraint constraint, spine_bool compress) {
  2757. if (constraint == nullptr) return;
  2758. IkConstraint *_constraint = (IkConstraint *) constraint;
  2759. _constraint->setCompress(compress);
  2760. }
  2761. spine_bool spine_ik_constraint_get_stretch(spine_ik_constraint constraint) {
  2762. if (constraint == nullptr) return 0;
  2763. IkConstraint *_constraint = (IkConstraint *) constraint;
  2764. return _constraint->getStretch() ? -1 : 0;
  2765. }
  2766. void spine_ik_constraint_set_stretch(spine_ik_constraint constraint, spine_bool stretch) {
  2767. if (constraint == nullptr) return;
  2768. IkConstraint *_constraint = (IkConstraint *) constraint;
  2769. _constraint->setStretch(stretch);
  2770. }
  2771. float spine_ik_constraint_get_mix(spine_ik_constraint constraint) {
  2772. if (constraint == nullptr) return 0;
  2773. IkConstraint *_constraint = (IkConstraint *) constraint;
  2774. return _constraint->getMix();
  2775. }
  2776. void spine_ik_constraint_set_mix(spine_ik_constraint constraint, float mix) {
  2777. if (constraint == nullptr) return;
  2778. IkConstraint *_constraint = (IkConstraint *) constraint;
  2779. _constraint->setMix(mix);
  2780. }
  2781. float spine_ik_constraint_get_softness(spine_ik_constraint constraint) {
  2782. if (constraint == nullptr) return 0;
  2783. IkConstraint *_constraint = (IkConstraint *) constraint;
  2784. return _constraint->getSoftness();
  2785. }
  2786. void spine_ik_constraint_set_softness(spine_ik_constraint constraint, float softness) {
  2787. if (constraint == nullptr) return;
  2788. IkConstraint *_constraint = (IkConstraint *) constraint;
  2789. _constraint->setSoftness(softness);
  2790. }
  2791. spine_bool spine_ik_constraint_get_is_active(spine_ik_constraint constraint) {
  2792. if (constraint == nullptr) return 0;
  2793. IkConstraint *_constraint = (IkConstraint *) constraint;
  2794. return _constraint->isActive() ? -1 : 0;
  2795. }
  2796. void spine_ik_constraint_set_is_active(spine_ik_constraint constraint, spine_bool isActive) {
  2797. if (constraint == nullptr) return;
  2798. IkConstraint *_constraint = (IkConstraint *) constraint;
  2799. _constraint->setActive(isActive);
  2800. }
  2801. // TransformConstraintData
  2802. int32_t spine_transform_constraint_data_get_num_bones(spine_transform_constraint_data data) {
  2803. if (data == nullptr) return 0;
  2804. TransformConstraintData *_data = (TransformConstraintData *) data;
  2805. return (int32_t) _data->getBones().size();
  2806. }
  2807. spine_bone_data *spine_transform_constraint_data_get_bones(spine_transform_constraint_data data) {
  2808. if (data == nullptr) return nullptr;
  2809. TransformConstraintData *_data = (TransformConstraintData *) data;
  2810. return (spine_bone_data *) _data->getBones().buffer();
  2811. }
  2812. spine_bone_data spine_transform_constraint_data_get_target(spine_transform_constraint_data data) {
  2813. if (data == nullptr) return nullptr;
  2814. TransformConstraintData *_data = (TransformConstraintData *) data;
  2815. return (spine_bone_data) _data->getTarget();
  2816. }
  2817. void spine_transform_constraint_data_set_target(spine_transform_constraint_data data, spine_bone_data target) {
  2818. if (data == nullptr) return;
  2819. TransformConstraintData *_data = (TransformConstraintData *) data;
  2820. _data->setTarget((BoneData *) target);
  2821. }
  2822. float spine_transform_constraint_data_get_mix_rotate(spine_transform_constraint_data data) {
  2823. if (data == nullptr) return 0;
  2824. TransformConstraintData *_data = (TransformConstraintData *) data;
  2825. return _data->getMixRotate();
  2826. }
  2827. void spine_transform_constraint_data_set_mix_rotate(spine_transform_constraint_data data, float mixRotate) {
  2828. if (data == nullptr) return;
  2829. TransformConstraintData *_data = (TransformConstraintData *) data;
  2830. _data->setMixRotate(mixRotate);
  2831. }
  2832. float spine_transform_constraint_data_get_mix_x(spine_transform_constraint_data data) {
  2833. if (data == nullptr) return 0;
  2834. TransformConstraintData *_data = (TransformConstraintData *) data;
  2835. return _data->getMixX();
  2836. }
  2837. void spine_transform_constraint_data_set_mix_x(spine_transform_constraint_data data, float mixX) {
  2838. if (data == nullptr) return;
  2839. TransformConstraintData *_data = (TransformConstraintData *) data;
  2840. _data->setMixX(mixX);
  2841. }
  2842. float spine_transform_constraint_data_get_mix_y(spine_transform_constraint_data data) {
  2843. if (data == nullptr) return 0;
  2844. TransformConstraintData *_data = (TransformConstraintData *) data;
  2845. return _data->getMixY();
  2846. }
  2847. void spine_transform_constraint_data_set_mix_y(spine_transform_constraint_data data, float mixY) {
  2848. if (data == nullptr) return;
  2849. TransformConstraintData *_data = (TransformConstraintData *) data;
  2850. _data->setMixY(mixY);
  2851. }
  2852. float spine_transform_constraint_data_get_mix_scale_x(spine_transform_constraint_data data) {
  2853. if (data == nullptr) return 0;
  2854. TransformConstraintData *_data = (TransformConstraintData *) data;
  2855. return _data->getMixScaleX();
  2856. }
  2857. void spine_transform_constraint_data_set_mix_scale_x(spine_transform_constraint_data data, float mixScaleX) {
  2858. if (data == nullptr) return;
  2859. TransformConstraintData *_data = (TransformConstraintData *) data;
  2860. _data->setMixScaleX(mixScaleX);
  2861. }
  2862. float spine_transform_constraint_data_get_mix_scale_y(spine_transform_constraint_data data) {
  2863. if (data == nullptr) return 0;
  2864. TransformConstraintData *_data = (TransformConstraintData *) data;
  2865. return _data->getMixScaleY();
  2866. }
  2867. void spine_transform_constraint_data_set_mix_scale_y(spine_transform_constraint_data data, float mixScaleY) {
  2868. if (data == nullptr) return;
  2869. TransformConstraintData *_data = (TransformConstraintData *) data;
  2870. _data->setMixScaleY(mixScaleY);
  2871. }
  2872. float spine_transform_constraint_data_get_mix_shear_y(spine_transform_constraint_data data) {
  2873. if (data == nullptr) return 0;
  2874. TransformConstraintData *_data = (TransformConstraintData *) data;
  2875. return _data->getMixShearY();
  2876. }
  2877. void spine_transform_constraint_data_set_mix_shear_y(spine_transform_constraint_data data, float mixShearY) {
  2878. if (data == nullptr) return;
  2879. TransformConstraintData *_data = (TransformConstraintData *) data;
  2880. _data->setMixShearY(mixShearY);
  2881. }
  2882. float spine_transform_constraint_data_get_offset_rotation(spine_transform_constraint_data data) {
  2883. if (data == nullptr) return 0;
  2884. TransformConstraintData *_data = (TransformConstraintData *) data;
  2885. return _data->getOffsetRotation();
  2886. }
  2887. void spine_transform_constraint_data_set_offset_rotation(spine_transform_constraint_data data, float offsetRotation) {
  2888. if (data == nullptr) return;
  2889. TransformConstraintData *_data = (TransformConstraintData *) data;
  2890. _data->setOffsetRotation(offsetRotation);
  2891. }
  2892. float spine_transform_constraint_data_get_offset_x(spine_transform_constraint_data data) {
  2893. if (data == nullptr) return 0;
  2894. TransformConstraintData *_data = (TransformConstraintData *) data;
  2895. return _data->getOffsetX();
  2896. }
  2897. void spine_transform_constraint_data_set_offset_x(spine_transform_constraint_data data, float offsetX) {
  2898. if (data == nullptr) return;
  2899. TransformConstraintData *_data = (TransformConstraintData *) data;
  2900. _data->setOffsetX(offsetX);
  2901. }
  2902. float spine_transform_constraint_data_get_offset_y(spine_transform_constraint_data data) {
  2903. if (data == nullptr) return 0;
  2904. TransformConstraintData *_data = (TransformConstraintData *) data;
  2905. return _data->getOffsetY();
  2906. }
  2907. void spine_transform_constraint_data_set_offset_y(spine_transform_constraint_data data, float offsetY) {
  2908. if (data == nullptr) return;
  2909. TransformConstraintData *_data = (TransformConstraintData *) data;
  2910. _data->setOffsetY(offsetY);
  2911. }
  2912. float spine_transform_constraint_data_get_offset_scale_x(spine_transform_constraint_data data) {
  2913. if (data == nullptr) return 0;
  2914. TransformConstraintData *_data = (TransformConstraintData *) data;
  2915. return _data->getOffsetScaleX();
  2916. }
  2917. void spine_transform_constraint_data_set_offset_scale_x(spine_transform_constraint_data data, float offsetScaleX) {
  2918. if (data == nullptr) return;
  2919. TransformConstraintData *_data = (TransformConstraintData *) data;
  2920. _data->setOffsetScaleX(offsetScaleX);
  2921. }
  2922. float spine_transform_constraint_data_get_offset_scale_y(spine_transform_constraint_data data) {
  2923. if (data == nullptr) return 0;
  2924. TransformConstraintData *_data = (TransformConstraintData *) data;
  2925. return _data->getOffsetScaleY();
  2926. }
  2927. void spine_transform_constraint_data_set_offset_scale_y(spine_transform_constraint_data data, float offsetScaleY) {
  2928. if (data == nullptr) return;
  2929. TransformConstraintData *_data = (TransformConstraintData *) data;
  2930. _data->setOffsetScaleY(offsetScaleY);
  2931. }
  2932. float spine_transform_constraint_data_get_offset_shear_y(spine_transform_constraint_data data) {
  2933. if (data == nullptr) return 0;
  2934. TransformConstraintData *_data = (TransformConstraintData *) data;
  2935. return _data->getOffsetShearY();
  2936. }
  2937. void spine_transform_constraint_data_set_offset_shear_y(spine_transform_constraint_data data, float offsetShearY) {
  2938. if (data == nullptr) return;
  2939. TransformConstraintData *_data = (TransformConstraintData *) data;
  2940. _data->setOffsetShearY(offsetShearY);
  2941. }
  2942. spine_bool spine_transform_constraint_data_get_is_relative(spine_transform_constraint_data data) {
  2943. if (data == nullptr) return 0;
  2944. TransformConstraintData *_data = (TransformConstraintData *) data;
  2945. return _data->isRelative() ? -1 : 0;
  2946. }
  2947. void spine_transform_constraint_data_set_is_relative(spine_transform_constraint_data data, spine_bool isRelative) {
  2948. if (data == nullptr) return;
  2949. TransformConstraintData *_data = (TransformConstraintData *) data;
  2950. _data->setRelative(isRelative);
  2951. }
  2952. spine_bool spine_transform_constraint_data_get_is_local(spine_transform_constraint_data data) {
  2953. if (data == nullptr) return 0;
  2954. TransformConstraintData *_data = (TransformConstraintData *) data;
  2955. return _data->isLocal() ? -1 : 0;
  2956. }
  2957. void spine_transform_constraint_data_set_is_local(spine_transform_constraint_data data, spine_bool isLocal) {
  2958. if (data == nullptr) return;
  2959. TransformConstraintData *_data = (TransformConstraintData *) data;
  2960. _data->setLocal(isLocal);
  2961. }
  2962. // TransformConstraint
  2963. void spine_transform_constraint_update(spine_transform_constraint constraint) {
  2964. if (constraint == nullptr) return;
  2965. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2966. _constraint->update(spine::Physics_Update);
  2967. }
  2968. int32_t spine_transform_constraint_get_order(spine_transform_constraint constraint) {
  2969. if (constraint == nullptr) return 0;
  2970. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2971. return _constraint->getOrder();
  2972. }
  2973. spine_transform_constraint_data spine_transform_constraint_get_data(spine_transform_constraint constraint) {
  2974. if (constraint == nullptr) return nullptr;
  2975. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2976. return (spine_transform_constraint_data) &_constraint->getData();
  2977. }
  2978. int32_t spine_transform_constraint_get_num_bones(spine_transform_constraint constraint) {
  2979. if (constraint == nullptr) return 0;
  2980. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2981. return (int32_t) _constraint->getBones().size();
  2982. }
  2983. spine_bone *spine_transform_constraint_get_bones(spine_transform_constraint constraint) {
  2984. if (constraint == nullptr) return nullptr;
  2985. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2986. return (spine_bone *) _constraint->getBones().buffer();
  2987. }
  2988. spine_bone spine_transform_constraint_get_target(spine_transform_constraint constraint) {
  2989. if (constraint == nullptr) return nullptr;
  2990. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2991. return (spine_bone) _constraint->getTarget();
  2992. }
  2993. void spine_transform_constraint_set_target(spine_transform_constraint constraint, spine_bone target) {
  2994. if (constraint == nullptr) return;
  2995. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2996. _constraint->setTarget((Bone *) target);
  2997. }
  2998. float spine_transform_constraint_get_mix_rotate(spine_transform_constraint constraint) {
  2999. if (constraint == nullptr) return 0;
  3000. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3001. return _constraint->getMixRotate();
  3002. }
  3003. void spine_transform_constraint_set_mix_rotate(spine_transform_constraint constraint, float mixRotate) {
  3004. if (constraint == nullptr) return;
  3005. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3006. _constraint->setMixRotate(mixRotate);
  3007. }
  3008. float spine_transform_constraint_get_mix_x(spine_transform_constraint constraint) {
  3009. if (constraint == nullptr) return 0;
  3010. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3011. return _constraint->getMixX();
  3012. }
  3013. void spine_transform_constraint_set_mix_x(spine_transform_constraint constraint, float mixX) {
  3014. if (constraint == nullptr) return;
  3015. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3016. _constraint->setMixX(mixX);
  3017. }
  3018. float spine_transform_constraint_get_mix_y(spine_transform_constraint constraint) {
  3019. if (constraint == nullptr) return 0;
  3020. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3021. return _constraint->getMixY();
  3022. }
  3023. void spine_transform_constraint_set_mix_y(spine_transform_constraint constraint, float mixY) {
  3024. if (constraint == nullptr) return;
  3025. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3026. _constraint->setMixY(mixY);
  3027. }
  3028. float spine_transform_constraint_get_mix_scale_x(spine_transform_constraint constraint) {
  3029. if (constraint == nullptr) return 0;
  3030. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3031. return _constraint->getMixScaleX();
  3032. }
  3033. void spine_transform_constraint_set_mix_scale_x(spine_transform_constraint constraint, float mixScaleX) {
  3034. if (constraint == nullptr) return;
  3035. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3036. _constraint->setMixScaleX(mixScaleX);
  3037. }
  3038. float spine_transform_constraint_get_mix_scale_y(spine_transform_constraint constraint) {
  3039. if (constraint == nullptr) return 0;
  3040. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3041. return _constraint->getMixScaleY();
  3042. }
  3043. void spine_transform_constraint_set_mix_scale_y(spine_transform_constraint constraint, float mixScaleY) {
  3044. if (constraint == nullptr) return;
  3045. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3046. _constraint->setMixScaleY(mixScaleY);
  3047. }
  3048. float spine_transform_constraint_get_mix_shear_y(spine_transform_constraint constraint) {
  3049. if (constraint == nullptr) return 0;
  3050. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3051. return _constraint->getMixShearY();
  3052. }
  3053. void spine_transform_constraint_set_mix_shear_y(spine_transform_constraint constraint, float mixShearY) {
  3054. if (constraint == nullptr) return;
  3055. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3056. _constraint->setMixShearY(mixShearY);
  3057. }
  3058. spine_bool spine_transform_constraint_get_is_active(spine_transform_constraint constraint) {
  3059. if (constraint == nullptr) return 0;
  3060. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3061. return _constraint->isActive() ? -1 : 0;
  3062. }
  3063. void spine_transform_constraint_set_is_active(spine_transform_constraint constraint, spine_bool isActive) {
  3064. if (constraint == nullptr) return;
  3065. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3066. _constraint->setActive(isActive);
  3067. }
  3068. // PathConstraintData
  3069. int32_t spine_path_constraint_data_get_num_bones(spine_path_constraint_data data) {
  3070. if (data == nullptr) return 0;
  3071. PathConstraintData *_data = (PathConstraintData *) data;
  3072. return (int32_t) _data->getBones().size();
  3073. }
  3074. spine_bone_data *spine_path_constraint_data_get_bones(spine_path_constraint_data data) {
  3075. if (data == nullptr) return nullptr;
  3076. PathConstraintData *_data = (PathConstraintData *) data;
  3077. return (spine_bone_data *) _data->getBones().buffer();
  3078. }
  3079. spine_slot_data spine_path_constraint_data_get_target(spine_path_constraint_data data) {
  3080. if (data == nullptr) return nullptr;
  3081. PathConstraintData *_data = (PathConstraintData *) data;
  3082. return (spine_slot_data) _data->getTarget();
  3083. }
  3084. void spine_path_constraint_data_set_target(spine_path_constraint_data data, spine_slot_data target) {
  3085. if (data == nullptr) return;
  3086. PathConstraintData *_data = (PathConstraintData *) data;
  3087. _data->setTarget((SlotData *) target);
  3088. }
  3089. spine_position_mode spine_path_constraint_data_get_position_mode(spine_path_constraint_data data) {
  3090. if (data == nullptr) return SPINE_POSITION_MODE_FIXED;
  3091. PathConstraintData *_data = (PathConstraintData *) data;
  3092. return (spine_position_mode) _data->getPositionMode();
  3093. }
  3094. void spine_path_constraint_data_set_position_mode(spine_path_constraint_data data, spine_position_mode positionMode) {
  3095. if (data == nullptr) return;
  3096. PathConstraintData *_data = (PathConstraintData *) data;
  3097. _data->setPositionMode((PositionMode) positionMode);
  3098. }
  3099. spine_spacing_mode spine_path_constraint_data_get_spacing_mode(spine_path_constraint_data data) {
  3100. if (data == nullptr) return SPINE_SPACING_MODE_LENGTH;
  3101. PathConstraintData *_data = (PathConstraintData *) data;
  3102. return (spine_spacing_mode) _data->getSpacingMode();
  3103. }
  3104. void spine_path_constraint_data_set_spacing_mode(spine_path_constraint_data data, spine_spacing_mode spacingMode) {
  3105. if (data == nullptr) return;
  3106. PathConstraintData *_data = (PathConstraintData *) data;
  3107. _data->setSpacingMode((SpacingMode) spacingMode);
  3108. }
  3109. spine_rotate_mode spine_path_constraint_data_get_rotate_mode(spine_path_constraint_data data) {
  3110. if (data == nullptr) return SPINE_ROTATE_MODE_TANGENT;
  3111. PathConstraintData *_data = (PathConstraintData *) data;
  3112. return (spine_rotate_mode) _data->getRotateMode();
  3113. }
  3114. void spine_path_constraint_data_set_rotate_mode(spine_path_constraint_data data, spine_rotate_mode rotateMode) {
  3115. if (data == nullptr) return;
  3116. PathConstraintData *_data = (PathConstraintData *) data;
  3117. _data->setRotateMode((RotateMode) rotateMode);
  3118. }
  3119. float spine_path_constraint_data_get_offset_rotation(spine_path_constraint_data data) {
  3120. if (data == nullptr) return 0;
  3121. PathConstraintData *_data = (PathConstraintData *) data;
  3122. return _data->getOffsetRotation();
  3123. }
  3124. void spine_path_constraint_data_set_offset_rotation(spine_path_constraint_data data, float offsetRotation) {
  3125. if (data == nullptr) return;
  3126. PathConstraintData *_data = (PathConstraintData *) data;
  3127. _data->setOffsetRotation(offsetRotation);
  3128. }
  3129. float spine_path_constraint_data_get_position(spine_path_constraint_data data) {
  3130. if (data == nullptr) return 0;
  3131. PathConstraintData *_data = (PathConstraintData *) data;
  3132. return _data->getPosition();
  3133. }
  3134. void spine_path_constraint_data_set_position(spine_path_constraint_data data, float position) {
  3135. if (data == nullptr) return;
  3136. PathConstraintData *_data = (PathConstraintData *) data;
  3137. _data->setPosition(position);
  3138. }
  3139. float spine_path_constraint_data_get_spacing(spine_path_constraint_data data) {
  3140. if (data == nullptr) return 0;
  3141. PathConstraintData *_data = (PathConstraintData *) data;
  3142. return _data->getSpacing();
  3143. }
  3144. void spine_path_constraint_data_set_spacing(spine_path_constraint_data data, float spacing) {
  3145. if (data == nullptr) return;
  3146. PathConstraintData *_data = (PathConstraintData *) data;
  3147. _data->setSpacing(spacing);
  3148. }
  3149. float spine_path_constraint_data_get_mix_rotate(spine_path_constraint_data data) {
  3150. if (data == nullptr) return 0;
  3151. PathConstraintData *_data = (PathConstraintData *) data;
  3152. return _data->getMixRotate();
  3153. }
  3154. void spine_path_constraint_data_set_mix_rotate(spine_path_constraint_data data, float mixRotate) {
  3155. if (data == nullptr) return;
  3156. PathConstraintData *_data = (PathConstraintData *) data;
  3157. _data->setMixRotate(mixRotate);
  3158. }
  3159. float spine_path_constraint_data_get_mix_x(spine_path_constraint_data data) {
  3160. if (data == nullptr) return 0;
  3161. PathConstraintData *_data = (PathConstraintData *) data;
  3162. return _data->getMixX();
  3163. }
  3164. void spine_path_constraint_data_set_mix_x(spine_path_constraint_data data, float mixX) {
  3165. if (data == nullptr) return;
  3166. PathConstraintData *_data = (PathConstraintData *) data;
  3167. _data->setMixX(mixX);
  3168. }
  3169. float spine_path_constraint_data_get_mix_y(spine_path_constraint_data data) {
  3170. if (data == nullptr) return 0;
  3171. PathConstraintData *_data = (PathConstraintData *) data;
  3172. return _data->getMixY();
  3173. }
  3174. void spine_path_constraint_data_set_mix_y(spine_path_constraint_data data, float mixY) {
  3175. if (data == nullptr) return;
  3176. PathConstraintData *_data = (PathConstraintData *) data;
  3177. _data->setMixY(mixY);
  3178. }
  3179. // PathConstraint
  3180. void spine_path_constraint_update(spine_path_constraint constraint) {
  3181. if (constraint == nullptr) return;
  3182. PathConstraint *_constraint = (PathConstraint *) constraint;
  3183. _constraint->update(spine::Physics_Update);
  3184. }
  3185. int32_t spine_path_constraint_get_order(spine_path_constraint constraint) {
  3186. if (constraint == nullptr) return 0;
  3187. PathConstraint *_constraint = (PathConstraint *) constraint;
  3188. return _constraint->getOrder();
  3189. }
  3190. spine_path_constraint_data spine_path_constraint_get_data(spine_path_constraint constraint) {
  3191. if (constraint == nullptr) return nullptr;
  3192. PathConstraint *_constraint = (PathConstraint *) constraint;
  3193. return (spine_path_constraint_data) &_constraint->getData();
  3194. }
  3195. int32_t spine_path_constraint_get_num_bones(spine_path_constraint constraint) {
  3196. if (constraint == nullptr) return 0;
  3197. PathConstraint *_constraint = (PathConstraint *) constraint;
  3198. return (int32_t) _constraint->getBones().size();
  3199. }
  3200. spine_bone *spine_path_constraint_get_bones(spine_path_constraint constraint) {
  3201. if (constraint == nullptr) return nullptr;
  3202. PathConstraint *_constraint = (PathConstraint *) constraint;
  3203. return (spine_bone *) _constraint->getBones().buffer();
  3204. }
  3205. spine_slot spine_path_constraint_get_target(spine_path_constraint constraint) {
  3206. if (constraint == nullptr) return nullptr;
  3207. PathConstraint *_constraint = (PathConstraint *) constraint;
  3208. return (spine_slot) _constraint->getTarget();
  3209. }
  3210. void spine_path_constraint_set_target(spine_path_constraint constraint, spine_slot target) {
  3211. if (constraint == nullptr) return;
  3212. PathConstraint *_constraint = (PathConstraint *) constraint;
  3213. _constraint->setTarget((Slot *) target);
  3214. }
  3215. float spine_path_constraint_get_position(spine_path_constraint constraint) {
  3216. if (constraint == nullptr) return 0;
  3217. PathConstraint *_constraint = (PathConstraint *) constraint;
  3218. return _constraint->getPosition();
  3219. }
  3220. void spine_path_constraint_set_position(spine_path_constraint constraint, float position) {
  3221. if (constraint == nullptr) return;
  3222. PathConstraint *_constraint = (PathConstraint *) constraint;
  3223. _constraint->setPosition(position);
  3224. }
  3225. float spine_path_constraint_get_spacing(spine_path_constraint constraint) {
  3226. if (constraint == nullptr) return 0;
  3227. PathConstraint *_constraint = (PathConstraint *) constraint;
  3228. return _constraint->getSpacing();
  3229. }
  3230. void spine_path_constraint_set_spacing(spine_path_constraint constraint, float spacing) {
  3231. if (constraint == nullptr) return;
  3232. PathConstraint *_constraint = (PathConstraint *) constraint;
  3233. _constraint->setSpacing(spacing);
  3234. }
  3235. float spine_path_constraint_get_mix_rotate(spine_path_constraint constraint) {
  3236. if (constraint == nullptr) return 0;
  3237. PathConstraint *_constraint = (PathConstraint *) constraint;
  3238. return _constraint->getMixRotate();
  3239. }
  3240. void spine_path_constraint_set_mix_rotate(spine_path_constraint constraint, float mixRotate) {
  3241. if (constraint == nullptr) return;
  3242. PathConstraint *_constraint = (PathConstraint *) constraint;
  3243. _constraint->setMixRotate(mixRotate);
  3244. }
  3245. float spine_path_constraint_get_mix_x(spine_path_constraint constraint) {
  3246. if (constraint == nullptr) return 0;
  3247. PathConstraint *_constraint = (PathConstraint *) constraint;
  3248. return _constraint->getMixX();
  3249. }
  3250. void spine_path_constraint_set_mix_x(spine_path_constraint constraint, float mixX) {
  3251. if (constraint == nullptr) return;
  3252. PathConstraint *_constraint = (PathConstraint *) constraint;
  3253. _constraint->setMixX(mixX);
  3254. }
  3255. float spine_path_constraint_get_mix_y(spine_path_constraint constraint) {
  3256. if (constraint == nullptr) return 0;
  3257. PathConstraint *_constraint = (PathConstraint *) constraint;
  3258. return _constraint->getMixY();
  3259. }
  3260. void spine_path_constraint_set_mix_y(spine_path_constraint constraint, float mixY) {
  3261. if (constraint == nullptr) return;
  3262. PathConstraint *_constraint = (PathConstraint *) constraint;
  3263. _constraint->setMixY(mixY);
  3264. }
  3265. spine_bool spine_path_constraint_get_is_active(spine_path_constraint constraint) {
  3266. if (constraint == nullptr) return 0;
  3267. PathConstraint *_constraint = (PathConstraint *) constraint;
  3268. return _constraint->isActive() ? -1 : 0;
  3269. }
  3270. void spine_path_constraint_set_is_active(spine_path_constraint constraint, spine_bool isActive) {
  3271. if (constraint == nullptr) return;
  3272. PathConstraint *_constraint = (PathConstraint *) constraint;
  3273. _constraint->setActive(isActive);
  3274. }
  3275. // PhysicsConstraintData
  3276. void spine_physics_constraint_data_set_bone(spine_physics_constraint_data data, spine_bone_data bone) {
  3277. if (data == nullptr) return;
  3278. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3279. _data->setBone((BoneData *) bone);
  3280. }
  3281. spine_bone_data spine_physics_constraint_data_get_bone(spine_physics_constraint_data data) {
  3282. if (data == nullptr) return nullptr;
  3283. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3284. return (spine_bone_data) _data->getBone();
  3285. }
  3286. void spine_physics_constraint_data_set_x(spine_physics_constraint_data data, float x) {
  3287. if (data == nullptr) return;
  3288. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3289. _data->setX(x);
  3290. }
  3291. float spine_physics_constraint_data_get_x(spine_physics_constraint_data data) {
  3292. if (data == nullptr) return 0.0f;
  3293. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3294. return _data->getX();
  3295. }
  3296. void spine_physics_constraint_data_set_y(spine_physics_constraint_data data, float y) {
  3297. if (data == nullptr) return;
  3298. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3299. _data->setY(y);
  3300. }
  3301. float spine_physics_constraint_data_get_y(spine_physics_constraint_data data) {
  3302. if (data == nullptr) return 0.0f;
  3303. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3304. return _data->getY();
  3305. }
  3306. void spine_physics_constraint_data_set_rotate(spine_physics_constraint_data data, float rotate) {
  3307. if (data == nullptr) return;
  3308. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3309. _data->setRotate(rotate);
  3310. }
  3311. float spine_physics_constraint_data_get_rotate(spine_physics_constraint_data data) {
  3312. if (data == nullptr) return 0.0f;
  3313. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3314. return _data->getRotate();
  3315. }
  3316. void spine_physics_constraint_data_set_scale_x(spine_physics_constraint_data data, float scaleX) {
  3317. if (data == nullptr) return;
  3318. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3319. _data->setScaleX(scaleX);
  3320. }
  3321. float spine_physics_constraint_data_get_scale_x(spine_physics_constraint_data data) {
  3322. if (data == nullptr) return 0.0f;
  3323. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3324. return _data->getScaleX();
  3325. }
  3326. void spine_physics_constraint_data_set_shear_x(spine_physics_constraint_data data, float shearX) {
  3327. if (data == nullptr) return;
  3328. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3329. _data->setShearX(shearX);
  3330. }
  3331. float spine_physics_constraint_data_get_shear_x(spine_physics_constraint_data data) {
  3332. if (data == nullptr) return 0.0f;
  3333. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3334. return _data->getShearX();
  3335. }
  3336. void spine_physics_constraint_data_set_limit(spine_physics_constraint_data data, float limit) {
  3337. if (data == nullptr) return;
  3338. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3339. _data->setLimit(limit);
  3340. }
  3341. float spine_physics_constraint_data_get_limit(spine_physics_constraint_data data) {
  3342. if (data == nullptr) return 0.0f;
  3343. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3344. return _data->getLimit();
  3345. }
  3346. void spine_physics_constraint_data_set_step(spine_physics_constraint_data data, float step) {
  3347. if (data == nullptr) return;
  3348. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3349. _data->setStep(step);
  3350. }
  3351. float spine_physics_constraint_data_get_step(spine_physics_constraint_data data) {
  3352. if (data == nullptr) return 0.0f;
  3353. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3354. return _data->getStep();
  3355. }
  3356. void spine_physics_constraint_data_set_inertia(spine_physics_constraint_data data, float inertia) {
  3357. if (data == nullptr) return;
  3358. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3359. _data->setInertia(inertia);
  3360. }
  3361. float spine_physics_constraint_data_get_inertia(spine_physics_constraint_data data) {
  3362. if (data == nullptr) return 0.0f;
  3363. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3364. return _data->getInertia();
  3365. }
  3366. void spine_physics_constraint_data_set_strength(spine_physics_constraint_data data, float strength) {
  3367. if (data == nullptr) return;
  3368. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3369. _data->setStrength(strength);
  3370. }
  3371. float spine_physics_constraint_data_get_strength(spine_physics_constraint_data data) {
  3372. if (data == nullptr) return 0.0f;
  3373. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3374. return _data->getStrength();
  3375. }
  3376. void spine_physics_constraint_data_set_damping(spine_physics_constraint_data data, float damping) {
  3377. if (data == nullptr) return;
  3378. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3379. _data->setDamping(damping);
  3380. }
  3381. float spine_physics_constraint_data_get_damping(spine_physics_constraint_data data) {
  3382. if (data == nullptr) return 0.0f;
  3383. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3384. return _data->getDamping();
  3385. }
  3386. void spine_physics_constraint_data_set_mass_inverse(spine_physics_constraint_data data, float massInverse) {
  3387. if (data == nullptr) return;
  3388. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3389. _data->setMassInverse(massInverse);
  3390. }
  3391. float spine_physics_constraint_data_get_mass_inverse(spine_physics_constraint_data data) {
  3392. if (data == nullptr) return 0.0f;
  3393. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3394. return _data->getMassInverse();
  3395. }
  3396. void spine_physics_constraint_data_set_wind(spine_physics_constraint_data data, float wind) {
  3397. if (data == nullptr) return;
  3398. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3399. _data->setWind(wind);
  3400. }
  3401. float spine_physics_constraint_data_get_wind(spine_physics_constraint_data data) {
  3402. if (data == nullptr) return 0.0f;
  3403. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3404. return _data->getWind();
  3405. }
  3406. void spine_physics_constraint_data_set_gravity(spine_physics_constraint_data data, float gravity) {
  3407. if (data == nullptr) return;
  3408. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3409. _data->setGravity(gravity);
  3410. }
  3411. float spine_physics_constraint_data_get_gravity(spine_physics_constraint_data data) {
  3412. if (data == nullptr) return 0.0f;
  3413. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3414. return _data->getGravity();
  3415. }
  3416. void spine_physics_constraint_data_set_mix(spine_physics_constraint_data data, float mix) {
  3417. if (data == nullptr) return;
  3418. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3419. _data->setMix(mix);
  3420. }
  3421. float spine_physics_constraint_data_get_mix(spine_physics_constraint_data data) {
  3422. if (data == nullptr) return 0.0f;
  3423. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3424. return _data->getMix();
  3425. }
  3426. void spine_physics_constraint_data_set_inertia_global(spine_physics_constraint_data data, int32_t inertiaGlobal) {
  3427. if (data == nullptr) return;
  3428. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3429. _data->setInertiaGlobal(inertiaGlobal);
  3430. }
  3431. spine_bool spine_physics_constraint_data_is_inertia_global(spine_physics_constraint_data data) {
  3432. if (data == nullptr) return false;
  3433. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3434. return _data->isInertiaGlobal();
  3435. }
  3436. void spine_physics_constraint_data_set_strength_global(spine_physics_constraint_data data, spine_bool strengthGlobal) {
  3437. if (data == nullptr) return;
  3438. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3439. _data->setStrengthGlobal(strengthGlobal);
  3440. }
  3441. spine_bool spine_physics_constraint_data_is_strength_global(spine_physics_constraint_data data) {
  3442. if (data == nullptr) return false;
  3443. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3444. return _data->isStrengthGlobal();
  3445. }
  3446. void spine_physics_constraint_data_set_damping_global(spine_physics_constraint_data data, spine_bool dampingGlobal) {
  3447. if (data == nullptr) return;
  3448. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3449. _data->setDampingGlobal(dampingGlobal);
  3450. }
  3451. spine_bool spine_physics_constraint_data_is_damping_global(spine_physics_constraint_data data) {
  3452. if (data == nullptr) return false;
  3453. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3454. return _data->isDampingGlobal();
  3455. }
  3456. void spine_physics_constraint_data_set_mass_global(spine_physics_constraint_data data, spine_bool massGlobal) {
  3457. if (data == nullptr) return;
  3458. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3459. _data->setMassGlobal(massGlobal);
  3460. }
  3461. spine_bool spine_physics_constraint_data_is_mass_global(spine_physics_constraint_data data) {
  3462. if (data == nullptr) return false;
  3463. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3464. return _data->isMassGlobal();
  3465. }
  3466. void spine_physics_constraint_data_set_wind_global(spine_physics_constraint_data data, spine_bool windGlobal) {
  3467. if (data == nullptr) return;
  3468. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3469. _data->setWindGlobal(windGlobal);
  3470. }
  3471. spine_bool spine_physics_constraint_data_is_wind_global(spine_physics_constraint_data data) {
  3472. if (data == nullptr) return false;
  3473. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3474. return _data->isWindGlobal();
  3475. }
  3476. void spine_physics_constraint_data_set_gravity_global(spine_physics_constraint_data data, spine_bool gravityGlobal) {
  3477. if (data == nullptr) return;
  3478. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3479. _data->setGravityGlobal(gravityGlobal);
  3480. }
  3481. spine_bool spine_physics_constraint_data_is_gravity_global(spine_physics_constraint_data data) {
  3482. if (data == nullptr) return false;
  3483. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3484. return _data->isGravityGlobal();
  3485. }
  3486. void spine_physics_constraint_data_set_mix_global(spine_physics_constraint_data data, spine_bool mixGlobal) {
  3487. if (data == nullptr) return;
  3488. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3489. _data->setMixGlobal(mixGlobal);
  3490. }
  3491. spine_bool spine_physics_constraint_data_is_mix_global(spine_physics_constraint_data data) {
  3492. if (data == nullptr) return false;
  3493. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3494. return _data->isMixGlobal();
  3495. }
  3496. // PhysicsConstraint
  3497. void spine_physics_constraint_set_bone(spine_physics_constraint constraint, spine_bone bone) {
  3498. if (constraint == nullptr) return;
  3499. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3500. _constraint->setBone((Bone *) bone);
  3501. }
  3502. spine_bone spine_physics_constraint_get_bone(spine_physics_constraint constraint) {
  3503. if (constraint == nullptr) return nullptr;
  3504. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3505. return (spine_bone) _constraint->getBone();
  3506. }
  3507. void spine_physics_constraint_set_inertia(spine_physics_constraint constraint, float value) {
  3508. if (constraint == nullptr) return;
  3509. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3510. _constraint->setInertia(value);
  3511. }
  3512. float spine_physics_constraint_get_inertia(spine_physics_constraint constraint) {
  3513. if (constraint == nullptr) return 0.0f;
  3514. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3515. return _constraint->getInertia();
  3516. }
  3517. void spine_physics_constraint_set_strength(spine_physics_constraint constraint, float value) {
  3518. if (constraint == nullptr) return;
  3519. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3520. _constraint->setStrength(value);
  3521. }
  3522. float spine_physics_constraint_get_strength(spine_physics_constraint constraint) {
  3523. if (constraint == nullptr) return 0.0f;
  3524. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3525. return _constraint->getStrength();
  3526. }
  3527. void spine_physics_constraint_set_damping(spine_physics_constraint constraint, float value) {
  3528. if (constraint == nullptr) return;
  3529. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3530. _constraint->setDamping(value);
  3531. }
  3532. float spine_physics_constraint_get_damping(spine_physics_constraint constraint) {
  3533. if (constraint == nullptr) return 0.0f;
  3534. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3535. return _constraint->getDamping();
  3536. }
  3537. void spine_physics_constraint_set_mass_inverse(spine_physics_constraint constraint, float value) {
  3538. if (constraint == nullptr) return;
  3539. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3540. _constraint->setMassInverse(value);
  3541. }
  3542. float spine_physics_constraint_get_mass_inverse(spine_physics_constraint constraint) {
  3543. if (constraint == nullptr) return 0.0f;
  3544. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3545. return _constraint->getMassInverse();
  3546. }
  3547. void spine_physics_constraint_set_wind(spine_physics_constraint constraint, float value) {
  3548. if (constraint == nullptr) return;
  3549. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3550. _constraint->setWind(value);
  3551. }
  3552. float spine_physics_constraint_get_wind(spine_physics_constraint constraint) {
  3553. if (constraint == nullptr) return 0.0f;
  3554. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3555. return _constraint->getWind();
  3556. }
  3557. void spine_physics_constraint_set_gravity(spine_physics_constraint constraint, float value) {
  3558. if (constraint == nullptr) return;
  3559. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3560. _constraint->setGravity(value);
  3561. }
  3562. float spine_physics_constraint_get_gravity(spine_physics_constraint constraint) {
  3563. if (constraint == nullptr) return 0.0f;
  3564. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3565. return _constraint->getGravity();
  3566. }
  3567. void spine_physics_constraint_set_mix(spine_physics_constraint constraint, float value) {
  3568. if (constraint == nullptr) return;
  3569. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3570. _constraint->setMix(value);
  3571. }
  3572. float spine_physics_constraint_get_mix(spine_physics_constraint constraint) {
  3573. if (constraint == nullptr) return 0.0f;
  3574. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3575. return _constraint->getMix();
  3576. }
  3577. void spine_physics_constraint_set_reset(spine_physics_constraint constraint, spine_bool value) {
  3578. if (constraint == nullptr) return;
  3579. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3580. _constraint->setReset(value);
  3581. }
  3582. spine_bool spine_physics_constraint_get_reset(spine_physics_constraint constraint) {
  3583. if (constraint == nullptr) return false;
  3584. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3585. return _constraint->getReset();
  3586. }
  3587. void spine_physics_constraint_set_ux(spine_physics_constraint constraint, float value) {
  3588. if (constraint == nullptr) return;
  3589. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3590. _constraint->setUx(value);
  3591. }
  3592. float spine_physics_constraint_get_ux(spine_physics_constraint constraint) {
  3593. if (constraint == nullptr) return 0.0f;
  3594. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3595. return _constraint->getUx();
  3596. }
  3597. void spine_physics_constraint_set_uy(spine_physics_constraint constraint, float value) {
  3598. if (constraint == nullptr) return;
  3599. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3600. _constraint->setUy(value);
  3601. }
  3602. float spine_physics_constraint_get_uy(spine_physics_constraint constraint) {
  3603. if (constraint == nullptr) return 0.0f;
  3604. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3605. return _constraint->getUy();
  3606. }
  3607. void spine_physics_constraint_set_cx(spine_physics_constraint constraint, float value) {
  3608. if (constraint == nullptr) return;
  3609. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3610. _constraint->setCx(value);
  3611. }
  3612. float spine_physics_constraint_get_cx(spine_physics_constraint constraint) {
  3613. if (constraint == nullptr) return 0.0f;
  3614. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3615. return _constraint->getCx();
  3616. }
  3617. void spine_physics_constraint_set_cy(spine_physics_constraint constraint, float value) {
  3618. if (constraint == nullptr) return;
  3619. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3620. _constraint->setCy(value);
  3621. }
  3622. float spine_physics_constraint_get_cy(spine_physics_constraint constraint) {
  3623. if (constraint == nullptr) return 0.0f;
  3624. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3625. return _constraint->getCy();
  3626. }
  3627. void spine_physics_constraint_set_tx(spine_physics_constraint constraint, float value) {
  3628. if (constraint == nullptr) return;
  3629. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3630. _constraint->setTx(value);
  3631. }
  3632. float spine_physics_constraint_get_tx(spine_physics_constraint constraint) {
  3633. if (constraint == nullptr) return 0.0f;
  3634. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3635. return _constraint->getTx();
  3636. }
  3637. void spine_physics_constraint_set_ty(spine_physics_constraint constraint, float value) {
  3638. if (constraint == nullptr) return;
  3639. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3640. _constraint->setTy(value);
  3641. }
  3642. float spine_physics_constraint_get_ty(spine_physics_constraint constraint) {
  3643. if (constraint == nullptr) return 0.0f;
  3644. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3645. return _constraint->getTy();
  3646. }
  3647. void spine_physics_constraint_set_x_offset(spine_physics_constraint constraint, float value) {
  3648. if (constraint == nullptr) return;
  3649. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3650. _constraint->setXOffset(value);
  3651. }
  3652. float spine_physics_constraint_get_x_offset(spine_physics_constraint constraint) {
  3653. if (constraint == nullptr) return 0.0f;
  3654. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3655. return _constraint->getXOffset();
  3656. }
  3657. void spine_physics_constraint_set_x_velocity(spine_physics_constraint constraint, float value) {
  3658. if (constraint == nullptr) return;
  3659. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3660. _constraint->setXVelocity(value);
  3661. }
  3662. float spine_physics_constraint_get_x_velocity(spine_physics_constraint constraint) {
  3663. if (constraint == nullptr) return 0.0f;
  3664. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3665. return _constraint->getXVelocity();
  3666. }
  3667. void spine_physics_constraint_set_y_offset(spine_physics_constraint constraint, float value) {
  3668. if (constraint == nullptr) return;
  3669. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3670. _constraint->setYOffset(value);
  3671. }
  3672. float spine_physics_constraint_get_y_offset(spine_physics_constraint constraint) {
  3673. if (constraint == nullptr) return 0.0f;
  3674. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3675. return _constraint->getYOffset();
  3676. }
  3677. void spine_physics_constraint_set_y_velocity(spine_physics_constraint constraint, float value) {
  3678. if (constraint == nullptr) return;
  3679. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3680. _constraint->setYVelocity(value);
  3681. }
  3682. float spine_physics_constraint_get_y_velocity(spine_physics_constraint constraint) {
  3683. if (constraint == nullptr) return 0.0f;
  3684. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3685. return _constraint->getYVelocity();
  3686. }
  3687. void spine_physics_constraint_set_rotate_offset(spine_physics_constraint constraint, float value) {
  3688. if (constraint == nullptr) return;
  3689. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3690. _constraint->setRotateOffset(value);
  3691. }
  3692. float spine_physics_constraint_get_rotate_offset(spine_physics_constraint constraint) {
  3693. if (constraint == nullptr) return 0.0f;
  3694. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3695. return _constraint->getRotateOffset();
  3696. }
  3697. void spine_physics_constraint_set_rotate_velocity(spine_physics_constraint constraint, float value) {
  3698. if (constraint == nullptr) return;
  3699. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3700. _constraint->setRotateVelocity(value);
  3701. }
  3702. float spine_physics_constraint_get_rotate_velocity(spine_physics_constraint constraint) {
  3703. if (constraint == nullptr) return 0.0f;
  3704. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3705. return _constraint->getRotateVelocity();
  3706. }
  3707. void spine_physics_constraint_set_scale_offset(spine_physics_constraint constraint, float value) {
  3708. if (constraint == nullptr) return;
  3709. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3710. _constraint->setScaleOffset(value);
  3711. }
  3712. float spine_physics_constraint_get_scale_offset(spine_physics_constraint constraint) {
  3713. if (constraint == nullptr) return 0.0f;
  3714. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3715. return _constraint->getScaleOffset();
  3716. }
  3717. void spine_physics_constraint_set_scale_velocity(spine_physics_constraint constraint, float value) {
  3718. if (constraint == nullptr) return;
  3719. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3720. _constraint->setScaleVelocity(value);
  3721. }
  3722. float spine_physics_constraint_get_scale_velocity(spine_physics_constraint constraint) {
  3723. if (constraint == nullptr) return 0.0f;
  3724. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3725. return _constraint->getScaleVelocity();
  3726. }
  3727. void spine_physics_constraint_set_active(spine_physics_constraint constraint, spine_bool value) {
  3728. if (constraint == nullptr) return;
  3729. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3730. _constraint->setActive(value);
  3731. }
  3732. spine_bool spine_physics_constraint_is_active(spine_physics_constraint constraint) {
  3733. if (constraint == nullptr) return false;
  3734. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3735. return _constraint->isActive();
  3736. }
  3737. void spine_physics_constraint_set_remaining(spine_physics_constraint constraint, float value) {
  3738. if (constraint == nullptr) return;
  3739. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3740. _constraint->setRemaining(value);
  3741. }
  3742. float spine_physics_constraint_get_remaining(spine_physics_constraint constraint) {
  3743. if (constraint == nullptr) return 0.0f;
  3744. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3745. return _constraint->getRemaining();
  3746. }
  3747. void spine_physics_constraint_set_last_time(spine_physics_constraint constraint, float value) {
  3748. if (constraint == nullptr) return;
  3749. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3750. _constraint->setLastTime(value);
  3751. }
  3752. float spine_physics_constraint_get_last_time(spine_physics_constraint constraint) {
  3753. if (constraint == nullptr) return 0.0f;
  3754. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3755. return _constraint->getLastTime();
  3756. }
  3757. void spine_physics_constraint_reset_fully(spine_physics_constraint constraint) {
  3758. if (constraint == nullptr) return;
  3759. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3760. _constraint->reset();
  3761. }
  3762. void spine_physics_constraint_update(spine_physics_constraint data, spine_physics physics) {
  3763. if (data == nullptr) return;
  3764. PhysicsConstraint *_constraint = (PhysicsConstraint *) data;
  3765. _constraint->update((spine::Physics) physics);
  3766. }
  3767. void spine_physics_constraint_translate(spine_physics_constraint data, float x, float y) {
  3768. if (data == nullptr) return;
  3769. PhysicsConstraint *_constraint = (PhysicsConstraint *) data;
  3770. _constraint->translate(x, y);
  3771. }
  3772. void spine_physics_constraint_rotate(spine_physics_constraint data, float x, float y, float degrees) {
  3773. if (data == nullptr) return;
  3774. PhysicsConstraint *_constraint = (PhysicsConstraint *) data;
  3775. _constraint->rotate(x, y, degrees);
  3776. }
  3777. // Sequence
  3778. void spine_sequence_apply(spine_sequence sequence, spine_slot slot, spine_attachment attachment) {
  3779. if (sequence == nullptr) return;
  3780. Sequence *_sequence = (Sequence *) sequence;
  3781. _sequence->apply((Slot *) slot, (Attachment *) attachment);
  3782. }
  3783. const utf8 *spine_sequence_get_path(spine_sequence sequence, const utf8 *basePath, int32_t index) {
  3784. if (sequence == nullptr) return nullptr;
  3785. Sequence *_sequence = (Sequence *) sequence;
  3786. return (utf8 *) strdup(_sequence->getPath(basePath, index).buffer());
  3787. }
  3788. int32_t spine_sequence_get_id(spine_sequence sequence) {
  3789. if (sequence == nullptr) return 0;
  3790. Sequence *_sequence = (Sequence *) sequence;
  3791. return _sequence->getId();
  3792. }
  3793. void spine_sequence_set_id(spine_sequence sequence, int32_t id) {
  3794. if (sequence == nullptr) return;
  3795. Sequence *_sequence = (Sequence *) sequence;
  3796. _sequence->setId(id);
  3797. }
  3798. int32_t spine_sequence_get_start(spine_sequence sequence) {
  3799. if (sequence == nullptr) return 0;
  3800. Sequence *_sequence = (Sequence *) sequence;
  3801. return _sequence->getStart();
  3802. }
  3803. void spine_sequence_set_start(spine_sequence sequence, int32_t start) {
  3804. if (sequence == nullptr) return;
  3805. Sequence *_sequence = (Sequence *) sequence;
  3806. _sequence->setStart(start);
  3807. }
  3808. int32_t spine_sequence_get_digits(spine_sequence sequence) {
  3809. if (sequence == nullptr) return 0;
  3810. Sequence *_sequence = (Sequence *) sequence;
  3811. return _sequence->getDigits();
  3812. }
  3813. void spine_sequence_set_digits(spine_sequence sequence, int32_t digits) {
  3814. if (sequence == nullptr) return;
  3815. Sequence *_sequence = (Sequence *) sequence;
  3816. _sequence->setDigits(digits);
  3817. }
  3818. int32_t spine_sequence_get_setup_index(spine_sequence sequence) {
  3819. if (sequence == nullptr) return 0;
  3820. Sequence *_sequence = (Sequence *) sequence;
  3821. return _sequence->getSetupIndex();
  3822. }
  3823. void spine_sequence_set_setup_index(spine_sequence sequence, int32_t setupIndex) {
  3824. if (sequence == nullptr) return;
  3825. Sequence *_sequence = (Sequence *) sequence;
  3826. _sequence->setSetupIndex(setupIndex);
  3827. }
  3828. int32_t spine_sequence_get_num_regions(spine_sequence sequence) {
  3829. if (sequence == nullptr) return 0;
  3830. Sequence *_sequence = (Sequence *) sequence;
  3831. return (int32_t) _sequence->getRegions().size();
  3832. }
  3833. spine_texture_region *spine_sequence_get_regions(spine_sequence sequence) {
  3834. if (sequence == nullptr) return nullptr;
  3835. Sequence *_sequence = (Sequence *) sequence;
  3836. return (spine_texture_region *) _sequence->getRegions().buffer();
  3837. }
  3838. // TextureRegion
  3839. void *spine_texture_region_get_texture(spine_texture_region textureRegion) {
  3840. if (textureRegion == nullptr) return nullptr;
  3841. TextureRegion *_region = (TextureRegion *) textureRegion;
  3842. return _region->rendererObject;
  3843. }
  3844. void spine_texture_region_set_texture(spine_texture_region textureRegion, void *texture) {
  3845. if (textureRegion == nullptr) return;
  3846. TextureRegion *_region = (TextureRegion *) textureRegion;
  3847. _region->rendererObject = texture;
  3848. }
  3849. float spine_texture_region_get_u(spine_texture_region textureRegion) {
  3850. if (textureRegion == nullptr) return 0;
  3851. TextureRegion *_region = (TextureRegion *) textureRegion;
  3852. return _region->u;
  3853. }
  3854. void spine_texture_region_set_u(spine_texture_region textureRegion, float u) {
  3855. if (textureRegion == nullptr) return;
  3856. TextureRegion *_region = (TextureRegion *) textureRegion;
  3857. _region->u = u;
  3858. }
  3859. float spine_texture_region_get_v(spine_texture_region textureRegion) {
  3860. if (textureRegion == nullptr) return 0;
  3861. TextureRegion *_region = (TextureRegion *) textureRegion;
  3862. return _region->v;
  3863. }
  3864. void spine_texture_region_set_v(spine_texture_region textureRegion, float v) {
  3865. if (textureRegion == nullptr) return;
  3866. TextureRegion *_region = (TextureRegion *) textureRegion;
  3867. _region->v = v;
  3868. }
  3869. float spine_texture_region_get_u2(spine_texture_region textureRegion) {
  3870. if (textureRegion == nullptr) return 0;
  3871. TextureRegion *_region = (TextureRegion *) textureRegion;
  3872. return _region->u2;
  3873. }
  3874. void spine_texture_region_set_u2(spine_texture_region textureRegion, float u2) {
  3875. if (textureRegion == nullptr) return;
  3876. TextureRegion *_region = (TextureRegion *) textureRegion;
  3877. _region->u2 = u2;
  3878. }
  3879. float spine_texture_region_get_v2(spine_texture_region textureRegion) {
  3880. if (textureRegion == nullptr) return 0;
  3881. TextureRegion *_region = (TextureRegion *) textureRegion;
  3882. return _region->v2;
  3883. }
  3884. void spine_texture_region_set_v2(spine_texture_region textureRegion, float v2) {
  3885. if (textureRegion == nullptr) return;
  3886. TextureRegion *_region = (TextureRegion *) textureRegion;
  3887. _region->v2 = v2;
  3888. }
  3889. int32_t spine_texture_region_get_degrees(spine_texture_region textureRegion) {
  3890. if (textureRegion == nullptr) return 0;
  3891. TextureRegion *_region = (TextureRegion *) textureRegion;
  3892. return _region->degrees;
  3893. }
  3894. void spine_texture_region_set_degrees(spine_texture_region textureRegion, int32_t degrees) {
  3895. if (textureRegion == nullptr) return;
  3896. TextureRegion *_region = (TextureRegion *) textureRegion;
  3897. _region->degrees = degrees;
  3898. }
  3899. float spine_texture_region_get_offset_x(spine_texture_region textureRegion) {
  3900. if (textureRegion == nullptr) return 0;
  3901. TextureRegion *_region = (TextureRegion *) textureRegion;
  3902. return _region->offsetX;
  3903. }
  3904. void spine_texture_region_set_offset_x(spine_texture_region textureRegion, float offsetX) {
  3905. if (textureRegion == nullptr) return;
  3906. TextureRegion *_region = (TextureRegion *) textureRegion;
  3907. _region->offsetX = offsetX;
  3908. }
  3909. float spine_texture_region_get_offset_y(spine_texture_region textureRegion) {
  3910. if (textureRegion == nullptr) return 0;
  3911. TextureRegion *_region = (TextureRegion *) textureRegion;
  3912. return _region->offsetY;
  3913. }
  3914. void spine_texture_region_set_offset_y(spine_texture_region textureRegion, float offsetY) {
  3915. if (textureRegion == nullptr) return;
  3916. TextureRegion *_region = (TextureRegion *) textureRegion;
  3917. _region->offsetY = offsetY;
  3918. }
  3919. int32_t spine_texture_region_get_width(spine_texture_region textureRegion) {
  3920. if (textureRegion == nullptr) return 0;
  3921. TextureRegion *_region = (TextureRegion *) textureRegion;
  3922. return _region->width;
  3923. }
  3924. void spine_texture_region_set_width(spine_texture_region textureRegion, int32_t width) {
  3925. if (textureRegion == nullptr) return;
  3926. TextureRegion *_region = (TextureRegion *) textureRegion;
  3927. _region->width = width;
  3928. }
  3929. int32_t spine_texture_region_get_height(spine_texture_region textureRegion) {
  3930. if (textureRegion == nullptr) return 0;
  3931. TextureRegion *_region = (TextureRegion *) textureRegion;
  3932. return _region->height;
  3933. }
  3934. void spine_texture_region_set_height(spine_texture_region textureRegion, int32_t height) {
  3935. if (textureRegion == nullptr) return;
  3936. TextureRegion *_region = (TextureRegion *) textureRegion;
  3937. _region->height = height;
  3938. }
  3939. int32_t spine_texture_region_get_original_width(spine_texture_region textureRegion) {
  3940. if (textureRegion == nullptr) return 0;
  3941. TextureRegion *_region = (TextureRegion *) textureRegion;
  3942. return _region->originalWidth;
  3943. }
  3944. void spine_texture_region_set_original_width(spine_texture_region textureRegion, int32_t originalWidth) {
  3945. if (textureRegion == nullptr) return;
  3946. TextureRegion *_region = (TextureRegion *) textureRegion;
  3947. _region->originalWidth = originalWidth;
  3948. }
  3949. int32_t spine_texture_region_get_original_height(spine_texture_region textureRegion) {
  3950. if (textureRegion == nullptr) return 0;
  3951. TextureRegion *_region = (TextureRegion *) textureRegion;
  3952. return _region->originalHeight;
  3953. }
  3954. void spine_texture_region_set_original_height(spine_texture_region textureRegion, int32_t originalHeight) {
  3955. if (textureRegion == nullptr) return;
  3956. TextureRegion *_region = (TextureRegion *) textureRegion;
  3957. _region->originalHeight = originalHeight;
  3958. }
  3959. spine_skeleton_bounds spine_skeleton_bounds_create() {
  3960. return (spine_skeleton_bounds) new (__FILE__, __LINE__) SkeletonBounds();
  3961. }
  3962. void spine_skeleton_bounds_dispose(spine_skeleton_bounds bounds) {
  3963. if (bounds == nullptr) return;
  3964. SkeletonBounds *_bounds = (SkeletonBounds *) bounds;
  3965. delete _bounds;
  3966. }
  3967. void spine_skeleton_bounds_update(spine_skeleton_bounds bounds, spine_skeleton skeleton, spine_bool updateAabb) {
  3968. if (bounds == nullptr) return;
  3969. if (skeleton == nullptr) return;
  3970. SkeletonBounds *_bounds = (SkeletonBounds *) bounds;
  3971. Skeleton *_skeleton = (Skeleton *) skeleton;
  3972. _bounds->update(*_skeleton, updateAabb != 0);
  3973. }
  3974. spine_bool spine_skeleton_bounds_aabb_contains_point(spine_skeleton_bounds bounds, float x, float y) {
  3975. if (bounds == nullptr) return false;
  3976. return ((SkeletonBounds *) bounds)->aabbcontainsPoint(x, y);
  3977. }
  3978. spine_bool spine_skeleton_bounds_aabb_intersects_segment(spine_skeleton_bounds bounds, float x1, float y1, float x2, float y2) {
  3979. if (bounds == nullptr) return false;
  3980. return ((SkeletonBounds *) bounds)->aabbintersectsSegment(x1, y1, x2, y2);
  3981. }
  3982. spine_bool spine_skeleton_bounds_aabb_intersects_skeleton(spine_skeleton_bounds bounds, spine_skeleton_bounds otherBounds) {
  3983. if (bounds == nullptr) return false;
  3984. if (otherBounds == nullptr) return false;
  3985. return ((SkeletonBounds *) bounds)->aabbIntersectsSkeleton(*((SkeletonBounds *) bounds));
  3986. }
  3987. spine_bool spine_skeleton_bounds_contains_point(spine_skeleton_bounds bounds, spine_polygon polygon, float x, float y) {
  3988. if (bounds == nullptr) return false;
  3989. if (polygon == nullptr) return false;
  3990. return ((SkeletonBounds *) bounds)->containsPoint((Polygon *) polygon, x, y);
  3991. }
  3992. spine_bounding_box_attachment spine_skeleton_bounds_contains_point_attachment(spine_skeleton_bounds bounds, float x, float y) {
  3993. if (bounds == nullptr) return nullptr;
  3994. return (spine_bounding_box_attachment) ((SkeletonBounds *) bounds)->containsPoint(x, y);
  3995. }
  3996. spine_bounding_box_attachment spine_skeleton_bounds_intersects_segment_attachment(spine_skeleton_bounds bounds, float x1, float y1, float x2, float y2) {
  3997. if (bounds == nullptr) return nullptr;
  3998. return (spine_bounding_box_attachment) ((SkeletonBounds *) bounds)->intersectsSegment(x1, y1, x2, y2);
  3999. }
  4000. spine_bool spine_skeleton_bounds_intersects_segment(spine_skeleton_bounds bounds, spine_polygon polygon, float x1, float y1, float x2, float y2) {
  4001. if (bounds == nullptr) return false;
  4002. if (polygon == nullptr) return false;
  4003. return ((SkeletonBounds *) bounds)->intersectsSegment((Polygon *) polygon, x1, y1, x2, y2);
  4004. }
  4005. spine_polygon spine_skeleton_bounds_get_polygon(spine_skeleton_bounds bounds, spine_bounding_box_attachment attachment) {
  4006. if (bounds == nullptr) return nullptr;
  4007. if (attachment == nullptr) return nullptr;
  4008. return (spine_polygon) ((SkeletonBounds *) bounds)->getPolygon((BoundingBoxAttachment *) attachment);
  4009. }
  4010. spine_bounding_box_attachment spine_skeleton_bounds_get_bounding_box(spine_skeleton_bounds bounds, spine_polygon polygon) {
  4011. if (bounds == nullptr) return nullptr;
  4012. if (polygon == nullptr) return nullptr;
  4013. return (spine_bounding_box_attachment) ((SkeletonBounds *) bounds)->getBoundingBox((Polygon *) polygon);
  4014. }
  4015. int32_t spine_skeleton_bounds_get_num_polygons(spine_skeleton_bounds bounds) {
  4016. if (bounds == nullptr) return 0;
  4017. return (int32_t) ((SkeletonBounds *) bounds)->getPolygons().size();
  4018. }
  4019. spine_polygon *spine_skeleton_bounds_get_polygons(spine_skeleton_bounds bounds) {
  4020. if (bounds == nullptr) return nullptr;
  4021. return (spine_polygon *) ((SkeletonBounds *) bounds)->getPolygons().buffer();
  4022. }
  4023. int32_t spine_skeleton_bounds_get_num_bounding_boxes(spine_skeleton_bounds bounds) {
  4024. if (bounds == nullptr) return 0;
  4025. return (int32_t) ((SkeletonBounds *) bounds)->getBoundingBoxes().size();
  4026. }
  4027. spine_bounding_box_attachment *spine_skeleton_bounds_get_bounding_boxes(spine_skeleton_bounds bounds) {
  4028. if (bounds == nullptr) return nullptr;
  4029. return (spine_bounding_box_attachment *) ((SkeletonBounds *) bounds)->getBoundingBoxes().buffer();
  4030. }
  4031. float spine_skeleton_bounds_get_width(spine_skeleton_bounds bounds) {
  4032. if (bounds == nullptr) return 0;
  4033. return ((SkeletonBounds *) bounds)->getWidth();
  4034. }
  4035. float spine_skeleton_bounds_get_height(spine_skeleton_bounds bounds) {
  4036. if (bounds == nullptr) return 0;
  4037. return ((SkeletonBounds *) bounds)->getHeight();
  4038. }
  4039. int32_t spine_polygon_get_num_vertices(spine_polygon polygon) {
  4040. if (polygon == nullptr) return 0;
  4041. return ((Polygon *) polygon)->_vertices.size();
  4042. }
  4043. float *spine_polygon_get_vertices(spine_polygon polygon) {
  4044. if (polygon == nullptr) return 0;
  4045. return ((Polygon *) polygon)->_vertices.buffer();
  4046. }