spine-cpp-lite.cpp 168 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843
  1. /******************************************************************************
  2. * Spine Runtimes License Agreement
  3. * Last updated April 5, 2025. Replaces all prior versions.
  4. *
  5. * Copyright (c) 2013-2025, Esoteric Software LLC
  6. *
  7. * Integration of the Spine Runtimes into software or otherwise creating
  8. * derivative works of the Spine Runtimes is permitted under the terms and
  9. * conditions of Section 2 of the Spine Editor License Agreement:
  10. * http://esotericsoftware.com/spine-editor-license
  11. *
  12. * Otherwise, it is permitted to integrate the Spine Runtimes into software
  13. * or otherwise create derivative works of the Spine Runtimes (collectively,
  14. * "Products"), provided that each user of the Products must obtain their own
  15. * Spine Editor license and redistribution of the Products in any form must
  16. * include this license and copyright notice.
  17. *
  18. * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
  19. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
  24. * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  27. * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *****************************************************************************/
  29. #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()) {
  2519. entries->numEntries++;
  2520. mapEntries.next();
  2521. }
  2522. }
  2523. {
  2524. entries->entries = SpineExtension::getInstance()->calloc<_spine_skin_entry>(entries->numEntries, __FILE__, __LINE__);
  2525. Skin::AttachmentMap::Entries mapEntries = _skin->getAttachments();
  2526. int32_t i = 0;
  2527. while (mapEntries.hasNext()) {
  2528. Skin::AttachmentMap::Entry entry = mapEntries.next();
  2529. entries->entries[i++] = {(int32_t) entry._slotIndex, (utf8 *) entry._name.buffer(), (spine_attachment) entry._attachment};
  2530. }
  2531. }
  2532. return (spine_skin_entries) entries;
  2533. }
  2534. int32_t spine_skin_entries_get_num_entries(spine_skin_entries entries) {
  2535. if (!entries) return 0;
  2536. return ((_spine_skin_entries *) entries)->numEntries;
  2537. }
  2538. spine_skin_entry spine_skin_entries_get_entry(spine_skin_entries entries, int32_t index) {
  2539. if (!entries) return 0;
  2540. return (spine_skin_entry) & ((_spine_skin_entries *) entries)->entries[index];
  2541. }
  2542. void spine_skin_entries_dispose(spine_skin_entries entries) {
  2543. if (entries == nullptr) return;
  2544. SpineExtension::getInstance()->free(((_spine_skin_entries *) entries)->entries, __FILE__, __LINE__);
  2545. SpineExtension::getInstance()->free(entries, __FILE__, __LINE__);
  2546. }
  2547. int32_t spine_skin_entry_get_slot_index(spine_skin_entry entry) {
  2548. if (!entry) return 0;
  2549. return ((_spine_skin_entry *) entry)->slotIndex;
  2550. }
  2551. utf8 *spine_skin_entry_get_name(spine_skin_entry entry) {
  2552. if (!entry) return nullptr;
  2553. return ((_spine_skin_entry *) entry)->name;
  2554. }
  2555. spine_attachment spine_skin_entry_get_attachment(spine_skin_entry entry) {
  2556. if (!entry) return nullptr;
  2557. return ((_spine_skin_entry *) entry)->attachment;
  2558. }
  2559. int32_t spine_skin_get_num_bones(spine_skin skin) {
  2560. if (skin == nullptr) return 0;
  2561. Skin *_skin = (Skin *) skin;
  2562. return (int32_t) _skin->getBones().size();
  2563. }
  2564. spine_bone_data *spine_skin_get_bones(spine_skin skin) {
  2565. if (skin == nullptr) return nullptr;
  2566. Skin *_skin = (Skin *) skin;
  2567. return (spine_bone_data *) _skin->getBones().buffer();
  2568. }
  2569. int32_t spine_skin_get_num_constraints(spine_skin skin) {
  2570. if (skin == nullptr) return 0;
  2571. Skin *_skin = (Skin *) skin;
  2572. return (int32_t) _skin->getConstraints().size();
  2573. }
  2574. spine_constraint_data *spine_skin_get_constraints(spine_skin skin) {
  2575. if (skin == nullptr) return nullptr;
  2576. Skin *_skin = (Skin *) skin;
  2577. return (spine_constraint_data *) _skin->getConstraints().buffer();
  2578. }
  2579. spine_skin spine_skin_create(const utf8 *name) {
  2580. if (name == nullptr) return nullptr;
  2581. return (spine_skin) new (__FILE__, __LINE__) Skin(name);
  2582. }
  2583. void spine_skin_dispose(spine_skin skin) {
  2584. if (skin == nullptr) return;
  2585. Skin *_skin = (Skin *) skin;
  2586. delete _skin;
  2587. }
  2588. // ConstraintData
  2589. spine_constraint_type spine_constraint_data_get_type(spine_constraint_data data) {
  2590. if (data == nullptr) return SPINE_CONSTRAINT_IK;
  2591. ConstraintData *_data = (ConstraintData *) data;
  2592. if (_data->getRTTI().isExactly(IkConstraintData::rtti)) {
  2593. return SPINE_CONSTRAINT_IK;
  2594. } else if (_data->getRTTI().isExactly(TransformConstraintData::rtti)) {
  2595. return SPINE_CONSTRAINT_TRANSFORM;
  2596. } else if (_data->getRTTI().isExactly(PathConstraintData::rtti)) {
  2597. return SPINE_CONSTRAINT_PATH;
  2598. } else {
  2599. return SPINE_CONSTRAINT_IK;
  2600. }
  2601. }
  2602. const utf8 *spine_constraint_data_get_name(spine_constraint_data data) {
  2603. if (data == nullptr) return nullptr;
  2604. ConstraintData *_data = (ConstraintData *) data;
  2605. return (utf8 *) _data->getName().buffer();
  2606. }
  2607. uint64_t spine_constraint_data_get_order(spine_constraint_data data) {
  2608. if (data == nullptr) return 0;
  2609. ConstraintData *_data = (ConstraintData *) data;
  2610. return (uint64_t) _data->getOrder();
  2611. }
  2612. void spine_constraint_data_set_order(spine_constraint_data data, uint64_t order) {
  2613. if (data == nullptr) return;
  2614. ConstraintData *_data = (ConstraintData *) data;
  2615. _data->setOrder((size_t) order);
  2616. }
  2617. spine_bool spine_constraint_data_get_is_skin_required(spine_constraint_data data) {
  2618. if (data == nullptr) return 0;
  2619. ConstraintData *_data = (ConstraintData *) data;
  2620. return _data->isSkinRequired() ? -1 : 0;
  2621. }
  2622. void spine_constraint_data_set_is_skin_required(spine_constraint_data data, spine_bool isSkinRequired) {
  2623. if (data == nullptr) return;
  2624. ConstraintData *_data = (ConstraintData *) data;
  2625. _data->setSkinRequired(isSkinRequired);
  2626. }
  2627. // IkConstraintData
  2628. int32_t spine_ik_constraint_data_get_num_bones(spine_ik_constraint_data data) {
  2629. if (data == nullptr) return 0;
  2630. IkConstraintData *_data = (IkConstraintData *) data;
  2631. return (int32_t) _data->getBones().size();
  2632. }
  2633. spine_bone_data *spine_ik_constraint_data_get_bones(spine_ik_constraint_data data) {
  2634. if (data == nullptr) return nullptr;
  2635. IkConstraintData *_data = (IkConstraintData *) data;
  2636. return (spine_bone_data *) _data->getBones().buffer();
  2637. }
  2638. spine_bone_data spine_ik_constraint_data_get_target(spine_ik_constraint_data data) {
  2639. if (data == nullptr) return nullptr;
  2640. IkConstraintData *_data = (IkConstraintData *) data;
  2641. return (spine_bone_data) _data->getTarget();
  2642. }
  2643. void spine_ik_constraint_data_set_target(spine_ik_constraint_data data, spine_bone_data target) {
  2644. if (data == nullptr) return;
  2645. IkConstraintData *_data = (IkConstraintData *) data;
  2646. _data->setTarget((BoneData *) target);
  2647. }
  2648. int32_t spine_ik_constraint_data_get_bend_direction(spine_ik_constraint_data data) {
  2649. if (data == nullptr) return 1;
  2650. IkConstraintData *_data = (IkConstraintData *) data;
  2651. return _data->getBendDirection();
  2652. }
  2653. void spine_ik_constraint_data_set_bend_direction(spine_ik_constraint_data data, int32_t bendDirection) {
  2654. if (data == nullptr) return;
  2655. IkConstraintData *_data = (IkConstraintData *) data;
  2656. _data->setBendDirection(bendDirection);
  2657. }
  2658. spine_bool spine_ik_constraint_data_get_compress(spine_ik_constraint_data data) {
  2659. if (data == nullptr) return 0;
  2660. IkConstraintData *_data = (IkConstraintData *) data;
  2661. return _data->getCompress() ? -1 : 0;
  2662. }
  2663. void spine_ik_constraint_data_set_compress(spine_ik_constraint_data data, spine_bool compress) {
  2664. if (data == nullptr) return;
  2665. IkConstraintData *_data = (IkConstraintData *) data;
  2666. _data->setCompress(compress);
  2667. }
  2668. spine_bool spine_ik_constraint_data_get_stretch(spine_ik_constraint_data data) {
  2669. if (data == nullptr) return 0;
  2670. IkConstraintData *_data = (IkConstraintData *) data;
  2671. return _data->getStretch() ? -1 : 0;
  2672. }
  2673. void spine_ik_constraint_data_set_stretch(spine_ik_constraint_data data, spine_bool stretch) {
  2674. if (data == nullptr) return;
  2675. IkConstraintData *_data = (IkConstraintData *) data;
  2676. _data->setStretch(stretch);
  2677. }
  2678. spine_bool spine_ik_constraint_data_get_uniform(spine_ik_constraint_data data) {
  2679. if (data == nullptr) return 0;
  2680. IkConstraintData *_data = (IkConstraintData *) data;
  2681. return _data->getUniform() ? -1 : 0;
  2682. }
  2683. void spine_ik_constraint_data_set_uniform(spine_ik_constraint_data data, spine_bool uniform) {
  2684. if (data == nullptr) return;
  2685. IkConstraintData *_data = (IkConstraintData *) data;
  2686. _data->setUniform(uniform);
  2687. }
  2688. float spine_ik_constraint_data_get_mix(spine_ik_constraint_data data) {
  2689. if (data == nullptr) return 0;
  2690. IkConstraintData *_data = (IkConstraintData *) data;
  2691. return _data->getMix();
  2692. }
  2693. void spine_ik_constraint_data_set_mix(spine_ik_constraint_data data, float mix) {
  2694. if (data == nullptr) return;
  2695. IkConstraintData *_data = (IkConstraintData *) data;
  2696. _data->setMix(mix);
  2697. }
  2698. float spine_ik_constraint_data_get_softness(spine_ik_constraint_data data) {
  2699. if (data == nullptr) return 0;
  2700. IkConstraintData *_data = (IkConstraintData *) data;
  2701. return _data->getSoftness();
  2702. }
  2703. void spine_ik_constraint_data_set_softness(spine_ik_constraint_data data, float softness) {
  2704. if (data == nullptr) return;
  2705. IkConstraintData *_data = (IkConstraintData *) data;
  2706. _data->setSoftness(softness);
  2707. }
  2708. // IKConstraint
  2709. void spine_ik_constraint_update(spine_ik_constraint constraint) {
  2710. if (constraint == nullptr) return;
  2711. IkConstraint *_constraint = (IkConstraint *) constraint;
  2712. _constraint->update(spine::Physics_Update);
  2713. }
  2714. int32_t spine_ik_constraint_get_order(spine_ik_constraint constraint) {
  2715. if (constraint == nullptr) return 0;
  2716. IkConstraint *_constraint = (IkConstraint *) constraint;
  2717. return _constraint->getOrder();
  2718. }
  2719. spine_ik_constraint_data spine_ik_constraint_get_data(spine_ik_constraint constraint) {
  2720. if (constraint == nullptr) return nullptr;
  2721. IkConstraint *_constraint = (IkConstraint *) constraint;
  2722. return (spine_ik_constraint_data) &_constraint->getData();
  2723. }
  2724. int32_t spine_ik_constraint_get_num_bones(spine_ik_constraint constraint) {
  2725. if (constraint == nullptr) return 0;
  2726. IkConstraint *_constraint = (IkConstraint *) constraint;
  2727. return (int32_t) _constraint->getBones().size();
  2728. }
  2729. spine_bone *spine_ik_constraint_get_bones(spine_ik_constraint constraint) {
  2730. if (constraint == nullptr) return nullptr;
  2731. IkConstraint *_constraint = (IkConstraint *) constraint;
  2732. return (spine_bone *) _constraint->getBones().buffer();
  2733. }
  2734. spine_bone spine_ik_constraint_get_target(spine_ik_constraint constraint) {
  2735. if (constraint == nullptr) return nullptr;
  2736. IkConstraint *_constraint = (IkConstraint *) constraint;
  2737. return (spine_bone) _constraint->getTarget();
  2738. }
  2739. void spine_ik_constraint_set_target(spine_ik_constraint constraint, spine_bone target) {
  2740. if (constraint == nullptr) return;
  2741. IkConstraint *_constraint = (IkConstraint *) constraint;
  2742. _constraint->setTarget((Bone *) target);
  2743. }
  2744. int32_t spine_ik_constraint_get_bend_direction(spine_ik_constraint constraint) {
  2745. if (constraint == nullptr) return 1;
  2746. IkConstraint *_constraint = (IkConstraint *) constraint;
  2747. return _constraint->getBendDirection();
  2748. }
  2749. void spine_ik_constraint_set_bend_direction(spine_ik_constraint constraint, int32_t bendDirection) {
  2750. if (constraint == nullptr) return;
  2751. IkConstraint *_constraint = (IkConstraint *) constraint;
  2752. _constraint->setBendDirection(bendDirection);
  2753. }
  2754. spine_bool spine_ik_constraint_get_compress(spine_ik_constraint constraint) {
  2755. if (constraint == nullptr) return 0;
  2756. IkConstraint *_constraint = (IkConstraint *) constraint;
  2757. return _constraint->getCompress() ? -1 : 0;
  2758. }
  2759. void spine_ik_constraint_set_compress(spine_ik_constraint constraint, spine_bool compress) {
  2760. if (constraint == nullptr) return;
  2761. IkConstraint *_constraint = (IkConstraint *) constraint;
  2762. _constraint->setCompress(compress);
  2763. }
  2764. spine_bool spine_ik_constraint_get_stretch(spine_ik_constraint constraint) {
  2765. if (constraint == nullptr) return 0;
  2766. IkConstraint *_constraint = (IkConstraint *) constraint;
  2767. return _constraint->getStretch() ? -1 : 0;
  2768. }
  2769. void spine_ik_constraint_set_stretch(spine_ik_constraint constraint, spine_bool stretch) {
  2770. if (constraint == nullptr) return;
  2771. IkConstraint *_constraint = (IkConstraint *) constraint;
  2772. _constraint->setStretch(stretch);
  2773. }
  2774. float spine_ik_constraint_get_mix(spine_ik_constraint constraint) {
  2775. if (constraint == nullptr) return 0;
  2776. IkConstraint *_constraint = (IkConstraint *) constraint;
  2777. return _constraint->getMix();
  2778. }
  2779. void spine_ik_constraint_set_mix(spine_ik_constraint constraint, float mix) {
  2780. if (constraint == nullptr) return;
  2781. IkConstraint *_constraint = (IkConstraint *) constraint;
  2782. _constraint->setMix(mix);
  2783. }
  2784. float spine_ik_constraint_get_softness(spine_ik_constraint constraint) {
  2785. if (constraint == nullptr) return 0;
  2786. IkConstraint *_constraint = (IkConstraint *) constraint;
  2787. return _constraint->getSoftness();
  2788. }
  2789. void spine_ik_constraint_set_softness(spine_ik_constraint constraint, float softness) {
  2790. if (constraint == nullptr) return;
  2791. IkConstraint *_constraint = (IkConstraint *) constraint;
  2792. _constraint->setSoftness(softness);
  2793. }
  2794. spine_bool spine_ik_constraint_get_is_active(spine_ik_constraint constraint) {
  2795. if (constraint == nullptr) return 0;
  2796. IkConstraint *_constraint = (IkConstraint *) constraint;
  2797. return _constraint->isActive() ? -1 : 0;
  2798. }
  2799. void spine_ik_constraint_set_is_active(spine_ik_constraint constraint, spine_bool isActive) {
  2800. if (constraint == nullptr) return;
  2801. IkConstraint *_constraint = (IkConstraint *) constraint;
  2802. _constraint->setActive(isActive);
  2803. }
  2804. // TransformConstraintData
  2805. int32_t spine_transform_constraint_data_get_num_bones(spine_transform_constraint_data data) {
  2806. if (data == nullptr) return 0;
  2807. TransformConstraintData *_data = (TransformConstraintData *) data;
  2808. return (int32_t) _data->getBones().size();
  2809. }
  2810. spine_bone_data *spine_transform_constraint_data_get_bones(spine_transform_constraint_data data) {
  2811. if (data == nullptr) return nullptr;
  2812. TransformConstraintData *_data = (TransformConstraintData *) data;
  2813. return (spine_bone_data *) _data->getBones().buffer();
  2814. }
  2815. spine_bone_data spine_transform_constraint_data_get_target(spine_transform_constraint_data data) {
  2816. if (data == nullptr) return nullptr;
  2817. TransformConstraintData *_data = (TransformConstraintData *) data;
  2818. return (spine_bone_data) _data->getTarget();
  2819. }
  2820. void spine_transform_constraint_data_set_target(spine_transform_constraint_data data, spine_bone_data target) {
  2821. if (data == nullptr) return;
  2822. TransformConstraintData *_data = (TransformConstraintData *) data;
  2823. _data->setTarget((BoneData *) target);
  2824. }
  2825. float spine_transform_constraint_data_get_mix_rotate(spine_transform_constraint_data data) {
  2826. if (data == nullptr) return 0;
  2827. TransformConstraintData *_data = (TransformConstraintData *) data;
  2828. return _data->getMixRotate();
  2829. }
  2830. void spine_transform_constraint_data_set_mix_rotate(spine_transform_constraint_data data, float mixRotate) {
  2831. if (data == nullptr) return;
  2832. TransformConstraintData *_data = (TransformConstraintData *) data;
  2833. _data->setMixRotate(mixRotate);
  2834. }
  2835. float spine_transform_constraint_data_get_mix_x(spine_transform_constraint_data data) {
  2836. if (data == nullptr) return 0;
  2837. TransformConstraintData *_data = (TransformConstraintData *) data;
  2838. return _data->getMixX();
  2839. }
  2840. void spine_transform_constraint_data_set_mix_x(spine_transform_constraint_data data, float mixX) {
  2841. if (data == nullptr) return;
  2842. TransformConstraintData *_data = (TransformConstraintData *) data;
  2843. _data->setMixX(mixX);
  2844. }
  2845. float spine_transform_constraint_data_get_mix_y(spine_transform_constraint_data data) {
  2846. if (data == nullptr) return 0;
  2847. TransformConstraintData *_data = (TransformConstraintData *) data;
  2848. return _data->getMixY();
  2849. }
  2850. void spine_transform_constraint_data_set_mix_y(spine_transform_constraint_data data, float mixY) {
  2851. if (data == nullptr) return;
  2852. TransformConstraintData *_data = (TransformConstraintData *) data;
  2853. _data->setMixY(mixY);
  2854. }
  2855. float spine_transform_constraint_data_get_mix_scale_x(spine_transform_constraint_data data) {
  2856. if (data == nullptr) return 0;
  2857. TransformConstraintData *_data = (TransformConstraintData *) data;
  2858. return _data->getMixScaleX();
  2859. }
  2860. void spine_transform_constraint_data_set_mix_scale_x(spine_transform_constraint_data data, float mixScaleX) {
  2861. if (data == nullptr) return;
  2862. TransformConstraintData *_data = (TransformConstraintData *) data;
  2863. _data->setMixScaleX(mixScaleX);
  2864. }
  2865. float spine_transform_constraint_data_get_mix_scale_y(spine_transform_constraint_data data) {
  2866. if (data == nullptr) return 0;
  2867. TransformConstraintData *_data = (TransformConstraintData *) data;
  2868. return _data->getMixScaleY();
  2869. }
  2870. void spine_transform_constraint_data_set_mix_scale_y(spine_transform_constraint_data data, float mixScaleY) {
  2871. if (data == nullptr) return;
  2872. TransformConstraintData *_data = (TransformConstraintData *) data;
  2873. _data->setMixScaleY(mixScaleY);
  2874. }
  2875. float spine_transform_constraint_data_get_mix_shear_y(spine_transform_constraint_data data) {
  2876. if (data == nullptr) return 0;
  2877. TransformConstraintData *_data = (TransformConstraintData *) data;
  2878. return _data->getMixShearY();
  2879. }
  2880. void spine_transform_constraint_data_set_mix_shear_y(spine_transform_constraint_data data, float mixShearY) {
  2881. if (data == nullptr) return;
  2882. TransformConstraintData *_data = (TransformConstraintData *) data;
  2883. _data->setMixShearY(mixShearY);
  2884. }
  2885. float spine_transform_constraint_data_get_offset_rotation(spine_transform_constraint_data data) {
  2886. if (data == nullptr) return 0;
  2887. TransformConstraintData *_data = (TransformConstraintData *) data;
  2888. return _data->getOffsetRotation();
  2889. }
  2890. void spine_transform_constraint_data_set_offset_rotation(spine_transform_constraint_data data, float offsetRotation) {
  2891. if (data == nullptr) return;
  2892. TransformConstraintData *_data = (TransformConstraintData *) data;
  2893. _data->setOffsetRotation(offsetRotation);
  2894. }
  2895. float spine_transform_constraint_data_get_offset_x(spine_transform_constraint_data data) {
  2896. if (data == nullptr) return 0;
  2897. TransformConstraintData *_data = (TransformConstraintData *) data;
  2898. return _data->getOffsetX();
  2899. }
  2900. void spine_transform_constraint_data_set_offset_x(spine_transform_constraint_data data, float offsetX) {
  2901. if (data == nullptr) return;
  2902. TransformConstraintData *_data = (TransformConstraintData *) data;
  2903. _data->setOffsetX(offsetX);
  2904. }
  2905. float spine_transform_constraint_data_get_offset_y(spine_transform_constraint_data data) {
  2906. if (data == nullptr) return 0;
  2907. TransformConstraintData *_data = (TransformConstraintData *) data;
  2908. return _data->getOffsetY();
  2909. }
  2910. void spine_transform_constraint_data_set_offset_y(spine_transform_constraint_data data, float offsetY) {
  2911. if (data == nullptr) return;
  2912. TransformConstraintData *_data = (TransformConstraintData *) data;
  2913. _data->setOffsetY(offsetY);
  2914. }
  2915. float spine_transform_constraint_data_get_offset_scale_x(spine_transform_constraint_data data) {
  2916. if (data == nullptr) return 0;
  2917. TransformConstraintData *_data = (TransformConstraintData *) data;
  2918. return _data->getOffsetScaleX();
  2919. }
  2920. void spine_transform_constraint_data_set_offset_scale_x(spine_transform_constraint_data data, float offsetScaleX) {
  2921. if (data == nullptr) return;
  2922. TransformConstraintData *_data = (TransformConstraintData *) data;
  2923. _data->setOffsetScaleX(offsetScaleX);
  2924. }
  2925. float spine_transform_constraint_data_get_offset_scale_y(spine_transform_constraint_data data) {
  2926. if (data == nullptr) return 0;
  2927. TransformConstraintData *_data = (TransformConstraintData *) data;
  2928. return _data->getOffsetScaleY();
  2929. }
  2930. void spine_transform_constraint_data_set_offset_scale_y(spine_transform_constraint_data data, float offsetScaleY) {
  2931. if (data == nullptr) return;
  2932. TransformConstraintData *_data = (TransformConstraintData *) data;
  2933. _data->setOffsetScaleY(offsetScaleY);
  2934. }
  2935. float spine_transform_constraint_data_get_offset_shear_y(spine_transform_constraint_data data) {
  2936. if (data == nullptr) return 0;
  2937. TransformConstraintData *_data = (TransformConstraintData *) data;
  2938. return _data->getOffsetShearY();
  2939. }
  2940. void spine_transform_constraint_data_set_offset_shear_y(spine_transform_constraint_data data, float offsetShearY) {
  2941. if (data == nullptr) return;
  2942. TransformConstraintData *_data = (TransformConstraintData *) data;
  2943. _data->setOffsetShearY(offsetShearY);
  2944. }
  2945. spine_bool spine_transform_constraint_data_get_is_relative(spine_transform_constraint_data data) {
  2946. if (data == nullptr) return 0;
  2947. TransformConstraintData *_data = (TransformConstraintData *) data;
  2948. return _data->isRelative() ? -1 : 0;
  2949. }
  2950. void spine_transform_constraint_data_set_is_relative(spine_transform_constraint_data data, spine_bool isRelative) {
  2951. if (data == nullptr) return;
  2952. TransformConstraintData *_data = (TransformConstraintData *) data;
  2953. _data->setRelative(isRelative);
  2954. }
  2955. spine_bool spine_transform_constraint_data_get_is_local(spine_transform_constraint_data data) {
  2956. if (data == nullptr) return 0;
  2957. TransformConstraintData *_data = (TransformConstraintData *) data;
  2958. return _data->isLocal() ? -1 : 0;
  2959. }
  2960. void spine_transform_constraint_data_set_is_local(spine_transform_constraint_data data, spine_bool isLocal) {
  2961. if (data == nullptr) return;
  2962. TransformConstraintData *_data = (TransformConstraintData *) data;
  2963. _data->setLocal(isLocal);
  2964. }
  2965. // TransformConstraint
  2966. void spine_transform_constraint_update(spine_transform_constraint constraint) {
  2967. if (constraint == nullptr) return;
  2968. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2969. _constraint->update(spine::Physics_Update);
  2970. }
  2971. int32_t spine_transform_constraint_get_order(spine_transform_constraint constraint) {
  2972. if (constraint == nullptr) return 0;
  2973. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2974. return _constraint->getOrder();
  2975. }
  2976. spine_transform_constraint_data spine_transform_constraint_get_data(spine_transform_constraint constraint) {
  2977. if (constraint == nullptr) return nullptr;
  2978. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2979. return (spine_transform_constraint_data) &_constraint->getData();
  2980. }
  2981. int32_t spine_transform_constraint_get_num_bones(spine_transform_constraint constraint) {
  2982. if (constraint == nullptr) return 0;
  2983. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2984. return (int32_t) _constraint->getBones().size();
  2985. }
  2986. spine_bone *spine_transform_constraint_get_bones(spine_transform_constraint constraint) {
  2987. if (constraint == nullptr) return nullptr;
  2988. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2989. return (spine_bone *) _constraint->getBones().buffer();
  2990. }
  2991. spine_bone spine_transform_constraint_get_target(spine_transform_constraint constraint) {
  2992. if (constraint == nullptr) return nullptr;
  2993. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2994. return (spine_bone) _constraint->getTarget();
  2995. }
  2996. void spine_transform_constraint_set_target(spine_transform_constraint constraint, spine_bone target) {
  2997. if (constraint == nullptr) return;
  2998. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  2999. _constraint->setTarget((Bone *) target);
  3000. }
  3001. float spine_transform_constraint_get_mix_rotate(spine_transform_constraint constraint) {
  3002. if (constraint == nullptr) return 0;
  3003. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3004. return _constraint->getMixRotate();
  3005. }
  3006. void spine_transform_constraint_set_mix_rotate(spine_transform_constraint constraint, float mixRotate) {
  3007. if (constraint == nullptr) return;
  3008. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3009. _constraint->setMixRotate(mixRotate);
  3010. }
  3011. float spine_transform_constraint_get_mix_x(spine_transform_constraint constraint) {
  3012. if (constraint == nullptr) return 0;
  3013. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3014. return _constraint->getMixX();
  3015. }
  3016. void spine_transform_constraint_set_mix_x(spine_transform_constraint constraint, float mixX) {
  3017. if (constraint == nullptr) return;
  3018. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3019. _constraint->setMixX(mixX);
  3020. }
  3021. float spine_transform_constraint_get_mix_y(spine_transform_constraint constraint) {
  3022. if (constraint == nullptr) return 0;
  3023. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3024. return _constraint->getMixY();
  3025. }
  3026. void spine_transform_constraint_set_mix_y(spine_transform_constraint constraint, float mixY) {
  3027. if (constraint == nullptr) return;
  3028. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3029. _constraint->setMixY(mixY);
  3030. }
  3031. float spine_transform_constraint_get_mix_scale_x(spine_transform_constraint constraint) {
  3032. if (constraint == nullptr) return 0;
  3033. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3034. return _constraint->getMixScaleX();
  3035. }
  3036. void spine_transform_constraint_set_mix_scale_x(spine_transform_constraint constraint, float mixScaleX) {
  3037. if (constraint == nullptr) return;
  3038. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3039. _constraint->setMixScaleX(mixScaleX);
  3040. }
  3041. float spine_transform_constraint_get_mix_scale_y(spine_transform_constraint constraint) {
  3042. if (constraint == nullptr) return 0;
  3043. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3044. return _constraint->getMixScaleY();
  3045. }
  3046. void spine_transform_constraint_set_mix_scale_y(spine_transform_constraint constraint, float mixScaleY) {
  3047. if (constraint == nullptr) return;
  3048. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3049. _constraint->setMixScaleY(mixScaleY);
  3050. }
  3051. float spine_transform_constraint_get_mix_shear_y(spine_transform_constraint constraint) {
  3052. if (constraint == nullptr) return 0;
  3053. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3054. return _constraint->getMixShearY();
  3055. }
  3056. void spine_transform_constraint_set_mix_shear_y(spine_transform_constraint constraint, float mixShearY) {
  3057. if (constraint == nullptr) return;
  3058. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3059. _constraint->setMixShearY(mixShearY);
  3060. }
  3061. spine_bool spine_transform_constraint_get_is_active(spine_transform_constraint constraint) {
  3062. if (constraint == nullptr) return 0;
  3063. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3064. return _constraint->isActive() ? -1 : 0;
  3065. }
  3066. void spine_transform_constraint_set_is_active(spine_transform_constraint constraint, spine_bool isActive) {
  3067. if (constraint == nullptr) return;
  3068. TransformConstraint *_constraint = (TransformConstraint *) constraint;
  3069. _constraint->setActive(isActive);
  3070. }
  3071. // PathConstraintData
  3072. int32_t spine_path_constraint_data_get_num_bones(spine_path_constraint_data data) {
  3073. if (data == nullptr) return 0;
  3074. PathConstraintData *_data = (PathConstraintData *) data;
  3075. return (int32_t) _data->getBones().size();
  3076. }
  3077. spine_bone_data *spine_path_constraint_data_get_bones(spine_path_constraint_data data) {
  3078. if (data == nullptr) return nullptr;
  3079. PathConstraintData *_data = (PathConstraintData *) data;
  3080. return (spine_bone_data *) _data->getBones().buffer();
  3081. }
  3082. spine_slot_data spine_path_constraint_data_get_target(spine_path_constraint_data data) {
  3083. if (data == nullptr) return nullptr;
  3084. PathConstraintData *_data = (PathConstraintData *) data;
  3085. return (spine_slot_data) _data->getTarget();
  3086. }
  3087. void spine_path_constraint_data_set_target(spine_path_constraint_data data, spine_slot_data target) {
  3088. if (data == nullptr) return;
  3089. PathConstraintData *_data = (PathConstraintData *) data;
  3090. _data->setTarget((SlotData *) target);
  3091. }
  3092. spine_position_mode spine_path_constraint_data_get_position_mode(spine_path_constraint_data data) {
  3093. if (data == nullptr) return SPINE_POSITION_MODE_FIXED;
  3094. PathConstraintData *_data = (PathConstraintData *) data;
  3095. return (spine_position_mode) _data->getPositionMode();
  3096. }
  3097. void spine_path_constraint_data_set_position_mode(spine_path_constraint_data data, spine_position_mode positionMode) {
  3098. if (data == nullptr) return;
  3099. PathConstraintData *_data = (PathConstraintData *) data;
  3100. _data->setPositionMode((PositionMode) positionMode);
  3101. }
  3102. spine_spacing_mode spine_path_constraint_data_get_spacing_mode(spine_path_constraint_data data) {
  3103. if (data == nullptr) return SPINE_SPACING_MODE_LENGTH;
  3104. PathConstraintData *_data = (PathConstraintData *) data;
  3105. return (spine_spacing_mode) _data->getSpacingMode();
  3106. }
  3107. void spine_path_constraint_data_set_spacing_mode(spine_path_constraint_data data, spine_spacing_mode spacingMode) {
  3108. if (data == nullptr) return;
  3109. PathConstraintData *_data = (PathConstraintData *) data;
  3110. _data->setSpacingMode((SpacingMode) spacingMode);
  3111. }
  3112. spine_rotate_mode spine_path_constraint_data_get_rotate_mode(spine_path_constraint_data data) {
  3113. if (data == nullptr) return SPINE_ROTATE_MODE_TANGENT;
  3114. PathConstraintData *_data = (PathConstraintData *) data;
  3115. return (spine_rotate_mode) _data->getRotateMode();
  3116. }
  3117. void spine_path_constraint_data_set_rotate_mode(spine_path_constraint_data data, spine_rotate_mode rotateMode) {
  3118. if (data == nullptr) return;
  3119. PathConstraintData *_data = (PathConstraintData *) data;
  3120. _data->setRotateMode((RotateMode) rotateMode);
  3121. }
  3122. float spine_path_constraint_data_get_offset_rotation(spine_path_constraint_data data) {
  3123. if (data == nullptr) return 0;
  3124. PathConstraintData *_data = (PathConstraintData *) data;
  3125. return _data->getOffsetRotation();
  3126. }
  3127. void spine_path_constraint_data_set_offset_rotation(spine_path_constraint_data data, float offsetRotation) {
  3128. if (data == nullptr) return;
  3129. PathConstraintData *_data = (PathConstraintData *) data;
  3130. _data->setOffsetRotation(offsetRotation);
  3131. }
  3132. float spine_path_constraint_data_get_position(spine_path_constraint_data data) {
  3133. if (data == nullptr) return 0;
  3134. PathConstraintData *_data = (PathConstraintData *) data;
  3135. return _data->getPosition();
  3136. }
  3137. void spine_path_constraint_data_set_position(spine_path_constraint_data data, float position) {
  3138. if (data == nullptr) return;
  3139. PathConstraintData *_data = (PathConstraintData *) data;
  3140. _data->setPosition(position);
  3141. }
  3142. float spine_path_constraint_data_get_spacing(spine_path_constraint_data data) {
  3143. if (data == nullptr) return 0;
  3144. PathConstraintData *_data = (PathConstraintData *) data;
  3145. return _data->getSpacing();
  3146. }
  3147. void spine_path_constraint_data_set_spacing(spine_path_constraint_data data, float spacing) {
  3148. if (data == nullptr) return;
  3149. PathConstraintData *_data = (PathConstraintData *) data;
  3150. _data->setSpacing(spacing);
  3151. }
  3152. float spine_path_constraint_data_get_mix_rotate(spine_path_constraint_data data) {
  3153. if (data == nullptr) return 0;
  3154. PathConstraintData *_data = (PathConstraintData *) data;
  3155. return _data->getMixRotate();
  3156. }
  3157. void spine_path_constraint_data_set_mix_rotate(spine_path_constraint_data data, float mixRotate) {
  3158. if (data == nullptr) return;
  3159. PathConstraintData *_data = (PathConstraintData *) data;
  3160. _data->setMixRotate(mixRotate);
  3161. }
  3162. float spine_path_constraint_data_get_mix_x(spine_path_constraint_data data) {
  3163. if (data == nullptr) return 0;
  3164. PathConstraintData *_data = (PathConstraintData *) data;
  3165. return _data->getMixX();
  3166. }
  3167. void spine_path_constraint_data_set_mix_x(spine_path_constraint_data data, float mixX) {
  3168. if (data == nullptr) return;
  3169. PathConstraintData *_data = (PathConstraintData *) data;
  3170. _data->setMixX(mixX);
  3171. }
  3172. float spine_path_constraint_data_get_mix_y(spine_path_constraint_data data) {
  3173. if (data == nullptr) return 0;
  3174. PathConstraintData *_data = (PathConstraintData *) data;
  3175. return _data->getMixY();
  3176. }
  3177. void spine_path_constraint_data_set_mix_y(spine_path_constraint_data data, float mixY) {
  3178. if (data == nullptr) return;
  3179. PathConstraintData *_data = (PathConstraintData *) data;
  3180. _data->setMixY(mixY);
  3181. }
  3182. // PathConstraint
  3183. void spine_path_constraint_update(spine_path_constraint constraint) {
  3184. if (constraint == nullptr) return;
  3185. PathConstraint *_constraint = (PathConstraint *) constraint;
  3186. _constraint->update(spine::Physics_Update);
  3187. }
  3188. int32_t spine_path_constraint_get_order(spine_path_constraint constraint) {
  3189. if (constraint == nullptr) return 0;
  3190. PathConstraint *_constraint = (PathConstraint *) constraint;
  3191. return _constraint->getOrder();
  3192. }
  3193. spine_path_constraint_data spine_path_constraint_get_data(spine_path_constraint constraint) {
  3194. if (constraint == nullptr) return nullptr;
  3195. PathConstraint *_constraint = (PathConstraint *) constraint;
  3196. return (spine_path_constraint_data) &_constraint->getData();
  3197. }
  3198. int32_t spine_path_constraint_get_num_bones(spine_path_constraint constraint) {
  3199. if (constraint == nullptr) return 0;
  3200. PathConstraint *_constraint = (PathConstraint *) constraint;
  3201. return (int32_t) _constraint->getBones().size();
  3202. }
  3203. spine_bone *spine_path_constraint_get_bones(spine_path_constraint constraint) {
  3204. if (constraint == nullptr) return nullptr;
  3205. PathConstraint *_constraint = (PathConstraint *) constraint;
  3206. return (spine_bone *) _constraint->getBones().buffer();
  3207. }
  3208. spine_slot spine_path_constraint_get_target(spine_path_constraint constraint) {
  3209. if (constraint == nullptr) return nullptr;
  3210. PathConstraint *_constraint = (PathConstraint *) constraint;
  3211. return (spine_slot) _constraint->getTarget();
  3212. }
  3213. void spine_path_constraint_set_target(spine_path_constraint constraint, spine_slot target) {
  3214. if (constraint == nullptr) return;
  3215. PathConstraint *_constraint = (PathConstraint *) constraint;
  3216. _constraint->setTarget((Slot *) target);
  3217. }
  3218. float spine_path_constraint_get_position(spine_path_constraint constraint) {
  3219. if (constraint == nullptr) return 0;
  3220. PathConstraint *_constraint = (PathConstraint *) constraint;
  3221. return _constraint->getPosition();
  3222. }
  3223. void spine_path_constraint_set_position(spine_path_constraint constraint, float position) {
  3224. if (constraint == nullptr) return;
  3225. PathConstraint *_constraint = (PathConstraint *) constraint;
  3226. _constraint->setPosition(position);
  3227. }
  3228. float spine_path_constraint_get_spacing(spine_path_constraint constraint) {
  3229. if (constraint == nullptr) return 0;
  3230. PathConstraint *_constraint = (PathConstraint *) constraint;
  3231. return _constraint->getSpacing();
  3232. }
  3233. void spine_path_constraint_set_spacing(spine_path_constraint constraint, float spacing) {
  3234. if (constraint == nullptr) return;
  3235. PathConstraint *_constraint = (PathConstraint *) constraint;
  3236. _constraint->setSpacing(spacing);
  3237. }
  3238. float spine_path_constraint_get_mix_rotate(spine_path_constraint constraint) {
  3239. if (constraint == nullptr) return 0;
  3240. PathConstraint *_constraint = (PathConstraint *) constraint;
  3241. return _constraint->getMixRotate();
  3242. }
  3243. void spine_path_constraint_set_mix_rotate(spine_path_constraint constraint, float mixRotate) {
  3244. if (constraint == nullptr) return;
  3245. PathConstraint *_constraint = (PathConstraint *) constraint;
  3246. _constraint->setMixRotate(mixRotate);
  3247. }
  3248. float spine_path_constraint_get_mix_x(spine_path_constraint constraint) {
  3249. if (constraint == nullptr) return 0;
  3250. PathConstraint *_constraint = (PathConstraint *) constraint;
  3251. return _constraint->getMixX();
  3252. }
  3253. void spine_path_constraint_set_mix_x(spine_path_constraint constraint, float mixX) {
  3254. if (constraint == nullptr) return;
  3255. PathConstraint *_constraint = (PathConstraint *) constraint;
  3256. _constraint->setMixX(mixX);
  3257. }
  3258. float spine_path_constraint_get_mix_y(spine_path_constraint constraint) {
  3259. if (constraint == nullptr) return 0;
  3260. PathConstraint *_constraint = (PathConstraint *) constraint;
  3261. return _constraint->getMixY();
  3262. }
  3263. void spine_path_constraint_set_mix_y(spine_path_constraint constraint, float mixY) {
  3264. if (constraint == nullptr) return;
  3265. PathConstraint *_constraint = (PathConstraint *) constraint;
  3266. _constraint->setMixY(mixY);
  3267. }
  3268. spine_bool spine_path_constraint_get_is_active(spine_path_constraint constraint) {
  3269. if (constraint == nullptr) return 0;
  3270. PathConstraint *_constraint = (PathConstraint *) constraint;
  3271. return _constraint->isActive() ? -1 : 0;
  3272. }
  3273. void spine_path_constraint_set_is_active(spine_path_constraint constraint, spine_bool isActive) {
  3274. if (constraint == nullptr) return;
  3275. PathConstraint *_constraint = (PathConstraint *) constraint;
  3276. _constraint->setActive(isActive);
  3277. }
  3278. // PhysicsConstraintData
  3279. void spine_physics_constraint_data_set_bone(spine_physics_constraint_data data, spine_bone_data bone) {
  3280. if (data == nullptr) return;
  3281. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3282. _data->setBone((BoneData *) bone);
  3283. }
  3284. spine_bone_data spine_physics_constraint_data_get_bone(spine_physics_constraint_data data) {
  3285. if (data == nullptr) return nullptr;
  3286. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3287. return (spine_bone_data) _data->getBone();
  3288. }
  3289. void spine_physics_constraint_data_set_x(spine_physics_constraint_data data, float x) {
  3290. if (data == nullptr) return;
  3291. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3292. _data->setX(x);
  3293. }
  3294. float spine_physics_constraint_data_get_x(spine_physics_constraint_data data) {
  3295. if (data == nullptr) return 0.0f;
  3296. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3297. return _data->getX();
  3298. }
  3299. void spine_physics_constraint_data_set_y(spine_physics_constraint_data data, float y) {
  3300. if (data == nullptr) return;
  3301. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3302. _data->setY(y);
  3303. }
  3304. float spine_physics_constraint_data_get_y(spine_physics_constraint_data data) {
  3305. if (data == nullptr) return 0.0f;
  3306. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3307. return _data->getY();
  3308. }
  3309. void spine_physics_constraint_data_set_rotate(spine_physics_constraint_data data, float rotate) {
  3310. if (data == nullptr) return;
  3311. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3312. _data->setRotate(rotate);
  3313. }
  3314. float spine_physics_constraint_data_get_rotate(spine_physics_constraint_data data) {
  3315. if (data == nullptr) return 0.0f;
  3316. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3317. return _data->getRotate();
  3318. }
  3319. void spine_physics_constraint_data_set_scale_x(spine_physics_constraint_data data, float scaleX) {
  3320. if (data == nullptr) return;
  3321. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3322. _data->setScaleX(scaleX);
  3323. }
  3324. float spine_physics_constraint_data_get_scale_x(spine_physics_constraint_data data) {
  3325. if (data == nullptr) return 0.0f;
  3326. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3327. return _data->getScaleX();
  3328. }
  3329. void spine_physics_constraint_data_set_shear_x(spine_physics_constraint_data data, float shearX) {
  3330. if (data == nullptr) return;
  3331. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3332. _data->setShearX(shearX);
  3333. }
  3334. float spine_physics_constraint_data_get_shear_x(spine_physics_constraint_data data) {
  3335. if (data == nullptr) return 0.0f;
  3336. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3337. return _data->getShearX();
  3338. }
  3339. void spine_physics_constraint_data_set_limit(spine_physics_constraint_data data, float limit) {
  3340. if (data == nullptr) return;
  3341. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3342. _data->setLimit(limit);
  3343. }
  3344. float spine_physics_constraint_data_get_limit(spine_physics_constraint_data data) {
  3345. if (data == nullptr) return 0.0f;
  3346. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3347. return _data->getLimit();
  3348. }
  3349. void spine_physics_constraint_data_set_step(spine_physics_constraint_data data, float step) {
  3350. if (data == nullptr) return;
  3351. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3352. _data->setStep(step);
  3353. }
  3354. float spine_physics_constraint_data_get_step(spine_physics_constraint_data data) {
  3355. if (data == nullptr) return 0.0f;
  3356. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3357. return _data->getStep();
  3358. }
  3359. void spine_physics_constraint_data_set_inertia(spine_physics_constraint_data data, float inertia) {
  3360. if (data == nullptr) return;
  3361. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3362. _data->setInertia(inertia);
  3363. }
  3364. float spine_physics_constraint_data_get_inertia(spine_physics_constraint_data data) {
  3365. if (data == nullptr) return 0.0f;
  3366. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3367. return _data->getInertia();
  3368. }
  3369. void spine_physics_constraint_data_set_strength(spine_physics_constraint_data data, float strength) {
  3370. if (data == nullptr) return;
  3371. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3372. _data->setStrength(strength);
  3373. }
  3374. float spine_physics_constraint_data_get_strength(spine_physics_constraint_data data) {
  3375. if (data == nullptr) return 0.0f;
  3376. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3377. return _data->getStrength();
  3378. }
  3379. void spine_physics_constraint_data_set_damping(spine_physics_constraint_data data, float damping) {
  3380. if (data == nullptr) return;
  3381. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3382. _data->setDamping(damping);
  3383. }
  3384. float spine_physics_constraint_data_get_damping(spine_physics_constraint_data data) {
  3385. if (data == nullptr) return 0.0f;
  3386. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3387. return _data->getDamping();
  3388. }
  3389. void spine_physics_constraint_data_set_mass_inverse(spine_physics_constraint_data data, float massInverse) {
  3390. if (data == nullptr) return;
  3391. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3392. _data->setMassInverse(massInverse);
  3393. }
  3394. float spine_physics_constraint_data_get_mass_inverse(spine_physics_constraint_data data) {
  3395. if (data == nullptr) return 0.0f;
  3396. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3397. return _data->getMassInverse();
  3398. }
  3399. void spine_physics_constraint_data_set_wind(spine_physics_constraint_data data, float wind) {
  3400. if (data == nullptr) return;
  3401. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3402. _data->setWind(wind);
  3403. }
  3404. float spine_physics_constraint_data_get_wind(spine_physics_constraint_data data) {
  3405. if (data == nullptr) return 0.0f;
  3406. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3407. return _data->getWind();
  3408. }
  3409. void spine_physics_constraint_data_set_gravity(spine_physics_constraint_data data, float gravity) {
  3410. if (data == nullptr) return;
  3411. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3412. _data->setGravity(gravity);
  3413. }
  3414. float spine_physics_constraint_data_get_gravity(spine_physics_constraint_data data) {
  3415. if (data == nullptr) return 0.0f;
  3416. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3417. return _data->getGravity();
  3418. }
  3419. void spine_physics_constraint_data_set_mix(spine_physics_constraint_data data, float mix) {
  3420. if (data == nullptr) return;
  3421. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3422. _data->setMix(mix);
  3423. }
  3424. float spine_physics_constraint_data_get_mix(spine_physics_constraint_data data) {
  3425. if (data == nullptr) return 0.0f;
  3426. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3427. return _data->getMix();
  3428. }
  3429. void spine_physics_constraint_data_set_inertia_global(spine_physics_constraint_data data, int32_t inertiaGlobal) {
  3430. if (data == nullptr) return;
  3431. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3432. _data->setInertiaGlobal(inertiaGlobal);
  3433. }
  3434. spine_bool spine_physics_constraint_data_is_inertia_global(spine_physics_constraint_data data) {
  3435. if (data == nullptr) return false;
  3436. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3437. return _data->isInertiaGlobal();
  3438. }
  3439. void spine_physics_constraint_data_set_strength_global(spine_physics_constraint_data data, spine_bool strengthGlobal) {
  3440. if (data == nullptr) return;
  3441. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3442. _data->setStrengthGlobal(strengthGlobal);
  3443. }
  3444. spine_bool spine_physics_constraint_data_is_strength_global(spine_physics_constraint_data data) {
  3445. if (data == nullptr) return false;
  3446. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3447. return _data->isStrengthGlobal();
  3448. }
  3449. void spine_physics_constraint_data_set_damping_global(spine_physics_constraint_data data, spine_bool dampingGlobal) {
  3450. if (data == nullptr) return;
  3451. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3452. _data->setDampingGlobal(dampingGlobal);
  3453. }
  3454. spine_bool spine_physics_constraint_data_is_damping_global(spine_physics_constraint_data data) {
  3455. if (data == nullptr) return false;
  3456. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3457. return _data->isDampingGlobal();
  3458. }
  3459. void spine_physics_constraint_data_set_mass_global(spine_physics_constraint_data data, spine_bool massGlobal) {
  3460. if (data == nullptr) return;
  3461. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3462. _data->setMassGlobal(massGlobal);
  3463. }
  3464. spine_bool spine_physics_constraint_data_is_mass_global(spine_physics_constraint_data data) {
  3465. if (data == nullptr) return false;
  3466. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3467. return _data->isMassGlobal();
  3468. }
  3469. void spine_physics_constraint_data_set_wind_global(spine_physics_constraint_data data, spine_bool windGlobal) {
  3470. if (data == nullptr) return;
  3471. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3472. _data->setWindGlobal(windGlobal);
  3473. }
  3474. spine_bool spine_physics_constraint_data_is_wind_global(spine_physics_constraint_data data) {
  3475. if (data == nullptr) return false;
  3476. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3477. return _data->isWindGlobal();
  3478. }
  3479. void spine_physics_constraint_data_set_gravity_global(spine_physics_constraint_data data, spine_bool gravityGlobal) {
  3480. if (data == nullptr) return;
  3481. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3482. _data->setGravityGlobal(gravityGlobal);
  3483. }
  3484. spine_bool spine_physics_constraint_data_is_gravity_global(spine_physics_constraint_data data) {
  3485. if (data == nullptr) return false;
  3486. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3487. return _data->isGravityGlobal();
  3488. }
  3489. void spine_physics_constraint_data_set_mix_global(spine_physics_constraint_data data, spine_bool mixGlobal) {
  3490. if (data == nullptr) return;
  3491. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3492. _data->setMixGlobal(mixGlobal);
  3493. }
  3494. spine_bool spine_physics_constraint_data_is_mix_global(spine_physics_constraint_data data) {
  3495. if (data == nullptr) return false;
  3496. PhysicsConstraintData *_data = (PhysicsConstraintData *) data;
  3497. return _data->isMixGlobal();
  3498. }
  3499. // PhysicsConstraint
  3500. void spine_physics_constraint_set_bone(spine_physics_constraint constraint, spine_bone bone) {
  3501. if (constraint == nullptr) return;
  3502. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3503. _constraint->setBone((Bone *) bone);
  3504. }
  3505. spine_bone spine_physics_constraint_get_bone(spine_physics_constraint constraint) {
  3506. if (constraint == nullptr) return nullptr;
  3507. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3508. return (spine_bone) _constraint->getBone();
  3509. }
  3510. void spine_physics_constraint_set_inertia(spine_physics_constraint constraint, float value) {
  3511. if (constraint == nullptr) return;
  3512. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3513. _constraint->setInertia(value);
  3514. }
  3515. float spine_physics_constraint_get_inertia(spine_physics_constraint constraint) {
  3516. if (constraint == nullptr) return 0.0f;
  3517. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3518. return _constraint->getInertia();
  3519. }
  3520. void spine_physics_constraint_set_strength(spine_physics_constraint constraint, float value) {
  3521. if (constraint == nullptr) return;
  3522. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3523. _constraint->setStrength(value);
  3524. }
  3525. float spine_physics_constraint_get_strength(spine_physics_constraint constraint) {
  3526. if (constraint == nullptr) return 0.0f;
  3527. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3528. return _constraint->getStrength();
  3529. }
  3530. void spine_physics_constraint_set_damping(spine_physics_constraint constraint, float value) {
  3531. if (constraint == nullptr) return;
  3532. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3533. _constraint->setDamping(value);
  3534. }
  3535. float spine_physics_constraint_get_damping(spine_physics_constraint constraint) {
  3536. if (constraint == nullptr) return 0.0f;
  3537. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3538. return _constraint->getDamping();
  3539. }
  3540. void spine_physics_constraint_set_mass_inverse(spine_physics_constraint constraint, float value) {
  3541. if (constraint == nullptr) return;
  3542. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3543. _constraint->setMassInverse(value);
  3544. }
  3545. float spine_physics_constraint_get_mass_inverse(spine_physics_constraint constraint) {
  3546. if (constraint == nullptr) return 0.0f;
  3547. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3548. return _constraint->getMassInverse();
  3549. }
  3550. void spine_physics_constraint_set_wind(spine_physics_constraint constraint, float value) {
  3551. if (constraint == nullptr) return;
  3552. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3553. _constraint->setWind(value);
  3554. }
  3555. float spine_physics_constraint_get_wind(spine_physics_constraint constraint) {
  3556. if (constraint == nullptr) return 0.0f;
  3557. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3558. return _constraint->getWind();
  3559. }
  3560. void spine_physics_constraint_set_gravity(spine_physics_constraint constraint, float value) {
  3561. if (constraint == nullptr) return;
  3562. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3563. _constraint->setGravity(value);
  3564. }
  3565. float spine_physics_constraint_get_gravity(spine_physics_constraint constraint) {
  3566. if (constraint == nullptr) return 0.0f;
  3567. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3568. return _constraint->getGravity();
  3569. }
  3570. void spine_physics_constraint_set_mix(spine_physics_constraint constraint, float value) {
  3571. if (constraint == nullptr) return;
  3572. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3573. _constraint->setMix(value);
  3574. }
  3575. float spine_physics_constraint_get_mix(spine_physics_constraint constraint) {
  3576. if (constraint == nullptr) return 0.0f;
  3577. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3578. return _constraint->getMix();
  3579. }
  3580. void spine_physics_constraint_set_reset(spine_physics_constraint constraint, spine_bool value) {
  3581. if (constraint == nullptr) return;
  3582. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3583. _constraint->setReset(value);
  3584. }
  3585. spine_bool spine_physics_constraint_get_reset(spine_physics_constraint constraint) {
  3586. if (constraint == nullptr) return false;
  3587. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3588. return _constraint->getReset();
  3589. }
  3590. void spine_physics_constraint_set_ux(spine_physics_constraint constraint, float value) {
  3591. if (constraint == nullptr) return;
  3592. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3593. _constraint->setUx(value);
  3594. }
  3595. float spine_physics_constraint_get_ux(spine_physics_constraint constraint) {
  3596. if (constraint == nullptr) return 0.0f;
  3597. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3598. return _constraint->getUx();
  3599. }
  3600. void spine_physics_constraint_set_uy(spine_physics_constraint constraint, float value) {
  3601. if (constraint == nullptr) return;
  3602. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3603. _constraint->setUy(value);
  3604. }
  3605. float spine_physics_constraint_get_uy(spine_physics_constraint constraint) {
  3606. if (constraint == nullptr) return 0.0f;
  3607. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3608. return _constraint->getUy();
  3609. }
  3610. void spine_physics_constraint_set_cx(spine_physics_constraint constraint, float value) {
  3611. if (constraint == nullptr) return;
  3612. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3613. _constraint->setCx(value);
  3614. }
  3615. float spine_physics_constraint_get_cx(spine_physics_constraint constraint) {
  3616. if (constraint == nullptr) return 0.0f;
  3617. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3618. return _constraint->getCx();
  3619. }
  3620. void spine_physics_constraint_set_cy(spine_physics_constraint constraint, float value) {
  3621. if (constraint == nullptr) return;
  3622. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3623. _constraint->setCy(value);
  3624. }
  3625. float spine_physics_constraint_get_cy(spine_physics_constraint constraint) {
  3626. if (constraint == nullptr) return 0.0f;
  3627. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3628. return _constraint->getCy();
  3629. }
  3630. void spine_physics_constraint_set_tx(spine_physics_constraint constraint, float value) {
  3631. if (constraint == nullptr) return;
  3632. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3633. _constraint->setTx(value);
  3634. }
  3635. float spine_physics_constraint_get_tx(spine_physics_constraint constraint) {
  3636. if (constraint == nullptr) return 0.0f;
  3637. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3638. return _constraint->getTx();
  3639. }
  3640. void spine_physics_constraint_set_ty(spine_physics_constraint constraint, float value) {
  3641. if (constraint == nullptr) return;
  3642. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3643. _constraint->setTy(value);
  3644. }
  3645. float spine_physics_constraint_get_ty(spine_physics_constraint constraint) {
  3646. if (constraint == nullptr) return 0.0f;
  3647. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3648. return _constraint->getTy();
  3649. }
  3650. void spine_physics_constraint_set_x_offset(spine_physics_constraint constraint, float value) {
  3651. if (constraint == nullptr) return;
  3652. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3653. _constraint->setXOffset(value);
  3654. }
  3655. float spine_physics_constraint_get_x_offset(spine_physics_constraint constraint) {
  3656. if (constraint == nullptr) return 0.0f;
  3657. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3658. return _constraint->getXOffset();
  3659. }
  3660. void spine_physics_constraint_set_x_velocity(spine_physics_constraint constraint, float value) {
  3661. if (constraint == nullptr) return;
  3662. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3663. _constraint->setXVelocity(value);
  3664. }
  3665. float spine_physics_constraint_get_x_velocity(spine_physics_constraint constraint) {
  3666. if (constraint == nullptr) return 0.0f;
  3667. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3668. return _constraint->getXVelocity();
  3669. }
  3670. void spine_physics_constraint_set_y_offset(spine_physics_constraint constraint, float value) {
  3671. if (constraint == nullptr) return;
  3672. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3673. _constraint->setYOffset(value);
  3674. }
  3675. float spine_physics_constraint_get_y_offset(spine_physics_constraint constraint) {
  3676. if (constraint == nullptr) return 0.0f;
  3677. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3678. return _constraint->getYOffset();
  3679. }
  3680. void spine_physics_constraint_set_y_velocity(spine_physics_constraint constraint, float value) {
  3681. if (constraint == nullptr) return;
  3682. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3683. _constraint->setYVelocity(value);
  3684. }
  3685. float spine_physics_constraint_get_y_velocity(spine_physics_constraint constraint) {
  3686. if (constraint == nullptr) return 0.0f;
  3687. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3688. return _constraint->getYVelocity();
  3689. }
  3690. void spine_physics_constraint_set_rotate_offset(spine_physics_constraint constraint, float value) {
  3691. if (constraint == nullptr) return;
  3692. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3693. _constraint->setRotateOffset(value);
  3694. }
  3695. float spine_physics_constraint_get_rotate_offset(spine_physics_constraint constraint) {
  3696. if (constraint == nullptr) return 0.0f;
  3697. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3698. return _constraint->getRotateOffset();
  3699. }
  3700. void spine_physics_constraint_set_rotate_velocity(spine_physics_constraint constraint, float value) {
  3701. if (constraint == nullptr) return;
  3702. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3703. _constraint->setRotateVelocity(value);
  3704. }
  3705. float spine_physics_constraint_get_rotate_velocity(spine_physics_constraint constraint) {
  3706. if (constraint == nullptr) return 0.0f;
  3707. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3708. return _constraint->getRotateVelocity();
  3709. }
  3710. void spine_physics_constraint_set_scale_offset(spine_physics_constraint constraint, float value) {
  3711. if (constraint == nullptr) return;
  3712. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3713. _constraint->setScaleOffset(value);
  3714. }
  3715. float spine_physics_constraint_get_scale_offset(spine_physics_constraint constraint) {
  3716. if (constraint == nullptr) return 0.0f;
  3717. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3718. return _constraint->getScaleOffset();
  3719. }
  3720. void spine_physics_constraint_set_scale_velocity(spine_physics_constraint constraint, float value) {
  3721. if (constraint == nullptr) return;
  3722. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3723. _constraint->setScaleVelocity(value);
  3724. }
  3725. float spine_physics_constraint_get_scale_velocity(spine_physics_constraint constraint) {
  3726. if (constraint == nullptr) return 0.0f;
  3727. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3728. return _constraint->getScaleVelocity();
  3729. }
  3730. void spine_physics_constraint_set_active(spine_physics_constraint constraint, spine_bool value) {
  3731. if (constraint == nullptr) return;
  3732. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3733. _constraint->setActive(value);
  3734. }
  3735. spine_bool spine_physics_constraint_is_active(spine_physics_constraint constraint) {
  3736. if (constraint == nullptr) return false;
  3737. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3738. return _constraint->isActive();
  3739. }
  3740. void spine_physics_constraint_set_remaining(spine_physics_constraint constraint, float value) {
  3741. if (constraint == nullptr) return;
  3742. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3743. _constraint->setRemaining(value);
  3744. }
  3745. float spine_physics_constraint_get_remaining(spine_physics_constraint constraint) {
  3746. if (constraint == nullptr) return 0.0f;
  3747. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3748. return _constraint->getRemaining();
  3749. }
  3750. void spine_physics_constraint_set_last_time(spine_physics_constraint constraint, float value) {
  3751. if (constraint == nullptr) return;
  3752. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3753. _constraint->setLastTime(value);
  3754. }
  3755. float spine_physics_constraint_get_last_time(spine_physics_constraint constraint) {
  3756. if (constraint == nullptr) return 0.0f;
  3757. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3758. return _constraint->getLastTime();
  3759. }
  3760. void spine_physics_constraint_reset_fully(spine_physics_constraint constraint) {
  3761. if (constraint == nullptr) return;
  3762. PhysicsConstraint *_constraint = (PhysicsConstraint *) constraint;
  3763. _constraint->reset();
  3764. }
  3765. void spine_physics_constraint_update(spine_physics_constraint data, spine_physics physics) {
  3766. if (data == nullptr) return;
  3767. PhysicsConstraint *_constraint = (PhysicsConstraint *) data;
  3768. _constraint->update((spine::Physics) physics);
  3769. }
  3770. void spine_physics_constraint_translate(spine_physics_constraint data, float x, float y) {
  3771. if (data == nullptr) return;
  3772. PhysicsConstraint *_constraint = (PhysicsConstraint *) data;
  3773. _constraint->translate(x, y);
  3774. }
  3775. void spine_physics_constraint_rotate(spine_physics_constraint data, float x, float y, float degrees) {
  3776. if (data == nullptr) return;
  3777. PhysicsConstraint *_constraint = (PhysicsConstraint *) data;
  3778. _constraint->rotate(x, y, degrees);
  3779. }
  3780. // Sequence
  3781. void spine_sequence_apply(spine_sequence sequence, spine_slot slot, spine_attachment attachment) {
  3782. if (sequence == nullptr) return;
  3783. Sequence *_sequence = (Sequence *) sequence;
  3784. _sequence->apply((Slot *) slot, (Attachment *) attachment);
  3785. }
  3786. const utf8 *spine_sequence_get_path(spine_sequence sequence, const utf8 *basePath, int32_t index) {
  3787. if (sequence == nullptr) return nullptr;
  3788. Sequence *_sequence = (Sequence *) sequence;
  3789. return (utf8 *) strdup(_sequence->getPath(basePath, index).buffer());
  3790. }
  3791. int32_t spine_sequence_get_id(spine_sequence sequence) {
  3792. if (sequence == nullptr) return 0;
  3793. Sequence *_sequence = (Sequence *) sequence;
  3794. return _sequence->getId();
  3795. }
  3796. void spine_sequence_set_id(spine_sequence sequence, int32_t id) {
  3797. if (sequence == nullptr) return;
  3798. Sequence *_sequence = (Sequence *) sequence;
  3799. _sequence->setId(id);
  3800. }
  3801. int32_t spine_sequence_get_start(spine_sequence sequence) {
  3802. if (sequence == nullptr) return 0;
  3803. Sequence *_sequence = (Sequence *) sequence;
  3804. return _sequence->getStart();
  3805. }
  3806. void spine_sequence_set_start(spine_sequence sequence, int32_t start) {
  3807. if (sequence == nullptr) return;
  3808. Sequence *_sequence = (Sequence *) sequence;
  3809. _sequence->setStart(start);
  3810. }
  3811. int32_t spine_sequence_get_digits(spine_sequence sequence) {
  3812. if (sequence == nullptr) return 0;
  3813. Sequence *_sequence = (Sequence *) sequence;
  3814. return _sequence->getDigits();
  3815. }
  3816. void spine_sequence_set_digits(spine_sequence sequence, int32_t digits) {
  3817. if (sequence == nullptr) return;
  3818. Sequence *_sequence = (Sequence *) sequence;
  3819. _sequence->setDigits(digits);
  3820. }
  3821. int32_t spine_sequence_get_setup_index(spine_sequence sequence) {
  3822. if (sequence == nullptr) return 0;
  3823. Sequence *_sequence = (Sequence *) sequence;
  3824. return _sequence->getSetupIndex();
  3825. }
  3826. void spine_sequence_set_setup_index(spine_sequence sequence, int32_t setupIndex) {
  3827. if (sequence == nullptr) return;
  3828. Sequence *_sequence = (Sequence *) sequence;
  3829. _sequence->setSetupIndex(setupIndex);
  3830. }
  3831. int32_t spine_sequence_get_num_regions(spine_sequence sequence) {
  3832. if (sequence == nullptr) return 0;
  3833. Sequence *_sequence = (Sequence *) sequence;
  3834. return (int32_t) _sequence->getRegions().size();
  3835. }
  3836. spine_texture_region *spine_sequence_get_regions(spine_sequence sequence) {
  3837. if (sequence == nullptr) return nullptr;
  3838. Sequence *_sequence = (Sequence *) sequence;
  3839. return (spine_texture_region *) _sequence->getRegions().buffer();
  3840. }
  3841. // TextureRegion
  3842. void *spine_texture_region_get_texture(spine_texture_region textureRegion) {
  3843. if (textureRegion == nullptr) return nullptr;
  3844. TextureRegion *_region = (TextureRegion *) textureRegion;
  3845. return _region->rendererObject;
  3846. }
  3847. void spine_texture_region_set_texture(spine_texture_region textureRegion, void *texture) {
  3848. if (textureRegion == nullptr) return;
  3849. TextureRegion *_region = (TextureRegion *) textureRegion;
  3850. _region->rendererObject = texture;
  3851. }
  3852. float spine_texture_region_get_u(spine_texture_region textureRegion) {
  3853. if (textureRegion == nullptr) return 0;
  3854. TextureRegion *_region = (TextureRegion *) textureRegion;
  3855. return _region->u;
  3856. }
  3857. void spine_texture_region_set_u(spine_texture_region textureRegion, float u) {
  3858. if (textureRegion == nullptr) return;
  3859. TextureRegion *_region = (TextureRegion *) textureRegion;
  3860. _region->u = u;
  3861. }
  3862. float spine_texture_region_get_v(spine_texture_region textureRegion) {
  3863. if (textureRegion == nullptr) return 0;
  3864. TextureRegion *_region = (TextureRegion *) textureRegion;
  3865. return _region->v;
  3866. }
  3867. void spine_texture_region_set_v(spine_texture_region textureRegion, float v) {
  3868. if (textureRegion == nullptr) return;
  3869. TextureRegion *_region = (TextureRegion *) textureRegion;
  3870. _region->v = v;
  3871. }
  3872. float spine_texture_region_get_u2(spine_texture_region textureRegion) {
  3873. if (textureRegion == nullptr) return 0;
  3874. TextureRegion *_region = (TextureRegion *) textureRegion;
  3875. return _region->u2;
  3876. }
  3877. void spine_texture_region_set_u2(spine_texture_region textureRegion, float u2) {
  3878. if (textureRegion == nullptr) return;
  3879. TextureRegion *_region = (TextureRegion *) textureRegion;
  3880. _region->u2 = u2;
  3881. }
  3882. float spine_texture_region_get_v2(spine_texture_region textureRegion) {
  3883. if (textureRegion == nullptr) return 0;
  3884. TextureRegion *_region = (TextureRegion *) textureRegion;
  3885. return _region->v2;
  3886. }
  3887. void spine_texture_region_set_v2(spine_texture_region textureRegion, float v2) {
  3888. if (textureRegion == nullptr) return;
  3889. TextureRegion *_region = (TextureRegion *) textureRegion;
  3890. _region->v2 = v2;
  3891. }
  3892. int32_t spine_texture_region_get_degrees(spine_texture_region textureRegion) {
  3893. if (textureRegion == nullptr) return 0;
  3894. TextureRegion *_region = (TextureRegion *) textureRegion;
  3895. return _region->degrees;
  3896. }
  3897. void spine_texture_region_set_degrees(spine_texture_region textureRegion, int32_t degrees) {
  3898. if (textureRegion == nullptr) return;
  3899. TextureRegion *_region = (TextureRegion *) textureRegion;
  3900. _region->degrees = degrees;
  3901. }
  3902. float spine_texture_region_get_offset_x(spine_texture_region textureRegion) {
  3903. if (textureRegion == nullptr) return 0;
  3904. TextureRegion *_region = (TextureRegion *) textureRegion;
  3905. return _region->offsetX;
  3906. }
  3907. void spine_texture_region_set_offset_x(spine_texture_region textureRegion, float offsetX) {
  3908. if (textureRegion == nullptr) return;
  3909. TextureRegion *_region = (TextureRegion *) textureRegion;
  3910. _region->offsetX = offsetX;
  3911. }
  3912. float spine_texture_region_get_offset_y(spine_texture_region textureRegion) {
  3913. if (textureRegion == nullptr) return 0;
  3914. TextureRegion *_region = (TextureRegion *) textureRegion;
  3915. return _region->offsetY;
  3916. }
  3917. void spine_texture_region_set_offset_y(spine_texture_region textureRegion, float offsetY) {
  3918. if (textureRegion == nullptr) return;
  3919. TextureRegion *_region = (TextureRegion *) textureRegion;
  3920. _region->offsetY = offsetY;
  3921. }
  3922. int32_t spine_texture_region_get_width(spine_texture_region textureRegion) {
  3923. if (textureRegion == nullptr) return 0;
  3924. TextureRegion *_region = (TextureRegion *) textureRegion;
  3925. return _region->width;
  3926. }
  3927. void spine_texture_region_set_width(spine_texture_region textureRegion, int32_t width) {
  3928. if (textureRegion == nullptr) return;
  3929. TextureRegion *_region = (TextureRegion *) textureRegion;
  3930. _region->width = width;
  3931. }
  3932. int32_t spine_texture_region_get_height(spine_texture_region textureRegion) {
  3933. if (textureRegion == nullptr) return 0;
  3934. TextureRegion *_region = (TextureRegion *) textureRegion;
  3935. return _region->height;
  3936. }
  3937. void spine_texture_region_set_height(spine_texture_region textureRegion, int32_t height) {
  3938. if (textureRegion == nullptr) return;
  3939. TextureRegion *_region = (TextureRegion *) textureRegion;
  3940. _region->height = height;
  3941. }
  3942. int32_t spine_texture_region_get_original_width(spine_texture_region textureRegion) {
  3943. if (textureRegion == nullptr) return 0;
  3944. TextureRegion *_region = (TextureRegion *) textureRegion;
  3945. return _region->originalWidth;
  3946. }
  3947. void spine_texture_region_set_original_width(spine_texture_region textureRegion, int32_t originalWidth) {
  3948. if (textureRegion == nullptr) return;
  3949. TextureRegion *_region = (TextureRegion *) textureRegion;
  3950. _region->originalWidth = originalWidth;
  3951. }
  3952. int32_t spine_texture_region_get_original_height(spine_texture_region textureRegion) {
  3953. if (textureRegion == nullptr) return 0;
  3954. TextureRegion *_region = (TextureRegion *) textureRegion;
  3955. return _region->originalHeight;
  3956. }
  3957. void spine_texture_region_set_original_height(spine_texture_region textureRegion, int32_t originalHeight) {
  3958. if (textureRegion == nullptr) return;
  3959. TextureRegion *_region = (TextureRegion *) textureRegion;
  3960. _region->originalHeight = originalHeight;
  3961. }
  3962. spine_skeleton_bounds spine_skeleton_bounds_create() {
  3963. return (spine_skeleton_bounds) new (__FILE__, __LINE__) SkeletonBounds();
  3964. }
  3965. void spine_skeleton_bounds_dispose(spine_skeleton_bounds bounds) {
  3966. if (bounds == nullptr) return;
  3967. SkeletonBounds *_bounds = (SkeletonBounds *) bounds;
  3968. delete _bounds;
  3969. }
  3970. void spine_skeleton_bounds_update(spine_skeleton_bounds bounds, spine_skeleton skeleton, spine_bool updateAabb) {
  3971. if (bounds == nullptr) return;
  3972. if (skeleton == nullptr) return;
  3973. SkeletonBounds *_bounds = (SkeletonBounds *) bounds;
  3974. Skeleton *_skeleton = (Skeleton *) skeleton;
  3975. _bounds->update(*_skeleton, updateAabb != 0);
  3976. }
  3977. spine_bool spine_skeleton_bounds_aabb_contains_point(spine_skeleton_bounds bounds, float x, float y) {
  3978. if (bounds == nullptr) return false;
  3979. return ((SkeletonBounds *) bounds)->aabbcontainsPoint(x, y);
  3980. }
  3981. spine_bool spine_skeleton_bounds_aabb_intersects_segment(spine_skeleton_bounds bounds, float x1, float y1, float x2, float y2) {
  3982. if (bounds == nullptr) return false;
  3983. return ((SkeletonBounds *) bounds)->aabbintersectsSegment(x1, y1, x2, y2);
  3984. }
  3985. spine_bool spine_skeleton_bounds_aabb_intersects_skeleton(spine_skeleton_bounds bounds, spine_skeleton_bounds otherBounds) {
  3986. if (bounds == nullptr) return false;
  3987. if (otherBounds == nullptr) return false;
  3988. return ((SkeletonBounds *) bounds)->aabbIntersectsSkeleton(*((SkeletonBounds *) bounds));
  3989. }
  3990. spine_bool spine_skeleton_bounds_contains_point(spine_skeleton_bounds bounds, spine_polygon polygon, float x, float y) {
  3991. if (bounds == nullptr) return false;
  3992. if (polygon == nullptr) return false;
  3993. return ((SkeletonBounds *) bounds)->containsPoint((Polygon *) polygon, x, y);
  3994. }
  3995. spine_bounding_box_attachment spine_skeleton_bounds_contains_point_attachment(spine_skeleton_bounds bounds, float x, float y) {
  3996. if (bounds == nullptr) return nullptr;
  3997. return (spine_bounding_box_attachment) ((SkeletonBounds *) bounds)->containsPoint(x, y);
  3998. }
  3999. spine_bounding_box_attachment spine_skeleton_bounds_intersects_segment_attachment(spine_skeleton_bounds bounds, float x1, float y1, float x2, float y2) {
  4000. if (bounds == nullptr) return nullptr;
  4001. return (spine_bounding_box_attachment) ((SkeletonBounds *) bounds)->intersectsSegment(x1, y1, x2, y2);
  4002. }
  4003. spine_bool spine_skeleton_bounds_intersects_segment(spine_skeleton_bounds bounds, spine_polygon polygon, float x1, float y1, float x2, float y2) {
  4004. if (bounds == nullptr) return false;
  4005. if (polygon == nullptr) return false;
  4006. return ((SkeletonBounds *) bounds)->intersectsSegment((Polygon *) polygon, x1, y1, x2, y2);
  4007. }
  4008. spine_polygon spine_skeleton_bounds_get_polygon(spine_skeleton_bounds bounds, spine_bounding_box_attachment attachment) {
  4009. if (bounds == nullptr) return nullptr;
  4010. if (attachment == nullptr) return nullptr;
  4011. return (spine_polygon) ((SkeletonBounds *) bounds)->getPolygon((BoundingBoxAttachment *) attachment);
  4012. }
  4013. spine_bounding_box_attachment spine_skeleton_bounds_get_bounding_box(spine_skeleton_bounds bounds, spine_polygon polygon) {
  4014. if (bounds == nullptr) return nullptr;
  4015. if (polygon == nullptr) return nullptr;
  4016. return (spine_bounding_box_attachment) ((SkeletonBounds *) bounds)->getBoundingBox((Polygon *) polygon);
  4017. }
  4018. int32_t spine_skeleton_bounds_get_num_polygons(spine_skeleton_bounds bounds) {
  4019. if (bounds == nullptr) return 0;
  4020. return (int32_t) ((SkeletonBounds *) bounds)->getPolygons().size();
  4021. }
  4022. spine_polygon *spine_skeleton_bounds_get_polygons(spine_skeleton_bounds bounds) {
  4023. if (bounds == nullptr) return nullptr;
  4024. return (spine_polygon *) ((SkeletonBounds *) bounds)->getPolygons().buffer();
  4025. }
  4026. int32_t spine_skeleton_bounds_get_num_bounding_boxes(spine_skeleton_bounds bounds) {
  4027. if (bounds == nullptr) return 0;
  4028. return (int32_t) ((SkeletonBounds *) bounds)->getBoundingBoxes().size();
  4029. }
  4030. spine_bounding_box_attachment *spine_skeleton_bounds_get_bounding_boxes(spine_skeleton_bounds bounds) {
  4031. if (bounds == nullptr) return nullptr;
  4032. return (spine_bounding_box_attachment *) ((SkeletonBounds *) bounds)->getBoundingBoxes().buffer();
  4033. }
  4034. float spine_skeleton_bounds_get_width(spine_skeleton_bounds bounds) {
  4035. if (bounds == nullptr) return 0;
  4036. return ((SkeletonBounds *) bounds)->getWidth();
  4037. }
  4038. float spine_skeleton_bounds_get_height(spine_skeleton_bounds bounds) {
  4039. if (bounds == nullptr) return 0;
  4040. return ((SkeletonBounds *) bounds)->getHeight();
  4041. }
  4042. int32_t spine_polygon_get_num_vertices(spine_polygon polygon) {
  4043. if (polygon == nullptr) return 0;
  4044. return ((Polygon *) polygon)->_vertices.size();
  4045. }
  4046. float *spine_polygon_get_vertices(spine_polygon polygon) {
  4047. if (polygon == nullptr) return 0;
  4048. return ((Polygon *) polygon)->_vertices.buffer();
  4049. }