spine-cpp-lite.cpp 171 KB

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