spine-cpp-lite.cpp 161 KB

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